Changeset 3086841
- Timestamp:
- 05/15/2024 06:19:11 AM (23 months ago)
- Location:
- fastpixel-website-accelerator
- Files:
-
- 2 added
- 27 edited
- 19 copied
-
tags/1.0.23 (copied) (copied from fastpixel-website-accelerator/trunk)
-
tags/1.0.23/README.md (copied) (copied from fastpixel-website-accelerator/trunk/README.md) (1 diff)
-
tags/1.0.23/advanced-cache.php (copied) (copied from fastpixel-website-accelerator/trunk/advanced-cache.php) (1 diff)
-
tags/1.0.23/composer.json (copied) (copied from fastpixel-website-accelerator/trunk/composer.json)
-
tags/1.0.23/composer.lock (copied) (copied from fastpixel-website-accelerator/trunk/composer.lock)
-
tags/1.0.23/fastpixel.php (copied) (copied from fastpixel-website-accelerator/trunk/fastpixel.php) (2 diffs)
-
tags/1.0.23/icons (copied) (copied from fastpixel-website-accelerator/trunk/icons)
-
tags/1.0.23/inc (copied) (copied from fastpixel-website-accelerator/trunk/inc)
-
tags/1.0.23/inc/autoload.php (modified) (2 diffs)
-
tags/1.0.23/inc/backend/autoload.php (modified) (2 diffs)
-
tags/1.0.23/inc/backend/controllers/actions.php (copied) (copied from fastpixel-website-accelerator/trunk/inc/backend/controllers/actions.php)
-
tags/1.0.23/inc/backend/controllers/cache.php (copied) (copied from fastpixel-website-accelerator/trunk/inc/backend/controllers/cache.php) (16 diffs)
-
tags/1.0.23/inc/backend/controllers/tabs/settings.php (modified) (2 diffs)
-
tags/1.0.23/inc/backend/models/diag-tests/ac-file.php (copied) (copied from fastpixel-website-accelerator/trunk/inc/backend/models/diag-tests/ac-file.php)
-
tags/1.0.23/inc/cache.php (copied) (copied from fastpixel-website-accelerator/trunk/inc/cache.php) (19 diffs)
-
tags/1.0.23/inc/config-model.php (modified) (1 diff)
-
tags/1.0.23/inc/excludes.php (modified) (1 diff)
-
tags/1.0.23/inc/functions.php (modified) (3 diffs)
-
tags/1.0.23/inc/modules/elementor.php (added)
-
tags/1.0.23/inc/modules/endurance.php (modified) (3 diffs)
-
tags/1.0.23/inc/modules/kinsta.php (modified) (5 diffs)
-
tags/1.0.23/inc/rest-api.php (modified) (2 diffs)
-
tags/1.0.23/inc/url.php (modified) (3 diffs)
-
tags/1.0.23/index.php (copied) (copied from fastpixel-website-accelerator/trunk/index.php)
-
tags/1.0.23/keys.dev.pub (copied) (copied from fastpixel-website-accelerator/trunk/keys.dev.pub)
-
tags/1.0.23/keys.tags.pub (copied) (copied from fastpixel-website-accelerator/trunk/keys.tags.pub)
-
tags/1.0.23/languages (copied) (copied from fastpixel-website-accelerator/trunk/languages)
-
tags/1.0.23/readme.txt (copied) (copied from fastpixel-website-accelerator/trunk/readme.txt) (2 diffs)
-
tags/1.0.23/vendor (copied) (copied from fastpixel-website-accelerator/trunk/vendor)
-
tags/1.0.23/vendor/composer/installed.php (copied) (copied from fastpixel-website-accelerator/trunk/vendor/composer/installed.php) (2 diffs)
-
trunk/README.md (modified) (1 diff)
-
trunk/advanced-cache.php (modified) (1 diff)
-
trunk/fastpixel.php (modified) (2 diffs)
-
trunk/inc/autoload.php (modified) (2 diffs)
-
trunk/inc/backend/autoload.php (modified) (2 diffs)
-
trunk/inc/backend/controllers/cache.php (modified) (16 diffs)
-
trunk/inc/backend/controllers/tabs/settings.php (modified) (2 diffs)
-
trunk/inc/cache.php (modified) (19 diffs)
-
trunk/inc/config-model.php (modified) (1 diff)
-
trunk/inc/excludes.php (modified) (1 diff)
-
trunk/inc/functions.php (modified) (3 diffs)
-
trunk/inc/modules/elementor.php (added)
-
trunk/inc/modules/endurance.php (modified) (3 diffs)
-
trunk/inc/modules/kinsta.php (modified) (5 diffs)
-
trunk/inc/rest-api.php (modified) (2 diffs)
-
trunk/inc/url.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fastpixel-website-accelerator/tags/1.0.23/README.md
r3083363 r3086841 5 5 Tested up to: 6.4 6 6 Requires PHP: 5.6 7 Stable tag: 1.0.2 27 Stable tag: 1.0.23 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
fastpixel-website-accelerator/tags/1.0.23/advanced-cache.php
r3083183 r3086841 14 14 $includes = [ 15 15 'FASTPIXEL\FASTPIXEL_Debug' => 'debug.php', 16 'FASTPIXEL\FASTPIXEL_Functions' => 'functions.php', 16 17 'FASTPIXEL\FASTPIXEL_Url' => 'url.php', 17 'FASTPIXEL\FASTPIXEL_Functions' => 'functions.php',18 18 'FASTPIXEL\FASTPIXEL_Config_Model' => 'config-model.php', 19 19 'FASTPIXEL\FASTPIXEL_Diag_Test' => 'backend/models/diag.php', -
fastpixel-website-accelerator/tags/1.0.23/fastpixel.php
r3083363 r3086841 5 5 * Description: Faster WordPress made easy - the latest technology to speed up your website, packaged in a 1-minute setup plugin. 6 6 * Author: ShortPixel 7 * Version: 1.0.2 27 * Version: 1.0.23 8 8 * Text Domain: fastpixel-website-accelerator 9 9 * Domain Path: /languages … … 21 21 defined('ABSPATH') || exit; 22 22 23 define('FASTPIXEL_VERSION', '1.0.2 2');23 define('FASTPIXEL_VERSION', '1.0.23'); 24 24 define('FASTPIXEL_NAME', 'FastPixel'); 25 25 if (!defined('FASTPIXEL_PLUGIN_DIR')) -
fastpixel-website-accelerator/tags/1.0.23/inc/autoload.php
r3083183 r3086841 9 9 $includes = [ 10 10 'FASTPIXEL\FASTPIXEL_Debug' => 'debug.php', 11 'FASTPIXEL\FASTPIXEL_Url' => 'url.php', 11 12 'FASTPIXEL\FASTPIXEL_Functions' => 'functions.php', 12 'FASTPIXEL\FASTPIXEL_ Url' => 'url.php',13 'FASTPIXEL\FASTPIXEL_Config_Model' => 'config-model.php', 13 14 'FASTPIXEL\FASTPIXEL_Exclude' => 'exclude-model.php', 14 15 'FASTPIXEL\FASTPIXEL_Excludes' => 'excludes.php', 15 'FASTPIXEL\FASTPIXEL_Config_Model' => 'config-model.php',16 16 'FASTPIXEL\FASTPIXEL_Cache' => 'cache.php', 17 17 'FASTPIXEL\FASTPIXEL_Plugin' => 'plugin.php' 18 18 ]; 19 19 foreach ($includes as $class_name => $class_path) { 20 if (!class_exists($class_name) ) {20 if (!class_exists($class_name) && file_exists(FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . $class_path)) { 21 21 require_once FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . $class_path; 22 22 } … … 25 25 // // rest_api_init not called if permalinks set to 'Plain' 26 26 add_action('rest_api_init', function () { 27 require FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'rest-api.php'; 27 if (file_exists(FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'rest-api.php')) { 28 require FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'rest-api.php'; 29 } 28 30 }); 29 31 //require backend functions 30 require FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'backend' . DIRECTORY_SEPARATOR . 'autoload.php'; 32 if (file_exists(FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'backend' . DIRECTORY_SEPARATOR . 'autoload.php')) { 33 require FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'backend' . DIRECTORY_SEPARATOR . 'autoload.php'; 34 } -
fastpixel-website-accelerator/tags/1.0.23/inc/backend/autoload.php
r3083183 r3086841 2 2 defined('ABSPATH') || exit; 3 3 4 //include abstract models 5 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/api-key.php'; 6 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/action.php'; 7 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/diag.php'; 8 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/ui-tab.php'; 9 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/ui.php'; 4 //include models 5 $models = array( 6 FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/api-key.php', 7 FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/action.php', 8 FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/diag.php', 9 FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/ui-tab.php', 10 FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/ui.php', 11 12 //include posts table model 13 FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/posts-ui.php' 14 ); 15 foreach($models as $model) { 16 if (file_exists($model)) { 17 include_once $model; 18 } 19 } 10 20 11 21 //include action models … … 13 23 while (false !== ($entry = readdir($handle))) { 14 24 if (!in_array($entry, ['.', '..'])) { 15 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/actions/' . $entry; 25 try { 26 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/actions/' . $entry; 27 } catch(Exception $e) { 28 FASTPIXEL\FASTPIXEL_Debug::log('Error occure while including action model -> ' . $e->getMessage()); 29 } 16 30 } 17 31 } 18 32 closedir($handle); 19 33 } 20 //include posts table model21 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/posts-ui.php';22 34 23 35 //include controllers 24 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/functions.php'; 25 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/notices.php'; 26 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/controller.php'; 27 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/actions.php'; 28 //ui controllers 29 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/ui-single.php'; 30 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/ui-multi.php'; 31 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/ui.php'; 36 $controllers = array( 37 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/functions.php', 38 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/notices.php', 39 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/controller.php', 40 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/actions.php', 41 //ui controllers 42 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/ui-single.php', 43 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/ui-multi.php', 44 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/ui.php', 32 45 33 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/cache.php'; 34 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/diag.php'; 46 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/cache.php', 47 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/diag.php' 48 ); 49 foreach ($controllers as $controller) { 50 if (file_exists($controller)) { 51 include_once $controller; 52 } 53 } -
fastpixel-website-accelerator/tags/1.0.23/inc/backend/controllers/cache.php
r3083363 r3086841 112 112 $current_term = get_term($term_id); 113 113 if ($current_term->slug != $args['slug']) { 114 $url = new FASTPIXEL_Url( null,get_term_link($current_term));114 $url = new FASTPIXEL_Url(get_term_link($current_term)); 115 115 $this->delete_url_cache($url); 116 116 }}, 10, 3); … … 118 118 FASTPIXEL_DEBUG::log('ACTION delete_term'); 119 119 if (!empty($deleted_term)) { 120 $url = new FASTPIXEL_Url( null,get_term_link($deleted_term));120 $url = new FASTPIXEL_Url(get_term_link($deleted_term)); 121 121 $this->delete_url_cache($url); 122 122 } … … 129 129 $term->slug = $args['slug']; 130 130 } 131 $url = new FASTPIXEL_Url( null,get_term_link($term));131 $url = new FASTPIXEL_Url(get_term_link($term)); 132 132 $this->functions->update_post_cache($url->get_url_path(), true); 133 133 }, 10, 3); … … 149 149 if ($post->post_status == 'publish' && $data['post_status'] != 'trash') { 150 150 //resetting/removing cache when post is "unpublished" 151 $url = new FASTPIXEL_Url( $post_id);151 $url = new FASTPIXEL_Url( (int)$post_id); 152 152 $this->delete_url_cache($url); 153 153 } 154 154 //if post was published and still have publish status then we need to check slug, it can be changed too 155 155 if ($post->post_status == 'publish' && $post->post_status == $data['post_status'] && $post->post_name != $data['post_name']) { 156 $url = new FASTPIXEL_Url( $post_id);156 $url = new FASTPIXEL_Url( (int)$post_id); 157 157 $this->delete_url_cache($url); 158 158 } … … 160 160 if ($data['post_status'] == 'trash' && $post->post_status == 'publish') { 161 161 $post->post_name = preg_replace('/__trashed/i', '', $post->post_name); 162 $url = new FASTPIXEL_Url( null,get_the_permalink($post));162 $url = new FASTPIXEL_Url(get_the_permalink($post)); 163 163 $this->delete_url_cache($url); 164 164 } … … 171 171 //need to delete old cached slug 172 172 FASTPIXEL_Debug::log('PRE_POST_UPDATE: Slug changed. Old post slug that should be removed', get_the_permalink($post)); 173 $url = new FASTPIXEL_Url( null,get_the_permalink($post));173 $url = new FASTPIXEL_Url(get_the_permalink($post)); 174 174 $this->delete_url_cache($url); 175 175 } … … 178 178 //need to delete old cached slug 179 179 FASTPIXEL_Debug::log('PRE_POST_UPDATE: Parent changed. Old post slug that should be removed', get_the_permalink($post)); 180 $url = new FASTPIXEL_Url( null,get_the_permalink($post));180 $url = new FASTPIXEL_Url(get_the_permalink($post)); 181 181 $this->delete_url_cache($url); 182 182 } … … 229 229 } 230 230 231 $url = new FASTPIXEL_Url( $post_id);231 $url = new FASTPIXEL_Url( (int)$post_id); 232 232 $path = untrailingslashit($url->get_url_path()); 233 233 //need to check if request already was sent, because on post save much hooks are fired and each can trigger cache request … … 290 290 wp_cache_flush(); 291 291 } 292 do_action('fastpixel _purge_all');292 do_action('fastpixel/purge/all'); 293 293 return true; 294 294 } … … 358 358 } 359 359 } else if ($post_id == 'homepage') { 360 $url = new FASTPIXEL_Url( null,get_home_url());360 $url = new FASTPIXEL_Url(get_home_url()); 361 361 $path = untrailingslashit($url->get_url_path()); 362 362 $this->functions->update_post_cache($path, true); … … 451 451 $permalink = get_permalink($post_id); 452 452 } 453 $url = new FASTPIXEL_Url( null,$permalink);453 $url = new FASTPIXEL_Url($permalink); 454 454 if ($this->delete_url_cache($url)) { 455 455 $post_status = $this->be_functions->cache_status_display($url->get_url()); … … 481 481 WP_Filesystem(); 482 482 } 483 $url = new FASTPIXEL_Url( null,get_home_url());483 $url = new FASTPIXEL_Url(get_home_url()); 484 484 $path = untrailingslashit($url->get_url_path()); 485 485 //need to check if request already was sent, because on post save much hooks are fired and each can trigger cache request … … 531 531 // if blog page is set then it needs to be reset 532 532 $blog_page_id = get_option('page_for_posts'); 533 $blog_url = new FASTPIXEL_Url( $blog_page_id);533 $blog_url = new FASTPIXEL_Url( (int)$blog_page_id); 534 534 $this->functions->update_post_cache($blog_url->get_url_path(), true); 535 535 } … … 539 539 $archive_url = get_post_type_archive_link($post_type); 540 540 if ($archive_url) { 541 $url = new FASTPIXEL_Url( null,$archive_url);541 $url = new FASTPIXEL_Url($archive_url); 542 542 $path = untrailingslashit($url->get_url_path()); 543 543 $this->functions->update_post_cache($path, true); … … 561 561 $term_link = get_term_link($term); 562 562 if (!empty($term_link)) { 563 $url = new FASTPIXEL_Url( null,$term_link);563 $url = new FASTPIXEL_Url($term_link); 564 564 $path = untrailingslashit($url->get_url_path()); 565 565 $this->functions->update_post_cache($path, true); … … 607 607 $url = get_the_permalink($post_id); 608 608 } 609 $url = new FASTPIXEL_Url( null,$url);609 $url = new FASTPIXEL_Url($url); 610 610 if ($this->delete_url_cache($url)) { 611 611 /* translators: %1 should be a url*/ -
fastpixel-website-accelerator/tags/1.0.23/inc/backend/controllers/tabs/settings.php
r3083183 r3086841 45 45 'fastpixel_settings_section' 46 46 ); 47 //add_settings_field(48 //'fastpixel_display_cached_for_logged',49 //esc_html__('Logged-in users', 'fastpixel-website-accelerator'),50 //[$this, 'fastpixel_display_cached_for_logged_cb'],51 //FASTPIXEL_TEXTDOMAIN,52 //'fastpixel_settings_section'53 //);47 add_settings_field( 48 'fastpixel_display_cached_for_logged', 49 esc_html__('Logged-in users', 'fastpixel-website-accelerator'), 50 [$this, 'fastpixel_display_cached_for_logged_cb'], 51 FASTPIXEL_TEXTDOMAIN, 52 'fastpixel_settings_section' 53 ); 54 54 add_settings_field( 55 55 'fastpixel_exclusions', … … 144 144 //deleting existing cache files for excludes 145 145 foreach($excludes as $exclude) { 146 $exclude_url = new FASTPIXEL_Url( null,$home_url . $exclude);146 $exclude_url = new FASTPIXEL_Url($home_url . $exclude); 147 147 if (!empty($exclude)) { 148 148 $this->functions->delete_cached_files($exclude_url->get_url_path()); -
fastpixel-website-accelerator/tags/1.0.23/inc/cache.php
r3083363 r3086841 3 3 4 4 defined('ABSPATH') || exit; 5 use FASTPIXEL\FASTPIXEL_Config_Model;6 5 7 6 if (!class_exists('FASTPIXEL\FASTPIXEL_Cache')) { … … 45 44 public function __construct() { 46 45 self::$instance = $this; 46 //checking for classes to avoid breakdown 47 if (!class_exists('FASTPIXEL\FASTPIXEL_Debug') || !class_exists('FASTPIXEL\FASTPIXEL_Url') || 48 !class_exists('FASTPIXEL\FASTPIXEL_Functions') || !class_exists('FASTPIXEL\FASTPIXEL_Config_Model')) { 49 return false; 50 } 47 51 $this->functions = FASTPIXEL_Functions::get_instance(); 48 52 $this->config = FASTPIXEL_Config_Model::get_instance(); … … 59 63 define('FASTPIXEL_API_URL', FASTPIXEL_API_HOST . '/api/v1/enqueue'); 60 64 } 61 do_action('fastpixel _early_init');62 63 // moving initialization to mu_plugin_loaded because we need sanitization and escaping function initialized64 add_action('mu_plugin_loaded', [$this, 'init']);65 do_action('fastpixel/init/early'); 66 67 //running initialization to check for cached page and return it early if exists 68 $this->init(); 65 69 } 66 70 67 71 public function init() { 68 if (!$this->check_request_agent()) { 69 return; 70 } 71 if (!$this->check_request()) { 72 return; 73 } 74 72 //initializing url 73 $this->url = new FASTPIXEL_Url(); 75 74 $this->cache_dir = $this->functions->get_cache_dir(); 76 $this->url = new FASTPIXEL_Url();77 75 $this->url_path = $this->url->get_url_path(); 78 76 $this->html_path = $this->cache_dir . DIRECTORY_SEPARATOR . $this->url_path . 'index.html'; … … 81 79 $this->meta_path = $this->cache_dir . DIRECTORY_SEPARATOR . $this->url_path . 'meta'; 82 80 83 //if no cache files exists registering function for cache request 81 if (!$this->check_request_agent()) { 82 return; 83 } 84 if (!$this->check_request()) { 85 return; 86 } 87 88 //registering function for cache request 84 89 register_shutdown_function([$this, 'request_page_cache']); 85 90 91 //returning cached file if it exists 86 92 $this->return_cached_if_exists(); 87 93 } … … 125 131 */ 126 132 if (isset($_SERVER['HTTP_USER_AGENT']) && !empty($_SERVER['HTTP_USER_AGENT']) && 127 (strpos( sanitize_text_field($_SERVER['HTTP_USER_AGENT']), 'FastPixel') !== false)133 (strpos($this->functions->sanitize_text_field($_SERVER['HTTP_USER_AGENT']), 'FastPixel') !== false) 128 134 ) { 129 135 //need to check if this is required … … 138 144 */ 139 145 if (isset($_SERVER['QUERY_STRING']) && 140 strpos( sanitize_text_field($_SERVER['QUERY_STRING']), 'fastpixeldebug') !== false) {146 strpos($this->functions->sanitize_text_field($_SERVER['QUERY_STRING']), 'fastpixeldebug') !== false) { 141 147 $this->debug_mode = true; 142 148 } … … 144 150 * Don't ever cache non-GET requests. 145 151 */ 146 if (!isset($_SERVER['REQUEST_METHOD']) || 'GET' !== sanitize_text_field($_SERVER['REQUEST_METHOD'])) {152 if (!isset($_SERVER['REQUEST_METHOD']) || 'GET' !== $this->functions->sanitize_text_field($_SERVER['REQUEST_METHOD'])) { 147 153 FASTPIXEL_DEBUG::log('CHECKING REQUEST: Not GET request, stopped'); 148 154 return false; … … 155 161 defined('DOING_AJAX') || 156 162 (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && 157 strtolower( sanitize_text_field($_SERVER['HTTP_X_REQUESTED_WITH'])) == 'xmlhttprequest')163 strtolower($this->functions->sanitize_text_field($_SERVER['HTTP_X_REQUESTED_WITH'])) == 'xmlhttprequest') 158 164 ) { 159 165 return false; … … 162 168 * getting request url 163 169 */ 164 $requested_url = new FASTPIXEL_Url();170 $requested_url = $this->url; 165 171 /** 166 172 * no need to activate class on api request … … 173 179 * run only for index.php 174 180 */ 175 if (!in_array( sanitize_text_field($_SERVER['SCRIPT_NAME']), ['/index.php'])) {181 if (!in_array($this->functions->sanitize_text_field($_SERVER['SCRIPT_NAME']), ['/index.php'])) { 176 182 return false; 177 183 } … … 204 210 * don't cache request with nocache query 205 211 */ 206 if(isset($_SERVER['QUERY_STRING']) && strpos( sanitize_text_field($_SERVER['QUERY_STRING']), 'fastpixeldisable') !== false) {212 if(isset($_SERVER['QUERY_STRING']) && strpos($this->functions->sanitize_text_field($_SERVER['QUERY_STRING']), 'fastpixeldisable') !== false) { 207 213 return false; 208 214 } … … 380 386 } 381 387 388 //extra check if file is inside cache folder 389 if (strpos(realpath($path), realpath($this->functions->get_cache_dir())) !== 0) { 390 return false; 391 } 392 382 393 if (@file_exists($path) && @is_readable($path)) { 383 394 $modified_time = (int) @filemtime($path); … … 417 428 } 418 429 } 419 /* 420 * displaying .html file, generated by our service 421 * no need to escape output, escape functions are not available in advanced-cache.php 422 */ 423 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile -- direct file output to the browser. 424 readfile($path); // phpcs:ignore 425 echo '<!-- Optimized and served by FastPixel.io -->'; 426 define('FASTPIXEL_STOP_REQUEST', true); 427 @ob_end_flush(); 428 flush(); 429 exit(); 430 if ($this->config->get_option('fastpixel_display_cached_for_logged') && $this->check_is_logged_in()) { 431 //registering hook that will display cached page before page rendering should begin 432 add_action('template_redirect', [$this, 'display_cached_for_logged'], 999); 433 } else { 434 /* 435 * displaying .html file, generated by our service 436 * no need to escape output, escape functions are not available in advanced-cache.php 437 */ 438 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile -- direct file output to the browser. 439 readfile($path); // phpcs:ignore 440 echo '<!-- Optimized and served by FastPixel.io -->'; 441 define('FASTPIXEL_STOP_REQUEST', true); 442 @ob_end_flush(); 443 flush(); 444 exit(); 445 } 430 446 } 431 447 } … … 592 608 $request_path = $this->url->get_url_path(); 593 609 } else if (isset($post_id) && !is_null($post_id) && !empty($post_id)) { 594 $url = new FASTPIXEL_Url( $post_id);610 $url = new FASTPIXEL_Url( (int)$post_id); 595 611 $request_url = $url->get_url(); 596 612 $request_path = $url->get_url_path(); 597 613 } else if (isset($post->ID) && !empty($post->ID)) { 598 $url = new FASTPIXEL_Url( $post->ID);614 $url = new FASTPIXEL_Url( (int)$post->ID); 599 615 $request_url = $url->get_url(); 600 616 $request_path = $url->get_url_path(); … … 630 646 return false; 631 647 } 632 $diag = FASTPIXEL_Diag::get_instance(); 633 if (!$diag->run_activation_tests()) { 634 FASTPIXEL_Debug::log('Common Validation: Stopped. Diagnostics errors'); 635 return false; 648 if (class_exists('FASTPIXEL_Diag')) { 649 $diag = FASTPIXEL_Diag::get_instance(); 650 if (!$diag->run_activation_tests()) { 651 FASTPIXEL_Debug::log('Common Validation: Stopped. Diagnostics errors'); 652 return false; 653 } 636 654 } 637 655 return true; … … 642 660 return false; 643 661 } 644 $url = new FASTPIXEL_Url( null,$input_url);662 $url = new FASTPIXEL_Url($input_url); 645 663 //check for pages that should be excluded from cache 646 664 $excludes = FASTPIXEL_Excludes::get_instance(); … … 716 734 if (!preg_match('/^'.$compare_rest_url_domain.'/i', $compare_reset_url_domain)) { 717 735 FASTPIXEL_DEBUG::log('CACHE REQUEST Error: $reset_url not match FASTPIXEL_REST_URL, request stopped'); 736 FASTPIXEL_DEBUG::log('CACHE REQUEST Error: '.var_export($compare_rest_url_domain, true) . ', '.var_export($compare_reset_url_domain, true), ', '.var_export(FASTPIXEL_REST_URL, true)); 718 737 return false; 719 738 } … … 943 962 public function load_modules() 944 963 { 945 if (!class_exists('FASTPIXEL\FASTPIXEL_Module')) { 964 //checking if file exists before loading 965 if (!class_exists('FASTPIXEL\FASTPIXEL_Module') 966 && file_exists(FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'module.php')) { 946 967 include_once FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'module.php'; 947 } 948 if (file_exists(FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'modules')) { 968 } else { 969 return false; 970 } 971 //including modules 972 if (class_exists('FASTPIXEL\FASTPIXEL_Module') && file_exists(FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'modules')) { 949 973 if ($handle = opendir(FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'modules')) { 950 974 while (false !== ($entry = readdir($handle))) { … … 961 985 } 962 986 } 987 988 public function display_cached_for_logged() { 989 global $wp_styles, $wp_scripts; 990 ob_start(); 991 $post_id = get_the_ID(); 992 do_action('fastpixel/loggeduser/adminbar/beforerender', $post_id); 993 foreach ($wp_styles->queue as $handle) { 994 wp_print_styles($handle); 995 } 996 foreach ($wp_scripts->queue as $handle) { 997 wp_print_scripts($handle); 998 } 999 wp_admin_bar_render(); 1000 do_action('fastpixel/loggeduser/adminbar/afterrender', $post_id); 1001 $admin_bar_output = ob_get_clean(); 1002 ob_start(function ($buffer) use ($admin_bar_output) { 1003 $regex = '/<\s*\/\s*body/s'; 1004 $buffer = preg_replace($regex, $admin_bar_output . '</body', $buffer); 1005 return $buffer; 1006 }); 1007 /* 1008 * displaying .html file, generated by our service 1009 * no need to escape output, escape functions are not available in advanced-cache.php 1010 */ 1011 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile -- direct file output to the browser. 1012 if (@file_exists($this->html_path) && @is_readable($this->html_path)) { 1013 readfile($this->html_path); // phpcs:ignore 1014 } 1015 ob_get_flush(); 1016 exit; 1017 } 963 1018 } 964 1019 new FASTPIXEL_Cache(); -
fastpixel-website-accelerator/tags/1.0.23/inc/config-model.php
r3083183 r3086841 58 58 59 59 public function save_file() { 60 do_action(' save_fastpixel_settings_config', $this);60 do_action('fastpixel/settings/config/save', $this); 61 61 if (!file_exists($this->config_dir)) { 62 62 wp_mkdir_p($this->config_dir); -
fastpixel-website-accelerator/tags/1.0.23/inc/excludes.php
r3083183 r3086841 43 43 return false; 44 44 } 45 $url = new FASTPIXEL_Url( null,$url);45 $url = new FASTPIXEL_Url($url); 46 46 foreach ($this->tests as $test) { 47 47 $test_result = $test->check_is_exclusion($url); -
fastpixel-website-accelerator/tags/1.0.23/inc/functions.php
r3083183 r3086841 137 137 return false; 138 138 } else { 139 $url = new FASTPIXEL_Url( null,$post_url);139 $url = new FASTPIXEL_Url($post_url); 140 140 } 141 141 $data = [ … … 414 414 } 415 415 } 416 $url = new FASTPIXEL_Url( null,$url);416 $url = new FASTPIXEL_Url($url); 417 417 $dirs = explode(DIRECTORY_SEPARATOR, $url->get_url_path()); 418 418 $path = $cache_dir; … … 511 511 return false; 512 512 } 513 514 public function esc_url($url) { 515 if (function_exists('esc_url')) { 516 return esc_url($url); 517 } 518 return $url; 519 } 520 521 public function sanitize_text_field($field) { 522 if (function_exists('sanitize_text_field')) { 523 return sanitize_text_field($field); 524 } 525 return $field; 526 } 513 527 } 514 528 -
fastpixel-website-accelerator/tags/1.0.23/inc/modules/endurance.php
r3083183 r3086841 15 15 16 16 public function init() { 17 add_action(' save_fastpixel_settings_config', [$this, 'save_fastpixel_config'], 10, 1);17 add_action('fastpixel/settings/config/save', [$this, 'save_fastpixel_config'], 10, 1); 18 18 //early init and api init only if module is enabled 19 19 if ($this->enabled) { … … 24 24 25 25 public function api_init() { 26 add_action('fastpixel _cache_files_saved', [$this, 'reset_page_cache'], 10, 1);26 add_action('fastpixel/cachefiles/saved', [$this, 'reset_page_cache'], 10, 1); 27 27 } 28 28 … … 78 78 return; 79 79 } 80 $url = new FASTPIXEL_Url( null,$input_url);80 $url = new FASTPIXEL_Url($input_url); 81 81 $url->add_query_param('epc_nocache'); 82 82 return $url->get_url(); -
fastpixel-website-accelerator/tags/1.0.23/inc/modules/kinsta.php
r3083183 r3086841 18 18 19 19 public function init() { 20 add_action(' save_fastpixel_settings_config', [$this, 'save_fastpixel_config'], 10, 1);20 add_action('fastpixel/settings/config/save', [$this, 'save_fastpixel_config'], 10, 1); 21 21 22 22 //early init and api init only if module is enabled … … 24 24 add_filter('fastpixel_cache_url_before_request', [$this, 'add_nocache_to_url'], 10, 1); 25 25 add_filter('fastpixel_request_purge_all', function ($request) { return false; }, 10, 1); 26 add_action('fastpixel _purge_all', [$this, 'purge_all'], 10);26 add_action('fastpixel/purge/all', [$this, 'purge_all'], 10); 27 27 add_action('admin_bar_menu', [$this, 'update_admin_bar_menu'], 101); 28 28 29 add_action('fastpixel _early_init', [$this, 'early_init'], 10);29 add_action('fastpixel/init/early', [$this, 'early_init'], 10); 30 30 add_action('rest_api_init', [$this, 'api_init'], 10); 31 31 } … … 34 34 public function api_init() { 35 35 add_filter('fastpixel_cache_url_before_request', [$this, 'add_nocache_to_url'], 10, 1); 36 add_action('fastpixel _cache_files_saved', [$this, 'reset_page_cache'], 10, 1);36 add_action('fastpixel/cachefiles/saved', [$this, 'reset_page_cache'], 10, 1); 37 37 } 38 38 … … 49 49 $kinsta_muplugin->kinsta_cache_purge->initiate_purge($post_id); 50 50 } else { 51 $input_url = new FASTPIXEL_Url( null,$cached_url);52 $home_url = new FASTPIXEL_Url( null,home_url());51 $input_url = new FASTPIXEL_Url($cached_url); 52 $home_url = new FASTPIXEL_Url(home_url()); 53 53 $reset_url = preg_replace('/https?:\/\//i', '', $input_url->get_url()); 54 54 if ($input_url->get_url() == $home_url->get_url()) { … … 80 80 return; 81 81 } 82 $url = new FASTPIXEL_Url( null,$input_url);82 $url = new FASTPIXEL_Url($input_url); 83 83 $url->add_query_param('nocache'); 84 84 return $url->get_url(); -
fastpixel-website-accelerator/tags/1.0.23/inc/rest-api.php
r3083183 r3086841 58 58 $is_exclusion = $excludes->check_is_exclusion($parameters['url']); 59 59 $cache_dir = $this->functions->get_cache_dir(); 60 $url = new FASTPIXEL_Url( false,$parameters['url']);60 $url = new FASTPIXEL_Url($parameters['url']); 61 61 if ($is_exclusion) { 62 62 //trying to delete existing files if page is exclusion and for some reason cached page exists … … 112 112 } 113 113 114 do_action('fastpixel _cache_files_saved', $parameters['url']);114 do_action('fastpixel/cachefiles/saved', $parameters['url']); 115 115 return true; 116 116 } -
fastpixel-website-accelerator/tags/1.0.23/inc/url.php
r3083183 r3086841 140 140 private $url_path; 141 141 142 public function __construct($ post_id = null, $url = null) {143 if ( function_exists('get_permalink') && !empty($post_id)) {144 $this->original_url = get_permalink($ post_id);142 public function __construct($url = null) { 143 if (is_int($url) && !empty($url) && function_exists('get_permalink')) { 144 $this->original_url = get_permalink($url); 145 145 FASTPIXEL_DEBUG::log('Getting URL by $post_id', $this->original_url); 146 } else if ( !empty($url)) {146 } else if (is_string($url) && !empty($url) && filter_var($url, FILTER_VALIDATE_URL)) { 147 147 $this->original_url = $url; 148 148 } else { … … 165 165 protected function get_data_from_request() 166 166 { 167 return \esc_url((isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] ? sanitize_text_field($_SERVER['HTTP_X_FORWARDED_PROTO']) : (isset($_SERVER['REQUEST_SCHEME']) && $_SERVER['REQUEST_SCHEME'] ? sanitize_text_field($_SERVER['REQUEST_SCHEME']) : (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http'))) . '://' . sanitize_text_field($_SERVER['HTTP_HOST']) . sanitize_text_field($_SERVER['REQUEST_URI'])); 167 $functions = FASTPIXEL_Functions::get_instance(); 168 return $functions->esc_url( 169 (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] ? $functions->sanitize_text_field($_SERVER['HTTP_X_FORWARDED_PROTO']) : 170 (isset($_SERVER['REQUEST_SCHEME']) && $_SERVER['REQUEST_SCHEME'] ? $functions->sanitize_text_field($_SERVER['REQUEST_SCHEME']) : 171 (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http'))) . '://' . $functions->sanitize_text_field($_SERVER['HTTP_HOST']) . $functions->sanitize_text_field($_SERVER['REQUEST_URI'])); 168 172 } 169 173 public function get_path() … … 237 241 return implode('&', $pairs); 238 242 } 239 240 /*241 * function that escape url242 * based on wordpress default functions which are not accessible in advanced-cache.php243 * used only for secaping urls get from global $_SERVER244 */245 /*protected function esc_url($url) {246 $url = str_replace(' ', '%20', ltrim($url));247 $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url);248 if ('' === $url) {249 return $url;250 }251 252 $strip = array('%0d', '%0a', '%0D', '%0A');253 $count = 1;254 while ($count) {255 $url = str_replace($strip, '', $url, $count);256 }257 258 $url = str_replace(';//', '://', $url);259 if (260 !$this->str_contains($url, ':') && !in_array($url[0], array('/', '#', '?'), true) &&261 !preg_match('/^[a-z0-9-]+?\.php/i', $url)262 ) {263 $url = 'http://' . $url;264 }265 if ($this->str_contains($url, '[') || $this->str_contains($url, ']')) {266 /*267 * can't use here wordpress native function wp_parse_url because this function fires early in advanced-cache.php268 */269 // phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url -- none available before WordPress is loaded.270 /*$parsed = parse_url($url); //phpcs:ignore271 $front = '';272 if (isset($parsed['scheme'])) {273 $front .= $parsed['scheme'] . '://';274 } elseif ('/' === $url[0]) {275 $front .= '//';276 }277 if (isset($parsed['user'])) {278 $front .= $parsed['user'];279 }280 if (isset($parsed['pass'])) {281 $front .= ':' . $parsed['pass'];282 }283 if (isset($parsed['user']) || isset($parsed['pass'])) {284 $front .= '@';285 }286 if (isset($parsed['host'])) {287 $front .= $parsed['host'];288 }289 if (isset($parsed['port'])) {290 $front .= ':' . $parsed['port'];291 }292 $end_dirty = str_replace($front, '', $url);293 $end_clean = str_replace(array('[', ']'), array('%5B', '%5D'), $end_dirty);294 $url = str_replace($end_dirty, $end_clean, $url);295 }296 if ('/' === $url[0]) {297 $good_protocol_url = $url;298 } else {299 $allowed_protocols = array('http', 'https');300 $url = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $url);301 $url = preg_replace('/\\\\+0+/', '', $url);302 // Short-circuit if the string starts with `https://` or `http://`. Most common cases.303 if (304 ($this->str_starts_with($url, 'https://') && in_array('https', $allowed_protocols, true)) ||305 ($this->str_starts_with($url, 'http://') && in_array('http', $allowed_protocols, true))306 ) {307 $good_protocol_url = $url;308 }309 if (strtolower($good_protocol_url) !== strtolower($url)) {310 return '';311 }312 }313 return $good_protocol_url;314 }315 316 protected function str_contains($haystack, $needle) {317 if (function_exists('str_contains')) {318 return str_contains($haystack, $needle);319 }320 return strpos($haystack, $needle) !== false;321 }322 323 protected function str_starts_with($haystack, $needle) {324 if (function_exists('str_starts_with')) {325 return str_starts_with($haystack, $needle);326 }327 if ('' === $needle) {328 return true;329 }330 return 0 === strpos($haystack, $needle);331 }*/332 243 } 333 244 } -
fastpixel-website-accelerator/tags/1.0.23/readme.txt
r3084429 r3086841 5 5 Tested up to: 6.5 6 6 Requires PHP: 5.6 7 Stable tag: 1.0.2 27 Stable tag: 1.0.23 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 141 141 == Changelog == 142 142 143 = 1.0.23 = 144 Release date: May 15, 2024 145 * Bugfixes, added ability to serve cached page for logged in user 146 143 147 = 1.0.22 = 144 148 Release date: May 8, 2024 -
fastpixel-website-accelerator/tags/1.0.23/vendor/composer/installed.php
r3083363 r3086841 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' 258ef55266a10bc93a17b3be690199a63248223b',6 'reference' => '04d640b2dbe51f82f5e430c8086521d5107a1bdd', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' 258ef55266a10bc93a17b3be690199a63248223b',16 'reference' => '04d640b2dbe51f82f5e430c8086521d5107a1bdd', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', -
fastpixel-website-accelerator/trunk/README.md
r3083363 r3086841 5 5 Tested up to: 6.4 6 6 Requires PHP: 5.6 7 Stable tag: 1.0.2 27 Stable tag: 1.0.23 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
fastpixel-website-accelerator/trunk/advanced-cache.php
r3083183 r3086841 14 14 $includes = [ 15 15 'FASTPIXEL\FASTPIXEL_Debug' => 'debug.php', 16 'FASTPIXEL\FASTPIXEL_Functions' => 'functions.php', 16 17 'FASTPIXEL\FASTPIXEL_Url' => 'url.php', 17 'FASTPIXEL\FASTPIXEL_Functions' => 'functions.php',18 18 'FASTPIXEL\FASTPIXEL_Config_Model' => 'config-model.php', 19 19 'FASTPIXEL\FASTPIXEL_Diag_Test' => 'backend/models/diag.php', -
fastpixel-website-accelerator/trunk/fastpixel.php
r3083363 r3086841 5 5 * Description: Faster WordPress made easy - the latest technology to speed up your website, packaged in a 1-minute setup plugin. 6 6 * Author: ShortPixel 7 * Version: 1.0.2 27 * Version: 1.0.23 8 8 * Text Domain: fastpixel-website-accelerator 9 9 * Domain Path: /languages … … 21 21 defined('ABSPATH') || exit; 22 22 23 define('FASTPIXEL_VERSION', '1.0.2 2');23 define('FASTPIXEL_VERSION', '1.0.23'); 24 24 define('FASTPIXEL_NAME', 'FastPixel'); 25 25 if (!defined('FASTPIXEL_PLUGIN_DIR')) -
fastpixel-website-accelerator/trunk/inc/autoload.php
r3083183 r3086841 9 9 $includes = [ 10 10 'FASTPIXEL\FASTPIXEL_Debug' => 'debug.php', 11 'FASTPIXEL\FASTPIXEL_Url' => 'url.php', 11 12 'FASTPIXEL\FASTPIXEL_Functions' => 'functions.php', 12 'FASTPIXEL\FASTPIXEL_ Url' => 'url.php',13 'FASTPIXEL\FASTPIXEL_Config_Model' => 'config-model.php', 13 14 'FASTPIXEL\FASTPIXEL_Exclude' => 'exclude-model.php', 14 15 'FASTPIXEL\FASTPIXEL_Excludes' => 'excludes.php', 15 'FASTPIXEL\FASTPIXEL_Config_Model' => 'config-model.php',16 16 'FASTPIXEL\FASTPIXEL_Cache' => 'cache.php', 17 17 'FASTPIXEL\FASTPIXEL_Plugin' => 'plugin.php' 18 18 ]; 19 19 foreach ($includes as $class_name => $class_path) { 20 if (!class_exists($class_name) ) {20 if (!class_exists($class_name) && file_exists(FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . $class_path)) { 21 21 require_once FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . $class_path; 22 22 } … … 25 25 // // rest_api_init not called if permalinks set to 'Plain' 26 26 add_action('rest_api_init', function () { 27 require FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'rest-api.php'; 27 if (file_exists(FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'rest-api.php')) { 28 require FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'rest-api.php'; 29 } 28 30 }); 29 31 //require backend functions 30 require FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'backend' . DIRECTORY_SEPARATOR . 'autoload.php'; 32 if (file_exists(FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'backend' . DIRECTORY_SEPARATOR . 'autoload.php')) { 33 require FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'backend' . DIRECTORY_SEPARATOR . 'autoload.php'; 34 } -
fastpixel-website-accelerator/trunk/inc/backend/autoload.php
r3083183 r3086841 2 2 defined('ABSPATH') || exit; 3 3 4 //include abstract models 5 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/api-key.php'; 6 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/action.php'; 7 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/diag.php'; 8 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/ui-tab.php'; 9 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/ui.php'; 4 //include models 5 $models = array( 6 FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/api-key.php', 7 FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/action.php', 8 FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/diag.php', 9 FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/ui-tab.php', 10 FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/ui.php', 11 12 //include posts table model 13 FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/posts-ui.php' 14 ); 15 foreach($models as $model) { 16 if (file_exists($model)) { 17 include_once $model; 18 } 19 } 10 20 11 21 //include action models … … 13 23 while (false !== ($entry = readdir($handle))) { 14 24 if (!in_array($entry, ['.', '..'])) { 15 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/actions/' . $entry; 25 try { 26 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/actions/' . $entry; 27 } catch(Exception $e) { 28 FASTPIXEL\FASTPIXEL_Debug::log('Error occure while including action model -> ' . $e->getMessage()); 29 } 16 30 } 17 31 } 18 32 closedir($handle); 19 33 } 20 //include posts table model21 include_once FASTPIXEL_PLUGIN_DIR . '/inc/backend/models/posts-ui.php';22 34 23 35 //include controllers 24 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/functions.php'; 25 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/notices.php'; 26 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/controller.php'; 27 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/actions.php'; 28 //ui controllers 29 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/ui-single.php'; 30 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/ui-multi.php'; 31 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/ui.php'; 36 $controllers = array( 37 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/functions.php', 38 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/notices.php', 39 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/controller.php', 40 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/actions.php', 41 //ui controllers 42 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/ui-single.php', 43 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/ui-multi.php', 44 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/ui.php', 32 45 33 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/cache.php'; 34 require FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/diag.php'; 46 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/cache.php', 47 FASTPIXEL_PLUGIN_DIR . '/inc/backend/controllers/diag.php' 48 ); 49 foreach ($controllers as $controller) { 50 if (file_exists($controller)) { 51 include_once $controller; 52 } 53 } -
fastpixel-website-accelerator/trunk/inc/backend/controllers/cache.php
r3083363 r3086841 112 112 $current_term = get_term($term_id); 113 113 if ($current_term->slug != $args['slug']) { 114 $url = new FASTPIXEL_Url( null,get_term_link($current_term));114 $url = new FASTPIXEL_Url(get_term_link($current_term)); 115 115 $this->delete_url_cache($url); 116 116 }}, 10, 3); … … 118 118 FASTPIXEL_DEBUG::log('ACTION delete_term'); 119 119 if (!empty($deleted_term)) { 120 $url = new FASTPIXEL_Url( null,get_term_link($deleted_term));120 $url = new FASTPIXEL_Url(get_term_link($deleted_term)); 121 121 $this->delete_url_cache($url); 122 122 } … … 129 129 $term->slug = $args['slug']; 130 130 } 131 $url = new FASTPIXEL_Url( null,get_term_link($term));131 $url = new FASTPIXEL_Url(get_term_link($term)); 132 132 $this->functions->update_post_cache($url->get_url_path(), true); 133 133 }, 10, 3); … … 149 149 if ($post->post_status == 'publish' && $data['post_status'] != 'trash') { 150 150 //resetting/removing cache when post is "unpublished" 151 $url = new FASTPIXEL_Url( $post_id);151 $url = new FASTPIXEL_Url( (int)$post_id); 152 152 $this->delete_url_cache($url); 153 153 } 154 154 //if post was published and still have publish status then we need to check slug, it can be changed too 155 155 if ($post->post_status == 'publish' && $post->post_status == $data['post_status'] && $post->post_name != $data['post_name']) { 156 $url = new FASTPIXEL_Url( $post_id);156 $url = new FASTPIXEL_Url( (int)$post_id); 157 157 $this->delete_url_cache($url); 158 158 } … … 160 160 if ($data['post_status'] == 'trash' && $post->post_status == 'publish') { 161 161 $post->post_name = preg_replace('/__trashed/i', '', $post->post_name); 162 $url = new FASTPIXEL_Url( null,get_the_permalink($post));162 $url = new FASTPIXEL_Url(get_the_permalink($post)); 163 163 $this->delete_url_cache($url); 164 164 } … … 171 171 //need to delete old cached slug 172 172 FASTPIXEL_Debug::log('PRE_POST_UPDATE: Slug changed. Old post slug that should be removed', get_the_permalink($post)); 173 $url = new FASTPIXEL_Url( null,get_the_permalink($post));173 $url = new FASTPIXEL_Url(get_the_permalink($post)); 174 174 $this->delete_url_cache($url); 175 175 } … … 178 178 //need to delete old cached slug 179 179 FASTPIXEL_Debug::log('PRE_POST_UPDATE: Parent changed. Old post slug that should be removed', get_the_permalink($post)); 180 $url = new FASTPIXEL_Url( null,get_the_permalink($post));180 $url = new FASTPIXEL_Url(get_the_permalink($post)); 181 181 $this->delete_url_cache($url); 182 182 } … … 229 229 } 230 230 231 $url = new FASTPIXEL_Url( $post_id);231 $url = new FASTPIXEL_Url( (int)$post_id); 232 232 $path = untrailingslashit($url->get_url_path()); 233 233 //need to check if request already was sent, because on post save much hooks are fired and each can trigger cache request … … 290 290 wp_cache_flush(); 291 291 } 292 do_action('fastpixel _purge_all');292 do_action('fastpixel/purge/all'); 293 293 return true; 294 294 } … … 358 358 } 359 359 } else if ($post_id == 'homepage') { 360 $url = new FASTPIXEL_Url( null,get_home_url());360 $url = new FASTPIXEL_Url(get_home_url()); 361 361 $path = untrailingslashit($url->get_url_path()); 362 362 $this->functions->update_post_cache($path, true); … … 451 451 $permalink = get_permalink($post_id); 452 452 } 453 $url = new FASTPIXEL_Url( null,$permalink);453 $url = new FASTPIXEL_Url($permalink); 454 454 if ($this->delete_url_cache($url)) { 455 455 $post_status = $this->be_functions->cache_status_display($url->get_url()); … … 481 481 WP_Filesystem(); 482 482 } 483 $url = new FASTPIXEL_Url( null,get_home_url());483 $url = new FASTPIXEL_Url(get_home_url()); 484 484 $path = untrailingslashit($url->get_url_path()); 485 485 //need to check if request already was sent, because on post save much hooks are fired and each can trigger cache request … … 531 531 // if blog page is set then it needs to be reset 532 532 $blog_page_id = get_option('page_for_posts'); 533 $blog_url = new FASTPIXEL_Url( $blog_page_id);533 $blog_url = new FASTPIXEL_Url( (int)$blog_page_id); 534 534 $this->functions->update_post_cache($blog_url->get_url_path(), true); 535 535 } … … 539 539 $archive_url = get_post_type_archive_link($post_type); 540 540 if ($archive_url) { 541 $url = new FASTPIXEL_Url( null,$archive_url);541 $url = new FASTPIXEL_Url($archive_url); 542 542 $path = untrailingslashit($url->get_url_path()); 543 543 $this->functions->update_post_cache($path, true); … … 561 561 $term_link = get_term_link($term); 562 562 if (!empty($term_link)) { 563 $url = new FASTPIXEL_Url( null,$term_link);563 $url = new FASTPIXEL_Url($term_link); 564 564 $path = untrailingslashit($url->get_url_path()); 565 565 $this->functions->update_post_cache($path, true); … … 607 607 $url = get_the_permalink($post_id); 608 608 } 609 $url = new FASTPIXEL_Url( null,$url);609 $url = new FASTPIXEL_Url($url); 610 610 if ($this->delete_url_cache($url)) { 611 611 /* translators: %1 should be a url*/ -
fastpixel-website-accelerator/trunk/inc/backend/controllers/tabs/settings.php
r3083183 r3086841 45 45 'fastpixel_settings_section' 46 46 ); 47 //add_settings_field(48 //'fastpixel_display_cached_for_logged',49 //esc_html__('Logged-in users', 'fastpixel-website-accelerator'),50 //[$this, 'fastpixel_display_cached_for_logged_cb'],51 //FASTPIXEL_TEXTDOMAIN,52 //'fastpixel_settings_section'53 //);47 add_settings_field( 48 'fastpixel_display_cached_for_logged', 49 esc_html__('Logged-in users', 'fastpixel-website-accelerator'), 50 [$this, 'fastpixel_display_cached_for_logged_cb'], 51 FASTPIXEL_TEXTDOMAIN, 52 'fastpixel_settings_section' 53 ); 54 54 add_settings_field( 55 55 'fastpixel_exclusions', … … 144 144 //deleting existing cache files for excludes 145 145 foreach($excludes as $exclude) { 146 $exclude_url = new FASTPIXEL_Url( null,$home_url . $exclude);146 $exclude_url = new FASTPIXEL_Url($home_url . $exclude); 147 147 if (!empty($exclude)) { 148 148 $this->functions->delete_cached_files($exclude_url->get_url_path()); -
fastpixel-website-accelerator/trunk/inc/cache.php
r3083363 r3086841 3 3 4 4 defined('ABSPATH') || exit; 5 use FASTPIXEL\FASTPIXEL_Config_Model;6 5 7 6 if (!class_exists('FASTPIXEL\FASTPIXEL_Cache')) { … … 45 44 public function __construct() { 46 45 self::$instance = $this; 46 //checking for classes to avoid breakdown 47 if (!class_exists('FASTPIXEL\FASTPIXEL_Debug') || !class_exists('FASTPIXEL\FASTPIXEL_Url') || 48 !class_exists('FASTPIXEL\FASTPIXEL_Functions') || !class_exists('FASTPIXEL\FASTPIXEL_Config_Model')) { 49 return false; 50 } 47 51 $this->functions = FASTPIXEL_Functions::get_instance(); 48 52 $this->config = FASTPIXEL_Config_Model::get_instance(); … … 59 63 define('FASTPIXEL_API_URL', FASTPIXEL_API_HOST . '/api/v1/enqueue'); 60 64 } 61 do_action('fastpixel _early_init');62 63 // moving initialization to mu_plugin_loaded because we need sanitization and escaping function initialized64 add_action('mu_plugin_loaded', [$this, 'init']);65 do_action('fastpixel/init/early'); 66 67 //running initialization to check for cached page and return it early if exists 68 $this->init(); 65 69 } 66 70 67 71 public function init() { 68 if (!$this->check_request_agent()) { 69 return; 70 } 71 if (!$this->check_request()) { 72 return; 73 } 74 72 //initializing url 73 $this->url = new FASTPIXEL_Url(); 75 74 $this->cache_dir = $this->functions->get_cache_dir(); 76 $this->url = new FASTPIXEL_Url();77 75 $this->url_path = $this->url->get_url_path(); 78 76 $this->html_path = $this->cache_dir . DIRECTORY_SEPARATOR . $this->url_path . 'index.html'; … … 81 79 $this->meta_path = $this->cache_dir . DIRECTORY_SEPARATOR . $this->url_path . 'meta'; 82 80 83 //if no cache files exists registering function for cache request 81 if (!$this->check_request_agent()) { 82 return; 83 } 84 if (!$this->check_request()) { 85 return; 86 } 87 88 //registering function for cache request 84 89 register_shutdown_function([$this, 'request_page_cache']); 85 90 91 //returning cached file if it exists 86 92 $this->return_cached_if_exists(); 87 93 } … … 125 131 */ 126 132 if (isset($_SERVER['HTTP_USER_AGENT']) && !empty($_SERVER['HTTP_USER_AGENT']) && 127 (strpos( sanitize_text_field($_SERVER['HTTP_USER_AGENT']), 'FastPixel') !== false)133 (strpos($this->functions->sanitize_text_field($_SERVER['HTTP_USER_AGENT']), 'FastPixel') !== false) 128 134 ) { 129 135 //need to check if this is required … … 138 144 */ 139 145 if (isset($_SERVER['QUERY_STRING']) && 140 strpos( sanitize_text_field($_SERVER['QUERY_STRING']), 'fastpixeldebug') !== false) {146 strpos($this->functions->sanitize_text_field($_SERVER['QUERY_STRING']), 'fastpixeldebug') !== false) { 141 147 $this->debug_mode = true; 142 148 } … … 144 150 * Don't ever cache non-GET requests. 145 151 */ 146 if (!isset($_SERVER['REQUEST_METHOD']) || 'GET' !== sanitize_text_field($_SERVER['REQUEST_METHOD'])) {152 if (!isset($_SERVER['REQUEST_METHOD']) || 'GET' !== $this->functions->sanitize_text_field($_SERVER['REQUEST_METHOD'])) { 147 153 FASTPIXEL_DEBUG::log('CHECKING REQUEST: Not GET request, stopped'); 148 154 return false; … … 155 161 defined('DOING_AJAX') || 156 162 (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && 157 strtolower( sanitize_text_field($_SERVER['HTTP_X_REQUESTED_WITH'])) == 'xmlhttprequest')163 strtolower($this->functions->sanitize_text_field($_SERVER['HTTP_X_REQUESTED_WITH'])) == 'xmlhttprequest') 158 164 ) { 159 165 return false; … … 162 168 * getting request url 163 169 */ 164 $requested_url = new FASTPIXEL_Url();170 $requested_url = $this->url; 165 171 /** 166 172 * no need to activate class on api request … … 173 179 * run only for index.php 174 180 */ 175 if (!in_array( sanitize_text_field($_SERVER['SCRIPT_NAME']), ['/index.php'])) {181 if (!in_array($this->functions->sanitize_text_field($_SERVER['SCRIPT_NAME']), ['/index.php'])) { 176 182 return false; 177 183 } … … 204 210 * don't cache request with nocache query 205 211 */ 206 if(isset($_SERVER['QUERY_STRING']) && strpos( sanitize_text_field($_SERVER['QUERY_STRING']), 'fastpixeldisable') !== false) {212 if(isset($_SERVER['QUERY_STRING']) && strpos($this->functions->sanitize_text_field($_SERVER['QUERY_STRING']), 'fastpixeldisable') !== false) { 207 213 return false; 208 214 } … … 380 386 } 381 387 388 //extra check if file is inside cache folder 389 if (strpos(realpath($path), realpath($this->functions->get_cache_dir())) !== 0) { 390 return false; 391 } 392 382 393 if (@file_exists($path) && @is_readable($path)) { 383 394 $modified_time = (int) @filemtime($path); … … 417 428 } 418 429 } 419 /* 420 * displaying .html file, generated by our service 421 * no need to escape output, escape functions are not available in advanced-cache.php 422 */ 423 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile -- direct file output to the browser. 424 readfile($path); // phpcs:ignore 425 echo '<!-- Optimized and served by FastPixel.io -->'; 426 define('FASTPIXEL_STOP_REQUEST', true); 427 @ob_end_flush(); 428 flush(); 429 exit(); 430 if ($this->config->get_option('fastpixel_display_cached_for_logged') && $this->check_is_logged_in()) { 431 //registering hook that will display cached page before page rendering should begin 432 add_action('template_redirect', [$this, 'display_cached_for_logged'], 999); 433 } else { 434 /* 435 * displaying .html file, generated by our service 436 * no need to escape output, escape functions are not available in advanced-cache.php 437 */ 438 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile -- direct file output to the browser. 439 readfile($path); // phpcs:ignore 440 echo '<!-- Optimized and served by FastPixel.io -->'; 441 define('FASTPIXEL_STOP_REQUEST', true); 442 @ob_end_flush(); 443 flush(); 444 exit(); 445 } 430 446 } 431 447 } … … 592 608 $request_path = $this->url->get_url_path(); 593 609 } else if (isset($post_id) && !is_null($post_id) && !empty($post_id)) { 594 $url = new FASTPIXEL_Url( $post_id);610 $url = new FASTPIXEL_Url( (int)$post_id); 595 611 $request_url = $url->get_url(); 596 612 $request_path = $url->get_url_path(); 597 613 } else if (isset($post->ID) && !empty($post->ID)) { 598 $url = new FASTPIXEL_Url( $post->ID);614 $url = new FASTPIXEL_Url( (int)$post->ID); 599 615 $request_url = $url->get_url(); 600 616 $request_path = $url->get_url_path(); … … 630 646 return false; 631 647 } 632 $diag = FASTPIXEL_Diag::get_instance(); 633 if (!$diag->run_activation_tests()) { 634 FASTPIXEL_Debug::log('Common Validation: Stopped. Diagnostics errors'); 635 return false; 648 if (class_exists('FASTPIXEL_Diag')) { 649 $diag = FASTPIXEL_Diag::get_instance(); 650 if (!$diag->run_activation_tests()) { 651 FASTPIXEL_Debug::log('Common Validation: Stopped. Diagnostics errors'); 652 return false; 653 } 636 654 } 637 655 return true; … … 642 660 return false; 643 661 } 644 $url = new FASTPIXEL_Url( null,$input_url);662 $url = new FASTPIXEL_Url($input_url); 645 663 //check for pages that should be excluded from cache 646 664 $excludes = FASTPIXEL_Excludes::get_instance(); … … 716 734 if (!preg_match('/^'.$compare_rest_url_domain.'/i', $compare_reset_url_domain)) { 717 735 FASTPIXEL_DEBUG::log('CACHE REQUEST Error: $reset_url not match FASTPIXEL_REST_URL, request stopped'); 736 FASTPIXEL_DEBUG::log('CACHE REQUEST Error: '.var_export($compare_rest_url_domain, true) . ', '.var_export($compare_reset_url_domain, true), ', '.var_export(FASTPIXEL_REST_URL, true)); 718 737 return false; 719 738 } … … 943 962 public function load_modules() 944 963 { 945 if (!class_exists('FASTPIXEL\FASTPIXEL_Module')) { 964 //checking if file exists before loading 965 if (!class_exists('FASTPIXEL\FASTPIXEL_Module') 966 && file_exists(FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'module.php')) { 946 967 include_once FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'module.php'; 947 } 948 if (file_exists(FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'modules')) { 968 } else { 969 return false; 970 } 971 //including modules 972 if (class_exists('FASTPIXEL\FASTPIXEL_Module') && file_exists(FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'modules')) { 949 973 if ($handle = opendir(FASTPIXEL_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'modules')) { 950 974 while (false !== ($entry = readdir($handle))) { … … 961 985 } 962 986 } 987 988 public function display_cached_for_logged() { 989 global $wp_styles, $wp_scripts; 990 ob_start(); 991 $post_id = get_the_ID(); 992 do_action('fastpixel/loggeduser/adminbar/beforerender', $post_id); 993 foreach ($wp_styles->queue as $handle) { 994 wp_print_styles($handle); 995 } 996 foreach ($wp_scripts->queue as $handle) { 997 wp_print_scripts($handle); 998 } 999 wp_admin_bar_render(); 1000 do_action('fastpixel/loggeduser/adminbar/afterrender', $post_id); 1001 $admin_bar_output = ob_get_clean(); 1002 ob_start(function ($buffer) use ($admin_bar_output) { 1003 $regex = '/<\s*\/\s*body/s'; 1004 $buffer = preg_replace($regex, $admin_bar_output . '</body', $buffer); 1005 return $buffer; 1006 }); 1007 /* 1008 * displaying .html file, generated by our service 1009 * no need to escape output, escape functions are not available in advanced-cache.php 1010 */ 1011 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile -- direct file output to the browser. 1012 if (@file_exists($this->html_path) && @is_readable($this->html_path)) { 1013 readfile($this->html_path); // phpcs:ignore 1014 } 1015 ob_get_flush(); 1016 exit; 1017 } 963 1018 } 964 1019 new FASTPIXEL_Cache(); -
fastpixel-website-accelerator/trunk/inc/config-model.php
r3083183 r3086841 58 58 59 59 public function save_file() { 60 do_action(' save_fastpixel_settings_config', $this);60 do_action('fastpixel/settings/config/save', $this); 61 61 if (!file_exists($this->config_dir)) { 62 62 wp_mkdir_p($this->config_dir); -
fastpixel-website-accelerator/trunk/inc/excludes.php
r3083183 r3086841 43 43 return false; 44 44 } 45 $url = new FASTPIXEL_Url( null,$url);45 $url = new FASTPIXEL_Url($url); 46 46 foreach ($this->tests as $test) { 47 47 $test_result = $test->check_is_exclusion($url); -
fastpixel-website-accelerator/trunk/inc/functions.php
r3083183 r3086841 137 137 return false; 138 138 } else { 139 $url = new FASTPIXEL_Url( null,$post_url);139 $url = new FASTPIXEL_Url($post_url); 140 140 } 141 141 $data = [ … … 414 414 } 415 415 } 416 $url = new FASTPIXEL_Url( null,$url);416 $url = new FASTPIXEL_Url($url); 417 417 $dirs = explode(DIRECTORY_SEPARATOR, $url->get_url_path()); 418 418 $path = $cache_dir; … … 511 511 return false; 512 512 } 513 514 public function esc_url($url) { 515 if (function_exists('esc_url')) { 516 return esc_url($url); 517 } 518 return $url; 519 } 520 521 public function sanitize_text_field($field) { 522 if (function_exists('sanitize_text_field')) { 523 return sanitize_text_field($field); 524 } 525 return $field; 526 } 513 527 } 514 528 -
fastpixel-website-accelerator/trunk/inc/modules/endurance.php
r3083183 r3086841 15 15 16 16 public function init() { 17 add_action(' save_fastpixel_settings_config', [$this, 'save_fastpixel_config'], 10, 1);17 add_action('fastpixel/settings/config/save', [$this, 'save_fastpixel_config'], 10, 1); 18 18 //early init and api init only if module is enabled 19 19 if ($this->enabled) { … … 24 24 25 25 public function api_init() { 26 add_action('fastpixel _cache_files_saved', [$this, 'reset_page_cache'], 10, 1);26 add_action('fastpixel/cachefiles/saved', [$this, 'reset_page_cache'], 10, 1); 27 27 } 28 28 … … 78 78 return; 79 79 } 80 $url = new FASTPIXEL_Url( null,$input_url);80 $url = new FASTPIXEL_Url($input_url); 81 81 $url->add_query_param('epc_nocache'); 82 82 return $url->get_url(); -
fastpixel-website-accelerator/trunk/inc/modules/kinsta.php
r3083183 r3086841 18 18 19 19 public function init() { 20 add_action(' save_fastpixel_settings_config', [$this, 'save_fastpixel_config'], 10, 1);20 add_action('fastpixel/settings/config/save', [$this, 'save_fastpixel_config'], 10, 1); 21 21 22 22 //early init and api init only if module is enabled … … 24 24 add_filter('fastpixel_cache_url_before_request', [$this, 'add_nocache_to_url'], 10, 1); 25 25 add_filter('fastpixel_request_purge_all', function ($request) { return false; }, 10, 1); 26 add_action('fastpixel _purge_all', [$this, 'purge_all'], 10);26 add_action('fastpixel/purge/all', [$this, 'purge_all'], 10); 27 27 add_action('admin_bar_menu', [$this, 'update_admin_bar_menu'], 101); 28 28 29 add_action('fastpixel _early_init', [$this, 'early_init'], 10);29 add_action('fastpixel/init/early', [$this, 'early_init'], 10); 30 30 add_action('rest_api_init', [$this, 'api_init'], 10); 31 31 } … … 34 34 public function api_init() { 35 35 add_filter('fastpixel_cache_url_before_request', [$this, 'add_nocache_to_url'], 10, 1); 36 add_action('fastpixel _cache_files_saved', [$this, 'reset_page_cache'], 10, 1);36 add_action('fastpixel/cachefiles/saved', [$this, 'reset_page_cache'], 10, 1); 37 37 } 38 38 … … 49 49 $kinsta_muplugin->kinsta_cache_purge->initiate_purge($post_id); 50 50 } else { 51 $input_url = new FASTPIXEL_Url( null,$cached_url);52 $home_url = new FASTPIXEL_Url( null,home_url());51 $input_url = new FASTPIXEL_Url($cached_url); 52 $home_url = new FASTPIXEL_Url(home_url()); 53 53 $reset_url = preg_replace('/https?:\/\//i', '', $input_url->get_url()); 54 54 if ($input_url->get_url() == $home_url->get_url()) { … … 80 80 return; 81 81 } 82 $url = new FASTPIXEL_Url( null,$input_url);82 $url = new FASTPIXEL_Url($input_url); 83 83 $url->add_query_param('nocache'); 84 84 return $url->get_url(); -
fastpixel-website-accelerator/trunk/inc/rest-api.php
r3083183 r3086841 58 58 $is_exclusion = $excludes->check_is_exclusion($parameters['url']); 59 59 $cache_dir = $this->functions->get_cache_dir(); 60 $url = new FASTPIXEL_Url( false,$parameters['url']);60 $url = new FASTPIXEL_Url($parameters['url']); 61 61 if ($is_exclusion) { 62 62 //trying to delete existing files if page is exclusion and for some reason cached page exists … … 112 112 } 113 113 114 do_action('fastpixel _cache_files_saved', $parameters['url']);114 do_action('fastpixel/cachefiles/saved', $parameters['url']); 115 115 return true; 116 116 } -
fastpixel-website-accelerator/trunk/inc/url.php
r3083183 r3086841 140 140 private $url_path; 141 141 142 public function __construct($ post_id = null, $url = null) {143 if ( function_exists('get_permalink') && !empty($post_id)) {144 $this->original_url = get_permalink($ post_id);142 public function __construct($url = null) { 143 if (is_int($url) && !empty($url) && function_exists('get_permalink')) { 144 $this->original_url = get_permalink($url); 145 145 FASTPIXEL_DEBUG::log('Getting URL by $post_id', $this->original_url); 146 } else if ( !empty($url)) {146 } else if (is_string($url) && !empty($url) && filter_var($url, FILTER_VALIDATE_URL)) { 147 147 $this->original_url = $url; 148 148 } else { … … 165 165 protected function get_data_from_request() 166 166 { 167 return \esc_url((isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] ? sanitize_text_field($_SERVER['HTTP_X_FORWARDED_PROTO']) : (isset($_SERVER['REQUEST_SCHEME']) && $_SERVER['REQUEST_SCHEME'] ? sanitize_text_field($_SERVER['REQUEST_SCHEME']) : (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http'))) . '://' . sanitize_text_field($_SERVER['HTTP_HOST']) . sanitize_text_field($_SERVER['REQUEST_URI'])); 167 $functions = FASTPIXEL_Functions::get_instance(); 168 return $functions->esc_url( 169 (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] ? $functions->sanitize_text_field($_SERVER['HTTP_X_FORWARDED_PROTO']) : 170 (isset($_SERVER['REQUEST_SCHEME']) && $_SERVER['REQUEST_SCHEME'] ? $functions->sanitize_text_field($_SERVER['REQUEST_SCHEME']) : 171 (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http'))) . '://' . $functions->sanitize_text_field($_SERVER['HTTP_HOST']) . $functions->sanitize_text_field($_SERVER['REQUEST_URI'])); 168 172 } 169 173 public function get_path() … … 237 241 return implode('&', $pairs); 238 242 } 239 240 /*241 * function that escape url242 * based on wordpress default functions which are not accessible in advanced-cache.php243 * used only for secaping urls get from global $_SERVER244 */245 /*protected function esc_url($url) {246 $url = str_replace(' ', '%20', ltrim($url));247 $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url);248 if ('' === $url) {249 return $url;250 }251 252 $strip = array('%0d', '%0a', '%0D', '%0A');253 $count = 1;254 while ($count) {255 $url = str_replace($strip, '', $url, $count);256 }257 258 $url = str_replace(';//', '://', $url);259 if (260 !$this->str_contains($url, ':') && !in_array($url[0], array('/', '#', '?'), true) &&261 !preg_match('/^[a-z0-9-]+?\.php/i', $url)262 ) {263 $url = 'http://' . $url;264 }265 if ($this->str_contains($url, '[') || $this->str_contains($url, ']')) {266 /*267 * can't use here wordpress native function wp_parse_url because this function fires early in advanced-cache.php268 */269 // phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url -- none available before WordPress is loaded.270 /*$parsed = parse_url($url); //phpcs:ignore271 $front = '';272 if (isset($parsed['scheme'])) {273 $front .= $parsed['scheme'] . '://';274 } elseif ('/' === $url[0]) {275 $front .= '//';276 }277 if (isset($parsed['user'])) {278 $front .= $parsed['user'];279 }280 if (isset($parsed['pass'])) {281 $front .= ':' . $parsed['pass'];282 }283 if (isset($parsed['user']) || isset($parsed['pass'])) {284 $front .= '@';285 }286 if (isset($parsed['host'])) {287 $front .= $parsed['host'];288 }289 if (isset($parsed['port'])) {290 $front .= ':' . $parsed['port'];291 }292 $end_dirty = str_replace($front, '', $url);293 $end_clean = str_replace(array('[', ']'), array('%5B', '%5D'), $end_dirty);294 $url = str_replace($end_dirty, $end_clean, $url);295 }296 if ('/' === $url[0]) {297 $good_protocol_url = $url;298 } else {299 $allowed_protocols = array('http', 'https');300 $url = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $url);301 $url = preg_replace('/\\\\+0+/', '', $url);302 // Short-circuit if the string starts with `https://` or `http://`. Most common cases.303 if (304 ($this->str_starts_with($url, 'https://') && in_array('https', $allowed_protocols, true)) ||305 ($this->str_starts_with($url, 'http://') && in_array('http', $allowed_protocols, true))306 ) {307 $good_protocol_url = $url;308 }309 if (strtolower($good_protocol_url) !== strtolower($url)) {310 return '';311 }312 }313 return $good_protocol_url;314 }315 316 protected function str_contains($haystack, $needle) {317 if (function_exists('str_contains')) {318 return str_contains($haystack, $needle);319 }320 return strpos($haystack, $needle) !== false;321 }322 323 protected function str_starts_with($haystack, $needle) {324 if (function_exists('str_starts_with')) {325 return str_starts_with($haystack, $needle);326 }327 if ('' === $needle) {328 return true;329 }330 return 0 === strpos($haystack, $needle);331 }*/332 243 } 333 244 } -
fastpixel-website-accelerator/trunk/readme.txt
r3084429 r3086841 5 5 Tested up to: 6.5 6 6 Requires PHP: 5.6 7 Stable tag: 1.0.2 27 Stable tag: 1.0.23 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 141 141 == Changelog == 142 142 143 = 1.0.23 = 144 Release date: May 15, 2024 145 * Bugfixes, added ability to serve cached page for logged in user 146 143 147 = 1.0.22 = 144 148 Release date: May 8, 2024 -
fastpixel-website-accelerator/trunk/vendor/composer/installed.php
r3083363 r3086841 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' 258ef55266a10bc93a17b3be690199a63248223b',6 'reference' => '04d640b2dbe51f82f5e430c8086521d5107a1bdd', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' 258ef55266a10bc93a17b3be690199a63248223b',16 'reference' => '04d640b2dbe51f82f5e430c8086521d5107a1bdd', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.