{$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 ); ?>

version ); define( 'RANK_MATH_MONITOR_FILE', __FILE__ ); define( 'RANK_MATH_MONITOR_PATH', dirname( RANK_MATH_MONITOR_FILE ) . '/' ); define( 'RANK_MATH_MONITOR_URL', plugins_url( '', RANK_MATH_MONITOR_FILE ) . '/' ); } /** * Instantiate classes */ private function instantiate() { new \RankMath_Monitor\Installer; // Setting Manager. $this->container['settings'] = new \RankMath_Monitor\Settings; // JSON Manager. $this->container['json'] = new \MyThemeShop\Json_Manager; // Notification Manager. $this->container['notification'] = new \MyThemeShop\Notification_Center( 'rank_math_monitor_notifications' ); $this->container['manager'] = new \RankMath_Monitor\Module_Manager; } /** * Initialize WordPress action hooks */ private function init_actions() { add_action( 'init', [ $this, 'localization_setup' ] ); // Add plugin action links. add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 ); add_filter( 'plugin_action_links_' . plugin_basename( RANK_MATH_MONITOR_FILE ), [ $this, 'plugin_action_links' ] ); if ( is_admin() ) { add_action( 'plugins_loaded', [ $this, 'init_admin' ], 14 ); } add_action( 'plugins_loaded', [ $this, 'init_modules' ], 15 ); } /** * Initialize module. */ public function init_modules() { new \RankMath_Monitor\Monitor\Monitor; } /** * Initialize the admin. */ public function init_admin() { new \RankMath_Monitor\Admin\Engine; } /** * Show action links on the plugin screen. * * @param mixed $links Plugin Action links. * @return array */ public function plugin_action_links( $links ) { $plugin_links = [ '' . esc_html__( 'Settings', '404-monitor' ) . '', ]; return array_merge( $links, $plugin_links ); } /** * Show row meta on the plugin screen. * * @param mixed $links Plugin Row Meta. * @param mixed $file Plugin Base file. * @return array */ public function plugin_row_meta( $links, $file ) { if ( plugin_basename( RANK_MATH_MONITOR_FILE ) !== $file ) { return $links; } $more = [ '' . esc_html__( 'Getting Started', '404-monitor' ) . '', '' . esc_html__( 'Documentation', '404-monitor' ) . '', ]; return array_merge( $links, $more ); } /** * Initialize plugin for localization. * * Note: the first-loaded translation file overrides any following ones if the same translation is present. * * Locales found in: * - WP_LANG_DIR/rank-math/rank-math-LOCALE.mo * - WP_LANG_DIR/plugins/rank-math-LOCALE.mo */ public function localization_setup() { $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); $locale = apply_filters( 'plugin_locale', $locale, '404-monitor' ); unload_textdomain( '404-monitor' ); load_textdomain( '404-monitor', WP_LANG_DIR . '/404-monitor/404-monitor-' . $locale . '.mo' ); load_plugin_textdomain( '404-monitor', false, rank_math_monitor()->plugin_dir() . '/languages/' ); $this->container['json']->add( 'version', $this->version, 'rankMath' ); $this->container['json']->add( 'ajaxurl', admin_url( 'admin-ajax.php' ), 'rankMath' ); $this->container['json']->add( 'adminurl', admin_url( 'admin.php' ), 'rankMath' ); $this->container['json']->add( 'security', wp_create_nonce( 'rank-math-monitor-ajax-nonce' ), 'rankMath' ); } } /** * Main instance of RankMath_Monitor. * * Returns the main instance of RankMath_Monitor to prevent the need to use globals. * * @return RankMath_Monitor */ function rank_math_monitor() { return RankMath_Monitor::get(); } // Kick it off. rank_math_monitor();