Blocks
1 week ago
Datastore
1 month ago
Meta
1 year ago
abilities
1 week ago
admin
1 week ago
ajax
1 month ago
api
3 days ago
fields
3 days ago
forms
3 days ago
legacy
1 year ago
locations
1 year ago
post-types
2 months ago
rest-api
1 week ago
walkers
1 year ago
acf-bidirectional-functions.php
1 year ago
acf-field-functions.php
2 months ago
acf-field-group-functions.php
7 months ago
acf-form-functions.php
1 year ago
acf-helper-functions.php
1 year ago
acf-hook-functions.php
1 year ago
acf-input-functions.php
7 months ago
acf-internal-post-type-functions.php
7 months ago
acf-meta-functions.php
3 weeks ago
acf-post-functions.php
1 year ago
acf-post-type-functions.php
1 year ago
acf-taxonomy-functions.php
1 year ago
acf-user-functions.php
1 week ago
acf-utility-functions.php
1 year ago
acf-value-functions.php
1 year ago
acf-wp-functions.php
3 days ago
assets.php
1 week ago
blocks-auto-inline-editing.php
2 months ago
blocks.php
3 weeks ago
class-acf-data.php
10 months ago
class-acf-internal-post-type.php
1 week ago
class-acf-options-page.php
1 year ago
class-acf-site-health.php
3 months ago
class-scf-json-schema-validator.php
6 months ago
class-scf-schema-builder.php
2 months ago
compatibility.php
1 year ago
datastore.php
1 month ago
deprecated.php
1 year ago
fields.php
10 months ago
index.php
1 year ago
l10n.php
1 year ago
local-fields.php
1 year ago
local-json.php
1 month ago
local-meta.php
1 year ago
locations.php
1 year ago
loop.php
10 months ago
media.php
1 year ago
rest-api.php
10 months ago
revisions.php
1 month ago
scf-ui-options-page-functions.php
1 year ago
third-party.php
7 months ago
upgrades.php
3 weeks ago
validation.php
10 months ago
wpml.php
1 year ago
class-acf-site-health.php
658 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Adds helpful debugging information to a new "Advanced Custom Fields" |
| 5 | * panel in the WordPress Site Health screen. |
| 6 | * |
| 7 | * @package wordpress/secure-custom-fields |
| 8 | */ |
| 9 | |
| 10 | // Exit if accessed directly. |
| 11 | defined( 'ABSPATH' ) || exit; |
| 12 | |
| 13 | if ( ! class_exists( 'ACF_Site_Health' ) ) { |
| 14 | |
| 15 | /** |
| 16 | * The ACF Site Health class responsible for populating ACF debug information in WordPress Site Health. |
| 17 | */ |
| 18 | class ACF_Site_Health { |
| 19 | |
| 20 | /** |
| 21 | * The option name used to store site health data. |
| 22 | * |
| 23 | * @var string |
| 24 | */ |
| 25 | public string $option_name = 'acf_site_health'; |
| 26 | |
| 27 | /** |
| 28 | * Constructs the ACF_Site_Health class. |
| 29 | * |
| 30 | * @since ACF 6.3 |
| 31 | */ |
| 32 | public function __construct() { |
| 33 | add_filter( 'debug_information', array( $this, 'render_tab_content' ) ); |
| 34 | add_filter( 'acf_update_site_health_data', array( $this, 'update_site_health_data' ) ); |
| 35 | |
| 36 | if ( ! wp_next_scheduled( 'acf_update_site_health_data' ) ) { |
| 37 | wp_schedule_event( time(), 'weekly', 'acf_update_site_health_data' ); |
| 38 | } |
| 39 | |
| 40 | // ACF events. |
| 41 | add_filter( 'acf/first_activated', array( $this, 'add_activation_event' ) ); |
| 42 | add_filter( 'acf/pre_update_field_group', array( $this, 'pre_update_acf_internal_cpt' ) ); |
| 43 | add_filter( 'acf/pre_update_post_type', array( $this, 'pre_update_acf_internal_cpt' ) ); |
| 44 | add_filter( 'acf/pre_update_taxonomy', array( $this, 'pre_update_acf_internal_cpt' ) ); |
| 45 | add_filter( 'acf/pre_update_ui_options_page', array( $this, 'pre_update_acf_internal_cpt' ) ); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Gets the stored site health information. |
| 50 | * |
| 51 | * @since ACF 6.3 |
| 52 | * |
| 53 | * @return array |
| 54 | */ |
| 55 | public function get_site_health(): array { |
| 56 | $site_health = get_option( $this->option_name, '' ); |
| 57 | |
| 58 | if ( is_string( $site_health ) ) { |
| 59 | $site_health = json_decode( $site_health, true ); |
| 60 | } |
| 61 | |
| 62 | return is_array( $site_health ) ? $site_health : array(); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Updates the site health information. |
| 67 | * |
| 68 | * @since ACF 6.3 |
| 69 | * |
| 70 | * @param array $data An array of site health information to update. |
| 71 | * @return boolean |
| 72 | */ |
| 73 | public function update_site_health( array $data = array() ): bool { |
| 74 | return update_option( $this->option_name, wp_json_encode( $data ), false ); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Stores debug data in the ACF site health option. |
| 79 | * |
| 80 | * @since ACF 6.3 |
| 81 | * |
| 82 | * @param array $data Data to update with (optional). |
| 83 | * @return boolean |
| 84 | */ |
| 85 | public function update_site_health_data( array $data = array() ): bool { |
| 86 | if ( wp_doing_cron() ) { |
| 87 | // Bootstrap wp-admin, as WP_Cron doesn't do this for us. |
| 88 | require_once trailingslashit( ABSPATH ) . 'wp-admin/includes/admin.php'; |
| 89 | } |
| 90 | |
| 91 | $site_health = $this->get_site_health(); |
| 92 | $values = ! empty( $data ) ? $data : $this->get_site_health_values(); |
| 93 | $updated = array(); |
| 94 | |
| 95 | if ( ! empty( $values ) ) { |
| 96 | foreach ( $values as $key => $value ) { |
| 97 | $updated[ $key ] = $value['debug'] ?? $value['value']; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | foreach ( $site_health as $key => $value ) { |
| 102 | if ( 'event_' === substr( $key, 0, 6 ) ) { |
| 103 | $updated[ $key ] = $value; |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | $updated['last_updated'] = time(); |
| 108 | |
| 109 | return $this->update_site_health( $updated ); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Pushes an event to the ACF site health option. |
| 114 | * |
| 115 | * @since ACF 6.3 |
| 116 | * |
| 117 | * @param string $event_name The name of the event to push. |
| 118 | * @return boolean |
| 119 | */ |
| 120 | public function add_site_health_event( string $event_name = '' ): bool { |
| 121 | $site_health = $this->get_site_health(); |
| 122 | |
| 123 | // Allow using action/filter hooks to set events. |
| 124 | if ( empty( $event_name ) ) { |
| 125 | $current_filter = current_filter(); |
| 126 | |
| 127 | if ( strpos( $current_filter, 'acf/' ) !== false ) { |
| 128 | $event_name = str_replace( 'acf/', '', $current_filter ); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | // Bail if this event was already stored. |
| 133 | if ( empty( $event_name ) || ! empty( $site_health[ 'event_' . $event_name ] ) ) { |
| 134 | return false; |
| 135 | } |
| 136 | |
| 137 | $time = time(); |
| 138 | |
| 139 | $site_health[ 'event_' . $event_name ] = $time; |
| 140 | $site_health['last_updated'] = $time; |
| 141 | |
| 142 | return $this->update_site_health( $site_health ); |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Logs activation events for free/pro. |
| 147 | * |
| 148 | * @since ACF 6.3 |
| 149 | * |
| 150 | * @return boolean |
| 151 | */ |
| 152 | public function add_activation_event() { |
| 153 | $event_name = 'first_activated'; |
| 154 | |
| 155 | return $this->add_site_health_event( $event_name ); |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Adds events when ACF internal post types are created. |
| 160 | * |
| 161 | * @since ACF 6.3 |
| 162 | * |
| 163 | * @param array $post The post about to be updated. |
| 164 | * @return array |
| 165 | */ |
| 166 | public function pre_update_acf_internal_cpt( array $post = array() ): array { |
| 167 | if ( empty( $post['key'] ) ) { |
| 168 | return $post; |
| 169 | } |
| 170 | |
| 171 | $post_type = acf_determine_internal_post_type( $post['key'] ); |
| 172 | |
| 173 | if ( $post_type ) { |
| 174 | $posts = acf_get_internal_post_type_posts( $post_type ); |
| 175 | |
| 176 | if ( empty( $posts ) ) { |
| 177 | $post_type = str_replace( |
| 178 | array( |
| 179 | 'acf-', |
| 180 | '-', |
| 181 | ), |
| 182 | array( |
| 183 | '', |
| 184 | '_', |
| 185 | ), |
| 186 | $post_type |
| 187 | ); |
| 188 | $this->add_site_health_event( 'first_created_' . $post_type ); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | return $post; |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Appends the SCF section to the "Info" tab of the WordPress Site Health screen. |
| 197 | * |
| 198 | * @since ACF 6.3 |
| 199 | * |
| 200 | * @param array $debug_info The current debug info for site health. |
| 201 | * @return array The debug info appended with the SCF section. |
| 202 | */ |
| 203 | public function render_tab_content( array $debug_info ): array { |
| 204 | $data = $this->get_site_health_values(); |
| 205 | |
| 206 | $this->update_site_health_data( $data ); |
| 207 | |
| 208 | // Unset values we don't want to display yet. |
| 209 | $fields_to_unset = array( |
| 210 | 'wp_version', |
| 211 | 'mysql_version', |
| 212 | 'is_multisite', |
| 213 | 'active_theme', |
| 214 | 'parent_theme', |
| 215 | 'active_plugins', |
| 216 | 'number_of_fields_by_type', |
| 217 | 'number_of_third_party_fields_by_type', |
| 218 | ); |
| 219 | |
| 220 | foreach ( $fields_to_unset as $field ) { |
| 221 | if ( isset( $data[ $field ] ) ) { |
| 222 | unset( $data[ $field ] ); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | foreach ( $data as $key => $value ) { |
| 227 | if ( 'event_' === substr( $key, 0, 6 ) ) { |
| 228 | unset( $data[ $key ] ); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | $debug_info['secure-custom-fields'] = array( |
| 233 | 'label' => __( 'SCF', 'secure-custom-fields' ), |
| 234 | 'description' => __( 'This section contains debug information about your SCF configuration which can be useful to provide to support.', 'secure-custom-fields' ), |
| 235 | 'fields' => $data, |
| 236 | ); |
| 237 | |
| 238 | return $debug_info; |
| 239 | } |
| 240 | |
| 241 | /** |
| 242 | * Gets the values for all data in the ACF site health section. |
| 243 | * |
| 244 | * @since ACF 6.3 |
| 245 | * |
| 246 | * @return array |
| 247 | */ |
| 248 | public function get_site_health_values(): array { |
| 249 | global $wpdb; |
| 250 | |
| 251 | $fields = array(); |
| 252 | $field_groups = acf_get_field_groups(); |
| 253 | $post_types = acf_get_post_types(); |
| 254 | $taxonomies = acf_get_taxonomies(); |
| 255 | |
| 256 | $yes = __( 'Yes', 'secure-custom-fields' ); |
| 257 | $no = __( 'No', 'secure-custom-fields' ); |
| 258 | |
| 259 | $fields['version'] = array( |
| 260 | 'label' => __( 'Plugin Version', 'secure-custom-fields' ), |
| 261 | 'value' => defined( 'ACF_VERSION' ) ? ACF_VERSION : '', |
| 262 | ); |
| 263 | |
| 264 | $fields['wp_version'] = array( |
| 265 | 'label' => __( 'WordPress Version', 'secure-custom-fields' ), |
| 266 | 'value' => get_bloginfo( 'version' ), |
| 267 | ); |
| 268 | |
| 269 | $fields['mysql_version'] = array( |
| 270 | 'label' => __( 'MySQL Version', 'secure-custom-fields' ), |
| 271 | 'value' => $wpdb->db_server_info(), |
| 272 | ); |
| 273 | |
| 274 | $fields['is_multisite'] = array( |
| 275 | 'label' => __( 'Is Multisite', 'secure-custom-fields' ), |
| 276 | 'value' => is_multisite() ? __( 'Yes', 'secure-custom-fields' ) : __( 'No', 'secure-custom-fields' ), |
| 277 | 'debug' => is_multisite(), |
| 278 | ); |
| 279 | |
| 280 | $active_theme = wp_get_theme(); |
| 281 | $parent_theme = $active_theme->parent(); |
| 282 | |
| 283 | $fields['active_theme'] = array( |
| 284 | 'label' => __( 'Active Theme', 'secure-custom-fields' ), |
| 285 | 'value' => array( |
| 286 | 'name' => $active_theme->get( 'Name' ), |
| 287 | 'version' => $active_theme->get( 'Version' ), |
| 288 | 'theme_uri' => $active_theme->get( 'ThemeURI' ), |
| 289 | 'stylesheet' => $active_theme->get( 'Stylesheet' ), |
| 290 | ), |
| 291 | ); |
| 292 | |
| 293 | if ( $parent_theme ) { |
| 294 | $fields['parent_theme'] = array( |
| 295 | 'label' => __( 'Parent Theme', 'secure-custom-fields' ), |
| 296 | 'value' => array( |
| 297 | 'name' => $parent_theme->get( 'Name' ), |
| 298 | 'version' => $parent_theme->get( 'Version' ), |
| 299 | 'theme_uri' => $parent_theme->get( 'ThemeURI' ), |
| 300 | 'stylesheet' => $parent_theme->get( 'Stylesheet' ), |
| 301 | ), |
| 302 | ); |
| 303 | } |
| 304 | |
| 305 | $active_plugins = array(); |
| 306 | $plugins = get_plugins(); |
| 307 | |
| 308 | foreach ( $plugins as $plugin_path => $plugin ) { |
| 309 | if ( ! is_plugin_active( $plugin_path ) ) { |
| 310 | continue; |
| 311 | } |
| 312 | |
| 313 | $active_plugins[ $plugin_path ] = array( |
| 314 | 'name' => $plugin['Name'], |
| 315 | 'version' => $plugin['Version'], |
| 316 | 'plugin_uri' => empty( $plugin['PluginURI'] ) ? '' : $plugin['PluginURI'], |
| 317 | ); |
| 318 | } |
| 319 | |
| 320 | $fields['active_plugins'] = array( |
| 321 | 'label' => __( 'Active Plugins', 'secure-custom-fields' ), |
| 322 | 'value' => $active_plugins, |
| 323 | ); |
| 324 | |
| 325 | $ui_field_groups = array_filter( |
| 326 | $field_groups, |
| 327 | function ( $field_group ) { |
| 328 | return empty( $field_group['local'] ); |
| 329 | } |
| 330 | ); |
| 331 | |
| 332 | $fields['ui_field_groups'] = array( |
| 333 | 'label' => __( 'Registered Field Groups (UI)', 'secure-custom-fields' ), |
| 334 | 'value' => number_format_i18n( count( $ui_field_groups ) ), |
| 335 | ); |
| 336 | |
| 337 | $php_field_groups = array_filter( |
| 338 | $field_groups, |
| 339 | function ( $field_group ) { |
| 340 | return ! empty( $field_group['local'] ) && 'PHP' === $field_group['local']; |
| 341 | } |
| 342 | ); |
| 343 | |
| 344 | $fields['php_field_groups'] = array( |
| 345 | 'label' => __( 'Registered Field Groups (PHP)', 'secure-custom-fields' ), |
| 346 | 'value' => number_format_i18n( count( $php_field_groups ) ), |
| 347 | ); |
| 348 | |
| 349 | $json_field_groups = array_filter( |
| 350 | $field_groups, |
| 351 | function ( $field_group ) { |
| 352 | return ! empty( $field_group['local'] ) && 'json' === $field_group['local']; |
| 353 | } |
| 354 | ); |
| 355 | |
| 356 | $fields['json_field_groups'] = array( |
| 357 | 'label' => __( 'Registered Field Groups (JSON)', 'secure-custom-fields' ), |
| 358 | 'value' => number_format_i18n( count( $json_field_groups ) ), |
| 359 | ); |
| 360 | |
| 361 | $rest_field_groups = array_filter( |
| 362 | $field_groups, |
| 363 | function ( $field_group ) { |
| 364 | return ! empty( $field_group['show_in_rest'] ); |
| 365 | } |
| 366 | ); |
| 367 | |
| 368 | $fields['rest_field_groups'] = array( |
| 369 | 'label' => __( 'Field Groups Enabled for REST API', 'secure-custom-fields' ), |
| 370 | 'value' => number_format_i18n( count( $rest_field_groups ) ), |
| 371 | ); |
| 372 | |
| 373 | $graphql_field_groups = array_filter( |
| 374 | $field_groups, |
| 375 | function ( $field_group ) { |
| 376 | return ! empty( $field_group['show_in_graphql'] ); |
| 377 | } |
| 378 | ); |
| 379 | |
| 380 | if ( is_plugin_active( 'wpgraphql-acf/wpgraphql-acf.php' ) ) { |
| 381 | $fields['graphql_field_groups'] = array( |
| 382 | 'label' => __( 'Field Groups Enabled for GraphQL', 'secure-custom-fields' ), |
| 383 | 'value' => number_format_i18n( count( $graphql_field_groups ) ), |
| 384 | ); |
| 385 | } |
| 386 | |
| 387 | $all_fields = array(); |
| 388 | foreach ( $field_groups as $field_group ) { |
| 389 | $all_fields = array_merge( $all_fields, acf_get_fields( $field_group ) ); |
| 390 | } |
| 391 | |
| 392 | $fields_by_type = array(); |
| 393 | $third_party_fields_by_type = array(); |
| 394 | $core_field_types = array_keys( acf_get_field_types() ); |
| 395 | |
| 396 | foreach ( $all_fields as $field ) { |
| 397 | if ( in_array( $field['type'], $core_field_types, true ) ) { |
| 398 | if ( ! isset( $fields_by_type[ $field['type'] ] ) ) { |
| 399 | $fields_by_type[ $field['type'] ] = 0; |
| 400 | } |
| 401 | |
| 402 | ++$fields_by_type[ $field['type'] ]; |
| 403 | |
| 404 | continue; |
| 405 | } |
| 406 | |
| 407 | if ( ! isset( $third_party_fields_by_type[ $field['type'] ] ) ) { |
| 408 | $third_party_fields_by_type[ $field['type'] ] = 0; |
| 409 | } |
| 410 | |
| 411 | ++$third_party_fields_by_type[ $field['type'] ]; |
| 412 | } |
| 413 | |
| 414 | $fields['number_of_fields_by_type'] = array( |
| 415 | 'label' => __( 'Number of Fields by Field Type', 'secure-custom-fields' ), |
| 416 | 'value' => $fields_by_type, |
| 417 | ); |
| 418 | |
| 419 | $fields['number_of_third_party_fields_by_type'] = array( |
| 420 | 'label' => __( 'Number of Third Party Fields by Field Type', 'secure-custom-fields' ), |
| 421 | 'value' => $third_party_fields_by_type, |
| 422 | ); |
| 423 | |
| 424 | $enable_post_types = acf_get_setting( 'enable_post_types' ); |
| 425 | |
| 426 | $fields['post_types_enabled'] = array( |
| 427 | 'label' => __( 'Post Types and Taxonomies Enabled', 'secure-custom-fields' ), |
| 428 | 'value' => $enable_post_types ? $yes : $no, |
| 429 | 'debug' => $enable_post_types, |
| 430 | ); |
| 431 | |
| 432 | $ui_post_types = array_filter( |
| 433 | $post_types, |
| 434 | function ( $post_type ) { |
| 435 | return empty( $post_type['local'] ); |
| 436 | } |
| 437 | ); |
| 438 | |
| 439 | $fields['ui_post_types'] = array( |
| 440 | 'label' => __( 'Registered Post Types (UI)', 'secure-custom-fields' ), |
| 441 | 'value' => number_format_i18n( count( $ui_post_types ) ), |
| 442 | ); |
| 443 | |
| 444 | $json_post_types = array_filter( |
| 445 | $post_types, |
| 446 | function ( $post_type ) { |
| 447 | return ! empty( $post_type['local'] ) && 'json' === $post_type['local']; |
| 448 | } |
| 449 | ); |
| 450 | |
| 451 | $fields['json_post_types'] = array( |
| 452 | 'label' => __( 'Registered Post Types (JSON)', 'secure-custom-fields' ), |
| 453 | 'value' => number_format_i18n( count( $json_post_types ) ), |
| 454 | ); |
| 455 | |
| 456 | $ui_taxonomies = array_filter( |
| 457 | $taxonomies, |
| 458 | function ( $taxonomy ) { |
| 459 | return empty( $taxonomy['local'] ); |
| 460 | } |
| 461 | ); |
| 462 | |
| 463 | $fields['ui_taxonomies'] = array( |
| 464 | 'label' => __( 'Registered Taxonomies (UI)', 'secure-custom-fields' ), |
| 465 | 'value' => number_format_i18n( count( $ui_taxonomies ) ), |
| 466 | ); |
| 467 | |
| 468 | $json_taxonomies = array_filter( |
| 469 | $taxonomies, |
| 470 | function ( $taxonomy ) { |
| 471 | return ! empty( $taxonomy['local'] ) && 'json' === $taxonomy['local']; |
| 472 | } |
| 473 | ); |
| 474 | |
| 475 | $fields['json_taxonomies'] = array( |
| 476 | 'label' => __( 'Registered Taxonomies (JSON)', 'secure-custom-fields' ), |
| 477 | 'value' => number_format_i18n( count( $json_taxonomies ) ), |
| 478 | ); |
| 479 | |
| 480 | $enable_options_pages_ui = acf_get_setting( 'enable_options_pages_ui' ); |
| 481 | |
| 482 | $fields['ui_options_pages_enabled'] = array( |
| 483 | 'label' => __( 'Options Pages UI Enabled', 'secure-custom-fields' ), |
| 484 | 'value' => $enable_options_pages_ui ? $yes : $no, |
| 485 | 'debug' => $enable_options_pages_ui, |
| 486 | ); |
| 487 | |
| 488 | $options_pages = acf_get_options_pages(); |
| 489 | $ui_options_pages = array(); |
| 490 | |
| 491 | if ( empty( $options_pages ) || ! is_array( $options_pages ) ) { |
| 492 | $options_pages = array(); |
| 493 | } |
| 494 | |
| 495 | if ( $enable_options_pages_ui ) { |
| 496 | $ui_options_pages = acf_get_ui_options_pages(); |
| 497 | |
| 498 | $ui_options_pages_in_ui = array_filter( |
| 499 | $ui_options_pages, |
| 500 | function ( $ui_options_page ) { |
| 501 | return empty( $ui_options_page['local'] ); |
| 502 | } |
| 503 | ); |
| 504 | |
| 505 | $json_options_pages = array_filter( |
| 506 | $ui_options_pages, |
| 507 | function ( $ui_options_page ) { |
| 508 | return ! empty( $ui_options_page['local'] ); |
| 509 | } |
| 510 | ); |
| 511 | |
| 512 | $fields['ui_options_pages'] = array( |
| 513 | 'label' => __( 'Registered Options Pages (UI)', 'secure-custom-fields' ), |
| 514 | 'value' => number_format_i18n( count( $ui_options_pages_in_ui ) ), |
| 515 | ); |
| 516 | |
| 517 | $fields['json_options_pages'] = array( |
| 518 | 'label' => __( 'Registered Options Pages (JSON)', 'secure-custom-fields' ), |
| 519 | 'value' => number_format_i18n( count( $json_options_pages ) ), |
| 520 | ); |
| 521 | } |
| 522 | |
| 523 | $ui_options_page_slugs = array_column( $ui_options_pages, 'menu_slug' ); |
| 524 | $php_options_pages = array_filter( |
| 525 | $options_pages, |
| 526 | function ( $options_page ) use ( $ui_options_page_slugs ) { |
| 527 | return ! in_array( $options_page['menu_slug'], $ui_options_page_slugs, true ); |
| 528 | } |
| 529 | ); |
| 530 | |
| 531 | $fields['php_options_pages'] = array( |
| 532 | 'label' => __( 'Registered Options Pages (PHP)', 'secure-custom-fields' ), |
| 533 | 'value' => number_format_i18n( count( $php_options_pages ) ), |
| 534 | ); |
| 535 | |
| 536 | $rest_api_format = acf_get_setting( 'rest_api_format' ); |
| 537 | |
| 538 | $fields['rest_api_format'] = array( |
| 539 | 'label' => __( 'REST API Format', 'secure-custom-fields' ), |
| 540 | 'value' => 'standard' === $rest_api_format ? __( 'Standard', 'secure-custom-fields' ) : __( 'Light', 'secure-custom-fields' ), |
| 541 | 'debug' => $rest_api_format, |
| 542 | ); |
| 543 | |
| 544 | $blocks = acf_get_block_types(); |
| 545 | $block_api_versions = array(); |
| 546 | $acf_block_versions = array(); |
| 547 | $blocks_using_post_meta = 0; |
| 548 | $blocks_using_auto_inline_editing = 0; |
| 549 | |
| 550 | foreach ( $blocks as $block ) { |
| 551 | if ( ! isset( $block_api_versions[ 'v' . $block['api_version'] ] ) ) { |
| 552 | $block_api_versions[ 'v' . $block['api_version'] ] = 0; |
| 553 | } |
| 554 | |
| 555 | if ( ! isset( $acf_block_versions[ 'v' . $block['acf_block_version'] ] ) ) { |
| 556 | $acf_block_versions[ 'v' . $block['acf_block_version'] ] = 0; |
| 557 | } |
| 558 | |
| 559 | if ( ! empty( $block['use_post_meta'] ) ) { |
| 560 | ++$blocks_using_post_meta; |
| 561 | } |
| 562 | |
| 563 | if ( ! empty( $block['auto_inline_editing'] ) ) { |
| 564 | ++$blocks_using_auto_inline_editing; |
| 565 | } |
| 566 | |
| 567 | ++$block_api_versions[ 'v' . $block['api_version'] ]; |
| 568 | ++$acf_block_versions[ 'v' . $block['acf_block_version'] ]; |
| 569 | } |
| 570 | |
| 571 | $fields['blocks_per_api_version'] = array( |
| 572 | 'label' => __( 'Blocks Per API Version', 'secure-custom-fields' ), |
| 573 | 'value' => $block_api_versions, |
| 574 | ); |
| 575 | |
| 576 | $fields['blocks_per_acf_block_version'] = array( |
| 577 | 'label' => __( 'Blocks Per SCF Block Version', 'secure-custom-fields' ), |
| 578 | 'value' => $acf_block_versions, |
| 579 | ); |
| 580 | |
| 581 | $fields['blocks_using_post_meta'] = array( |
| 582 | 'label' => __( 'Blocks Using Post Meta', 'secure-custom-fields' ), |
| 583 | 'value' => number_format_i18n( $blocks_using_post_meta ), |
| 584 | ); |
| 585 | |
| 586 | $fields['blocks_using_auto_inline_editing'] = array( |
| 587 | 'label' => __( 'Blocks Using Auto Inline Editing', 'secure-custom-fields' ), |
| 588 | 'value' => number_format_i18n( $blocks_using_auto_inline_editing ), |
| 589 | ); |
| 590 | |
| 591 | $preload_blocks = acf_get_setting( 'preload_blocks' ); |
| 592 | |
| 593 | $fields['preload_blocks'] = array( |
| 594 | 'label' => __( 'Block Preloading Enabled', 'secure-custom-fields' ), |
| 595 | 'value' => ! empty( $preload_blocks ) ? $yes : $no, |
| 596 | 'debug' => $preload_blocks, |
| 597 | ); |
| 598 | |
| 599 | $show_admin = acf_get_setting( 'show_admin' ); |
| 600 | |
| 601 | $fields['admin_ui_enabled'] = array( |
| 602 | 'label' => __( 'Admin UI Enabled', 'secure-custom-fields' ), |
| 603 | 'value' => $show_admin ? $yes : $no, |
| 604 | 'debug' => $show_admin, |
| 605 | ); |
| 606 | |
| 607 | $field_type_modal_enabled = apply_filters( 'acf/field_group/enable_field_browser', true ); |
| 608 | |
| 609 | $fields['field_type-modal_enabled'] = array( |
| 610 | 'label' => __( 'Field Type Modal Enabled', 'secure-custom-fields' ), |
| 611 | 'value' => ! empty( $field_type_modal_enabled ) ? $yes : $no, |
| 612 | 'debug' => $field_type_modal_enabled, |
| 613 | ); |
| 614 | |
| 615 | $field_settings_tabs_enabled = apply_filters( 'acf/field_group/disable_field_settings_tabs', false ); |
| 616 | |
| 617 | $fields['field_settings_tabs_enabled'] = array( |
| 618 | 'label' => __( 'Field Settings Tabs Enabled', 'secure-custom-fields' ), |
| 619 | 'value' => empty( $field_settings_tabs_enabled ) ? $yes : $no, |
| 620 | 'debug' => $field_settings_tabs_enabled, |
| 621 | ); |
| 622 | |
| 623 | $shortcode_enabled = acf_get_setting( 'enable_shortcode' ); |
| 624 | |
| 625 | $fields['shortcode_enabled'] = array( |
| 626 | 'label' => __( 'Shortcode Enabled', 'secure-custom-fields' ), |
| 627 | 'value' => ! empty( $shortcode_enabled ) ? $yes : $no, |
| 628 | 'debug' => $shortcode_enabled, |
| 629 | ); |
| 630 | |
| 631 | $fields['registered_acf_forms'] = array( |
| 632 | 'label' => __( 'Registered SCF Forms', 'secure-custom-fields' ), |
| 633 | 'value' => number_format_i18n( count( acf_get_forms() ) ), |
| 634 | ); |
| 635 | |
| 636 | $local_json = acf_get_instance( 'ACF_Local_JSON' ); |
| 637 | $save_paths = $local_json->get_save_paths(); |
| 638 | $load_paths = $local_json->get_load_paths(); |
| 639 | |
| 640 | $fields['json_save_paths'] = array( |
| 641 | 'label' => __( 'JSON Save Paths', 'secure-custom-fields' ), |
| 642 | 'value' => number_format_i18n( count( $save_paths ) ), |
| 643 | 'debug' => count( $save_paths ), |
| 644 | ); |
| 645 | |
| 646 | $fields['json_load_paths'] = array( |
| 647 | 'label' => __( 'JSON Load Paths', 'secure-custom-fields' ), |
| 648 | 'value' => number_format_i18n( count( $load_paths ) ), |
| 649 | 'debug' => count( $load_paths ), |
| 650 | ); |
| 651 | |
| 652 | return $fields; |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | acf_new_instance( 'ACF_Site_Health' ); |
| 657 | } |
| 658 |