25 * |
25 * |
26 * @since 2.1.0 |
26 * @since 2.1.0 |
27 * @access private |
27 * @access private |
28 */ |
28 */ |
29 function wp_unregister_GLOBALS() { |
29 function wp_unregister_GLOBALS() { |
30 if ( !ini_get( 'register_globals' ) ) |
30 if ( ! ini_get( 'register_globals' ) ) { |
31 return; |
31 return; |
32 |
32 } |
33 if ( isset( $_REQUEST['GLOBALS'] ) ) |
33 |
|
34 if ( isset( $_REQUEST['GLOBALS'] ) ) { |
34 die( 'GLOBALS overwrite attempt detected' ); |
35 die( 'GLOBALS overwrite attempt detected' ); |
|
36 } |
35 |
37 |
36 // Variables that shouldn't be unset |
38 // Variables that shouldn't be unset |
37 $no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' ); |
39 $no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' ); |
38 |
40 |
39 $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() ); |
41 $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() ); |
40 foreach ( $input as $k => $v ) |
42 foreach ( $input as $k => $v ) { |
41 if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) { |
43 if ( ! in_array( $k, $no_unset ) && isset( $GLOBALS[ $k ] ) ) { |
42 unset( $GLOBALS[$k] ); |
44 unset( $GLOBALS[ $k ] ); |
43 } |
45 } |
|
46 } |
44 } |
47 } |
45 |
48 |
46 /** |
49 /** |
47 * Fix `$_SERVER` variables for various setups. |
50 * Fix `$_SERVER` variables for various setups. |
48 * |
51 * |
55 function wp_fix_server_vars() { |
58 function wp_fix_server_vars() { |
56 global $PHP_SELF; |
59 global $PHP_SELF; |
57 |
60 |
58 $default_server_values = array( |
61 $default_server_values = array( |
59 'SERVER_SOFTWARE' => '', |
62 'SERVER_SOFTWARE' => '', |
60 'REQUEST_URI' => '', |
63 'REQUEST_URI' => '', |
61 ); |
64 ); |
62 |
65 |
63 $_SERVER = array_merge( $default_server_values, $_SERVER ); |
66 $_SERVER = array_merge( $default_server_values, $_SERVER ); |
64 |
67 |
65 // Fix for IIS when running with PHP ISAPI |
68 // Fix for IIS when running with PHP ISAPI |
66 if ( empty( $_SERVER['REQUEST_URI'] ) || ( PHP_SAPI != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) { |
69 if ( empty( $_SERVER['REQUEST_URI'] ) || ( PHP_SAPI != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) { |
67 |
70 |
68 // IIS Mod-Rewrite |
|
69 if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) { |
71 if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) { |
|
72 // IIS Mod-Rewrite |
70 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; |
73 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; |
71 } |
74 } elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) { |
72 // IIS Isapi_Rewrite |
75 // IIS Isapi_Rewrite |
73 elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) { |
|
74 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; |
76 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; |
75 } else { |
77 } else { |
76 // Use ORIG_PATH_INFO if there is no PATH_INFO |
78 // Use ORIG_PATH_INFO if there is no PATH_INFO |
77 if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) |
79 if ( ! isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) { |
78 $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; |
80 $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; |
|
81 } |
79 |
82 |
80 // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) |
83 // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) |
81 if ( isset( $_SERVER['PATH_INFO'] ) ) { |
84 if ( isset( $_SERVER['PATH_INFO'] ) ) { |
82 if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) |
85 if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) { |
83 $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; |
86 $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; |
84 else |
87 } else { |
85 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; |
88 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; |
|
89 } |
86 } |
90 } |
87 |
91 |
88 // Append the query string if it exists and isn't null |
92 // Append the query string if it exists and isn't null |
89 if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { |
93 if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { |
90 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
94 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
91 } |
95 } |
92 } |
96 } |
93 } |
97 } |
94 |
98 |
95 // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests |
99 // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests |
96 if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) |
100 if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) { |
97 $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; |
101 $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; |
|
102 } |
98 |
103 |
99 // Fix for Dreamhost and other PHP as CGI hosts |
104 // Fix for Dreamhost and other PHP as CGI hosts |
100 if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) |
105 if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) { |
101 unset( $_SERVER['PATH_INFO'] ); |
106 unset( $_SERVER['PATH_INFO'] ); |
|
107 } |
102 |
108 |
103 // Fix empty PHP_SELF |
109 // Fix empty PHP_SELF |
104 $PHP_SELF = $_SERVER['PHP_SELF']; |
110 $PHP_SELF = $_SERVER['PHP_SELF']; |
105 if ( empty( $PHP_SELF ) ) |
111 if ( empty( $PHP_SELF ) ) { |
106 $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] ); |
112 $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER['REQUEST_URI'] ); |
|
113 } |
107 } |
114 } |
108 |
115 |
109 /** |
116 /** |
110 * Check for the required PHP version, and the MySQL extension or |
117 * Check for the required PHP version, and the MySQL extension or |
111 * a database drop-in. |
118 * a database drop-in. |
127 |
134 |
128 $protocol = wp_get_server_protocol(); |
135 $protocol = wp_get_server_protocol(); |
129 header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); |
136 header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); |
130 header( 'Content-Type: text/html; charset=utf-8' ); |
137 header( 'Content-Type: text/html; charset=utf-8' ); |
131 /* translators: 1: Current PHP version number, 2: WordPress version number, 3: Minimum required PHP version number */ |
138 /* translators: 1: Current PHP version number, 2: WordPress version number, 3: Minimum required PHP version number */ |
132 die( sprintf( __( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.' ), $php_version, $wp_version, $required_php_version ) ); |
139 printf( __( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.' ), $php_version, $wp_version, $required_php_version ); |
|
140 exit( 1 ); |
133 } |
141 } |
134 |
142 |
135 if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! extension_loaded( 'mysqlnd' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) { |
143 if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! extension_loaded( 'mysqlnd' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) { |
|
144 require_once( ABSPATH . WPINC . '/functions.php' ); |
136 wp_load_translations_early(); |
145 wp_load_translations_early(); |
137 |
146 $args = array( |
138 $protocol = wp_get_server_protocol(); |
147 'exit' => false, |
139 header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); |
148 'code' => 'mysql_not_found', |
140 header( 'Content-Type: text/html; charset=utf-8' ); |
149 ); |
141 die( __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ) ); |
150 wp_die( |
|
151 __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ), |
|
152 __( 'Insufficient Requirements' ), |
|
153 $args |
|
154 ); |
|
155 exit( 1 ); |
142 } |
156 } |
143 } |
157 } |
144 |
158 |
145 /** |
159 /** |
146 * Don't load all of WordPress when handling a favicon.ico request. |
160 * Don't load all of WordPress when handling a favicon.ico request. |
311 * |
319 * |
312 * @since 4.6.0 |
320 * @since 4.6.0 |
313 * |
321 * |
314 * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true. |
322 * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true. |
315 */ |
323 */ |
316 if ( ! apply_filters( 'enable_wp_debug_mode_checks', true ) ){ |
324 if ( ! apply_filters( 'enable_wp_debug_mode_checks', true ) ) { |
317 return; |
325 return; |
318 } |
326 } |
319 |
327 |
320 if ( WP_DEBUG ) { |
328 if ( WP_DEBUG ) { |
321 error_reporting( E_ALL ); |
329 error_reporting( E_ALL ); |
322 |
330 |
323 if ( WP_DEBUG_DISPLAY ) |
331 if ( WP_DEBUG_DISPLAY ) { |
324 ini_set( 'display_errors', 1 ); |
332 ini_set( 'display_errors', 1 ); |
325 elseif ( null !== WP_DEBUG_DISPLAY ) |
333 } elseif ( null !== WP_DEBUG_DISPLAY ) { |
326 ini_set( 'display_errors', 0 ); |
334 ini_set( 'display_errors', 0 ); |
327 |
335 } |
328 if ( WP_DEBUG_LOG ) { |
336 |
|
337 if ( in_array( strtolower( (string) WP_DEBUG_LOG ), array( 'true', '1' ), true ) ) { |
|
338 $log_path = WP_CONTENT_DIR . '/debug.log'; |
|
339 } elseif ( is_string( WP_DEBUG_LOG ) ) { |
|
340 $log_path = WP_DEBUG_LOG; |
|
341 } else { |
|
342 $log_path = false; |
|
343 } |
|
344 |
|
345 if ( $log_path ) { |
329 ini_set( 'log_errors', 1 ); |
346 ini_set( 'log_errors', 1 ); |
330 ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' ); |
347 ini_set( 'error_log', $log_path ); |
331 } |
348 } |
332 } else { |
349 } else { |
333 error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); |
350 error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); |
334 } |
351 } |
335 |
352 |
336 if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() ) { |
353 if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() || wp_is_json_request() ) { |
337 @ini_set( 'display_errors', 0 ); |
354 @ini_set( 'display_errors', 0 ); |
338 } |
355 } |
339 } |
356 } |
340 |
357 |
341 /** |
358 /** |
416 * @global wpdb $wpdb The WordPress database class. |
439 * @global wpdb $wpdb The WordPress database class. |
417 * @global string $table_prefix The database table prefix. |
440 * @global string $table_prefix The database table prefix. |
418 */ |
441 */ |
419 function wp_set_wpdb_vars() { |
442 function wp_set_wpdb_vars() { |
420 global $wpdb, $table_prefix; |
443 global $wpdb, $table_prefix; |
421 if ( !empty( $wpdb->error ) ) |
444 if ( ! empty( $wpdb->error ) ) { |
422 dead_db(); |
445 dead_db(); |
423 |
446 } |
424 $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', |
447 |
425 'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', |
448 $wpdb->field_types = array( |
426 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d', |
449 'post_author' => '%d', |
427 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d', |
450 'post_parent' => '%d', |
|
451 'menu_order' => '%d', |
|
452 'term_id' => '%d', |
|
453 'term_group' => '%d', |
|
454 'term_taxonomy_id' => '%d', |
|
455 'parent' => '%d', |
|
456 'count' => '%d', |
|
457 'object_id' => '%d', |
|
458 'term_order' => '%d', |
|
459 'ID' => '%d', |
|
460 'comment_ID' => '%d', |
|
461 'comment_post_ID' => '%d', |
|
462 'comment_parent' => '%d', |
|
463 'user_id' => '%d', |
|
464 'link_id' => '%d', |
|
465 'link_owner' => '%d', |
|
466 'link_rating' => '%d', |
|
467 'option_id' => '%d', |
|
468 'blog_id' => '%d', |
|
469 'meta_id' => '%d', |
|
470 'post_id' => '%d', |
|
471 'user_status' => '%d', |
|
472 'umeta_id' => '%d', |
|
473 'comment_karma' => '%d', |
|
474 'comment_count' => '%d', |
428 // multisite: |
475 // multisite: |
429 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d', |
476 'active' => '%d', |
|
477 'cat_id' => '%d', |
|
478 'deleted' => '%d', |
|
479 'lang_id' => '%d', |
|
480 'mature' => '%d', |
|
481 'public' => '%d', |
|
482 'site_id' => '%d', |
|
483 'spam' => '%d', |
430 ); |
484 ); |
431 |
485 |
432 $prefix = $wpdb->set_prefix( $table_prefix ); |
486 $prefix = $wpdb->set_prefix( $table_prefix ); |
433 |
487 |
434 if ( is_wp_error( $prefix ) ) { |
488 if ( is_wp_error( $prefix ) ) { |
435 wp_load_translations_early(); |
489 wp_load_translations_early(); |
436 wp_die( |
490 wp_die( |
437 /* translators: 1: $table_prefix 2: wp-config.php */ |
491 /* translators: 1: $table_prefix, 2: wp-config.php */ |
438 sprintf( __( '<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.' ), |
492 sprintf( |
|
493 __( '<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.' ), |
439 '<code>$table_prefix</code>', |
494 '<code>$table_prefix</code>', |
440 '<code>wp-config.php</code>' |
495 '<code>wp-config.php</code>' |
441 ) |
496 ) |
442 ); |
497 ); |
443 } |
498 } |
473 * |
529 * |
474 * @global array $wp_filter Stores all of the filters. |
530 * @global array $wp_filter Stores all of the filters. |
475 */ |
531 */ |
476 function wp_start_object_cache() { |
532 function wp_start_object_cache() { |
477 global $wp_filter; |
533 global $wp_filter; |
478 |
534 static $first_init = true; |
479 $first_init = false; |
535 |
480 if ( ! function_exists( 'wp_cache_init' ) ) { |
536 // Only perform the following checks once. |
481 if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
537 if ( $first_init ) { |
482 require_once ( WP_CONTENT_DIR . '/object-cache.php' ); |
538 if ( ! function_exists( 'wp_cache_init' ) ) { |
483 if ( function_exists( 'wp_cache_init' ) ) { |
539 /* |
484 wp_using_ext_object_cache( true ); |
540 * This is the normal situation. First-run of this function. No |
|
541 * caching backend has been loaded. |
|
542 * |
|
543 * We try to load a custom caching backend, and then, if it |
|
544 * results in a wp_cache_init() function existing, we note |
|
545 * that an external object cache is being used. |
|
546 */ |
|
547 if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
|
548 require_once( WP_CONTENT_DIR . '/object-cache.php' ); |
|
549 if ( function_exists( 'wp_cache_init' ) ) { |
|
550 wp_using_ext_object_cache( true ); |
|
551 } |
|
552 |
|
553 // Re-initialize any hooks added manually by object-cache.php |
|
554 if ( $wp_filter ) { |
|
555 $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); |
|
556 } |
485 } |
557 } |
486 |
558 } elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
487 // Re-initialize any hooks added manually by object-cache.php |
559 /* |
488 if ( $wp_filter ) { |
560 * Sometimes advanced-cache.php can load object-cache.php before |
489 $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); |
561 * this function is run. This breaks the function_exists() check |
490 } |
562 * above and can result in wp_using_ext_object_cache() returning |
491 } |
563 * false when actually an external cache is in use. |
492 |
564 */ |
493 $first_init = true; |
565 wp_using_ext_object_cache( true ); |
494 } elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
566 } |
495 /* |
|
496 * Sometimes advanced-cache.php can load object-cache.php before |
|
497 * it is loaded here. This breaks the function_exists check above |
|
498 * and can result in `$_wp_using_ext_object_cache` being set |
|
499 * incorrectly. Double check if an external cache exists. |
|
500 */ |
|
501 wp_using_ext_object_cache( true ); |
|
502 } |
567 } |
503 |
568 |
504 if ( ! wp_using_ext_object_cache() ) { |
569 if ( ! wp_using_ext_object_cache() ) { |
505 require_once ( ABSPATH . WPINC . '/cache.php' ); |
570 require_once( ABSPATH . WPINC . '/cache.php' ); |
506 } |
571 } |
507 |
572 |
508 /* |
573 /* |
509 * If cache supports reset, reset instead of init if already |
574 * If cache supports reset, reset instead of init if already |
510 * initialized. Reset signals to the cache that global IDs |
575 * initialized. Reset signals to the cache that global IDs |
582 /** |
651 /** |
583 * Retrieve an array of active and valid plugin files. |
652 * Retrieve an array of active and valid plugin files. |
584 * |
653 * |
585 * While upgrading or installing WordPress, no plugins are returned. |
654 * While upgrading or installing WordPress, no plugins are returned. |
586 * |
655 * |
587 * The default directory is wp-content/plugins. To change the default |
656 * The default directory is `wp-content/plugins`. To change the default |
588 * directory manually, define `WP_PLUGIN_DIR` and `WP_PLUGIN_URL` |
657 * directory manually, define `WP_PLUGIN_DIR` and `WP_PLUGIN_URL` |
589 * in wp-config.php. |
658 * in `wp-config.php`. |
590 * |
659 * |
591 * @since 3.0.0 |
660 * @since 3.0.0 |
592 * @access private |
661 * @access private |
593 * |
662 * |
594 * @return array Files. |
663 * @return string[] $plugin_file Array of paths to plugin files relative to the plugins directory. |
595 */ |
664 */ |
596 function wp_get_active_and_valid_plugins() { |
665 function wp_get_active_and_valid_plugins() { |
597 $plugins = array(); |
666 $plugins = array(); |
598 $active_plugins = (array) get_option( 'active_plugins', array() ); |
667 $active_plugins = (array) get_option( 'active_plugins', array() ); |
599 |
668 |
600 // Check for hacks file if the option is enabled |
669 // Check for hacks file if the option is enabled |
601 if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) { |
670 if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) { |
602 _deprecated_file( 'my-hacks.php', '1.5.0' ); |
671 _deprecated_file( 'my-hacks.php', '1.5.0' ); |
603 array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); |
672 array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); |
604 } |
673 } |
605 |
674 |
606 if ( empty( $active_plugins ) || wp_installing() ) |
675 if ( empty( $active_plugins ) || wp_installing() ) { |
607 return $plugins; |
676 return $plugins; |
|
677 } |
608 |
678 |
609 $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; |
679 $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; |
610 |
680 |
611 foreach ( $active_plugins as $plugin ) { |
681 foreach ( $active_plugins as $plugin ) { |
612 if ( ! validate_file( $plugin ) // $plugin must validate as file |
682 if ( ! validate_file( $plugin ) // $plugin must validate as file |
613 && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php' |
683 && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php' |
614 && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist |
684 && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist |
615 // not already included as a network plugin |
685 // not already included as a network plugin |
616 && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) ) |
686 && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) ) |
617 ) |
687 ) { |
618 $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
688 $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
619 } |
689 } |
|
690 } |
|
691 |
|
692 /* |
|
693 * Remove plugins from the list of active plugins when we're on an endpoint |
|
694 * that should be protected against WSODs and the plugin is paused. |
|
695 */ |
|
696 if ( wp_is_recovery_mode() ) { |
|
697 $plugins = wp_skip_paused_plugins( $plugins ); |
|
698 } |
|
699 |
620 return $plugins; |
700 return $plugins; |
|
701 } |
|
702 |
|
703 /** |
|
704 * Filters a given list of plugins, removing any paused plugins from it. |
|
705 * |
|
706 * @since 5.2.0 |
|
707 * |
|
708 * @param array $plugins List of absolute plugin main file paths. |
|
709 * @return array Filtered value of $plugins, without any paused plugins. |
|
710 */ |
|
711 function wp_skip_paused_plugins( array $plugins ) { |
|
712 $paused_plugins = wp_paused_plugins()->get_all(); |
|
713 |
|
714 if ( empty( $paused_plugins ) ) { |
|
715 return $plugins; |
|
716 } |
|
717 |
|
718 foreach ( $plugins as $index => $plugin ) { |
|
719 list( $plugin ) = explode( '/', plugin_basename( $plugin ) ); |
|
720 |
|
721 if ( array_key_exists( $plugin, $paused_plugins ) ) { |
|
722 unset( $plugins[ $index ] ); |
|
723 |
|
724 // Store list of paused plugins for displaying an admin notice. |
|
725 $GLOBALS['_paused_plugins'][ $plugin ] = $paused_plugins[ $plugin ]; |
|
726 } |
|
727 } |
|
728 |
|
729 return $plugins; |
|
730 } |
|
731 |
|
732 /** |
|
733 * Retrieves an array of active and valid themes. |
|
734 * |
|
735 * While upgrading or installing WordPress, no themes are returned. |
|
736 * |
|
737 * @since 5.1.0 |
|
738 * @access private |
|
739 * |
|
740 * @return array Array of paths to theme directories. |
|
741 */ |
|
742 function wp_get_active_and_valid_themes() { |
|
743 global $pagenow; |
|
744 |
|
745 $themes = array(); |
|
746 |
|
747 if ( wp_installing() && 'wp-activate.php' !== $pagenow ) { |
|
748 return $themes; |
|
749 } |
|
750 |
|
751 if ( TEMPLATEPATH !== STYLESHEETPATH ) { |
|
752 $themes[] = STYLESHEETPATH; |
|
753 } |
|
754 |
|
755 $themes[] = TEMPLATEPATH; |
|
756 |
|
757 /* |
|
758 * Remove themes from the list of active themes when we're on an endpoint |
|
759 * that should be protected against WSODs and the theme is paused. |
|
760 */ |
|
761 if ( wp_is_recovery_mode() ) { |
|
762 $themes = wp_skip_paused_themes( $themes ); |
|
763 |
|
764 // If no active and valid themes exist, skip loading themes. |
|
765 if ( empty( $themes ) ) { |
|
766 add_filter( 'wp_using_themes', '__return_false' ); |
|
767 } |
|
768 } |
|
769 |
|
770 return $themes; |
|
771 } |
|
772 |
|
773 /** |
|
774 * Filters a given list of themes, removing any paused themes from it. |
|
775 * |
|
776 * @since 5.2.0 |
|
777 * |
|
778 * @param array $themes List of absolute theme directory paths. |
|
779 * @return array Filtered value of $themes, without any paused themes. |
|
780 */ |
|
781 function wp_skip_paused_themes( array $themes ) { |
|
782 $paused_themes = wp_paused_themes()->get_all(); |
|
783 |
|
784 if ( empty( $paused_themes ) ) { |
|
785 return $themes; |
|
786 } |
|
787 |
|
788 foreach ( $themes as $index => $theme ) { |
|
789 $theme = basename( $theme ); |
|
790 |
|
791 if ( array_key_exists( $theme, $paused_themes ) ) { |
|
792 unset( $themes[ $index ] ); |
|
793 |
|
794 // Store list of paused themes for displaying an admin notice. |
|
795 $GLOBALS['_paused_themes'][ $theme ] = $paused_themes[ $theme ]; |
|
796 } |
|
797 } |
|
798 |
|
799 return $themes; |
|
800 } |
|
801 |
|
802 /** |
|
803 * Is WordPress in Recovery Mode. |
|
804 * |
|
805 * In this mode, plugins or themes that cause WSODs will be paused. |
|
806 * |
|
807 * @since 5.2.0 |
|
808 * |
|
809 * @return bool |
|
810 */ |
|
811 function wp_is_recovery_mode() { |
|
812 return wp_recovery_mode()->is_active(); |
|
813 } |
|
814 |
|
815 /** |
|
816 * Determines whether we are currently on an endpoint that should be protected against WSODs. |
|
817 * |
|
818 * @since 5.2.0 |
|
819 * |
|
820 * @return bool True if the current endpoint should be protected. |
|
821 */ |
|
822 function is_protected_endpoint() { |
|
823 // Protect login pages. |
|
824 if ( isset( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { |
|
825 return true; |
|
826 } |
|
827 |
|
828 // Protect the admin backend. |
|
829 if ( is_admin() && ! wp_doing_ajax() ) { |
|
830 return true; |
|
831 } |
|
832 |
|
833 // Protect AJAX actions that could help resolve a fatal error should be available. |
|
834 if ( is_protected_ajax_action() ) { |
|
835 return true; |
|
836 } |
|
837 |
|
838 /** |
|
839 * Filters whether the current request is against a protected endpoint. |
|
840 * |
|
841 * This filter is only fired when an endpoint is requested which is not already protected by |
|
842 * WordPress core. As such, it exclusively allows providing further protected endpoints in |
|
843 * addition to the admin backend, login pages and protected AJAX actions. |
|
844 * |
|
845 * @since 5.2.0 |
|
846 * |
|
847 * @param bool $is_protected_endpoint Whether the currently requested endpoint is protected. Default false. |
|
848 */ |
|
849 return (bool) apply_filters( 'is_protected_endpoint', false ); |
|
850 } |
|
851 |
|
852 /** |
|
853 * Determines whether we are currently handling an AJAX action that should be protected against WSODs. |
|
854 * |
|
855 * @since 5.2.0 |
|
856 * |
|
857 * @return bool True if the current AJAX action should be protected. |
|
858 */ |
|
859 function is_protected_ajax_action() { |
|
860 if ( ! wp_doing_ajax() ) { |
|
861 return false; |
|
862 } |
|
863 |
|
864 if ( ! isset( $_REQUEST['action'] ) ) { |
|
865 return false; |
|
866 } |
|
867 |
|
868 $actions_to_protect = array( |
|
869 'edit-theme-plugin-file', // Saving changes in the core code editor. |
|
870 'heartbeat', // Keep the heart beating. |
|
871 'install-plugin', // Installing a new plugin. |
|
872 'install-theme', // Installing a new theme. |
|
873 'search-plugins', // Searching in the list of plugins. |
|
874 'search-install-plugins', // Searching for a plugin in the plugin install screen. |
|
875 'update-plugin', // Update an existing plugin. |
|
876 'update-theme', // Update an existing theme. |
|
877 ); |
|
878 |
|
879 /** |
|
880 * Filters the array of protected AJAX actions. |
|
881 * |
|
882 * This filter is only fired when doing AJAX and the AJAX request has an 'action' property. |
|
883 * |
|
884 * @since 5.2.0 |
|
885 * |
|
886 * @param array $actions_to_protect Array of strings with AJAX actions to protect. |
|
887 */ |
|
888 $actions_to_protect = (array) apply_filters( 'wp_protected_ajax_actions', $actions_to_protect ); |
|
889 |
|
890 if ( ! in_array( $_REQUEST['action'], $actions_to_protect, true ) ) { |
|
891 return false; |
|
892 } |
|
893 |
|
894 return true; |
621 } |
895 } |
622 |
896 |
623 /** |
897 /** |
624 * Set internal encoding. |
898 * Set internal encoding. |
625 * |
899 * |
694 // Use parens for clone to accommodate PHP 4. See #17880 |
969 // Use parens for clone to accommodate PHP 4. See #17880 |
695 return clone( $object ); |
970 return clone( $object ); |
696 } |
971 } |
697 |
972 |
698 /** |
973 /** |
699 * Whether the current request is for an administrative interface page. |
974 * Determines whether the current request is for an administrative interface page. |
700 * |
975 * |
701 * Does not check if the user is an administrator; current_user_can() |
976 * Does not check if the user is an administrator; use current_user_can() |
702 * for checking roles and capabilities. |
977 * for checking roles and capabilities. |
703 * |
978 * |
|
979 * For more information on this and similar theme functions, check out |
|
980 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ |
|
981 * Conditional Tags} article in the Theme Developer Handbook. |
|
982 * |
704 * @since 1.5.1 |
983 * @since 1.5.1 |
705 * |
984 * |
706 * @global WP_Screen $current_screen |
985 * @global WP_Screen $current_screen |
707 * |
986 * |
708 * @return bool True if inside WordPress administration interface, false otherwise. |
987 * @return bool True if inside WordPress administration interface, false otherwise. |
709 */ |
988 */ |
710 function is_admin() { |
989 function is_admin() { |
711 if ( isset( $GLOBALS['current_screen'] ) ) |
990 if ( isset( $GLOBALS['current_screen'] ) ) { |
712 return $GLOBALS['current_screen']->in_admin(); |
991 return $GLOBALS['current_screen']->in_admin(); |
713 elseif ( defined( 'WP_ADMIN' ) ) |
992 } elseif ( defined( 'WP_ADMIN' ) ) { |
714 return WP_ADMIN; |
993 return WP_ADMIN; |
|
994 } |
715 |
995 |
716 return false; |
996 return false; |
717 } |
997 } |
718 |
998 |
719 /** |
999 /** |
720 * Whether the current request is for a site's admininstrative interface. |
1000 * Whether the current request is for a site's admininstrative interface. |
721 * |
1001 * |
722 * e.g. `/wp-admin/` |
1002 * e.g. `/wp-admin/` |
723 * |
1003 * |
724 * Does not check if the user is an administrator; current_user_can() |
1004 * Does not check if the user is an administrator; use current_user_can() |
725 * for checking roles and capabilities. |
1005 * for checking roles and capabilities. |
726 * |
1006 * |
727 * @since 3.1.0 |
1007 * @since 3.1.0 |
728 * |
1008 * |
729 * @global WP_Screen $current_screen |
1009 * @global WP_Screen $current_screen |
730 * |
1010 * |
731 * @return bool True if inside WordPress blog administration pages. |
1011 * @return bool True if inside WordPress blog administration pages. |
732 */ |
1012 */ |
733 function is_blog_admin() { |
1013 function is_blog_admin() { |
734 if ( isset( $GLOBALS['current_screen'] ) ) |
1014 if ( isset( $GLOBALS['current_screen'] ) ) { |
735 return $GLOBALS['current_screen']->in_admin( 'site' ); |
1015 return $GLOBALS['current_screen']->in_admin( 'site' ); |
736 elseif ( defined( 'WP_BLOG_ADMIN' ) ) |
1016 } elseif ( defined( 'WP_BLOG_ADMIN' ) ) { |
737 return WP_BLOG_ADMIN; |
1017 return WP_BLOG_ADMIN; |
|
1018 } |
738 |
1019 |
739 return false; |
1020 return false; |
740 } |
1021 } |
741 |
1022 |
742 /** |
1023 /** |
743 * Whether the current request is for the network administrative interface. |
1024 * Whether the current request is for the network administrative interface. |
744 * |
1025 * |
745 * e.g. `/wp-admin/network/` |
1026 * e.g. `/wp-admin/network/` |
746 * |
1027 * |
747 * Does not check if the user is an administrator; current_user_can() |
1028 * Does not check if the user is an administrator; use current_user_can() |
748 * for checking roles and capabilities. |
1029 * for checking roles and capabilities. |
749 * |
1030 * |
750 * @since 3.1.0 |
1031 * @since 3.1.0 |
751 * |
1032 * |
752 * @global WP_Screen $current_screen |
1033 * @global WP_Screen $current_screen |
753 * |
1034 * |
754 * @return bool True if inside WordPress network administration pages. |
1035 * @return bool True if inside WordPress network administration pages. |
755 */ |
1036 */ |
756 function is_network_admin() { |
1037 function is_network_admin() { |
757 if ( isset( $GLOBALS['current_screen'] ) ) |
1038 if ( isset( $GLOBALS['current_screen'] ) ) { |
758 return $GLOBALS['current_screen']->in_admin( 'network' ); |
1039 return $GLOBALS['current_screen']->in_admin( 'network' ); |
759 elseif ( defined( 'WP_NETWORK_ADMIN' ) ) |
1040 } elseif ( defined( 'WP_NETWORK_ADMIN' ) ) { |
760 return WP_NETWORK_ADMIN; |
1041 return WP_NETWORK_ADMIN; |
|
1042 } |
761 |
1043 |
762 return false; |
1044 return false; |
763 } |
1045 } |
764 |
1046 |
765 /** |
1047 /** |
766 * Whether the current request is for a user admin screen. |
1048 * Whether the current request is for a user admin screen. |
767 * |
1049 * |
768 * e.g. `/wp-admin/user/` |
1050 * e.g. `/wp-admin/user/` |
769 * |
1051 * |
770 * Does not inform on whether the user is an admin! Use capability |
1052 * Does not check if the user is an administrator; use current_user_can() |
771 * checks to tell if the user should be accessing a section or not |
1053 * for checking roles and capabilities. |
772 * current_user_can(). |
|
773 * |
1054 * |
774 * @since 3.1.0 |
1055 * @since 3.1.0 |
775 * |
1056 * |
776 * @global WP_Screen $current_screen |
1057 * @global WP_Screen $current_screen |
777 * |
1058 * |
778 * @return bool True if inside WordPress user administration pages. |
1059 * @return bool True if inside WordPress user administration pages. |
779 */ |
1060 */ |
780 function is_user_admin() { |
1061 function is_user_admin() { |
781 if ( isset( $GLOBALS['current_screen'] ) ) |
1062 if ( isset( $GLOBALS['current_screen'] ) ) { |
782 return $GLOBALS['current_screen']->in_admin( 'user' ); |
1063 return $GLOBALS['current_screen']->in_admin( 'user' ); |
783 elseif ( defined( 'WP_USER_ADMIN' ) ) |
1064 } elseif ( defined( 'WP_USER_ADMIN' ) ) { |
784 return WP_USER_ADMIN; |
1065 return WP_USER_ADMIN; |
|
1066 } |
785 |
1067 |
786 return false; |
1068 return false; |
787 } |
1069 } |
788 |
1070 |
789 /** |
1071 /** |
880 |
1166 |
881 $locales = $locations = array(); |
1167 $locales = $locations = array(); |
882 |
1168 |
883 while ( true ) { |
1169 while ( true ) { |
884 if ( defined( 'WPLANG' ) ) { |
1170 if ( defined( 'WPLANG' ) ) { |
885 if ( '' == WPLANG ) |
1171 if ( '' == WPLANG ) { |
886 break; |
1172 break; |
|
1173 } |
887 $locales[] = WPLANG; |
1174 $locales[] = WPLANG; |
888 } |
1175 } |
889 |
1176 |
890 if ( isset( $wp_local_package ) ) |
1177 if ( isset( $wp_local_package ) ) { |
891 $locales[] = $wp_local_package; |
1178 $locales[] = $wp_local_package; |
892 |
1179 } |
893 if ( ! $locales ) |
1180 |
|
1181 if ( ! $locales ) { |
894 break; |
1182 break; |
895 |
1183 } |
896 if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) |
1184 |
|
1185 if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) { |
897 $locations[] = WP_LANG_DIR; |
1186 $locations[] = WP_LANG_DIR; |
898 |
1187 } |
899 if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) |
1188 |
|
1189 if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) { |
900 $locations[] = WP_CONTENT_DIR . '/languages'; |
1190 $locations[] = WP_CONTENT_DIR . '/languages'; |
901 |
1191 } |
902 if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) |
1192 |
|
1193 if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) { |
903 $locations[] = ABSPATH . 'wp-content/languages'; |
1194 $locations[] = ABSPATH . 'wp-content/languages'; |
904 |
1195 } |
905 if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) |
1196 |
|
1197 if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) { |
906 $locations[] = ABSPATH . WPINC . '/languages'; |
1198 $locations[] = ABSPATH . WPINC . '/languages'; |
907 |
1199 } |
908 if ( ! $locations ) |
1200 |
|
1201 if ( ! $locations ) { |
909 break; |
1202 break; |
|
1203 } |
910 |
1204 |
911 $locations = array_unique( $locations ); |
1205 $locations = array_unique( $locations ); |
912 |
1206 |
913 foreach ( $locales as $locale ) { |
1207 foreach ( $locales as $locale ) { |
914 foreach ( $locations as $location ) { |
1208 foreach ( $locations as $location ) { |
915 if ( file_exists( $location . '/' . $locale . '.mo' ) ) { |
1209 if ( file_exists( $location . '/' . $locale . '.mo' ) ) { |
916 load_textdomain( 'default', $location . '/' . $locale . '.mo' ); |
1210 load_textdomain( 'default', $location . '/' . $locale . '.mo' ); |
917 if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) |
1211 if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) { |
918 load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' ); |
1212 load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' ); |
|
1213 } |
919 break 2; |
1214 break 2; |
920 } |
1215 } |
921 } |
1216 } |
922 } |
1217 } |
923 |
1218 |
1122 */ |
1435 */ |
1123 function wp_start_scraping_edited_file_errors() { |
1436 function wp_start_scraping_edited_file_errors() { |
1124 if ( ! isset( $_REQUEST['wp_scrape_key'] ) || ! isset( $_REQUEST['wp_scrape_nonce'] ) ) { |
1437 if ( ! isset( $_REQUEST['wp_scrape_key'] ) || ! isset( $_REQUEST['wp_scrape_nonce'] ) ) { |
1125 return; |
1438 return; |
1126 } |
1439 } |
1127 $key = substr( sanitize_key( wp_unslash( $_REQUEST['wp_scrape_key'] ) ), 0, 32 ); |
1440 $key = substr( sanitize_key( wp_unslash( $_REQUEST['wp_scrape_key'] ) ), 0, 32 ); |
1128 $nonce = wp_unslash( $_REQUEST['wp_scrape_nonce'] ); |
1441 $nonce = wp_unslash( $_REQUEST['wp_scrape_nonce'] ); |
1129 |
1442 |
1130 if ( get_transient( 'scrape_key_' . $key ) !== $nonce ) { |
1443 if ( get_transient( 'scrape_key_' . $key ) !== $nonce ) { |
1131 echo "###### wp_scraping_result_start:$key ######"; |
1444 echo "###### wp_scraping_result_start:$key ######"; |
1132 echo wp_json_encode( array( |
1445 echo wp_json_encode( |
1133 'code' => 'scrape_nonce_failure', |
1446 array( |
1134 'message' => __( 'Scrape nonce check failed. Please try again.' ), |
1447 'code' => 'scrape_nonce_failure', |
1135 ) ); |
1448 'message' => __( 'Scrape nonce check failed. Please try again.' ), |
|
1449 ) |
|
1450 ); |
1136 echo "###### wp_scraping_result_end:$key ######"; |
1451 echo "###### wp_scraping_result_end:$key ######"; |
1137 die(); |
1452 die(); |
|
1453 } |
|
1454 if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) { |
|
1455 define( 'WP_SANDBOX_SCRAPING', true ); |
1138 } |
1456 } |
1139 register_shutdown_function( 'wp_finalize_scraping_edited_file_errors', $key ); |
1457 register_shutdown_function( 'wp_finalize_scraping_edited_file_errors', $key ); |
1140 } |
1458 } |
1141 |
1459 |
1142 /** |
1460 /** |
1155 } else { |
1473 } else { |
1156 echo wp_json_encode( true ); |
1474 echo wp_json_encode( true ); |
1157 } |
1475 } |
1158 echo "\n###### wp_scraping_result_end:$scrape_key ######\n"; |
1476 echo "\n###### wp_scraping_result_end:$scrape_key ######\n"; |
1159 } |
1477 } |
|
1478 |
|
1479 /** |
|
1480 * Checks whether current request is a JSON request, or is expecting a JSON response. |
|
1481 * |
|
1482 * @since 5.0.0 |
|
1483 * |
|
1484 * @return bool True if Accepts or Content-Type headers contain application/json, false otherwise. |
|
1485 */ |
|
1486 function wp_is_json_request() { |
|
1487 |
|
1488 if ( isset( $_SERVER['HTTP_ACCEPT'] ) && false !== strpos( $_SERVER['HTTP_ACCEPT'], 'application/json' ) ) { |
|
1489 return true; |
|
1490 } |
|
1491 |
|
1492 if ( isset( $_SERVER['CONTENT_TYPE'] ) && 'application/json' === $_SERVER['CONTENT_TYPE'] ) { |
|
1493 return true; |
|
1494 } |
|
1495 |
|
1496 return false; |
|
1497 |
|
1498 } |
|
1499 |
|
1500 /** |
|
1501 * Checks whether current request is a JSONP request, or is expecting a JSONP response. |
|
1502 * |
|
1503 * @since 5.2.0 |
|
1504 * |
|
1505 * @return bool True if JSONP request, false otherwise. |
|
1506 */ |
|
1507 function wp_is_jsonp_request() { |
|
1508 if ( ! isset( $_GET['_jsonp'] ) ) { |
|
1509 return false; |
|
1510 } |
|
1511 |
|
1512 if ( ! function_exists( 'wp_check_jsonp_callback' ) ) { |
|
1513 require_once ABSPATH . WPINC . '/functions.php'; |
|
1514 } |
|
1515 |
|
1516 $jsonp_callback = $_GET['_jsonp']; |
|
1517 if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) { |
|
1518 return false; |
|
1519 } |
|
1520 |
|
1521 /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */ |
|
1522 $jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true ); |
|
1523 |
|
1524 return $jsonp_enabled; |
|
1525 |
|
1526 } |
|
1527 |
|
1528 /** |
|
1529 * Checks whether current request is an XML request, or is expecting an XML response. |
|
1530 * |
|
1531 * @since 5.2.0 |
|
1532 * |
|
1533 * @return bool True if Accepts or Content-Type headers contain xml, false otherwise. |
|
1534 */ |
|
1535 function wp_is_xml_request() { |
|
1536 $accepted = array( |
|
1537 'text/xml', |
|
1538 'application/rss+xml', |
|
1539 'application/atom+xml', |
|
1540 'application/rdf+xml', |
|
1541 'text/xml+oembed', |
|
1542 'application/xml+oembed', |
|
1543 ); |
|
1544 |
|
1545 if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) { |
|
1546 foreach ( $accepted as $type ) { |
|
1547 if ( false !== strpos( $_SERVER['HTTP_ACCEPT'], $type ) ) { |
|
1548 return true; |
|
1549 } |
|
1550 } |
|
1551 } |
|
1552 |
|
1553 if ( isset( $_SERVER['CONTENT_TYPE'] ) && in_array( $_SERVER['CONTENT_TYPE'], $accepted, true ) ) { |
|
1554 return true; |
|
1555 } |
|
1556 |
|
1557 return false; |
|
1558 } |