Exemplo n.º 1
0
 public function checkActivePlugins()
 {
     //for WP-Polls
     if ($this->isPluginActive('wp-polls/wp-polls.php')) {
         require_once "wp-polls.php";
         $wp_polls = new WpPollsForWpFc();
         $wp_polls->hook();
     }
 }
Exemplo n.º 2
0
 public function __construct()
 {
     $optimize_image_ajax_requests = array("wpfc_revert_image_ajax_request", "wpfc_statics_ajax_request", "wpfc_optimize_image_ajax_request", "wpfc_update_image_list_ajax_request");
     add_action('wp_ajax_wpfc_save_timeout_pages', array($this, 'wpfc_save_timeout_pages_callback'));
     add_action('wp_ajax_wpfc_save_exclude_pages', array($this, 'wpfc_save_exclude_pages_callback'));
     add_action('wp_ajax_wpfc_cdn_options_ajax_request', array($this, 'wpfc_cdn_options_ajax_request_callback'));
     add_action('wp_ajax_wpfc_remove_cdn_integration_ajax_request', array($this, 'wpfc_remove_cdn_integration_ajax_request_callback'));
     add_action('wp_ajax_wpfc_save_cdn_integration_ajax_request', array($this, 'wpfc_save_cdn_integration_ajax_request_callback'));
     add_action('wp_ajax_wpfc_cdn_template_ajax_request', array($this, 'wpfc_cdn_template_ajax_request_callback'));
     add_action('wp_ajax_wpfc_check_url_ajax_request', array($this, 'wpfc_check_url_ajax_request_callback'));
     add_action('wp_ajax_wpfc_cache_statics_get', array($this, 'wpfc_cache_statics_get_callback'));
     add_action('wp_ajax_wpfc_update_premium', array($this, 'wpfc_update_premium_callback'));
     add_action('rate_post', array($this, 'wp_postratings_clear_fastest_cache'), 10, 2);
     if (is_dir($this->getWpContentDir() . "/cache/tmpWpfc")) {
         $this->rm_folder_recursively($this->getWpContentDir() . "/cache/tmpWpfc");
     }
     if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "wpestate_ajax_agent_contact_form") {
         if (isset($_POST["nonce"]) && $_POST["nonce"]) {
             //for WpResidence theme contact form
             include_once ABSPATH . "wp-includes/pluggable.php";
             foreach ($_POST as $key => &$value) {
                 if (preg_match("/nonce/", $key)) {
                     $value = wp_create_nonce('ajax-property-contact');
                 }
             }
         }
     } else {
         if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "vc_get_vc_grid_data") {
             if (isset($_POST["vc_post_id"]) && $_POST["vc_post_id"]) {
                 if (isset($_POST["_vcnonce"]) && $_POST["_vcnonce"]) {
                     //for Visual Composer Grid-View
                     include_once ABSPATH . "wp-includes/pluggable.php";
                     foreach ($_POST as $key => &$value) {
                         if (preg_match("/_vcnonce/", $key)) {
                             $value = wp_create_nonce('vc-nonce-vc-public-nonce');
                         }
                     }
                 }
             }
         } else {
             if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "polls") {
                 //for WP-Polls
                 include_once ABSPATH . "wp-includes/pluggable.php";
                 foreach ($_POST as $key => &$value) {
                     if (preg_match("/poll_\\d+_nonce/", $key)) {
                         $value = wp_create_nonce('poll_' . $_POST["poll_id"] . '-nonce');
                     }
                 }
             } else {
                 if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "wpfc_wppolls_ajax_request") {
                     //for WP-Polls
                     require_once "inc/wp-polls.php";
                     $wp_polls = new WpPollsForWpFc();
                     $wp_polls->hook();
                 } else {
                     if (isset($_GET) && isset($_GET["action"]) && in_array($_GET["action"], $optimize_image_ajax_requests)) {
                         if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                             include_once $this->get_premium_path("image.php");
                             $img = new WpFastestCacheImageOptimisation();
                             $img->hook();
                         }
                     } else {
                         if (isset($_GET) && isset($_GET["action"]) && $_GET["action"] == "wpfastestcache") {
                             if (isset($_GET) && isset($_GET["type"]) && $_GET["type"] == "preload") {
                                 // /?action=wpfastestcache&type=preload
                                 $this->create_preload_cache();
                             }
                             exit;
                         } else {
                             $this->setCustomInterval();
                             $this->options = $this->getOptions();
                             add_action('transition_post_status', array($this, 'on_all_status_transitions'), 10, 3);
                             $this->commentHooks();
                             $this->checkCronTime();
                             register_deactivation_hook(__FILE__, array('WpFastestCache', 'deactivate'));
                             register_uninstall_hook(__FILE__, array('WpFastestCache', 'uninstall'));
                             if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                 include_once $this->get_premium_path("mobile-cache.php");
                             }
                             if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                 include_once $this->get_premium_path("powerful-html.php");
                             }
                             if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                 if (file_exists(WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium/pro/library/statics.php")) {
                                     include_once $this->get_premium_path("statics.php");
                                 }
                             }
                             if (is_admin()) {
                                 // to avoid loading menu and optionPage() twice
                                 if (!class_exists("WpFastestCacheAdmin")) {
                                     //for wp-panel
                                     if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                         include_once $this->get_premium_path("image.php");
                                     }
                                     if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                         include_once $this->get_premium_path("logs.php");
                                     }
                                     add_action('wp_ajax_wpfc_cdn_template_ajax_request', array($this, 'wpfc_cdn_template_ajax_request_callback'));
                                     add_action('plugins_loaded', array($this, 'wpfc_load_plugin_textdomain'));
                                     $this->admin();
                                 }
                             } else {
                                 if (preg_match("/wpfc-minified\\/([^\\/]+)\\/([^\\/]+)/", $this->current_url(), $path)) {
                                     if ($sources = @scandir(WPFC_WP_CONTENT_DIR . "/cache/wpfc-minified/" . $path[1], 1)) {
                                         if (isset($sources[0])) {
                                             // $exist_url = str_replace($path[2], $sources[0], $this->current_url());
                                             // header('Location: ' . $exist_url, true, 301);
                                             // exit;
                                             if (preg_match("/\\.css/", $this->current_url())) {
                                                 header('Content-type: text/css');
                                             } else {
                                                 if (preg_match("/\\.js/", $this->current_url())) {
                                                     header('Content-type: text/js');
                                                 }
                                             }
                                             echo file_get_contents(WPFC_WP_CONTENT_DIR . "/cache/wpfc-minified/" . $path[1] . "/" . $sources[0]);
                                             exit;
                                         }
                                     }
                                 } else {
                                     //for cache
                                     $this->cache();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 public function __construct()
 {
     $optimize_image_ajax_requests = array("wpfc_revert_image_ajax_request", "wpfc_statics_ajax_request", "wpfc_optimize_image_ajax_request", "wpfc_update_image_list_ajax_request");
     add_action('wp_ajax_wpfc_save_timeout_pages', array($this, 'wpfc_save_timeout_pages_callback'));
     add_action('wp_ajax_wpfc_save_exclude_pages', array($this, 'wpfc_save_exclude_pages_callback'));
     add_action('wp_ajax_wpfc_cdn_options_ajax_request', array($this, 'wpfc_cdn_options_ajax_request_callback'));
     add_action('wp_ajax_wpfc_remove_cdn_integration_ajax_request', array($this, 'wpfc_remove_cdn_integration_ajax_request_callback'));
     add_action('wp_ajax_wpfc_save_cdn_integration_ajax_request', array($this, 'wpfc_save_cdn_integration_ajax_request_callback'));
     add_action('wp_ajax_wpfc_cdn_template_ajax_request', array($this, 'wpfc_cdn_template_ajax_request_callback'));
     add_action('wp_ajax_wpfc_check_url_ajax_request', array($this, 'wpfc_check_url_ajax_request_callback'));
     add_action('wp_ajax_wpfc_cache_statics_get', array($this, 'wpfc_cache_statics_get_callback'));
     add_action('wp_ajax_wpfc_update_premium', array($this, 'wpfc_update_premium_callback'));
     add_action('rate_post', array($this, 'wp_postratings_clear_fastest_cache'), 10, 2);
     if (is_dir($this->getWpContentDir() . "/cache/tmpWpfc")) {
         $this->rm_folder_recursively($this->getWpContentDir() . "/cache/tmpWpfc");
     }
     if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "vc_get_vc_grid_data") {
         if (isset($_POST["vc_post_id"]) && $_POST["vc_post_id"]) {
             if (isset($_POST["_vcnonce"]) && $_POST["_vcnonce"]) {
                 $this->setCustomInterval();
                 $schedules_rules = array();
                 $exist_cronjob = false;
                 $wpfc_timeout_number = 0;
                 $crons = _get_cron_array();
                 foreach ((array) $crons as $cron_key => $cron_value) {
                     foreach ((array) $cron_value as $hook => $events) {
                         if (preg_match("/^wp\\_fastest\\_cache(.*)/", $hook, $id)) {
                             if (!$id[1] || preg_match("/^\\_(\\d+)\$/", $id[1])) {
                                 $wpfc_timeout_number++;
                                 foreach ((array) $events as $event_key => $event) {
                                     $schedules = wp_get_schedules();
                                     if (isset($event["args"]) && isset($event["args"][0])) {
                                         if ($event["args"][0] == '{"prefix":"all","content":"all"}') {
                                             if ($schedules[$event["schedule"]]["interval"] <= 86400) {
                                                 $exist_cronjob = true;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if (!$exist_cronjob) {
                     $args = array("prefix" => "all", "content" => "all");
                     wp_schedule_event(time(), "onceaday", "wp_fastest_cache_" . $wpfc_timeout_number, array(json_encode($args)));
                 }
             }
         }
     } else {
         if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "wpfc_wppolls_ajax_request") {
             //for WP-Polls
             require_once "inc/wp-polls.php";
             $wp_polls = new WpPollsForWpFc();
             $wp_polls->hook();
         } else {
             if (isset($_GET) && isset($_GET["action"]) && in_array($_GET["action"], $optimize_image_ajax_requests)) {
                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                     include_once $this->get_premium_path("image.php");
                     $img = new WpFastestCacheImageOptimisation();
                     $img->hook();
                 }
             } else {
                 $this->setCustomInterval();
                 $this->options = $this->getOptions();
                 add_action('transition_post_status', array($this, 'on_all_status_transitions'), 10, 3);
                 $this->commentHooks();
                 $this->checkCronTime();
                 register_deactivation_hook(__FILE__, array('WpFastestCache', 'deactivate'));
                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                     include_once $this->get_premium_path("mobile-cache.php");
                 }
                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                     include_once $this->get_premium_path("powerful-html.php");
                 }
                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                     if (file_exists(WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium/pro/library/statics.php")) {
                         include_once $this->get_premium_path("statics.php");
                     }
                 }
                 if (is_admin()) {
                     //for wp-panel
                     if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                         include_once $this->get_premium_path("image.php");
                     }
                     if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                         include_once $this->get_premium_path("logs.php");
                     }
                     add_action('wp_ajax_wpfc_cdn_template_ajax_request', array($this, 'wpfc_cdn_template_ajax_request_callback'));
                     add_action('plugins_loaded', array($this, 'wpfc_load_plugin_textdomain'));
                     $this->admin();
                 } else {
                     if (preg_match("/wpfc-minified\\/([^\\/]+)\\/([^\\/]+)/", $this->current_url(), $path)) {
                         if ($sources = @scandir(WPFC_WP_CONTENT_DIR . "/cache/wpfc-minified/" . $path[1], 1)) {
                             if (isset($sources[0])) {
                                 // $exist_url = str_replace($path[2], $sources[0], $this->current_url());
                                 // header('Location: ' . $exist_url, true, 301);
                                 // exit;
                                 if (preg_match("/\\.css/", $this->current_url())) {
                                     header('Content-type: text/css');
                                 } else {
                                     if (preg_match("/\\.js/", $this->current_url())) {
                                         header('Content-type: text/js');
                                     }
                                 }
                                 echo file_get_contents(WPFC_WP_CONTENT_DIR . "/cache/wpfc-minified/" . $path[1] . "/" . $sources[0]);
                                 exit;
                             }
                         }
                     } else {
                         //for cache
                         $this->cache();
                     }
                 }
             }
         }
     }
 }