golden hour
/home/doctorbruno/.trash/google-site-kit/includes/Core/Util
⬆️ Go Up
Upload
File/Folder
Size
Actions
Activation_Flag.php
3.25 KB
Del
OK
Activation_Notice.php
4.11 KB
Del
OK
Auto_Updates.php
4.17 KB
Del
OK
BC_Functions.php
4.68 KB
Del
OK
Block_Support.php
889 B
Del
OK
Collection_Key_Cap_Filter.php
1.38 KB
Del
OK
Date.php
1.93 KB
Del
OK
Developer_Plugin_Installer.php
5.44 KB
Del
OK
Entity.php
3.2 KB
Del
OK
Entity_Factory.php
20.71 KB
Del
OK
Exit_Handler.php
836 B
Del
OK
Feature_Flags.php
2.22 KB
Del
OK
Google_Icon.php
1.58 KB
Del
OK
Google_URL_Matcher_Trait.php
3.02 KB
Del
OK
Google_URL_Normalizer.php
1.6 KB
Del
OK
Health_Checks.php
3.94 KB
Del
OK
Input.php
2.76 KB
Del
OK
Method_Proxy_Trait.php
1.09 KB
Del
OK
Migrate_Legacy_Keys.php
1.08 KB
Del
OK
Migration_1_123_0.php
4.54 KB
Del
OK
Migration_1_129_0.php
4.01 KB
Del
OK
Migration_1_3_0.php
2.96 KB
Del
OK
Migration_1_8_1.php
6.85 KB
Del
OK
Plugin_Status.php
1.36 KB
Del
OK
REST_Entity_Search_Controller.php
3.34 KB
Del
OK
Requires_Javascript_Trait.php
1.09 KB
Del
OK
Reset.php
8.16 KB
Del
OK
Reset_Persistent.php
666 B
Del
OK
Sanitize.php
1.04 KB
Del
OK
Scopes.php
2.59 KB
Del
OK
Sort.php
1.1 KB
Del
OK
Synthetic_WP_Query.php
4.08 KB
Del
OK
URL.php
5.4 KB
Del
OK
Uninstallation.php
3.5 KB
Del
OK
WP_Context_Switcher_Trait.php
2.13 KB
Del
OK
WP_Query_Factory.php
9.77 KB
Del
OK
Edit: WP_Context_Switcher_Trait.php
<?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 }; } }
Save