Changeset 2154691
- Timestamp:
- 09/11/2019 09:50:34 AM (6 years ago)
- Location:
- runcache-purger/trunk
- Files:
-
- 4 edited
-
assets/runcache_purger.css (modified) (2 diffs)
-
languages/runcachepurger.pot (modified) (3 diffs)
-
runcache-purger.php (modified) (18 diffs)
-
views/settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
runcache-purger/trunk/assets/runcache_purger.css
r2154386 r2154691 38 38 #runcachepurger-wrap h1, 39 39 #runcachepurger-wrap h2, 40 #runcachepurger-wrap h3 { 40 #runcachepurger-wrap h3, 41 #runcachepurger-wrap h4 { 41 42 color: currentColor; 42 43 margin: 0; … … 494 495 } 495 496 497 #runcachepurger-wrap .runcachepurger-field-children { 498 padding-left: 32px; 499 } 500 501 #runcachepurger-wrap input[type=text], 502 #runcachepurger-wrap input[type=number] { 503 margin-top: 8px; 504 padding: 0 8px; 505 width: 100%; 506 height: 32px; 507 color: #23282d; 508 background: #fff; 509 border: 2px solid #c2cad4; 510 border-radius: 3px; 511 font-family: monospace, monaco, Consolas, Lucida Console; 512 font-size: 12px; 513 font-size: .75rem; 514 line-height: 1.33333; 515 transition: border 200ms ease-out; 516 -webkit-transition: border 200ms ease-out; 517 } 518 519 #runcachepurger-wrap input[type=text]:focus, 520 #runcachepurger-wrap input[type=number]:focus { 521 outline: none; 522 border-color: #34373a; 523 -moz-box-shadow: none; 524 -webkit-box-shadow: none; 525 box-shadow: none; 526 } 527 528 #runcachepurger-wrap .cache-redis { 529 padding-left: 32px; 530 } 531 532 #runcachepurger-wrap .cache-redis > h4 { 533 margin-bottom: 5px; 534 font-size: 14px; 535 font-weight: 500; 536 } 537 538 #runcachepurger-wrap .cache-redis > label { 539 display: inline-block; 540 width: 120px; 541 color: #72777c; 542 } 543 544 #runcachepurger-wrap .cache-redis > input { 545 display: inline-block; 546 width: 60%; 547 } 548 549 @media (max-width: 783px) { 550 #runcachepurger-wrap .cache-redis > label { 551 display: block; 552 width: 100%; 553 } 554 555 #runcachepurger-wrap .cache-redis > input { 556 display: block; 557 width: 100%; 558 } 559 } 560 496 561 .update-nag { 497 562 display: none; -
runcache-purger/trunk/languages/runcachepurger.pot
r2154386 r2154691 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-11 01:49+0800\n"7 "POT-Creation-Date: 2019-09-11 17:47+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 7016 #: runcache-purger.php:253 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:264 22 #, php-format 23 msgid "WordPress version %s or higher." 24 msgstr "" 25 26 #: runcache-purger.php:273 27 #, php-format 28 msgid "PHP version %s or higher." 29 msgstr "" 30 21 31 #: runcache-purger.php:281 22 #, php-format23 msgid "WordPress version %s or higher."24 msgstr ""25 26 #: runcache-purger.php:29027 #, php-format28 msgid "PHP version %s or higher."29 msgstr ""30 31 #: runcache-purger.php:29832 32 msgid "Apache or NGINX Web Server." 33 33 msgstr "" 34 34 35 #: runcache-purger.php: 30435 #: runcache-purger.php:287 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: 469 runcache-purger.php:57840 #: runcache-purger.php:506 runcache-purger.php:625 41 41 msgid "Settings" 42 42 msgstr "" 43 43 44 #: runcache-purger.php: 59344 #: runcache-purger.php:640 45 45 msgid "Clear Cache this Post" 46 46 msgstr "" 47 47 48 #: runcache-purger.php:6 0448 #: runcache-purger.php:651 49 49 msgid "Clear Cache this URL" 50 50 msgstr "" 51 51 52 #: runcache-purger.php:6 14 views/settings.php:16852 #: runcache-purger.php:661 views/settings.php:191 53 53 msgid "Clear All Cache" 54 54 msgstr "" 55 55 56 #: runcache-purger.php:10 3356 #: runcache-purger.php:1086 57 57 msgid "Failed to purge cache." 58 58 msgstr "" 59 59 60 #: runcache-purger.php:10 4060 #: runcache-purger.php:1093 61 61 msgid "Purging cache was successful." 62 62 msgstr "" 63 63 64 #: runcache-purger.php:10 4264 #: runcache-purger.php:1095 65 65 msgid "Purging redis object cache was successful." 66 66 msgstr "" 67 67 68 #: runcache-purger.php:1 04768 #: runcache-purger.php:1100 69 69 #, php-format 70 70 msgid "Purging method not implement. Status Code %s" 71 71 msgstr "" 72 72 73 #: runcache-purger.php:1 05173 #: runcache-purger.php:1104 74 74 msgid "Failed to purge redis object cache." 75 75 msgstr "" 76 76 77 #: runcache-purger.php:1053 78 msgid "Purging method not implement. Redis WP Object Cache Plugin not " 79 "available" 80 msgstr "" 81 82 #: runcache-purger.php:1058 77 #: runcache-purger.php:1106 78 msgid "Purging method not implement." 79 msgstr "" 80 81 #: runcache-purger.php:1111 83 82 #, php-format 84 83 msgid "Failed to purge cache. Status Code %s" … … 175 174 msgstr "" 176 175 177 #: views/settings.php:163 176 #: views/settings.php:156 177 msgid "Enable Object Cache" 178 msgstr "" 179 180 #: views/settings.php:160 181 msgid "Enable this option to allow this plugin handle redis object cache." 182 msgstr "" 183 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 178 197 msgid "Purge Actions" 179 198 msgstr "" 180 199 181 #: views/settings.php:1 72200 #: views/settings.php:195 182 201 msgid "Clear Homepage Cache" 183 202 msgstr "" 184 203 185 #: views/settings.php:1 76204 #: views/settings.php:199 186 205 msgid "Clear Content Cache" 187 206 msgstr "" 188 207 189 #: views/settings.php: 180208 #: views/settings.php:203 190 209 msgid "Clear Archives Cache" 191 210 msgstr "" 192 211 193 #: views/settings.php: 184212 #: views/settings.php:207 194 213 msgid "Clear Redis Cache" 195 214 msgstr "" -
runcache-purger/trunk/runcache-purger.php
r2154393 r2154691 5 5 * Plugin URI: https://runcloud.io 6 6 * Description: This plugin will purge RunCloud.io NGINX fastcgi, Proxy Cache and Redis Object Cache. 7 * Version: 1.0. 57 * Version: 1.0.6 8 8 * Author: RunCloud 9 9 * Author URI: https://profiles.wordpress.org/runcloud/ … … 63 63 64 64 // version 65 private static $version = '1.0. 5';66 private static $version_prev = '1.0. 4';65 private static $version = '1.0.6'; 66 private static $version_prev = '1.0.5'; 67 67 68 68 // later … … 79 79 private static $plugin_url_logo_w = ''; 80 80 81 // view checkbox81 // view 82 82 private static $checked = []; 83 private static $value = []; 83 84 84 85 // is cond … … 174 175 175 176 return false; 176 }177 178 /**179 * is_redis_cache_available.180 */181 private static function is_redis_cache_available() {182 $plugin = 'redis-cache/redis-cache.php';183 $file = WP_PLUGIN_DIR.DIRECTORY_SEPARATOR.$plugin;184 185 if ( !file_exists($file) ) {186 return false;187 }188 189 if ( !self::is_plugin_active($plugin) && !self::is_plugin_active_for_network($plugin) ) {190 return false;191 }192 193 return true;194 177 } 195 178 … … 341 324 'archives_homepage_onn' => 1, 342 325 'archives_content_onn' => 1, 343 'redis_purge_onn' => 1 326 'redis_purge_onn' => 1, 327 'redis_cache_onn' => 1, 328 'redis_prefix' => 'runcache-purger', 329 'redis_host' => '127.0.0.1', 330 'redis_port' => 6379, 344 331 ]; 345 332 … … 416 403 417 404 /** 418 * is_plugin_active. 419 */ 420 private static function is_plugin_active( $plugin ) { 421 if ( ! function_exists( 'is_plugin_active' ) ) { 422 require_once( ABSPATH.'wp-admin/includes/plugin.php' ); 423 } 424 return is_plugin_active( $plugin ); 405 * install_dropin. 406 */ 407 private static function install_dropin() 408 { 409 $file = RUNCACHE_PURGER_PATH.'vendor/object-cache.php'; 410 if ( !file_exists($file) ) { 411 return false; 412 } 413 414 $options = self::get_settings(); 415 if ( empty($options['redis_cache_onn']) ) { 416 return self::uninstall_dropin(); 417 } 418 419 $buff = file_get_contents($file); 420 if ( !empty($buff) ) { 421 422 $redis_host = $options['redis_host']; 423 $redis_port = $options['redis_port']; 424 $redis_prefix = $options['redis_prefix']; 425 426 $code = ""; 427 $code .= "!defined('RUNCACHE_PURGER_DROPIN_HOST') && define('RUNCACHE_PURGER_DROPIN_HOST', '".$redis_host."');".PHP_EOL; 428 $code .= "!defined('RUNCACHE_PURGER_DROPIN_PORT') && define('RUNCACHE_PURGER_DROPIN_PORT', '".$redis_port."');".PHP_EOL; 429 $code .= "!defined('RUNCACHE_PURGER_DROPIN_PREFIX') && define('RUNCACHE_PURGER_DROPIN_PREFIX', '".addslashes($redis_prefix)."');".PHP_EOL; 430 431 $buff = str_replace('/*@CONFIG-MARKER*/', $code, $buff); 432 433 $filesave = WP_CONTENT_DIR.'/object-cache.php'; 434 435 $perm = self::get_fileperms('file'); 436 if (file_put_contents($filesave, $buff)) { 437 @chmod($filesave, $perm); 438 return true; 439 } 440 } 441 442 return false; 443 } 444 445 /** 446 * install_dropin. 447 */ 448 private static function uninstall_dropin() 449 { 450 $filesave = WP_CONTENT_DIR.'/object-cache.php'; 451 return unlink($filesave); 452 } 453 454 /** 455 * install_dropin. 456 */ 457 private static function try_install_dropin() 458 { 459 if ( !defined('RUNCACHE_PURGER_DROPIN') ) { 460 self::install_dropin(); 461 } 425 462 } 426 463 … … 507 544 508 545 /** 546 * view_fvalue. 547 */ 548 private static function view_fvalue($name) 549 { 550 echo self::$value[$name]; 551 } 552 553 /** 509 554 * view_index. 510 555 */ … … 518 563 $val = (int) $val; 519 564 self::$checked[$key] = (1 === $val ? ' checked' : ''); 565 } else { 566 self::$value[$key] = $val; 520 567 } 521 568 } … … 624 671 { 625 672 if (!empty($options)) { 673 self::install_dropin(); 626 674 } 627 675 } … … 637 685 [__CLASS__, 'settings_validate'] 638 686 ); 687 688 // try install dropin 689 self::try_install_dropin(); 639 690 } 640 691 … … 664 715 $options = []; 665 716 } 717 666 718 return $options; 667 719 } … … 723 775 724 776 $options = array_merge($options, $input); 777 725 778 return $options; 726 779 } … … 1051 1104 $msg = __('Failed to purge redis object cache.', self::$textdomain); 1052 1105 } else { 1053 $msg = __('Purging method not implement. Redis WP Object Cache Plugin not available', self::$textdomain);1106 $msg = __('Purging method not implement.', self::$textdomain); 1054 1107 } 1055 1108 } … … 1132 1185 */ 1133 1186 public static function flush_object($purge = false) { 1134 $ok = false; 1135 $is_avail = self::is_redis_cache_available(); 1136 1137 if ( $is_avail ) { 1138 $ok = wp_cache_flush(); 1139 } 1140 1187 $ok = wp_cache_flush(); 1188 $filesave = WP_CONTENT_DIR.'/object-cache.php'; 1189 $is_avail = ( file_exists($filesave) ? true : false ); 1141 1190 $return = [ 1142 'code' => 200,1191 'code' => ( $ok ? 200 : 404 ), 1143 1192 'is_redis' => 1, 1144 1193 'is_avail' => ( $is_avail ? 1 : 0 ) 1145 1194 ]; 1146 1195 1147 1196 if ( !$purge ) { 1148 $return['code'] = ( $ok ? 200 : 404 );1149 1197 self::$req_status = $return; 1150 1198 } … … 1565 1613 { 1566 1614 self::install_options(); 1615 self::install_dropin(); 1567 1616 } 1568 1617 … … 1573 1622 { 1574 1623 self::force_site_deactivate_plugin(); 1624 self::uninstall_dropin(); 1575 1625 } 1576 1626 … … 1581 1631 { 1582 1632 self::uninstall_options(); 1633 self::uninstall_dropin(); 1583 1634 } 1584 1635 … … 1756 1807 * cli_purge_all. 1757 1808 */ 1758 /*public static function cli_purge_all($types)1759 {1760 $_res = [];1761 1762 foreach ($types as $type) {1763 self::request_purge_all($type);1764 1765 if (!self::is_debugging()) {1766 $_res[$type] = [1767 'code' => self::$req_status['code'],1768 'status' => self::$req_status['status'],1769 ];1770 } else {1771 $_res[$type] = self::$req_status;1772 }1773 }1774 1775 return $_res;1776 }*/1777 1778 1809 public static function cli_purge_all($type, $host = null) 1779 1810 { -
runcache-purger/trunk/views/settings.php
r2154386 r2154691 149 149 <?php _e( 'Automatically clean redis object cache when any purge action was triggered.', self::$textdomain ); ?> 150 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 <div class="runcachepurger-field cache-redis"> 165 <h4>Redis Server</h4> 166 <label for="redis_host"><?php _e( 'Hostname', self::$textdomain ); ?></label> 167 <input type="text" id="redis_host" name="<?php self::view_fname('redis_host');?>" value="<?php self::view_fvalue('redis_host');?>"> 168 <br> 169 <label for="redis_port"><?php _e( 'Port', self::$textdomain ); ?></label> 170 <input type="number" min=1 id="redis_port" name="<?php self::view_fname('redis_port');?>" value="<?php self::view_fvalue('redis_port');?>"> 171 <br> 172 <label for="redis_prefix"><?php _e( 'Key Prefix', self::$textdomain ); ?></label> 173 <input type="text" id="redis_prefix" name="<?php self::view_fname('redis_prefix');?>" value="<?php self::view_fvalue('redis_prefix');?>"> 151 174 </div> 152 175
Note: See TracChangeset
for help on using the changeset viewer.