Changeset 3213676
- Timestamp:
- 12/27/2024 08:48:27 AM (15 months ago)
- Location:
- nginx-helper
- Files:
-
- 2 added
- 26 edited
- 1 copied
-
tags/2.3.0 (copied) (copied from nginx-helper/trunk)
-
tags/2.3.0/Development.md (added)
-
tags/2.3.0/admin/class-fastcgi-purger.php (modified) (1 diff)
-
tags/2.3.0/admin/class-nginx-helper-admin.php (modified) (52 diffs)
-
tags/2.3.0/admin/class-phpredis-purger.php (modified) (1 diff)
-
tags/2.3.0/admin/class-predis-purger.php (modified) (1 diff)
-
tags/2.3.0/admin/css/nginx-helper-admin.css (modified) (2 diffs)
-
tags/2.3.0/admin/js/nginx-helper-admin.js (modified) (1 diff)
-
tags/2.3.0/admin/partials/nginx-helper-general-options.php (modified) (9 diffs)
-
tags/2.3.0/includes/class-nginx-helper-activator.php (modified) (1 diff)
-
tags/2.3.0/includes/class-nginx-helper.php (modified) (3 diffs)
-
tags/2.3.0/languages/nginx-helper.mo (modified) (previous)
-
tags/2.3.0/languages/nginx-helper.po (modified) (4 diffs)
-
tags/2.3.0/nginx-helper.php (modified) (2 diffs)
-
tags/2.3.0/readme.txt (modified) (4 diffs)
-
trunk/Development.md (added)
-
trunk/admin/class-fastcgi-purger.php (modified) (1 diff)
-
trunk/admin/class-nginx-helper-admin.php (modified) (52 diffs)
-
trunk/admin/class-phpredis-purger.php (modified) (1 diff)
-
trunk/admin/class-predis-purger.php (modified) (1 diff)
-
trunk/admin/css/nginx-helper-admin.css (modified) (2 diffs)
-
trunk/admin/js/nginx-helper-admin.js (modified) (1 diff)
-
trunk/admin/partials/nginx-helper-general-options.php (modified) (9 diffs)
-
trunk/includes/class-nginx-helper-activator.php (modified) (1 diff)
-
trunk/includes/class-nginx-helper.php (modified) (3 diffs)
-
trunk/languages/nginx-helper.mo (modified) (previous)
-
trunk/languages/nginx-helper.po (modified) (4 diffs)
-
trunk/nginx-helper.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nginx-helper/tags/2.3.0/admin/class-fastcgi-purger.php
r3071366 r3213676 91 91 92 92 } 93 93 94 if( ( is_page() || is_single() ) && $nginx_helper_admin->options['purge_amp_urls'] ) { 95 $this->purge_amp_version( $url ); 96 } 97 98 } 99 100 /** 101 * Purge AMP version of a URL. 102 * 103 * @param string $url_base The base URL to purge. 104 */ 105 private function purge_amp_version( $url_base ) { 106 $amp_url = sprintf( '%s/amp/', rtrim( $url_base, '/' ) ); 107 108 $this->log( '- Purging AMP URL | ' . $amp_url ); 109 110 if ( 'unlink_files' === $this->nginx_helper_admin->options['purge_method'] ) { 111 $this->delete_cache_file_for( $amp_url ); 112 } else { 113 $this->do_remote_get( $amp_url ); 114 } 94 115 } 95 116 -
nginx-helper/tags/2.3.0/admin/class-nginx-helper-admin.php
r3071366 r3213676 21 21 */ 22 22 class Nginx_Helper_Admin { 23 23 24 24 /** 25 25 * The ID of this plugin. … … 30 30 */ 31 31 private $plugin_name; 32 32 33 33 /** 34 34 * The version of this plugin. … … 39 39 */ 40 40 private $version; 41 41 42 42 /** 43 43 * Various settings tabs. … … 48 48 */ 49 49 private $settings_tabs; 50 50 51 51 /** 52 52 * Purge options. … … 57 57 */ 58 58 public $options; 59 59 60 60 /** 61 61 * WP-CLI Command. … … 66 66 */ 67 67 const WP_CLI_COMMAND = 'nginx-helper'; 68 68 69 69 /** 70 70 * Initialize the class and set its properties. … … 75 75 */ 76 76 public function __construct( $plugin_name, $version ) { 77 77 78 78 $this->plugin_name = $plugin_name; 79 79 $this->version = $version; 80 80 81 $this->options = $this->nginx_helper_settings(); 82 } 83 84 /** 85 * Initialize the settings tab. 86 * Required since i18n is used in the settings tab which can be invoked only after init hook since WordPress 6.7 87 */ 88 public function initialize_setting_tab() { 89 81 90 /** 82 91 * Define settings tabs … … 95 104 ) 96 105 ); 97 98 $this->options = $this->nginx_helper_settings(); 99 100 } 101 106 } 107 102 108 /** 103 109 * Register the stylesheets for the admin area. … … 108 114 */ 109 115 public function enqueue_styles( $hook ) { 110 116 111 117 /** 112 118 * This function is provided for demonstration purposes only. … … 120 126 * class. 121 127 */ 122 128 123 129 if ( 'settings_page_nginx' !== $hook ) { 124 130 return; 125 131 } 126 132 127 133 wp_enqueue_style( $this->plugin_name . '-icons', plugin_dir_url( __FILE__ ) . 'icons/css/nginx-fontello.css', array(), $this->version, 'all' ); 128 134 wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/nginx-helper-admin.css', array(), $this->version, 'all' ); 129 130 } 131 135 136 } 137 132 138 /** 133 139 * Register the JavaScript for the admin area. … … 138 144 */ 139 145 public function enqueue_scripts( $hook ) { 140 146 141 147 /** 142 148 * This function is provided for demonstration purposes only. … … 150 156 * class. 151 157 */ 152 158 153 159 if ( 'settings_page_nginx' !== $hook ) { 154 160 return; 155 161 } 156 162 157 163 wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/nginx-helper-admin.js', array( 'jquery' ), $this->version, false ); 158 164 159 165 $do_localize = array( 160 166 'purge_confirm_string' => esc_html__( 'Purging entire cache is not recommended. Would you like to continue?', 'nginx-helper' ), 161 167 ); 162 168 wp_localize_script( $this->plugin_name, 'nginx_helper', $do_localize ); 163 164 } 165 169 170 } 171 166 172 /** 167 173 * Add admin menu. … … 170 176 */ 171 177 public function nginx_helper_admin_menu() { 172 178 173 179 if ( is_multisite() ) { 174 180 175 181 add_submenu_page( 176 182 'settings.php', … … 181 187 array( &$this, 'nginx_helper_setting_page' ) 182 188 ); 183 189 184 190 } else { 185 191 186 192 add_submenu_page( 187 193 'options-general.php', … … 192 198 array( &$this, 'nginx_helper_setting_page' ) 193 199 ); 194 195 } 196 197 } 198 200 201 } 202 203 } 204 199 205 /** 200 206 * Function to add toolbar purge link. … … 203 209 */ 204 210 public function nginx_helper_toolbar_purge_link( $wp_admin_bar ) { 205 211 206 212 if ( ! current_user_can( 'manage_options' ) ) { 207 213 return; 208 214 } 209 215 210 216 if ( is_admin() ) { 211 217 $nginx_helper_urls = 'all'; … … 215 221 $link_title = __( 'Purge Current Page', 'nginx-helper' ); 216 222 } 217 223 218 224 $purge_url = add_query_arg( 219 225 array( … … 222 228 ) 223 229 ); 224 230 225 231 $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' ); 226 232 227 233 $wp_admin_bar->add_menu( 228 234 array( … … 233 239 ) 234 240 ); 235 236 } 237 241 242 } 243 238 244 /** 239 245 * Display settings. … … 246 252 include plugin_dir_path( __FILE__ ) . 'partials/nginx-helper-admin-display.php'; 247 253 } 248 254 249 255 /** 250 256 * Default settings. … … 254 260 */ 255 261 public function nginx_helper_default_settings() { 256 262 257 263 return array( 258 264 'enable_purge' => 0, … … 276 282 'redis_hostname' => '127.0.0.1', 277 283 'redis_port' => '6379', 278 'redis_prefix' => 'nginx-cache:', 284 'redis_prefix' => 'nginx-cache:', 285 'redis_unix_socket' => '', 286 'redis_database' => 0, 287 'redis_username' => '', 288 'redis_password' => '', 279 289 'purge_url' => '', 280 290 'redis_enabled_by_constant' => 0, 291 'purge_amp_urls' => 1, 292 'redis_socket_enabled_by_constant' => 0, 293 'redis_acl_enabled_by_constant' => 0, 294 'preload_cache' => 0, 295 'is_cache_preloaded' => 0 281 296 ); 297 298 } 299 300 public function store_default_options() { 301 $options = get_site_option( 'rt_wp_nginx_helper_options', array() ); 302 $default_settings = $this->nginx_helper_default_settings(); 303 304 $removable_default_settings = array( 305 'redis_port', 306 'redis_prefix', 307 'redis_hostname', 308 'redis_database', 309 'redis_unix_socket' 310 ); 311 312 // Remove all the keys that are not to be stored by default. 313 foreach ( $removable_default_settings as $removable_key ) { 314 unset( $default_settings[ $removable_key ] ); 315 } 316 317 $diffed_options = wp_parse_args( $options, $default_settings ); 318 319 add_site_option( 'rt_wp_nginx_helper_options', $diffed_options ); 320 } 282 321 283 }284 285 322 /** 286 323 * Get settings. … … 289 326 */ 290 327 public function nginx_helper_settings() { 291 328 292 329 $options = get_site_option( 293 330 'rt_wp_nginx_helper_options', … … 296 333 'redis_port' => '6379', 297 334 'redis_prefix' => 'nginx-cache:', 335 'redis_database' => 0, 298 336 ) 299 337 ); 300 338 301 339 $data = wp_parse_args( 302 340 $options, 303 341 $this->nginx_helper_default_settings() 304 342 ); 305 343 306 344 $is_redis_enabled = ( 307 345 defined( 'RT_WP_NGINX_HELPER_REDIS_HOSTNAME' ) && … … 309 347 defined( 'RT_WP_NGINX_HELPER_REDIS_PREFIX' ) 310 348 ); 349 350 $data['redis_acl_enabled_by_constant'] = defined('RT_WP_NGINX_HELPER_REDIS_USERNAME') && defined('RT_WP_NGINX_HELPER_REDIS_PASSWORD'); 351 $data['redis_socket_enabled_by_constant'] = defined('RT_WP_NGINX_HELPER_REDIS_UNIX_SOCKET'); 352 $data['redis_unix_socket'] = $data['redis_socket_enabled_by_constant'] ? RT_WP_NGINX_HELPER_REDIS_UNIX_SOCKET : $data['redis_unix_socket']; 353 $data['redis_username'] = $data['redis_acl_enabled_by_constant'] ? RT_WP_NGINX_HELPER_REDIS_USERNAME : $data['redis_username']; 354 $data['redis_password'] = $data['redis_acl_enabled_by_constant'] ? RT_WP_NGINX_HELPER_REDIS_PASSWORD : $data['redis_password']; 311 355 312 356 if ( ! $is_redis_enabled ) { … … 314 358 } 315 359 316 $data['redis_enabled_by_constant'] = $is_redis_enabled; 317 $data['enable_purge'] = $is_redis_enabled; 318 $data['cache_method'] = 'enable_redis'; 319 $data['redis_hostname'] = RT_WP_NGINX_HELPER_REDIS_HOSTNAME; 320 $data['redis_port'] = RT_WP_NGINX_HELPER_REDIS_PORT; 321 $data['redis_prefix'] = RT_WP_NGINX_HELPER_REDIS_PREFIX; 360 $data['redis_enabled_by_constant'] = $is_redis_enabled; 361 $data['enable_purge'] = $is_redis_enabled; 362 $data['cache_method'] = 'enable_redis'; 363 $data['redis_hostname'] = RT_WP_NGINX_HELPER_REDIS_HOSTNAME; 364 $data['redis_port'] = RT_WP_NGINX_HELPER_REDIS_PORT; 365 $data['redis_prefix'] = RT_WP_NGINX_HELPER_REDIS_PREFIX; 366 $data['redis_database'] = defined('RT_WP_NGINX_HELPER_REDIS_DATABASE') ? RT_WP_NGINX_HELPER_REDIS_DATABASE : 0; 322 367 323 368 return $data; 324 325 } 326 369 370 } 371 327 372 /** 328 373 * Nginx helper setting link function. … … 333 378 */ 334 379 public function nginx_helper_settings_link( $links ) { 335 380 336 381 if ( is_network_admin() ) { 337 382 $setting_page = 'settings.php'; … … 339 384 $setting_page = 'options-general.php'; 340 385 } 341 386 342 387 $settings_link = '<a href="' . network_admin_url( $setting_page . '?page=nginx' ) . '">' . __( 'Settings', 'nginx-helper' ) . '</a>'; 343 388 array_unshift( $links, $settings_link ); 344 389 345 390 return $links; 346 347 } 348 391 392 } 393 349 394 /** 350 395 * Check if the nginx log is enabled. … … 354 399 */ 355 400 public function is_nginx_log_enabled() { 356 401 357 402 $options = get_site_option( 'rt_wp_nginx_helper_options', array() ); 358 403 359 404 if ( ! empty( $options['enable_log'] ) && 1 === (int) $options['enable_log'] ) { 360 405 return true; 361 406 } 362 407 363 408 if ( defined( 'NGINX_HELPER_LOG' ) && true === NGINX_HELPER_LOG ) { 364 409 return true; 365 410 } 366 411 367 412 return false; 368 413 } 369 414 370 415 /** 371 416 * Retrieve the asset path. … … 375 420 */ 376 421 public function functional_asset_path() { 377 422 378 423 $log_path = WP_CONTENT_DIR . '/uploads/nginx-helper/'; 379 424 380 425 return apply_filters( 'nginx_asset_path', $log_path ); 381 382 } 383 426 427 } 428 384 429 /** 385 430 * Retrieve the asset url. … … 389 434 */ 390 435 public function functional_asset_url() { 391 436 392 437 $log_url = WP_CONTENT_URL . '/uploads/nginx-helper/'; 393 438 394 439 return apply_filters( 'nginx_asset_url', $log_url ); 395 396 } 397 440 441 } 442 398 443 /** 399 444 * Get latest news. … … 402 447 */ 403 448 public function nginx_helper_get_feeds() { 404 449 405 450 // Get RSS Feed(s). 406 451 require_once ABSPATH . WPINC . '/feed.php'; 407 452 408 453 $maxitems = 0; 409 454 $rss_items = array(); 410 455 411 456 // Get a SimplePie feed object from the specified feed source. 412 457 $rss = fetch_feed( 'https://rtcamp.com/blog/feed/' ); 413 458 414 459 if ( ! is_wp_error( $rss ) ) { // Checks that the object is created correctly. 415 460 416 461 // Figure out how many total items there are, but limit it to 5. 417 462 $maxitems = $rss->get_item_quantity( 5 ); 418 463 // Build an array of all the items, starting with element 0 (first element). 419 464 $rss_items = $rss->get_items( 0, $maxitems ); 420 465 421 466 } 422 467 ?> … … 426 471 echo '<li role="listitem">' . esc_html_e( 'No items', 'nginx-helper' ) . '.</li>'; 427 472 } else { 428 473 429 474 // Loop through each feed item and display each item as a hyperlink. 430 475 foreach ( $rss_items as $item ) { 431 476 ?> 432 <li role="listitem">433 <?php434 printf(435 '<a href="%s" title="%s">%s</a>',436 esc_url( $item->get_permalink() ),437 esc_attr__( 'Posted ', 'nginx-helper' ) . esc_attr( $item->get_date( 'j F Y | g:i a' ) ),438 esc_html( $item->get_title() )439 );440 ?>441 </li>477 <li role="listitem"> 478 <?php 479 printf( 480 '<a href="%s" title="%s">%s</a>', 481 esc_url( $item->get_permalink() ), 482 esc_attr__( 'Posted ', 'nginx-helper' ) . esc_attr( $item->get_date( 'j F Y | g:i a' ) ), 483 esc_html( $item->get_title() ) 484 ); 485 ?> 486 </li> 442 487 <?php 443 488 } … … 447 492 <?php 448 493 die(); 449 450 } 451 494 495 } 496 452 497 /** 453 498 * Add time stamps in html. 454 499 */ 455 500 public function add_timestamps() { 456 501 457 502 global $pagenow; 458 503 459 504 if ( is_admin() || 1 !== (int) $this->options['enable_purge'] || 1 !== (int) $this->options['enable_stamp'] ) { 460 505 return; 461 506 } 462 507 463 508 if ( ! empty( $pagenow ) && 'wp-login.php' === $pagenow ) { 464 509 return; 465 510 } 466 511 467 512 foreach ( headers_list() as $header ) { 468 513 list( $key, $value ) = explode( ':', $header, 2 ); … … 475 520 } 476 521 } 477 522 478 523 /** 479 524 * Don't add timestamp if run from ajax, cron or wpcli. … … 482 527 return; 483 528 } 484 529 485 530 if ( defined( 'DOING_CRON' ) && DOING_CRON ) { 486 531 return; 487 532 } 488 533 489 534 if ( defined( 'WP_CLI' ) && WP_CLI ) { 490 535 return; 491 536 } 492 537 493 538 $timestamps = "\n<!--" . 494 'Cached using Nginx-Helper on ' . current_time( 'mysql' ) . '. ' .495 'It took ' . get_num_queries() . ' queries executed in ' . timer_stop() . ' seconds.' .496 "-->\n" .497 '<!--Visit http://wordpress.org/extend/plugins/nginx-helper/faq/ for more details-->';498 539 'Cached using Nginx-Helper on ' . current_time( 'mysql' ) . '. ' . 540 'It took ' . get_num_queries() . ' queries executed in ' . timer_stop() . ' seconds.' . 541 "-->\n" . 542 '<!--Visit http://wordpress.org/extend/plugins/nginx-helper/faq/ for more details-->'; 543 499 544 echo wp_kses( $timestamps, array() ); 500 501 } 502 545 546 } 547 503 548 /** 504 549 * Get map … … 509 554 */ 510 555 public function get_map() { 511 556 512 557 if ( ! $this->options['enable_map'] ) { 513 558 return; 514 559 } 515 560 516 561 if ( is_multisite() ) { 517 562 518 563 global $wpdb; 519 564 520 565 $rt_all_blogs = $wpdb->get_results( 521 566 $wpdb->prepare( … … 524 569 ) 525 570 ); 526 571 527 572 $wpdb->dmtable = $wpdb->base_prefix . 'domain_mapping'; 528 573 529 574 $rt_domain_map_sites = ''; 530 575 531 576 if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->dmtable}'" ) === $wpdb->dmtable ) { // phpcs:ignore 532 577 $rt_domain_map_sites = $wpdb->get_results( "SELECT blog_id, domain FROM {$wpdb->dmtable} ORDER BY id DESC" ); 533 578 } 534 579 535 580 $rt_nginx_map = ''; 536 581 $rt_nginx_map_array = array(); 537 582 538 583 if ( $rt_all_blogs ) { 539 584 540 585 foreach ( $rt_all_blogs as $blog ) { 541 586 542 587 if ( true === SUBDOMAIN_INSTALL ) { 543 588 $rt_nginx_map_array[ $blog->domain ] = $blog->blog_id; 544 589 } else { 545 590 546 591 if ( 1 !== $blog->blog_id ) { 547 592 $rt_nginx_map_array[ $blog->path ] = $blog->blog_id; … … 550 595 } 551 596 } 552 597 553 598 if ( $rt_domain_map_sites ) { 554 599 555 600 foreach ( $rt_domain_map_sites as $site ) { 556 601 $rt_nginx_map_array[ $site->domain ] = $site->blog_id; 557 602 } 558 603 } 559 604 560 605 foreach ( $rt_nginx_map_array as $domain => $domain_id ) { 561 606 $rt_nginx_map .= "\t" . $domain . "\t" . $domain_id . ";\n"; 562 607 } 563 608 564 609 return $rt_nginx_map; 565 566 } 567 568 } 569 610 611 } 612 613 } 614 570 615 /** 571 616 * Update map 572 617 */ 573 618 public function update_map() { 574 619 575 620 if ( is_multisite() ) { 576 621 577 622 $rt_nginx_map = $this->get_map(); 578 623 579 624 $fp = fopen( $this->functional_asset_path() . 'map.conf', 'w+' ); 580 625 if ( $fp ) { … … 583 628 } 584 629 } 585 586 } 587 630 631 } 632 588 633 /** 589 634 * Purge url when post status is changed. … … 597 642 */ 598 643 public function set_future_post_option_on_future_status( $new_status, $old_status, $post ) { 599 644 600 645 global $blog_id, $nginx_purger; 601 646 602 647 $exclude_post_types = array( 'nav_menu_item' ); 603 648 604 649 if ( in_array( $post->post_type, $exclude_post_types, true ) ) { 605 650 return; 606 651 } 607 608 if ( ! $this->options['enable_purge'] ) {609 return; 610 } 611 652 653 if ( ! $this->options['enable_purge'] || $this->is_import_request() ) { 654 return; 655 } 656 612 657 $purge_status = array( 'publish', 'future' ); 613 658 614 659 if ( in_array( $old_status, $purge_status, true ) || in_array( $new_status, $purge_status, true ) ) { 615 660 616 661 $nginx_purger->log( 'Purge post on transition post STATUS from ' . $old_status . ' to ' . $new_status ); 617 662 $nginx_purger->purge_post( $post->ID ); 618 619 } 620 663 664 } 665 621 666 if ( 622 667 'future' === $new_status && $post && 'future' === $post->post_status && … … 629 674 ) 630 675 ) { 631 676 632 677 $nginx_purger->log( 'Set/update future_posts option ( post id = ' . $post->ID . ' and blog id = ' . $blog_id . ' )' ); 633 678 $this->options['future_posts'][ $blog_id ][ $post->ID ] = strtotime( $post->post_date_gmt ) + 60; 634 679 update_site_option( 'rt_wp_nginx_helper_options', $this->options ); 635 636 } 637 638 } 639 680 681 } 682 683 } 684 640 685 /** 641 686 * Unset future post option on delete … … 647 692 */ 648 693 public function unset_future_post_option_on_delete( $post_id ) { 649 694 650 695 global $blog_id, $nginx_purger; 651 696 652 697 if ( 653 698 ! $this->options['enable_purge'] || … … 659 704 return; 660 705 } 661 706 662 707 $nginx_purger->log( 'Unset future_posts option ( post id = ' . $post_id . ' and blog id = ' . $blog_id . ' )' ); 663 708 664 709 unset( $this->options['future_posts'][ $blog_id ][ $post_id ] ); 665 710 666 711 if ( ! count( $this->options['future_posts'][ $blog_id ] ) ) { 667 712 unset( $this->options['future_posts'][ $blog_id ] ); 668 713 } 669 714 670 715 update_site_option( 'rt_wp_nginx_helper_options', $this->options ); 671 716 } 672 717 673 718 /** 674 719 * Update map when new blog added in multisite. … … 679 724 */ 680 725 public function update_new_blog_options( $blog_id ) { 681 726 682 727 global $nginx_purger; 683 728 684 729 $nginx_purger->log( "New site added ( id $blog_id )" ); 685 730 $this->update_map(); … … 688 733 update_blog_option( $blog_id, 'rt_wp_nginx_helper_options', $helper_options ); 689 734 $nginx_purger->log( "Default options updated for the new blog ( id $blog_id )" ); 690 691 } 692 735 736 } 737 693 738 /** 694 739 * Purge all urls. … … 699 744 */ 700 745 public function purge_all() { 701 746 747 if ( $this->is_import_request() ) { 748 return; 749 } 750 702 751 global $nginx_purger, $wp; 703 752 704 753 $method = null; 705 754 if ( isset( $_SERVER['REQUEST_METHOD'] ) ) { 706 755 $method = wp_strip_all_tags( $_SERVER['REQUEST_METHOD'] ); 707 756 } 708 757 709 758 $action = ''; 710 759 if ( 'POST' === $method ) { … … 717 766 } 718 767 } 719 768 720 769 if ( empty( $action ) ) { 721 770 return; 722 771 } 723 772 724 773 if ( ! current_user_can( 'manage_options' ) ) { 725 774 wp_die( 'Sorry, you do not have the necessary privileges to edit these options.' ); 726 775 } 727 776 728 777 if ( 'done' === $action ) { 729 778 730 779 add_action( 'admin_notices', array( &$this, 'display_notices' ) ); 731 780 add_action( 'network_admin_notices', array( &$this, 'display_notices' ) ); 732 781 return; 733 734 } 735 782 783 } 784 736 785 check_admin_referer( 'nginx_helper-purge_all' ); 737 786 738 787 $current_url = user_trailingslashit( home_url( $wp->request ) ); 739 788 740 789 if ( ! is_admin() ) { 741 790 $action = 'purge_current_page'; … … 744 793 $redirect_url = add_query_arg( array( 'nginx_helper_action' => 'done' ) ); 745 794 } 746 795 747 796 switch ( $action ) { 748 797 case 'purge': … … 753 802 break; 754 803 } 755 804 756 805 if ( 'purge' === $action ) { 757 806 758 807 /** 759 808 * Fire an action after the entire cache has been purged whatever caching type is used. … … 762 811 */ 763 812 do_action( 'rt_nginx_helper_after_purge_all' ); 764 765 } 766 813 814 } 815 767 816 wp_redirect( esc_url_raw( $redirect_url ) ); 768 817 exit(); 769 770 } 771 818 819 } 820 772 821 /** 773 822 * Dispay plugin notices. … … 776 825 echo '<div class="updated"><p>' . esc_html__( 'Purge initiated', 'nginx-helper' ) . '</p></div>'; 777 826 } 778 827 828 /** 829 * Preloads the cache for the website. 830 * 831 * @return void 832 */ 833 public function preload_cache() { 834 $is_cache_preloaded = $this->options['is_cache_preloaded']; 835 $preload_cache_enabled = $this->options['preload_cache']; 836 837 if ( $preload_cache_enabled && false === boolval( $is_cache_preloaded ) ) { 838 $this->options['is_cache_preloaded'] = true; 839 840 update_site_option( 'rt_wp_nginx_helper_options', $this->options ); 841 $this->preload_cache_from_sitemap(); 842 } 843 } 844 845 /** 846 * This function preloads the cache from sitemap url. 847 * 848 * @return void 849 */ 850 private function preload_cache_from_sitemap() { 851 852 $sitemap_urls = $this->get_index_sitemap_urls(); 853 $all_urls = array(); 854 855 foreach ( $sitemap_urls as $sitemap_url ) { 856 $urls = $this->extract_sitemap_urls( $sitemap_url ); 857 $all_urls = array_merge( $all_urls, $urls ); 858 } 859 860 $args = array( 861 'timeout' => 1, 862 'blocking' => false, 863 'sslverify' => false, 864 ); 865 866 foreach ( $all_urls as $url ) { 867 wp_remote_get( esc_url_raw( $url ), $args ); 868 } 869 870 } 871 872 /** 873 * Fetches all the sitemap urls for the site. 874 * 875 * @return array 876 */ 877 private function get_index_sitemap_urls() { 878 $sitemaps = wp_sitemaps_get_server()->index->get_sitemap_list(); 879 $urls = array(); 880 foreach ( $sitemaps as $sitemap ) { 881 $urls[] = $sitemap['loc']; 882 } 883 return $urls; 884 } 885 886 /** 887 * Parse sitemap content and extract all URLs. 888 * 889 * @param string $sitemap_url The URL of the sitemap. 890 * @return array|WP_Error An array of URLs or WP_Error on failure. 891 */ 892 private function extract_sitemap_urls( $sitemap_url ) { 893 $response = wp_remote_get( $sitemap_url ); 894 895 $urls = array(); 896 897 if ( is_wp_error( $response ) ) { 898 return $urls; 899 } 900 901 $sitemap_content = wp_remote_retrieve_body( $response ); 902 903 libxml_use_internal_errors( true ); 904 $xml = simplexml_load_string( $sitemap_content ); 905 906 if ( false === $xml ) { 907 return new WP_Error( 'sitemap_parse_error', esc_html__( 'Failed to parse the sitemap XML', 'nginx-helper' ) ); 908 } 909 910 $urls = array(); 911 912 if ( false === $xml ) { 913 return $urls; 914 } 915 916 foreach ( $xml->url as $url ) { 917 $urls[] = (string) $url->loc; 918 } 919 920 return $urls; 921 } 922 923 /** 924 * Determines if the current request is for importing Posts/ WordPress content. 925 * 926 * @return bool True if the request is for importing, false otherwise. 927 */ 928 public function is_import_request() { 929 $import_query_var = sanitize_text_field( wp_unslash( $_GET['import'] ?? '' ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is already in the admin dashboard. 930 $has_import_started = did_action( 'import_start' ); 931 932 return ( defined( 'WP_IMPORTING' ) && true === WP_IMPORTING ) 933 || 0 !== $has_import_started 934 || ! empty( $import_query_var ); 935 } 936 937 779 938 } -
nginx-helper/tags/2.3.0/admin/class-phpredis-purger.php
r2222658 r3213676 40 40 41 41 $this->redis_object = new Redis(); 42 43 $redis_acl = array(); 44 45 $username = $nginx_helper_admin->options['redis_username']; 46 $password = $nginx_helper_admin->options['redis_password']; 47 48 if( $username && $password ) { 49 $redis_acl['auth'] = array( $username, $password ); 50 } 51 52 $hostname = empty( $nginx_helper_admin->options['redis_unix_socket'] ) ? $nginx_helper_admin->options['redis_hostname'] : $nginx_helper_admin->options['redis_unix_socket']; 53 $port = empty( $nginx_helper_admin->options['redis_unix_socket'] ) ? $nginx_helper_admin->options['redis_port'] : 0; 54 42 55 $this->redis_object->connect( 43 $nginx_helper_admin->options['redis_hostname'], 44 $nginx_helper_admin->options['redis_port'], 45 5 56 $hostname, 57 $port, 58 5, 59 null, 60 0, 61 0, 62 $redis_acl 46 63 ); 64 65 if( $nginx_helper_admin->options['redis_database'] !== 0 ) { 66 $this->redis_object->select($nginx_helper_admin->options['redis_database']); 67 } 47 68 48 69 } catch ( Exception $e ) { -
nginx-helper/tags/2.3.0/admin/class-predis-purger.php
r2222658 r3213676 38 38 39 39 Predis\Autoloader::register(); 40 40 41 $predis_args = array(); 42 43 $username = $nginx_helper_admin->options['redis_username']; 44 $password = $nginx_helper_admin->options['redis_password']; 45 46 if( ! empty( $nginx_helper_admin->options['redis_unix_socket'] ) ) { 47 $predis_args['path'] = $nginx_helper_admin->options['redis_unix_socket']; 48 } else { 49 $predis_args['host'] = $nginx_helper_admin->options['redis_hostname'];; 50 $predis_args['port'] = $nginx_helper_admin->options['redis_port']; 51 } 52 53 if ( $username && $password ) { 54 $predis_args['username'] = $username; 55 $predis_args['password'] = $password; 56 } 57 41 58 // redis server parameter. 42 $this->redis_object = new Predis\Client( 43 array( 44 'host' => $nginx_helper_admin->options['redis_hostname'], 45 'port' => $nginx_helper_admin->options['redis_port'], 46 ) 47 ); 59 $this->redis_object = new Predis\Client( $predis_args ); 48 60 49 61 try { 50 62 $this->redis_object->connect(); 63 64 if( 0 !== $nginx_helper_admin->options['redis_database'] ) { 65 $this->redis_object->select( $nginx_helper_admin->options['redis_database'] ); 66 } 51 67 } catch ( Exception $e ) { 52 68 $this->log( $e->getMessage(), 'ERROR' ); 53 } 69 return; 70 } 71 54 72 55 73 } -
nginx-helper/tags/2.3.0/admin/css/nginx-helper-admin.css
r3023296 r3213676 5 5 6 6 .clearfix { 7 *zoom: 1;7 zoom: 1; 8 8 } 9 9 .clearfix:before, … … 104 104 margin-left: 23px; 105 105 } 106 107 .password-input { 108 padding-right: 40px; 109 } 110 111 .password-show-hide-btn { 112 background-color: transparent; 113 border: 0; 114 cursor: pointer; 115 display: inline-block; 116 } 117 118 .password-wrapper { 119 display: flex; 120 } -
nginx-helper/tags/2.3.0/admin/js/nginx-helper-admin.js
r2222658 r3213676 76 76 ); 77 77 78 jQuery('.password-show-hide-btn').on('click', function() { 79 var passwordInput = $(this).siblings('.password-input'); 80 var icon = $(this).find('.password-input-icon'); 81 82 if (passwordInput.attr('type') === 'password') { 83 passwordInput.attr('type', 'text'); 84 icon.removeClass('dashicons-hidden').addClass('dashicons-visibility'); 85 } else { 86 passwordInput.attr('type', 'password'); 87 icon.removeClass('dashicons-visibility').addClass('dashicons-hidden'); 88 } 89 }); 90 78 91 /** 79 92 * Show OR Hide options on option checkbox -
nginx-helper/tags/2.3.0/admin/partials/nginx-helper-general-options.php
r3071366 r3213676 23 23 'redis_port', 24 24 'redis_prefix', 25 'redis_database', 26 'redis_username', 27 'redis_password', 28 'redis_unix_socket', 29 'redis_socket_enabled_by_constant', 30 'redis_acl_enabled_by_constant', 25 31 'purge_homepage_on_edit', 26 32 'purge_homepage_on_del', … … 41 47 'purge_feeds', 42 48 'smart_http_expire_form_nonce', 49 'purge_amp_urls', 50 'preload_cache', 43 51 ); 44 52 … … 125 133 <input type="checkbox" value="1" id="enable_purge" name="enable_purge" <?php checked( $nginx_helper_settings['enable_purge'], 1 ); ?> /> 126 134 <label for="enable_purge"><?php esc_html_e( 'Enable Purge', 'nginx-helper' ); ?></label> 135 </td> 136 </tr> 137 <tr valign="top"> 138 <td> 139 <input type="checkbox" value="1" id="preload_cache" name="preload_cache" <?php checked( $nginx_helper_settings['preload_cache'], 1 ); ?> /> 140 <label for="preload_cache"><?php esc_html_e( 'Preload Cache', 'nginx-helper' ); ?></label> 127 141 </td> 128 142 </tr> … … 247 261 <th><label for="redis_hostname"><?php esc_html_e( 'Hostname', 'nginx-helper' ); ?></label></th> 248 262 <td> 249 <input id="redis_hostname" class="medium-text" type="text" name="redis_hostname" value="<?php echo esc_attr( $nginx_helper_settings['redis_hostname'] ); ?>" <?php echo ( $nginx_helper_settings['redis_enabled_by_constant'] ) ? 'readonly="readonly"' : ''; ?> />263 <input id="redis_hostname" class="medium-text" type="text" name="redis_hostname" value="<?php echo esc_attr( $nginx_helper_settings['redis_hostname'] ); ?>" <?php echo ( $nginx_helper_settings['redis_enabled_by_constant'] || $nginx_helper_settings['redis_unix_socket'] ) ? 'readonly="readonly"' : ''; ?> /> 250 264 <?php 251 265 if ( $nginx_helper_settings['redis_enabled_by_constant'] ) { … … 255 269 echo '</p>'; 256 270 271 } 272 ?> 273 <?php 274 if ( $nginx_helper_settings['redis_unix_socket'] ) { 275 echo '<p class="description">'; 276 esc_html_e( 'Overridden by unix socket path.', 'nginx-helper' ); 277 echo '</p>'; 257 278 } 258 279 ?> … … 262 283 <th><label for="redis_port"><?php esc_html_e( 'Port', 'nginx-helper' ); ?></label></th> 263 284 <td> 264 <input id="redis_port" class="medium-text" type="text" name="redis_port" value="<?php echo esc_attr( $nginx_helper_settings['redis_port'] ); ?>" <?php echo ( $nginx_helper_settings['redis_enabled_by_constant'] ) ? 'readonly="readonly"' : ''; ?> />285 <input id="redis_port" class="medium-text" type="text" name="redis_port" value="<?php echo esc_attr( $nginx_helper_settings['redis_port'] ); ?>" <?php echo ( $nginx_helper_settings['redis_enabled_by_constant'] || $nginx_helper_settings['redis_unix_socket'] ) ? 'readonly="readonly"' : ''; ?> /> 265 286 <?php 266 287 if ( $nginx_helper_settings['redis_enabled_by_constant'] ) { … … 270 291 echo '</p>'; 271 292 293 } 294 ?> 295 <?php 296 if ( $nginx_helper_settings['redis_unix_socket'] ) { 297 298 echo '<p class="description">'; 299 esc_html_e( 'Overridden by unix socket path.', 'nginx-helper' ); 300 echo '</p>'; 301 302 } 303 ?> 304 </td> 305 </tr> 306 <tr> 307 <th><label for="redis_unix_socket"><?php esc_html_e( 'Socket Path', 'nginx-helper' ); ?></label></th> 308 <td> 309 <input id="redis_unix_socket" class="medium-text" type="text" name="redis_unix_socket" value="<?php echo esc_attr( $nginx_helper_settings['redis_unix_socket'] ); ?>" <?php echo ( $nginx_helper_settings['redis_socket_enabled_by_constant'] ) ? 'readonly="readonly"' : ''; ?> /> 310 <?php 311 if ( $nginx_helper_settings['redis_socket_enabled_by_constant'] ) { 312 313 echo '<p class="description">'; 314 esc_html_e( 'Overridden by constant variables.', 'nginx-helper' ); 315 echo '</p>'; 316 272 317 } 273 318 ?> … … 285 330 echo '</p>'; 286 331 332 } 333 ?> 334 </td> 335 </tr> 336 <tr> 337 <th><label for="redis_database"><?php esc_html_e( 'Database', 'nginx-helper' ); ?></label></th> 338 <td> 339 <input id="redis_database" class="medium-text" type="text" name="redis_database" value="<?php echo esc_attr( $nginx_helper_settings['redis_database'] ); ?>" <?php echo ( $nginx_helper_settings['redis_enabled_by_constant'] ) ? 'readonly="readonly"' : ''; ?> /> 340 <?php 341 if ( $nginx_helper_settings['redis_enabled_by_constant'] ) { 342 343 echo '<p class="description">'; 344 esc_html_e( 'Overridden by constant variables.', 'nginx-helper' ); 345 echo '</p>'; 346 347 } 348 ?> 349 </td> 350 </tr> 351 352 <tr> 353 <th><label for="redis_username"><?php esc_html_e( 'Username', 'nginx-helper' ); ?></label></th> 354 <td> 355 <input id="redis_username" class="medium-text" type="text" name="redis_username" value="<?php echo esc_attr( $nginx_helper_settings['redis_username'] ); ?>" <?php echo ( $nginx_helper_settings['redis_enabled_by_constant'] ) ? 'readonly="readonly"' : ''; ?> /> 356 <?php 357 if ( $nginx_helper_settings['redis_enabled_by_constant'] ) { 358 359 echo '<p class="description">'; 360 esc_html_e( 'Overridden by constant variables.', 'nginx-helper' ); 361 echo '</p>'; 362 363 } 364 ?> 365 </td> 366 </tr> 367 368 <tr> 369 <th><label for="redis_password"><?php esc_html_e( 'Password', 'nginx-helper' ); ?></label></th> 370 <td> 371 <div class="password-wrapper"> 372 <input id="redis_password" class="medium-text password-input" type="password" name="redis_password" value="<?php echo esc_attr( $nginx_helper_settings['redis_password'] ); ?>" <?php echo ( $nginx_helper_settings['redis_enabled_by_constant'] ) ? 'readonly="readonly"' : ''; ?> /> 373 <button type="button" class="password-show-hide-btn"><span class="dashicons dashicons-hidden password-input-icon"></span></button> 374 </div> 375 <?php 376 if ( $nginx_helper_settings['redis_enabled_by_constant'] ) { 377 echo '<p class="description">'; 378 esc_html_e( 'Overridden by constant variables.', 'nginx-helper' ); 379 echo '</p>'; 380 287 381 } 288 382 ?> … … 542 636 array( 'strong' => array() ) 543 637 ); 638 ?> 639 </label> 640 <br /> 641 </fieldset> 642 </td> 643 </tr> 644 </table> 645 <table class="form-table rtnginx-table"> 646 <tr valign="top"> 647 <th scope="row"> 648 <h4> 649 <?php esc_html_e( 'Purge AMP URL:', 'nginx-helper' ); ?> 650 </h4> 651 </th> 652 <td> 653 <fieldset> 654 <legend class="screen-reader-text"> 655 <span> 656 657 <?php 658 esc_html_e( 'purge amp urls', 'nginx-helper' ); 659 ?> 660 </span> 661 </legend> 662 <label for="purge_amp_urls"> 663 <input type="checkbox" value="1" id="purge_amp_urls" name="purge_amp_urls" <?php checked( $nginx_helper_settings['purge_amp_urls'], 1 ); ?> /> 664 665 <?php 666 echo wp_kses( 667 __( 'purge <strong>amp urls</strong> along with <strong>posts</strong> & <strong>pages</strong>.', 'nginx-helper' ), 668 array( 'strong' => array() ) 669 ); 544 670 ?> 545 671 </label> -
nginx-helper/tags/2.3.0/includes/class-nginx-helper-activator.php
r1976548 r3213676 58 58 59 59 wp_schedule_event( time(), 'daily', 'rt_wp_nginx_helper_check_log_file_size_daily' ); 60 61 if( method_exists( $nginx_helper_admin, 'store_default_options' ) ) { 62 $nginx_helper_admin->store_default_options(); 63 } 60 64 61 65 } -
nginx-helper/tags/2.3.0/includes/class-nginx-helper.php
r3071366 r3213676 78 78 79 79 $this->plugin_name = 'nginx-helper'; 80 $this->version = '2. 2.5';80 $this->version = '2.3.0'; 81 81 $this->minimum_wp = '3.0'; 82 82 … … 170 170 171 171 $nginx_helper_admin = new Nginx_Helper_Admin( $this->get_plugin_name(), $this->get_version() ); 172 172 $this->loader->add_action( 'init', $nginx_helper_admin, 'initialize_setting_tab' ); 173 173 // Defines global variables. 174 174 if ( ! empty( $nginx_helper_admin->options['cache_method'] ) && 'enable_redis' === $nginx_helper_admin->options['cache_method'] ) { … … 228 228 // expose action to allow other plugins to purge the cache. 229 229 $this->loader->add_action( 'rt_nginx_helper_purge_all', $nginx_purger, 'purge_all' ); 230 231 // add action to preload the cache 232 $this->loader->add_action( 'admin_init', $nginx_helper_admin, 'preload_cache' ); 230 233 } 231 234 -
nginx-helper/tags/2.3.0/languages/nginx-helper.po
r3071366 r3213676 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Nginx Helper 2. 2.5\n"5 "Project-Id-Version: Nginx Helper 2.3.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/nginx-helper\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2024- 04-15T10:26:40+00:00\n"12 "POT-Creation-Date: 2024-12-19T06:01:42+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 "X-Generator: WP-CLI 2. 9.0\n"14 "X-Generator: WP-CLI 2.11.0\n" 15 15 "X-Domain: nginx-helper\n" 16 16 17 17 #. Plugin Name of the plugin 18 #: admin/class-nginx-helper-admin.php:177 19 #: admin/class-nginx-helper-admin.php:178 20 #: admin/class-nginx-helper-admin.php:188 21 #: admin/class-nginx-helper-admin.php:189 18 #: nginx-helper.php 19 #: admin/class-nginx-helper-admin.php:183 20 #: admin/class-nginx-helper-admin.php:184 21 #: admin/class-nginx-helper-admin.php:194 22 #: admin/class-nginx-helper-admin.php:195 22 23 msgid "Nginx Helper" 23 24 msgstr "" 24 25 25 26 #. Plugin URI of the plugin 27 #: nginx-helper.php 26 28 msgid "https://rtcamp.com/nginx-helper/" 27 29 msgstr "" 28 30 29 31 #. Description of the plugin 32 #: nginx-helper.php 30 33 msgid "Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does few more things." 31 34 msgstr "" 32 35 33 36 #. Author of the plugin 37 #: nginx-helper.php 34 38 msgid "rtCamp" 35 39 msgstr "" 36 40 37 41 #. Author URI of the plugin 42 #: nginx-helper.php 38 43 msgid "https://rtcamp.com" 39 44 msgstr "" 40 45 41 #: admin/class-nginx-helper-admin.php: 8846 #: admin/class-nginx-helper-admin.php:97 42 47 msgid "General" 43 48 msgstr "" 44 49 45 #: admin/class-nginx-helper-admin.php: 9250 #: admin/class-nginx-helper-admin.php:101 46 51 msgid "Support" 47 52 msgstr "" 48 53 49 #: admin/class-nginx-helper-admin.php:16 054 #: admin/class-nginx-helper-admin.php:166 50 55 msgid "Purging entire cache is not recommended. Would you like to continue?" 51 56 msgstr "" 52 57 53 #: admin/class-nginx-helper-admin.php:21 258 #: admin/class-nginx-helper-admin.php:218 54 59 msgid "Purge Cache" 55 60 msgstr "" 56 61 57 #: admin/class-nginx-helper-admin.php:2 1562 #: admin/class-nginx-helper-admin.php:221 58 63 msgid "Purge Current Page" 59 64 msgstr "" 60 65 61 #: admin/class-nginx-helper-admin.php:3 4266 #: admin/class-nginx-helper-admin.php:387 62 67 msgid "Settings" 63 68 msgstr "" 64 69 65 #: admin/class-nginx-helper-admin.php:4 2670 #: admin/class-nginx-helper-admin.php:471 66 71 msgid "No items" 67 72 msgstr "" 68 73 69 #: admin/class-nginx-helper-admin.php:4 3774 #: admin/class-nginx-helper-admin.php:482 70 75 msgid "Posted " 71 76 msgstr "" 72 77 73 #: admin/class-nginx-helper-admin.php: 77678 #: admin/class-nginx-helper-admin.php:825 74 79 msgid "Purge initiated" 80 msgstr "" 81 82 #: admin/class-nginx-helper-admin.php:907 83 msgid "Failed to parse the sitemap XML" 75 84 msgstr "" 76 85 … … 237 246 msgstr "" 238 247 239 #: admin/partials/nginx-helper-general-options.php: 82248 #: admin/partials/nginx-helper-general-options.php:90 240 249 msgid "Log file size must be a number." 241 250 msgstr "" 242 251 243 #: admin/partials/nginx-helper-general-options.php: 92252 #: admin/partials/nginx-helper-general-options.php:100 244 253 msgid "Settings saved." 245 254 msgstr "" 246 255 247 #: admin/partials/nginx-helper-general-options.php:1 19256 #: admin/partials/nginx-helper-general-options.php:127 248 257 msgid "Purging Options" 249 258 msgstr "" 250 259 251 #: admin/partials/nginx-helper-general-options.php:1 26260 #: admin/partials/nginx-helper-general-options.php:134 252 261 msgid "Enable Purge" 253 262 msgstr "" 254 263 255 #: admin/partials/nginx-helper-general-options.php:136 264 #: admin/partials/nginx-helper-general-options.php:140 265 msgid "Preload Cache" 266 msgstr "" 267 268 #: admin/partials/nginx-helper-general-options.php:150 256 269 msgid "Caching Method" 257 270 msgstr "" 258 271 259 #: admin/partials/nginx-helper-general-options.php:1 48272 #: admin/partials/nginx-helper-general-options.php:162 260 273 msgid "nginx Fastcgi cache" 261 274 msgstr "" 262 275 263 #: admin/partials/nginx-helper-general-options.php:1 50276 #: admin/partials/nginx-helper-general-options.php:164 264 277 msgid "External settings for nginx" 265 278 msgstr "" 266 279 267 #: admin/partials/nginx-helper-general-options.php:1 51280 #: admin/partials/nginx-helper-general-options.php:165 268 281 msgid "requires external settings for nginx" 269 282 msgstr "" 270 283 271 #: admin/partials/nginx-helper-general-options.php:1 61284 #: admin/partials/nginx-helper-general-options.php:175 272 285 msgid "Redis cache" 273 286 msgstr "" 274 287 275 #: admin/partials/nginx-helper-general-options.php:1 71288 #: admin/partials/nginx-helper-general-options.php:185 276 289 msgid "Purge Method" 277 290 msgstr "" 278 291 279 #: admin/partials/nginx-helper-general-options.php:1 81280 #: admin/partials/nginx-helper-general-options.php: 361292 #: admin/partials/nginx-helper-general-options.php:195 293 #: admin/partials/nginx-helper-general-options.php:455 281 294 msgid "when a post/page/custom post is published." 282 295 msgstr "" 283 296 284 #: admin/partials/nginx-helper-general-options.php: 191297 #: admin/partials/nginx-helper-general-options.php:205 285 298 msgid "Using a GET request to" 286 299 msgstr "" 287 300 288 #: admin/partials/nginx-helper-general-options.php: 192301 #: admin/partials/nginx-helper-general-options.php:206 289 302 msgid "(Default option)" 290 303 msgstr "" 291 304 292 305 #. translators: %s Nginx cache purge module link. 293 #: admin/partials/nginx-helper-general-options.php:2 03306 #: admin/partials/nginx-helper-general-options.php:217 294 307 msgid "Uses the %s module." 295 308 msgstr "" 296 309 297 #: admin/partials/nginx-helper-general-options.php:2 21310 #: admin/partials/nginx-helper-general-options.php:235 298 311 msgid "Delete local server cache files" 299 312 msgstr "" 300 313 301 #: admin/partials/nginx-helper-general-options.php:2 27314 #: admin/partials/nginx-helper-general-options.php:241 302 315 msgid "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\")." 303 316 msgstr "" 304 317 305 #: admin/partials/nginx-helper-general-options.php:2 42318 #: admin/partials/nginx-helper-general-options.php:256 306 319 msgid "Redis Settings" 307 320 msgstr "" 308 321 309 #: admin/partials/nginx-helper-general-options.php:2 47322 #: admin/partials/nginx-helper-general-options.php:261 310 323 msgid "Hostname" 311 324 msgstr "" 312 325 313 #: admin/partials/nginx-helper-general-options.php:254 314 #: admin/partials/nginx-helper-general-options.php:269 315 #: admin/partials/nginx-helper-general-options.php:284 326 #: admin/partials/nginx-helper-general-options.php:268 327 #: admin/partials/nginx-helper-general-options.php:290 328 #: admin/partials/nginx-helper-general-options.php:314 329 #: admin/partials/nginx-helper-general-options.php:329 330 #: admin/partials/nginx-helper-general-options.php:344 331 #: admin/partials/nginx-helper-general-options.php:360 332 #: admin/partials/nginx-helper-general-options.php:378 316 333 msgid "Overridden by constant variables." 317 334 msgstr "" 318 335 319 #: admin/partials/nginx-helper-general-options.php:262 336 #: admin/partials/nginx-helper-general-options.php:276 337 #: admin/partials/nginx-helper-general-options.php:299 338 msgid "Overridden by unix socket path." 339 msgstr "" 340 341 #: admin/partials/nginx-helper-general-options.php:283 320 342 msgid "Port" 321 343 msgstr "" 322 344 323 #: admin/partials/nginx-helper-general-options.php:277 345 #: admin/partials/nginx-helper-general-options.php:307 346 msgid "Socket Path" 347 msgstr "" 348 349 #: admin/partials/nginx-helper-general-options.php:322 324 350 msgid "Prefix" 325 351 msgstr "" 326 352 327 #: admin/partials/nginx-helper-general-options.php:297 353 #: admin/partials/nginx-helper-general-options.php:337 354 msgid "Database" 355 msgstr "" 356 357 #: admin/partials/nginx-helper-general-options.php:353 358 msgid "Username" 359 msgstr "" 360 361 #: admin/partials/nginx-helper-general-options.php:369 362 msgid "Password" 363 msgstr "" 364 365 #: admin/partials/nginx-helper-general-options.php:391 328 366 msgid "Purging Conditions" 329 367 msgstr "" 330 368 331 #: admin/partials/nginx-helper-general-options.php:3 02369 #: admin/partials/nginx-helper-general-options.php:396 332 370 msgid "Purge Homepage:" 333 371 msgstr "" 334 372 335 #: admin/partials/nginx-helper-general-options.php: 309373 #: admin/partials/nginx-helper-general-options.php:403 336 374 msgid "when a post/page/custom post is modified or added." 337 375 msgstr "" 338 376 339 #: admin/partials/nginx-helper-general-options.php: 318340 #: admin/partials/nginx-helper-general-options.php: 445377 #: admin/partials/nginx-helper-general-options.php:412 378 #: admin/partials/nginx-helper-general-options.php:539 341 379 msgid "when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>." 342 380 msgstr "" 343 381 344 #: admin/partials/nginx-helper-general-options.php: 330382 #: admin/partials/nginx-helper-general-options.php:424 345 383 msgid "when an existing post/page/custom post is modified." 346 384 msgstr "" 347 385 348 #: admin/partials/nginx-helper-general-options.php: 339386 #: admin/partials/nginx-helper-general-options.php:433 349 387 msgid "when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>" 350 388 msgstr "" 351 389 352 #: admin/partials/nginx-helper-general-options.php: 353390 #: admin/partials/nginx-helper-general-options.php:447 353 391 msgid "Purge Post/Page/Custom Post Type:" 354 392 msgstr "" 355 393 356 #: admin/partials/nginx-helper-general-options.php: 370394 #: admin/partials/nginx-helper-general-options.php:464 357 395 msgid "when a <strong>post</strong> is <strong>published</strong>." 358 396 msgstr "" 359 397 360 #: admin/partials/nginx-helper-general-options.php: 382361 #: admin/partials/nginx-helper-general-options.php: 479398 #: admin/partials/nginx-helper-general-options.php:476 399 #: admin/partials/nginx-helper-general-options.php:573 362 400 msgid "when a comment is approved/published." 363 401 msgstr "" 364 402 365 #: admin/partials/nginx-helper-general-options.php: 391366 #: admin/partials/nginx-helper-general-options.php: 488403 #: admin/partials/nginx-helper-general-options.php:485 404 #: admin/partials/nginx-helper-general-options.php:582 367 405 msgid "when a <strong>comment</strong> is <strong>approved/published</strong>." 368 406 msgstr "" 369 407 370 #: admin/partials/nginx-helper-general-options.php:4 03371 #: admin/partials/nginx-helper-general-options.php:5 00408 #: admin/partials/nginx-helper-general-options.php:497 409 #: admin/partials/nginx-helper-general-options.php:594 372 410 msgid "when a comment is unapproved/deleted." 373 411 msgstr "" 374 412 375 #: admin/partials/nginx-helper-general-options.php: 412376 #: admin/partials/nginx-helper-general-options.php: 509413 #: admin/partials/nginx-helper-general-options.php:506 414 #: admin/partials/nginx-helper-general-options.php:603 377 415 msgid "when a <strong>comment</strong> is <strong>unapproved/deleted</strong>." 378 416 msgstr "" 379 417 380 #: admin/partials/nginx-helper-general-options.php: 426418 #: admin/partials/nginx-helper-general-options.php:520 381 419 msgid "Purge Archives:" 382 420 msgstr "" 383 421 384 #: admin/partials/nginx-helper-general-options.php: 428422 #: admin/partials/nginx-helper-general-options.php:522 385 423 msgid "(date, category, tag, author, custom taxonomies)" 386 424 msgstr "" 387 425 388 #: admin/partials/nginx-helper-general-options.php: 436426 #: admin/partials/nginx-helper-general-options.php:530 389 427 msgid "when an post/page/custom post is modified or added" 390 428 msgstr "" 391 429 392 #: admin/partials/nginx-helper-general-options.php: 457430 #: admin/partials/nginx-helper-general-options.php:551 393 431 msgid "when an existing post/page/custom post is trashed." 394 432 msgstr "" 395 433 396 #: admin/partials/nginx-helper-general-options.php: 466434 #: admin/partials/nginx-helper-general-options.php:560 397 435 msgid "when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>." 398 436 msgstr "" 399 437 400 #: admin/partials/nginx-helper-general-options.php: 523438 #: admin/partials/nginx-helper-general-options.php:617 401 439 msgid "Purge Feeds:" 402 440 msgstr "" 403 441 404 #: admin/partials/nginx-helper-general-options.php: 532442 #: admin/partials/nginx-helper-general-options.php:626 405 443 msgid "purge feeds" 406 444 msgstr "" 407 445 408 #: admin/partials/nginx-helper-general-options.php: 541446 #: admin/partials/nginx-helper-general-options.php:635 409 447 msgid "purge <strong>feeds</strong> along with <strong>posts</strong> & <strong>pages</strong>." 410 448 msgstr "" 411 449 412 #: admin/partials/nginx-helper-general-options.php:554 450 #: admin/partials/nginx-helper-general-options.php:649 451 msgid "Purge AMP URL:" 452 msgstr "" 453 454 #: admin/partials/nginx-helper-general-options.php:658 455 msgid "purge amp urls" 456 msgstr "" 457 458 #: admin/partials/nginx-helper-general-options.php:667 459 msgid "purge <strong>amp urls</strong> along with <strong>posts</strong> & <strong>pages</strong>." 460 msgstr "" 461 462 #: admin/partials/nginx-helper-general-options.php:680 413 463 msgid "Custom Purge URL:" 414 464 msgstr "" 415 465 416 #: admin/partials/nginx-helper-general-options.php: 560466 #: admin/partials/nginx-helper-general-options.php:686 417 467 msgid "Add one URL per line. URL should not contain domain name." 418 468 msgstr "" 419 469 420 #: admin/partials/nginx-helper-general-options.php: 563470 #: admin/partials/nginx-helper-general-options.php:689 421 471 msgid "Eg: To purge http://example.com/sample-page/ add <strong>/sample-page/</strong> in above textarea." 422 472 msgstr "" 423 473 424 #: admin/partials/nginx-helper-general-options.php: 567474 #: admin/partials/nginx-helper-general-options.php:693 425 475 msgid "'*' will only work with redis cache server." 426 476 msgstr "" 427 477 428 #: admin/partials/nginx-helper-general-options.php: 577478 #: admin/partials/nginx-helper-general-options.php:703 429 479 msgid "Debug Options" 430 480 msgstr "" 431 481 432 #: admin/partials/nginx-helper-general-options.php: 587482 #: admin/partials/nginx-helper-general-options.php:713 433 483 msgid "Enable Nginx Map." 434 484 msgstr "" 435 485 436 #: admin/partials/nginx-helper-general-options.php: 606486 #: admin/partials/nginx-helper-general-options.php:732 437 487 msgid "Enable Logging" 438 488 msgstr "" 439 489 440 #: admin/partials/nginx-helper-general-options.php: 611490 #: admin/partials/nginx-helper-general-options.php:737 441 491 msgid "disable" 442 492 msgstr "" 443 493 444 #: admin/partials/nginx-helper-general-options.php: 617494 #: admin/partials/nginx-helper-general-options.php:743 445 495 msgid "enable" 446 496 msgstr "" 447 497 448 #: admin/partials/nginx-helper-general-options.php: 624498 #: admin/partials/nginx-helper-general-options.php:750 449 499 msgid "NOTE" 450 500 msgstr "" 451 501 452 #: admin/partials/nginx-helper-general-options.php: 625502 #: admin/partials/nginx-helper-general-options.php:751 453 503 msgid "To" 454 504 msgstr "" 455 505 456 #: admin/partials/nginx-helper-general-options.php: 627506 #: admin/partials/nginx-helper-general-options.php:753 457 507 msgid "the logging feature, you must define" 458 508 msgstr "" 459 509 460 #: admin/partials/nginx-helper-general-options.php: 628510 #: admin/partials/nginx-helper-general-options.php:754 461 511 msgid "as" 462 512 msgstr "" 463 513 464 #: admin/partials/nginx-helper-general-options.php: 630514 #: admin/partials/nginx-helper-general-options.php:756 465 515 msgid "in your" 466 516 msgstr "" 467 517 468 #: admin/partials/nginx-helper-general-options.php: 641518 #: admin/partials/nginx-helper-general-options.php:767 469 519 msgid "Enable Nginx Timestamp in HTML" 470 520 msgstr "" 471 521 472 #: admin/partials/nginx-helper-general-options.php: 655522 #: admin/partials/nginx-helper-general-options.php:781 473 523 msgid "Nginx Map" 474 524 msgstr "" 475 525 476 #: admin/partials/nginx-helper-general-options.php: 664526 #: admin/partials/nginx-helper-general-options.php:790 477 527 msgid "Can't write on map file." 478 528 msgstr "" 479 529 480 530 #. translators: %s file url. 481 #: admin/partials/nginx-helper-general-options.php: 669482 #: admin/partials/nginx-helper-general-options.php: 741531 #: admin/partials/nginx-helper-general-options.php:795 532 #: admin/partials/nginx-helper-general-options.php:867 483 533 msgid "Check you have write permission on <strong>%s</strong>" 484 534 msgstr "" 485 535 486 #: admin/partials/nginx-helper-general-options.php: 686536 #: admin/partials/nginx-helper-general-options.php:812 487 537 msgid "Nginx Map path to include in nginx settings" 488 538 msgstr "" 489 539 490 #: admin/partials/nginx-helper-general-options.php: 687540 #: admin/partials/nginx-helper-general-options.php:813 491 541 msgid "(recommended)" 492 542 msgstr "" 493 543 494 #: admin/partials/nginx-helper-general-options.php: 700544 #: admin/partials/nginx-helper-general-options.php:826 495 545 msgid "Or," 496 546 msgstr "" 497 547 498 #: admin/partials/nginx-helper-general-options.php: 701548 #: admin/partials/nginx-helper-general-options.php:827 499 549 msgid "Text to manually copy and paste in nginx settings" 500 550 msgstr "" 501 551 502 #: admin/partials/nginx-helper-general-options.php: 702552 #: admin/partials/nginx-helper-general-options.php:828 503 553 msgid "(if your network is small and new sites are not added frequently)" 504 554 msgstr "" 505 555 506 #: admin/partials/nginx-helper-general-options.php: 720556 #: admin/partials/nginx-helper-general-options.php:846 507 557 msgid "Logging Options" 508 558 msgstr "" 509 559 510 #: admin/partials/nginx-helper-general-options.php: 736560 #: admin/partials/nginx-helper-general-options.php:862 511 561 msgid "Can't write on log file." 512 562 msgstr "" 513 563 514 #: admin/partials/nginx-helper-general-options.php: 758564 #: admin/partials/nginx-helper-general-options.php:884 515 565 msgid "Logs path" 516 566 msgstr "" 517 567 518 #: admin/partials/nginx-helper-general-options.php: 770568 #: admin/partials/nginx-helper-general-options.php:896 519 569 msgid "View Log" 520 570 msgstr "" 521 571 522 #: admin/partials/nginx-helper-general-options.php: 775572 #: admin/partials/nginx-helper-general-options.php:901 523 573 msgid "Log" 524 574 msgstr "" 525 575 526 #: admin/partials/nginx-helper-general-options.php: 782576 #: admin/partials/nginx-helper-general-options.php:908 527 577 msgid "Log level" 528 578 msgstr "" 529 579 530 #: admin/partials/nginx-helper-general-options.php: 787580 #: admin/partials/nginx-helper-general-options.php:913 531 581 msgid "None" 532 582 msgstr "" 533 583 534 #: admin/partials/nginx-helper-general-options.php: 788584 #: admin/partials/nginx-helper-general-options.php:914 535 585 msgid "Info" 536 586 msgstr "" 537 587 538 #: admin/partials/nginx-helper-general-options.php: 789588 #: admin/partials/nginx-helper-general-options.php:915 539 589 msgid "Warning" 540 590 msgstr "" 541 591 542 #: admin/partials/nginx-helper-general-options.php: 790592 #: admin/partials/nginx-helper-general-options.php:916 543 593 msgid "Error" 544 594 msgstr "" 545 595 546 #: admin/partials/nginx-helper-general-options.php: 797596 #: admin/partials/nginx-helper-general-options.php:923 547 597 msgid "Max log file size" 548 598 msgstr "" 549 599 550 #: admin/partials/nginx-helper-general-options.php: 803600 #: admin/partials/nginx-helper-general-options.php:929 551 601 msgid "Mb" 552 602 msgstr "" 553 603 554 #: admin/partials/nginx-helper-general-options.php: 820604 #: admin/partials/nginx-helper-general-options.php:946 555 605 msgid "Save All Changes" 556 606 msgstr "" … … 654 704 655 705 #. translators: %s is Minimum WP version. 656 #: includes/class-nginx-helper.php:31 1706 #: includes/class-nginx-helper.php:314 657 707 msgid "Sorry, Nginx Helper requires WordPress %s or higher" 658 708 msgstr "" -
nginx-helper/tags/2.3.0/nginx-helper.php
r3071366 r3213676 4 4 * Plugin URI: https://rtcamp.com/nginx-helper/ 5 5 * Description: Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does few more things. 6 * Version: 2. 2.56 * Version: 2.3.0 7 7 * Author: rtCamp 8 8 * Author URI: https://rtcamp.com … … 10 10 * Domain Path: /languages 11 11 * Requires at least: 3.0 12 * Tested up to: 6. 412 * Tested up to: 6.7 13 13 * 14 14 * @link https://rtcamp.com/nginx-helper/ -
nginx-helper/tags/2.3.0/readme.txt
r3071384 r3213676 6 6 License URI: http://www.gnu.org/licenses/gpl-2.0.html 7 7 Requires at least: 3.0 8 Tested up to: 6. 59 Stable tag: 2. 2.58 Tested up to: 6.7 9 Stable tag: 2.3.0 10 10 11 11 Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does a few more things. … … 107 107 ``` 108 108 109 **Q. Can I override the redis socket path, username, password?** 110 111 Yes, you can force override the redis socket path, username, password by defining constant in wp-config.php. For example: 112 113 ```php 114 define( 'RT_WP_NGINX_HELPER_REDIS_UNIX_SOCKET', '/var/run/redis/redis.sock' ); 115 116 define( 'RT_WP_NGINX_HELPER_REDIS_USERNAME', 'admin' ); 117 118 define( 'RT_WP_NGINX_HELPER_REDIS_PASSWORD', 'admin' ); 119 ``` 120 109 121 = FAQ - Nginx Map = 110 122 … … 117 129 Most likely yes. A wordpress plugin, if not using explicitly any Apache-only mod, should work on Nginx. Some plugin may need some extra work. 118 130 131 132 = FAQ - WP-CLI = 133 134 **Q. How can I update the options using WP-CLI?** 135 136 ```shell 137 wp option patch update rt_wp_nginx_helper_options <option_name> <option_value> 138 ``` 119 139 120 140 = Still need help! = … … 127 147 128 148 == Changelog == 149 150 = 2.3.0 = 151 152 * Disable the purge functionality when importing data. [#52](https://github.com/rtCamp/nginx-helper/pull/52) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi) 153 * Added option to preload cache for all Post and Pages. [#47](https://github.com/rtCamp/nginx-helper/pull/47) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi) 154 * Added the capability to purge Amp URL's. [#135](https://github.com/rtCamp/nginx-helper/pull/135) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi) 155 * Add support for adding Username, Password support for Redis. It also includes the support for Unix Socket Path for Redis along with Database selection. [#343](https://github.com/rtCamp/nginx-helper/pull/343),[#350](https://github.com/rtCamp/nginx-helper/pull/350) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi) 156 * Add capability to allow modifying options using WP-CLI. [#307](https://github.com/rtCamp/nginx-helper/pull/307) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi) 157 * Fix the plugin crash issue due to internationalization after upgrading to WordPress Version 6.7. [#364](https://github.com/rtCamp/nginx-helper/pull/364) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi) 158 129 159 130 160 = 2.2.5 = -
nginx-helper/trunk/admin/class-fastcgi-purger.php
r3071366 r3213676 91 91 92 92 } 93 93 94 if( ( is_page() || is_single() ) && $nginx_helper_admin->options['purge_amp_urls'] ) { 95 $this->purge_amp_version( $url ); 96 } 97 98 } 99 100 /** 101 * Purge AMP version of a URL. 102 * 103 * @param string $url_base The base URL to purge. 104 */ 105 private function purge_amp_version( $url_base ) { 106 $amp_url = sprintf( '%s/amp/', rtrim( $url_base, '/' ) ); 107 108 $this->log( '- Purging AMP URL | ' . $amp_url ); 109 110 if ( 'unlink_files' === $this->nginx_helper_admin->options['purge_method'] ) { 111 $this->delete_cache_file_for( $amp_url ); 112 } else { 113 $this->do_remote_get( $amp_url ); 114 } 94 115 } 95 116 -
nginx-helper/trunk/admin/class-nginx-helper-admin.php
r3071366 r3213676 21 21 */ 22 22 class Nginx_Helper_Admin { 23 23 24 24 /** 25 25 * The ID of this plugin. … … 30 30 */ 31 31 private $plugin_name; 32 32 33 33 /** 34 34 * The version of this plugin. … … 39 39 */ 40 40 private $version; 41 41 42 42 /** 43 43 * Various settings tabs. … … 48 48 */ 49 49 private $settings_tabs; 50 50 51 51 /** 52 52 * Purge options. … … 57 57 */ 58 58 public $options; 59 59 60 60 /** 61 61 * WP-CLI Command. … … 66 66 */ 67 67 const WP_CLI_COMMAND = 'nginx-helper'; 68 68 69 69 /** 70 70 * Initialize the class and set its properties. … … 75 75 */ 76 76 public function __construct( $plugin_name, $version ) { 77 77 78 78 $this->plugin_name = $plugin_name; 79 79 $this->version = $version; 80 80 81 $this->options = $this->nginx_helper_settings(); 82 } 83 84 /** 85 * Initialize the settings tab. 86 * Required since i18n is used in the settings tab which can be invoked only after init hook since WordPress 6.7 87 */ 88 public function initialize_setting_tab() { 89 81 90 /** 82 91 * Define settings tabs … … 95 104 ) 96 105 ); 97 98 $this->options = $this->nginx_helper_settings(); 99 100 } 101 106 } 107 102 108 /** 103 109 * Register the stylesheets for the admin area. … … 108 114 */ 109 115 public function enqueue_styles( $hook ) { 110 116 111 117 /** 112 118 * This function is provided for demonstration purposes only. … … 120 126 * class. 121 127 */ 122 128 123 129 if ( 'settings_page_nginx' !== $hook ) { 124 130 return; 125 131 } 126 132 127 133 wp_enqueue_style( $this->plugin_name . '-icons', plugin_dir_url( __FILE__ ) . 'icons/css/nginx-fontello.css', array(), $this->version, 'all' ); 128 134 wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/nginx-helper-admin.css', array(), $this->version, 'all' ); 129 130 } 131 135 136 } 137 132 138 /** 133 139 * Register the JavaScript for the admin area. … … 138 144 */ 139 145 public function enqueue_scripts( $hook ) { 140 146 141 147 /** 142 148 * This function is provided for demonstration purposes only. … … 150 156 * class. 151 157 */ 152 158 153 159 if ( 'settings_page_nginx' !== $hook ) { 154 160 return; 155 161 } 156 162 157 163 wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/nginx-helper-admin.js', array( 'jquery' ), $this->version, false ); 158 164 159 165 $do_localize = array( 160 166 'purge_confirm_string' => esc_html__( 'Purging entire cache is not recommended. Would you like to continue?', 'nginx-helper' ), 161 167 ); 162 168 wp_localize_script( $this->plugin_name, 'nginx_helper', $do_localize ); 163 164 } 165 169 170 } 171 166 172 /** 167 173 * Add admin menu. … … 170 176 */ 171 177 public function nginx_helper_admin_menu() { 172 178 173 179 if ( is_multisite() ) { 174 180 175 181 add_submenu_page( 176 182 'settings.php', … … 181 187 array( &$this, 'nginx_helper_setting_page' ) 182 188 ); 183 189 184 190 } else { 185 191 186 192 add_submenu_page( 187 193 'options-general.php', … … 192 198 array( &$this, 'nginx_helper_setting_page' ) 193 199 ); 194 195 } 196 197 } 198 200 201 } 202 203 } 204 199 205 /** 200 206 * Function to add toolbar purge link. … … 203 209 */ 204 210 public function nginx_helper_toolbar_purge_link( $wp_admin_bar ) { 205 211 206 212 if ( ! current_user_can( 'manage_options' ) ) { 207 213 return; 208 214 } 209 215 210 216 if ( is_admin() ) { 211 217 $nginx_helper_urls = 'all'; … … 215 221 $link_title = __( 'Purge Current Page', 'nginx-helper' ); 216 222 } 217 223 218 224 $purge_url = add_query_arg( 219 225 array( … … 222 228 ) 223 229 ); 224 230 225 231 $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' ); 226 232 227 233 $wp_admin_bar->add_menu( 228 234 array( … … 233 239 ) 234 240 ); 235 236 } 237 241 242 } 243 238 244 /** 239 245 * Display settings. … … 246 252 include plugin_dir_path( __FILE__ ) . 'partials/nginx-helper-admin-display.php'; 247 253 } 248 254 249 255 /** 250 256 * Default settings. … … 254 260 */ 255 261 public function nginx_helper_default_settings() { 256 262 257 263 return array( 258 264 'enable_purge' => 0, … … 276 282 'redis_hostname' => '127.0.0.1', 277 283 'redis_port' => '6379', 278 'redis_prefix' => 'nginx-cache:', 284 'redis_prefix' => 'nginx-cache:', 285 'redis_unix_socket' => '', 286 'redis_database' => 0, 287 'redis_username' => '', 288 'redis_password' => '', 279 289 'purge_url' => '', 280 290 'redis_enabled_by_constant' => 0, 291 'purge_amp_urls' => 1, 292 'redis_socket_enabled_by_constant' => 0, 293 'redis_acl_enabled_by_constant' => 0, 294 'preload_cache' => 0, 295 'is_cache_preloaded' => 0 281 296 ); 297 298 } 299 300 public function store_default_options() { 301 $options = get_site_option( 'rt_wp_nginx_helper_options', array() ); 302 $default_settings = $this->nginx_helper_default_settings(); 303 304 $removable_default_settings = array( 305 'redis_port', 306 'redis_prefix', 307 'redis_hostname', 308 'redis_database', 309 'redis_unix_socket' 310 ); 311 312 // Remove all the keys that are not to be stored by default. 313 foreach ( $removable_default_settings as $removable_key ) { 314 unset( $default_settings[ $removable_key ] ); 315 } 316 317 $diffed_options = wp_parse_args( $options, $default_settings ); 318 319 add_site_option( 'rt_wp_nginx_helper_options', $diffed_options ); 320 } 282 321 283 }284 285 322 /** 286 323 * Get settings. … … 289 326 */ 290 327 public function nginx_helper_settings() { 291 328 292 329 $options = get_site_option( 293 330 'rt_wp_nginx_helper_options', … … 296 333 'redis_port' => '6379', 297 334 'redis_prefix' => 'nginx-cache:', 335 'redis_database' => 0, 298 336 ) 299 337 ); 300 338 301 339 $data = wp_parse_args( 302 340 $options, 303 341 $this->nginx_helper_default_settings() 304 342 ); 305 343 306 344 $is_redis_enabled = ( 307 345 defined( 'RT_WP_NGINX_HELPER_REDIS_HOSTNAME' ) && … … 309 347 defined( 'RT_WP_NGINX_HELPER_REDIS_PREFIX' ) 310 348 ); 349 350 $data['redis_acl_enabled_by_constant'] = defined('RT_WP_NGINX_HELPER_REDIS_USERNAME') && defined('RT_WP_NGINX_HELPER_REDIS_PASSWORD'); 351 $data['redis_socket_enabled_by_constant'] = defined('RT_WP_NGINX_HELPER_REDIS_UNIX_SOCKET'); 352 $data['redis_unix_socket'] = $data['redis_socket_enabled_by_constant'] ? RT_WP_NGINX_HELPER_REDIS_UNIX_SOCKET : $data['redis_unix_socket']; 353 $data['redis_username'] = $data['redis_acl_enabled_by_constant'] ? RT_WP_NGINX_HELPER_REDIS_USERNAME : $data['redis_username']; 354 $data['redis_password'] = $data['redis_acl_enabled_by_constant'] ? RT_WP_NGINX_HELPER_REDIS_PASSWORD : $data['redis_password']; 311 355 312 356 if ( ! $is_redis_enabled ) { … … 314 358 } 315 359 316 $data['redis_enabled_by_constant'] = $is_redis_enabled; 317 $data['enable_purge'] = $is_redis_enabled; 318 $data['cache_method'] = 'enable_redis'; 319 $data['redis_hostname'] = RT_WP_NGINX_HELPER_REDIS_HOSTNAME; 320 $data['redis_port'] = RT_WP_NGINX_HELPER_REDIS_PORT; 321 $data['redis_prefix'] = RT_WP_NGINX_HELPER_REDIS_PREFIX; 360 $data['redis_enabled_by_constant'] = $is_redis_enabled; 361 $data['enable_purge'] = $is_redis_enabled; 362 $data['cache_method'] = 'enable_redis'; 363 $data['redis_hostname'] = RT_WP_NGINX_HELPER_REDIS_HOSTNAME; 364 $data['redis_port'] = RT_WP_NGINX_HELPER_REDIS_PORT; 365 $data['redis_prefix'] = RT_WP_NGINX_HELPER_REDIS_PREFIX; 366 $data['redis_database'] = defined('RT_WP_NGINX_HELPER_REDIS_DATABASE') ? RT_WP_NGINX_HELPER_REDIS_DATABASE : 0; 322 367 323 368 return $data; 324 325 } 326 369 370 } 371 327 372 /** 328 373 * Nginx helper setting link function. … … 333 378 */ 334 379 public function nginx_helper_settings_link( $links ) { 335 380 336 381 if ( is_network_admin() ) { 337 382 $setting_page = 'settings.php'; … … 339 384 $setting_page = 'options-general.php'; 340 385 } 341 386 342 387 $settings_link = '<a href="' . network_admin_url( $setting_page . '?page=nginx' ) . '">' . __( 'Settings', 'nginx-helper' ) . '</a>'; 343 388 array_unshift( $links, $settings_link ); 344 389 345 390 return $links; 346 347 } 348 391 392 } 393 349 394 /** 350 395 * Check if the nginx log is enabled. … … 354 399 */ 355 400 public function is_nginx_log_enabled() { 356 401 357 402 $options = get_site_option( 'rt_wp_nginx_helper_options', array() ); 358 403 359 404 if ( ! empty( $options['enable_log'] ) && 1 === (int) $options['enable_log'] ) { 360 405 return true; 361 406 } 362 407 363 408 if ( defined( 'NGINX_HELPER_LOG' ) && true === NGINX_HELPER_LOG ) { 364 409 return true; 365 410 } 366 411 367 412 return false; 368 413 } 369 414 370 415 /** 371 416 * Retrieve the asset path. … … 375 420 */ 376 421 public function functional_asset_path() { 377 422 378 423 $log_path = WP_CONTENT_DIR . '/uploads/nginx-helper/'; 379 424 380 425 return apply_filters( 'nginx_asset_path', $log_path ); 381 382 } 383 426 427 } 428 384 429 /** 385 430 * Retrieve the asset url. … … 389 434 */ 390 435 public function functional_asset_url() { 391 436 392 437 $log_url = WP_CONTENT_URL . '/uploads/nginx-helper/'; 393 438 394 439 return apply_filters( 'nginx_asset_url', $log_url ); 395 396 } 397 440 441 } 442 398 443 /** 399 444 * Get latest news. … … 402 447 */ 403 448 public function nginx_helper_get_feeds() { 404 449 405 450 // Get RSS Feed(s). 406 451 require_once ABSPATH . WPINC . '/feed.php'; 407 452 408 453 $maxitems = 0; 409 454 $rss_items = array(); 410 455 411 456 // Get a SimplePie feed object from the specified feed source. 412 457 $rss = fetch_feed( 'https://rtcamp.com/blog/feed/' ); 413 458 414 459 if ( ! is_wp_error( $rss ) ) { // Checks that the object is created correctly. 415 460 416 461 // Figure out how many total items there are, but limit it to 5. 417 462 $maxitems = $rss->get_item_quantity( 5 ); 418 463 // Build an array of all the items, starting with element 0 (first element). 419 464 $rss_items = $rss->get_items( 0, $maxitems ); 420 465 421 466 } 422 467 ?> … … 426 471 echo '<li role="listitem">' . esc_html_e( 'No items', 'nginx-helper' ) . '.</li>'; 427 472 } else { 428 473 429 474 // Loop through each feed item and display each item as a hyperlink. 430 475 foreach ( $rss_items as $item ) { 431 476 ?> 432 <li role="listitem">433 <?php434 printf(435 '<a href="%s" title="%s">%s</a>',436 esc_url( $item->get_permalink() ),437 esc_attr__( 'Posted ', 'nginx-helper' ) . esc_attr( $item->get_date( 'j F Y | g:i a' ) ),438 esc_html( $item->get_title() )439 );440 ?>441 </li>477 <li role="listitem"> 478 <?php 479 printf( 480 '<a href="%s" title="%s">%s</a>', 481 esc_url( $item->get_permalink() ), 482 esc_attr__( 'Posted ', 'nginx-helper' ) . esc_attr( $item->get_date( 'j F Y | g:i a' ) ), 483 esc_html( $item->get_title() ) 484 ); 485 ?> 486 </li> 442 487 <?php 443 488 } … … 447 492 <?php 448 493 die(); 449 450 } 451 494 495 } 496 452 497 /** 453 498 * Add time stamps in html. 454 499 */ 455 500 public function add_timestamps() { 456 501 457 502 global $pagenow; 458 503 459 504 if ( is_admin() || 1 !== (int) $this->options['enable_purge'] || 1 !== (int) $this->options['enable_stamp'] ) { 460 505 return; 461 506 } 462 507 463 508 if ( ! empty( $pagenow ) && 'wp-login.php' === $pagenow ) { 464 509 return; 465 510 } 466 511 467 512 foreach ( headers_list() as $header ) { 468 513 list( $key, $value ) = explode( ':', $header, 2 ); … … 475 520 } 476 521 } 477 522 478 523 /** 479 524 * Don't add timestamp if run from ajax, cron or wpcli. … … 482 527 return; 483 528 } 484 529 485 530 if ( defined( 'DOING_CRON' ) && DOING_CRON ) { 486 531 return; 487 532 } 488 533 489 534 if ( defined( 'WP_CLI' ) && WP_CLI ) { 490 535 return; 491 536 } 492 537 493 538 $timestamps = "\n<!--" . 494 'Cached using Nginx-Helper on ' . current_time( 'mysql' ) . '. ' .495 'It took ' . get_num_queries() . ' queries executed in ' . timer_stop() . ' seconds.' .496 "-->\n" .497 '<!--Visit http://wordpress.org/extend/plugins/nginx-helper/faq/ for more details-->';498 539 'Cached using Nginx-Helper on ' . current_time( 'mysql' ) . '. ' . 540 'It took ' . get_num_queries() . ' queries executed in ' . timer_stop() . ' seconds.' . 541 "-->\n" . 542 '<!--Visit http://wordpress.org/extend/plugins/nginx-helper/faq/ for more details-->'; 543 499 544 echo wp_kses( $timestamps, array() ); 500 501 } 502 545 546 } 547 503 548 /** 504 549 * Get map … … 509 554 */ 510 555 public function get_map() { 511 556 512 557 if ( ! $this->options['enable_map'] ) { 513 558 return; 514 559 } 515 560 516 561 if ( is_multisite() ) { 517 562 518 563 global $wpdb; 519 564 520 565 $rt_all_blogs = $wpdb->get_results( 521 566 $wpdb->prepare( … … 524 569 ) 525 570 ); 526 571 527 572 $wpdb->dmtable = $wpdb->base_prefix . 'domain_mapping'; 528 573 529 574 $rt_domain_map_sites = ''; 530 575 531 576 if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->dmtable}'" ) === $wpdb->dmtable ) { // phpcs:ignore 532 577 $rt_domain_map_sites = $wpdb->get_results( "SELECT blog_id, domain FROM {$wpdb->dmtable} ORDER BY id DESC" ); 533 578 } 534 579 535 580 $rt_nginx_map = ''; 536 581 $rt_nginx_map_array = array(); 537 582 538 583 if ( $rt_all_blogs ) { 539 584 540 585 foreach ( $rt_all_blogs as $blog ) { 541 586 542 587 if ( true === SUBDOMAIN_INSTALL ) { 543 588 $rt_nginx_map_array[ $blog->domain ] = $blog->blog_id; 544 589 } else { 545 590 546 591 if ( 1 !== $blog->blog_id ) { 547 592 $rt_nginx_map_array[ $blog->path ] = $blog->blog_id; … … 550 595 } 551 596 } 552 597 553 598 if ( $rt_domain_map_sites ) { 554 599 555 600 foreach ( $rt_domain_map_sites as $site ) { 556 601 $rt_nginx_map_array[ $site->domain ] = $site->blog_id; 557 602 } 558 603 } 559 604 560 605 foreach ( $rt_nginx_map_array as $domain => $domain_id ) { 561 606 $rt_nginx_map .= "\t" . $domain . "\t" . $domain_id . ";\n"; 562 607 } 563 608 564 609 return $rt_nginx_map; 565 566 } 567 568 } 569 610 611 } 612 613 } 614 570 615 /** 571 616 * Update map 572 617 */ 573 618 public function update_map() { 574 619 575 620 if ( is_multisite() ) { 576 621 577 622 $rt_nginx_map = $this->get_map(); 578 623 579 624 $fp = fopen( $this->functional_asset_path() . 'map.conf', 'w+' ); 580 625 if ( $fp ) { … … 583 628 } 584 629 } 585 586 } 587 630 631 } 632 588 633 /** 589 634 * Purge url when post status is changed. … … 597 642 */ 598 643 public function set_future_post_option_on_future_status( $new_status, $old_status, $post ) { 599 644 600 645 global $blog_id, $nginx_purger; 601 646 602 647 $exclude_post_types = array( 'nav_menu_item' ); 603 648 604 649 if ( in_array( $post->post_type, $exclude_post_types, true ) ) { 605 650 return; 606 651 } 607 608 if ( ! $this->options['enable_purge'] ) {609 return; 610 } 611 652 653 if ( ! $this->options['enable_purge'] || $this->is_import_request() ) { 654 return; 655 } 656 612 657 $purge_status = array( 'publish', 'future' ); 613 658 614 659 if ( in_array( $old_status, $purge_status, true ) || in_array( $new_status, $purge_status, true ) ) { 615 660 616 661 $nginx_purger->log( 'Purge post on transition post STATUS from ' . $old_status . ' to ' . $new_status ); 617 662 $nginx_purger->purge_post( $post->ID ); 618 619 } 620 663 664 } 665 621 666 if ( 622 667 'future' === $new_status && $post && 'future' === $post->post_status && … … 629 674 ) 630 675 ) { 631 676 632 677 $nginx_purger->log( 'Set/update future_posts option ( post id = ' . $post->ID . ' and blog id = ' . $blog_id . ' )' ); 633 678 $this->options['future_posts'][ $blog_id ][ $post->ID ] = strtotime( $post->post_date_gmt ) + 60; 634 679 update_site_option( 'rt_wp_nginx_helper_options', $this->options ); 635 636 } 637 638 } 639 680 681 } 682 683 } 684 640 685 /** 641 686 * Unset future post option on delete … … 647 692 */ 648 693 public function unset_future_post_option_on_delete( $post_id ) { 649 694 650 695 global $blog_id, $nginx_purger; 651 696 652 697 if ( 653 698 ! $this->options['enable_purge'] || … … 659 704 return; 660 705 } 661 706 662 707 $nginx_purger->log( 'Unset future_posts option ( post id = ' . $post_id . ' and blog id = ' . $blog_id . ' )' ); 663 708 664 709 unset( $this->options['future_posts'][ $blog_id ][ $post_id ] ); 665 710 666 711 if ( ! count( $this->options['future_posts'][ $blog_id ] ) ) { 667 712 unset( $this->options['future_posts'][ $blog_id ] ); 668 713 } 669 714 670 715 update_site_option( 'rt_wp_nginx_helper_options', $this->options ); 671 716 } 672 717 673 718 /** 674 719 * Update map when new blog added in multisite. … … 679 724 */ 680 725 public function update_new_blog_options( $blog_id ) { 681 726 682 727 global $nginx_purger; 683 728 684 729 $nginx_purger->log( "New site added ( id $blog_id )" ); 685 730 $this->update_map(); … … 688 733 update_blog_option( $blog_id, 'rt_wp_nginx_helper_options', $helper_options ); 689 734 $nginx_purger->log( "Default options updated for the new blog ( id $blog_id )" ); 690 691 } 692 735 736 } 737 693 738 /** 694 739 * Purge all urls. … … 699 744 */ 700 745 public function purge_all() { 701 746 747 if ( $this->is_import_request() ) { 748 return; 749 } 750 702 751 global $nginx_purger, $wp; 703 752 704 753 $method = null; 705 754 if ( isset( $_SERVER['REQUEST_METHOD'] ) ) { 706 755 $method = wp_strip_all_tags( $_SERVER['REQUEST_METHOD'] ); 707 756 } 708 757 709 758 $action = ''; 710 759 if ( 'POST' === $method ) { … … 717 766 } 718 767 } 719 768 720 769 if ( empty( $action ) ) { 721 770 return; 722 771 } 723 772 724 773 if ( ! current_user_can( 'manage_options' ) ) { 725 774 wp_die( 'Sorry, you do not have the necessary privileges to edit these options.' ); 726 775 } 727 776 728 777 if ( 'done' === $action ) { 729 778 730 779 add_action( 'admin_notices', array( &$this, 'display_notices' ) ); 731 780 add_action( 'network_admin_notices', array( &$this, 'display_notices' ) ); 732 781 return; 733 734 } 735 782 783 } 784 736 785 check_admin_referer( 'nginx_helper-purge_all' ); 737 786 738 787 $current_url = user_trailingslashit( home_url( $wp->request ) ); 739 788 740 789 if ( ! is_admin() ) { 741 790 $action = 'purge_current_page'; … … 744 793 $redirect_url = add_query_arg( array( 'nginx_helper_action' => 'done' ) ); 745 794 } 746 795 747 796 switch ( $action ) { 748 797 case 'purge': … … 753 802 break; 754 803 } 755 804 756 805 if ( 'purge' === $action ) { 757 806 758 807 /** 759 808 * Fire an action after the entire cache has been purged whatever caching type is used. … … 762 811 */ 763 812 do_action( 'rt_nginx_helper_after_purge_all' ); 764 765 } 766 813 814 } 815 767 816 wp_redirect( esc_url_raw( $redirect_url ) ); 768 817 exit(); 769 770 } 771 818 819 } 820 772 821 /** 773 822 * Dispay plugin notices. … … 776 825 echo '<div class="updated"><p>' . esc_html__( 'Purge initiated', 'nginx-helper' ) . '</p></div>'; 777 826 } 778 827 828 /** 829 * Preloads the cache for the website. 830 * 831 * @return void 832 */ 833 public function preload_cache() { 834 $is_cache_preloaded = $this->options['is_cache_preloaded']; 835 $preload_cache_enabled = $this->options['preload_cache']; 836 837 if ( $preload_cache_enabled && false === boolval( $is_cache_preloaded ) ) { 838 $this->options['is_cache_preloaded'] = true; 839 840 update_site_option( 'rt_wp_nginx_helper_options', $this->options ); 841 $this->preload_cache_from_sitemap(); 842 } 843 } 844 845 /** 846 * This function preloads the cache from sitemap url. 847 * 848 * @return void 849 */ 850 private function preload_cache_from_sitemap() { 851 852 $sitemap_urls = $this->get_index_sitemap_urls(); 853 $all_urls = array(); 854 855 foreach ( $sitemap_urls as $sitemap_url ) { 856 $urls = $this->extract_sitemap_urls( $sitemap_url ); 857 $all_urls = array_merge( $all_urls, $urls ); 858 } 859 860 $args = array( 861 'timeout' => 1, 862 'blocking' => false, 863 'sslverify' => false, 864 ); 865 866 foreach ( $all_urls as $url ) { 867 wp_remote_get( esc_url_raw( $url ), $args ); 868 } 869 870 } 871 872 /** 873 * Fetches all the sitemap urls for the site. 874 * 875 * @return array 876 */ 877 private function get_index_sitemap_urls() { 878 $sitemaps = wp_sitemaps_get_server()->index->get_sitemap_list(); 879 $urls = array(); 880 foreach ( $sitemaps as $sitemap ) { 881 $urls[] = $sitemap['loc']; 882 } 883 return $urls; 884 } 885 886 /** 887 * Parse sitemap content and extract all URLs. 888 * 889 * @param string $sitemap_url The URL of the sitemap. 890 * @return array|WP_Error An array of URLs or WP_Error on failure. 891 */ 892 private function extract_sitemap_urls( $sitemap_url ) { 893 $response = wp_remote_get( $sitemap_url ); 894 895 $urls = array(); 896 897 if ( is_wp_error( $response ) ) { 898 return $urls; 899 } 900 901 $sitemap_content = wp_remote_retrieve_body( $response ); 902 903 libxml_use_internal_errors( true ); 904 $xml = simplexml_load_string( $sitemap_content ); 905 906 if ( false === $xml ) { 907 return new WP_Error( 'sitemap_parse_error', esc_html__( 'Failed to parse the sitemap XML', 'nginx-helper' ) ); 908 } 909 910 $urls = array(); 911 912 if ( false === $xml ) { 913 return $urls; 914 } 915 916 foreach ( $xml->url as $url ) { 917 $urls[] = (string) $url->loc; 918 } 919 920 return $urls; 921 } 922 923 /** 924 * Determines if the current request is for importing Posts/ WordPress content. 925 * 926 * @return bool True if the request is for importing, false otherwise. 927 */ 928 public function is_import_request() { 929 $import_query_var = sanitize_text_field( wp_unslash( $_GET['import'] ?? '' ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is already in the admin dashboard. 930 $has_import_started = did_action( 'import_start' ); 931 932 return ( defined( 'WP_IMPORTING' ) && true === WP_IMPORTING ) 933 || 0 !== $has_import_started 934 || ! empty( $import_query_var ); 935 } 936 937 779 938 } -
nginx-helper/trunk/admin/class-phpredis-purger.php
r2222658 r3213676 40 40 41 41 $this->redis_object = new Redis(); 42 43 $redis_acl = array(); 44 45 $username = $nginx_helper_admin->options['redis_username']; 46 $password = $nginx_helper_admin->options['redis_password']; 47 48 if( $username && $password ) { 49 $redis_acl['auth'] = array( $username, $password ); 50 } 51 52 $hostname = empty( $nginx_helper_admin->options['redis_unix_socket'] ) ? $nginx_helper_admin->options['redis_hostname'] : $nginx_helper_admin->options['redis_unix_socket']; 53 $port = empty( $nginx_helper_admin->options['redis_unix_socket'] ) ? $nginx_helper_admin->options['redis_port'] : 0; 54 42 55 $this->redis_object->connect( 43 $nginx_helper_admin->options['redis_hostname'], 44 $nginx_helper_admin->options['redis_port'], 45 5 56 $hostname, 57 $port, 58 5, 59 null, 60 0, 61 0, 62 $redis_acl 46 63 ); 64 65 if( $nginx_helper_admin->options['redis_database'] !== 0 ) { 66 $this->redis_object->select($nginx_helper_admin->options['redis_database']); 67 } 47 68 48 69 } catch ( Exception $e ) { -
nginx-helper/trunk/admin/class-predis-purger.php
r2222658 r3213676 38 38 39 39 Predis\Autoloader::register(); 40 40 41 $predis_args = array(); 42 43 $username = $nginx_helper_admin->options['redis_username']; 44 $password = $nginx_helper_admin->options['redis_password']; 45 46 if( ! empty( $nginx_helper_admin->options['redis_unix_socket'] ) ) { 47 $predis_args['path'] = $nginx_helper_admin->options['redis_unix_socket']; 48 } else { 49 $predis_args['host'] = $nginx_helper_admin->options['redis_hostname'];; 50 $predis_args['port'] = $nginx_helper_admin->options['redis_port']; 51 } 52 53 if ( $username && $password ) { 54 $predis_args['username'] = $username; 55 $predis_args['password'] = $password; 56 } 57 41 58 // redis server parameter. 42 $this->redis_object = new Predis\Client( 43 array( 44 'host' => $nginx_helper_admin->options['redis_hostname'], 45 'port' => $nginx_helper_admin->options['redis_port'], 46 ) 47 ); 59 $this->redis_object = new Predis\Client( $predis_args ); 48 60 49 61 try { 50 62 $this->redis_object->connect(); 63 64 if( 0 !== $nginx_helper_admin->options['redis_database'] ) { 65 $this->redis_object->select( $nginx_helper_admin->options['redis_database'] ); 66 } 51 67 } catch ( Exception $e ) { 52 68 $this->log( $e->getMessage(), 'ERROR' ); 53 } 69 return; 70 } 71 54 72 55 73 } -
nginx-helper/trunk/admin/css/nginx-helper-admin.css
r3023296 r3213676 5 5 6 6 .clearfix { 7 *zoom: 1;7 zoom: 1; 8 8 } 9 9 .clearfix:before, … … 104 104 margin-left: 23px; 105 105 } 106 107 .password-input { 108 padding-right: 40px; 109 } 110 111 .password-show-hide-btn { 112 background-color: transparent; 113 border: 0; 114 cursor: pointer; 115 display: inline-block; 116 } 117 118 .password-wrapper { 119 display: flex; 120 } -
nginx-helper/trunk/admin/js/nginx-helper-admin.js
r2222658 r3213676 76 76 ); 77 77 78 jQuery('.password-show-hide-btn').on('click', function() { 79 var passwordInput = $(this).siblings('.password-input'); 80 var icon = $(this).find('.password-input-icon'); 81 82 if (passwordInput.attr('type') === 'password') { 83 passwordInput.attr('type', 'text'); 84 icon.removeClass('dashicons-hidden').addClass('dashicons-visibility'); 85 } else { 86 passwordInput.attr('type', 'password'); 87 icon.removeClass('dashicons-visibility').addClass('dashicons-hidden'); 88 } 89 }); 90 78 91 /** 79 92 * Show OR Hide options on option checkbox -
nginx-helper/trunk/admin/partials/nginx-helper-general-options.php
r3071366 r3213676 23 23 'redis_port', 24 24 'redis_prefix', 25 'redis_database', 26 'redis_username', 27 'redis_password', 28 'redis_unix_socket', 29 'redis_socket_enabled_by_constant', 30 'redis_acl_enabled_by_constant', 25 31 'purge_homepage_on_edit', 26 32 'purge_homepage_on_del', … … 41 47 'purge_feeds', 42 48 'smart_http_expire_form_nonce', 49 'purge_amp_urls', 50 'preload_cache', 43 51 ); 44 52 … … 125 133 <input type="checkbox" value="1" id="enable_purge" name="enable_purge" <?php checked( $nginx_helper_settings['enable_purge'], 1 ); ?> /> 126 134 <label for="enable_purge"><?php esc_html_e( 'Enable Purge', 'nginx-helper' ); ?></label> 135 </td> 136 </tr> 137 <tr valign="top"> 138 <td> 139 <input type="checkbox" value="1" id="preload_cache" name="preload_cache" <?php checked( $nginx_helper_settings['preload_cache'], 1 ); ?> /> 140 <label for="preload_cache"><?php esc_html_e( 'Preload Cache', 'nginx-helper' ); ?></label> 127 141 </td> 128 142 </tr> … … 247 261 <th><label for="redis_hostname"><?php esc_html_e( 'Hostname', 'nginx-helper' ); ?></label></th> 248 262 <td> 249 <input id="redis_hostname" class="medium-text" type="text" name="redis_hostname" value="<?php echo esc_attr( $nginx_helper_settings['redis_hostname'] ); ?>" <?php echo ( $nginx_helper_settings['redis_enabled_by_constant'] ) ? 'readonly="readonly"' : ''; ?> />263 <input id="redis_hostname" class="medium-text" type="text" name="redis_hostname" value="<?php echo esc_attr( $nginx_helper_settings['redis_hostname'] ); ?>" <?php echo ( $nginx_helper_settings['redis_enabled_by_constant'] || $nginx_helper_settings['redis_unix_socket'] ) ? 'readonly="readonly"' : ''; ?> /> 250 264 <?php 251 265 if ( $nginx_helper_settings['redis_enabled_by_constant'] ) { … … 255 269 echo '</p>'; 256 270 271 } 272 ?> 273 <?php 274 if ( $nginx_helper_settings['redis_unix_socket'] ) { 275 echo '<p class="description">'; 276 esc_html_e( 'Overridden by unix socket path.', 'nginx-helper' ); 277 echo '</p>'; 257 278 } 258 279 ?> … … 262 283 <th><label for="redis_port"><?php esc_html_e( 'Port', 'nginx-helper' ); ?></label></th> 263 284 <td> 264 <input id="redis_port" class="medium-text" type="text" name="redis_port" value="<?php echo esc_attr( $nginx_helper_settings['redis_port'] ); ?>" <?php echo ( $nginx_helper_settings['redis_enabled_by_constant'] ) ? 'readonly="readonly"' : ''; ?> />285 <input id="redis_port" class="medium-text" type="text" name="redis_port" value="<?php echo esc_attr( $nginx_helper_settings['redis_port'] ); ?>" <?php echo ( $nginx_helper_settings['redis_enabled_by_constant'] || $nginx_helper_settings['redis_unix_socket'] ) ? 'readonly="readonly"' : ''; ?> /> 265 286 <?php 266 287 if ( $nginx_helper_settings['redis_enabled_by_constant'] ) { … … 270 291 echo '</p>'; 271 292 293 } 294 ?> 295 <?php 296 if ( $nginx_helper_settings['redis_unix_socket'] ) { 297 298 echo '<p class="description">'; 299 esc_html_e( 'Overridden by unix socket path.', 'nginx-helper' ); 300 echo '</p>'; 301 302 } 303 ?> 304 </td> 305 </tr> 306 <tr> 307 <th><label for="redis_unix_socket"><?php esc_html_e( 'Socket Path', 'nginx-helper' ); ?></label></th> 308 <td> 309 <input id="redis_unix_socket" class="medium-text" type="text" name="redis_unix_socket" value="<?php echo esc_attr( $nginx_helper_settings['redis_unix_socket'] ); ?>" <?php echo ( $nginx_helper_settings['redis_socket_enabled_by_constant'] ) ? 'readonly="readonly"' : ''; ?> /> 310 <?php 311 if ( $nginx_helper_settings['redis_socket_enabled_by_constant'] ) { 312 313 echo '<p class="description">'; 314 esc_html_e( 'Overridden by constant variables.', 'nginx-helper' ); 315 echo '</p>'; 316 272 317 } 273 318 ?> … … 285 330 echo '</p>'; 286 331 332 } 333 ?> 334 </td> 335 </tr> 336 <tr> 337 <th><label for="redis_database"><?php esc_html_e( 'Database', 'nginx-helper' ); ?></label></th> 338 <td> 339 <input id="redis_database" class="medium-text" type="text" name="redis_database" value="<?php echo esc_attr( $nginx_helper_settings['redis_database'] ); ?>" <?php echo ( $nginx_helper_settings['redis_enabled_by_constant'] ) ? 'readonly="readonly"' : ''; ?> /> 340 <?php 341 if ( $nginx_helper_settings['redis_enabled_by_constant'] ) { 342 343 echo '<p class="description">'; 344 esc_html_e( 'Overridden by constant variables.', 'nginx-helper' ); 345 echo '</p>'; 346 347 } 348 ?> 349 </td> 350 </tr> 351 352 <tr> 353 <th><label for="redis_username"><?php esc_html_e( 'Username', 'nginx-helper' ); ?></label></th> 354 <td> 355 <input id="redis_username" class="medium-text" type="text" name="redis_username" value="<?php echo esc_attr( $nginx_helper_settings['redis_username'] ); ?>" <?php echo ( $nginx_helper_settings['redis_enabled_by_constant'] ) ? 'readonly="readonly"' : ''; ?> /> 356 <?php 357 if ( $nginx_helper_settings['redis_enabled_by_constant'] ) { 358 359 echo '<p class="description">'; 360 esc_html_e( 'Overridden by constant variables.', 'nginx-helper' ); 361 echo '</p>'; 362 363 } 364 ?> 365 </td> 366 </tr> 367 368 <tr> 369 <th><label for="redis_password"><?php esc_html_e( 'Password', 'nginx-helper' ); ?></label></th> 370 <td> 371 <div class="password-wrapper"> 372 <input id="redis_password" class="medium-text password-input" type="password" name="redis_password" value="<?php echo esc_attr( $nginx_helper_settings['redis_password'] ); ?>" <?php echo ( $nginx_helper_settings['redis_enabled_by_constant'] ) ? 'readonly="readonly"' : ''; ?> /> 373 <button type="button" class="password-show-hide-btn"><span class="dashicons dashicons-hidden password-input-icon"></span></button> 374 </div> 375 <?php 376 if ( $nginx_helper_settings['redis_enabled_by_constant'] ) { 377 echo '<p class="description">'; 378 esc_html_e( 'Overridden by constant variables.', 'nginx-helper' ); 379 echo '</p>'; 380 287 381 } 288 382 ?> … … 542 636 array( 'strong' => array() ) 543 637 ); 638 ?> 639 </label> 640 <br /> 641 </fieldset> 642 </td> 643 </tr> 644 </table> 645 <table class="form-table rtnginx-table"> 646 <tr valign="top"> 647 <th scope="row"> 648 <h4> 649 <?php esc_html_e( 'Purge AMP URL:', 'nginx-helper' ); ?> 650 </h4> 651 </th> 652 <td> 653 <fieldset> 654 <legend class="screen-reader-text"> 655 <span> 656 657 <?php 658 esc_html_e( 'purge amp urls', 'nginx-helper' ); 659 ?> 660 </span> 661 </legend> 662 <label for="purge_amp_urls"> 663 <input type="checkbox" value="1" id="purge_amp_urls" name="purge_amp_urls" <?php checked( $nginx_helper_settings['purge_amp_urls'], 1 ); ?> /> 664 665 <?php 666 echo wp_kses( 667 __( 'purge <strong>amp urls</strong> along with <strong>posts</strong> & <strong>pages</strong>.', 'nginx-helper' ), 668 array( 'strong' => array() ) 669 ); 544 670 ?> 545 671 </label> -
nginx-helper/trunk/includes/class-nginx-helper-activator.php
r1976548 r3213676 58 58 59 59 wp_schedule_event( time(), 'daily', 'rt_wp_nginx_helper_check_log_file_size_daily' ); 60 61 if( method_exists( $nginx_helper_admin, 'store_default_options' ) ) { 62 $nginx_helper_admin->store_default_options(); 63 } 60 64 61 65 } -
nginx-helper/trunk/includes/class-nginx-helper.php
r3071366 r3213676 78 78 79 79 $this->plugin_name = 'nginx-helper'; 80 $this->version = '2. 2.5';80 $this->version = '2.3.0'; 81 81 $this->minimum_wp = '3.0'; 82 82 … … 170 170 171 171 $nginx_helper_admin = new Nginx_Helper_Admin( $this->get_plugin_name(), $this->get_version() ); 172 172 $this->loader->add_action( 'init', $nginx_helper_admin, 'initialize_setting_tab' ); 173 173 // Defines global variables. 174 174 if ( ! empty( $nginx_helper_admin->options['cache_method'] ) && 'enable_redis' === $nginx_helper_admin->options['cache_method'] ) { … … 228 228 // expose action to allow other plugins to purge the cache. 229 229 $this->loader->add_action( 'rt_nginx_helper_purge_all', $nginx_purger, 'purge_all' ); 230 231 // add action to preload the cache 232 $this->loader->add_action( 'admin_init', $nginx_helper_admin, 'preload_cache' ); 230 233 } 231 234 -
nginx-helper/trunk/languages/nginx-helper.po
r3071366 r3213676 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Nginx Helper 2. 2.5\n"5 "Project-Id-Version: Nginx Helper 2.3.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/nginx-helper\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2024- 04-15T10:26:40+00:00\n"12 "POT-Creation-Date: 2024-12-19T06:01:42+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 "X-Generator: WP-CLI 2. 9.0\n"14 "X-Generator: WP-CLI 2.11.0\n" 15 15 "X-Domain: nginx-helper\n" 16 16 17 17 #. Plugin Name of the plugin 18 #: admin/class-nginx-helper-admin.php:177 19 #: admin/class-nginx-helper-admin.php:178 20 #: admin/class-nginx-helper-admin.php:188 21 #: admin/class-nginx-helper-admin.php:189 18 #: nginx-helper.php 19 #: admin/class-nginx-helper-admin.php:183 20 #: admin/class-nginx-helper-admin.php:184 21 #: admin/class-nginx-helper-admin.php:194 22 #: admin/class-nginx-helper-admin.php:195 22 23 msgid "Nginx Helper" 23 24 msgstr "" 24 25 25 26 #. Plugin URI of the plugin 27 #: nginx-helper.php 26 28 msgid "https://rtcamp.com/nginx-helper/" 27 29 msgstr "" 28 30 29 31 #. Description of the plugin 32 #: nginx-helper.php 30 33 msgid "Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does few more things." 31 34 msgstr "" 32 35 33 36 #. Author of the plugin 37 #: nginx-helper.php 34 38 msgid "rtCamp" 35 39 msgstr "" 36 40 37 41 #. Author URI of the plugin 42 #: nginx-helper.php 38 43 msgid "https://rtcamp.com" 39 44 msgstr "" 40 45 41 #: admin/class-nginx-helper-admin.php: 8846 #: admin/class-nginx-helper-admin.php:97 42 47 msgid "General" 43 48 msgstr "" 44 49 45 #: admin/class-nginx-helper-admin.php: 9250 #: admin/class-nginx-helper-admin.php:101 46 51 msgid "Support" 47 52 msgstr "" 48 53 49 #: admin/class-nginx-helper-admin.php:16 054 #: admin/class-nginx-helper-admin.php:166 50 55 msgid "Purging entire cache is not recommended. Would you like to continue?" 51 56 msgstr "" 52 57 53 #: admin/class-nginx-helper-admin.php:21 258 #: admin/class-nginx-helper-admin.php:218 54 59 msgid "Purge Cache" 55 60 msgstr "" 56 61 57 #: admin/class-nginx-helper-admin.php:2 1562 #: admin/class-nginx-helper-admin.php:221 58 63 msgid "Purge Current Page" 59 64 msgstr "" 60 65 61 #: admin/class-nginx-helper-admin.php:3 4266 #: admin/class-nginx-helper-admin.php:387 62 67 msgid "Settings" 63 68 msgstr "" 64 69 65 #: admin/class-nginx-helper-admin.php:4 2670 #: admin/class-nginx-helper-admin.php:471 66 71 msgid "No items" 67 72 msgstr "" 68 73 69 #: admin/class-nginx-helper-admin.php:4 3774 #: admin/class-nginx-helper-admin.php:482 70 75 msgid "Posted " 71 76 msgstr "" 72 77 73 #: admin/class-nginx-helper-admin.php: 77678 #: admin/class-nginx-helper-admin.php:825 74 79 msgid "Purge initiated" 80 msgstr "" 81 82 #: admin/class-nginx-helper-admin.php:907 83 msgid "Failed to parse the sitemap XML" 75 84 msgstr "" 76 85 … … 237 246 msgstr "" 238 247 239 #: admin/partials/nginx-helper-general-options.php: 82248 #: admin/partials/nginx-helper-general-options.php:90 240 249 msgid "Log file size must be a number." 241 250 msgstr "" 242 251 243 #: admin/partials/nginx-helper-general-options.php: 92252 #: admin/partials/nginx-helper-general-options.php:100 244 253 msgid "Settings saved." 245 254 msgstr "" 246 255 247 #: admin/partials/nginx-helper-general-options.php:1 19256 #: admin/partials/nginx-helper-general-options.php:127 248 257 msgid "Purging Options" 249 258 msgstr "" 250 259 251 #: admin/partials/nginx-helper-general-options.php:1 26260 #: admin/partials/nginx-helper-general-options.php:134 252 261 msgid "Enable Purge" 253 262 msgstr "" 254 263 255 #: admin/partials/nginx-helper-general-options.php:136 264 #: admin/partials/nginx-helper-general-options.php:140 265 msgid "Preload Cache" 266 msgstr "" 267 268 #: admin/partials/nginx-helper-general-options.php:150 256 269 msgid "Caching Method" 257 270 msgstr "" 258 271 259 #: admin/partials/nginx-helper-general-options.php:1 48272 #: admin/partials/nginx-helper-general-options.php:162 260 273 msgid "nginx Fastcgi cache" 261 274 msgstr "" 262 275 263 #: admin/partials/nginx-helper-general-options.php:1 50276 #: admin/partials/nginx-helper-general-options.php:164 264 277 msgid "External settings for nginx" 265 278 msgstr "" 266 279 267 #: admin/partials/nginx-helper-general-options.php:1 51280 #: admin/partials/nginx-helper-general-options.php:165 268 281 msgid "requires external settings for nginx" 269 282 msgstr "" 270 283 271 #: admin/partials/nginx-helper-general-options.php:1 61284 #: admin/partials/nginx-helper-general-options.php:175 272 285 msgid "Redis cache" 273 286 msgstr "" 274 287 275 #: admin/partials/nginx-helper-general-options.php:1 71288 #: admin/partials/nginx-helper-general-options.php:185 276 289 msgid "Purge Method" 277 290 msgstr "" 278 291 279 #: admin/partials/nginx-helper-general-options.php:1 81280 #: admin/partials/nginx-helper-general-options.php: 361292 #: admin/partials/nginx-helper-general-options.php:195 293 #: admin/partials/nginx-helper-general-options.php:455 281 294 msgid "when a post/page/custom post is published." 282 295 msgstr "" 283 296 284 #: admin/partials/nginx-helper-general-options.php: 191297 #: admin/partials/nginx-helper-general-options.php:205 285 298 msgid "Using a GET request to" 286 299 msgstr "" 287 300 288 #: admin/partials/nginx-helper-general-options.php: 192301 #: admin/partials/nginx-helper-general-options.php:206 289 302 msgid "(Default option)" 290 303 msgstr "" 291 304 292 305 #. translators: %s Nginx cache purge module link. 293 #: admin/partials/nginx-helper-general-options.php:2 03306 #: admin/partials/nginx-helper-general-options.php:217 294 307 msgid "Uses the %s module." 295 308 msgstr "" 296 309 297 #: admin/partials/nginx-helper-general-options.php:2 21310 #: admin/partials/nginx-helper-general-options.php:235 298 311 msgid "Delete local server cache files" 299 312 msgstr "" 300 313 301 #: admin/partials/nginx-helper-general-options.php:2 27314 #: admin/partials/nginx-helper-general-options.php:241 302 315 msgid "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\")." 303 316 msgstr "" 304 317 305 #: admin/partials/nginx-helper-general-options.php:2 42318 #: admin/partials/nginx-helper-general-options.php:256 306 319 msgid "Redis Settings" 307 320 msgstr "" 308 321 309 #: admin/partials/nginx-helper-general-options.php:2 47322 #: admin/partials/nginx-helper-general-options.php:261 310 323 msgid "Hostname" 311 324 msgstr "" 312 325 313 #: admin/partials/nginx-helper-general-options.php:254 314 #: admin/partials/nginx-helper-general-options.php:269 315 #: admin/partials/nginx-helper-general-options.php:284 326 #: admin/partials/nginx-helper-general-options.php:268 327 #: admin/partials/nginx-helper-general-options.php:290 328 #: admin/partials/nginx-helper-general-options.php:314 329 #: admin/partials/nginx-helper-general-options.php:329 330 #: admin/partials/nginx-helper-general-options.php:344 331 #: admin/partials/nginx-helper-general-options.php:360 332 #: admin/partials/nginx-helper-general-options.php:378 316 333 msgid "Overridden by constant variables." 317 334 msgstr "" 318 335 319 #: admin/partials/nginx-helper-general-options.php:262 336 #: admin/partials/nginx-helper-general-options.php:276 337 #: admin/partials/nginx-helper-general-options.php:299 338 msgid "Overridden by unix socket path." 339 msgstr "" 340 341 #: admin/partials/nginx-helper-general-options.php:283 320 342 msgid "Port" 321 343 msgstr "" 322 344 323 #: admin/partials/nginx-helper-general-options.php:277 345 #: admin/partials/nginx-helper-general-options.php:307 346 msgid "Socket Path" 347 msgstr "" 348 349 #: admin/partials/nginx-helper-general-options.php:322 324 350 msgid "Prefix" 325 351 msgstr "" 326 352 327 #: admin/partials/nginx-helper-general-options.php:297 353 #: admin/partials/nginx-helper-general-options.php:337 354 msgid "Database" 355 msgstr "" 356 357 #: admin/partials/nginx-helper-general-options.php:353 358 msgid "Username" 359 msgstr "" 360 361 #: admin/partials/nginx-helper-general-options.php:369 362 msgid "Password" 363 msgstr "" 364 365 #: admin/partials/nginx-helper-general-options.php:391 328 366 msgid "Purging Conditions" 329 367 msgstr "" 330 368 331 #: admin/partials/nginx-helper-general-options.php:3 02369 #: admin/partials/nginx-helper-general-options.php:396 332 370 msgid "Purge Homepage:" 333 371 msgstr "" 334 372 335 #: admin/partials/nginx-helper-general-options.php: 309373 #: admin/partials/nginx-helper-general-options.php:403 336 374 msgid "when a post/page/custom post is modified or added." 337 375 msgstr "" 338 376 339 #: admin/partials/nginx-helper-general-options.php: 318340 #: admin/partials/nginx-helper-general-options.php: 445377 #: admin/partials/nginx-helper-general-options.php:412 378 #: admin/partials/nginx-helper-general-options.php:539 341 379 msgid "when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>." 342 380 msgstr "" 343 381 344 #: admin/partials/nginx-helper-general-options.php: 330382 #: admin/partials/nginx-helper-general-options.php:424 345 383 msgid "when an existing post/page/custom post is modified." 346 384 msgstr "" 347 385 348 #: admin/partials/nginx-helper-general-options.php: 339386 #: admin/partials/nginx-helper-general-options.php:433 349 387 msgid "when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>" 350 388 msgstr "" 351 389 352 #: admin/partials/nginx-helper-general-options.php: 353390 #: admin/partials/nginx-helper-general-options.php:447 353 391 msgid "Purge Post/Page/Custom Post Type:" 354 392 msgstr "" 355 393 356 #: admin/partials/nginx-helper-general-options.php: 370394 #: admin/partials/nginx-helper-general-options.php:464 357 395 msgid "when a <strong>post</strong> is <strong>published</strong>." 358 396 msgstr "" 359 397 360 #: admin/partials/nginx-helper-general-options.php: 382361 #: admin/partials/nginx-helper-general-options.php: 479398 #: admin/partials/nginx-helper-general-options.php:476 399 #: admin/partials/nginx-helper-general-options.php:573 362 400 msgid "when a comment is approved/published." 363 401 msgstr "" 364 402 365 #: admin/partials/nginx-helper-general-options.php: 391366 #: admin/partials/nginx-helper-general-options.php: 488403 #: admin/partials/nginx-helper-general-options.php:485 404 #: admin/partials/nginx-helper-general-options.php:582 367 405 msgid "when a <strong>comment</strong> is <strong>approved/published</strong>." 368 406 msgstr "" 369 407 370 #: admin/partials/nginx-helper-general-options.php:4 03371 #: admin/partials/nginx-helper-general-options.php:5 00408 #: admin/partials/nginx-helper-general-options.php:497 409 #: admin/partials/nginx-helper-general-options.php:594 372 410 msgid "when a comment is unapproved/deleted." 373 411 msgstr "" 374 412 375 #: admin/partials/nginx-helper-general-options.php: 412376 #: admin/partials/nginx-helper-general-options.php: 509413 #: admin/partials/nginx-helper-general-options.php:506 414 #: admin/partials/nginx-helper-general-options.php:603 377 415 msgid "when a <strong>comment</strong> is <strong>unapproved/deleted</strong>." 378 416 msgstr "" 379 417 380 #: admin/partials/nginx-helper-general-options.php: 426418 #: admin/partials/nginx-helper-general-options.php:520 381 419 msgid "Purge Archives:" 382 420 msgstr "" 383 421 384 #: admin/partials/nginx-helper-general-options.php: 428422 #: admin/partials/nginx-helper-general-options.php:522 385 423 msgid "(date, category, tag, author, custom taxonomies)" 386 424 msgstr "" 387 425 388 #: admin/partials/nginx-helper-general-options.php: 436426 #: admin/partials/nginx-helper-general-options.php:530 389 427 msgid "when an post/page/custom post is modified or added" 390 428 msgstr "" 391 429 392 #: admin/partials/nginx-helper-general-options.php: 457430 #: admin/partials/nginx-helper-general-options.php:551 393 431 msgid "when an existing post/page/custom post is trashed." 394 432 msgstr "" 395 433 396 #: admin/partials/nginx-helper-general-options.php: 466434 #: admin/partials/nginx-helper-general-options.php:560 397 435 msgid "when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>." 398 436 msgstr "" 399 437 400 #: admin/partials/nginx-helper-general-options.php: 523438 #: admin/partials/nginx-helper-general-options.php:617 401 439 msgid "Purge Feeds:" 402 440 msgstr "" 403 441 404 #: admin/partials/nginx-helper-general-options.php: 532442 #: admin/partials/nginx-helper-general-options.php:626 405 443 msgid "purge feeds" 406 444 msgstr "" 407 445 408 #: admin/partials/nginx-helper-general-options.php: 541446 #: admin/partials/nginx-helper-general-options.php:635 409 447 msgid "purge <strong>feeds</strong> along with <strong>posts</strong> & <strong>pages</strong>." 410 448 msgstr "" 411 449 412 #: admin/partials/nginx-helper-general-options.php:554 450 #: admin/partials/nginx-helper-general-options.php:649 451 msgid "Purge AMP URL:" 452 msgstr "" 453 454 #: admin/partials/nginx-helper-general-options.php:658 455 msgid "purge amp urls" 456 msgstr "" 457 458 #: admin/partials/nginx-helper-general-options.php:667 459 msgid "purge <strong>amp urls</strong> along with <strong>posts</strong> & <strong>pages</strong>." 460 msgstr "" 461 462 #: admin/partials/nginx-helper-general-options.php:680 413 463 msgid "Custom Purge URL:" 414 464 msgstr "" 415 465 416 #: admin/partials/nginx-helper-general-options.php: 560466 #: admin/partials/nginx-helper-general-options.php:686 417 467 msgid "Add one URL per line. URL should not contain domain name." 418 468 msgstr "" 419 469 420 #: admin/partials/nginx-helper-general-options.php: 563470 #: admin/partials/nginx-helper-general-options.php:689 421 471 msgid "Eg: To purge http://example.com/sample-page/ add <strong>/sample-page/</strong> in above textarea." 422 472 msgstr "" 423 473 424 #: admin/partials/nginx-helper-general-options.php: 567474 #: admin/partials/nginx-helper-general-options.php:693 425 475 msgid "'*' will only work with redis cache server." 426 476 msgstr "" 427 477 428 #: admin/partials/nginx-helper-general-options.php: 577478 #: admin/partials/nginx-helper-general-options.php:703 429 479 msgid "Debug Options" 430 480 msgstr "" 431 481 432 #: admin/partials/nginx-helper-general-options.php: 587482 #: admin/partials/nginx-helper-general-options.php:713 433 483 msgid "Enable Nginx Map." 434 484 msgstr "" 435 485 436 #: admin/partials/nginx-helper-general-options.php: 606486 #: admin/partials/nginx-helper-general-options.php:732 437 487 msgid "Enable Logging" 438 488 msgstr "" 439 489 440 #: admin/partials/nginx-helper-general-options.php: 611490 #: admin/partials/nginx-helper-general-options.php:737 441 491 msgid "disable" 442 492 msgstr "" 443 493 444 #: admin/partials/nginx-helper-general-options.php: 617494 #: admin/partials/nginx-helper-general-options.php:743 445 495 msgid "enable" 446 496 msgstr "" 447 497 448 #: admin/partials/nginx-helper-general-options.php: 624498 #: admin/partials/nginx-helper-general-options.php:750 449 499 msgid "NOTE" 450 500 msgstr "" 451 501 452 #: admin/partials/nginx-helper-general-options.php: 625502 #: admin/partials/nginx-helper-general-options.php:751 453 503 msgid "To" 454 504 msgstr "" 455 505 456 #: admin/partials/nginx-helper-general-options.php: 627506 #: admin/partials/nginx-helper-general-options.php:753 457 507 msgid "the logging feature, you must define" 458 508 msgstr "" 459 509 460 #: admin/partials/nginx-helper-general-options.php: 628510 #: admin/partials/nginx-helper-general-options.php:754 461 511 msgid "as" 462 512 msgstr "" 463 513 464 #: admin/partials/nginx-helper-general-options.php: 630514 #: admin/partials/nginx-helper-general-options.php:756 465 515 msgid "in your" 466 516 msgstr "" 467 517 468 #: admin/partials/nginx-helper-general-options.php: 641518 #: admin/partials/nginx-helper-general-options.php:767 469 519 msgid "Enable Nginx Timestamp in HTML" 470 520 msgstr "" 471 521 472 #: admin/partials/nginx-helper-general-options.php: 655522 #: admin/partials/nginx-helper-general-options.php:781 473 523 msgid "Nginx Map" 474 524 msgstr "" 475 525 476 #: admin/partials/nginx-helper-general-options.php: 664526 #: admin/partials/nginx-helper-general-options.php:790 477 527 msgid "Can't write on map file." 478 528 msgstr "" 479 529 480 530 #. translators: %s file url. 481 #: admin/partials/nginx-helper-general-options.php: 669482 #: admin/partials/nginx-helper-general-options.php: 741531 #: admin/partials/nginx-helper-general-options.php:795 532 #: admin/partials/nginx-helper-general-options.php:867 483 533 msgid "Check you have write permission on <strong>%s</strong>" 484 534 msgstr "" 485 535 486 #: admin/partials/nginx-helper-general-options.php: 686536 #: admin/partials/nginx-helper-general-options.php:812 487 537 msgid "Nginx Map path to include in nginx settings" 488 538 msgstr "" 489 539 490 #: admin/partials/nginx-helper-general-options.php: 687540 #: admin/partials/nginx-helper-general-options.php:813 491 541 msgid "(recommended)" 492 542 msgstr "" 493 543 494 #: admin/partials/nginx-helper-general-options.php: 700544 #: admin/partials/nginx-helper-general-options.php:826 495 545 msgid "Or," 496 546 msgstr "" 497 547 498 #: admin/partials/nginx-helper-general-options.php: 701548 #: admin/partials/nginx-helper-general-options.php:827 499 549 msgid "Text to manually copy and paste in nginx settings" 500 550 msgstr "" 501 551 502 #: admin/partials/nginx-helper-general-options.php: 702552 #: admin/partials/nginx-helper-general-options.php:828 503 553 msgid "(if your network is small and new sites are not added frequently)" 504 554 msgstr "" 505 555 506 #: admin/partials/nginx-helper-general-options.php: 720556 #: admin/partials/nginx-helper-general-options.php:846 507 557 msgid "Logging Options" 508 558 msgstr "" 509 559 510 #: admin/partials/nginx-helper-general-options.php: 736560 #: admin/partials/nginx-helper-general-options.php:862 511 561 msgid "Can't write on log file." 512 562 msgstr "" 513 563 514 #: admin/partials/nginx-helper-general-options.php: 758564 #: admin/partials/nginx-helper-general-options.php:884 515 565 msgid "Logs path" 516 566 msgstr "" 517 567 518 #: admin/partials/nginx-helper-general-options.php: 770568 #: admin/partials/nginx-helper-general-options.php:896 519 569 msgid "View Log" 520 570 msgstr "" 521 571 522 #: admin/partials/nginx-helper-general-options.php: 775572 #: admin/partials/nginx-helper-general-options.php:901 523 573 msgid "Log" 524 574 msgstr "" 525 575 526 #: admin/partials/nginx-helper-general-options.php: 782576 #: admin/partials/nginx-helper-general-options.php:908 527 577 msgid "Log level" 528 578 msgstr "" 529 579 530 #: admin/partials/nginx-helper-general-options.php: 787580 #: admin/partials/nginx-helper-general-options.php:913 531 581 msgid "None" 532 582 msgstr "" 533 583 534 #: admin/partials/nginx-helper-general-options.php: 788584 #: admin/partials/nginx-helper-general-options.php:914 535 585 msgid "Info" 536 586 msgstr "" 537 587 538 #: admin/partials/nginx-helper-general-options.php: 789588 #: admin/partials/nginx-helper-general-options.php:915 539 589 msgid "Warning" 540 590 msgstr "" 541 591 542 #: admin/partials/nginx-helper-general-options.php: 790592 #: admin/partials/nginx-helper-general-options.php:916 543 593 msgid "Error" 544 594 msgstr "" 545 595 546 #: admin/partials/nginx-helper-general-options.php: 797596 #: admin/partials/nginx-helper-general-options.php:923 547 597 msgid "Max log file size" 548 598 msgstr "" 549 599 550 #: admin/partials/nginx-helper-general-options.php: 803600 #: admin/partials/nginx-helper-general-options.php:929 551 601 msgid "Mb" 552 602 msgstr "" 553 603 554 #: admin/partials/nginx-helper-general-options.php: 820604 #: admin/partials/nginx-helper-general-options.php:946 555 605 msgid "Save All Changes" 556 606 msgstr "" … … 654 704 655 705 #. translators: %s is Minimum WP version. 656 #: includes/class-nginx-helper.php:31 1706 #: includes/class-nginx-helper.php:314 657 707 msgid "Sorry, Nginx Helper requires WordPress %s or higher" 658 708 msgstr "" -
nginx-helper/trunk/nginx-helper.php
r3071366 r3213676 4 4 * Plugin URI: https://rtcamp.com/nginx-helper/ 5 5 * Description: Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does few more things. 6 * Version: 2. 2.56 * Version: 2.3.0 7 7 * Author: rtCamp 8 8 * Author URI: https://rtcamp.com … … 10 10 * Domain Path: /languages 11 11 * Requires at least: 3.0 12 * Tested up to: 6. 412 * Tested up to: 6.7 13 13 * 14 14 * @link https://rtcamp.com/nginx-helper/ -
nginx-helper/trunk/readme.txt
r3071384 r3213676 6 6 License URI: http://www.gnu.org/licenses/gpl-2.0.html 7 7 Requires at least: 3.0 8 Tested up to: 6. 59 Stable tag: 2. 2.58 Tested up to: 6.7 9 Stable tag: 2.3.0 10 10 11 11 Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does a few more things. … … 107 107 ``` 108 108 109 **Q. Can I override the redis socket path, username, password?** 110 111 Yes, you can force override the redis socket path, username, password by defining constant in wp-config.php. For example: 112 113 ```php 114 define( 'RT_WP_NGINX_HELPER_REDIS_UNIX_SOCKET', '/var/run/redis/redis.sock' ); 115 116 define( 'RT_WP_NGINX_HELPER_REDIS_USERNAME', 'admin' ); 117 118 define( 'RT_WP_NGINX_HELPER_REDIS_PASSWORD', 'admin' ); 119 ``` 120 109 121 = FAQ - Nginx Map = 110 122 … … 117 129 Most likely yes. A wordpress plugin, if not using explicitly any Apache-only mod, should work on Nginx. Some plugin may need some extra work. 118 130 131 132 = FAQ - WP-CLI = 133 134 **Q. How can I update the options using WP-CLI?** 135 136 ```shell 137 wp option patch update rt_wp_nginx_helper_options <option_name> <option_value> 138 ``` 119 139 120 140 = Still need help! = … … 127 147 128 148 == Changelog == 149 150 = 2.3.0 = 151 152 * Disable the purge functionality when importing data. [#52](https://github.com/rtCamp/nginx-helper/pull/52) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi) 153 * Added option to preload cache for all Post and Pages. [#47](https://github.com/rtCamp/nginx-helper/pull/47) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi) 154 * Added the capability to purge Amp URL's. [#135](https://github.com/rtCamp/nginx-helper/pull/135) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi) 155 * Add support for adding Username, Password support for Redis. It also includes the support for Unix Socket Path for Redis along with Database selection. [#343](https://github.com/rtCamp/nginx-helper/pull/343),[#350](https://github.com/rtCamp/nginx-helper/pull/350) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi) 156 * Add capability to allow modifying options using WP-CLI. [#307](https://github.com/rtCamp/nginx-helper/pull/307) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi) 157 * Fix the plugin crash issue due to internationalization after upgrading to WordPress Version 6.7. [#364](https://github.com/rtCamp/nginx-helper/pull/364) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi) 158 129 159 130 160 = 2.2.5 =
Note: See TracChangeset
for help on using the changeset viewer.