| @@ -24,31 +24,59 @@ | ||
| 24 | 24 | return get_page_by_title( $page_title, $output, $post_type ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.get_page_by_title_get_page_by_title |
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | -if ( ! function_exists( 'wpcom_vip_get_page_by_path' ) ) { | |
| 28 | +if ( ! function_exists( 'wp_doing_ajax' ) ) { | |
| 29 | 29 | /** |
| 30 | - * Retrieves a page given its path. | |
| 30 | + * Determines whether the current request is a WordPress Ajax request. | |
| 31 | + * Backward compatibility function for WP < 4.7 | |
| 31 | 32 | * |
| 32 | - * @since 2.8.3 | |
| 33 | + * @since 2.2 | |
| 33 | 34 | * |
| 34 | - * @param string $page_path Page path. | |
| 35 | - * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to | |
| 36 | - * a WP_Post object, an associative array, or a numeric array, respectively. Default OBJECT. | |
| 37 | - * @param string|array $post_type Optional. Post type or array of post types. Default 'page'. | |
| 38 | - * @return WP_Post|array|null WP_Post (or array) on success, or null on failure. | |
| 35 | + * @return bool True if it's a WordPress Ajax request, false otherwise. | |
| 39 | 36 | */ |
| 40 | - function wpcom_vip_get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) { | |
| 41 | - return get_page_by_path( $page_path, $output, $post_type ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.get_page_by_path_get_page_by_path | |
| 37 | + function wp_doing_ajax() { | |
| 38 | + /** This filter is documented in wp-includes/load.php */ | |
| 39 | + return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ); | |
| 42 | 40 | } |
| 43 | 41 | } |
| 44 | 42 | |
| 43 | +if ( ! function_exists( 'wp_doing_cron' ) ) { | |
| 44 | + /** | |
| 45 | + * Determines whether the current request is a WordPress cron request. | |
| 46 | + * Backward compatibility function for WP < 4.8 | |
| 47 | + * | |
| 48 | + * @since 2.6 | |
| 49 | + * | |
| 50 | + * @return bool True if it's a WordPress cron request, false otherwise. | |
| 51 | + */ | |
| 52 | + function wp_doing_cron() { | |
| 53 | + /** This filter is documented in wp-includes/load.php */ | |
| 54 | + return apply_filters( 'wp_doing_cron', defined( 'DOING_CRON' ) && DOING_CRON ); | |
| 55 | + } | |
| 56 | +} | |
| 57 | + | |
| 58 | +if ( ! function_exists( 'wp_using_themes' ) ) { | |
| 59 | + /** | |
| 60 | + * Determines whether the current request should use themes. | |
| 61 | + * Backward compatibility function for WP < 5.1 | |
| 62 | + * | |
| 63 | + * @since 2.6 | |
| 64 | + * | |
| 65 | + * @return bool True if themes should be used, false otherwise. | |
| 66 | + */ | |
| 67 | + function wp_using_themes() { | |
| 68 | + /** This filter is documented in wp-includes/load.php */ | |
| 69 | + return apply_filters( 'wp_using_themes', defined( 'WP_USE_THEMES' ) && WP_USE_THEMES ); | |
| 70 | + } | |
| 71 | +} | |
| 72 | + | |
| 45 | 73 | /** |
| 46 | 74 | * Determines whether we should load the cache compatibility |
| 47 | 75 | * |
| 48 | 76 | * @since 2.3.8 |
| 49 | 77 | * |
| 50 | - * @return bool True if the cache compatibility must be loaded | |
| 78 | + * return bool True if the cache compatibility must be loaded | |
| 51 | 79 | */ |
| 52 | 80 | function pll_is_cache_active() { |
| 53 | 81 | /** |
| 54 | 82 | * Filters whether we should load the cache compatibility |
| @@ -94,9 +122,9 @@ | ||
| 94 | 122 | * Determines whether we should load the block editor plugin or the legacy languages metabox. |
| 95 | 123 | * |
| 96 | 124 | * @since 2.6.0 |
| 97 | 125 | * |
| 98 | - * @return bool True to use the block editor plugin. | |
| 126 | + * return bool True to use the block editor plugin. | |
| 99 | 127 | */ |
| 100 | 128 | function pll_use_block_editor_plugin() { |
| 101 | 129 | /** |
| 102 | 130 | * Filters whether we should load the block editor plugin or the legacy languages metabox. |