Changeset 3442759
- Timestamp:
- 01/19/2026 07:17:29 PM (2 months ago)
- Location:
- static-porter/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (6 diffs)
-
static-porter.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
static-porter/trunk/readme.txt
r3441946 r3442759 1 1 === Static Porter === 2 Contributors: kturgutoglu 3 Tags: static site generator, SEO, performance, page speed, optimization 2 Contributors: KAYIHAN TURGUTOGLU, KAYA TURK 3 Donate link: https://www.paypal.me/kturgutoglu 4 Tags: static, cache, performance, speed, optimization 4 5 Requires at least: 5.0 5 6 Tested up to: 6.9 … … 9 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 11 11 Slash your page load times without changing a single URL. Static Porter converts WordPress into lightning-fast static HTML while preserving your exact permalink structure for 100% SEO safety. Reduce server load and improve SEO instantly.12 Convert your dynamic WordPress site into ultra-fast static HTML files. Reduce server load and improve SEO instantly. 12 13 13 14 == Description == … … 18 19 19 20 ### Key Features: 20 * **One-Click Full Crawl:** Easily generate a static HTML version of your entire site. 21 * **Zero URL Changes:** Static Porter keeps your original URL slugs exactly as they are. Your SEO remains intact with no broken links. 21 * **One-Click Full Crawl:** Easily generate a static version of your entire site. 22 22 * **Smart Refresh:** Automatically updates the static home page and post pages when you hit publish. 23 23 * **Persistent Cache Table:** Monitor exactly which files are cached with individual 'Delete' and 'Recrawl' controls. … … 35 35 == Frequently Asked Questions == 36 36 37 = Will Static Porter really make my site faster? = 38 Yes! Traditional WordPress pages require the server to process PHP and query a MySQL database every time a visitor arrives. Static Porter converts these into flat HTML files. Your server can then deliver these files instantly, bypassing the "heavy lifting" entirely. This often results in a nearly instant Time to First Byte (TTFB). 39 40 = Will my URL structure or permalinks change? = 41 No. This is one of the core strengths of Static Porter. The plugin generates a static mirror of your site that follows your existing WordPress permalink structure perfectly. Your visitors (and search engine bots) will continue to see the same clean URLs they always have, but the pages will simply load much faster. 42 43 = Do I have to manually recrawl my site every time I write a post? = 44 No. Static Porter includes a "Smart Refresh" feature. When you publish or update a post, the plugin automatically regenerates the static version of that specific post and your homepage. It’s a "set-and-forget" solution for active bloggers. 45 46 = Can I use this on a low-resource budget server? = 47 Absolutely. Static Porter is designed to be resource-efficient and includes a built-in "Peak Memory" monitor in the dashboard so you can track its impact. If the crawl is too heavy for your server, you can use the "Stop Crawl" safety button at any time to immediately halt the process. 48 49 = Does this plugin improve my site's security? = 50 Yes. In addition to serving static files (which are inherently more secure than dynamic PHP), Static Porter automatically injects security headers into your .htaccess file. This includes protection against clickjacking (X-Frame-Options) and MIME-type sniffing (X-Content-Type-Options). 51 52 = Will this help my Google search rankings (SEO)? = 53 Speed is a major ranking factor for Google, especially with Core Web Vitals. By serving ultra-fast static HTML and enabling Gzip compression and browser caching automatically, your site will likely see improved performance scores, which can lead to better visibility in search results. 54 55 = What happens if I want to remove a single page from the cache? = 56 Unlike simple "purge all" plugins, Static Porter gives you a persistent cache table. You can view a list of every cached URL and use individual "Delete" or "Recrawl" buttons for precise control without affecting the rest of your static site. 57 58 = Can I choose which parts of my site to make static? = 59 Yes. The dashboard allows you to toggle the crawling of Posts, Pages, Categories, and Tags independently. You can also use the "Excluded Paths" box to prevent specific directories from ever being turned into static files. 37 = Does this work with WooCommerce? = 38 It is recommended to exclude checkout, cart, and account pages using the "Excluded Paths" setting to ensure dynamic functionality remains intact. 60 39 61 40 = How do I know if it's working? = 62 41 Enable the "HTML Attribution" setting. View your website's source code, and you will see a comment at the top confirming the page is being served as static HTML. 63 64 = Does this work with WooCommerce? =65 It is recommended to exclude checkout, cart, and account pages using the "Excluded Paths" setting to ensure dynamic functionality remains intact.66 42 67 43 == Screenshots == … … 73 49 == Upgrade Notice == 74 50 51 = 3.5.4 = 52 This version introduces the new professional "Porter" branding, optimized UI, and a faster 5-second auto-refresh after crawling. Highly recommended for all users. 53 54 == Changelog == 55 56 = 3.5.4 = 57 * **New Icon:** Updated plugin branding to a professional "Porter/Package" box icon. 58 * **UI Refresh:** Restored sidebar labels and updated dashboard header icons. 59 * **Timer Update:** Reduced post-crawl auto-refresh from 10 seconds to 5 seconds for a faster workflow. 60 61 75 62 = 3.4.7 = 76 63 This version adds a persistent cache management table and a manual "Stop Crawl" safety button. Highly recommended for all users. … … 78 65 == Changelog == 79 66 80 = 3. 5.2=67 = 3.4.7 = 81 68 * Major fixes 82 69 * Added Stop Crawl functionality. -
static-porter/trunk/static-porter.php
r3441902 r3442759 3 3 * Plugin Name: Static Porter 4 4 * Description: High-performance static site generator with optional Gzip, Minification, Security Headers, and Cache-Control settings. 5 * Version: 3.5. 26 * Author: kturgutoglu5 * Version: 3.5.4 6 * Author: KAYIHAN TURGUTOGLU, KAYA TURK 7 7 * License: GPLv2 or later 8 8 * License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 11 11 12 12 // --- Configuration --- 13 define('STATIC_PORTER_VERSION', '3.5. 2');13 define('STATIC_PORTER_VERSION', '3.5.4'); 14 14 15 15 // Use a function to get the cache directory to ensure wp_upload_dir is available … … 36 36 if (!function_exists('static_porter_add_sidebar_menu')) { 37 37 function static_porter_add_sidebar_menu() { 38 $icon_svg = 'data:image/svg+xml;base64,' . base64_encode('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path d="M10 2L8 5h4l-2-3zM8 6l-1 8h6l-1-8H8zm-1 9v1h6v-1H7zm-1 2v1h8v-1H6z"/></svg>'); 38 // Modern 3D Isometric Box (Porter Package) 39 $icon_svg = 'data:image/svg+xml;base64,' . base64_encode('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path d="M11 2a1 1 0 011 1v1h3a1 1 0 011 1v12a1 1 0 01-1 1H5a1 1 0 01-1-1V5a1 1 0 011-1h3V3a1 1 0 011-1h2zM9 4v1h2V4H9zM8 6H6v10h8V6h-2v1a1 1 0 11-2 0V6z"/></svg>'); 40 39 41 add_menu_page( 40 'Static Porter', 41 'Static Porter', 42 'manage_options', 43 'static-porter', 42 'Static Porter', // Page Title 43 'Static Porter', // Menu Label 44 'manage_options', // Permission 45 'static-porter', // Slug 44 46 'static_porter_dashboard', 45 $icon_svg, 47 $icon_svg, // The Box Icon 46 48 3 47 49 ); … … 49 51 } 50 52 53 51 54 // --- Assets & Scripts --- 52 55 if (!function_exists('static_porter_enqueue_assets')) { … … 64 67 'nonce' => wp_create_nonce('static_porter_nonce') 65 68 ]; 66 // Use wp_json_encode instead of json_encode67 69 wp_add_inline_script('static-porter-admin-js', 'var spConfig = ' . wp_json_encode($script_vars) . ';'); 68 70 69 71 $js_logic = " 70 72 jQuery(document).ready(function($) { 71 let currentLiveCount = parseInt($('#sp-live-count').text()) || 0;72 73 let stopCrawl = false; 73 74 … … 89 90 \$btn.text('Recrawl').css('color', '#2271b1').prop('disabled', false); 90 91 \$row.find('.row-size').text('—'); 91 currentLiveCount--;92 $('#sp-live-count').text(currentLiveCount);93 92 }); 94 93 } else { … … 98 97 \$btn.text('Delete').css('color', '#d63638').prop('disabled', false); 99 98 \$row.find('.row-size').text(res.data.size); 100 currentLiveCount++;101 $('#sp-live-count').text(currentLiveCount);102 99 } 103 100 }); … … 143 140 $('#sp-summary-text').text('Now your ' + processedSuccessfully + ' pages are being served as HTML. They will load way faster.'); 144 141 $('#sp-finish-area').fadeIn(); 145 let timeLeft = 10;142 let timeLeft = 5; 146 143 setInterval(() => { 147 144 timeLeft--; … … 164 161 if(response.success) { 165 162 processedSuccessfully++; 166 currentLiveCount++;167 $('#sp-live-count').text(currentLiveCount).fadeOut(100).fadeIn(100);168 163 if ($('tr[data-url=\"'+url+'\"]').length > 0) { 169 164 const \$existingRow = $('tr[data-url=\"'+url+'\"]'); … … 314 309 } 315 310 316 // 2. Attribution Branding (FIXED)311 // 2. Attribution Branding 317 312 if (get_option('static_porter_enable_attr', '1') === '1') { 318 313 $msg_template = get_option('static_porter_attr_msg'); 319 // If the message is empty in database, use this hard fallback string320 314 if (empty($msg_template)) { 321 315 $msg_template = 'Verification: Page served as static HTML by Static Porter v{version} at {timestamp}'; 322 316 } 323 317 $processed_msg = str_replace(['{version}', '{timestamp}'], [STATIC_PORTER_VERSION, current_time('mysql')], $msg_template); 324 325 // Starts strictly at the first character, then newline for Line 2 326 $attribution = "<!-- " . esc_html($processed_msg) . " -->\n"; 327 $html = $attribution . ltrim($html); 318 $attribution = "\n"; 319 $html = $attribution . ltrim($html); 328 320 } 329 321 … … 406 398 $cache_dir = static_porter_get_cache_dir(); 407 399 if (isset($_POST['save_sp_settings'])) { 408 check_admin_referer('static_porter_save_settings'); 400 if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'static_porter_save_settings')) { 401 wp_die('Security check failed. Please refresh the page and try again.'); 402 } 409 403 update_option('static_porter_excluded_paths', sanitize_textarea_field($_POST['excluded_paths'])); 410 404 update_option('static_porter_enable_gzip', isset($_POST['static_porter_enable_gzip']) ? '1' : '0'); … … 422 416 echo '<div class="updated"><p>Settings updated.</p></div>'; 423 417 } 424 if (isset($_POST['purge_sp_cache'])) { check_admin_referer('static_porter_purge_cache'); static_porter_clear_cache($cache_dir); delete_option('static_porter_last_crawl_time'); echo '<div class="updated"><p>Cache purged.</p></div>'; } 418 if (isset($_POST['purge_sp_cache'])) { 419 if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'static_porter_save_settings')) { 420 wp_die('Security check failed. Please refresh the page and try again.'); 421 } 422 static_porter_clear_cache($cache_dir); 423 delete_option('static_porter_last_crawl_time'); 424 echo '<div class="updated"><p>Cache purged.</p></div>'; 425 } 425 426 426 427 $excluded = get_option('static_porter_excluded_paths', ''); … … 446 447 $peak_mem = (int)get_option('static_porter_peak_memory_usage', 0); 447 448 $server_icon = (stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false) ? 'Nginx' : ((stripos($_SERVER['SERVER_SOFTWARE'], 'litespeed') !== false) ? 'LiteSpeed' : 'Apache'); 448 global $wp_version; $avg_size = ($file_count > 0) ? $disk_usage / $file_count : 0; 449 $os_info = php_uname('s') . ' ' . php_uname('r'); 449 $avg_size = ($file_count > 0) ? $disk_usage / $file_count : 0; 450 451 // --- DATA PREP FOR CARDS --- 452 $count_posts = wp_count_posts('post'); $published_posts = $count_posts->publish; 453 $count_pages = wp_count_posts('page'); $published_pages = $count_pages->publish; 454 $total_public = $published_posts + $published_pages; 455 $coverage_pct = ($total_public > 0) ? round(($file_count / $total_public) * 100) : 0; 456 457 $cards = [ 458 ['Static Coverage', $coverage_pct . '%', $file_count . ' of ' . $total_public . ' urls'], 459 ['PHP & MySQL Requests Avoided', $file_count, 'Estimated'], 460 ['Peak Memory', size_format($peak_mem, 2), 'Max usage during crawl'], 461 ['Static Files Size', size_format($disk_usage), 'On disk'] 462 ]; 450 463 ?> 451 464 <div class="wrap"> 452 465 <div style="display: flex; align-items: center; gap: 15px; margin-top: 10px; margin-bottom: 20px;"> 453 466 <div style="width: 50px; height: 50px; background: #2271b1; border-radius: 6px; display: flex; align-items: center; justify-content: center;"> 454 <svg width="30" height="30" viewBox="0 0 20 20" fill="#fff" xmlns="http://www.w3.org/2000/svg"><path d="M1 0 2L8 5h4l-2-3zM8 6l-1 8h6l-1-8H8zm-1 9v1h6v-1H7zm-1 2v1h8v-1H6z"/></svg>467 <svg width="30" height="30" viewBox="0 0 20 20" fill="#fff" xmlns="http://www.w3.org/2000/svg"><path d="M11 2a1 1 0 011 1v1h3a1 1 0 011 1v12a1 1 0 01-1 1H5a1 1 0 01-1-1V5a1 1 0 011-1h3V3a1 1 0 011-1h2zM8 6H6v10h8V6h-2v1a1 1 0 11-2 0V6zM9 4v1h2V4H9z"/></svg> 455 468 </div> 456 469 <h1 style="margin:0;">Static Porter <small style="font-size: 12px; opacity: 0.6;">v<?php echo esc_html(STATIC_PORTER_VERSION); ?></small></h1> 457 470 </div> 458 <div style="display: grid; grid-template-columns: 1fr 320px; gap: 20px;"> 471 472 <div style="display:flex; gap:16px; margin-bottom:20px; flex-wrap:wrap;"> 473 <?php foreach($cards as $c): ?> 474 <div style="flex:1; min-width: 200px; background:#fff; border:1px solid #ccd0d4; border-radius:4px; padding:16px;"> 475 <strong><?php echo esc_html($c[0]); ?></strong> 476 <div style="font-size:24px; margin:8px 0;"><?php echo esc_html($c[1]); ?></div> 477 <div style="font-size:12px; color:#666;"><?php echo esc_html($c[2]); ?></div> 478 </div> 479 <?php endforeach; ?> 480 </div> 481 <div> 459 482 <div class="sp-main"> 460 <form method="post" >483 <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>"> 461 484 <?php wp_nonce_field('static_porter_save_settings'); ?> 462 485 <div class="card"> … … 490 513 <button type="button" id="sp-start" class="button button-secondary" style="margin-left:10px;">Start Full Crawl</button> 491 514 <button type="button" id="sp-stop" class="button" style="margin-left:10px; display:none; color: #d63638; border-color: #d63638;">Stop Crawl</button> 492 </div> 515 <input type="submit" name="purge_sp_cache" class="button" value="Purge Cache" style="margin-left:10px;" onclick="return confirm('Are you sure you want to clear all static files?');"> 516 </div> 517 493 518 <div id="sp-progress" style="display:none; margin-top: 30px; padding: 20px; background: #f6f7f7; border: 1px solid #dcdcde;"> 494 519 <div style="display: flex; justify-content: space-between; margin-bottom: 10px;"><strong id="sp-label">Initialising...</strong><span id="sp-percent">0%</span></div> … … 496 521 <p id="sp-status" style="font-family: monospace; font-size: 11px; color: #666;"></p> 497 522 <div id="sp-finish-area" style="display:none; border-top: 1px solid #dcdcde; padding-top: 20px;"> 498 <h3>✅ Crawl Complete!</h3><p id="sp-summary-text"></p><p>Refreshing page in <span id="sp-timer"> 10</span> seconds...</p>523 <h3>✅ Crawl Complete!</h3><p id="sp-summary-text"></p><p>Refreshing page in <span id="sp-timer">5</span> seconds...</p> 499 524 </div> 500 525 </div> … … 507 532 </div> 508 533 </form> 509 <form method="post" style="margin-top: 20px;"><?php wp_nonce_field('static_porter_purge_cache'); ?><input type="submit" name="purge_sp_cache" class="button" value="Purge Cache" style="margin-left:10px;"></form>510 </div>511 <div class="sp-sidebar">512 <div class="card">513 <h3>Status</h3>514 <table class="widefat" style="border:0; font-size: 12px;">515 <tr><td><strong>Cached Pages</strong></td><td style="text-align:right; font-size:22px; font-weight:800; color:#2271b1;" id="sp-live-count"><?php echo esc_html($file_count); ?></td></tr>516 <tr><td><strong>Efficiency</strong></td><td style="text-align:right; color:#46b450;">-<?php echo esc_html($efficiency); ?>%</td></tr>517 <tr><td><strong>Disk Usage</strong></td><td style="text-align:right;"><?php echo size_format($disk_usage, 2); ?></td></tr>518 <tr><td><strong>Avg. Page Size</strong></td><td style="text-align:right;"><?php echo size_format($avg_size, 2); ?></td></tr>519 <tr><td><strong>Peak Memory</strong></td><td style="text-align:right;"><?php echo size_format($peak_mem, 2); ?></td></tr>520 <tr><td><strong>Cache Health</strong></td><td style="text-align:right;"><?php echo wp_kses_post($cache_writable); ?></td></tr>521 <tr><td><strong>Server</strong></td><td style="text-align:right;"><?php echo esc_html($server_icon); ?></td></tr>522 </table>523 </div>524 534 </div> 525 535 </div>
Note: See TracChangeset
for help on using the changeset viewer.