PATH:
home
/
letacommog
/
laindinois
/
wp-content
/
plugins
/
google-site-kit
/
includes
/
Core
/
Util
<?php /** * Class Google\Site_Kit\Core\Util\Feature_Flags * * @package Google\Site_Kit\Core\Util * @copyright 2020 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; use ArrayAccess; /** * Class for interacting with feature flag configuration. * * @since 1.22.0 * @access private * @ignore */ class Feature_Flags { const MODE_PRODUCTION = 'production'; /** * Feature flag mode. * * @since 1.22.0 * @var string */ private static $mode = self::MODE_PRODUCTION; /** * Feature flag definitions. * * @since 1.22.0 * @var array|ArrayAccess */ private static $features = array(); /** * Checks if the given feature is enabled in the current mode on the main instance. * * @since 1.22.0 * * @param string $feature Feature key path to check. * @return bool */ public static function enabled( $feature ) { if ( ! $feature || ! is_string( $feature ) || empty( static::$features ) ) { return false; } // In JS, the key always ends in `enabled`, but we add that here to eliminate // semantic redundancy with the name of the method. $feature_path = explode( '.', "$feature.enabled" ); $feature_modes = array_reduce( $feature_path, function ( $value, $key ) { if ( isset( $value[ $key ] ) ) { return $value[ $key ]; } return null; }, static::$features ); return in_array( static::get_mode(), (array) $feature_modes, true ); } /** * Sets the feature configuration. * * @since 1.22.0 * * @param array|ArrayAccess $features Feature configuration. */ public static function set_features( $features ) { if ( is_array( $features ) || $features instanceof ArrayAccess ) { static::$features = $features; } } /** * Sets the feature flag mode. * * @since 1.22.0 * * @param string $mode Feature flag mode. */ public static function set_mode( $mode ) { if ( $mode && is_string( $mode ) ) { static::$mode = $mode; } } /** * Gets the current feature flag mode. * * @since 1.22.0 * * @return string Current mode. */ private static function get_mode() { /** * Filter the feature flag mode. * * @since 1.22.0 * * @param string $mode The current feature flag mode. */ return (string) apply_filters( 'googlesitekit_flag_mode', static::$mode ) ?: self::MODE_PRODUCTION; } }
[+]
..
[-] Entity_Factory.php
[edit]
[-] Tracking.php
[edit]
[-] Input.php
[edit]
[-] Uninstallation.php
[edit]
[-] Developer_Plugin_Installer.php
[edit]
[-] User_Input_Settings.php
[edit]
[-] Migrate_Legacy_Keys.php
[edit]
[-] Activation_Flag.php
[edit]
[-] Migration_1_8_1.php
[edit]
[-] Tracking_Consent.php
[edit]
[-] Requires_Javascript_Trait.php
[edit]
[-] Health_Checks.php
[edit]
[-] JSON_File.php
[edit]
[-] Entity.php
[edit]
[-] BC_Functions.php
[edit]
[-] Migration_1_3_0.php
[edit]
[-] Scopes.php
[edit]
[-] Debug_Data.php
[edit]
[-] WP_Query_Factory.php
[edit]
[-] Activation_Notice.php
[edit]
[-] Exit_Handler.php
[edit]
[-] Google_URL_Matcher_Trait.php
[edit]
[-] Synthetic_WP_Query.php
[edit]
[-] WP_Context_Switcher_Trait.php
[edit]
[-] Feature_Flags.php
[edit]
[-] Reset.php
[edit]
[-] Google_URL_Normalizer.php
[edit]
[-] Method_Proxy_Trait.php
[edit]