Plugin Directory

Changeset 3139578


Ignore:
Timestamp:
08/22/2024 09:37:01 AM (18 months ago)
Author:
gabelivan
Message:

v1.3.9.6

Location:
wp-asset-clean-up
Files:
357 added
7 edited

Legend:

Unmodified
Added
Removed
  • wp-asset-clean-up/trunk/classes/Admin/SettingsAdminOnlyForAdmin.php

    r3137436 r3139578  
    7474
    7575            foreach ($allowManageAssetsTo as $specificUserId) {
    76                 add_user_meta($specificUserId, WPACU_PLUGIN_ID . '_user_chosen_for_access_to_assets_manager', 1);
     76                delete_user_meta($specificUserId, $metaKeyTargeted);
     77                add_user_meta($specificUserId, $metaKeyTargeted, 1);
    7778            }
    7879        }
     
    421422    public static function getAnySpecifiedAdminsForAccessToAssetsManager($data = array())
    422423    {
     424        $metaKeyTargeted = WPACU_PLUGIN_ID . '_user_chosen_for_access_to_assets_manager';
     425
    423426        // [START] Old plugin version transition
    424427        // First move it, if an old version of the plugin is used
     
    436439                }
    437440
    438                 add_user_meta($specificUserId, WPACU_PLUGIN_ID . '_user_chosen_for_access_to_assets_manager', 1);
     441                delete_user_meta($specificUserId, $metaKeyTargeted);
     442                add_user_meta($specificUserId, $metaKeyTargeted, 1);
    439443            }
    440444
     
    452456        // In order to use the same code as before in [...]/templates/_admin-page-settings-plugin-areas/_plugin-usage-settings/_assets-management.php
    453457        global $wpdb;
    454 
    455         $metaKeyTargeted = WPACU_PLUGIN_ID . '_user_chosen_for_access_to_assets_manager';
    456458
    457459        $query = <<<SQL
  • wp-asset-clean-up/trunk/classes/AssetsManager.php

    r3137436 r3139578  
    55
    66use WpAssetCleanUp\Admin\MiscAdmin;
     7use WpAssetCleanUp\Admin\SettingsAdminOnlyForAdmin;
    78use WpAssetCleanUp\OptimiseAssets\DynamicLoadedAssets;
    89use WpAssetCleanUp\OptimiseAssets\OptimizeCommon;
     
    105106    public static function currentUserCanViewAssetsList()
    106107    {
    107         if ( Main::instance()->settings['allow_manage_assets_to'] === 'chosen' && ! empty(Main::instance()->settings['allow_manage_assets_to_list']) ) {
     108        Main::instance()->settings = SettingsAdminOnlyForAdmin::getAnySpecifiedAdminsForAccessToAssetsManager(Main::instance()->settings);
     109
     110        if ( Main::instance()->settings['allow_manage_assets_to'] === 'chosen' && ! empty(Main::instance()->settings['allow_manage_assets_to_list']) ) {
    108111            $wpacuCurrentUserId = get_current_user_id();
    109112
  • wp-asset-clean-up/trunk/classes/Main.php

    r3137436 r3139578  
    259259                && ! self::instance()->isGetAssetsCall // 2
    260260              && ! is_admin(); // 3
    261 
    262             Main::instance()->settings = SettingsAdminOnlyForAdmin::getAnySpecifiedAdminsForAccessToAssetsManager(Main::instance()->settings);
    263 
    264             if (self::instance()->isFrontendEditView && ! AssetsManager::currentUserCanViewAssetsList()) {
    265                 // Viewing the CSS/JS manager is not for every admin, as mentioned here: "Settings" -- "Plugin Usage Preferences" -- "Allow managing assets to:"
    266                 // The logged-in admimn is not in the particular list, thus, no CSS/JS manager will show in the front-end view
    267                 self::instance()->isFrontendEditView = false;
    268             }
    269261        }, 0);
    270262    }
  • wp-asset-clean-up/trunk/classes/Maintenance.php

    r3137436 r3139578  
    8686        self::clearCacheConditionally();
    8787
    88         }
     88        // Fix v1.2.5.6 (duplicates in "usermeta" table)
     89        self::removeAnyDuplicateMetaKeysFromUsersTable();
     90
     91        }
     92
     93    /**
     94     * @return void
     95     */
     96    public static function removeAnyDuplicateMetaKeysFromUsersTable()
     97    {
     98        global $wpdb;
     99
     100        $pluginId = WPACU_PLUGIN_ID;
     101
     102        $sqlQuery = <<<SQL
     103SELECT umeta_id, user_id, COUNT(CONCAT(user_id, meta_key)) as total_count
     104FROM `{$wpdb->usermeta}`
     105WHERE meta_key='{$pluginId}_user_chosen_for_access_to_assets_manager'
     106GROUP BY CONCAT(user_id, meta_key)
     107HAVING total_count > 1;
     108SQL;
     109        $rows = $wpdb->get_results($sqlQuery, ARRAY_A);
     110
     111        if ( ! empty($rows) ) {
     112            foreach ($rows as $row) {
     113                $deleteSqlQuery = <<<SQL
     114DELETE FROM `{$wpdb->usermeta}`
     115WHERE umeta_id != '%d' AND user_id='%d' AND meta_key='%s'
     116SQL;
     117
     118                $deleteSqlQueryPrepared = $wpdb->prepare(
     119                    $deleteSqlQuery,
     120                    (int)$row['umeta_id'],
     121                    (int)$row['user_id'],
     122                    $pluginId . '_user_chosen_for_access_to_assets_manager'
     123                );
     124
     125                $wpdb->query($deleteSqlQueryPrepared);
     126            }
     127        }
     128    }
    89129
    90130    /**
  • wp-asset-clean-up/trunk/classes/Settings.php

    r3137436 r3139578  
    408408    public function filterSettings($settings)
    409409    {
    410         // "only to the following administrator(s):" can not be empty; if that's the case, reset it to "any administrator"
    411         if ($settings['allow_manage_assets_to'] === 'chosen' && empty($settings['allow_manage_assets_to_list'])) {
    412             $settings['allow_manage_assets_to'] = 'any_admin';
    413         }
    414 
    415410        // Renamed "hide_assets_meta_box" to "show_assets_meta_box" (legacy)
    416411        if ( isset($settings['show_assets_meta_box'], $settings['hide_assets_meta_box']) && $settings['hide_assets_meta_box'] == 1 ) { // legacy
     
    612607        // Instead, it will be triggered later on when the values below are relevant
    613608        if (is_admin() && function_exists('wp_get_current_user')) {
    614             $settings = Main::instance()->settings;
    615 
    616609            if (current_user_can(Menu::$defaultAccessRole)) {
    617610                $allowManageAssetsArray                          = SettingsAdminOnlyForAdmin::getAnySpecifiedAdminsForAccessToAssetsManager();
     
    623616                $settings['access_via_non_admin_user_roles']     = ! empty($nonAdminRolesArray['non_admin_role_slugs_with_cap']) ? $nonAdminRolesArray['non_admin_role_slugs_with_cap'] : array();
    624617                $settings['access_via_specific_non_admin_users'] = $nonAdminsWithPluginAccessCap;
     618
     619                // "only to the following administrator(s):" can not be empty; if that's the case, reset it to "any administrator"
     620                if ($settings['allow_manage_assets_to'] === 'chosen' && empty($settings['allow_manage_assets_to_list'])) {
     621                    $settings['allow_manage_assets_to'] = 'any_admin';
     622                }
    625623            } else {
    626624                // Non-admins have no business with these settings
  • wp-asset-clean-up/trunk/readme.txt

    r3137436 r3139578  
    55Requires at least: 4.6
    66Tested up to: 6.6.1
    7 Stable tag: 1.3.9.5
     7Stable tag: 1.3.9.6
    88Requires PHP: 5.6
    99License: GPLv3
     
    193193
    194194== Changelog ==
     195= 1.3.9.6 =
     196* Fix: The "usermeta" table is populated with duplicate entries, leading to a larger database, and sometimes, leading to a high CPU usage
     197
    195198= 1.3.9.5 =
    196199* New Option: "Settings" -- "Plugin Usage Preferences" -- "Plugin Access" / Choose user roles or particular users, apart from administrators, that could have access to the plugin area * e.g. the admin could give Asset CleanUp Pro access within the Dashboard to a developer that is optimizing the website, but the developer does not have the "administrator" role for security reasons
  • wp-asset-clean-up/trunk/wpacu.php

    r3137436 r3139578  
    33 * Plugin Name: Asset CleanUp: Page Speed Booster
    44 * Plugin URI: https://wordpress.org/plugins/wp-asset-clean-up/
    5  * Version: 1.3.9.5
     5 * Version: 1.3.9.6
    66 * Requires at least: 4.5
    77 * Requires PHP: 5.6
     
    3030// Is the Pro version triggered before the Lite one and are both plugins active?
    3131if (! defined('WPACU_PLUGIN_VERSION')) {
    32     define('WPACU_PLUGIN_VERSION', '1.3.9.5');
     32    define('WPACU_PLUGIN_VERSION', '1.3.9.6');
    3333}
    3434
Note: See TracChangeset for help on using the changeset viewer.