Changeset 3435242
- Timestamp:
- 01/08/2026 03:23:08 PM (3 months ago)
- Location:
- jinx-fast-cache/trunk
- Files:
-
- 6 edited
-
index.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
src/Front.php (modified) (3 diffs)
-
src/Helper.php (modified) (1 diff)
-
src/Plugin.php (modified) (2 diffs)
-
src/Url.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
jinx-fast-cache/trunk/index.php
r3435089 r3435242 5 5 * Plugin URI: https://wordpress.org/plugins/jixn-fast-cache/ 6 6 * Description: Blazing fast full-page caching for WordPress. Jinx Fast-Cache serves static HTML files, bypassing PHP and database overhead entirely. 7 * Version: 0.9. 17 * Version: 0.9.2 8 8 * Author: Jinx Digital <hello@jinx-digital.com> 9 9 * Author URI: http://jinx-digital.com -
jinx-fast-cache/trunk/readme.txt
r3435089 r3435242 135 135 `do_action('jinx_fast_cache', ['ttl' => 3600, 'tags' => ['foo', 'bar']]);` 136 136 137 137 138 == Roadmap == 138 139 -
jinx-fast-cache/trunk/src/Front.php
r3435089 r3435242 22 22 23 23 if (apply_filters('jinx_fast_cache_active', false)) { 24 24 25 25 $files = Helper::getCacheFiles(Helper::getUrl()); 26 26 if (file_exists($files['html'])) { … … 42 42 43 43 add_action('template_redirect', [__CLASS__, 'capture'], PHP_INT_MAX); 44 45 add_filter('jinx_fast_cache_active', function($cache) {46 47 if ($cache === true) {48 49 $disabled = null;50 51 // disable caching if52 // * in maintenance mode53 // * admin bar is showing54 // * is preview55 // * is user logged in56 if (wp_is_maintenance_mode() || is_admin_bar_showing() || is_preview()) {57 $disabled = true;58 } elseif (is_user_logged_in()) {59 $disabled = apply_filters('jinx_fast_cache_ignore_logged_in_users', true);60 } elseif (is_404()) {61 $disabled = apply_filters('jinx_fast_cache_ignore_404', true);62 } else {63 64 $metaKey = Helper::getDisabledMetaKey();65 66 $object = get_queried_object();67 68 if (is_a($object, 'WP_Post')) {69 70 $postTypes = Helper::getPostTypes();71 72 if (in_array($object->post_type, $postTypes)) {73 $disabled = (bool) get_post_meta($object->ID, $metaKey, true);74 } else {75 $disabled = true;76 }77 78 } elseif (is_a($object, 'WP_Term')) {79 80 $taxonomies = Helper::getTaxonomies();81 82 if (in_array($object->taxonomy, $taxonomies)) {83 $disabled = (bool) get_term_meta($object->term_id, $metaKey, true);84 } else {85 $disabled = true;86 }87 88 }89 90 }91 92 if (is_bool($disabled)) {93 return !$disabled;94 }95 96 }97 98 return $cache;99 100 }, PHP_INT_MAX);101 44 102 45 // enqueue inject script only if injects exist … … 112 55 } 113 56 114 }, PHP_INT_MIN); 57 }, PHP_INT_MIN); 115 58 116 59 add_action('wp_ajax_jinx-fast-cache-inject', [__CLASS__, 'ajaxInject']); -
jinx-fast-cache/trunk/src/Helper.php
r3434586 r3435242 212 212 { 213 213 214 $host = $_SERVER['HTTP_HOST'] ?? ''; 215 $requestUri = $_SERVER['REQUEST_URI'] ?? ''; 216 217 $scriptDirectory = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])); 218 219 if ($scriptDirectory !== '/' && strpos($requestUri, $scriptDirectory) === 0) { 220 $path = substr($requestUri, strlen($scriptDirectory)); 221 } else { 222 $path = $requestUri; 223 } 224 225 return rtrim(preg_replace('#/+#', '/', $host.'/'.$path), '/').'/'; 214 $host = $_SERVER['HTTP_HOST'] ?? ''; 215 $requestUri = $_SERVER['REQUEST_URI'] ?? ''; 216 217 $uriParts = explode('?', $requestUri); 218 $path = $uriParts[0]; 219 $queryString = isset($uriParts[1]) ? '?'.$uriParts[1] : ''; 220 221 $scriptPath = str_replace('\\', '/', $_SERVER['SCRIPT_NAME']); 222 $baseDir = str_replace('\\', '/', dirname($scriptPath)); 223 224 if ($baseDir !== '/' && $baseDir !== '.' && strpos($path, $baseDir) === 0) { 225 $path = substr($path, strlen($baseDir)); 226 } 227 228 return rtrim(preg_replace('#/+#', '/', $host.'/'.ltrim($path, '/')), '/').$queryString; 229 226 230 } 227 231 -
jinx-fast-cache/trunk/src/Plugin.php
r3434586 r3435242 36 36 public static function bootstrap() 37 37 { 38 38 39 39 add_filter('jinx_fast_cache_active', function($active) { 40 40 return (bool) Settings::getOption('active', $active); … … 84 84 return array_diff($queryParams, Settings::getOption('ignore_query_params', [])); 85 85 }, 0); 86 87 add_filter('jinx_fast_cache_active', function($cache) { 88 89 if ($cache === true) { 90 91 $disabled = null; 92 93 // disable caching if 94 // * in maintenance mode 95 // * admin bar is showing 96 // * is preview 97 // * is user logged in 98 if (wp_is_maintenance_mode() || is_admin_bar_showing() || is_preview()) { 99 $disabled = true; 100 } elseif (is_user_logged_in()) { 101 $disabled = apply_filters('jinx_fast_cache_ignore_logged_in_users', true); 102 } elseif (is_404()) { 103 $disabled = apply_filters('jinx_fast_cache_ignore_404', true); 104 } else { 105 106 $metaKey = Helper::getDisabledMetaKey(); 107 108 $object = get_queried_object(); 109 110 if (is_a($object, 'WP_Post')) { 111 112 $postTypes = Helper::getPostTypes(); 113 114 if (in_array($object->post_type, $postTypes)) { 115 $disabled = (bool) get_post_meta($object->ID, $metaKey, true); 116 } else { 117 $disabled = true; 118 } 119 120 } elseif (is_a($object, 'WP_Term')) { 121 122 $taxonomies = Helper::getTaxonomies(); 123 124 if (in_array($object->taxonomy, $taxonomies)) { 125 $disabled = (bool) get_term_meta($object->term_id, $metaKey, true); 126 } else { 127 $disabled = true; 128 } 129 130 } 131 132 } 133 134 if (is_bool($disabled)) { 135 return !$disabled; 136 } 137 138 } 139 140 return $cache; 141 142 }, PHP_INT_MAX); 86 143 87 144 } -
jinx-fast-cache/trunk/src/Url.php
r3434620 r3435242 191 191 { 192 192 193 $host = parse_url($url, PHP_URL_HOST); 194 $port = parse_url($url, PHP_URL_PORT); 195 $fullHost = $host . ($port ? ':' . $port : ''); 196 197 $path = parse_url($url, PHP_URL_PATH) ?: ''; 198 199 $basePath = parse_url(site_url(), PHP_URL_PATH) ?: ''; 193 $parts = parse_url($url); 194 $host = $parts['host'] ?? ''; 195 196 $port = isset($parts['port']) ? ':'.$parts['port'] : ''; 197 $path = $parts['path'] ?? ''; 198 199 $basePath = ''; 200 if (function_exists('site_url')) { 201 $basePath = parse_url(site_url(), PHP_URL_PATH) ?: ''; 202 } 200 203 $basePath = trim($basePath, '/'); 201 204 202 205 if (!empty($basePath)) { 203 $path = preg_replace('#^/?' . preg_quote($basePath, '#') . '/?#i', '/', $path); 204 } 205 206 if (!empty($fullHost)) { 207 $url = $fullHost . '/' . $path; 208 } else { 209 $url = $path; 210 } 211 212 $url = preg_replace('#/+#', '/', $url); 213 214 return trim($url, '/').'/'; 215 206 $pattern = '#^/?'.preg_quote($basePath, '#').'(?=/|$)#i'; 207 $path = preg_replace($pattern, '', $path); 208 } 209 210 return trim(preg_replace('#/+#', '/', $host.$port.'/'.$path), '/'); 216 211 217 212 }
Note: See TracChangeset
for help on using the changeset viewer.