Changeset 1190839
- Timestamp:
- 07/01/2015 02:37:31 PM (11 years ago)
- Location:
- nginx-helper/trunk
- Files:
-
- 22 added
- 7 edited
-
. (modified) (1 prop)
-
admin/assets/nginx.js (modified) (1 diff)
-
admin/assets/style.css (modified) (1 diff)
-
admin/lib/nginx-general.php (modified) (10 diffs)
-
admin/lib/nginx-sidebar.php (modified) (1 diff)
-
includes (added)
-
includes/predis.php (added)
-
includes/redis-delete.php (added)
-
nginx-helper.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
redis-purger.php (added)
-
tests (added)
-
tests/functional (added)
-
tests/functional/custom-commands (added)
-
tests/functional/custom-commands/enableAllPurgeCheckbox.js (added)
-
tests/functional/custom-commands/goToAddNewPage.js (added)
-
tests/functional/custom-commands/goToAddNewPost.js (added)
-
tests/functional/custom-commands/nginxSettings.js (added)
-
tests/functional/custom-commands/wplogin.js (added)
-
tests/functional/custom-commands/wplogout.js (added)
-
tests/functional/nightwatch.json (added)
-
tests/functional/package.json (added)
-
tests/functional/res (added)
-
tests/functional/res/constants.js (added)
-
tests/functional/src (added)
-
tests/functional/src/purge-method-get-request-page-test.js (added)
-
tests/functional/src/purge-method-get-request-post-test.js (added)
-
tests/functional/src/purge-method-unlink-files-page-test.js (added)
-
tests/functional/src/purge-method-unlink-files-post-test.js (added)
Legend:
- Unmodified
- Added
- Removed
-
nginx-helper/trunk
- Property svn:ignore
-
nginx-helper/trunk/admin/assets/nginx.js
r831565 r1190839 1 jQuery(document).ready(function() { 2 var news_section = jQuery('#latest_news'); 3 if (news_section.length > 0) { 4 jQuery.get(news_url, function(data) { 5 news_section.find('.inside').html(data); 6 }); 7 } 8 9 /** 10 * Show OR Hide options on option checkbox 11 * @param {type} selector Selector of Checkbox and PostBox 12 */ 13 function nginx_show_option( selector ) { 14 jQuery( '#'+selector ).on( 'change', function (){ 15 if ( jQuery(this).is( ':checked' ) ) { 16 jQuery( '.'+selector ).show(); 17 } else { 18 jQuery( '.'+selector ).hide(); 19 } 20 } ); 21 } 22 /* Function call with parameter */ 23 nginx_show_option( 'enable_purge' ); 24 nginx_show_option( 'enable_map' ); 25 nginx_show_option( 'enable_log' ); 26 }); 1 jQuery( document ).ready( function() { 2 var news_section = jQuery( '#latest_news' ); 3 if ( news_section.length > 0 ) { 4 jQuery.get( news_url, function( data ) { 5 news_section.find( '.inside' ).html( data ); 6 } ); 7 } 8 9 jQuery( "form#purgeall a" ).click( function( e ) { 10 if ( confirm( "Purging entire cache is not recommended. Would you like to continue ?" ) == true ) { 11 // continue submitting form 12 } else { 13 e.preventDefault(); 14 } 15 16 } ); 17 18 /** 19 * Show OR Hide options on option checkbox 20 * @param {type} selector Selector of Checkbox and PostBox 21 */ 22 function nginx_show_option( selector ) { 23 jQuery( '#' + selector ).on( 'change', function() { 24 if ( jQuery( this ).is( ':checked' ) ) { 25 jQuery( '.' + selector ).show(); 26 if ( selector == "cache_method_redis" ) { 27 jQuery( '.cache_method_fastcgi' ).hide(); 28 } else if ( selector == "cache_method_fastcgi" ) { 29 jQuery( '.cache_method_redis' ).hide(); 30 } 31 } else { 32 jQuery( '.' + selector ).hide(); 33 } 34 } ); 35 } 36 /* Function call with parameter */ 37 nginx_show_option( 'cache_method_fastcgi' ); 38 nginx_show_option( 'cache_method_redis' ); 39 nginx_show_option( 'enable_map' ); 40 nginx_show_option( 'enable_log' ); 41 nginx_show_option( 'enable_purge' ); 42 } ); -
nginx-helper/trunk/admin/assets/style.css
r831565 r1190839 10 10 .wrap h2.rt_option_title { background: url(nginx-icon-32x32.png) 0 6px no-repeat rgba(0, 0, 0, 0); padding-left: 40px; } 11 11 #poststuff h2 { padding: 0 0 0 10px; margin-top: 0; } 12 form#purgeall .button-primary { box-shadow: inset 0 -2px rgba(0, 0, 0, 0.14);padding: 15px 30px;font-size: 1rem;border: 0;border-radius: 5px;color: #FFF;background: #DD3D36; height: auto; }12 form#purgeall .button-primary { margin-bottom: 20px; box-shadow: inset 0 -2px rgba(0, 0, 0, 0.14);padding: 15px 30px;font-size: 1rem;border: 0;border-radius: 5px;color: #FFF;background: #DD3D36; height: auto; } 13 13 form#purgeall .button-primary:hover, form#purgeall .button-primary:focus { background: #d52c24; } 14 14 .nh-aligncenter { display: block; text-align: center; line-height: 2; } -
nginx-helper/trunk/admin/lib/nginx-general.php
r1189553 r1190839 3 3 namespace rtCamp\WP\Nginx { 4 4 5 function nginx_general_options_page() { 5 function nginx_general_options_page() 6 { 6 7 global $rt_wp_nginx_helper, $rt_wp_nginx_purger; 7 8 … … 10 11 $error_log_filesize = false; 11 12 $rt_wp_nginx_helper->options['enable_purge'] = (isset( $_POST['enable_purge'] ) and ( $_POST['enable_purge'] == 1) ) ? 1 : 0; 13 $rt_wp_nginx_helper->options['cache_method'] = (isset( $_POST['cache_method'] ) ) ? $_POST['cache_method'] : 'enable_fastcgi'; 12 14 $rt_wp_nginx_helper->options['enable_map'] = (isset( $_POST['enable_map'] ) and ( $_POST['enable_map'] == 1) ) ? 1 : 0; 13 15 $rt_wp_nginx_helper->options['enable_log'] = (isset( $_POST['enable_log'] ) and ( $_POST['enable_log'] == 1) ) ? 1 : 0; … … 52 54 $rt_wp_nginx_helper->options['purge_method'] = ( isset( $_POST['purge_method'] ) ) ? $_POST['purge_method'] : 'get_request'; 53 55 } 56 if ( isset( $_POST['cache_method'] ) && $_POST['cache_method'] = "enable_redis" ) { 57 $rt_wp_nginx_helper->options['redis_hostname'] = ( isset( $_POST['redis_hostname'] ) ) ? $_POST['redis_hostname'] : '127.0.0.1'; 58 $rt_wp_nginx_helper->options['redis_port'] = ( isset( $_POST['redis_port'] ) ) ? $_POST['redis_port'] : '6379'; 59 $rt_wp_nginx_helper->options['redis_prefix'] = ( isset( $_POST['redis_prefix'] ) ) ? $_POST['redis_prefix'] : 'nginx-cache:'; 60 } 54 61 update_site_option( 'rt_wp_nginx_helper_options', $rt_wp_nginx_helper->options ); 55 62 $update = 1; … … 57 64 $rt_wp_nginx_helper->options = get_site_option( 'rt_wp_nginx_helper_options' ); 58 65 66 // set default purge method to fastcgi 67 if ( empty( $rt_wp_nginx_helper->options['cache_method'] ) ) { 68 $rt_wp_nginx_helper->options['cache_method'] = "enable_fastcgi"; 69 } 59 70 /** 60 71 * Show Update Message … … 78 89 } 79 90 ?> 80 < div class="postbox">81 < h3 class="hndle">82 < span><?php _e( 'Purge Cache', 'nginx-helper' ); ?></span>83 </h3>84 <form id="purgeall" action="" method="post" class="clearfix">91 <form id="post_form" method="post" action="#" name="smart_http_expire_form" class="clearfix"> 92 <div class="postbox"> 93 <h3 class="hndle"> 94 <span><?php _e( 'Purging Options', 'nginx-helper' ); ?></span> 95 </h3> 85 96 <div class="inside"> 86 <?php $purge_url = add_query_arg( array( 'nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all' ) ); ?>87 <?php $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' ); ?>88 97 <table class="form-table"> 89 98 <tr valign="top"> 90 <th><?php _e( 'Purge All Cache', 'nginx-helper' ); ?></th>91 99 <td> 92 <a href="<?php echo $nonced_url; ?>" class="button-primary"><?php _e( 'Purge Cache', 'nginx-helper' ); ?></a> 100 <input type="checkbox" value="1" id="enable_purge" name="enable_purge"<?php checked( $rt_wp_nginx_helper->options['enable_purge'], 1 ); ?> /> 101 <label for="enable_purge"><?php _e( 'Enable Purge', 'nginx-helper' ); ?></label> 93 102 </td> 94 103 </tr> 95 104 </table> 96 </div> 97 </form> 98 </div> <!-- End of .postbox --> 99 <form id="post_form" method="post" action="#" name="smart_http_expire_form" class="clearfix"> 100 <div class="postbox"> 105 </div> <!-- End of .inside --> 106 </div> 107 <div class="postbox enable_purge"<?php echo ( $rt_wp_nginx_helper->options['enable_purge'] == false ) ? ' style="display: none;"' : ''; ?>> 101 108 <h3 class="hndle"> 102 <span><?php _e( ' Plugin Options', 'nginx-helper' ); ?></span>109 <span><?php _e( 'Caching Method', 'nginx-helper' ); ?></span> 103 110 </h3> 104 <?php if ( !(!is_network_admin() && is_multisite() ) ) { ?>111 <?php if ( !(!is_network_admin() && is_multisite() ) ) { ?> 105 112 <div class="inside"> 106 113 <input type="hidden" name="is_submit" value="1" /> … … 108 115 <tr valign="top"> 109 116 <td> 110 <input type=" checkbox" value="1" id="enable_purge" name="enable_purge" <?php checked( $rt_wp_nginx_helper->options['enable_purge'], 1); ?> />111 <label for=" enable_purge">112 <?php printf( __( 'Enable Cache Purge (<a target="_blank" href="%s" title="External settings for nginx">requires external settings for nginx</a>)', 'nginx-helper' ), $nginx_setting_link ); ?>117 <input type="radio" value="enable_fastcgi" id="cache_method_fastcgi" name="cache_method" <?php checked( $rt_wp_nginx_helper->options['cache_method'], "enable_fastcgi" ); ?> /> 118 <label for="cache_method_fastcgi"> 119 <?php printf( __( 'nginx Fastcgi cache (<a target="_blank" href="%s" title="External settings for nginx">requires external settings for nginx</a>)', 'nginx-helper' ), $nginx_setting_link ); ?> 113 120 </label> 114 121 </td> 115 122 </tr> 116 <?php if ( is_network_admin() ) { ?> 123 <tr valign="top"> 124 <td> 125 <input type="radio" value="enable_redis" id="cache_method_redis" name="cache_method" <?php checked( $rt_wp_nginx_helper->options['cache_method'], "enable_redis" ); ?> /> 126 <label for="cache_method_redis"> 127 <?php printf( __( 'Redis cache', 'nginx-helper' ) ); ?> 128 </label> 129 </td> 130 </tr> 131 </table> 132 </div> <!-- End of .inside --> 133 </div> 134 <div class="enable_purge"> 135 <div class="postbox cache_method_fastcgi"<?php echo ( $rt_wp_nginx_helper->options['enable_purge'] == true && $rt_wp_nginx_helper->options['cache_method'] == "enable_fastcgi" ) ? '' : ' style="display: none;"'; ?>> 136 <h3 class="hndle"> 137 <span><?php _e( 'Purge Method', 'nginx-helper' ); ?></span> 138 </h3> 139 <div class="inside"> 140 <table class="form-table rtnginx-table"> 141 <tr valign="top"> 142 <td> 143 <fieldset> 144 <legend class="screen-reader-text"> 145 <span> <?php _e( 'when a post/page/custom post is published.', 'nginx-helper' ); ?></span> 146 </legend> 147 <label for="purge_method_get_request"> 148 <input type="radio" value="get_request" id="purge_method_get_request" name="purge_method"<?php checked( isset( $rt_wp_nginx_helper->options['purge_method'] ) ? $rt_wp_nginx_helper->options['purge_method'] : 'get_request', 'get_request' ); ?>> 149 <?php _e( 'Using a GET request to <strong>PURGE/url</strong> (Default option)', 'nginx-helper' ); ?><br /> 150 <small><?php _e( 'Uses the <strong><a href="https://github.com/FRiCKLE/ngx_cache_purge">ngx_cache_purge</a></strong> module. ', 'nginx-helper' ); ?></small> 151 </label><br /> 152 <label for="purge_method_unlink_files"> 153 <input type="radio" value="unlink_files" id="purge_method_unlink_files" name="purge_method"<?php checked( isset( $rt_wp_nginx_helper->options['purge_method'] ) ? $rt_wp_nginx_helper->options['purge_method'] : '', 'unlink_files' ); ?>> 154 <?php _e( 'Delete local server cache files', 'nginx-helper' ); ?><br /> 155 <small><?php _e( 'Checks for matching cache file in <strong>RT_WP_NGINX_HELPER_CACHE_PATH</strong>. Does not require any other modules. Requires that the cache be stored on the same server as WordPress. You must also be using the default nginx cache options (levels=1:2) and (fastcgi_cache_key "$scheme$request_method$host$request_uri"). ', 'nginx-helper' ); ?></small> 156 157 </label><br /> 158 </fieldset> 159 </td> 160 </tr> 161 </table> 162 </div> <!-- End of .inside --> 163 </div> 164 <div class="postbox cache_method_redis"<?php echo ( $rt_wp_nginx_helper->options['enable_purge'] == true && $rt_wp_nginx_helper->options['cache_method'] == "enable_redis" ) ? '' : ' style="display: none;"'; ?>> 165 <h3 class="hndle"> 166 <span><?php _e( 'Redis Settings', 'nginx-helper' ); ?></span> 167 </h3> 168 <div class="inside"> 169 <table class="form-table rtnginx-table"> 170 <?php 171 $redis_hostname = ( empty( $rt_wp_nginx_helper->options['redis_hostname'] ) ) ? '127.0.0.1' : $rt_wp_nginx_helper->options['redis_hostname']; 172 $redis_port = ( empty( $rt_wp_nginx_helper->options['redis_port'] ) ) ? '6379' : $rt_wp_nginx_helper->options['redis_port']; 173 $redis_prefix = ( empty( $rt_wp_nginx_helper->options['redis_prefix'] ) ) ? 'nginx-cache:' : $rt_wp_nginx_helper->options['redis_prefix']; 174 ?> 175 <tr> 176 <th><label for="redis_hostname"><?php _e( 'Hostname', 'nginx-helper' ); ?></label></th> 177 <td> 178 <input id="redis_hostname" class="medium-text" type="text" name="redis_hostname" value="<?php echo $redis_hostname; ?>" /> 179 </td> 180 </tr> 181 <tr> 182 <th><label for="redis_port"><?php _e( 'Port', 'nginx-helper' ); ?></label></th> 183 <td> 184 <input id="redis_port" class="medium-text" type="text" name="redis_port" value="<?php echo $redis_port; ?>" /> 185 </td> 186 </tr> 187 <tr> 188 <th><label for="redis_prefix"><?php _e( 'Prefix', 'nginx-helper' ); ?></label></th> 189 <td> 190 <input id="redis_prefix" class="medium-text" type="text" name="redis_prefix" value="<?php echo $redis_prefix; ?>" /> 191 </td> 192 </tr> 193 </table> 194 </div> <!-- End of .inside --> 195 </div> 196 </div> 197 <div class="postbox enable_purge"<?php echo ( $rt_wp_nginx_helper->options['enable_purge'] == false ) ? ' style="display: none;"' : ''; ?>> 198 <h3 class="hndle"> 199 <span><?php _e( 'Purging Conditions', 'nginx-helper' ); ?></span> 200 </h3> 201 <div class="inside"> 202 203 <table class="form-table rtnginx-table"> 204 <tr valign="top"> 205 <th scope="row"><h4><?php _e( 'Purge Homepage:', 'nginx-helper' ); ?></h4></th> 206 <td> 207 <fieldset> 208 <legend class="screen-reader-text"> 209 <span> <?php _e( 'when a post/page/custom post is modified or added.', 'nginx-helper' ); ?></span> 210 </legend> 211 <label for="purge_homepage_on_edit"> 212 <input type="checkbox" value="1" id="purge_homepage_on_edit" name="purge_homepage_on_edit"<?php checked( $rt_wp_nginx_helper->options['purge_homepage_on_edit'], 1 ); ?> /> 213 <?php _e( 'when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper' ); ?> 214 </label><br /> 215 </fieldset> 216 <fieldset> 217 <legend class="screen-reader-text"> 218 <span> <?php _e( 'when an existing post/page/custom post is modified.', 'nginx-helper' ); ?></span> 219 </legend> 220 <label for="purge_homepage_on_del"> 221 <input type="checkbox" value="1" id="purge_homepage_on_del" name="purge_homepage_on_del"<?php checked( $rt_wp_nginx_helper->options['purge_homepage_on_del'], 1 ); ?> /> 222 <?php _e( 'when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper' ); ?></label><br /> 223 </fieldset> 224 </td> 225 </tr> 226 </table> 227 <table class="form-table rtnginx-table"> 228 <tr valign="top"> 229 <th scope="row"> 230 <h4><?php _e( 'Purge Post/Page/Custom Post Type:', 'nginx-helper' ); ?></h4> 231 </th> 232 <td> 233 <fieldset> 234 <legend class="screen-reader-text"> 235 <span> <?php _e( 'when a post/page/custom post is published.', 'nginx-helper' ); ?></span> 236 </legend> 237 <label for="purge_page_on_mod"> 238 <input type="checkbox" value="1" id="purge_page_on_mod" name="purge_page_on_mod"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_mod'], 1 ); ?>> 239 <?php _e( 'when a <strong>post</strong> is <strong>published</strong>.', 'nginx-helper' ); ?> 240 </label><br /> 241 </fieldset> 242 <fieldset> 243 <legend class="screen-reader-text"> 244 <span> <?php _e( 'when a comment is approved/published.', 'nginx-helper' ); ?></span> 245 </legend> 246 <label for="purge_page_on_new_comment"> 247 <input type="checkbox" value="1" id="purge_page_on_new_comment" name="purge_page_on_new_comment"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_new_comment'], 1 ); ?>> 248 <?php _e( 'when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper' ); ?> 249 </label><br /> 250 </fieldset> 251 <fieldset> 252 <legend class="screen-reader-text"> 253 <span> <?php _e( 'when a comment is unapproved/deleted.', 'nginx-helper' ); ?></span> 254 </legend> 255 <label for="purge_page_on_deleted_comment"> 256 <input type="checkbox" value="1" id="purge_page_on_deleted_comment" name="purge_page_on_deleted_comment"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_deleted_comment'], 1 ); ?>> 257 <?php _e( 'when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper' ); ?> 258 </label><br /> 259 </fieldset> 260 </td> 261 </tr> 262 </table> 263 <table class="form-table rtnginx-table"> 264 <tr valign="top"> 265 <th scope="row"> 266 <h4><?php _e( 'Purge Archives:', 'nginx-helper' ); ?></h4> 267 <small><?php _e( '(date, category, tag, author, custom taxonomies)', 'nginx-helper' ); ?></small> 268 </th> 269 <td> 270 <fieldset> 271 <legend class="screen-reader-text"> 272 <span> <?php _e( 'when an post/page/custom post is modified or added.</span>', 'nginx-helper' ); ?> 273 </legend> 274 <label for="purge_archive_on_edit"> 275 <input type="checkbox" value="1" id="purge_archive_on_edit" name="purge_archive_on_edit"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_edit'], 1 ); ?> /> 276 <?php _e( 'when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper' ); ?> 277 </label><br /> 278 </fieldset> 279 <fieldset> 280 <legend class="screen-reader-text"> 281 <span> <?php _e( 'when an existing post/page/custom post is trashed.</span>', 'nginx-helper' ); ?> 282 </legend> 283 <label for="purge_archive_on_del"> 284 <input type="checkbox" value="1" id="purge_archive_on_del" name="purge_archive_on_del"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_del'], 1 ); ?> /> 285 <?php _e( 'when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper' ); ?> 286 </label><br /> 287 </fieldset> 288 <br /> 289 <fieldset> 290 <legend class="screen-reader-text"> 291 <span> <?php _e( 'when a comment is approved/published.</span>', 'nginx-helper' ); ?> 292 </legend> 293 <label for="purge_archive_on_new_comment"> 294 <input type="checkbox" value="1" id="purge_archive_on_new_comment" name="purge_archive_on_new_comment"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_new_comment'], 1 ); ?> /> 295 <?php _e( 'when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper' ); ?> 296 </label><br /> 297 </fieldset> 298 <fieldset> 299 <legend class="screen-reader-text"> 300 <span> <?php _e( 'when a comment is unapproved/deleted.</span>', 'nginx-helper' ); ?> 301 </legend> 302 <label for="purge_archive_on_deleted_comment"> 303 <input type="checkbox" value="1" id="purge_archive_on_deleted_comment" name="purge_archive_on_deleted_comment"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_deleted_comment'], 1 ); ?> /> 304 <?php _e( 'when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper' ); ?> 305 </label><br /> 306 </fieldset> 307 308 </td> 309 </tr> 310 </table> 311 </div> <!-- End of .inside --> 312 </div> 313 <div class="postbox"> 314 <h3 class="hndle"> 315 <span><?php _e( 'Debug Options', 'nginx-helper' ); ?></span> 316 </h3> 317 <div class="inside"> 318 <input type="hidden" name="is_submit" value="1" /> 319 <table class="form-table"> 320 <?php if ( is_network_admin() ) { ?> 117 321 <tr valign="top"> 118 322 <td> … … 121 325 </td> 122 326 </tr> 123 <?php } ?>327 <?php } ?> 124 328 <tr valign="top"> 125 329 <td> … … 137 341 </div> <!-- End of .inside --> 138 342 </div> 139 140 <div class="postbox enable_purge"<?php echo ( $rt_wp_nginx_helper->options['enable_purge'] == false ) ? ' style="display: none;"' : ''; ?>> 141 <h3 class="hndle"> 142 <span><?php _e( 'Purging Options', 'nginx-helper' ); ?></span> 143 </h3> 144 <div class="inside"> 145 146 <table class="form-table rtnginx-table"> 147 <tr valign="top"> 148 <th scope="row"><h4><?php _e( 'Purge Homepage:', 'nginx-helper' ); ?></h4></th> 149 <td> 150 <fieldset> 151 <legend class="screen-reader-text"> 152 <span> <?php _e( 'when a post/page/custom post is modified or added.', 'nginx-helper' ); ?></span> 153 </legend> 154 <label for="purge_homepage_on_edit"> 155 <input type="checkbox" value="1" id="purge_homepage_on_edit" name="purge_homepage_on_edit"<?php checked( $rt_wp_nginx_helper->options['purge_homepage_on_edit'], 1 ); ?> /> 156 <?php _e( 'when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper' ); ?> 157 </label><br /> 158 </fieldset> 159 <fieldset> 160 <legend class="screen-reader-text"> 161 <span> <?php _e( 'when an existing post/page/custom post is modified.', 'nginx-helper' ); ?></span> 162 </legend> 163 <label for="purge_homepage_on_del"> 164 <input type="checkbox" value="1" id="purge_homepage_on_del" name="purge_homepage_on_del"<?php checked( $rt_wp_nginx_helper->options['purge_homepage_on_del'], 1 ); ?> /> 165 <?php _e( 'when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper' ); ?></label><br /> 166 </fieldset> 167 </td> 168 </tr> 169 </table> 170 <table class="form-table rtnginx-table"> 171 <tr valign="top"> 172 <th scope="row"> 173 <h4><?php _e( 'Purge Post/Page/Custom Post Type:', 'nginx-helper' ); ?></h4> 174 </th> 175 <td> 176 <fieldset> 177 <legend class="screen-reader-text"> 178 <span> <?php _e( 'when a post/page/custom post is published.', 'nginx-helper' ); ?></span> 179 </legend> 180 <label for="purge_page_on_mod"> 181 <input type="checkbox" value="1" id="purge_page_on_mod" name="purge_page_on_mod"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_mod'], 1 ); ?>> 182 <?php _e( 'when a <strong>post</strong> is <strong>published</strong>.', 'nginx-helper' ); ?> 183 </label><br /> 184 </fieldset> 185 <fieldset> 186 <legend class="screen-reader-text"> 187 <span> <?php _e( 'when a comment is approved/published.', 'nginx-helper' ); ?></span> 188 </legend> 189 <label for="purge_page_on_new_comment"> 190 <input type="checkbox" value="1" id="purge_page_on_new_comment" name="purge_page_on_new_comment"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_new_comment'], 1 ); ?>> 191 <?php _e( 'when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper' ); ?> 192 </label><br /> 193 </fieldset> 194 <fieldset> 195 <legend class="screen-reader-text"> 196 <span> <?php _e( 'when a comment is unapproved/deleted.', 'nginx-helper' ); ?></span> 197 </legend> 198 <label for="purge_page_on_deleted_comment"> 199 <input type="checkbox" value="1" id="purge_page_on_deleted_comment" name="purge_page_on_deleted_comment"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_deleted_comment'], 1 ); ?>> 200 <?php _e( 'when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper' ); ?> 201 </label><br /> 202 </fieldset> 203 </td> 204 </tr> 205 </table> 206 <table class="form-table rtnginx-table"> 207 <tr valign="top"> 208 <th scope="row"> 209 <h4><?php _e( 'Purge Archives:', 'nginx-helper' ); ?></h4> 210 <small><?php _e( '(date, category, tag, author, custom taxonomies)', 'nginx-helper' ); ?></small> 211 </th> 212 <td> 213 <fieldset> 214 <legend class="screen-reader-text"> 215 <span> <?php _e( 'when an post/page/custom post is modified or added.</span>', 'nginx-helper' ); ?> 216 </legend> 217 <label for="purge_archive_on_edit"> 218 <input type="checkbox" value="1" id="purge_archive_on_edit" name="purge_archive_on_edit"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_edit'], 1 ); ?> /> 219 <?php _e( 'when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper' ); ?> 220 </label><br /> 221 </fieldset> 222 <fieldset> 223 <legend class="screen-reader-text"> 224 <span> <?php _e( 'when an existing post/page/custom post is trashed.</span>', 'nginx-helper' ); ?> 225 </legend> 226 <label for="purge_archive_on_del"> 227 <input type="checkbox" value="1" id="purge_archive_on_del" name="purge_archive_on_del"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_del'], 1 ); ?> /> 228 <?php _e( 'when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper' ); ?> 229 </label><br /> 230 </fieldset> 231 <br /> 232 <fieldset> 233 <legend class="screen-reader-text"> 234 <span> <?php _e( 'when a comment is approved/published.</span>', 'nginx-helper' ); ?> 235 </legend> 236 <label for="purge_archive_on_new_comment"> 237 <input type="checkbox" value="1" id="purge_archive_on_new_comment" name="purge_archive_on_new_comment"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_new_comment'], 1 ); ?> /> 238 <?php _e( 'when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper' ); ?> 239 </label><br /> 240 </fieldset> 241 <fieldset> 242 <legend class="screen-reader-text"> 243 <span> <?php _e( 'when a comment is unapproved/deleted.</span>', 'nginx-helper' ); ?> 244 </legend> 245 <label for="purge_archive_on_deleted_comment"> 246 <input type="checkbox" value="1" id="purge_archive_on_deleted_comment" name="purge_archive_on_deleted_comment"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_deleted_comment'], 1 ); ?> /> 247 <?php _e( 'when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper' ); ?> 248 </label><br /> 249 </fieldset> 250 251 </td> 252 </tr> 253 </table> 254 <table class="form-table rtnginx-table"> 255 <tr valign="top"> 256 <th scope="row"> 257 <h4><?php _e( 'Purge Method:', 'nginx-helper' ); ?></h4> 258 </th> 259 <td> 260 <fieldset> 261 <legend class="screen-reader-text"> 262 <span> <?php _e( 'when a post/page/custom post is published.', 'nginx-helper' ); ?></span> 263 </legend> 264 <label for="purge_method_get_request"> 265 <input type="radio" value="get_request" id="purge_method_get_request" name="purge_method"<?php checked( isset( $rt_wp_nginx_helper->options['purge_method'] ) ? $rt_wp_nginx_helper->options['purge_method'] : 'get_request', 'get_request' ); ?>> 266 <?php _e( 'Using a GET request to <strong>PURGE/url</strong> (Default option)', 'nginx-helper' ); ?><br /> 267 <small><?php _e( 'Uses the <strong><a href="https://github.com/FRiCKLE/ngx_cache_purge">ngx_cache_purge</a></strong> module. ', 'nginx-helper' ); ?></small> 268 </label><br /> 269 <label for="purge_method_unlink_files"> 270 <input type="radio" value="unlink_files" id="purge_method_unlink_files" name="purge_method"<?php checked( isset( $rt_wp_nginx_helper->options['purge_method'] ) ? $rt_wp_nginx_helper->options['purge_method'] : '', 'unlink_files' ); ?>> 271 <?php _e( 'Delete local server cache files', 'nginx-helper' ); ?><br /> 272 <small><?php _e( 'Checks for matching cache file in <strong>RT_WP_NGINX_HELPER_CACHE_PATH</strong>. Does not require any other modules. Requires that the cache be stored on the same server as WordPress. You must also be using the default nginx cache options (levels=1:2) and (fastcgi_cache_key "$scheme$request_method$host$request_uri"). ', 'nginx-helper' ); ?></small> 273 274 </label><br /> 275 </fieldset> 276 </td> 277 </tr> 278 </table> 279 </div> <!-- End of .inside --> 280 </div><?php 343 <?php 281 344 } // End of if ( !( !is_network_admin() && is_multisite() ) ) 282 345 … … 308 371 </div> <!-- End of .inside --> 309 372 </div> 310 <?php } ?>373 <?php } ?> 311 374 312 375 <div class="postbox enable_log"<?php echo ( $rt_wp_nginx_helper->options['enable_log'] == false ) ? ' style="display: none;"' : ''; ?>> … … 358 421 <th><label for="log_filesize"><?php _e( 'Max log file size', 'nginx-helper' ); ?></label></th> 359 422 <td> 360 <input id="log_filesize" class="small-text" type="text" name="log_filesize" value="<?php echo $rt_wp_nginx_helper->options['log_filesize'] ?>" /> <?php _e( 'Mb', 'nginx-helper' ); 361 if ( $error_log_filesize ) { 362 ?> 423 <input id="log_filesize" class="small-text" type="text" name="log_filesize" value="<?php echo $rt_wp_nginx_helper->options['log_filesize'] ?>" /> <?php 424 _e( 'Mb', 'nginx-helper' ); 425 if ( $error_log_filesize ) { 426 ?> 363 427 <p class="error fade" style="display: block;"><?php echo $error_log_filesize; ?></p><?php } 364 ?>428 ?> 365 429 </td> 366 430 </tr> -
nginx-helper/trunk/admin/lib/nginx-sidebar.php
r831565 r1190839 3 3 namespace rtCamp\WP\Nginx { 4 4 5 function default_admin_sidebar() { ?> 6 <div class="postbox" id="support"> 7 <h3 class="hndle"> 8 <span><?php _e( 'Need Help?', 'nginx-helper' ); ?></span> 9 </h3> 10 <div class="inside"> 11 <p><?php printf( __( 'Please use our <a href="%s">free support forum</a>.', 'nginx-helper' ), 'http://rtcamp.com/support/forum/wordpress-nginx/' ); ?></p> 12 </div> 13 </div> 5 function default_admin_sidebar() 6 { 7 ?> 8 <?php $purge_url = add_query_arg( array( 'nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all' ) ); ?> 9 <?php $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' ); ?> 10 <form id="purgeall" action="" method="post" class="clearfix"> 11 <a href="<?php echo $nonced_url; ?>" class="button-primary"><?php _e( 'Purge Entire Cache', 'nginx-helper' ); ?></a> 12 </form> 13 <div class="postbox" id="support"> 14 <h3 class="hndle"> 15 <span><?php _e( 'Need Help?', 'nginx-helper' ); ?></span> 16 </h3> 17 <div class="inside"> 18 <p><?php printf( __( 'Please use our <a href="%s">free support forum</a>.', 'nginx-helper' ), 'http://rtcamp.com/support/forum/wordpress-nginx/' ); ?></p> 19 </div> 20 </div> 14 21 15 <div class="postbox" id="social">16 <h3 class="hndle">17 <span><?php _e( 'Getting Social is Good', 'nginx-helper' ); ?></span>18 </h3>19 <div style="text-align:center;" class="inside">20 <a class="nginx-helper-facebook" title="<?php _e( 'Become a fan on Facebook', 'nginx-helper' ); ?>" target="_blank" href="http://www.facebook.com/rtCamp.solutions/"></a>21 <a class="nginx-helper-twitter" title="<?php _e( 'Follow us on Twitter', 'nginx-helper' ); ?>" target="_blank" href="https://twitter.com/rtcamp/"></a>22 <a class="nginx-helper-gplus" title="<?php _e( 'Add to Circle', 'nginx-helper' ); ?>" target="_blank" href="https://plus.google.com/110214156830549460974/posts"></a>23 <a class="nginx-helper-rss" title="<?php _e( 'Subscribe to our feeds', 'nginx-helper' ); ?>" target="_blank" href="http://feeds.feedburner.com/rtcamp/"></a>24 </div>25 </div>22 <div class="postbox" id="social"> 23 <h3 class="hndle"> 24 <span><?php _e( 'Getting Social is Good', 'nginx-helper' ); ?></span> 25 </h3> 26 <div style="text-align:center;" class="inside"> 27 <a class="nginx-helper-facebook" title="<?php _e( 'Become a fan on Facebook', 'nginx-helper' ); ?>" target="_blank" href="http://www.facebook.com/rtCamp.solutions/"></a> 28 <a class="nginx-helper-twitter" title="<?php _e( 'Follow us on Twitter', 'nginx-helper' ); ?>" target="_blank" href="https://twitter.com/rtcamp/"></a> 29 <a class="nginx-helper-gplus" title="<?php _e( 'Add to Circle', 'nginx-helper' ); ?>" target="_blank" href="https://plus.google.com/110214156830549460974/posts"></a> 30 <a class="nginx-helper-rss" title="<?php _e( 'Subscribe to our feeds', 'nginx-helper' ); ?>" target="_blank" href="http://feeds.feedburner.com/rtcamp/"></a> 31 </div> 32 </div> 26 33 27 <div class="postbox" id="useful-links">28 <h3 class="hndle">29 <span><?php _e( 'Useful Links', 'nginx-helper' ); ?></span>30 </h3>31 <div class="inside">32 <ul role="list">33 <li role="listitem">34 <a href="https://rtcamp.com/wordpress-nginx/" title="<?php _e( 'WordPress-Nginx Solutions', 'nginx-helper' ); ?>"><?php _e( 'WordPress-Nginx Solutions', 'nginx-helper' ); ?></a>35 </li>36 <li role="listitem">37 <a href="https://rtcamp.com/services/wordPress-themes-design-development/" title="<?php _e( 'WordPress Theme Devleopment', 'nginx-helper' ); ?>"><?php _e( 'WordPress Theme Devleopment', 'nginx-helper' ); ?></a>38 </li>39 <li role="listitem">40 <a href="http://rtcamp.com/services/wordpress-plugins/" title="<?php _e( 'WordPress Plugin Development', 'nginx-helper' ); ?>"><?php _e( 'WordPress Plugin Development', 'nginx-helper' ); ?></a>41 </li>42 <li role="listitem">43 <a href="http://rtcamp.com/services/custom-wordpress-solutions/" title="<?php _e( 'WordPress Consultancy', 'nginx-helper' ); ?>"><?php _e( 'WordPress Consultancy', 'nginx-helper' ); ?></a>44 </li>45 <li role="listitem">46 <a href="https://rtcamp.com/easyengine/" title="<?php _e( 'easyengine (ee)', 'nginx-helper' ); ?>"><?php _e( 'easyengine (ee)', 'nginx-helper' ); ?></a>47 </li>48 </ul>49 </div>50 </div>34 <div class="postbox" id="useful-links"> 35 <h3 class="hndle"> 36 <span><?php _e( 'Useful Links', 'nginx-helper' ); ?></span> 37 </h3> 38 <div class="inside"> 39 <ul role="list"> 40 <li role="listitem"> 41 <a href="https://rtcamp.com/wordpress-nginx/" title="<?php _e( 'WordPress-Nginx Solutions', 'nginx-helper' ); ?>"><?php _e( 'WordPress-Nginx Solutions', 'nginx-helper' ); ?></a> 42 </li> 43 <li role="listitem"> 44 <a href="https://rtcamp.com/services/wordPress-themes-design-development/" title="<?php _e( 'WordPress Theme Devleopment', 'nginx-helper' ); ?>"><?php _e( 'WordPress Theme Devleopment', 'nginx-helper' ); ?></a> 45 </li> 46 <li role="listitem"> 47 <a href="http://rtcamp.com/services/wordpress-plugins/" title="<?php _e( 'WordPress Plugin Development', 'nginx-helper' ); ?>"><?php _e( 'WordPress Plugin Development', 'nginx-helper' ); ?></a> 48 </li> 49 <li role="listitem"> 50 <a href="http://rtcamp.com/services/custom-wordpress-solutions/" title="<?php _e( 'WordPress Consultancy', 'nginx-helper' ); ?>"><?php _e( 'WordPress Consultancy', 'nginx-helper' ); ?></a> 51 </li> 52 <li role="listitem"> 53 <a href="https://rtcamp.com/easyengine/" title="<?php _e( 'easyengine (ee)', 'nginx-helper' ); ?>"><?php _e( 'easyengine (ee)', 'nginx-helper' ); ?></a> 54 </li> 55 </ul> 56 </div> 57 </div> 51 58 52 <div class="postbox" id="latest_news"> 53 <div title="<?php _e( 'Click to toggle', 'nginx-helper' ); ?>" class="handlediv"><br /></div> 54 <h3 class="hndle"><span><?php _e( 'Latest News', 'nginx-helper' ); ?></span></h3> 55 <div class="inside"><img src ="<?php echo admin_url(); ?>/images/wpspin_light.gif" /><?php _e( 'Loading...', 'nginx-helper' ); ?></div> 56 </div><?php 57 } // End of default_admin_sidebar() 59 <div class="postbox" id="latest_news"> 60 <div title="<?php _e( 'Click to toggle', 'nginx-helper' ); ?>" class="handlediv"><br /></div> 61 <h3 class="hndle"><span><?php _e( 'Latest News', 'nginx-helper' ); ?></span></h3> 62 <div class="inside"><img src ="<?php echo admin_url(); ?>/images/wpspin_light.gif" /><?php _e( 'Loading...', 'nginx-helper' ); ?></div> 63 </div><?php 64 } 65 66 // End of default_admin_sidebar() 58 67 } -
nginx-helper/trunk/nginx-helper.php
r1189553 r1190839 4 4 Plugin URI: https://rtcamp.com/nginx-helper/ 5 5 Description: Cleans nginx's fastcgi/proxy cache whenever a post is edited/published. Also does few more things. 6 Version: 1. 8.136 Version: 1.9 7 7 Author: rtCamp 8 8 Author URI: https://rtcamp.com 9 9 Text Domain: nginx-helper 10 10 Requires at least: 3.0 11 Tested up to: 4.2 11 Tested up to: 4.2.2 12 12 */ 13 13 14 14 namespace rtCamp\WP\Nginx { 15 define('rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH', plugin_dir_path(__FILE__)); 16 define('rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_URL', plugin_dir_url(__FILE__)); 17 18 class Helper { 19 20 var $minium_WP = '3.0'; 21 var $options = null; 22 var $plugin_name = 'nginx-helper'; 23 const WP_CLI_COMMAND = 'nginx-helper'; 24 25 function __construct() { 26 27 if (!$this->required_wp_version()) 28 if (!$this->required_php_version()) 29 return; 30 31 // Load Plugin Text Domain 32 add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); 33 34 $this->load_options(); 35 $this->plugin_name = plugin_basename(__FILE__); 36 37 register_activation_hook($this->plugin_name, array(&$this, 'activate')); 38 register_deactivation_hook($this->plugin_name, array(&$this, 'deactivate')); 39 40 add_action( 'init', array( &$this, 'start_helper' ), 15 ); 41 } 42 43 function start_helper() { 44 45 global $rt_wp_nginx_purger; 46 add_action('shutdown', array(&$this, 'add_timestamps'), 99999); 47 add_action('add_init', array(&$this, 'update_map')); 48 49 add_action('publish_post', array(&$rt_wp_nginx_purger, 'purgePost'), 200, 1); 50 add_action('publish_page', array(&$rt_wp_nginx_purger, 'purgePost'), 200, 1); 51 add_action('wp_insert_comment', array(&$rt_wp_nginx_purger, 'purgePostOnComment'), 200, 2); 52 add_action('transition_comment_status', array(&$rt_wp_nginx_purger, 'purgePostOnCommentChange'), 200, 3); 53 54 $args = array('_builtin' => false); 55 $_rt_custom_post_types = get_post_types($args); 56 if (isset($post_types) && !empty($post_types)) { 57 if ($this->options['rt_wp_custom_post_types'] == true) { 58 foreach ($_rt_custom_post_types as $post_type) { 59 add_action('publish_' . trim($post_type), array(&$rt_wp_nginx_purger, 'purgePost'), 200, 1); 60 } 61 } 62 } 63 64 add_action('transition_post_status', array(&$this, 'set_future_post_option_on_future_status'), 20, 3); 65 add_action('delete_post', array(&$this, 'unset_future_post_option_on_delete'), 20, 1); 66 add_action('nm_check_log_file_size_daily', array(&$rt_wp_nginx_purger, 'checkAndTruncateLogFile'), 100, 1); 67 add_action('edit_attachment', array(&$rt_wp_nginx_purger, 'purgeImageOnEdit'), 100, 1); 68 add_action('wpmu_new_blog', array(&$this, 'update_new_blog_options'), 10, 1); 69 add_action('transition_post_status', array(&$rt_wp_nginx_purger, 'purge_on_post_moved_to_trash'), 20, 3); 70 add_action('edit_term', array(&$rt_wp_nginx_purger, 'purge_on_term_taxonomy_edited'), 20, 3); 71 add_action('delete_term', array(&$rt_wp_nginx_purger, 'purge_on_term_taxonomy_edited'), 20, 3); 72 add_action('check_ajax_referer', array(&$rt_wp_nginx_purger, 'purge_on_check_ajax_referer'), 20, 2); 73 add_action('admin_init', array(&$this, 'purge_all')); 74 75 // expose action to allow other plugins to purge the cache 76 add_action('rt_nginx_helper_purge_all', array(&$this, 'true_purge_all')); 77 78 // Load WP-CLI command 79 if ( defined( 'WP_CLI' ) && WP_CLI ) { 80 require_once RT_WP_NGINX_HELPER_PATH . 'wp-cli.php'; 81 \WP_CLI::add_command( self::WP_CLI_COMMAND, 'Nginx_Helper_WP_CLI_Command' ); 82 } 83 } 84 85 function activate() { 86 87 $path = $this->functional_asset_path(); 88 if (!is_dir($path)) { 89 mkdir($path); 90 } 91 include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php'); 92 rt_wp_nginx_helper_install(); 93 } 94 95 function deactivate() { 96 include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php'); 97 rt_wp_nginx_helper_uninstall(); 98 } 99 100 function required_wp_version() { 101 102 global $wp_version; 103 $wp_ok = version_compare($wp_version, $this->minium_WP, '>='); 104 if (($wp_ok == FALSE)) { 105 add_action( 'admin_notices', create_function( '', 'global $rt_wp_nginx_helper; printf (\'<div id="message" class="error"><p><strong>\' . __(\'Sorry, Nginx Helper requires WordPress %s or higher\', "nginx-helper" ) . \'</strong></p></div>\', $rt_wp_nginx_helper->minium_WP );' ) ); 106 add_action( 'network_admin_notices', create_function( '', 'global $rt_wp_nginx_helper; printf (\'<div id="message" class="error"><p><strong>\' . __(\'Sorry, Nginx Helper requires WordPress %s or higher\', "nginx-helper" ) . \'</strong></p></div>\', $rt_wp_nginx_helper->minium_WP );' ) ); 107 return false; 108 } 109 110 return true; 111 } 112 113 function load_options() { 114 $this->options = get_site_option('rt_wp_nginx_helper_options'); 115 } 116 117 function set_future_post_option_on_future_status($new_status, $old_status, $post) { 118 119 global $blog_id, $rt_wp_nginx_purger; 120 if (!$this->options['enable_purge']) { 121 return; 122 } 123 if ($old_status != $new_status && $old_status != 'inherit' && $new_status != 'inherit' && $old_status != 'auto-draft' && $new_status != 'auto-draft' && $new_status != 'publish' && !wp_is_post_revision($post->ID)) { 124 $rt_wp_nginx_purger->log("Purge post on transition post STATUS from " . $old_status . " to " . $new_status); 125 $rt_wp_nginx_purger->purgePost($post->ID); 126 } 127 128 if ($new_status == 'future') { 129 if ($post && $post->post_status == 'future' && ( ( $post->post_type == 'post' || $post->post_type == 'page' ) || ( isset( $this->options['custom_post_types_recognized'] ) && in_array($post->post_type, $this->options['custom_post_types_recognized']) ) )) { 130 $rt_wp_nginx_purger->log("Set/update future_posts option (post id = " . $post->ID . " and blog id = " . $blog_id . ")"); 131 $this->options['future_posts'][$blog_id][$post->ID] = strtotime($post->post_date_gmt) + 60; 132 update_site_option("rt_wp_nginx_helper_global_options", $this->options); 133 } 134 } 135 } 136 137 function unset_future_post_option_on_delete($post_id) { 138 139 global $blog_id, $rt_wp_nginx_purger; 140 if (!$this->options['enable_purge']) { 141 return; 142 } 143 if ($post_id && !wp_is_post_revision($post_id)) { 144 145 if (isset($this->options['future_posts'][$blog_id][$post_id]) && count($this->options['future_posts'][$blog_id][$post_id])) { 146 $rt_wp_nginx_purger->log("Unset future_posts option (post id = " . $post_id . " and blog id = " . $blog_id . ")"); 147 unset($this->options['future_posts'][$blog_id][$post_id]); 148 update_site_option("rt_wp_nginx_helper_global_options", $this->options); 149 150 if (!count($this->options['future_posts'][$blog_id])) { 151 unset($this->options['future_posts'][$blog_id]); 152 update_site_option("rt_wp_nginx_helper_global_options", $this->options); 153 } 154 } 155 } 156 } 157 158 function update_new_blog_options($blog_id) { 159 global $rt_wp_nginx_purger; 160 include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php'); 161 $rt_wp_nginx_purger->log("New site added (id $blog_id)"); 162 $this->update_map(); 163 $rt_wp_nginx_purger->log("New site added to nginx map (id $blog_id)"); 164 $helper_options = rt_wp_nginx_helper_get_options(); 165 update_blog_option($blog_id, "rt_wp_nginx_helper_options", $helper_options); 166 $rt_wp_nginx_purger->log("Default options updated for the new blog (id $blog_id)"); 167 } 168 169 function get_map() { 170 if (!$this->options['enable_map']) { 171 return; 172 } 173 174 if (is_multisite()) { 175 176 global $wpdb; 177 178 $rt_all_blogs = $wpdb->get_results($wpdb->prepare("SELECT blog_id, domain, path FROM " . $wpdb->blogs . " WHERE site_id = %d AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'", $wpdb->siteid)); 179 $wpdb->dmtable = $wpdb->base_prefix . 'domain_mapping'; 180 $rt_domain_map_sites = ''; 181 if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->dmtable}'") == $wpdb->dmtable) { 182 $rt_domain_map_sites = $wpdb->get_results("SELECT blog_id, domain FROM {$wpdb->dmtable} ORDER BY id DESC"); 183 } 184 $rt_nginx_map = ""; 185 $rt_nginx_map_array = array(); 186 187 188 if ($rt_all_blogs) 189 foreach ($rt_all_blogs as $blog) { 190 if (SUBDOMAIN_INSTALL == "yes") { 191 $rt_nginx_map_array[$blog->domain] = $blog->blog_id; 192 } else { 193 if ($blog->blog_id != 1) { 194 $rt_nginx_map_array[$blog->path] = $blog->blog_id; 195 } 196 } 197 } 198 199 if ($rt_domain_map_sites) { 200 foreach ($rt_domain_map_sites as $site) { 201 $rt_nginx_map_array[$site->domain] = $site->blog_id; 202 } 203 } 204 205 foreach ($rt_nginx_map_array as $domain => $domain_id) { 206 $rt_nginx_map .= "\t" . $domain . "\t" . $domain_id . ";\n"; 207 } 208 209 return $rt_nginx_map; 210 } 211 } 212 213 function functional_asset_path() { 214 $dir = wp_upload_dir(); 215 $path = $dir['basedir'] . '/nginx-helper/'; 216 return apply_filters('nginx_asset_path', $path); 217 } 218 219 function functional_asset_url() { 220 $dir = wp_upload_dir(); 221 $url = $dir['baseurl'] . '/nginx-helper/'; 222 return apply_filters('nginx_asset_url', $url); 223 } 224 225 function update_map() { 226 if (is_multisite()) { 227 $rt_nginx_map = $this->get_map(); 228 229 if ($fp = fopen($this->functional_asset_path() . 'map.conf', 'w+')) { 230 fwrite($fp, $rt_nginx_map); 231 fclose($fp); 232 return true; 233 } 234 } 235 } 236 237 function add_timestamps() { 238 if ($this->options['enable_purge'] != 1) 239 return; 240 if ($this->options['enable_stamp'] != 1) 241 return; 242 if (is_admin()) 243 return; 244 foreach (headers_list() as $header) { 245 list($key, $value) = explode(':', $header, 2); 246 if ($key == 'Content-Type' && strpos(trim($value), 'text/html') !== 0) { 247 return; 248 } 249 if ($key == 'Content-Type') 250 break; 251 } 252 253 if (defined('DOING_AJAX') && DOING_AJAX) 254 return; 255 $timestamps = "\n<!--" . 256 "Cached using Nginx-Helper on " . current_time('mysql') . ". " . 257 "It took " . get_num_queries() . " queries executed in " . timer_stop() . " seconds." . 258 "-->\n" . 259 "<!--Visit http://wordpress.org/extend/plugins/nginx-helper/faq/ for more details-->"; 260 echo $timestamps; 261 } 262 263 function show_notice() { 264 echo '<div class="updated"><p>' . __('Purge initiated', 'nginx-helper') . '</p></div>'; 265 } 266 267 function purge_all() { 268 if (!isset($_REQUEST['nginx_helper_action'])) 269 return; 270 271 if (!current_user_can('manage_options')) 272 wp_die('Sorry, you do not have the necessary privileges to edit these options.'); 273 274 $action = $_REQUEST['nginx_helper_action']; 275 276 if ($action == 'done') { 277 add_action('admin_notices', array(&$this, 'show_notice')); 278 add_action('network_admin_notices', array(&$this, 'show_notice')); 279 return; 280 } 281 282 check_admin_referer('nginx_helper-purge_all'); 283 284 switch ($action) { 285 case 'purge': 286 $this->true_purge_all(); 287 break; 288 } 289 wp_redirect( esc_url_raw( add_query_arg( array( 'nginx_helper_action' => 'done' ) ) ) ); 290 } 291 292 function true_purge_all() { 293 global $rt_wp_nginx_purger; 294 $rt_wp_nginx_purger->true_purge_all(); 295 } 296 297 /** 298 * Load the translation file for current language. 299 */ 300 function load_plugin_textdomain() { 301 load_plugin_textdomain( 'nginx-helper', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 302 } 303 } 15 define( 'rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH', plugin_dir_path( __FILE__ ) ); 16 define( 'rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_URL', plugin_dir_url( __FILE__ ) ); 17 18 class Helper { 19 20 var $minium_WP = '3.0'; 21 var $options = null; 22 var $plugin_name = 'nginx-helper'; 23 24 const WP_CLI_COMMAND = 'nginx-helper'; 25 26 function __construct() 27 { 28 29 if ( !$this->required_wp_version() ) 30 if ( !$this->required_php_version() ) 31 return; 32 33 // Load Plugin Text Domain 34 add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); 35 36 $this->load_options(); 37 $this->plugin_name = plugin_basename( __FILE__ ); 38 39 register_activation_hook( $this->plugin_name, array( &$this, 'activate' ) ); 40 register_deactivation_hook( $this->plugin_name, array( &$this, 'deactivate' ) ); 41 42 add_action( 'init', array( &$this, 'start_helper' ), 15 ); 43 } 44 45 function start_helper() 46 { 47 48 global $rt_wp_nginx_purger; 49 add_action( 'shutdown', array( &$this, 'add_timestamps' ), 99999 ); 50 add_action( 'add_init', array( &$this, 'update_map' ) ); 51 52 add_action( 'publish_post', array( &$rt_wp_nginx_purger, 'purgePost' ), 200, 1 ); 53 add_action( 'publish_page', array( &$rt_wp_nginx_purger, 'purgePost' ), 200, 1 ); 54 add_action( 'wp_insert_comment', array( &$rt_wp_nginx_purger, 'purgePostOnComment' ), 200, 2 ); 55 add_action( 'transition_comment_status', array( &$rt_wp_nginx_purger, 'purgePostOnCommentChange' ), 200, 3 ); 56 57 $args = array( '_builtin' => false ); 58 $_rt_custom_post_types = get_post_types( $args ); 59 if ( isset( $post_types ) && !empty( $post_types ) ) { 60 if ( $this->options['rt_wp_custom_post_types'] == true ) { 61 foreach ( $_rt_custom_post_types as $post_type ) { 62 add_action( 'publish_' . trim( $post_type ), array( &$rt_wp_nginx_purger, 'purgePost' ), 200, 1 ); 63 } 64 } 65 } 66 67 add_action( 'transition_post_status', array( &$this, 'set_future_post_option_on_future_status' ), 20, 3 ); 68 add_action( 'delete_post', array( &$this, 'unset_future_post_option_on_delete' ), 20, 1 ); 69 add_action( 'nm_check_log_file_size_daily', array( &$rt_wp_nginx_purger, 'checkAndTruncateLogFile' ), 100, 1 ); 70 add_action( 'edit_attachment', array( &$rt_wp_nginx_purger, 'purgeImageOnEdit' ), 100, 1 ); 71 add_action( 'wpmu_new_blog', array( &$this, 'update_new_blog_options' ), 10, 1 ); 72 add_action( 'transition_post_status', array( &$rt_wp_nginx_purger, 'purge_on_post_moved_to_trash' ), 20, 3 ); 73 add_action( 'edit_term', array( &$rt_wp_nginx_purger, 'purge_on_term_taxonomy_edited' ), 20, 3 ); 74 add_action( 'delete_term', array( &$rt_wp_nginx_purger, 'purge_on_term_taxonomy_edited' ), 20, 3 ); 75 add_action( 'check_ajax_referer', array( &$rt_wp_nginx_purger, 'purge_on_check_ajax_referer' ), 20, 2 ); 76 add_action( 'admin_init', array( &$this, 'purge_all' ) ); 77 78 // expose action to allow other plugins to purge the cache 79 add_action( 'rt_nginx_helper_purge_all', array( &$this, 'true_purge_all' ) ); 80 81 // Load WP-CLI command 82 if ( defined( 'WP_CLI' ) && WP_CLI ) { 83 require_once RT_WP_NGINX_HELPER_PATH . 'wp-cli.php'; 84 \WP_CLI::add_command( self::WP_CLI_COMMAND, 'Nginx_Helper_WP_CLI_Command' ); 85 } 86 } 87 88 function activate() 89 { 90 91 $path = $this->functional_asset_path(); 92 if ( !is_dir( $path ) ) { 93 mkdir( $path ); 94 } 95 include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php'); 96 rt_wp_nginx_helper_install(); 97 } 98 99 function deactivate() 100 { 101 include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php'); 102 rt_wp_nginx_helper_uninstall(); 103 } 104 105 function required_wp_version() 106 { 107 108 global $wp_version; 109 $wp_ok = version_compare( $wp_version, $this->minium_WP, '>=' ); 110 if ( ($wp_ok == FALSE ) ) { 111 add_action( 'admin_notices', create_function( '', 'global $rt_wp_nginx_helper; printf (\'<div id="message" class="error"><p><strong>\' . __(\'Sorry, Nginx Helper requires WordPress %s or higher\', "nginx-helper" ) . \'</strong></p></div>\', $rt_wp_nginx_helper->minium_WP );' ) ); 112 add_action( 'network_admin_notices', create_function( '', 'global $rt_wp_nginx_helper; printf (\'<div id="message" class="error"><p><strong>\' . __(\'Sorry, Nginx Helper requires WordPress %s or higher\', "nginx-helper" ) . \'</strong></p></div>\', $rt_wp_nginx_helper->minium_WP );' ) ); 113 return false; 114 } 115 116 return true; 117 } 118 119 function load_options() 120 { 121 $this->options = get_site_option( 'rt_wp_nginx_helper_options' ); 122 } 123 124 function set_future_post_option_on_future_status( $new_status, $old_status, $post ) 125 { 126 127 global $blog_id, $rt_wp_nginx_purger; 128 if ( !$this->options['enable_purge'] ) { 129 return; 130 } 131 if ( $old_status != $new_status && $old_status != 'inherit' && $new_status != 'inherit' && $old_status != 'auto-draft' && $new_status != 'auto-draft' && $new_status != 'publish' && !wp_is_post_revision( $post->ID ) ) { 132 $rt_wp_nginx_purger->log( "Purge post on transition post STATUS from " . $old_status . " to " . $new_status ); 133 $rt_wp_nginx_purger->purgePost( $post->ID ); 134 } 135 136 if ( $new_status == 'future' ) { 137 if ( $post && $post->post_status == 'future' && ( ( $post->post_type == 'post' || $post->post_type == 'page' ) || ( isset( $this->options['custom_post_types_recognized'] ) && in_array( $post->post_type, $this->options['custom_post_types_recognized'] ) ) ) ) { 138 $rt_wp_nginx_purger->log( "Set/update future_posts option (post id = " . $post->ID . " and blog id = " . $blog_id . ")" ); 139 $this->options['future_posts'][$blog_id][$post->ID] = strtotime( $post->post_date_gmt ) + 60; 140 update_site_option( "rt_wp_nginx_helper_global_options", $this->options ); 141 } 142 } 143 } 144 145 function unset_future_post_option_on_delete( $post_id ) 146 { 147 148 global $blog_id, $rt_wp_nginx_purger; 149 if ( !$this->options['enable_purge'] ) { 150 return; 151 } 152 if ( $post_id && !wp_is_post_revision( $post_id ) ) { 153 154 if ( isset( $this->options['future_posts'][$blog_id][$post_id] ) && count( $this->options['future_posts'][$blog_id][$post_id] ) ) { 155 $rt_wp_nginx_purger->log( "Unset future_posts option (post id = " . $post_id . " and blog id = " . $blog_id . ")" ); 156 unset( $this->options['future_posts'][$blog_id][$post_id] ); 157 update_site_option( "rt_wp_nginx_helper_global_options", $this->options ); 158 159 if ( !count( $this->options['future_posts'][$blog_id] ) ) { 160 unset( $this->options['future_posts'][$blog_id] ); 161 update_site_option( "rt_wp_nginx_helper_global_options", $this->options ); 162 } 163 } 164 } 165 } 166 167 function update_new_blog_options( $blog_id ) 168 { 169 global $rt_wp_nginx_purger; 170 include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php'); 171 $rt_wp_nginx_purger->log( "New site added (id $blog_id)" ); 172 $this->update_map(); 173 $rt_wp_nginx_purger->log( "New site added to nginx map (id $blog_id)" ); 174 $helper_options = rt_wp_nginx_helper_get_options(); 175 update_blog_option( $blog_id, "rt_wp_nginx_helper_options", $helper_options ); 176 $rt_wp_nginx_purger->log( "Default options updated for the new blog (id $blog_id)" ); 177 } 178 179 function get_map() 180 { 181 if ( !$this->options['enable_map'] ) { 182 return; 183 } 184 185 if ( is_multisite() ) { 186 187 global $wpdb; 188 189 $rt_all_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM " . $wpdb->blogs . " WHERE site_id = %d AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'", $wpdb->siteid ) ); 190 $wpdb->dmtable = $wpdb->base_prefix . 'domain_mapping'; 191 $rt_domain_map_sites = ''; 192 if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->dmtable}'" ) == $wpdb->dmtable ) { 193 $rt_domain_map_sites = $wpdb->get_results( "SELECT blog_id, domain FROM {$wpdb->dmtable} ORDER BY id DESC" ); 194 } 195 $rt_nginx_map = ""; 196 $rt_nginx_map_array = array(); 197 198 199 if ( $rt_all_blogs ) 200 foreach ( $rt_all_blogs as $blog ) { 201 if ( SUBDOMAIN_INSTALL == "yes" ) { 202 $rt_nginx_map_array[$blog->domain] = $blog->blog_id; 203 } else { 204 if ( $blog->blog_id != 1 ) { 205 $rt_nginx_map_array[$blog->path] = $blog->blog_id; 206 } 207 } 208 } 209 210 if ( $rt_domain_map_sites ) { 211 foreach ( $rt_domain_map_sites as $site ) { 212 $rt_nginx_map_array[$site->domain] = $site->blog_id; 213 } 214 } 215 216 foreach ( $rt_nginx_map_array as $domain => $domain_id ) { 217 $rt_nginx_map .= "\t" . $domain . "\t" . $domain_id . ";\n"; 218 } 219 220 return $rt_nginx_map; 221 } 222 } 223 224 function functional_asset_path() 225 { 226 $dir = wp_upload_dir(); 227 $path = $dir['basedir'] . '/nginx-helper/'; 228 return apply_filters( 'nginx_asset_path', $path ); 229 } 230 231 function functional_asset_url() 232 { 233 $dir = wp_upload_dir(); 234 $url = $dir['baseurl'] . '/nginx-helper/'; 235 return apply_filters( 'nginx_asset_url', $url ); 236 } 237 238 function update_map() 239 { 240 if ( is_multisite() ) { 241 $rt_nginx_map = $this->get_map(); 242 243 if ( $fp = fopen( $this->functional_asset_path() . 'map.conf', 'w+' ) ) { 244 fwrite( $fp, $rt_nginx_map ); 245 fclose( $fp ); 246 return true; 247 } 248 } 249 } 250 251 function add_timestamps() 252 { 253 if ( $this->options['enable_purge'] != 1 ) 254 return; 255 if ( $this->options['enable_stamp'] != 1 ) 256 return; 257 if ( is_admin() ) 258 return; 259 foreach ( headers_list() as $header ) { 260 list($key, $value) = explode( ':', $header, 2 ); 261 if ( $key == 'Content-Type' && strpos( trim( $value ), 'text/html' ) !== 0 ) { 262 return; 263 } 264 if ( $key == 'Content-Type' ) 265 break; 266 } 267 268 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) 269 return; 270 $timestamps = "\n<!--" . 271 "Cached using Nginx-Helper on " . current_time( 'mysql' ) . ". " . 272 "It took " . get_num_queries() . " queries executed in " . timer_stop() . " seconds." . 273 "-->\n" . 274 "<!--Visit http://wordpress.org/extend/plugins/nginx-helper/faq/ for more details-->"; 275 echo $timestamps; 276 } 277 278 function show_notice() 279 { 280 echo '<div class="updated"><p>' . __( 'Purge initiated', 'nginx-helper' ) . '</p></div>'; 281 } 282 283 function purge_all() 284 { 285 if ( !isset( $_REQUEST['nginx_helper_action'] ) ) 286 return; 287 288 if ( !current_user_can( 'manage_options' ) ) 289 wp_die( 'Sorry, you do not have the necessary privileges to edit these options.' ); 290 291 $action = $_REQUEST['nginx_helper_action']; 292 293 if ( $action == 'done' ) { 294 add_action( 'admin_notices', array( &$this, 'show_notice' ) ); 295 add_action( 'network_admin_notices', array( &$this, 'show_notice' ) ); 296 return; 297 } 298 299 check_admin_referer( 'nginx_helper-purge_all' ); 300 301 switch ( $action ) { 302 case 'purge': 303 $this->true_purge_all(); 304 break; 305 } 306 wp_redirect( esc_url_raw( add_query_arg( array( 'nginx_helper_action' => 'done' ) ) ) ); 307 } 308 309 function true_purge_all() 310 { 311 global $rt_wp_nginx_purger; 312 $rt_wp_nginx_purger->true_purge_all(); 313 } 314 315 /** 316 * Load the translation file for current language. 317 */ 318 function load_plugin_textdomain() 319 { 320 load_plugin_textdomain( 'nginx-helper', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 321 } 322 323 } 324 304 325 } 305 326 306 327 namespace { 307 328 308 if (!defined('RT_WP_NGINX_HELPER_CACHE_PATH')) { 309 define('RT_WP_NGINX_HELPER_CACHE_PATH', '/var/run/nginx-cache'); 310 } 311 global $current_blog; 312 313 if (is_admin()) { 314 require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . '/admin/admin.php'); 315 $rtwpAdminPanel = new \rtCamp\WP\Nginx\Admin(); 316 } 317 318 require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . 'purger.php'); 319 require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . 'compatibility.php'); 320 321 global $rt_wp_nginx_helper, $rt_wp_nginx_purger, $rt_wp_nginx_compatibility; 322 $rt_wp_nginx_helper = new \rtCamp\WP\Nginx\Helper; 323 $rt_wp_nginx_purger = new \rtCamp\WP\Nginx\Purger; 324 $rt_wp_nginx_compatibility = namespace\rtCamp\WP\Nginx\Compatibility::instance(); 325 if ($rt_wp_nginx_compatibility->haveNginx() && !function_exists('wp_redirect')) { 326 327 function wp_redirect($location, $status = 302) { 328 $location = apply_filters('wp_redirect', $location, $status); 329 330 if (empty($location)) { 331 return false; 332 } 333 334 $status = apply_filters('wp_redirect_status', $status, $location); 335 if ($status < 300 || $status > 399) { 336 $status = 302; 337 } 338 339 if (function_exists('wp_sanitize_redirect')) { 340 $location = wp_sanitize_redirect($location); 341 } 342 header('Location: ' . $location, true, $status); 343 } 344 345 } 346 347 // Add settings link on plugin page 348 function nginx_settings_link($links) { 349 if (is_network_admin()) { 350 $u = 'settings.php'; 351 } else { 352 $u = 'options-general.php'; 353 } 354 $settings_link = '<a href="' . $u . '?page=nginx">' . __('Settings', 'nginx-helper') . '</a>'; 355 array_unshift($links, $settings_link); 356 return $links; 357 } 358 359 if (is_multisite()) { 360 add_filter("network_admin_plugin_action_links_" . plugin_basename(__FILE__), 'nginx_settings_link'); 361 } else { 362 add_filter("plugin_action_links_" . plugin_basename(__FILE__), 'nginx_settings_link'); 363 } 364 365 function get_feeds($feed_url = 'http://rtcamp.com/blog/feed/') { 366 // Get RSS Feed(s) 367 require_once( ABSPATH . WPINC . '/feed.php' ); 368 $maxitems = 0; 369 // Get a SimplePie feed object from the specified feed source. 370 $rss = fetch_feed($feed_url); 371 if (!is_wp_error($rss)) { // Checks that the object is created correctly 372 // Figure out how many total items there are, but limit it to 5. 373 $maxitems = $rss->get_item_quantity(5); 374 375 // Build an array of all the items, starting with element 0 (first element). 376 $rss_items = $rss->get_items(0, $maxitems); 377 } ?> 378 <ul role="list"><?php 379 if ($maxitems == 0) { 380 echo '<li role="listitem">' . __('No items', 'nginx-helper') . '.</li>'; 381 } else { 382 // Loop through each feed item and display each item as a hyperlink. 383 foreach ($rss_items as $item) { ?> 384 <li role="listitem"> 385 <a href='<?php echo $item->get_permalink(); ?>' title='<?php echo __('Posted ', 'nginx-helper') . $item->get_date('j F Y | g:i a'); ?>'><?php echo $item->get_title(); ?></a> 386 </li><?php 387 } 388 } ?> 389 </ul><?php 390 } 391 392 function fetch_feeds() { 393 if (isset($_GET['get_feeds']) && $_GET['get_feeds'] == '1') { 394 get_feeds(); 395 die(); 396 } 397 } 398 399 add_action('init', 'fetch_feeds'); 329 if ( !defined( 'RT_WP_NGINX_HELPER_CACHE_PATH' ) ) { 330 define( 'RT_WP_NGINX_HELPER_CACHE_PATH', '/var/run/nginx-cache' ); 331 } 332 global $current_blog; 333 334 if ( is_admin() ) { 335 require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . '/admin/admin.php'); 336 $rtwpAdminPanel = new \rtCamp\WP\Nginx\Admin(); 337 } 338 339 require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . 'purger.php'); 340 require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . 'redis-purger.php'); 341 require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . 'compatibility.php'); 342 343 global $rt_wp_nginx_helper, $rt_wp_nginx_purger, $rt_wp_nginx_compatibility; 344 $rt_wp_nginx_helper = new \rtCamp\WP\Nginx\Helper; 345 346 if ( !empty( $rt_wp_nginx_helper->options['cache_method'] ) && $rt_wp_nginx_helper->options['cache_method'] == "enable_redis" ) { 347 $rt_wp_nginx_purger = new \rtCamp\WP\Nginx\Redispurger; 348 } else { 349 $rt_wp_nginx_purger = new \rtCamp\WP\Nginx\Purger; 350 } 351 $rt_wp_nginx_compatibility = namespace\rtCamp\WP\Nginx\Compatibility::instance(); 352 if ( $rt_wp_nginx_compatibility->haveNginx() && !function_exists( 'wp_redirect' ) ) { 353 354 function wp_redirect( $location, $status = 302 ) 355 { 356 $location = apply_filters( 'wp_redirect', $location, $status ); 357 358 if ( empty( $location ) ) { 359 return false; 360 } 361 362 $status = apply_filters( 'wp_redirect_status', $status, $location ); 363 if ( $status < 300 || $status > 399 ) { 364 $status = 302; 365 } 366 367 if ( function_exists( 'wp_sanitize_redirect' ) ) { 368 $location = wp_sanitize_redirect( $location ); 369 } 370 header( 'Location: ' . $location, true, $status ); 371 } 372 373 } 374 375 // Add settings link on plugin page 376 function nginx_settings_link( $links ) 377 { 378 if ( is_network_admin() ) { 379 $u = 'settings.php'; 380 } else { 381 $u = 'options-general.php'; 382 } 383 $settings_link = '<a href="' . $u . '?page=nginx">' . __( 'Settings', 'nginx-helper' ) . '</a>'; 384 array_unshift( $links, $settings_link ); 385 return $links; 386 } 387 388 if ( is_multisite() ) { 389 add_filter( "network_admin_plugin_action_links_" . plugin_basename( __FILE__ ), 'nginx_settings_link' ); 390 } else { 391 add_filter( "plugin_action_links_" . plugin_basename( __FILE__ ), 'nginx_settings_link' ); 392 } 393 394 function get_feeds( $feed_url = 'http://rtcamp.com/blog/feed/' ) 395 { 396 // Get RSS Feed(s) 397 require_once( ABSPATH . WPINC . '/feed.php' ); 398 $maxitems = 0; 399 // Get a SimplePie feed object from the specified feed source. 400 $rss = fetch_feed( $feed_url ); 401 if ( !is_wp_error( $rss ) ) { // Checks that the object is created correctly 402 // Figure out how many total items there are, but limit it to 5. 403 $maxitems = $rss->get_item_quantity( 5 ); 404 405 // Build an array of all the items, starting with element 0 (first element). 406 $rss_items = $rss->get_items( 0, $maxitems ); 407 } 408 ?> 409 <ul role="list"><?php 410 if ( $maxitems == 0 ) { 411 echo '<li role="listitem">' . __( 'No items', 'nginx-helper' ) . '.</li>'; 412 } else { 413 // Loop through each feed item and display each item as a hyperlink. 414 foreach ( $rss_items as $item ) { 415 ?> 416 <li role="listitem"> 417 <a href='<?php echo $item->get_permalink(); ?>' title='<?php echo __( 'Posted ', 'nginx-helper' ) . $item->get_date( 'j F Y | g:i a' ); ?>'><?php echo $item->get_title(); ?></a> 418 </li><?php 419 } 420 } 421 ?> 422 </ul><?php 423 } 424 425 function fetch_feeds() 426 { 427 if ( isset( $_GET['get_feeds'] ) && $_GET['get_feeds'] == '1' ) { 428 get_feeds(); 429 die(); 430 } 431 } 432 433 add_action( 'init', 'fetch_feeds' ); 400 434 } 435 -
nginx-helper/trunk/readme.txt
r1189553 r1190839 1 1 === Nginx Helper === 2 Contributors: rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, Darren Slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko, weskoop, bcole808, gungeekatx 2 Contributors: rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, Darren Slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko, weskoop, bcole808, gungeekatx, rohanveer 3 3 Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, rewrite, permalinks 4 4 Requires at least: 3.0 5 Tested up to: 4.2 6 Stable tag: 1. 8.135 Tested up to: 4.2.2 6 Stable tag: 1.9 7 7 License: GPLv2 or later (of-course) 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 114 114 == Changelog == 115 115 116 = 1.9 = 117 Added Redis cache purge support. 118 116 119 = 1.8.13 = 117 120 Fixed PHP notice for an undefined index when "Enable Logging" is not set. … … 294 297 == Upgrade Notice == 295 298 296 = 1. 8.4=297 Fix undefined index issue and correct "purge_archive_on_del" key 299 = 1.9 = 300 Added Redis cache purge support.
Note: See TracChangeset
for help on using the changeset viewer.