| |
| <?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| defined( 'ABSPATH' ) || exit;
|
|
|
|
|
|
|
|
|
|
|
| add_action( 'admin_menu', function() {
|
| add_management_page(
|
| 'KIC Diagnostics',
|
| 'KIC Diagnostics',
|
| 'manage_options',
|
| 'kic-diagnostics',
|
| 'kic_diagnostic_page'
|
| );
|
| } );
|
|
|
|
|
|
|
|
|
| function kic_diagnostic_page() {
|
| global $wpdb;
|
|
|
|
|
| $test_action = isset( $_GET['test'] ) ? sanitize_text_field( $_GET['test'] ) : null;
|
| $test_result = null;
|
|
|
| if ( $test_action && check_admin_referer( 'kic_diagnostic_test' ) ) {
|
| $test_result = kic_run_diagnostic_test( $test_action );
|
| }
|
|
|
| ?>
|
| <div class="wrap" style="max-width: 1400px;">
|
| <h1 style="color: #0073aa;">🔧 KIC Universal Diagnostic Tool</h1>
|
| <p style="font-size: 16px;">Click any button below to run diagnostics. This tool does NOT run automatically.</p>
|
|
|
| <!-- TEST RESULT -->
|
| <?php if ( $test_result ) : ?>
|
| <div style="background: #fff; padding: 20px; margin: 20px 0; border-left: 5px solid <?php echo $test_result['success'] ? '#28a745' : '#dc3545'; ?>;">
|
| <h2 style="margin-top: 0; color: <?php echo $test_result['success'] ? '#28a745' : '#dc3545'; ?>;">
|
| <?php echo $test_result['success'] ? '✅ Test Complete' : '❌ Test Failed'; ?>
|
| </h2>
|
|
|
| <?php if ( isset( $test_result['test'] ) && $test_result['test'] === 'explore_meta_keys' && $test_result['success'] ) : ?>
|
| <!-- Special display for meta key exploration -->
|
| <div style="background: #f9f9f9; padding: 20px; margin: 15px 0; border: 1px solid #ddd;">
|
| <h3 style="margin-top: 0;">📊 Meta Key Summary</h3>
|
| <table style="width: 100%; border-collapse: collapse;">
|
| <tr>
|
| <td style="padding: 10px; border: 1px solid #ddd;"><strong>Post Type:</strong></td>
|
| <td style="padding: 10px; border: 1px solid #ddd;"><?php echo esc_html( $test_result['post_type'] ); ?></td>
|
| </tr>
|
| <tr>
|
| <td style="padding: 10px; border: 1px solid #ddd;"><strong>Posts Analyzed:</strong></td>
|
| <td style="padding: 10px; border: 1px solid #ddd;"><?php echo $test_result['sample_size']; ?></td>
|
| </tr>
|
| <tr>
|
| <td style="padding: 10px; border: 1px solid #ddd;"><strong>Unique Meta Keys Found:</strong></td>
|
| <td style="padding: 10px; border: 1px solid #ddd; font-weight: bold; color: #0073aa;"><?php echo $test_result['total_unique_keys']; ?></td>
|
| </tr>
|
| </table>
|
| </div>
|
|
|
| <!-- Categorized Keys -->
|
| <div style="margin-top: 20px;">
|
| <h3>🗂️ Meta Keys by Category</h3>
|
|
|
| <?php foreach ( $test_result['categorized_keys'] as $category => $keys ) :
|
| if ( empty( $keys ) ) continue;
|
| $category_labels = array(
|
| 'acf' => '🎨 ACF Fields',
|
| 'wpcode' => '📝 WPCode Meta',
|
| 'kic' => '🔧 KIC Custom Fields',
|
| 'wp_core' => '⚙️ WordPress Core',
|
| 'custom' => '✨ Other Custom Fields',
|
| );
|
| ?>
|
| <details style="margin: 15px 0; background: #fff; padding: 15px; border: 1px solid #ddd;">
|
| <summary style="cursor: pointer; font-weight: bold; font-size: 16px; color: #0073aa;">
|
| <?php echo $category_labels[ $category ]; ?> (<?php echo count( $keys ); ?> keys)
|
| </summary>
|
| <table style="width: 100%; border-collapse: collapse; margin-top: 15px;">
|
| <thead>
|
| <tr style="background: #0073aa; color: #fff;">
|
| <th style="padding: 10px; text-align: left; width: 30%;">Meta Key</th>
|
| <th style="padding: 10px; text-align: left; width: 15%;">Used In</th>
|
| <th style="padding: 10px; text-align: left; width: 15%;">Value Type</th>
|
| <th style="padding: 10px; text-align: left;">Sample Value(s)</th>
|
| </tr>
|
| </thead>
|
| <tbody>
|
| <?php foreach ( $keys as $key ) :
|
| $stats = $test_result['meta_key_stats'][ $key ];
|
| ?>
|
| <tr style="border-bottom: 1px solid #ddd;">
|
| <td style="padding: 10px; font-family: monospace; background: #f9f9f9;">
|
| <?php echo esc_html( $key ); ?>
|
| </td>
|
| <td style="padding: 10px;">
|
| <?php echo $stats['count']; ?>/<?php echo $test_result['sample_size']; ?> posts
|
| </td>
|
| <td style="padding: 10px;">
|
| <?php echo esc_html( implode( ', ', array_unique( $stats['value_types'] ) ) ); ?>
|
| </td>
|
| <td style="padding: 10px; font-size: 12px; font-family: monospace;">
|
| <?php
|
| foreach ( $stats['sample_values'] as $idx => $sample ) {
|
| echo '<div style="margin: 2px 0; padding: 3px; background: #f0f0f0;">' . esc_html( $sample ) . '</div>';
|
| }
|
| ?>
|
| </td>
|
| </tr>
|
| <?php endforeach; ?>
|
| </tbody>
|
| </table>
|
| </details>
|
| <?php endforeach; ?>
|
| </div>
|
|
|
| <?php else : ?>
|
| <!-- Standard result display -->
|
| <pre style="background: #f5f5f5; padding: 15px; overflow-x: auto; max-height: 400px;"><?php echo esc_html( print_r( $test_result, true ) ); ?></pre>
|
| <?php endif; ?>
|
| </div>
|
| <?php endif; ?>
|
|
|
| <!-- DASHBOARD -->
|
| <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-top: 20px;">
|
|
|
| <!-- SYSTEM STATUS -->
|
| <div class="kic-diag-card">
|
| <h2>📊 System Status</h2>
|
| <?php
|
| $acf_active = function_exists( 'acf_add_local_field_group' );
|
| $wpcode_active = function_exists( 'wpcode' );
|
| $php_version = phpversion();
|
| $wp_version = get_bloginfo( 'version' );
|
| $memory_limit = ini_get( 'memory_limit' );
|
| ?>
|
| <table>
|
| <tr class="<?php echo $acf_active ? 'status-good' : 'status-bad'; ?>">
|
| <td><strong>ACF Plugin:</strong></td>
|
| <td><?php echo $acf_active ? '✅ Active' : '❌ Not Active'; ?></td>
|
| </tr>
|
| <tr class="<?php echo $wpcode_active ? 'status-good' : 'status-bad'; ?>">
|
| <td><strong>WPCode Plugin:</strong></td>
|
| <td><?php echo $wpcode_active ? '✅ Active' : '❌ Not Active'; ?></td>
|
| </tr>
|
| <tr>
|
| <td><strong>PHP Version:</strong></td>
|
| <td><?php echo $php_version; ?></td>
|
| </tr>
|
| <tr>
|
| <td><strong>WordPress:</strong></td>
|
| <td><?php echo $wp_version; ?></td>
|
| </tr>
|
| <tr>
|
| <td><strong>Memory Limit:</strong></td>
|
| <td><?php echo $memory_limit; ?></td>
|
| </tr>
|
| </table>
|
| </div>
|
|
|
| <!-- CUSTOM POST TYPES -->
|
| <div class="kic-diag-card">
|
| <h2>📝 Custom Post Types</h2>
|
| <?php
|
| $kic_cpts = array(
|
| 'wpcode' => 'WPCode Snippets',
|
| 'wpcode_snippets_sync' => 'WPCode Sync',
|
| );
|
| ?>
|
| <table>
|
| <?php foreach ( $kic_cpts as $cpt => $label ) :
|
| $exists = post_type_exists( $cpt );
|
| $count = wp_count_posts( $cpt );
|
| $total = 0;
|
| if ( $count ) {
|
| foreach ( get_object_vars( $count ) as $status => $num ) {
|
| $total += $num;
|
| }
|
| }
|
| ?>
|
| <tr class="<?php echo $exists ? 'status-good' : 'status-bad'; ?>">
|
| <td><strong><?php echo $label; ?>:</strong></td>
|
| <td>
|
| <?php echo $exists ? "✅ {$total} posts" : '❌ Not registered'; ?>
|
| </td>
|
| </tr>
|
| <?php endforeach; ?>
|
| </table>
|
|
|
| <a href="<?php echo wp_nonce_url( admin_url( 'tools.php?page=kic-diagnostics&test=cpt_check' ), 'kic_diagnostic_test' ); ?>" class="button">
|
| 🔍 Deep CPT Check
|
| </a>
|
| </div>
|
|
|
| <!-- ACF FIELD GROUPS -->
|
| <div class="kic-diag-card">
|
| <h2>🎨 ACF Field Groups</h2>
|
| <?php
|
| $kic_field_groups = array(
|
| 'group_wpcode_snippets_sync' => 'WPCode Snippet Data',
|
| );
|
|
|
| if ( $acf_active ) {
|
| $all_groups = acf_get_field_groups();
|
| ?>
|
| <table>
|
| <?php foreach ( $kic_field_groups as $key => $label ) :
|
| $exists = false;
|
| foreach ( $all_groups as $group ) {
|
| if ( $group['key'] === $key ) {
|
| $exists = true;
|
| break;
|
| }
|
| }
|
| ?>
|
| <tr class="<?php echo $exists ? 'status-good' : 'status-bad'; ?>">
|
| <td><strong><?php echo $label; ?>:</strong></td>
|
| <td><?php echo $exists ? '✅ Registered' : '❌ Not found'; ?></td>
|
| </tr>
|
| <?php endforeach; ?>
|
| </table>
|
|
|
| <a href="<?php echo wp_nonce_url( admin_url( 'tools.php?page=kic-diagnostics&test=acf_fields' ), 'kic_diagnostic_test' ); ?>" class="button">
|
| 🔍 View All Fields
|
| </a>
|
| <?php } else { ?>
|
| <p style="color:
|
| <?php } ?>
|
| </div>
|
|
|
| <!-- SYNC FUNCTIONS -->
|
| <div class="kic-diag-card">
|
| <h2>🔄 Sync Functions</h2>
|
| <?php
|
| $sync_functions = array(
|
| 'kic_sync_wpcode_snippet' => 'Single Snippet Sync',
|
| 'kic_sync_all_wpcode_snippets' => 'Bulk Sync',
|
| 'kic_wpcode_sync_admin_page' => 'Admin Page',
|
| );
|
| ?>
|
| <table>
|
| <?php foreach ( $sync_functions as $func => $label ) :
|
| $exists = function_exists( $func );
|
| ?>
|
| <tr class="<?php echo $exists ? 'status-good' : 'status-bad'; ?>">
|
| <td><strong><?php echo $label; ?>:</strong></td>
|
| <td><?php echo $exists ? '✅ Loaded' : '❌ Not loaded'; ?></td>
|
| </tr>
|
| <?php endforeach; ?>
|
| </table>
|
|
|
| <?php if ( function_exists( 'kic_sync_all_wpcode_snippets' ) ) : ?>
|
| <a href="<?php echo wp_nonce_url( admin_url( 'tools.php?page=kic-diagnostics&test=run_sync' ), 'kic_diagnostic_test' ); ?>" class="button button-primary">
|
| ▶️ Test Sync Now
|
| </a>
|
| <?php endif; ?>
|
| </div>
|
|
|
| <!-- REST API -->
|
| <div class="kic-diag-card">
|
| <h2>🌐 REST API</h2>
|
| <?php
|
| $rest_endpoints = array(
|
| 'wpcode-snippets-sync' => 'WPCode Sync Endpoint',
|
| );
|
| ?>
|
| <table>
|
| <?php foreach ( $rest_endpoints as $endpoint => $label ) :
|
| $url = rest_url( 'wp/v2/' . $endpoint );
|
| ?>
|
| <tr>
|
| <td><strong><?php echo $label; ?>:</strong></td>
|
| <td>
|
| <a href="<?php echo esc_url( $url ); ?>" target="_blank" style="color: #0073aa;">
|
| Test →
|
| </a>
|
| </td>
|
| </tr>
|
| <?php endforeach; ?>
|
| </table>
|
|
|
| <a href="<?php echo wp_nonce_url( admin_url( 'tools.php?page=kic-diagnostics&test=rest_api' ), 'kic_diagnostic_test' ); ?>" class="button">
|
| 🔍 Full API Check
|
| </a>
|
| </div>
|
|
|
| <!-- DATABASE CHECKER -->
|
| <div class="kic-diag-card">
|
| <h2>💾 Database Inspector</h2>
|
| <p>Check post meta and field values</p>
|
|
|
| <form method="get" action="<?php echo admin_url( 'tools.php' ); ?>">
|
| <input type="hidden" name="page" value="kic-diagnostics">
|
| <?php wp_nonce_field( 'kic_diagnostic_test' ); ?>
|
| <input type="hidden" name="test" value="check_post">
|
| <p>
|
| <label><strong>Post ID:</strong></label><br>
|
| <input type="number" name="post_id" placeholder="Enter post ID" style="width: 100%;">
|
| </p>
|
| <button type="submit" class="button">🔍 Inspect Post</button>
|
| </form>
|
| </div>
|
|
|
| <!-- META KEY EXPLORER -->
|
| <div class="kic-diag-card">
|
| <h2>🔑 Meta Key Explorer</h2>
|
| <p>See all meta keys for a post type</p>
|
|
|
| <form method="get" action="<?php echo admin_url( 'tools.php' ); ?>">
|
| <input type="hidden" name="page" value="kic-diagnostics">
|
| <?php wp_nonce_field( 'kic_diagnostic_test' ); ?>
|
| <input type="hidden" name="test" value="explore_meta_keys">
|
| <p>
|
| <label><strong>Post Type:</strong></label><br>
|
| <select name="post_type" style="width: 100%;">
|
| <option value="wpcode">WPCode Snippets</option>
|
| <option value="wpcode_snippets_sync">WPCode Sync</option>
|
| <option value="post">Posts</option>
|
| <option value="page">Pages</option>
|
| </select>
|
| </p>
|
| <p>
|
| <label><strong>Sample Size:</strong></label><br>
|
| <input type="number" name="sample_size" value="10" min="1" max="100" style="width: 100%;">
|
| </p>
|
| <button type="submit" class="button">🔍 Explore Meta Keys</button>
|
| </form>
|
| </div>
|
|
|
| </div>
|
|
|
| <!-- QUICK ACTIONS -->
|
| <div style="background: #fff; padding: 20px; margin-top: 20px; border-left: 5px solid #0073aa;">
|
| <h2 style="margin-top: 0;">⚡ Quick Actions</h2>
|
| <div style="display: flex; gap: 10px; flex-wrap: wrap;">
|
| <a href="<?php echo admin_url( 'edit.php?post_type=wpcode_snippets_sync' ); ?>" class="button">
|
| 📝 View Sync Posts
|
| </a>
|
| <a href="<?php echo admin_url( 'edit.php?post_type=wpcode_snippets_sync&page=kic-wpcode-sync' ); ?>" class="button">
|
| 🔄 Sync Now Page
|
| </a>
|
| <a href="<?php echo rest_url( 'wp/v2/wpcode-snippets-sync' ); ?>" target="_blank" class="button">
|
| 🌐 View REST API
|
| </a>
|
| <a href="<?php echo wp_nonce_url( admin_url( 'tools.php?page=kic-diagnostics&test=full_system' ), 'kic_diagnostic_test' ); ?>" class="button button-primary">
|
| 🔍 Full System Diagnostic
|
| </a>
|
| </div>
|
| </div>
|
|
|
| <!-- DOCUMENTATION -->
|
| <div style="background: #f9f9f9; padding: 20px; margin-top: 20px; border: 1px solid #ddd;">
|
| <h2 style="margin-top: 0;">📚 How to Use This Tool</h2>
|
| <ol>
|
| <li><strong>System Status:</strong> Shows if required plugins are active</li>
|
| <li><strong>CPT Check:</strong> Verifies custom post types are registered</li>
|
| <li><strong>ACF Fields:</strong> Checks if field groups exist</li>
|
| <li><strong>Sync Functions:</strong> Tests if sync code is loaded</li>
|
| <li><strong>REST API:</strong> Verifies API endpoints are working</li>
|
| <li><strong>Database Inspector:</strong> Look up any post's meta data</li>
|
| </ol>
|
| <p><strong>💡 TIP:</strong> This diagnostic tool runs ONLY when you open this page. It has zero impact on site performance when not in use!</p>
|
| </div>
|
| </div>
|
|
|
| <style>
|
| .kic-diag-card {
|
| background:
|
| padding: 20px;
|
| border: 1px solid
|
| border-radius: 4px;
|
| box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
| }
|
| .kic-diag-card h2 {
|
| margin-top: 0;
|
| color:
|
| font-size: 18px;
|
| border-bottom: 2px solid
|
| padding-bottom: 10px;
|
| }
|
| .kic-diag-card table {
|
| width: 100%;
|
| border-collapse: collapse;
|
| margin: 15px 0;
|
| }
|
| .kic-diag-card table td {
|
| padding: 8px;
|
| border-bottom: 1px solid
|
| }
|
| .kic-diag-card .button {
|
| margin-top: 10px;
|
| }
|
| .status-good {
|
| background:
|
| }
|
| .status-bad {
|
| background:
|
| }
|
| </style>
|
| <?php
|
| }
|
|
|
|
|
|
|
|
|
| function kic_run_diagnostic_test( $test ) {
|
| global $wpdb;
|
|
|
| $result = array(
|
| 'success' => true,
|
| 'test' => $test,
|
| 'timestamp' => current_time( 'mysql' ),
|
| );
|
|
|
| switch ( $test ) {
|
|
|
| case 'cpt_check':
|
| $result['cpts'] = array();
|
| $all_cpts = get_post_types( array( 'public' => true, 'show_ui' => true ), 'objects' );
|
| foreach ( $all_cpts as $cpt ) {
|
| if ( strpos( $cpt->name, 'wpcode' ) !== false || strpos( $cpt->name, 'kic_' ) !== false ) {
|
| $count = wp_count_posts( $cpt->name );
|
| $result['cpts'][ $cpt->name ] = array(
|
| 'label' => $cpt->label,
|
| 'rest_base' => $cpt->rest_base,
|
| 'show_in_rest' => $cpt->show_in_rest,
|
| 'counts' => get_object_vars( $count ),
|
| );
|
| }
|
| }
|
| break;
|
|
|
| case 'acf_fields':
|
| if ( function_exists( 'acf_get_field_groups' ) ) {
|
| $result['field_groups'] = array();
|
| $groups = acf_get_field_groups();
|
| foreach ( $groups as $group ) {
|
| $fields = acf_get_fields( $group['key'] );
|
| $result['field_groups'][ $group['key'] ] = array(
|
| 'title' => $group['title'],
|
| 'location' => $group['location'],
|
| 'field_count' => count( $fields ),
|
| 'fields' => array_map( function( $f ) {
|
| return array(
|
| 'name' => $f['name'],
|
| 'type' => $f['type'],
|
| 'label' => $f['label'],
|
| );
|
| }, $fields ),
|
| );
|
| }
|
| } else {
|
| $result['success'] = false;
|
| $result['error'] = 'ACF not active';
|
| }
|
| break;
|
|
|
| case 'run_sync':
|
| if ( function_exists( 'kic_sync_all_wpcode_snippets' ) ) {
|
| $result['sync_result'] = kic_sync_all_wpcode_snippets();
|
| } else {
|
| $result['success'] = false;
|
| $result['error'] = 'Sync function not found';
|
| }
|
| break;
|
|
|
| case 'rest_api':
|
| $endpoints = array(
|
| 'wpcode-snippets-sync',
|
| );
|
| $result['endpoints'] = array();
|
| foreach ( $endpoints as $endpoint ) {
|
| $url = rest_url( 'wp/v2/' . $endpoint );
|
| $response = wp_remote_get( $url );
|
| $result['endpoints'][ $endpoint ] = array(
|
| 'url' => $url,
|
| 'status' => wp_remote_retrieve_response_code( $response ),
|
| 'message' => wp_remote_retrieve_response_message( $response ),
|
| );
|
| }
|
| break;
|
|
|
| case 'check_post':
|
| if ( isset( $_GET['post_id'] ) ) {
|
| $post_id = intval( $_GET['post_id'] );
|
| $post = get_post( $post_id );
|
|
|
| if ( $post ) {
|
| $result['post'] = array(
|
| 'ID' => $post->ID,
|
| 'title' => $post->post_title,
|
| 'type' => $post->post_type,
|
| 'status' => $post->post_status,
|
| 'content_length' => strlen( $post->post_content ),
|
| );
|
|
|
| $result['meta'] = get_post_meta( $post_id );
|
|
|
| if ( function_exists( 'get_fields' ) ) {
|
| $result['acf_fields'] = get_fields( $post_id );
|
| }
|
| } else {
|
| $result['success'] = false;
|
| $result['error'] = 'Post not found';
|
| }
|
| }
|
| break;
|
|
|
| case 'explore_meta_keys':
|
| $post_type = isset( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : 'wpcode';
|
| $sample_size = isset( $_GET['sample_size'] ) ? intval( $_GET['sample_size'] ) : 10;
|
|
|
|
|
| $posts = get_posts( array(
|
| 'post_type' => $post_type,
|
| 'posts_per_page' => $sample_size,
|
| 'post_status' => 'any',
|
| 'orderby' => 'ID',
|
| 'order' => 'DESC',
|
| ) );
|
|
|
| if ( empty( $posts ) ) {
|
| $result['success'] = false;
|
| $result['error'] = 'No posts found for this post type';
|
| break;
|
| }
|
|
|
|
|
| $all_meta_keys = array();
|
| $meta_key_stats = array();
|
|
|
| foreach ( $posts as $post ) {
|
| $post_meta = get_post_meta( $post->ID );
|
|
|
| foreach ( $post_meta as $key => $value ) {
|
|
|
| if ( ! in_array( $key, $all_meta_keys ) ) {
|
| $all_meta_keys[] = $key;
|
| }
|
|
|
|
|
| if ( ! isset( $meta_key_stats[ $key ] ) ) {
|
| $meta_key_stats[ $key ] = array(
|
| 'count' => 0,
|
| 'sample_values' => array(),
|
| 'value_types' => array(),
|
| );
|
| }
|
|
|
| $meta_key_stats[ $key ]['count']++;
|
|
|
|
|
| if ( count( $meta_key_stats[ $key ]['sample_values'] ) < 3 ) {
|
| $sample_value = $value[0];
|
| $value_type = gettype( $sample_value );
|
|
|
| if ( is_array( $sample_value ) || is_object( $sample_value ) ) {
|
| $sample_value = '[' . $value_type . ']';
|
| } elseif ( strlen( $sample_value ) > 100 ) {
|
| $sample_value = substr( $sample_value, 0, 100 ) . '...';
|
| }
|
|
|
| $meta_key_stats[ $key ]['sample_values'][] = $sample_value;
|
| $meta_key_stats[ $key ]['value_types'][] = $value_type;
|
| }
|
| }
|
| }
|
|
|
|
|
| ksort( $meta_key_stats );
|
|
|
| $result['post_type'] = $post_type;
|
| $result['sample_size'] = count( $posts );
|
| $result['total_unique_keys'] = count( $all_meta_keys );
|
| $result['meta_keys'] = $all_meta_keys;
|
| $result['meta_key_stats'] = $meta_key_stats;
|
|
|
|
|
| $result['categorized_keys'] = array(
|
| 'acf' => array_filter( $all_meta_keys, function( $k ) { return strpos( $k, '_' ) === 0 || strpos( $k, 'field_' ) === 0; } ),
|
| 'wpcode' => array_filter( $all_meta_keys, function( $k ) { return strpos( $k, '_wpcode' ) !== false || strpos( $k, 'wpcode_' ) !== false; } ),
|
| 'kic' => array_filter( $all_meta_keys, function( $k ) { return strpos( $k, 'kic_' ) !== false; } ),
|
| 'wp_core' => array_filter( $all_meta_keys, function( $k ) { return in_array( $k, array( '_edit_lock', '_edit_last', '_wp_page_template' ) ); } ),
|
| 'custom' => array(),
|
| );
|
|
|
|
|
| foreach ( $all_meta_keys as $key ) {
|
| $is_categorized = false;
|
| foreach ( array( 'acf', 'wpcode', 'kic', 'wp_core' ) as $cat ) {
|
| if ( in_array( $key, $result['categorized_keys'][ $cat ] ) ) {
|
| $is_categorized = true;
|
| break;
|
| }
|
| }
|
| if ( ! $is_categorized ) {
|
| $result['categorized_keys']['custom'][] = $key;
|
| }
|
| }
|
|
|
| break;
|
|
|
| case 'full_system':
|
| $result['system'] = array(
|
| 'php_version' => phpversion(),
|
| 'wp_version' => get_bloginfo( 'version' ),
|
| 'memory_limit' => ini_get( 'memory_limit' ),
|
| 'max_execution_time' => ini_get( 'max_execution_time' ),
|
| 'upload_max_filesize' => ini_get( 'upload_max_filesize' ),
|
| );
|
|
|
| $result['plugins'] = array(
|
| 'acf' => function_exists( 'acf_add_local_field_group' ),
|
| 'wpcode' => function_exists( 'wpcode' ),
|
| );
|
|
|
| $result['sync_functions'] = array(
|
| 'kic_sync_wpcode_snippet' => function_exists( 'kic_sync_wpcode_snippet' ),
|
| 'kic_sync_all_wpcode_snippets' => function_exists( 'kic_sync_all_wpcode_snippets' ),
|
| );
|
|
|
|
|
| $wpcode_count = wp_count_posts( 'wpcode' );
|
| $sync_count = wp_count_posts( 'wpcode_snippets_sync' );
|
|
|
| $result['post_counts'] = array(
|
| 'wpcode' => $wpcode_count ? get_object_vars( $wpcode_count ) : array(),
|
| 'wpcode_snippets_sync' => $sync_count ? get_object_vars( $sync_count ) : array(),
|
| );
|
| break;
|
| }
|
|
|
| return $result;
|
| }
|
| |
| |
Comments