PATH:
home
/
letacommog
/
gdiags.fr
/
wp-content
/
plugins
/
google-site-kit
/
includes
/
Core
/
Util
<?php /** * Trait Google\Site_Kit\Core\Util\WP_Context_Switcher_Trait * * @package Google\Site_Kit\Core\Util * @copyright 2021 Google LLC * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 * @link https://sitekit.withgoogle.com */ namespace Google\Site_Kit\Core\Util; /** * Trait for temporarily switching WordPress context, e.g. from admin to frontend. * * @since 1.16.0 * @access private * @ignore */ trait WP_Context_Switcher_Trait { /** * Switches to WordPress frontend context if necessary. * * Context is only switched if WordPress is not already in frontend context. Context should only ever be switched * temporarily. Call the returned closure as soon as possible after to restore the original context. * * @since 1.16.0 * * @return callable Closure that restores context. */ protected static function with_frontend_context() { $restore = self::get_restore_current_screen_closure(); if ( ! is_admin() ) { return $restore; } self::switch_current_screen( 'front' ); return $restore; } /** * Switches the current WordPress screen via the given screen ID or hook name. * * @since 1.16.0 * * @param string $screen_id WordPress screen ID. */ private static function switch_current_screen( $screen_id ) { global $current_screen; require_once ABSPATH . 'wp-admin/includes/class-wp-screen.php'; require_once ABSPATH . 'wp-admin/includes/screen.php'; $current_screen = \WP_Screen::get( $screen_id ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited } /** * Returns the closure to restore the current screen. * * Calling the closure will restore the `$current_screen` global to what it was set to at the time of calling * this method. * * @since 1.16.0 * * @return callable Closure that restores context. */ private static function get_restore_current_screen_closure() { global $current_screen; $original_screen = $current_screen; return static function() use ( $original_screen ) { global $current_screen; $current_screen = $original_screen; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited }; } }
[+]
..
[-] Migrate_Legacy_Keys.php
[edit]
[-] Tracking_Consent.php
[edit]
[-] Synthetic_WP_Query.php
[edit]
[-] User_Input_Settings.php
[edit]
[-] Developer_Plugin_Installer.php
[edit]
[-] Method_Proxy_Trait.php
[edit]
[-] Reset_Persistent.php
[edit]
[-] WP_Query_Factory.php
[edit]
[-] Migration_1_3_0.php
[edit]
[-] Input.php
[edit]
[-] Activation_Notice.php
[edit]
[-] Scopes.php
[edit]
[-] Requires_Javascript_Trait.php
[edit]
[-] JSON_File.php
[edit]
[-] Health_Checks.php
[edit]
[-] Debug_Data.php
[edit]
[-] Entity_Factory.php
[edit]
[-] Reset.php
[edit]
[-] Uninstallation.php
[edit]
[-] Exit_Handler.php
[edit]
[-] Google_URL_Matcher_Trait.php
[edit]
[-] BC_Functions.php
[edit]
[-] Activation_Flag.php
[edit]
[-] Feature_Flags.php
[edit]
[-] Google_URL_Normalizer.php
[edit]
[-] WP_Context_Switcher_Trait.php
[edit]
[-] Tracking.php
[edit]
[-] Google_Icon.php
[edit]
[-] Entity.php
[edit]
[-] Build_Mode.php
[edit]
[-] Migration_1_8_1.php
[edit]