{$prop} ) || isset( $this->container[ $prop ] ); } /** * Magic getter method. * * @param string $prop Property to get. * @return mixed Property value or NULL if it does not exists. */ public function __get( $prop ) { if ( array_key_exists( $prop, $this->container ) ) { return $this->container[ $prop ]; } if ( isset( $this->{$prop} ) ) { return $this->{$prop}; } return null; } /** * Magic setter method. * * @param mixed $prop Property to set. * @param mixed $value Value to set. */ public function __set( $prop, $value ) { if ( property_exists( $this, $prop ) ) { $this->$prop = $value; return; } $this->container[ $prop ] = $value; } /** * Magic call method. * * @param string $name Method to call. * @param array $arguments Arguments to pass when calling. * @return mixed Return value of the callback. */ public function __call( $name, $arguments ) { $hash = [ 'plugin_dir' => RANK_MATH_PATH, 'plugin_url' => RANK_MATH_URL, 'includes_dir' => RANK_MATH_PATH . 'includes/', 'assets' => RANK_MATH_URL . 'assets/front/', 'admin_dir' => RANK_MATH_PATH . 'includes/admin/', ]; if ( isset( $hash[ $name ] ) ) { return $hash[ $name ]; } return call_user_func_array( $name, $arguments ); } /** * Initialize. */ public function init() { } /** * Retrieve main RankMath instance. * * Ensure only one instance is loaded or can be loaded. * * @see rank_math() * @return RankMath */ public static function get() { if ( is_null( self::$instance ) && ! ( self::$instance instanceof RankMath ) ) { self::$instance = new RankMath(); self::$instance->setup(); } return self::$instance; } /** * Instantiate the plugin. */ private function setup() { // Define plugin constants. $this->define_constants(); if ( ! $this->is_requirements_meet() ) { return; } // Include required files. $this->includes(); // Instantiate classes. $this->instantiate(); // Loaded action. do_action( 'rank_math/loaded' ); } /** * Check that the WordPress and PHP setup meets the plugin requirements. * * @return bool */ private function is_requirements_meet() { // Check WordPress version. if ( version_compare( get_bloginfo( 'version' ), $this->wordpress_version, '<' ) ) { /* translators: WordPress Version */ $this->messages[] = sprintf( esc_html__( 'You are using the outdated WordPress, please update it to version %s or higher.', 'rank-math' ), $this->wordpress_version ); } // Check PHP version. if ( version_compare( phpversion(), $this->php_version, '<' ) ) { /* translators: PHP Version */ $this->messages[] = sprintf( esc_html__( 'Rank Math requires PHP version %s or above. Please update PHP to run this plugin.', 'rank-math' ), $this->php_version ); } if ( empty( $this->messages ) ) { return true; } // Auto-deactivate plugin. add_action( 'admin_init', [ $this, 'auto_deactivate' ] ); add_action( 'admin_notices', [ $this, 'activation_error' ] ); return false; } /** * Auto-deactivate plugin if requirements are not met, and display a notice. */ public function auto_deactivate() { deactivate_plugins( plugin_basename( RANK_MATH_FILE ) ); if ( isset( $_GET['activate'] ) ) { // phpcs:ignore unset( $_GET['activate'] ); // phpcs:ignore } } /** * Error notice on plugin activation. */ public function activation_error() { ?>
', $this->messages ); // phpcs:ignore ?>
';
echo sprintf(
/* translators: 1. Bold text 2. Bold text */
esc_html__( '%1$s A filter to remove the Rank Math data from the database is present. Deactivating & Deleting this plugin will remove everything related to the Rank Math plugin. %2$s', 'rank-math' ),
'' . esc_html__( 'CAUTION:', 'rank-math' ) . '',
'
' . esc_html__( 'This action is IRREVERSIBLE.', 'rank-math' ) . ''
);
echo '