Plugin Directory

Changeset 3072940


Ignore:
Timestamp:
04/18/2024 09:38:57 AM (23 months ago)
Author:
mxp
Message:

update 3.1.1

Location:
mxp-dev-tools
Files:
1 deleted
5 edited
18 copied

Legend:

Unmodified
Added
Removed
  • mxp-dev-tools/tags/3.1.1/index.php

    r3067305 r3072940  
    44 * Plugin URI: https://goo.gl/2gLq18
    55 * Description: 一介資男の常用外掛整理與常用開發功能整合外掛。
    6  * Version: 3.1.0
     6 * Version: 3.1.1
    77 * Author: Chun
    88 * Author URI: https://www.mxp.tw/contact/
     
    2626    use SearchReplace;
    2727    use Utility;
    28     static $VERSION                   = '3.1.0';
     28    static $VERSION                   = '3.1.1';
    2929    private $themeforest_api_base_url = 'https://api.envato.com/v3';
    3030    protected static $instance        = null;
     
    8686        add_submenu_page($this->plugin_slug, 'Themeforest List', 'Themeforest List', 'administrator', 'mxp-themeforest-list', array($this, 'themeforest_page_cb'));
    8787        add_submenu_page($this->plugin_slug, '調整內容作者工具', '調整內容作者工具', 'administrator', 'mxp-change-post-owner', array($this, 'changepostowner_page_cb'));
    88         add_submenu_page($this->plugin_slug, '作者外掛列表', '作者外掛列表', 'administrator', 'mxp-author-plugins', array($this, 'listauthorplugin_page_cb'));
     88        // add_submenu_page($this->plugin_slug, '作者外掛列表', '作者外掛列表', 'administrator', 'mxp-author-plugins', array($this, 'listauthorplugin_page_cb'));
    8989        add_submenu_page($this->plugin_slug, '外掛搜尋工具', '外掛搜尋工具', 'administrator', 'mxp-search-plugins', array($this, 'searchplugin_page_cb'));
    9090        add_submenu_page($this->plugin_slug, '主題打包工具', '主題打包工具', 'administrator', 'mxp-theme-archive', array($this, 'themearchive_page_cb'));
  • mxp-dev-tools/tags/3.1.1/mxp-login-path.php

    r3067305 r3072940  
    44 * Plugin URI: https://tw.wordpress.org/plugins/mxp-dev-tools/
    55 * Description: 隱藏後台登入位置工具。啟用即更改預設登入網址為 /admin-staff/
    6  * Version: 3.1.0
     6 * Version: 3.1.1
    77 * Author: Chun
    88 * Author URI: https://www.mxp.tw/contact/
  • mxp-dev-tools/tags/3.1.1/mxp-site-manager.php

    r3067305 r3072940  
    44 * Plugin URI: https://tw.wordpress.org/plugins/mxp-dev-tools/
    55 * Description: 管理多個 WordPress 站點的工具。
    6  * Version: 3.1.0
     6 * Version: 3.1.1
    77 * Author: Chun
    88 * Author URI: https://www.mxp.tw/contact/
     
    3535class MDTSiteManager {
    3636    public $plugin_slug    = 'mdt-site-manager';
    37     public static $VERSION = '3.1.0';
     37    public static $VERSION = '3.1.1';
    3838
    3939    public function __construct() {
  • mxp-dev-tools/tags/3.1.1/mxp-snippets.php

    r3067305 r3072940  
    44 * Plugin URI: https://tw.wordpress.org/plugins/mxp-dev-tools/
    55 * Description: 整合 GitHub 中常用的程式碼片段。請注意,並非所有網站都適用全部的選項,有進階需求可以透過設定 wp-config.php 中此外掛預設常數,啟用或停用部分功能。
    6  * Version: 3.1.0
     6 * Version: 3.1.1
    77 * Author: Chun
    88 * Author URI: https://www.mxp.tw/contact/
     
    325325        if (isset($_REQUEST['opcache_reset']) && function_exists('opcache_reset')) {
    326326            opcache_reset();
     327        }
     328        if (defined('MDT_DISALLOW_FILE_MODS_ADMINS') && is_array(MDT_DISALLOW_FILE_MODS_ADMINS)) {
     329            add_filter('users_list_table_query_args', array($this, 'filter_user_query_qrgs'), 99999, 1);
     330            add_filter('map_meta_cap', array($this, 'restrict_user_editing'), 99999, 4);
     331            add_filter('pre_count_users', array($this, 'filter_user_counts'), 99999, 3);
    327332        }
    328333    }
     
    10651070    }
    10661071
     1072    public function filter_user_query_qrgs($args) {
     1073        //Exclude superusers if the current user is not a superuser.
     1074        $super_users = MDT_DISALLOW_FILE_MODS_ADMINS;
     1075        if (empty($super_users)) {
     1076            return $args;
     1077        }
     1078
     1079        if (!in_array(get_current_user_id(), MDT_DISALLOW_FILE_MODS_ADMINS)) {
     1080            $args['exclude'] = array_merge(
     1081                isset($args['exclude']) ? $args['exclude'] : array(),
     1082                $super_users
     1083            );
     1084
     1085            //Exclude hidden users even if specifically included. This can happen
     1086            //when looking at the "None" view on the "Users" page (this view shows
     1087            //users that have no role on the current site).
     1088            if (isset($args['include']) && !empty($args['include'])) {
     1089                $args['include'] = array_diff($args['include'], $super_users);
     1090                if (empty($args['include'])) {
     1091                    unset($args['include']);
     1092                }
     1093            }
     1094        }
     1095
     1096        return $args;
     1097    }
     1098
     1099    public function restrict_user_editing($required_caps, $capability, $this_user_id, $args) {
     1100        static $edit_user_caps = array('edit_user', 'delete_user', 'promote_user', 'remove_user');
     1101        if (!in_array($capability, $edit_user_caps) || !isset($args[0])) {
     1102            return $required_caps;
     1103        }
     1104
     1105        /** @var int The user that might be edited or deleted. */
     1106        $that_user_id = intval($args[0]);
     1107        $this_user_id = intval($this_user_id);
     1108
     1109        if (in_array($that_user_id, MDT_DISALLOW_FILE_MODS_ADMINS) && !in_array($this_user_id, MDT_DISALLOW_FILE_MODS_ADMINS)) {
     1110            return array_merge($required_caps, array('do_not_allow'));
     1111        }
     1112
     1113        return $required_caps;
     1114    }
     1115
     1116    public function filter_user_counts($result = null, $strategy = 'time', $site_id = null) {
     1117        // 避免無限重複執行導致記憶體被吃光的問題
     1118        remove_filter('pre_count_users', array($this, 'filter_user_counts'), 99999, 3);
     1119
     1120        //Perform this filtering only on the "Users" page.
     1121        if (!isset($GLOBALS['parent_file']) || ($GLOBALS['parent_file'] !== 'users.php')) {
     1122            return $result;
     1123        }
     1124
     1125        if (in_array(get_current_user_id(), MDT_DISALLOW_FILE_MODS_ADMINS)) {
     1126            //This user can see other hidden users.
     1127            return $result;
     1128        }
     1129
     1130        $super_users = array();
     1131        foreach (MDT_DISALLOW_FILE_MODS_ADMINS as $index => $user_id) {
     1132            $user_obj = get_user_by('id', $user_id);
     1133            if ($user_obj) {
     1134                $super_users[] = $user_obj;
     1135            }
     1136        }
     1137        //Note the $site_id. We want the roles that each user has on the specified site.
     1138        //This should normally be the current site, but it doesn't have to be.
     1139
     1140        if (empty($super_users)) {
     1141            //There are no users that need to be hidden.
     1142            return $result;
     1143        }
     1144
     1145        $result = count_users($strategy, $site_id);
     1146
     1147        //Adjust the total number of users.
     1148        $result['total_users'] -= count($super_users);
     1149
     1150        //For each hidden user, subtract one from each of the roles that the user has.
     1151        foreach ($super_users as $user) {
     1152            if (!empty($user->roles) && is_array($user->roles)) {
     1153                foreach ($user->roles as $roleId) {
     1154                    if (isset($result['avail_roles'][$roleId])) {
     1155                        $result['avail_roles'][$roleId]--;
     1156                        if ($result['avail_roles'][$roleId] <= 0) {
     1157                            unset($result['avail_roles'][$roleId]);
     1158                        }
     1159                    }
     1160                }
     1161            } else if (isset($result['avail_roles']['none'])) {
     1162                $result['avail_roles']['none']--;
     1163            }
     1164        }
     1165
     1166        return $result;
     1167    }
     1168
    10671169    public function wp_diagnostic_info() {
    10681170        global $table_prefix;
  • mxp-dev-tools/tags/3.1.1/readme.txt

    r3067305 r3072940  
    66Requires PHP: 5.6
    77Tested up to: 6.5
    8 Stable tag: 3.1.0
     8Stable tag: 3.1.1
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7878
    7979== Changelog ==
     80
     81= 3.1.1 =
     82
     83* 新增 Snipets 中預設把特殊管理權限的使用者隱藏
     84* 關閉 作者外掛列表 頁籤
    8085
    8186= 3.1.0 =
  • mxp-dev-tools/trunk/index.php

    r3067305 r3072940  
    44 * Plugin URI: https://goo.gl/2gLq18
    55 * Description: 一介資男の常用外掛整理與常用開發功能整合外掛。
    6  * Version: 3.1.0
     6 * Version: 3.1.1
    77 * Author: Chun
    88 * Author URI: https://www.mxp.tw/contact/
     
    2626    use SearchReplace;
    2727    use Utility;
    28     static $VERSION                   = '3.1.0';
     28    static $VERSION                   = '3.1.1';
    2929    private $themeforest_api_base_url = 'https://api.envato.com/v3';
    3030    protected static $instance        = null;
     
    8686        add_submenu_page($this->plugin_slug, 'Themeforest List', 'Themeforest List', 'administrator', 'mxp-themeforest-list', array($this, 'themeforest_page_cb'));
    8787        add_submenu_page($this->plugin_slug, '調整內容作者工具', '調整內容作者工具', 'administrator', 'mxp-change-post-owner', array($this, 'changepostowner_page_cb'));
    88         add_submenu_page($this->plugin_slug, '作者外掛列表', '作者外掛列表', 'administrator', 'mxp-author-plugins', array($this, 'listauthorplugin_page_cb'));
     88        // add_submenu_page($this->plugin_slug, '作者外掛列表', '作者外掛列表', 'administrator', 'mxp-author-plugins', array($this, 'listauthorplugin_page_cb'));
    8989        add_submenu_page($this->plugin_slug, '外掛搜尋工具', '外掛搜尋工具', 'administrator', 'mxp-search-plugins', array($this, 'searchplugin_page_cb'));
    9090        add_submenu_page($this->plugin_slug, '主題打包工具', '主題打包工具', 'administrator', 'mxp-theme-archive', array($this, 'themearchive_page_cb'));
  • mxp-dev-tools/trunk/mxp-login-path.php

    r3067305 r3072940  
    44 * Plugin URI: https://tw.wordpress.org/plugins/mxp-dev-tools/
    55 * Description: 隱藏後台登入位置工具。啟用即更改預設登入網址為 /admin-staff/
    6  * Version: 3.1.0
     6 * Version: 3.1.1
    77 * Author: Chun
    88 * Author URI: https://www.mxp.tw/contact/
  • mxp-dev-tools/trunk/mxp-site-manager.php

    r3067305 r3072940  
    44 * Plugin URI: https://tw.wordpress.org/plugins/mxp-dev-tools/
    55 * Description: 管理多個 WordPress 站點的工具。
    6  * Version: 3.1.0
     6 * Version: 3.1.1
    77 * Author: Chun
    88 * Author URI: https://www.mxp.tw/contact/
     
    3535class MDTSiteManager {
    3636    public $plugin_slug    = 'mdt-site-manager';
    37     public static $VERSION = '3.1.0';
     37    public static $VERSION = '3.1.1';
    3838
    3939    public function __construct() {
  • mxp-dev-tools/trunk/mxp-snippets.php

    r3067305 r3072940  
    44 * Plugin URI: https://tw.wordpress.org/plugins/mxp-dev-tools/
    55 * Description: 整合 GitHub 中常用的程式碼片段。請注意,並非所有網站都適用全部的選項,有進階需求可以透過設定 wp-config.php 中此外掛預設常數,啟用或停用部分功能。
    6  * Version: 3.1.0
     6 * Version: 3.1.1
    77 * Author: Chun
    88 * Author URI: https://www.mxp.tw/contact/
     
    325325        if (isset($_REQUEST['opcache_reset']) && function_exists('opcache_reset')) {
    326326            opcache_reset();
     327        }
     328        if (defined('MDT_DISALLOW_FILE_MODS_ADMINS') && is_array(MDT_DISALLOW_FILE_MODS_ADMINS)) {
     329            add_filter('users_list_table_query_args', array($this, 'filter_user_query_qrgs'), 99999, 1);
     330            add_filter('map_meta_cap', array($this, 'restrict_user_editing'), 99999, 4);
     331            add_filter('pre_count_users', array($this, 'filter_user_counts'), 99999, 3);
    327332        }
    328333    }
     
    10651070    }
    10661071
     1072    public function filter_user_query_qrgs($args) {
     1073        //Exclude superusers if the current user is not a superuser.
     1074        $super_users = MDT_DISALLOW_FILE_MODS_ADMINS;
     1075        if (empty($super_users)) {
     1076            return $args;
     1077        }
     1078
     1079        if (!in_array(get_current_user_id(), MDT_DISALLOW_FILE_MODS_ADMINS)) {
     1080            $args['exclude'] = array_merge(
     1081                isset($args['exclude']) ? $args['exclude'] : array(),
     1082                $super_users
     1083            );
     1084
     1085            //Exclude hidden users even if specifically included. This can happen
     1086            //when looking at the "None" view on the "Users" page (this view shows
     1087            //users that have no role on the current site).
     1088            if (isset($args['include']) && !empty($args['include'])) {
     1089                $args['include'] = array_diff($args['include'], $super_users);
     1090                if (empty($args['include'])) {
     1091                    unset($args['include']);
     1092                }
     1093            }
     1094        }
     1095
     1096        return $args;
     1097    }
     1098
     1099    public function restrict_user_editing($required_caps, $capability, $this_user_id, $args) {
     1100        static $edit_user_caps = array('edit_user', 'delete_user', 'promote_user', 'remove_user');
     1101        if (!in_array($capability, $edit_user_caps) || !isset($args[0])) {
     1102            return $required_caps;
     1103        }
     1104
     1105        /** @var int The user that might be edited or deleted. */
     1106        $that_user_id = intval($args[0]);
     1107        $this_user_id = intval($this_user_id);
     1108
     1109        if (in_array($that_user_id, MDT_DISALLOW_FILE_MODS_ADMINS) && !in_array($this_user_id, MDT_DISALLOW_FILE_MODS_ADMINS)) {
     1110            return array_merge($required_caps, array('do_not_allow'));
     1111        }
     1112
     1113        return $required_caps;
     1114    }
     1115
     1116    public function filter_user_counts($result = null, $strategy = 'time', $site_id = null) {
     1117        // 避免無限重複執行導致記憶體被吃光的問題
     1118        remove_filter('pre_count_users', array($this, 'filter_user_counts'), 99999, 3);
     1119
     1120        //Perform this filtering only on the "Users" page.
     1121        if (!isset($GLOBALS['parent_file']) || ($GLOBALS['parent_file'] !== 'users.php')) {
     1122            return $result;
     1123        }
     1124
     1125        if (in_array(get_current_user_id(), MDT_DISALLOW_FILE_MODS_ADMINS)) {
     1126            //This user can see other hidden users.
     1127            return $result;
     1128        }
     1129
     1130        $super_users = array();
     1131        foreach (MDT_DISALLOW_FILE_MODS_ADMINS as $index => $user_id) {
     1132            $user_obj = get_user_by('id', $user_id);
     1133            if ($user_obj) {
     1134                $super_users[] = $user_obj;
     1135            }
     1136        }
     1137        //Note the $site_id. We want the roles that each user has on the specified site.
     1138        //This should normally be the current site, but it doesn't have to be.
     1139
     1140        if (empty($super_users)) {
     1141            //There are no users that need to be hidden.
     1142            return $result;
     1143        }
     1144
     1145        $result = count_users($strategy, $site_id);
     1146
     1147        //Adjust the total number of users.
     1148        $result['total_users'] -= count($super_users);
     1149
     1150        //For each hidden user, subtract one from each of the roles that the user has.
     1151        foreach ($super_users as $user) {
     1152            if (!empty($user->roles) && is_array($user->roles)) {
     1153                foreach ($user->roles as $roleId) {
     1154                    if (isset($result['avail_roles'][$roleId])) {
     1155                        $result['avail_roles'][$roleId]--;
     1156                        if ($result['avail_roles'][$roleId] <= 0) {
     1157                            unset($result['avail_roles'][$roleId]);
     1158                        }
     1159                    }
     1160                }
     1161            } else if (isset($result['avail_roles']['none'])) {
     1162                $result['avail_roles']['none']--;
     1163            }
     1164        }
     1165
     1166        return $result;
     1167    }
     1168
    10671169    public function wp_diagnostic_info() {
    10681170        global $table_prefix;
  • mxp-dev-tools/trunk/readme.txt

    r3067305 r3072940  
    66Requires PHP: 5.6
    77Tested up to: 6.5
    8 Stable tag: 3.1.0
     8Stable tag: 3.1.1
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7878
    7979== Changelog ==
     80
     81= 3.1.1 =
     82
     83* 新增 Snipets 中預設把特殊管理權限的使用者隱藏
     84* 關閉 作者外掛列表 頁籤
    8085
    8186= 3.1.0 =
Note: See TracChangeset for help on using the changeset viewer.