Plugin Directory

Changeset 2925069


Ignore:
Timestamp:
06/13/2023 05:22:31 AM (3 years ago)
Author:
stefanpejcic
Message:
  • settings pages to set custom server and port, monitor resources and cache warmup
Location:
use-memcached/trunk
Files:
10 added
5 edited

Legend:

Unmodified
Added
Removed
  • use-memcached/trunk/classes/AdminNotices.php

    r2225295 r2925069  
    9898        ) {
    9999            $this->enqueue(
    100                 __( "Some memcache servers are not reachable. Please check memcached service and connection settings.", DOMAIN )
     100                __( "Some memcache servers are not reachable. Please check <a href='/wp-admin/admin.php?page=use-memcached'>memcached service and connection settings</a>.", DOMAIN )
    101101            );
    102102        } else if(
  • use-memcached/trunk/classes/Tools.php

    r2259565 r2925069  
    1515    public function __construct(Plugin $plugin) {
    1616        $this->plugin = $plugin;
    17         add_action( 'admin_menu', array( $this, 'admin_menu' ) );
    1817        add_action( 'admin_init', array($this, 'save_settings') );
    1918    }
     
    2423     */
    2524    public function getUrl(){
    26         return admin_url("tools.php?page=use_memcached");
    27     }
    28 
    29     public function admin_menu() {
    30         add_management_page(
    31             __("Tools › Use Memcached", DOMAIN),
    32             __("Use Memcached", DOMAIN),
    33             "manage_options",
    34             self::SLUG,
    35             array( $this, 'render' )
    36         );
     25        return admin_url("admin.php?page=use-memcached");
    3726    }
    3827
     
    5443        }
    5544    }
    56 
    57     public function render(){
    58 
    59         echo "<div class='wrap'>";
    60         echo sprintf("<h2>%s</h2>", __("Use Memcached", DOMAIN));
    61 
    62         if(!function_exists("use_memcached_get_configuration")){
    63             printf("<p>%s</p>", __("Cannot find use_memcached_get_configuration function.", DOMAIN));
    64             return;
    65         }
    66 
    67         $config = use_memcached_get_configuration();
    68 
    69         $buttonText = (!$config->isEnabled())?
    70             __("Memcached is disabled. Enable memcached!", DOMAIN)
    71             :
    72             __("Memcache is enabled. Disable memcached!", DOMAIN);
    73 
    74         $primaryClass = (!$config->isEnabled())?
    75             "": "button-primary";
    76 
    77         echo "<form method='post'>";
    78             echo "<input type='hidden' name='use_memcached_disable_toggle' value='yes' />";
    79             echo "<p style='text-align: center;'>";
    80             echo "<button class='button $primaryClass button-hero'>$buttonText</button>";
    81             echo "</p>";
    82         echo "</form>";
    83 
    84         if($config->isEnabled()){
    85             $this->renderStats();
    86         } else {
    87             printf(
    88                 "<p style='text-align: center;' class='description'>%s</p>",
    89                 __("No info available because Memcached is disabled.", DOMAIN)
    90             );
    91         }
    92 
    93         echo "</div>";
    94     }
    95 
    96     private function renderStats(){
    97 
    98         $config = use_memcached_get_configuration();
    99         if($config->isFreistil()){
    100             echo "<p>We have Freistil infrastructure</p>";
    101         } else {
    102             echo "<p>We do not have Freistil infrastructure</p>";
    103         }
    104 
    105 
    106         $this->renderRow(
    107             __("Freistil prefix", DOMAIN),
    108             $this->plugin->memcache->getFreistilPrefix()
    109         );
    110         $this->renderRow(
    111             __("Global prefix", DOMAIN),
    112             $this->plugin->memcache->getGlobalPrefix()
    113         );
    114         $this->renderRow(
    115             __("Blog prefix", DOMAIN),
    116             $this->plugin->memcache->getBlogPrefix()
    117         );
    118 
    119         $stats = $this->plugin->memcache->stats(true);
    120         if(is_array($stats)){
    121 
    122             foreach ($stats as $buckets){
    123                 foreach ($buckets as $ip => $server){
    124                     echo "<h3>$ip</h3>";
    125                     foreach ($server as $key =>  $value){
    126                         $this->renderRow($key, $value);
    127                     }
    128 
    129                 }
    130             }
    131         } else {
    132             sprintf("<p>%s</p>",__("No stats available", DOMAIN));
    133         }
    134 
    135     }
    136 
    137     private function renderRow($key, $value){
    138         echo "<div><p><strong>$key:</strong> $value</p></div>";
    139     }
    14045}
  • use-memcached/trunk/plugin.php

    r2924652 r2925069  
    55 * Plugin URI: https://github.com/palasthotel/use-memcached
    66 * Description: Adds memcached support for WP_Object_Cache.
    7  * Version: 1.0.4
     7 * Version: 1.0.5
    88 * Text Domain: use-memcached
    99 * Domain Path: /languages
    10  * Author: Edward Bock
    11  * Author URI: https://profiles.wordpress.org/edwardbock/
     10 * Author: Palasthotel <[email protected]> (in person: Edward Bock)
     11 * Author URI: http://www.palasthotel.de
    1212 * Requires at least: 5.0
    13  * Tested up to: 5.3.2
     13 * Tested up to: 6.2
    1414 * License: http://www.gnu.org/licenses/gpl-2.0.html GPLv2
    1515 *
     
    2424// ------------------------------------------------------------------------
    2525const DOMAIN = "use-memcached";
     26
     27
     28
     29
     30
    2631
    2732//------------------------------------------------------------------------
     
    124129
    125130require_once dirname( __FILE__ ) . "/cli/wp-cli.php";
     131
     132
     133// Include plugin Settings pages
     134require_once plugin_dir_path( __FILE__ ) . 'includes/use_memcached_main_page.php';
     135require_once plugin_dir_path( __FILE__ ) . 'includes/use_memcached_info_page.php';
     136require_once plugin_dir_path( __FILE__ ) . 'includes/use_memcached_warmer_page.php';
  • use-memcached/trunk/readme.txt

    r2924652 r2925069  
    11=== Use Memcached ===
    22Contributors: edwardbock, stefanpejcic
    3 Authors:
     3Donate link: http://palasthotel.de/
    44Tags: cache, performance
    55Requires at least: 5.0
    6 Tested up to: 5.3.2
    7 Stable tag: 1.0.4
     6Tested up to: 6.2
     7Stable tag: 1.0.5
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl
     
    1313== Description ==
    1414
    15 This plugin is no longer actively maintained.
     15Use this to optimize your website performance with Memcached instances.
     16
    1617
    1718== Installation ==
     
    2930If you are using a Memcached service with default values host 127.0.0.1 (localhost) and port 11211 or you are hosting with freistil.it than you don't need to configure anything.
    3031
    31 With other hosters or service settings you need to configure some php variables in wp-config.php file.
     32With other hosters or service settings you need to set the server and port in the plugin settings page.
    3233
    3334
     
    3738
    3839== Changelog ==
     40
     41= 1.0.5 =
     42
     43* Added a settings page where user can set memcached server and port
     44* Added a settings page that allows user to view cached information
    3945
    4046= 1.0.4 =
  • use-memcached/trunk/templates/object-cache.php

    r2259573 r2925069  
    327327
    328328                } else {
    329                     $buckets = array( '127.0.0.1:11211' );
     329                    // Load the wp-config.php file
     330require_once('../wp-config.php');
     331
     332// Check if the constants are defined and not empty
     333if (defined('USE_MEMCACHED_SERVER') && !empty(USE_MEMCACHED_SERVER)) {
     334    $server = USE_MEMCACHED_SERVER;
     335} else {
     336    $server = '127.0.0.1';
     337}
     338
     339if (defined('USE_MEMCACHED_PORT') && !empty(USE_MEMCACHED_PORT)) {
     340    $port = USE_MEMCACHED_PORT;
     341} else {
     342    $port = '11211';
     343}
     344
     345// Create the array with the server and port
     346$buckets = array($server . ':' . $port);
     347               
    330348                }
    331349            }
Note: See TracChangeset for help on using the changeset viewer.