); global $wp_query, $post; $this->originalQuery = $this->deepClone( $wp_query ); $this->originalPost = is_a( $post, 'WP_Post' ) ? $this->deepClone( $post ) : null; $wp_query->posts = [ $wpPost ]; $wp_query->post = $wpPost; $wp_query->post_count = 1; $wp_query->get_queried_object_id = (int) $wpPost->ID; $wp_query->queried_object = $wpPost; $wp_query->is_single = true; $wp_query->is_singular = true; if ( 'page' === $wpPost->post_type ) { $wp_query->is_page = true; } $post = $wpPost; } /** * Restores the main query back to the original query. * * @since 4.3.0 * * @return void */ public function restoreWpQuery() { global $wp_query, $post; if ( is_a( $this->originalQuery, 'WP_Query' ) ) { // Loop over all properties and replace the ones that have changed. // We want to avoid replacing the entire object because it can cause issues with other plugins. foreach ( $this->originalQuery as $key => $value ) { if ( $value !== $wp_query->{$key} ) { $wp_query->{$key} = $value; } } } if ( is_a( $this->originalPost, 'WP_Post' ) ) { foreach ( $this->originalPost as $key => $value ) { if ( $value !== $post->{$key} ) { $post->{$key} = $value; } } } $this->originalQuery = null; $this->originalPost = null; } /** * Gets the list of theme features. * * @since 4.4.9 * * @return array List of theme features. */ public function getThemeFeatures() { global $_wp_theme_features; return isset( $_wp_theme_features ) && is_array( $_wp_theme_features ) ? $_wp_theme_features : []; } /** * Returns whether the active theme is a block-based theme or not. * * @since 4.5.3 * * @return bool Whether the active theme is a block-based theme or not. */ public function isBlockTheme() { if ( function_exists( 'wp_is_block_theme' ) ) { return wp_is_block_theme(); // phpcs:ignore AIOSEO.WpFunctionUse.NewFunctions.wp_is_block_themeFound } return false; } /** * Retrieves the website name. * * @since 4.6.1 * * @return string The website name. */ public function getWebsiteName() { return aioseo()->options->searchAppearance->global->schema->websiteName ? aioseo()->tags->replaceTags( aioseo()->options->searchAppearance->global->schema->websiteName ) : aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'name' ) ); } }