-l10n-ithemes-security-pro' ) ]; } if ( ! self::is_available( $flag ) ) { $evaluation = ITSEC_Lib::evaluate_requirements( $config['requirements'] ); return [ 'requirements', $evaluation->get_error_message() ]; } if ( defined( 'ITSEC_FF_' . $flag ) ) { return [ 'constant', __( 'Manually configured with a constant.', 'it-l10n-ithemes-security-pro' ) ]; } if ( ! empty( $config['disabled'] ) ) { return [ 'remote', __( 'Remotely disabled by SolidWP.', 'it-l10n-ithemes-security-pro' ) ]; } $rates = ITSEC_Modules::get_setting( 'feature-flags', 'rates' ); if ( isset( $rates[ $flag ] ) ) { return [ 'rollout', __( 'Gradually rolling out.', 'it-l10n-ithemes-security-pro' ) ]; } return [ 'setting', __( 'Configured on the Feature Flags page.', 'it-l10n-ithemes-security-pro' ) ]; } /** * Manually enable a feature flag. * * @param string $flag */ public static function enable( $flag ) { $enabled = ITSEC_Modules::get_setting( 'feature-flags', 'enabled' ); $enabled[] = $flag; ITSEC_Modules::set_setting( 'feature-flags', 'enabled', $enabled ); } /** * Manually disable a feature flag. * * @param string $flag */ public static function disable( $flag ) { $settings = ITSEC_Modules::get_settings( 'feature-flags' ); $settings['opt_outs'][] = $flag; $settings['enabled'] = array_filter( $settings['enabled'], function ( $maybe_flag ) use ( $flag ) { return $maybe_flag !== $flag; } ); ITSEC_Modules::set_settings( 'feature-flags', $settings ); } /** * Get the flag configuration. * * @param string $flag * * @return array|null */ public static function get_flag_config( $flag ) { if ( ! isset( self::$flags[ $flag ] ) ) { return null; } $config = self::$flags[ $flag ]; if ( $config['remote'] && $remote = ITSEC_Lib_Remote_Messages::get_feature( $flag ) ) { $config = array_merge( $config, $remote ); } return $config; } }