Changeset 2155285
- Timestamp:
- 09/12/2019 06:25:24 AM (6 years ago)
- Location:
- runcache-purger/trunk
- Files:
-
- 1 added
- 5 edited
-
assets/runcache_purger.css (modified) (2 diffs)
-
languages/runcachepurger.pot (modified) (3 diffs)
-
runcache-purger.php (modified) (5 diffs)
-
vendor/object-cache.php (modified) (3 diffs)
-
vendor/redis_is_connect.php (added)
-
views/settings.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
runcache-purger/trunk/assets/runcache_purger.css
r2154797 r2155285 526 526 } 527 527 528 #runcachepurger-wrap .cache-redis {529 padding-left: 32px;530 }531 532 528 #runcachepurger-wrap .cache-redis > h4 { 533 529 margin-bottom: 5px; … … 547 543 } 548 544 545 #runcachepurger-wrap .cache-redis > div.redis-status { 546 display: inline-block; 547 width: 60%; 548 margin-top: 8px; 549 padding: 8px 0 8px 0; 550 height: 32px; 551 color: #23282d; 552 font-family: monospace, monaco, Consolas, Lucida Console; 553 font-size: 14px; 554 font-weight: 500; 555 line-height: 1.33333; 556 } 557 558 #runcachepurger-wrap .cache-redis > div.redis-status-ok { 559 color: green; 560 } 561 562 #runcachepurger-wrap .cache-redis > div.redis-status-ko { 563 color: red; 564 } 565 549 566 @media (max-width: 783px) { 550 551 #runcachepurger-wrap .cache-redis {552 padding-left: 0px;553 }554 567 555 568 #runcachepurger-wrap .cache-redis > label { -
runcache-purger/trunk/languages/runcachepurger.pot
r2154797 r2155285 5 5 msgstr "Project-Id-Version: RunCache Purger 1.0.0\n" 6 6 "Report-Msgid-Bugs-To: https://runcloud.io\n" 7 "POT-Creation-Date: 2019-09-1 1 21:09+0800\n"7 "POT-Creation-Date: 2019-09-12 14:23+0800\n" 8 8 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 9 9 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 14 14 "Content-Transfer-Encoding: 8bit\n" 15 15 16 #: runcache-purger.php:2 5316 #: runcache-purger.php:277 17 17 #, php-format 18 18 msgid "The <strong>%1$s</strong> plugin version %2$s requires:" 19 19 msgstr "" 20 20 21 #: runcache-purger.php:2 6421 #: runcache-purger.php:288 22 22 #, php-format 23 23 msgid "WordPress version %s or higher." 24 24 msgstr "" 25 25 26 #: runcache-purger.php:2 7326 #: runcache-purger.php:297 27 27 #, php-format 28 28 msgid "PHP version %s or higher." 29 29 msgstr "" 30 30 31 #: runcache-purger.php: 28131 #: runcache-purger.php:305 32 32 msgid "Apache or NGINX Web Server." 33 33 msgstr "" 34 34 35 #: runcache-purger.php: 28735 #: runcache-purger.php:311 36 36 msgid "The plugin has now deactivated itself. Please contact your hosting " 37 37 "provider or system administrator for version upgrade." 38 38 msgstr "" 39 39 40 #: runcache-purger.php:5 16 runcache-purger.php:63540 #: runcache-purger.php:544 runcache-purger.php:663 41 41 msgid "Settings" 42 42 msgstr "" 43 43 44 #: runcache-purger.php:6 5044 #: runcache-purger.php:678 45 45 msgid "Clear Cache this Post" 46 46 msgstr "" 47 47 48 #: runcache-purger.php:6 6148 #: runcache-purger.php:689 49 49 msgid "Clear Cache this URL" 50 50 msgstr "" 51 51 52 #: runcache-purger.php:6 71 views/settings.php:19152 #: runcache-purger.php:699 views/settings.php:194 53 53 msgid "Clear All Cache" 54 54 msgstr "" 55 55 56 #: runcache-purger.php:1 09656 #: runcache-purger.php:1124 57 57 msgid "Failed to purge cache." 58 58 msgstr "" 59 59 60 #: runcache-purger.php:11 0360 #: runcache-purger.php:1131 61 61 msgid "Purging cache was successful." 62 62 msgstr "" 63 63 64 #: runcache-purger.php:11 0564 #: runcache-purger.php:1133 65 65 msgid "Purging redis object cache was successful." 66 66 msgstr "" 67 67 68 #: runcache-purger.php:11 1068 #: runcache-purger.php:1138 69 69 #, php-format 70 70 msgid "Purging method not implement. Status Code %s" 71 71 msgstr "" 72 72 73 #: runcache-purger.php:1114 73 #: runcache-purger.php:1143 74 msgid "Redis server not connected." 75 msgstr "" 76 77 #: runcache-purger.php:1145 74 78 msgid "Failed to purge redis object cache." 75 79 msgstr "" 76 80 77 #: runcache-purger.php:11 1681 #: runcache-purger.php:1148 78 82 msgid "Purging method not implement." 79 83 msgstr "" 80 84 81 #: runcache-purger.php:11 2185 #: runcache-purger.php:1153 82 86 #, php-format 83 87 msgid "Failed to purge cache. Status Code %s" … … 165 169 msgstr "" 166 170 167 #: views/settings.php:145 171 #: views/settings.php:143 172 msgid "Status" 173 msgstr "" 174 175 #: views/settings.php:147 176 msgid "Hostname" 177 msgstr "" 178 179 #: views/settings.php:150 180 msgid "Port" 181 msgstr "" 182 183 #: views/settings.php:153 184 msgid "Key Prefix" 185 msgstr "" 186 187 #: views/settings.php:160 168 188 msgid "Purge Object Cache" 169 189 msgstr "" 170 190 171 #: views/settings.php:1 49191 #: views/settings.php:164 172 192 msgid "Automatically clean redis object cache when any purge action was " 173 193 "triggered." 174 194 msgstr "" 175 195 176 #: views/settings.php:1 56196 #: views/settings.php:171 177 197 msgid "Enable Object Cache" 178 198 msgstr "" 179 199 180 #: views/settings.php:1 60200 #: views/settings.php:175 181 201 msgid "Enable this option to allow this plugin handle redis object cache." 182 202 msgstr "" 183 203 184 #: views/settings.php:166 185 msgid "Hostname" 186 msgstr "" 187 188 #: views/settings.php:169 189 msgid "Port" 190 msgstr "" 191 192 #: views/settings.php:172 193 msgid "Key Prefix" 194 msgstr "" 195 196 #: views/settings.php:186 204 #: views/settings.php:189 197 205 msgid "Purge Actions" 198 206 msgstr "" 199 207 200 #: views/settings.php:19 5208 #: views/settings.php:198 201 209 msgid "Clear Homepage Cache" 202 210 msgstr "" 203 211 204 #: views/settings.php: 199212 #: views/settings.php:202 205 213 msgid "Clear Content Cache" 206 214 msgstr "" 207 215 208 #: views/settings.php:20 3216 #: views/settings.php:206 209 217 msgid "Clear Archives Cache" 210 218 msgstr "" 211 219 212 #: views/settings.php:2 07220 #: views/settings.php:210 213 221 msgid "Clear Redis Cache" 214 222 msgstr "" -
runcache-purger/trunk/runcache-purger.php
r2155198 r2155285 44 44 define('RUNCACHE_PURGER_PATH_LANG', RUNCACHE_PURGER_PATH . 'languages/'); 45 45 define('RUNCACHE_PURGER_PATH_VIEW', RUNCACHE_PURGER_PATH . 'views/'); 46 !defined('RUNCACHE_PURGER_PATH_VENDOR') && define('RUNCACHE_PURGER_PATH_VENDOR', RUNCACHE_PURGER_PATH . 'vendor/'); 46 47 47 48 final class RunCache_Purger … … 172 173 if (false !== strpos($_SERVER['SERVER_SOFTWARE'], 'nginx')) { 173 174 return true; 175 } 176 177 return false; 178 } 179 180 /** 181 * is_redis_connect. 182 */ 183 private static function is_redis_connect($host = null, $port = null, &$error = '') 184 { 185 186 if ( function_exists('__redis_is_connect') ) { 187 if ( empty($host) || empty($port) ) { 188 $options = self::get_settings(); 189 $host = $options['redis_host']; 190 $port = $options['redis_port']; 191 } 192 if ( __redis_is_connect($host, $port, $error) ) { 193 return true; 194 } 174 195 } 175 196 … … 200 221 public static function register() 201 222 { 223 224 require_once RUNCACHE_PURGER_PATH_VENDOR . 'redis_is_connect.php'; 225 202 226 self::register_locale(); 203 227 … … 1116 1140 if ( !empty($req_status['is_redis']) && 404 === $req_status['code'] ) { 1117 1141 if ( !empty($req_status['is_avail']) ) { 1118 $msg = __('Failed to purge redis object cache.', self::$textdomain); 1142 if ( !empty($req_status['is_avail']) ) { 1143 $msg = __('Redis server not connected.', self::$textdomain); 1144 } else { 1145 $msg = __('Failed to purge redis object cache.', self::$textdomain); 1146 } 1119 1147 } else { 1120 1148 $msg = __('Purging method not implement.', self::$textdomain); … … 1199 1227 */ 1200 1228 public static function flush_object($purge = false) { 1201 $ok = wp_cache_flush();1229 $ok = false; 1202 1230 $filesave = WP_CONTENT_DIR.'/object-cache.php'; 1203 1231 $is_avail = ( file_exists($filesave) ? true : false ); 1232 $is_connect = self::is_redis_connect(null, null, $redis_error); 1233 1234 if ( $is_connect ) { 1235 $ok = wp_cache_flush(); 1236 } 1237 1204 1238 $return = [ 1205 1239 'code' => ( $ok ? 200 : 404 ), 1206 1240 'is_redis' => 1, 1207 'is_avail' => ( $is_avail ? 1 : 0 ) 1241 'is_avail' => ( $is_avail ? 1 : 0 ), 1242 'is_connect' => ( $is_connect ? 1 : 0 ) 1208 1243 ]; 1244 1245 if ( !$is_connect && !empty($redis_error) ) { 1246 $return['is_connect_error'] = $redis_error; 1247 } 1209 1248 1210 1249 if ( !$purge ) { -
runcache-purger/trunk/vendor/object-cache.php
r2155196 r2155285 11 11 define('RUNCACHE_PURGER_DROPIN', true); 12 12 !defined('WP_REDIS_SELECTIVE_FLUSH') && define('WP_REDIS_SELECTIVE_FLUSH', true); 13 !defined('RUNCACHE_PURGER_PATH_VENDOR') && define('RUNCACHE_PURGER_PATH_VENDOR', ( defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/plugins/runcache-purger/vendor/' ) ); 13 14 14 15 /*@CONFIG-MARKER@*/ 16 17 function wp_cache_is_redis_connect() 18 { 19 static $__redis_is_connect = false; 20 21 if ( $__redis_is_connect ) { 22 return true; 23 } 24 25 if ( !function_exists('__redis_is_connect') && defined('RUNCACHE_PURGER_DROPIN_HOST') && defined('RUNCACHE_PURGER_DROPIN_PORT') ) { 26 $file = RUNCACHE_PURGER_PATH_VENDOR.'redis_is_connect.php'; 27 if ( file_exists($file) ) { 28 include_once($file); 29 30 if ( function_exists('__redis_is_connect') ) { 31 if ( __redis_is_connect(RUNCACHE_PURGER_DROPIN_HOST, RUNCACHE_PURGER_DROPIN_PORT) ) { 32 $__redis_is_connect = true; 33 return true; 34 } 35 } 36 } 37 } 38 39 $__redis_is_connect = false; 40 return false; 41 } 42 43 if ( wp_cache_is_redis_connect() ): 15 44 16 45 function wp_cache_add($key, $value, $group = '', $expiration = 0) … … 248 277 249 278 if (! class_exists('Predis\Client')) { 250 $predis = sprintf( 251 '%s/runcache-purger/vendor/predis/autoload.php', 252 defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/plugins' 253 ); 279 $predis = RUNCACHE_PURGER_PATH_VENDOR.'predis/autoload.php'; 254 280 255 281 if (file_exists($predis)) { … … 926 952 } 927 953 928 endif; 954 endif; // is_redis_connect 955 endif; // if defined -
runcache-purger/trunk/views/settings.php
r2154691 r2155285 139 139 140 140 <fieldset class="runcachepurger-field-container-fieldset"> 141 142 <div class="runcachepurger-field runcachepurger-field-checkbox">143 <div class="runcachepurger-checkbox">144 <input type="checkbox" id="redis_purge_onn" name="<?php self::view_fname('redis_purge_onn');?>" value="1"<?php self::view_checked('redis_purge_onn');?>>145 <label for="redis_purge_onn"><?php _e( 'Purge Object Cache', self::$textdomain ); ?></label>146 </div>147 148 <div class="runcachepurger-field-description">149 <?php _e( 'Automatically clean redis object cache when any purge action was triggered.', self::$textdomain ); ?>150 </div>151 </div>152 153 <div class="runcachepurger-field runcachepurger-field-checkbox">154 <div class="runcachepurger-checkbox">155 <input type="checkbox" id="redis_cache_onn" name="<?php self::view_fname('redis_cache_onn');?>" value="1"<?php self::view_checked('redis_cache_onn');?>>156 <label for="redis_cache_onn"><?php _e( 'Enable Object Cache', self::$textdomain ); ?></label>157 </div>158 159 <div class="runcachepurger-field-description">160 <?php _e( 'Enable this option to allow this plugin handle redis object cache.', self::$textdomain ); ?>161 </div>162 </div>163 164 141 <div class="runcachepurger-field cache-redis"> 165 142 <h4>Redis Server</h4> 143 <label for="redis_prefix"><?php _e( 'Status', self::$textdomain ); ?></label> 144 <?php $redis_stat = self::is_redis_connect(self::$value['redis_host'], self::$value['redis_port']); ?> 145 <div class='redis-status<?php echo ( $redis_stat ? ' redis-status-ok' : ' redis-status-ko');?>'><?php echo ( $redis_stat ? 'Connected' : 'Not connected' );?></div> 146 <br> 166 147 <label for="redis_host"><?php _e( 'Hostname', self::$textdomain ); ?></label> 167 148 <input type="text" id="redis_host" name="<?php self::view_fname('redis_host');?>" value="<?php self::view_fvalue('redis_host');?>"> … … 172 153 <label for="redis_prefix"><?php _e( 'Key Prefix', self::$textdomain ); ?></label> 173 154 <input type="text" id="redis_prefix" name="<?php self::view_fname('redis_prefix');?>" value="<?php self::view_fvalue('redis_prefix');?>"> 155 </div> 156 157 <div class="runcachepurger-field runcachepurger-field-checkbox"> 158 <div class="runcachepurger-checkbox"> 159 <input type="checkbox" id="redis_purge_onn" name="<?php self::view_fname('redis_purge_onn');?>" value="1"<?php self::view_checked('redis_purge_onn');?>> 160 <label for="redis_purge_onn"><?php _e( 'Purge Object Cache', self::$textdomain ); ?></label> 161 </div> 162 163 <div class="runcachepurger-field-description"> 164 <?php _e( 'Automatically clean redis object cache when any purge action was triggered.', self::$textdomain ); ?> 165 </div> 166 </div> 167 168 <div class="runcachepurger-field runcachepurger-field-checkbox"> 169 <div class="runcachepurger-checkbox"> 170 <input type="checkbox" id="redis_cache_onn" name="<?php self::view_fname('redis_cache_onn');?>" value="1"<?php self::view_checked('redis_cache_onn');?>> 171 <label for="redis_cache_onn"><?php _e( 'Enable Object Cache', self::$textdomain ); ?></label> 172 </div> 173 174 <div class="runcachepurger-field-description"> 175 <?php _e( 'Enable this option to allow this plugin handle redis object cache.', self::$textdomain ); ?> 176 </div> 174 177 </div> 175 178
Note: See TracChangeset
for help on using the changeset viewer.