Plugin Directory

Changeset 2502985


Ignore:
Timestamp:
03/25/2021 02:52:15 AM (5 years ago)
Author:
pluginoptimizer
Message:
  • Auto Menu Update Fixed
  • Overview and walkthrough added
  • Other minor tweeks to the code
Location:
plugin-optimizer
Files:
69 added
7 edited

Legend:

Unmodified
Added
Removed
  • plugin-optimizer/trunk/README.txt

    r2501831 r2502985  
    44Requires at least: 5.0
    55Tested up to: 5.7
    6 Stable tag: 1.0.3
     6Stable tag: 1.0.4
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    1515== Plugin Optimizer for WordPress ==
    1616
    17 Tired of WordPress bogging down everytime you load a page?
     17Speed up WordPress by only loading the Plugins you need in each page.
    1818
    19 Are you losing time and money waiting for pages to load?
     19https://youtu.be/_s5p9mor5AU
    2020
    21 Have you tried all the caching plugins but are still having issues?
     21Optimizing your WordPress site with [Plugin Optimizer](https://pluginoptimizer.com/?utm_source=po-lite&utm_campaign=wp-repo&utm_medium=readme&utm_term=pluginoptimizer) is easy and can reduce load times as much as 90%.
    2222
    23 You don't need to anymore.
     23Faster page load, faster wp-admin, and faster page editing.
    2424
    25 Meet [Plugin Optimizer](https://pluginoptimizer.com/?utm_source=po-lite&utm_campaign=wp-repo&utm_medium=readme&utm_term=pluginoptimizer): The most innovative and affordable way to speed up your WordPress site for you, your team, and your subscribers.  It makes the process easy and intuitive to remove all your load time problems.
     25Speed up your site today with by only loading the plugin code needed for any particular page.   
     26
     27Plugin Optimizer works completely different than any other Page Speed / Site Speed plugin or tool.
     28
     29Plugin Optimizer does not affect minifying, cache, image load/size or scripts. It works by filtering the plugins and only allowing the necessary plugins for each page to load.
     30
     31Once installed and configured you will see an instant boost in any optimized page.
     32
     33Speed up the back-end development environment and speed up the front-end user experience.
     34
     35== Features ==
     36
     37* Page size reduction by stripping code from unneeded plugins on each optimized page
     38* Step-by-Step Wizard for creating Filters, Groups, and Categories
     39* Custom filters for maximizing user experience
     40* Boost speed for both backend and frontend pages
     41* Speed up editing of content
     42* Instant page speed boost on optimized pages
     43* Reduction in server load - get great results with even basic shared server accounts
     44* Works great in combination with a cache plugin (e.g. WP Rocket, WP Fastest Cache, W3 Total Cache), a hosting company that offers packages with server-level caching available (e.g. WordKeeper) or a service like Cloudflare that has page caching enabled.
    2645
    2746== Installation ==
     
    3352== Changelog ==
    3453
    35 = 1.0.0 =
     54= 1.0.4 = March 2021
     55* Auto Menu Update Fixed
     56* Overview and walkthrough added
     57* Other minor tweeks to the code
     58
     59= 1.0.3 = March 2021
    3660* Initial Deployment.
    3761
    3862## Privacy Policy
    39 
    4063Plugin Optimizer uses [Appsero](https://appsero.com) SDK to collect some telemetry data upon user's confirmation. This helps us to troubleshoot problems faster & make product improvements.
    4164Appsero SDK **does not gather any data by default.** The SDK only starts gathering basic telemetry data **when a user allows it via the admin notice**. We collect the data to ensure a great user experience for all our users.
  • plugin-optimizer/trunk/admin/class-po-admin-helper.php

    r2501831 r2502985  
    221221                }
    222222               
    223                 // Jake's note: implode failing on empty array;
    224                 if( $categories = get_post_meta( $filter->ID, 'categories', true ) ){
    225 
    226                     if (!empty($categories)){
    227 
    228                         $categories = implode( ',<br>', $categories );
    229                     }
    230                 }
     223                $categories = get_post_meta( $filter->ID, 'categories', true );
     224                $categories = ! empty( $categories ) ? implode( ',<br>', $categories ) : "";
     225               
    231226
    232227                $date = date("Ym",  strtotime( $filter->post_date ) );// 202109
     
    373368        foreach ( $active_plugins as $plugin_id ) {
    374369           
    375             if( $plugin_id != "plugin-optimizer/plugin-optimizer.php" || ! $remove_po ){
     370            if( ! in_array( $plugin_id, sospo_mu_plugin()->po_plugins ) || ! $remove_po ){
    376371                $plugins_simple_list["active"][ $plugin_id ] = $all_plugins[ $plugin_id ][ 'Name' ];
    377372                $plugins_simple_list["all"][ $plugin_id ]    = $all_plugins[ $plugin_id ][ 'Name' ];
     
    389384        foreach ( $all_plugins as $plugin_id => $plugin_data ) {
    390385           
    391             if( $plugin_id != "plugin-optimizer/plugin-optimizer.php" || ! $remove_po ){
     386            if( ! in_array( $plugin_id, sospo_mu_plugin()->po_plugins ) || ! $remove_po ){
    392387                $plugins_simple_list["inactive"][ $plugin_id ] = $all_plugins[ $plugin_id ][ 'Name' ];
    393388                $plugins_simple_list["all"][ $plugin_id ]      = $all_plugins[ $plugin_id ][ 'Name' ];
  • plugin-optimizer/trunk/admin/class-po-admin-pages.php

    r2501831 r2502985  
    2121
    2222        // add_menu_page( 'Plugin Optimizer', 'Plugin Optimizer', 'manage_options', 'plugin_optimizer', [ $this, 'render_overview_page' ], 'dashicons-sos' );
    23         add_menu_page( 'Plugin Optimizer', 'Plugin Optimizer', 'manage_options', 'plugin_optimizer', [ $this, 'render_filters_page' ], 'dashicons-sos' );
    24        
    2523        // add_submenu_page( 'plugin_optimizer', 'Overview',           'Overview',             'manage_options', 'plugin_optimizer',                    [ $this, 'render_overview_page'           ] );
    2624        // add_submenu_page( 'plugin_optimizer', 'Filters',            'Filters',              'manage_options', 'plugin_optimizer_filters',            [ $this, 'render_filters_page'            ] );
     25       
     26        add_menu_page( 'Plugin Optimizer', 'Plugin Optimizer', 'manage_options', 'plugin_optimizer', [ $this, 'render_filters_page' ], 'dashicons-sos' );
    2727        add_submenu_page( 'plugin_optimizer', 'Filters',            'Filters',              'manage_options', 'plugin_optimizer',                    [ $this, 'render_filters_page'            ] );
     28       
     29        // and plugin-optimizer\admin\js\po-admin.js
     30       
    2831        add_submenu_page( 'plugin_optimizer', 'Filter',             'Create Filter',        'manage_options', 'plugin_optimizer_add_filters',        [ $this, 'render_add_filters_page'        ] );
    2932        add_submenu_page( 'plugin_optimizer', 'Groups',             'Groups',               'manage_options', 'plugin_optimizer_groups',             [ $this, 'render_groups_page'             ] );
  • plugin-optimizer/trunk/admin/js/po-admin-menu-get.js

    r2501831 r2502985  
    4545    let new_html = $('#wp-admin-bar-new-content-default').html();
    4646   
     47    // form the data object for sending
     48    let data = {
     49        action                   : 'po_save_original_menu',
     50        menu_html                : menu_html,
     51        topbar_menu_html         : topbar_menu_html,
     52        new_html                 : new_html
     53    };
    4754   
    4855    // save the menu in wp_options
    49     $.post( po_object.ajax_url, { action  : 'po_save_original_menu', menu_html : menu_html, topbar_menu_html : topbar_menu_html, new_html : new_html }, function( response ) {
     56    $.post( po_object.ajax_url, data, function( response ) {
    5057       
    5158        $('#po_please_wait_message').html('Refreshing...');
    5259       
    53         if( po_object.redirect_to ){
    54            
    55             console.log( "Redirecting to the original page..." );
    56             window.location.href = po_object.redirect_to;
    57         }
     60        window.location.href = po_object.redirect_to ? po_object.redirect_to : window.location.href;
    5861       
    5962    }, "json");
  • plugin-optimizer/trunk/includes/class-po-mu.php

    r2501831 r2502985  
    44 * Plugin URI:        https://pluginoptimizer.com
    55 * Description:       This MU plugin is required by the Plugin Optimizer plugin. It will be removed upon deactivation.
    6  * Version:           1.0.3
     6 * Version:           1.0.4
    77 * Author:            pluginoptimizer
    88 * Author URI:        https://pluginoptimizer.com/about/
     
    1515    protected static $instance      = null;
    1616   
     17    public $po_plugins              = [];
    1718    protected $po_pages             = [];
    1819    protected $po_post_types        = [];
     
    2930    public $filters_in_use          = [];
    3031
    31     private function __construct() {
     32    private function __construct() {
    3233       
    3334        if( wp_doing_ajax() || wp_doing_cron() ){
     
    3536        }
    3637       
     38        $this->po_plugins = [
     39            "plugin-optimizer/plugin-optimizer.php",
     40            "sos_plugin_optimizer_dictionary_age/sos_plugin_optimizer_dictionary_age.php",
     41            "sos_plugin_optimizer_premium/sos_plugin_optimizer_premium.php",
     42        ];
    3743        $this->po_pages = [
    3844            "/wp-admin/admin.php?page=plugin_optimizer",
     
    4652            "/wp-admin/admin.php?page=plugin_optimizer_settings",
    4753            "/wp-admin/admin.php?page=plugin_optimizer_support",
     54            "/wp-admin/admin.php?page=plugin_optimizer_agent",
     55            "/wp-admin/admin.php?page=plugin_optimizer_pending",
     56            "/wp-admin/admin.php?page=plugin_optimizer_approved"
    4857        ];
    4958        $this->po_post_types = [
     
    5564        $this->set_hooks();
    5665       
    57     }
     66    }
    5867   
    5968    static function get_instance() {
     
    6574        return self::$instance;
    6675
    67     }
    68 
    69 
    70     function set_hooks() {
    71 
    72         add_filter( 'option_active_plugins', [ $this, 'filter_active_plugins_option_value' ], 5 );
    73        
    74         add_action( 'plugins_loaded',        [ $this, 'complete_action_once_plugins_are_loaded' ], 5 );
    75 
    76         add_action( 'shutdown',              [ $this, 'update_worklist_if_needed' ] );
    77 
    78     }
    79 
    80     function complete_action_once_plugins_are_loaded(){
    81 
    82         remove_filter('option_active_plugins', [ $this, 'filter_active_plugins_option_value' ], 5 );
    83        
    84     }
    85 
    86 
    87     function filter_active_plugins_option_value( $active_plugins ) {
     76    }
     77
     78
     79    function set_hooks() {
     80
     81        add_filter( 'option_active_plugins', [ $this, 'filter_active_plugins_option_value' ], 5 );
     82       
     83        add_action( 'plugins_loaded',        [ $this, 'complete_action_once_plugins_are_loaded' ], 5 );
     84
     85        add_action( 'shutdown',              [ $this, 'update_worklist_if_needed' ] );
     86
     87    }
     88
     89    function complete_action_once_plugins_are_loaded(){
     90
     91        remove_filter('option_active_plugins', [ $this, 'filter_active_plugins_option_value' ], 5 );
     92       
     93    }
     94
     95
     96    function filter_active_plugins_option_value( $active_plugins ) {
    8897       
    8998        if( ! empty( $this->all_plugins ) ){
     
    91100        }
    92101       
    93         require_once ABSPATH . 'wp-admin/includes/plugin.php';
     102        require_once ABSPATH . 'wp-admin/includes/plugin.php';
    94103
    95104        remove_filter('option_active_plugins', [ $this, 'filter_active_plugins_option_value' ], 5 );
     
    98107       
    99108        $this->original_active_plugins  = $active_plugins;
    100 
    101         $this->plugins_to_block         = $this->get_plugins_to_block_for_current_url();
     109       
     110        $active_plugins_on_menu_save = get_option( "active_plugins_on_menu_save" );
     111       
     112        if( $active_plugins_on_menu_save != $active_plugins ){
     113           
     114            // this will trigger the script that recreates the menu:
     115            update_option( "active_plugins_on_menu_save", $active_plugins );
     116            $_GET["po_original_menu"] = "get";
     117           
     118        }
     119
     120        $this->plugins_to_block         = $this->get_plugins_to_block_for_current_url();
    102121       
    103122        $this->filtered_active_plugins  = array_diff( $this->original_active_plugins, $this->plugins_to_block );
     
    105124        $this->blocked_plugins          = array_intersect( $this->original_active_plugins, $this->plugins_to_block );
    106125       
    107         sospo_mu_plugin()->write_log( $this->filtered_active_plugins, "filter_active_plugins_option_value-filtered_active_plugins" );
    108 
    109         return $this->filtered_active_plugins;
    110 
    111     }
    112 
    113     function should_skip_url( $url ) {
     126        return $this->filtered_active_plugins;
     127    }
     128
     129    function should_skip_url( $url ) {
    114130       
    115131        $skip = [
     
    130146       
    131147        return false;
    132     }
    133 
    134     function get_plugins_to_block_for_current_url() {
    135        
    136         $relative_url  = trim( $_SERVER["REQUEST_URI"] );
    137         $current_url   = get_home_url() . $relative_url;
     148    }
     149
     150    function get_plugins_to_block_for_current_url() {
     151       
     152        $relative_url  = trim( $_SERVER["REQUEST_URI"] );
     153        $current_url   = get_home_url() . $relative_url;
    138154       
    139155        // some URLs just need to be skipped
     
    162178            $this->is_po_default_page   = true;
    163179            $this->is_being_filtered    = true;
    164             $this->plugins_to_block     = array_diff( $this->original_active_plugins, [ "plugin-optimizer/plugin-optimizer.php" ] );
     180            $this->plugins_to_block     = array_diff( $this->original_active_plugins, $this->po_plugins );
    165181           
    166182            return $this->plugins_to_block;
     
    169185        // --- Get plugins to block from all the filters
    170186       
    171         $filters = get_posts([
    172             'post_type'   => 'sos_filter',
    173             'numberposts' => - 1,
    174         ]);
    175        
    176         foreach( $filters as $filter ){
     187        $filters = get_posts([
     188            'post_type'   => 'sos_filter',
     189            'numberposts' => - 1,
     190        ]);
     191       
     192        foreach( $filters as $filter ){
    177193           
    178194            if( $filter->turned_off ){
     
    183199            // If we're on the edit post screen, filter by post type
    184200           
    185             if( $filter->type_filter !== '_endpoint' && $editing_post_type && $editing_post_type == $filter->type_filter ){
    186                
    187                 $this->use_filter( $filter );
     201            if( $filter->type_filter !== '_endpoint' && $editing_post_type && $editing_post_type == $filter->type_filter ){
     202               
     203                $this->use_filter( $filter );
    188204               
    189205                continue;
    190             }
     206            }
    191207           
    192208            // Filter by URL
     
    213229            }
    214230
    215         }
    216        
    217         return array_unique( $this->plugins_to_block );
    218     }
     231        }
     232       
     233        return array_unique( $this->plugins_to_block );
     234    }
    219235
    220236    function use_filter( $filter ){
     
    250266   
    251267
    252     function is_editing_post_type( $url ){
     268    function is_editing_post_type( $url ){
    253269       
    254270        $post_id   = $this->url_to_postid( $url );
     
    262278        return $post_type;
    263279       
    264     }
    265    
    266     function url_to_postid( $url ){
     280    }
     281   
     282    function url_to_postid( $url ){
    267283       
    268284        parse_str( parse_url( $url, PHP_URL_QUERY ), $query_vars);
     
    273289        return $post_id;
    274290       
    275     }
     291    }
    276292   
    277293    function write_log( $log, $text = "write_log: ", $file_name = "debug.log" )  {
     
    312328
    313329function sospo_mu_plugin(){
    314      return SOSPO_MU::get_instance();
     330    return SOSPO_MU::get_instance();
    315331}
    316332sospo_mu_plugin();
  • plugin-optimizer/trunk/includes/class-po.php

    r2501831 r2502985  
    4444            $this->version = SOSPO_VERSION;
    4545        } else {
    46             $this->version = '1.0.3';
     46            $this->version = '1.0.4';
    4747        }
    4848        $this->plugin_name = 'plugin-optimizer';
  • plugin-optimizer/trunk/plugin-optimizer.php

    r2501831 r2502985  
    55 * Plugin URI:        https://pluginoptimizer.com
    66 * Description:       The Most Powerful Performance Plugin for WordPress is now available for FREE.
    7  * Version:           1.0.3
     7 * Version:           1.0.4
    88 * Author:            Plugin Optimizer
    99 * Author URI:        https://pluginoptimizer.com/about/
     
    4141 * Use SemVer - https://semver.org
    4242 */
    43 define( 'SOSPO_VERSION', '1.0.3' );
     43define( 'SOSPO_VERSION', '1.0.4' );
    4444
    4545/**
     
    6464register_deactivation_hook( __FILE__, 'deactivate_plugin_optimizer' );
    6565
    66 // TODO - let's copy the file there if it's missing
     66// let's install the MU plugin if it's missing and refresh
    6767if( ! file_exists( WPMU_PLUGIN_DIR . '/class-po-mu.php') ){
    6868   
    69     // TODO should we add the MU plugin at this point?
    70     // copy( __DIR__ . '/class-po-mu.php', WPMU_PLUGIN_DIR . '/class-po-mu.php' );
     69    if( ! file_exists( WPMU_PLUGIN_DIR ) ){
     70       
     71        mkdir( WPMU_PLUGIN_DIR );
     72        chmod( WPMU_PLUGIN_DIR, 0755 );
     73    }
     74
     75    copy( __DIR__ . '/includes/class-po-mu.php', WPMU_PLUGIN_DIR . '/class-po-mu.php' );
     76   
     77    header("Refresh:0");
    7178   
    7279    return;
Note: See TracChangeset for help on using the changeset viewer.