{$prop} ) || isset( $this->container[ $prop ] ); } /** * Magic get 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 ]; } return $this->{$prop}; } /** * Magic set 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_MONITOR_PATH, 'plugin_url' => RANK_MATH_MONITOR_URL, 'includes_dir' => RANK_MATH_MONITOR_PATH . 'includes/', 'admin_dir' => RANK_MATH_MONITOR_PATH . 'includes/admin/', ]; if ( isset( $hash[ $name ] ) ) { return $hash[ $name ]; } return call_user_func_array( $name, $arguments ); } /** * Main RankMath_Monitor instance * * Ensure only one instance is loaded or can be loaded. * * @see rm_monitor() * @return RankMath_Monitor */ public static function get() { if ( is_null( self::$instance ) && ! ( self::$instance instanceof RankMath_Monitor ) ) { self::$instance = new RankMath_Monitor; self::$instance->setup(); } return self::$instance; } /** * Instantiate the plugin */ private function setup() { // Define constants. $this->define_constants(); if ( ! $this->is_requirements_meet() ) { return; } // Include required files. include dirname( __FILE__ ) . '/vendor/autoload.php'; // instantiate classes. $this->instantiate(); // Initialize the action hooks. $this->init_actions(); // Loaded action. do_action( 'rank_math_monitor/loaded' ); } /** * Check that the WordPress and PHP setup meets the plugin requirements * * @return bool */ private function is_requirements_meet() { // Check if WordPress version is enough to run this plugin. if ( version_compare( get_bloginfo( 'version' ), $this->wordpress_version, '<' ) ) { /* translators: WordPress Version */ $this->messages[] = sprintf( esc_html__( 'Rank Math requires WordPress version %s or above. Please update WordPress to run this plugin.', '404-monitor' ), $this->wordpress_version ); } // Check if PHP version is enough to run this plugin. 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.', '404-monitor' ), $this->php_version ); } // Check if Rank Math Plugin is active. include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); if ( is_plugin_active( 'seo-by-rank-math/rank-math.php' ) ) { $this->messages[] = sprintf( esc_html__( '%s plugin is active. You don\'t need 404 Monitor plugin separately.', '404-monitor' ), '' . esc_html__( 'Rank Math SEO', '404-monitor' ) . '' ); } 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 requirement not meet and display a notice */ public function auto_deactivate() { deactivate_plugins( plugin_basename( RANK_MATH_MONITOR_FILE ) ); if ( isset( $_GET['activate'] ) ) { unset( $_GET['activate'] ); } } /** * Plugin activation notice */ public function activation_error() { ?>
', $this->messages ); ?>