Changeset 2440250
- Timestamp:
- 12/16/2020 12:21:27 AM (5 years ago)
- Location:
- flexistatic
- Files:
-
- 4 edited
- 1 copied
-
tags/2.1.0 (copied) (copied from flexistatic/trunk)
-
tags/2.1.0/flexistatic.php (modified) (12 diffs)
-
tags/2.1.0/readme.txt (modified) (2 diffs)
-
trunk/flexistatic.php (modified) (12 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
flexistatic/tags/2.1.0/flexistatic.php
r1842014 r2440250 5 5 * Description: Make real static posts flexible. 6 6 * Author: 3UU 7 * Version: 2. 0.17 * Version: 2.1.1 8 8 * Author URI: http://datenverwurstungszentrale.com 9 9 * License: MIT … … 16 16 - log all static so that they can get unlink also if structure of permalinks changes 17 17 - speichern an anderem Ort / auf anderem Server (trigger publish) 18 - make all / remove all19 18 */ 20 19 … … 27 26 // sanitoeter 28 27 $static3uu_search = isset($_REQUEST['static3uu_search']) ? sanitize_text_field($_REQUEST['static3uu_search']) : ''; 29 $static3uu_post_ID = isset($_REQUEST['static3uu_post_ID']) && intval($_REQUEST['static3uu_post_ID']) >= '0' ? intval($_REQUEST['static3uu_post_ID']) : ' ';30 $static3uu_startID = isset($_REQUEST['static3uu_startID']) && intval($_REQUEST['static3uu_startID']) >= '0' ? intval($_REQUEST['static3uu_startID']) : ' ';28 $static3uu_post_ID = isset($_REQUEST['static3uu_post_ID']) && intval($_REQUEST['static3uu_post_ID']) >= '0' ? intval($_REQUEST['static3uu_post_ID']) : '0'; 29 $static3uu_startID = isset($_REQUEST['static3uu_startID']) && intval($_REQUEST['static3uu_startID']) >= '0' ? intval($_REQUEST['static3uu_startID']) : '0'; 31 30 32 31 // create/remove static content 33 32 $static3uu_act = isset($_REQUEST['static3uu_act']) ? sanitize_text_field($_REQUEST['static3uu_act']) : ''; 34 if($static3uu_act=='static3UU_proc_make_static') static3UU_proc_make_static($static3uu_post_ID); 35 if($static3uu_act=='static3UU_proc_remove_static') static3UU_proc_remove_static($static3uu_post_ID); 33 if($static3uu_act=='static3UU_proc_make_static') static3UU_proc_make_static($static3uu_post_ID); 34 if($static3uu_act=='static3UU_proc_remove_static') static3UU_proc_remove_static($static3uu_post_ID); 35 if($static3uu_act=='static3UU_proc_make_all_static') static3UU_proc_make_all_static(); 36 if($static3uu_act=='static3UU_proc_remove_all_static')static3UU_proc_remove_all_static(); 36 37 } 37 38 add_action( 'admin_init', 'static3UU_init' ); … … 57 58 <hr> 58 59 <? 59 # global $wp_rewrite;60 # $rtz=$wp_rewrite->mod_rewrite_rules();61 # echo "<pre>";62 # var_dump($rtz);63 # echo "</pre>";64 # #$wp_rewrite->flush_rules();65 66 60 // search a post 67 61 global $static3uu_search; … … 98 92 99 93 global $static3uu_startID; 100 94 if(empty($static3uu_startID))$static3uu_startID='0'; 95 101 96 // start page static 102 97 echo "<h2>".__('Make the start page static.','flexistatic')."</h2>"; … … 122 117 // if index.html get preference. E.g. the very usefull "Simple Custom CSS". 123 118 echo "<p>".__('Attention: Some more ore less usefull plugins do need direct requests to the <code>index.php</code> in the blog root folder. Therefor you should add','flexistatic')," "; 124 $SUBDIR="FR/"; // rtzrtz: must end with an "/" 125 echo "<pre> # FlexiStatic 126 # first make shure that we do not match 127 # requests with dynamic parameters. Also 128 # make sure that the webserver prefers 129 # 'index.html' over directory listing 130 RewriteEngine On 131 132 RewriteBase /".$SUBDIR." 133 RewriteCond %{REQUEST_URI} (index|%{HTTP_HOST})\.html$ 134 RewriteCond %{QUERY_STRING} !^$ 135 RewriteRule . /index.php [L]</pre>"; 136 echo "<pre> ### only needed for WPMU ### 137 RewriteCond %{REQUEST_URI} ^/".$SUBDIR."$ 138 RewriteCond %{QUERY_STRING} ^$ 139 RewriteCond %{DOCUMENT_ROOT}/".$SUBDIR."%{HTTP_HOST}.html -f 140 RewriteRule .* %{HTTP_HOST}.html [L] 141 # END FlexiStatic 142 </pre>"; 119 120 # global $wp_rewrite; 121 # $rtz=$wp_rewrite->mod_rewrite_rules(); 122 # echo "<pre>"; 123 # var_dump($rtz); 124 # echo "</pre>"; 125 # #$wp_rewrite->flush_rules(); 126 127 $SUBDIR=wp_make_link_relative(get_site_url())."/"; # / and only 1 is needed 128 129 echo "<pre> # FlexiStatic 130 # make sure that the webserver prefers 131 # index.html over directory listing 132 133 # with dynamic content 134 RewriteEngine On 135 RewriteBase ".$SUBDIR." 136 RewriteRule index\.html$ - [L] 137 RewriteCond %{REQUEST_URI} (index|%{HTTP_HOST})\.html$ 138 RewriteCond %{QUERY_STRING} !^$ 139 RewriteRule . /index.php? [L]</pre>"; 140 echo "<pre> ### use HTTP_HOST to enable WPMU ### 141 # only needed for the blog page that is 142 # not index.hml like used in subdirs 143 RewriteBase ".$SUBDIR." 144 RewriteRule index\.html$ - [L] 145 RewriteRule %{HTTP_HOST}\.html - [L] 146 RewriteCond %{REQUEST_FILENAME} /$ 147 RewriteCond %{REQUEST_FILENAME} !.*wp-admin.*$ 148 RewriteCond %{QUERY_STRING} !^$ 149 RewriteCond %{DOCUMENT_ROOT}/%{HTTP_HOST}.html -f 150 RewriteRule .* %{HTTP_HOST}.html [L] 151 # END FlexiStatic</pre>"; 143 152 144 153 printf ( __("to your <code>%s/.htaccess</code> file.",'flexistatic'), $_SERVER['DOCUMENT_ROOT'].wp_make_link_relative(get_site_url()) ); … … 148 157 // all list posts/pages 149 158 echo "<h2>".__('Make single posts static.','flexistatic')."</h2>"; 150 // alle Seiten-Urls holen159 // get all posts/pages 151 160 $posts = new WP_Query('post_type=any&posts_per_page=-1'); 152 161 $posts = $posts->posts; … … 204 213 205 214 echo "<hr> $nav <hr>"; 206 } 207 215 216 echo "ALL => "; 217 echo " posts/pages/cats <form style='display:inline!important;' action='".$_SERVER['PHP_SELF']."?page=flexistatic/flexistatic.php' method='POST'>"; 218 echo "<input type='hidden' name='static3uu_startID' value='$static3uu_startID'> 219 <input type='hidden' name='static3uu_act' value='static3UU_proc_remove_all_static'><input type='submit' style='background-color: #ff0000;' value='".__('remove static','flexistatic')."'></form> "; 220 echo "<form style='display:inline!important;' action='".$_SERVER['PHP_SELF']."?page=flexistatic/flexistatic.php' method='POST'>"; 221 echo "<input type='hidden' name='static3uu_startID' value='$static3uu_startID'> 222 <input type='hidden' name='static3uu_act' value='static3UU_proc_make_all_static'><input type='submit' value='".__('make static','flexistatic')."'></form> Content"; 223 224 } 208 225 209 226 function static3UU_proc_make_static($static3uu_post_ID){ … … 291 308 elseif(get_post_type($static3uu_post_ID)=='post') $fsfile=$_SERVER['DOCUMENT_ROOT'].wp_make_link_relative(get_permalink($static3uu_post_ID)); 292 309 293 // check that the static file exists. Than read it... 294 if(is_file($fsfile)) $content=file_get_contents($fsfile); 295 // ...to make sure that we only delete files that this plugin has written! 296 if( strstr($content,"static3UU|$static3uu_post_ID") || strstr($content,"static3UU|autocreate") ) unlink($fsfile); 297 // clean up empty subdirs 298 // rtzTodo: Think about that sombody could have the stupid idea to set permalinks to the temp-dir 299 // auf this vhost. That could become an empty dir! But how to avoid this problem without leaving 300 // perhaps tousends of emty dirs? 301 // However we should at least check that the dir is empty! 302 if(count(scandir(dirname($fsfile)))=='2') rmdir(dirname($fsfile)); 310 // check that the static file exists. 311 if(is_file($fsfile)){ 312 // Than read it... 313 $content=file_get_contents($fsfile); 314 // ...and make sure that we only delete files that this plugin has written! 315 if( strstr($content,"static3UU|$static3uu_post_ID") || strstr($content,"static3UU|autocreate") ) unlink($fsfile); 316 // clean up empty subdirs 317 // rtzTodo: Think about that sombody could have the stupid idea to set permalinks to the temp-dir 318 // auf this vhost. That could become an empty dir! But how to avoid this problem without leaving 319 // perhaps tousends of empty dirs? 320 // However we should at least check that the dir is empty! 321 if(count(scandir(dirname($fsfile)))=='2') rmdir(dirname($fsfile)); 322 } 303 323 // if we have updated a post/page perhaps we must update the blog startpage too 304 324 // rtzTodo: this is workarround until we do a implementition at the editor pages and make a hook on save action … … 307 327 308 328 function static3UU_proc_update_static($static3uu_post_ID){ 309 static3UU_proc_remove_static($static3uu_post_ID);310 static3UU_proc_make_static($static3uu_post_ID);329 static3UU_proc_remove_static($static3uu_post_ID); 330 static3UU_proc_make_static($static3uu_post_ID); 311 331 } 312 332 … … 316 336 if( file_exists($_SERVER['DOCUMENT_ROOT'].wp_make_link_relative(get_permalink($static3uu_post_ID) ) ) ){ 317 337 echo "<h2>WARNING: A static version of this post exists. Please remove it first!!! You must create the static site (and perhaps a static blog start page) again after editing!</h2>"; 338 } 339 } 340 341 function static3UU_proc_make_all_static(){ 342 // get all posts/pages 343 $posts = new WP_Query('post_type=any&posts_per_page=-1'); 344 $posts = $posts->posts; 345 346 foreach($posts as $post) { 347 # echo "working on ID ".$post->ID." | ".$post->post_name."<br>"; 348 # flush(); 349 # ob_flush(); 350 // only on posts/pages 351 if( ($post->post_type!='post') && ($post->post_type!='page') )continue; 352 static3UU_proc_update_static(intval($post->ID)); 353 } 354 } 355 356 function static3UU_proc_remove_all_static(){ 357 // get all posts/pages 358 $posts = new WP_Query('post_type=any&posts_per_page=-1'); 359 $posts = $posts->posts; 360 361 foreach($posts as $post) { 362 # echo "working on ID ".$post->ID." | ".$post->post_name."<br>"; 363 # flush(); 364 # ob_flush(); 365 // only on posts/pages 366 if( ($post->post_type!='post') && ($post->post_type!='page') )continue; 367 static3UU_proc_remove_static(intval($post->ID)); 318 368 } 319 369 } … … 337 387 } 338 388 add_action( 'add_meta_boxes_post', 'add_static3uu_meta_boxes' ); 389 390 339 391 340 392 #function static3UUadmin_sub_page(){ -
flexistatic/tags/2.1.0/readme.txt
r1842020 r2440250 3 3 Tags: static page, performance 4 4 Requires at least: 4.4 5 Tested up to: 4.9.46 Stable tag: 2. 0.25 Tested up to: 5.6 6 Stable tag: 2.1.0 7 7 License: MIT 8 8 License URI: http://opensource.org/licenses/mit … … 95 95 == Changelog == 96 96 97 = 2.1.0 = 98 - works also with parameters (like needed for client side JS) now 99 - if WP is installed within a subdir now add subdir in the hints 100 97 101 = 2.0.2 = 98 102 - optimize RewriteRules to work with installations in subdirs -
flexistatic/trunk/flexistatic.php
r1842014 r2440250 5 5 * Description: Make real static posts flexible. 6 6 * Author: 3UU 7 * Version: 2. 0.17 * Version: 2.1.1 8 8 * Author URI: http://datenverwurstungszentrale.com 9 9 * License: MIT … … 16 16 - log all static so that they can get unlink also if structure of permalinks changes 17 17 - speichern an anderem Ort / auf anderem Server (trigger publish) 18 - make all / remove all19 18 */ 20 19 … … 27 26 // sanitoeter 28 27 $static3uu_search = isset($_REQUEST['static3uu_search']) ? sanitize_text_field($_REQUEST['static3uu_search']) : ''; 29 $static3uu_post_ID = isset($_REQUEST['static3uu_post_ID']) && intval($_REQUEST['static3uu_post_ID']) >= '0' ? intval($_REQUEST['static3uu_post_ID']) : ' ';30 $static3uu_startID = isset($_REQUEST['static3uu_startID']) && intval($_REQUEST['static3uu_startID']) >= '0' ? intval($_REQUEST['static3uu_startID']) : ' ';28 $static3uu_post_ID = isset($_REQUEST['static3uu_post_ID']) && intval($_REQUEST['static3uu_post_ID']) >= '0' ? intval($_REQUEST['static3uu_post_ID']) : '0'; 29 $static3uu_startID = isset($_REQUEST['static3uu_startID']) && intval($_REQUEST['static3uu_startID']) >= '0' ? intval($_REQUEST['static3uu_startID']) : '0'; 31 30 32 31 // create/remove static content 33 32 $static3uu_act = isset($_REQUEST['static3uu_act']) ? sanitize_text_field($_REQUEST['static3uu_act']) : ''; 34 if($static3uu_act=='static3UU_proc_make_static') static3UU_proc_make_static($static3uu_post_ID); 35 if($static3uu_act=='static3UU_proc_remove_static') static3UU_proc_remove_static($static3uu_post_ID); 33 if($static3uu_act=='static3UU_proc_make_static') static3UU_proc_make_static($static3uu_post_ID); 34 if($static3uu_act=='static3UU_proc_remove_static') static3UU_proc_remove_static($static3uu_post_ID); 35 if($static3uu_act=='static3UU_proc_make_all_static') static3UU_proc_make_all_static(); 36 if($static3uu_act=='static3UU_proc_remove_all_static')static3UU_proc_remove_all_static(); 36 37 } 37 38 add_action( 'admin_init', 'static3UU_init' ); … … 57 58 <hr> 58 59 <? 59 # global $wp_rewrite;60 # $rtz=$wp_rewrite->mod_rewrite_rules();61 # echo "<pre>";62 # var_dump($rtz);63 # echo "</pre>";64 # #$wp_rewrite->flush_rules();65 66 60 // search a post 67 61 global $static3uu_search; … … 98 92 99 93 global $static3uu_startID; 100 94 if(empty($static3uu_startID))$static3uu_startID='0'; 95 101 96 // start page static 102 97 echo "<h2>".__('Make the start page static.','flexistatic')."</h2>"; … … 122 117 // if index.html get preference. E.g. the very usefull "Simple Custom CSS". 123 118 echo "<p>".__('Attention: Some more ore less usefull plugins do need direct requests to the <code>index.php</code> in the blog root folder. Therefor you should add','flexistatic')," "; 124 $SUBDIR="FR/"; // rtzrtz: must end with an "/" 125 echo "<pre> # FlexiStatic 126 # first make shure that we do not match 127 # requests with dynamic parameters. Also 128 # make sure that the webserver prefers 129 # 'index.html' over directory listing 130 RewriteEngine On 131 132 RewriteBase /".$SUBDIR." 133 RewriteCond %{REQUEST_URI} (index|%{HTTP_HOST})\.html$ 134 RewriteCond %{QUERY_STRING} !^$ 135 RewriteRule . /index.php [L]</pre>"; 136 echo "<pre> ### only needed for WPMU ### 137 RewriteCond %{REQUEST_URI} ^/".$SUBDIR."$ 138 RewriteCond %{QUERY_STRING} ^$ 139 RewriteCond %{DOCUMENT_ROOT}/".$SUBDIR."%{HTTP_HOST}.html -f 140 RewriteRule .* %{HTTP_HOST}.html [L] 141 # END FlexiStatic 142 </pre>"; 119 120 # global $wp_rewrite; 121 # $rtz=$wp_rewrite->mod_rewrite_rules(); 122 # echo "<pre>"; 123 # var_dump($rtz); 124 # echo "</pre>"; 125 # #$wp_rewrite->flush_rules(); 126 127 $SUBDIR=wp_make_link_relative(get_site_url())."/"; # / and only 1 is needed 128 129 echo "<pre> # FlexiStatic 130 # make sure that the webserver prefers 131 # index.html over directory listing 132 133 # with dynamic content 134 RewriteEngine On 135 RewriteBase ".$SUBDIR." 136 RewriteRule index\.html$ - [L] 137 RewriteCond %{REQUEST_URI} (index|%{HTTP_HOST})\.html$ 138 RewriteCond %{QUERY_STRING} !^$ 139 RewriteRule . /index.php? [L]</pre>"; 140 echo "<pre> ### use HTTP_HOST to enable WPMU ### 141 # only needed for the blog page that is 142 # not index.hml like used in subdirs 143 RewriteBase ".$SUBDIR." 144 RewriteRule index\.html$ - [L] 145 RewriteRule %{HTTP_HOST}\.html - [L] 146 RewriteCond %{REQUEST_FILENAME} /$ 147 RewriteCond %{REQUEST_FILENAME} !.*wp-admin.*$ 148 RewriteCond %{QUERY_STRING} !^$ 149 RewriteCond %{DOCUMENT_ROOT}/%{HTTP_HOST}.html -f 150 RewriteRule .* %{HTTP_HOST}.html [L] 151 # END FlexiStatic</pre>"; 143 152 144 153 printf ( __("to your <code>%s/.htaccess</code> file.",'flexistatic'), $_SERVER['DOCUMENT_ROOT'].wp_make_link_relative(get_site_url()) ); … … 148 157 // all list posts/pages 149 158 echo "<h2>".__('Make single posts static.','flexistatic')."</h2>"; 150 // alle Seiten-Urls holen159 // get all posts/pages 151 160 $posts = new WP_Query('post_type=any&posts_per_page=-1'); 152 161 $posts = $posts->posts; … … 204 213 205 214 echo "<hr> $nav <hr>"; 206 } 207 215 216 echo "ALL => "; 217 echo " posts/pages/cats <form style='display:inline!important;' action='".$_SERVER['PHP_SELF']."?page=flexistatic/flexistatic.php' method='POST'>"; 218 echo "<input type='hidden' name='static3uu_startID' value='$static3uu_startID'> 219 <input type='hidden' name='static3uu_act' value='static3UU_proc_remove_all_static'><input type='submit' style='background-color: #ff0000;' value='".__('remove static','flexistatic')."'></form> "; 220 echo "<form style='display:inline!important;' action='".$_SERVER['PHP_SELF']."?page=flexistatic/flexistatic.php' method='POST'>"; 221 echo "<input type='hidden' name='static3uu_startID' value='$static3uu_startID'> 222 <input type='hidden' name='static3uu_act' value='static3UU_proc_make_all_static'><input type='submit' value='".__('make static','flexistatic')."'></form> Content"; 223 224 } 208 225 209 226 function static3UU_proc_make_static($static3uu_post_ID){ … … 291 308 elseif(get_post_type($static3uu_post_ID)=='post') $fsfile=$_SERVER['DOCUMENT_ROOT'].wp_make_link_relative(get_permalink($static3uu_post_ID)); 292 309 293 // check that the static file exists. Than read it... 294 if(is_file($fsfile)) $content=file_get_contents($fsfile); 295 // ...to make sure that we only delete files that this plugin has written! 296 if( strstr($content,"static3UU|$static3uu_post_ID") || strstr($content,"static3UU|autocreate") ) unlink($fsfile); 297 // clean up empty subdirs 298 // rtzTodo: Think about that sombody could have the stupid idea to set permalinks to the temp-dir 299 // auf this vhost. That could become an empty dir! But how to avoid this problem without leaving 300 // perhaps tousends of emty dirs? 301 // However we should at least check that the dir is empty! 302 if(count(scandir(dirname($fsfile)))=='2') rmdir(dirname($fsfile)); 310 // check that the static file exists. 311 if(is_file($fsfile)){ 312 // Than read it... 313 $content=file_get_contents($fsfile); 314 // ...and make sure that we only delete files that this plugin has written! 315 if( strstr($content,"static3UU|$static3uu_post_ID") || strstr($content,"static3UU|autocreate") ) unlink($fsfile); 316 // clean up empty subdirs 317 // rtzTodo: Think about that sombody could have the stupid idea to set permalinks to the temp-dir 318 // auf this vhost. That could become an empty dir! But how to avoid this problem without leaving 319 // perhaps tousends of empty dirs? 320 // However we should at least check that the dir is empty! 321 if(count(scandir(dirname($fsfile)))=='2') rmdir(dirname($fsfile)); 322 } 303 323 // if we have updated a post/page perhaps we must update the blog startpage too 304 324 // rtzTodo: this is workarround until we do a implementition at the editor pages and make a hook on save action … … 307 327 308 328 function static3UU_proc_update_static($static3uu_post_ID){ 309 static3UU_proc_remove_static($static3uu_post_ID);310 static3UU_proc_make_static($static3uu_post_ID);329 static3UU_proc_remove_static($static3uu_post_ID); 330 static3UU_proc_make_static($static3uu_post_ID); 311 331 } 312 332 … … 316 336 if( file_exists($_SERVER['DOCUMENT_ROOT'].wp_make_link_relative(get_permalink($static3uu_post_ID) ) ) ){ 317 337 echo "<h2>WARNING: A static version of this post exists. Please remove it first!!! You must create the static site (and perhaps a static blog start page) again after editing!</h2>"; 338 } 339 } 340 341 function static3UU_proc_make_all_static(){ 342 // get all posts/pages 343 $posts = new WP_Query('post_type=any&posts_per_page=-1'); 344 $posts = $posts->posts; 345 346 foreach($posts as $post) { 347 # echo "working on ID ".$post->ID." | ".$post->post_name."<br>"; 348 # flush(); 349 # ob_flush(); 350 // only on posts/pages 351 if( ($post->post_type!='post') && ($post->post_type!='page') )continue; 352 static3UU_proc_update_static(intval($post->ID)); 353 } 354 } 355 356 function static3UU_proc_remove_all_static(){ 357 // get all posts/pages 358 $posts = new WP_Query('post_type=any&posts_per_page=-1'); 359 $posts = $posts->posts; 360 361 foreach($posts as $post) { 362 # echo "working on ID ".$post->ID." | ".$post->post_name."<br>"; 363 # flush(); 364 # ob_flush(); 365 // only on posts/pages 366 if( ($post->post_type!='post') && ($post->post_type!='page') )continue; 367 static3UU_proc_remove_static(intval($post->ID)); 318 368 } 319 369 } … … 337 387 } 338 388 add_action( 'add_meta_boxes_post', 'add_static3uu_meta_boxes' ); 389 390 339 391 340 392 #function static3UUadmin_sub_page(){ -
flexistatic/trunk/readme.txt
r1842020 r2440250 3 3 Tags: static page, performance 4 4 Requires at least: 4.4 5 Tested up to: 4.9.46 Stable tag: 2. 0.25 Tested up to: 5.6 6 Stable tag: 2.1.0 7 7 License: MIT 8 8 License URI: http://opensource.org/licenses/mit … … 95 95 == Changelog == 96 96 97 = 2.1.0 = 98 - works also with parameters (like needed for client side JS) now 99 - if WP is installed within a subdir now add subdir in the hints 100 97 101 = 2.0.2 = 98 102 - optimize RewriteRules to work with installations in subdirs
Note: See TracChangeset
for help on using the changeset viewer.