File "rank-math.php"
Full path: /home/kosmetik/public_html/wp-content/plugins/seo-by-rank-math/rank-math.php
File
size: 10.69 B
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
defined('ABSPATH') || exit;
final class RankMath
{
public $version = '1.0.201.1';
public $db_version = '1';
private $wordpress_version = '5.2';
private $php_version = '7.2';
private $container = array();
private $messages = array();
protected static $instance = null;
public function __isset($prop)
{
return isset($this->{$prop}) || isset($this->container[$prop]);
}
public function __get($prop)
{
if (array_key_exists($prop, $this->container)) {
return $this->container[$prop];
}
if (isset($this->{$prop})) {
return $this->{$prop};
}
return null;
}
public function __set($prop, $value)
{
if (property_exists($this, $prop)) {
$this->{$prop} = $value;
return;
}
$this->container[$prop] = $value;
}
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);
}
public function init()
{
}
public static function get()
{
if (is_null(self::$instance) && !self::$instance instanceof RankMath) {
self::$instance = new RankMath();
self::$instance->setup();
}
return self::$instance;
}
private function setup()
{
$this->define_constants();
if (!$this->is_requirements_meet()) {
return;
}
$this->includes();
$this->instantiate();
do_action('rank_math/loaded');
}
private function is_requirements_meet()
{
if (version_compare(get_bloginfo('version'), $this->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);
}
if (version_compare(phpversion(), $this->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;
}
add_action('admin_init', [$this, 'auto_deactivate']);
add_action('admin_notices', [$this, 'activation_error']);
return false;
}
public function auto_deactivate()
{
deactivate_plugins(plugin_basename(RANK_MATH_FILE));
if (isset($_GET['activate'])) {
unset($_GET['activate']);
}
}
public function activation_error()
{
?>
<div class="notice rank-math-notice notice-error">
<p>
<?php
echo join('<br>', $this->messages);
?>
</p>
</div>
<?php
}
private function define_constants()
{
define('RANK_MATH_VERSION', $this->version);
define('RANK_MATH_FILE', __FILE__);
define('RANK_MATH_PATH', dirname(RANK_MATH_FILE) . '/');
define('RANK_MATH_URL', plugins_url('', RANK_MATH_FILE) . '/');
}
private function includes()
{
include dirname(__FILE__) . '/vendor/autoload.php';
$file = get_stylesheet_directory() . '/rank-math.php';
if (file_exists($file)) {
require_once $file;
}
}
private function instantiate()
{
new \RankMath\Installer();
$this->container['settings'] = new \RankMath\Settings();
$this->container['json'] = new \MyThemeShop\Json_Manager();
$this->container['notification'] = new \MyThemeShop\Notification_Center('rank_math_notifications');
$this->container['registration'] = new \RankMath\Admin\Registration();
if ($this->container['registration']->invalid) {
return;
}
$this->container['manager'] = new \RankMath\Module\Manager();
$this->container['variables'] = new \RankMath\Replace_Variables\Manager();
new \RankMath\Common();
$this->container['rewrite'] = new \RankMath\Rewrite();
new \RankMath\Compatibility();
$this->container['frontend_seo_score'] = new \RankMath\Frontend_SEO_Score();
$this->load_3rd_party();
$this->init_actions();
}
private function init_actions()
{
add_action('plugins_loaded', [$this, 'localization_setup'], 9);
add_action('init', [$this, 'pass_admin_content']);
add_filter('cron_schedules', [$this, 'cron_schedules']);
add_filter('plugin_row_meta', [$this, 'plugin_row_meta'], 10, 2);
add_filter('plugin_action_links_' . plugin_basename(RANK_MATH_FILE), [$this, 'plugin_action_links']);
add_action('after_plugin_row_' . plugin_basename(RANK_MATH_FILE), [$this, 'plugin_row_deactivate_notice'], 10, 2);
add_action('plugins_loaded', [$this, 'init'], 14);
add_action('rest_api_init', [$this, 'init_rest_api']);
if (is_admin()) {
add_action('plugins_loaded', [$this, 'init_admin'], 15);
}
if (!is_admin() || in_array(\MyThemeShop\Helpers\Param::request('action'), ['elementor', 'elementor_ajax'], true)) {
add_action('plugins_loaded', [$this, 'init_frontend'], 15);
}
if (defined('WP_CLI') && WP_CLI) {
add_action('plugins_loaded', [$this, 'init_wp_cli'], 20);
}
}
public function init_rest_api()
{
$controllers = [new \RankMath\Rest\Admin(), new \RankMath\Rest\Front(), new \RankMath\Rest\Shared(), new \RankMath\Rest\Post(), new \RankMath\Rest\Headless()];
foreach ($controllers as $controller) {
$controller->register_routes();
}
}
public function init_admin()
{
if ($this->container['registration']->invalid) {
return;
}
new \RankMath\Admin\Admin_Init();
}
public function init_frontend()
{
if ($this->container['registration']->invalid) {
return;
}
$this->container['frontend'] = new \RankMath\Frontend\Frontend();
}
private function load_3rd_party()
{
if (!function_exists('is_plugin_active')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
if (is_plugin_active('elementor/elementor.php')) {
new \RankMath\Elementor\Elementor();
}
add_action('after_setup_theme', function () {
if (defined('ET_CORE')) {
new \RankMath\Divi\Divi();
}
}, 11);
add_action('current_screen', function () {
if (defined('ET_CORE')) {
new \RankMath\Divi\Divi_Admin();
}
});
}
public function init_wp_cli()
{
WP_CLI::add_command('rankmath sitemap generate', ['\\RankMath\\CLI\\Commands', 'sitemap_generate']);
}
public function plugin_action_links($links)
{
$options = ['options-general' => __('Settings', 'rank-math'), 'wizard' => __('Setup Wizard', 'rank-math')];
if ($this->container['registration']->invalid) {
$options = ['registration' => __('Setup Wizard', 'rank-math')];
}
foreach ($options as $link => $label) {
$plugin_links[] = '<a href="' . \RankMath\Helper::get_admin_url($link) . '">' . esc_html($label) . '</a>';
}
return array_merge($links, $plugin_links);
}
public function plugin_row_deactivate_notice($file, $plugin_data)
{
if (false === apply_filters('rank_math_clear_data_on_uninstall', false)) {
return;
}
if (is_multisite() && !is_network_admin() && is_plugin_active_for_network($file)) {
return;
}
$wp_list_table = _get_list_table('WP_Plugins_List_Table');
echo '<tr class="plugin-update-tr active rank-math-deactivate-notice-row" data-slug="" data-plugin="' . esc_attr($file) . '" style="position: relative; top: -1px;"><td colspan="' . esc_attr($wp_list_table->get_column_count()) . '" class="plugin-update colspanchange"><div class="notice inline notice-error notice-alt"><p>';
echo sprintf(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'), '<strong>' . esc_html__('CAUTION:', 'rank-math') . '</strong>', '<br /><strong>' . esc_html__('This action is IRREVERSIBLE.', 'rank-math') . '</strong>');
echo '</p></div></td></tr>';
}
public function plugin_row_meta($links, $file)
{
if (plugin_basename(RANK_MATH_FILE) !== $file) {
return $links;
}
$more = ['<a href="' . admin_url('?page=rank-math&view=help') . '">' . esc_html__('Getting Started', 'rank-math') . '</a>', '<a href="https://rankmath.com/kb/?utm_source=Plugin&utm_medium=Plugin%20Page%20KB%20Link&utm_campaign=WP" target="_blank">' . esc_html__('Documentation', 'rank-math') . '</a>'];
return array_merge($links, $more);
}
public function localization_setup()
{
$locale = get_user_locale();
$locale = apply_filters('plugin_locale', $locale, 'rank-math');
unload_textdomain('rank-math');
if (false === load_textdomain('rank-math', WP_LANG_DIR . '/plugins/seo-by-rank-math-' . $locale . '.mo')) {
load_textdomain('rank-math', WP_LANG_DIR . '/seo-by-rank-math/seo-by-rank-math-' . $locale . '.mo');
}
load_plugin_textdomain('rank-math', false, rank_math()->plugin_dir() . 'languages/');
}
public function pass_admin_content()
{
if (is_user_logged_in() && is_admin_bar_showing()) {
$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('endpoint', esc_url_raw(rest_url('rankmath/v1')), 'rankMath');
$this->container['json']->add('security', wp_create_nonce('rank-math-ajax-nonce'), 'rankMath');
$this->container['json']->add('restNonce', wp_installing() && !is_multisite() ? '' : wp_create_nonce('wp_rest'), 'rankMath');
$this->container['json']->add('modules', \RankMath\Helper::get_active_modules(), 'rankMath');
}
}
public function cron_schedules($schedules)
{
$schedules['weekly'] = ['interval' => DAY_IN_SECONDS * 7, 'display' => esc_html__('Once Weekly', 'rank-math')];
return $schedules;
}
}
function rank_math()
{
return RankMath::get();
}
rank_math();