| |
| <?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| defined( 'ABSPATH' ) || exit;
|
|
|
|
|
|
|
|
|
| add_action( 'gv_views_sync_complete', 'populate_gv_field_details_data', 10, 2 );
|
|
|
|
|
|
|
|
|
| function populate_gv_field_details_data( $post_id, $view_id ) {
|
|
|
| error_log( "GV_FIELD_DETAILS_SYNC: Processing view {$view_id} for post {$post_id}" );
|
|
|
|
|
| $view_post = get_post( $view_id );
|
| if ( ! $view_post ) {
|
| error_log( "GV_FIELD_DETAILS_SYNC: Failed to get view post {$view_id}" );
|
| return false;
|
| }
|
|
|
|
|
| $form_id = get_post_meta( $view_id, '_gravityview_form_id', true );
|
| $form = null;
|
|
|
| if ( class_exists( 'GFAPI' ) && $form_id ) {
|
| $form = GFAPI::get_form( $form_id );
|
| }
|
|
|
|
|
| $field_details = generate_gv_field_details_list( $view_id, $form );
|
|
|
|
|
| update_post_meta( $post_id, 'field_details_comprehensive', $field_details );
|
| update_post_meta( $post_id, 'field_details_sync_timestamp', current_time( 'Y-m-d H:i:s' ) );
|
|
|
|
|
| $base_edit_url = admin_url( 'post.php?post=' . $view_id . '&action=edit' );
|
| update_post_meta( $post_id, 'gv_layout_builder_link', $base_edit_url . '#gravityview-view-configuration' );
|
| update_post_meta( $post_id, 'gv_settings_link', $base_edit_url . '#gravityview-settings' );
|
|
|
|
|
| $stats = generate_view_statistics( $view_id, $form );
|
| update_post_meta( $post_id, 'view_statistics', $stats );
|
|
|
| error_log( "GV_FIELD_DETAILS_SYNC: Completed view {$view_id} - " . strlen( $field_details ) . " characters" );
|
|
|
| return true;
|
| }
|
|
|
|
|
|
|
|
|
| function generate_gv_field_details_list( $view_id, $form ) {
|
|
|
| $output = '';
|
|
|
|
|
| $view_post = get_post( $view_id );
|
| $template = get_post_meta( $view_id, '_gravityview_template', true );
|
|
|
| $output .= "═══════════════════════════════════════════════════════════════════\n";
|
| $output .= "GRAVITYVIEW: {$view_post->post_title} (ID: {$view_id})\n";
|
| $output .= "TEMPLATE: " . strtoupper( $template ?: 'table' ) . "\n";
|
|
|
| if ( $form ) {
|
| $output .= "CONNECTED FORM: {$form['title']} (ID: {$form['id']})\n";
|
| }
|
|
|
| $output .= "CREATED: " . $view_post->post_date . "\n";
|
| $output .= "MODIFIED: " . $view_post->post_modified . "\n";
|
| $output .= "═══════════════════════════════════════════════════════════════════\n\n";
|
|
|
|
|
| $output .= "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
|
| $output .= "DIRECTORY/MULTIPLE ENTRIES LAYOUT\n";
|
| $output .= "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n";
|
|
|
| $directory_fields = get_post_meta( $view_id, '_gravityview_directory_fields', true );
|
| $output .= process_gv_layout_fields( $directory_fields, $form, 'Directory' );
|
|
|
|
|
| $output .= "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
|
| $output .= "SINGLE ENTRY LAYOUT\n";
|
| $output .= "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n";
|
|
|
| $single_fields = get_post_meta( $view_id, '_gravityview_single_fields', true );
|
| $output .= process_gv_layout_fields( $single_fields, $form, 'Single Entry' );
|
|
|
|
|
| $output .= "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
|
| $output .= "EDIT ENTRY LAYOUT\n";
|
| $output .= "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n";
|
|
|
| $edit_fields = get_post_meta( $view_id, '_gravityview_edit_fields', true );
|
| $output .= process_gv_layout_fields( $edit_fields, $form, 'Edit Entry' );
|
|
|
|
|
| $output .= "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
|
| $output .= "WIDGETS CONFIGURATION\n";
|
| $output .= "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n";
|
|
|
| $widgets = get_post_meta( $view_id, '_gravityview_directory_widgets', true );
|
| $output .= process_gv_widgets( $widgets );
|
|
|
|
|
| $output .= "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
|
| $output .= "VIEW SETTINGS & CONFIGURATION\n";
|
| $output .= "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n";
|
|
|
| $settings = get_post_meta( $view_id, '_gravityview_settings', true );
|
| $output .= process_gv_settings( $settings );
|
|
|
|
|
| $joined_forms = get_post_meta( $view_id, '_gravityview_joined_forms', true );
|
| if ( ! empty( $joined_forms ) ) {
|
| $output .= "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
|
| $output .= "MULTIPLE FORMS CONFIGURATION\n";
|
| $output .= "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n";
|
| $output .= process_multiple_forms( $joined_forms );
|
| }
|
|
|
| $output .= "═══════════════════════════════════════════════════════════════════\n";
|
| $output .= "END OF VIEW FIELD DETAILS\n";
|
| $output .= "═══════════════════════════════════════════════════════════════════\n";
|
|
|
| return $output;
|
| }
|
|
|
|
|
|
|
|
|
| function process_gv_layout_fields( $fields, $form, $layout_name ) {
|
|
|
| $output = '';
|
|
|
| if ( empty( $fields ) || ! is_array( $fields ) ) {
|
| return "No fields configured for {$layout_name}\n\n";
|
| }
|
|
|
| $field_count = 0;
|
| $form_fields = [];
|
|
|
|
|
| if ( $form && isset( $form['fields'] ) ) {
|
| foreach ( $form['fields'] as $gf_field ) {
|
| $form_fields[ $gf_field->id ] = $gf_field;
|
| }
|
| }
|
|
|
| foreach ( $fields as $zone_id => $zone_fields ) {
|
| if ( ! empty( $zone_fields ) && is_array( $zone_fields ) ) {
|
|
|
| $output .= "ZONE: " . strtoupper( str_replace( '_', ' ', $zone_id ) ) . "\n";
|
| $output .= "-------------------------------------------\n\n";
|
|
|
| foreach ( $zone_fields as $field ) {
|
| $field_count++;
|
|
|
| $output .= "Field #{$field_count}:\n";
|
|
|
|
|
| if ( ! empty( $field['id'] ) ) {
|
| $output .= " GV Field ID: {$field['id']}\n";
|
|
|
|
|
| if ( is_numeric( $field['id'] ) && isset( $form_fields[ $field['id'] ] ) ) {
|
| $gf_field = $form_fields[ $field['id'] ];
|
| $output .= " Form Field Type: {$gf_field->type}\n";
|
| $output .= " Form Field Label: " . ( $gf_field->label ?: '(No Label)' ) . "\n";
|
|
|
|
|
| $gppa_settings = extract_gv_gppa_settings( $gf_field );
|
| if ( ! empty( $gppa_settings ) ) {
|
| $output .= " Populate Anything Settings:\n";
|
| $output .= $gppa_settings;
|
| }
|
| } else {
|
|
|
| $output .= " Field Type: " . get_gv_field_type_name( $field['id'] ) . "\n";
|
| }
|
| }
|
|
|
|
|
| if ( ! empty( $field['custom_label'] ) ) {
|
| $output .= " Custom Label: {$field['custom_label']}\n";
|
| } elseif ( ! empty( $field['label'] ) ) {
|
| $output .= " Label: {$field['label']}\n";
|
| }
|
|
|
|
|
| if ( ! empty( $field['custom_class'] ) ) {
|
| $output .= " CSS Class: {$field['custom_class']}\n";
|
| }
|
|
|
|
|
| if ( ! empty( $field['show_label'] ) ) {
|
| $output .= " Show Label: " . ( $field['show_label'] == '1' ? 'Yes' : 'No' ) . "\n";
|
| }
|
|
|
| if ( ! empty( $field['only_loggedin'] ) ) {
|
| $output .= " Visibility: Logged-in Users Only\n";
|
| if ( ! empty( $field['only_loggedin_cap'] ) ) {
|
| $output .= " Required Capability: {$field['only_loggedin_cap']}\n";
|
| }
|
| }
|
|
|
|
|
| if ( $field['id'] === 'custom' && ! empty( $field['content'] ) ) {
|
| $content_preview = substr( strip_tags( $field['content'] ), 0, 100 );
|
| $output .= " Custom Content: {$content_preview}...\n";
|
| }
|
|
|
|
|
| if ( ! empty( $field['search_fields'] ) ) {
|
| $output .= " Search Fields: " . implode( ', ', $field['search_fields'] ) . "\n";
|
| }
|
|
|
|
|
| $additional = extract_gv_field_settings( $field );
|
| if ( ! empty( $additional ) ) {
|
| $output .= $additional;
|
| }
|
|
|
| $output .= "\n";
|
| }
|
| }
|
| }
|
|
|
| $output .= "Total {$layout_name} Fields: {$field_count}\n\n";
|
|
|
| return $output;
|
| }
|
|
|
|
|
|
|
|
|
| function process_gv_widgets( $widgets ) {
|
|
|
| $output = '';
|
|
|
| if ( empty( $widgets ) || ! is_array( $widgets ) ) {
|
| return "No widgets configured\n\n";
|
| }
|
|
|
| $widget_areas = [
|
| 'header_top' => 'Header Top',
|
| 'header_left' => 'Header Left',
|
| 'header_right' => 'Header Right',
|
| 'footer_top' => 'Footer Top',
|
| 'footer_left' => 'Footer Left',
|
| 'footer_right' => 'Footer Right',
|
| 'footer_bottom' => 'Footer Bottom',
|
| ];
|
|
|
| foreach ( $widget_areas as $area_key => $area_name ) {
|
| if ( ! empty( $widgets[ $area_key ] ) && is_array( $widgets[ $area_key ] ) ) {
|
| $output .= "{$area_name} Widgets:\n";
|
|
|
| foreach ( $widgets[ $area_key ] as $index => $widget ) {
|
| $widget_num = $index + 1;
|
| $output .= " Widget #{$widget_num}:\n";
|
|
|
| if ( ! empty( $widget['id'] ) ) {
|
| $output .= " Type: " . get_gv_widget_type_name( $widget['id'] ) . "\n";
|
| }
|
|
|
| if ( ! empty( $widget['label'] ) ) {
|
| $output .= " Label: {$widget['label']}\n";
|
| }
|
|
|
|
|
| $widget_settings = extract_gv_widget_settings( $widget );
|
| if ( ! empty( $widget_settings ) ) {
|
| $output .= $widget_settings;
|
| }
|
| }
|
|
|
| $output .= "\n";
|
| }
|
| }
|
|
|
| return $output;
|
| }
|
|
|
|
|
|
|
|
|
| function process_gv_settings( $settings ) {
|
|
|
| $output = '';
|
|
|
| if ( empty( $settings ) || ! is_array( $settings ) ) {
|
| return "Default view settings\n\n";
|
| }
|
|
|
|
|
| $setting_categories = [
|
| 'Display' => [
|
| 'page_size' => 'Entries Per Page',
|
| 'pagination' => 'Pagination',
|
| 'hide_empty' => 'Hide Empty Fields',
|
| 'hide_until_searched' => 'Hide Until Searched',
|
| 'no_entries_text' => 'No Entries Message',
|
| ],
|
| 'Permissions' => [
|
| 'show_only_user_entries' => 'Show Only User Entries',
|
| 'user_edit' => 'User Can Edit',
|
| 'user_delete' => 'User Can Delete',
|
| 'admin_approval' => 'Require Admin Approval',
|
| ],
|
| 'Filtering' => [
|
| 'show_only_approved' => 'Show Only Approved',
|
| 'sort_field' => 'Default Sort Field',
|
| 'sort_direction' => 'Sort Direction',
|
| 'search_layout' => 'Search Layout',
|
| ],
|
| 'Advanced' => [
|
| 'class' => 'CSS Classes',
|
| 'cache_enable' => 'Cache Enabled',
|
| 'cache_duration' => 'Cache Duration',
|
| 'rest_enable' => 'REST API Enabled',
|
| ],
|
| ];
|
|
|
| foreach ( $setting_categories as $category => $category_settings ) {
|
| $category_output = '';
|
|
|
| foreach ( $category_settings as $key => $label ) {
|
| if ( isset( $settings[ $key ] ) && $settings[ $key ] !== '' ) {
|
| $value = $settings[ $key ];
|
|
|
| if ( is_bool( $value ) || $value === '0' || $value === '1' ) {
|
| $value = ( $value == '1' || $value === true ) ? 'Yes' : 'No';
|
| } elseif ( is_array( $value ) ) {
|
| $value = json_encode( $value, JSON_PRETTY_PRINT );
|
| }
|
|
|
| $category_output .= " {$label}: {$value}\n";
|
| }
|
| }
|
|
|
| if ( ! empty( $category_output ) ) {
|
| $output .= "{$category} Settings:\n";
|
| $output .= $category_output;
|
| $output .= "\n";
|
| }
|
| }
|
|
|
|
|
| if ( ! empty( $settings['search_criteria'] ) ) {
|
| $output .= "Advanced Filter Criteria:\n";
|
| $output .= process_filter_criteria( $settings['search_criteria'] );
|
| $output .= "\n";
|
| }
|
|
|
| return $output;
|
| }
|
|
|
|
|
|
|
|
|
| function process_multiple_forms( $joined_forms ) {
|
|
|
| $output = '';
|
|
|
| if ( empty( $joined_forms ) || ! is_array( $joined_forms ) ) {
|
| return "No joined forms configured\n\n";
|
| }
|
|
|
| $form_count = 1;
|
| foreach ( $joined_forms as $joined ) {
|
| $output .= "Joined Form #{$form_count}:\n";
|
|
|
| if ( ! empty( $joined['form_id'] ) ) {
|
| $output .= " Form ID: {$joined['form_id']}\n";
|
|
|
|
|
| if ( class_exists( 'GFAPI' ) ) {
|
| $joined_form = GFAPI::get_form( $joined['form_id'] );
|
| if ( $joined_form ) {
|
| $output .= " Form Title: {$joined_form['title']}\n";
|
| }
|
| }
|
| }
|
|
|
| if ( ! empty( $joined['join_type'] ) ) {
|
| $output .= " Join Type: " . ucfirst( $joined['join_type'] ) . "\n";
|
| }
|
|
|
| if ( ! empty( $joined['join_on'] ) ) {
|
| $output .= " Join Conditions:\n";
|
|
|
| if ( ! empty( $joined['join_on']['field'] ) ) {
|
| $output .= " Primary Field: {$joined['join_on']['field']}\n";
|
| }
|
| if ( ! empty( $joined['join_on']['joined_field'] ) ) {
|
| $output .= " Joined Field: {$joined['join_on']['joined_field']}\n";
|
| }
|
| if ( ! empty( $joined['join_on']['condition'] ) ) {
|
| $output .= " Condition: {$joined['join_on']['condition']}\n";
|
| }
|
| }
|
|
|
| $output .= "\n";
|
| $form_count++;
|
| }
|
|
|
| return $output;
|
| }
|
|
|
|
|
|
|
|
|
| function extract_gv_gppa_settings( $field ) {
|
|
|
| $output = '';
|
|
|
|
|
| if ( ! empty( $field->{'gppa-choices-enabled'} ) || ! empty( $field->{'gppa-values-enabled'} ) ) {
|
|
|
| if ( ! empty( $field->{'gppa-choices-enabled'} ) ) {
|
| $output .= " GPPA Choices: Enabled\n";
|
|
|
| if ( ! empty( $field->{'gppa-choices-object-type'} ) ) {
|
| $output .= " Object Type: {$field->{'gppa-choices-object-type'}}\n";
|
| }
|
| if ( ! empty( $field->{'gppa-choices-filter'} ) ) {
|
| $filters = is_array( $field->{'gppa-choices-filter'} )
|
| ? json_encode( $field->{'gppa-choices-filter'} )
|
| : $field->{'gppa-choices-filter'};
|
| $output .= " Filters: {$filters}\n";
|
| }
|
| }
|
|
|
| if ( ! empty( $field->{'gppa-values-enabled'} ) ) {
|
| $output .= " GPPA Values: Enabled\n";
|
|
|
| if ( ! empty( $field->{'gppa-values-object-type'} ) ) {
|
| $output .= " Object Type: {$field->{'gppa-values-object-type'}}\n";
|
| }
|
| }
|
| }
|
|
|
|
|
| if ( ! empty( $field->{'gppa-live-merge-tags'} ) ) {
|
| $output .= " GPPA Live Merge Tags: Enabled\n";
|
| }
|
|
|
| return $output;
|
| }
|
|
|
|
|
|
|
|
|
| function extract_gv_field_settings( $field ) {
|
|
|
| $output = '';
|
|
|
|
|
| if ( ! empty( $field['sort'] ) ) {
|
| $output .= " Sortable: Yes\n";
|
| }
|
|
|
|
|
| if ( ! empty( $field['link_to_entry'] ) ) {
|
| $output .= " Links to Entry: Yes\n";
|
| }
|
|
|
| if ( ! empty( $field['link_to_post'] ) ) {
|
| $output .= " Links to Post: Yes\n";
|
| }
|
|
|
|
|
| if ( ! empty( $field['date_format'] ) ) {
|
| $output .= " Date Format: {$field['date_format']}\n";
|
| }
|
|
|
|
|
| if ( ! empty( $field['truncate_length'] ) ) {
|
| $output .= " Truncate Length: {$field['truncate_length']} characters\n";
|
| }
|
|
|
|
|
| if ( ! empty( $field['new_window'] ) ) {
|
| $output .= " Opens in New Window: Yes\n";
|
| }
|
|
|
| return $output;
|
| }
|
|
|
|
|
|
|
|
|
| function extract_gv_widget_settings( $widget ) {
|
|
|
| $output = '';
|
|
|
|
|
| if ( $widget['id'] === 'search_bar' ) {
|
| if ( ! empty( $widget['search_fields'] ) ) {
|
| $output .= " Search Fields: " . count( $widget['search_fields'] ) . " fields\n";
|
| }
|
| if ( ! empty( $widget['search_clear'] ) ) {
|
| $output .= " Show Clear Button: Yes\n";
|
| }
|
| }
|
|
|
|
|
| if ( $widget['id'] === 'page_info' || $widget['id'] === 'pagination' ) {
|
| if ( ! empty( $widget['show_all'] ) ) {
|
| $output .= " Show All Option: Yes\n";
|
| }
|
| }
|
|
|
|
|
| if ( $widget['id'] === 'export_link' ) {
|
| if ( ! empty( $widget['export_type'] ) ) {
|
| $output .= " Export Type: {$widget['export_type']}\n";
|
| }
|
| }
|
|
|
| return $output;
|
| }
|
|
|
|
|
|
|
|
|
| function process_filter_criteria( $criteria ) {
|
|
|
| $output = '';
|
|
|
| if ( ! empty( $criteria['field_filters'] ) && is_array( $criteria['field_filters'] ) ) {
|
| $filter_count = 1;
|
|
|
| foreach ( $criteria['field_filters'] as $filter ) {
|
| if ( is_array( $filter ) && ! empty( $filter['key'] ) ) {
|
| $output .= " Filter #{$filter_count}:\n";
|
| $output .= " Field: {$filter['key']}\n";
|
|
|
| if ( ! empty( $filter['operator'] ) ) {
|
| $output .= " Operator: {$filter['operator']}\n";
|
| }
|
| if ( isset( $filter['value'] ) ) {
|
| $value = is_array( $filter['value'] )
|
| ? json_encode( $filter['value'] )
|
| : $filter['value'];
|
| $output .= " Value: {$value}\n";
|
| }
|
|
|
| $filter_count++;
|
| }
|
| }
|
| }
|
|
|
| if ( ! empty( $criteria['mode'] ) ) {
|
| $output .= " Filter Logic: {$criteria['mode']}\n";
|
| }
|
|
|
| if ( ! empty( $criteria['status'] ) ) {
|
| $output .= " Entry Status: {$criteria['status']}\n";
|
| }
|
|
|
| return $output;
|
| }
|
|
|
|
|
|
|
|
|
| function get_gv_field_type_name( $field_id ) {
|
|
|
| $field_types = [
|
| 'entry_id' => 'Entry ID',
|
| 'entry_date' => 'Entry Date',
|
| 'source_url' => 'Source URL',
|
| 'ip' => 'IP Address',
|
| 'created_by' => 'Created By',
|
| 'user_name' => 'User Name',
|
| 'custom' => 'Custom Content',
|
| 'edit_link' => 'Edit Entry Link',
|
| 'delete_link' => 'Delete Entry Link',
|
| 'approval_status' => 'Approval Status',
|
| 'other_entries' => 'Other Entries',
|
| ];
|
|
|
| return isset( $field_types[ $field_id ] ) ? $field_types[ $field_id ] : ucwords( str_replace( '_', ' ', $field_id ) );
|
| }
|
|
|
|
|
|
|
|
|
| function get_gv_widget_type_name( $widget_id ) {
|
|
|
| $widget_types = [
|
| 'search_bar' => 'Search Bar',
|
| 'page_info' => 'Page Information',
|
| 'pagination' => 'Pagination Links',
|
| 'export_link' => 'Export Links',
|
| 'total_entries' => 'Total Entries',
|
| ];
|
|
|
| return isset( $widget_types[ $widget_id ] ) ? $widget_types[ $widget_id ] : ucwords( str_replace( '_', ' ', $widget_id ) );
|
| }
|
|
|
|
|
|
|
|
|
| function generate_view_statistics( $view_id, $form ) {
|
|
|
| $output = '';
|
|
|
| $output .= "═══════════════════════════════════════════════════════════════════\n";
|
| $output .= "VIEW STATISTICS\n";
|
| $output .= "═══════════════════════════════════════════════════════════════════\n\n";
|
|
|
|
|
| $directory_fields = get_post_meta( $view_id, '_gravityview_directory_fields', true );
|
| $single_fields = get_post_meta( $view_id, '_gravityview_single_fields', true );
|
| $edit_fields = get_post_meta( $view_id, '_gravityview_edit_fields', true );
|
|
|
| $dir_count = count_fields_recursive( $directory_fields );
|
| $single_count = count_fields_recursive( $single_fields );
|
| $edit_count = count_fields_recursive( $edit_fields );
|
|
|
| $output .= "Field Counts:\n";
|
| $output .= " Directory Layout: {$dir_count} fields\n";
|
| $output .= " Single Entry Layout: {$single_count} fields\n";
|
| $output .= " Edit Entry Layout: {$edit_count} fields\n";
|
| $output .= " Total Fields: " . ( $dir_count + $single_count + $edit_count ) . "\n\n";
|
|
|
|
|
| $widgets = get_post_meta( $view_id, '_gravityview_directory_widgets', true );
|
| $widget_count = count_fields_recursive( $widgets );
|
| $output .= "Total Widgets: {$widget_count}\n\n";
|
|
|
|
|
| if ( $form && class_exists( 'GFAPI' ) ) {
|
| $entry_count = GFAPI::count_entries( $form['id'] );
|
| $output .= "Connected Entries: {$entry_count}\n";
|
|
|
|
|
| $active_count = GFAPI::count_entries( $form['id'], ['status' => 'active'] );
|
| $trash_count = GFAPI::count_entries( $form['id'], ['status' => 'trash'] );
|
|
|
| $output .= " Active: {$active_count}\n";
|
| $output .= " Trash: {$trash_count}\n";
|
| }
|
|
|
| $output .= "\n";
|
|
|
|
|
| $output .= "Active Extensions:\n";
|
|
|
| $extensions = [
|
| 'GravityView_Featured_Entries' => 'Featured Entries',
|
| 'GravityView_Ratings_Reviews' => 'Ratings & Reviews',
|
| 'GravityView_Magic_Links' => 'Magic Links',
|
| 'GravityView_Calendar' => 'Calendar',
|
| 'GravityView_Charts' => 'Charts',
|
| 'GravityView_Maps' => 'Maps',
|
| 'GravityView_DataTables' => 'DataTables',
|
| 'GravityView_PDF' => 'PDF Export',
|
| 'GravityView_Import_Entries' => 'Import Entries',
|
| ];
|
|
|
| $active_extensions = 0;
|
| foreach ( $extensions as $class => $name ) {
|
| if ( class_exists( $class ) ) {
|
| $output .= " ✓ {$name}\n";
|
| $active_extensions++;
|
| }
|
| }
|
|
|
| if ( $active_extensions === 0 ) {
|
| $output .= " No extensions detected\n";
|
| }
|
|
|
| $output .= "\n═══════════════════════════════════════════════════════════════════\n";
|
|
|
| return $output;
|
| }
|
|
|
|
|
|
|
|
|
| function count_fields_recursive( $array ) {
|
| if ( ! is_array( $array ) ) {
|
| return 0;
|
| }
|
|
|
| $count = 0;
|
| foreach ( $array as $value ) {
|
| if ( is_array( $value ) ) {
|
| $count += count_fields_recursive( $value );
|
| } else {
|
| $count++;
|
| }
|
| }
|
|
|
| return $count;
|
| }
|
|
|
|
|
|
|
|
|
| add_action( 'admin_init', function() {
|
| if ( isset( $_GET['sync_gv_field_details'] ) && current_user_can( 'manage_options' ) ) {
|
| $view_id = intval( $_GET['view_id'] );
|
|
|
| if ( $view_id ) {
|
|
|
| $sync_posts = get_posts( [
|
| 'post_type' => 'gv_views_sync',
|
| 'meta_key' => 'view_id',
|
| 'meta_value' => $view_id,
|
| 'numberposts' => 1,
|
| ] );
|
|
|
| if ( ! empty( $sync_posts ) ) {
|
| populate_gv_field_details_data( $sync_posts[0]->ID, $view_id );
|
| wp_die( 'Field details synced for view ' . $view_id );
|
| }
|
| }
|
| }
|
| } );
|
| |
| |
Comments