Changeset 422897
- Timestamp:
- 08/13/2011 12:07:36 PM (15 years ago)
- Location:
- generate-cache
- Files:
-
- 8 added
- 6 edited
-
tags/0.2/generate-cache.php (modified) (2 diffs)
-
tags/0.3 (added)
-
tags/0.3/functions.php (added)
-
tags/0.3/generate-cache.php (added)
-
tags/0.3/readme.txt (added)
-
tags/0.3/run1.php (added)
-
tags/0.3/run2.php (added)
-
tags/0.3/screenshot-1.png (added)
-
trunk/functions.php (modified) (1 diff)
-
trunk/generate-cache.php (modified) (7 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/run1.php (modified) (1 diff)
-
trunk/run2.php (modified) (1 diff)
-
trunk/screenshot-1.png (added)
Legend:
- Unmodified
- Added
- Removed
-
generate-cache/tags/0.2/generate-cache.php
r420326 r422897 161 161 function gen_cache_validate_options($input) { 162 162 if( ( trim( $input['gen_cache_time_hr'] ) != "" ) && ( trim( $input['gen_cache_time_min'] ) != "" ) ) { 163 $now = time() + get_option('gmt_offset') * 3600; 163 $offset = get_option('gmt_offset') * 3600; 164 $now = time(); 164 165 $midnight = $now - ( $now%86400 ); 165 166 $converted = strtotime( trim( $input['gen_cache_time_hr'] ) . ":" . trim( $input['gen_cache_time_min'] ) ); 166 if( $converted > $now ) { 167 //$converted = $converted%86400 + $midnight; 168 if( $converted%86400 == 0 ) { 169 $start = $midnight + ( $converted%86400 ) + 86400; 170 } elseif( ( $converted - $offset ) > $now ) { 167 171 $start = $converted; 168 172 } else { 169 173 $start = $midnight + ( $converted%86400 ) + 86400; 170 174 } 171 $start = $start - get_option('gmt_offset') * 3600; 172 //$start = $now; 175 $start = $start - $offset; 173 176 174 177 $timestamp = wp_next_scheduled( 'gen_cache_hook' ); … … 176 179 177 180 if (!wp_next_scheduled('gen_cache_hook')) { 178 wp_schedule_event( $start /* - get_option('gmt_offset') * 3600*/, $input['gen_cache_freq'], 'gen_cache_hook' );181 wp_schedule_event( $start, $input['gen_cache_freq'], 'gen_cache_hook' ); 179 182 } 180 183 } else { -
generate-cache/trunk/functions.php
r420299 r422897 11 11 $asynchronous_call = curl_post_async( $url, $params ); 12 12 } 13 13 function slaap($seconds) { 14 $seconds = abs($seconds); 15 if ($seconds < 1): 16 usleep($seconds*1000000); 17 else: 18 sleep($seconds); 19 endif; 20 } 14 21 function get_data($url) { 15 22 $ch = curl_init(); -
generate-cache/trunk/generate-cache.php
r420326 r422897 4 4 Plugin URI: http://www.denisbuka.ru/generate-cache/ 5 5 Description: When your cache is emptied (say, upon a new post or comment publication), the plugin loops through selected items (posts, categories, tags or pages) and makes sure you have them all freshly cached for quicker access. 6 Version: 0. 26 Version: 0.3 7 7 Author: Denis Buka 8 8 Author URI: http://www.denisbuka.ru … … 39 39 "gen_cache_tags" => "1", 40 40 "gen_cache_pages" => "1", 41 "gen_cache_speed" => "1", 41 42 "gen_cache_dir" => "", 42 "gen_cache_cur_cache_dir" => "",43 43 "gen_cache_final_dir" => "", 44 44 "gen_cache_user_dir" => "", … … 123 123 124 124 <tr> 125 <th scope="row" style="width:270px;"><strong>Caching speed:</strong><br /><em>(interval between subsequent page calls)</em></th> 126 <td> 127 <label><input style="text-align:right;" type="text" size="4" name="gen_cache_options[gen_cache_speed]" value="<?php echo $options['gen_cache_speed']; ?>" /> seconds <em>– <strong>Warning:</strong> setting this to less than a second may impede your server's performance!</em></label> 128 </td> 129 </tr> 130 131 <tr> 125 132 <th scope="row" style="width:270px;"><strong>Schedule cache generation:</strong><br /><em>(you can optionally schedule cache generation to be run periodically even if cache folder size is above limit)</em></th> 126 133 <td> … … 149 156 </p> 150 157 </form> 158 159 <?php 160 if( isset( $_POST['gen_cache_now'] ) ) initCache(); 161 162 $genflag = WP_PLUGIN_DIR . '/generate-cache/generation_running'; 163 if( isset( $_POST['gen_cache_abort'] ) ) unlink( $genflag );; 164 if( file_exists( $genflag ) ) { 165 echo ' <form method="post"> 166 <p class="submit"><strong>Cache generation is now in progress...</strong> 167 <input type="submit" name="gen_cache_abort" value="Abort" /> 168 </p> 169 </form>'; 170 } else { 171 echo ' <form method="post"> 172 <p class="submit">You can start cache generation manually by hitting this button: 173 <input type="submit" name="gen_cache_now" value="Generate cache now!" /> 174 </p> 175 </form>'; 176 } 177 ?> 151 178 152 179 </div> … … 161 188 function gen_cache_validate_options($input) { 162 189 if( ( trim( $input['gen_cache_time_hr'] ) != "" ) && ( trim( $input['gen_cache_time_min'] ) != "" ) ) { 163 $now = time() + get_option('gmt_offset') * 3600; 190 $offset = get_option('gmt_offset') * 3600; 191 $now = time(); 164 192 $midnight = $now - ( $now%86400 ); 165 193 $converted = strtotime( trim( $input['gen_cache_time_hr'] ) . ":" . trim( $input['gen_cache_time_min'] ) ); 194 $converted = ($converted - $offset)%86400 + $midnight; 166 195 if( $converted > $now ) { 167 196 $start = $converted; … … 169 198 $start = $midnight + ( $converted%86400 ) + 86400; 170 199 } 171 $start = $start - get_option('gmt_offset') * 3600;172 //$start = $now;173 200 174 201 $timestamp = wp_next_scheduled( 'gen_cache_hook' ); … … 176 203 177 204 if (!wp_next_scheduled('gen_cache_hook')) { 178 wp_schedule_event( $start /* - get_option('gmt_offset') * 3600*/, $input['gen_cache_freq'], 'gen_cache_hook' );205 wp_schedule_event( $start, $input['gen_cache_freq'], 'gen_cache_hook' ); 179 206 } 180 207 } else { -
generate-cache/trunk/readme.txt
r420299 r422897 5 5 Requires at least: 3.2 6 6 Tested up to: 3.2 7 Stable tag: 0. 27 Stable tag: 0.3 8 8 9 9 Makes sure your entire website is fully cached at all times. Can be used when performing website maintenance/construction. … … 29 29 * Tries to guess your cache folder location, or you can specify it manually. 30 30 * Choose for which blog items (posts, categories, tags, pages) cache should be regenerated. 31 * Set cache generation interval. 31 32 * Schedule automatic cache generation to be run at a specific time even if cache folder size is not below limit (in case your caching plugin doesn't emply cache upon content changes). 33 * Manually start/abort cache generation from the admin page. 32 34 33 35 … … 54 56 == Screenshots == 55 57 58 1. Settings admin page 59 56 60 == Changelog == 61 62 = 0.3 = 63 * Minor code fixes 64 * Added manual cache generate/abort 65 66 = 0.2 = 67 * Added scheduling feature 57 68 58 69 = 0.1 = 59 70 * Initial release 60 61 = 0.2 =62 * Added scheduling feature -
generate-cache/trunk/run1.php
r418947 r422897 12 12 13 13 $links = getCacheLinks(); 14 $options = get_option('gen_cache_options'); 15 14 16 15 17 $contents = get_data( $links[$count] ); 16 sl eep(1);18 slaap( $options['gen_cache_speed'] ); 17 19 unset( $contents ); 18 20 -
generate-cache/trunk/run2.php
r418947 r422897 12 12 13 13 $links = getCacheLinks(); 14 $options = get_option('gen_cache_options'); 15 14 16 15 17 $contents = get_data( $links[$count] ); 16 sl eep(1);18 slaap( $options['gen_cache_speed'] ); 17 19 unset( $contents ); 18 20
Note: See TracChangeset
for help on using the changeset viewer.