"specific-url-redirections", "redirection-rules" => "redirection-rules", "redirection-and-404-logs" => "redirection-and-404-logs", "automatic-redirects" => "automatic-redirects", "change-urls" => "change-urls", ]; public static $CRITERIAS; public static $PERMALINK_STRUCTURE_VALUES; public static $ACTIONS; public static $REDIRECTION_LOGS_DELETE; public static $REDIRECTION_LOGS_FILTER; private static $INSTANCE = null; private function __construct() { $this->dbManager = new IRRPDBManager(); //add_action("admin_notices", [&$this, "adminNotices"]); add_action("wp_loaded", [&$this, "irrpDependencies"]); //add_filter("cron_schedules", [$this, "irrpSetIntervals"]); } public static function getInstance() { if (is_null(self::$INSTANCE)) { self::$INSTANCE = new self(); } return self::$INSTANCE; } /** * Add a signature to the front page. */ public function MetaVersion() { echo ''; } public function irrpInit() { $rules = $this->dbManager->getRules(); $option404Status = $this->dbManager->isAre404sRuleExists($rules) ? "disabled" : ""; $optionAllUrlsStatus = $this->dbManager->isAllURLsRuleExists($rules) ? "disabled" : ""; self::$CRITERIAS = [ [ "option" => "contain", "text" => __("Contain", "redirect-redirection"), ], [ "option" => "start-with", "text" => __("Start with", "redirect-redirection"), ], [ "option" => "end-with", "text" => __("End with", "redirect-redirection"), ], [ "option" => "have-permalink-structure", "text" => __("Have permalink structure", "redirect-redirection"), ], // [ // "option" => "have-category", // "text" => __("Have Category", "redirect-redirection"), // ], // [ // "option" => "have-tag", // "text" => __("Have Tag", "redirect-redirection"), // ], // [ // "option" => "have-author", // "text" => __("Have Author", "redirect-redirection"), // ], [ "option" => "regex-match", "text" => __("Regex matches", "redirect-redirection"), ], [ "option" => "are-404s", "text" => __("Are 404s", "redirect-redirection"), "status" => $option404Status, ], [ "option" => "all-urls", "text" => __("All URLs", "redirect-redirection"), "status" => $optionAllUrlsStatus, ], ]; self::$PERMALINK_STRUCTURE_VALUES = [ [ "option" => "day-and-name", "text" => __("Day and name", "redirect-redirection") ], [ "option" => "month-and-name", "text" => __("Month and name", "redirect-redirection") ], [ "option" => "post-name", "text" => __("Post name", "redirect-redirection") ], [ "option" => "category-and-name", "text" => __("Category and name", "redirect-redirection") ], [ "option" => "author-and-name", "text" => __("Author and name", "redirect-redirection") ], ]; self::$ACTIONS = [ [ "option" => "a-specific-url", "text" => __("A Specific URL", "redirect-redirection") ], [ "option" => "urls-with-new-string", "text" => __("URLs with new string", "redirect-redirection") ], [ "option" => "urls-with-removed-string", "text" => __("URLs with removed string", "redirect-redirection") ], [ "option" => "new-permalink-structure", "text" => __("New permalink structure", "redirect-redirection") ], [ "option" => "regex-match", "text" => __("Regex matches", "redirect-redirection") ], [ "option" => "random-similar-post", "text" => __("Random similar post", "redirect-redirection") ], [ "option" => "explain-those-options", "text" => __("Explain those options", "redirect-redirection") ], ]; self::$REDIRECTION_LOGS_DELETE = [ [ "option" => "never", "text" => __("Never", "redirect-redirection"), ], [ "option" => "older-than-a-week", "text" => __("Older than a week", "redirect-redirection") ], [ "option" => "older-than-a-month", "text" => __("Older than a month", "redirect-redirection") ], "selectedId" => 0, ]; self::$REDIRECTION_LOGS_FILTER = [ [ "option" => "all", "text" => __("All", "redirect-redirection"), ], [ "option" => "404s", "text" => __("404s", "redirect-redirection") ], "selectedId" => 0, ]; } public function irrpDependencies() { if (!defined('IRRP_ACTIVATION_REQUEST') && get_option('irrp_activation_redirect', false) == true) { delete_option('irrp_activation_redirect'); wp_redirect(admin_url('admin.php?page=irrp-redirection')); exit; } $this->helper = new IRRPHelper($this->dbManager); $this->settings = new IRRPSettings($this->dbManager, $this->helper); $this->helperAjax = new IRRPHelperAjax($this->dbManager, $this->settings, $this->helper); $this->exportImport = new IRRPExportImport($this->dbManager, $this->helper); add_action("wpmu_new_blog", [&$this->dbManager, "onNewBlog"], 10, 6); add_filter("wpmu_drop_tables", [&$this->dbManager, "onDeleteBlog"]); $plugin = plugin_basename(__FILE__); add_filter("plugin_action_links_$plugin", [&$this, "links"]); add_action("activated_plugin", [&$this, "activated"]); add_action("admin_post_ir_uninstall", [&$this, "uninstall"]); // Add signature to frontend. add_action("wp_head", [&$this, "MetaVersion"]); } function irrpSetIntervals($schedules) { $schedules[IRRP_CRON_DELETE_LOGS_RECURRENCE_KEY] = [ "interval" => IRRP_CRON_DELETE_LOGS_RECURRENCE, "display" => esc_html__("Every 15 minutes", "redirect-redirection") ]; return $schedules; } public function activated($plugin) { if ($plugin == plugin_basename(__FILE__)) { exit(wp_redirect(admin_url("admin.php?page=" . self::PAGE_SETTINGS))); } } public function adminNotices() { $wpVersion = get_bloginfo("version"); $phpVersion = phpversion(); if (current_user_can("manage_options") || current_user_can("redirect_redirection_admin")) { if (version_compare($wpVersion, $this->minimum_wp_version, "<")) { echo "