Changeset 3162623
- Timestamp:
- 10/04/2024 09:45:39 AM (17 months ago)
- Location:
- mxp-dev-tools
- Files:
-
- 8 edited
- 7 copied
-
tags/3.2.1 (copied) (copied from mxp-dev-tools/trunk)
-
tags/3.2.1/includes/class_plugins_list_table.php (copied) (copied from mxp-dev-tools/trunk/includes/class_plugins_list_table.php) (1 diff)
-
tags/3.2.1/includes/hooks-usage.php (modified) (2 diffs)
-
tags/3.2.1/index.php (copied) (copied from mxp-dev-tools/trunk/index.php) (2 diffs)
-
tags/3.2.1/mxp-login-path.php (copied) (copied from mxp-dev-tools/trunk/mxp-login-path.php) (1 diff)
-
tags/3.2.1/mxp-site-manager.php (copied) (copied from mxp-dev-tools/trunk/mxp-site-manager.php) (5 diffs)
-
tags/3.2.1/mxp-snippets.php (copied) (copied from mxp-dev-tools/trunk/mxp-snippets.php) (1 diff)
-
tags/3.2.1/readme.txt (copied) (copied from mxp-dev-tools/trunk/readme.txt) (2 diffs)
-
trunk/includes/class_plugins_list_table.php (modified) (1 diff)
-
trunk/includes/hooks-usage.php (modified) (2 diffs)
-
trunk/index.php (modified) (2 diffs)
-
trunk/mxp-login-path.php (modified) (1 diff)
-
trunk/mxp-site-manager.php (modified) (5 diffs)
-
trunk/mxp-snippets.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mxp-dev-tools/tags/3.2.1/includes/class_plugins_list_table.php
r3161580 r3162623 187 187 public function column_id($item) { 188 188 $actions = array(); 189 $actions['activate'] = sprintf('<button class="mxp-activate" data-id="p_%s" disabled>啟用</button>', $item['id']);190 $actions['update'] = sprintf('<button class="mxp-update" data-id="p_%s" disabled>更新</button>', $item['id']);191 $actions['install'] = sprintf('<button class="mxp-install" data-id="p_%s" disabled>安裝</button>', $item['id']);189 $actions['activate'] = sprintf('<button mxp-activate" data-id="p_%s" disabled>啟用</button>', $item['id']); 190 $actions['update'] = sprintf('<button mxp-update" data-id="p_%s" disabled>更新</button>', $item['id']); 191 $actions['install'] = sprintf('<button mxp-install" data-id="p_%s" disabled>安裝</button>', $item['id']); 192 192 return sprintf('%1$s %2$s', $item['id'], $this->row_actions($actions)); 193 193 } -
mxp-dev-tools/tags/3.2.1/includes/hooks-usage.php
r2986482 r3162623 3 3 4 4 if (!defined('WPINC')) { 5 die;5 die; 6 6 } 7 7 … … 9 9 class MxpDevHooksUsage { 10 10 11 public $data = array();11 public $data = array(); 12 12 13 public function __construct() {14 add_action('admin_bar_menu', array($this, 'customize_admin_bar'), 99);15 add_action('all', array($this, 'filter_start'));16 add_action('shutdown', array($this, 'results'));17 }13 public function __construct() { 14 add_action('admin_bar_menu', array($this, 'customize_admin_bar'), 99); 15 add_action('all', array($this, 'filter_start')); 16 add_action('shutdown', array($this, 'results')); 17 } 18 18 19 public function customize_admin_bar() {20 global $wp_admin_bar;21 $wp_admin_bar->add_menu(array(22 'id'=> 'mxp_dev_hooks_usage',23 'title' => 'Hooks 執行時間',24 'href'=> false,25 ));26 $wp_admin_bar->add_menu(array(27 'id'=> 'demo-sub-menu',28 'parent' => 'mxp_dev_hooks_usage',29 'title'=> 'hook:ms',30 'href'=> false,31 ));32 }19 public function customize_admin_bar() { 20 global $wp_admin_bar; 21 $wp_admin_bar->add_menu(array( 22 => 'mxp_dev_hooks_usage', 23 'title' => 'Hooks 執行時間', 24 => false, 25 )); 26 $wp_admin_bar->add_menu(array( 27 => 'demo-sub-menu', 28 'parent' => 'mxp_dev_hooks_usage', 29 => 'hook:ms', 30 => false, 31 )); 32 } 33 33 34 // This runs first for all actions and filters.35 // It starts a timer for this hook.36 public function filter_start() {37 $current_filter= current_filter();38 $this->data[$current_filter][]['start'] = microtime(true);39 add_filter($current_filter, array($this, 'filter_end'), 99999);40 }34 // This runs first for all actions and filters. 35 // It starts a timer for this hook. 36 ) { 37 = current_filter(); 38 $this->data[$current_filter][]['start'] = microtime(true); 39 ); 40 } 41 41 42 // This runs last (hopefully) for each hook and records the end time.43 // This has problems if a hook fires inside of itself since it assumes44 // the last entry in the data key for this hook is the matching pair.45 public function filter_end($filter_data = null) {46 $current_filter = current_filter();47 remove_filter($current_filter, array($this, 'filter_end'), 99999);48 end($this->data[$current_filter]);49 $last_key= key($this->data[$current_filter]);50 $this->data[$current_filter][$last_key]['stop'] = microtime(true);51 return $filter_data;52 }42 // This runs last (hopefully) for each hook and records the end time. 43 // This has problems if a hook fires inside of itself since it assumes 44 // the last entry in the data key for this hook is the matching pair. 45 public function filter_end($filter_data = null) { 46 $current_filter = current_filter(); 47 ); 48 end($this->data[$current_filter]); 49 = key($this->data[$current_filter]); 50 $this->data[$current_filter][$last_key]['stop'] = microtime(true); 51 return $filter_data; 52 } 53 53 54 // Processes the results and var_dump()'s them. TODO: Debug bar panel? 55 public function results() { 56 $results = array(); 57 foreach ($this->data as $filter => $calls) { 58 foreach ($calls as $call) { 59 // Skip filters with no end point (i.e. the hook this function is hooked into) 60 if (!isset($call['stop'])) { 61 continue; 62 } 63 if (!isset($results[$filter])) { 64 $results[$filter] = 0; 65 } 66 $results[$filter] = $results[$filter] + ($call['stop'] - $call['start']); 67 } 68 } 69 asort($results, SORT_NUMERIC); 70 $results = array_reverse($results); 71 $now = time(); 72 $new_res = array(); 73 $total = 0; 74 foreach ($results as $hook_name => $time_diff) { 75 $time = round($time_diff, 3); 76 $total += $time; 77 if ($time > 0.01) { 78 $new_res[$hook_name] = $time; 79 } 80 } 81 $insert = array('總計' => round($total, 3)); 82 $resultArray = $insert + $new_res; 83 echo '<script>var mxp_hooks_usage=' . json_encode($resultArray) . ';var ulElement = document.getElementById("wp-admin-bar-mxp_dev_hooks_usage-default");ulElement.innerHTML = "";for (var hook in mxp_hooks_usage) { if (mxp_hooks_usage.hasOwnProperty(hook)) { console.log(hook,mxp_hooks_usage[hook]+" 秒");var liElement = document.createElement("li"); liElement.innerHTML = "<div class=\'ab-item ab-empty-item\'>"+hook + " : " + mxp_hooks_usage[hook]+" 秒</div>"; ulElement.appendChild(liElement); } } 54 // Processes the results and var_dump()'s them. TODO: Debug bar panel? 55 public function results() { 56 $results = array(); 57 foreach ($this->data as $filter => $calls) { 58 foreach ($calls as $call) { 59 // Skip filters with no end point (i.e. the hook this function is hooked into) 60 if (!isset($call['stop'])) { 61 continue; 62 } 63 if (!isset($results[$filter])) { 64 $results[$filter] = 0; 65 } 66 $results[$filter] = $results[$filter] + ($call['stop'] - $call['start']); 67 } 68 } 69 asort($results, SORT_NUMERIC); 70 $results = array_reverse($results); 71 $now = time(); 72 $new_res = array(); 73 $total = 0; 74 foreach ($results as $hook_name => $time_diff) { 75 $time = round($time_diff, 3); 76 $total += $time; 77 if ($time > 0.001) { 78 $new_res[$hook_name] = $time; 79 } 80 } 81 $insert = array('總計' => round($total, 3)); 82 $resultArray = $insert + $new_res; 83 if ((defined('DOING_AJAX') && DOING_AJAX) || wp_doing_cron()) { 84 return; 85 } 86 echo '<script>var mxp_hooks_usage=' . json_encode($resultArray) . ';var ulElement = document.getElementById("wp-admin-bar-mxp_dev_hooks_usage-default");ulElement.innerHTML = "";for (var hook in mxp_hooks_usage) { if (mxp_hooks_usage.hasOwnProperty(hook)) { console.log(hook,mxp_hooks_usage[hook]+" 秒");var liElement = document.createElement("li"); liElement.innerHTML = "<div class=\'ab-item ab-empty-item\'>"+hook + " : " + mxp_hooks_usage[hook]+" 秒</div>"; ulElement.appendChild(liElement); } } 84 87 </script>'; 85 }88 } 86 89 } 87 90 88 if (!function_exists('wp_get_current_user')) { 89 include_once ABSPATH . WPINC . '/pluggable.php'; 91 $cookie = isset($_COOKIE) ? $_COOKIE : array(); 92 $login_flag = false; 93 foreach ($cookie as $cookie_key => $cookie_value) { 94 if (strpos($cookie_key, 'wordpress_logged_in_') === 0 && $cookie_value != '') { 95 $login_flag = true; 96 } 90 97 } 91 if (isset($_REQUEST['debug']) && \is_super_admin()) {92 new MxpDevHooksUsage();98 if (isset($_REQUEST['debug']) && ) { 99 new MxpDevHooksUsage(); 93 100 } -
mxp-dev-tools/tags/3.2.1/index.php
r3161580 r3162623 7 7 * Requires PHP: 5.6 8 8 * Tested up to: 6.6 9 * Stable tag: 3.2. 010 * Version: 3.2. 09 * Stable tag: 3.2. 10 * Version: 3.2. 11 11 * Author: Chun 12 12 * Author URI: https://www.mxp.tw/contact/ … … 39 39 use SearchReplace; 40 40 use Utility; 41 static $VERSION = '3.2. 0';41 static $VERSION = '3.2.'; 42 42 private $themeforest_api_base_url = 'https://api.envato.com/v3'; 43 43 protected static $instance = null; -
mxp-dev-tools/tags/3.2.1/mxp-login-path.php
r3161580 r3162623 7 7 * Requires PHP: 5.6 8 8 * Tested up to: 6.6 9 * Stable tag: 3.2. 010 * Version: 3.2. 09 * Stable tag: 3.2. 10 * Version: 3.2. 11 11 * Author: Chun 12 12 * Author URI: https://www.mxp.tw/contact/ -
mxp-dev-tools/tags/3.2.1/mxp-site-manager.php
r3161580 r3162623 7 7 * Requires PHP: 5.6 8 8 * Tested up to: 6.6 9 * Stable tag: 3.2. 010 * Version: 3.2. 09 * Stable tag: 3.2. 10 * Version: 3.2. 11 11 * Author: Chun 12 12 * Author URI: https://www.mxp.tw/contact/ … … 39 39 class MDTSiteManager { 40 40 public $plugin_slug = 'mdt-site-manager'; 41 public static $VERSION = '3.2. 0';41 public static $VERSION = '3.2.'; 42 42 43 43 public function __construct() { … … 55 55 add_action('template_redirect', array($this, 'verify_login_request'), -1); 56 56 add_action('wp_ajax_mxp_ajax_site_mamager', array($this, 'ajax_action')); 57 58 59 60 61 57 62 // 避免單獨啟用時呼叫判斷 is_super_admin() 噴錯 58 63 if (!function_exists('wp_get_current_user')) { … … 61 66 // 新增「設定」中的外掛選單 62 67 if (is_super_admin()) { 68 69 70 63 71 add_action('admin_menu', array($this, 'admin_menu')); 64 72 } 65 add_action('admin_enqueue_scripts', array($this, 'load_assets'));66 73 } 67 74 … … 102 109 ) 103 110 ); 111 112 113 114 115 116 117 118 119 120 104 121 } 105 122 } -
mxp-dev-tools/tags/3.2.1/mxp-snippets.php
r3161580 r3162623 7 7 * Requires PHP: 5.6 8 8 * Tested up to: 6.6 9 * Stable tag: 3.2. 010 * Version: 3.2. 09 * Stable tag: 3.2. 10 * Version: 3.2. 11 11 * Author: Chun 12 12 * Author URI: https://www.mxp.tw/contact/ -
mxp-dev-tools/tags/3.2.1/readme.txt
r3161580 r3162623 6 6 Requires PHP: 5.6 7 7 Tested up to: 6.6 8 Stable tag: 3.2. 08 Stable tag: 3.2. 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 77 77 78 78 == Changelog == 79 80 81 82 83 84 79 85 80 86 = 3.2.0 = -
mxp-dev-tools/trunk/includes/class_plugins_list_table.php
r3161580 r3162623 187 187 public function column_id($item) { 188 188 $actions = array(); 189 $actions['activate'] = sprintf('<button class="mxp-activate" data-id="p_%s" disabled>啟用</button>', $item['id']);190 $actions['update'] = sprintf('<button class="mxp-update" data-id="p_%s" disabled>更新</button>', $item['id']);191 $actions['install'] = sprintf('<button class="mxp-install" data-id="p_%s" disabled>安裝</button>', $item['id']);189 $actions['activate'] = sprintf('<button mxp-activate" data-id="p_%s" disabled>���用</button>', $item['id']); 190 $actions['update'] = sprintf('<button mxp-update" data-id="p_%s" disabled>更新</button>', $item['id']); 191 $actions['install'] = sprintf('<button mxp-install" data-id="p_%s" disabled>安裝</button>', $item['id']); 192 192 return sprintf('%1$s %2$s', $item['id'], $this->row_actions($actions)); 193 193 } -
mxp-dev-tools/trunk/includes/hooks-usage.php
r2986482 r3162623 3 3 4 4 if (!defined('WPINC')) { 5 die;5 die; 6 6 } 7 7 … … 9 9 class MxpDevHooksUsage { 10 10 11 public $data = array();11 public $data = array(); 12 12 13 public function __construct() {14 add_action('admin_bar_menu', array($this, 'customize_admin_bar'), 99);15 add_action('all', array($this, 'filter_start'));16 add_action('shutdown', array($this, 'results'));17 }13 public function __construct() { 14 add_action('admin_bar_menu', array($this, 'customize_admin_bar'), 99); 15 add_action('all', array($this, 'filter_start')); 16 add_action('shutdown', array($this, 'results')); 17 } 18 18 19 public function customize_admin_bar() {20 global $wp_admin_bar;21 $wp_admin_bar->add_menu(array(22 'id'=> 'mxp_dev_hooks_usage',23 'title' => 'Hooks 執行時間',24 'href'=> false,25 ));26 $wp_admin_bar->add_menu(array(27 'id'=> 'demo-sub-menu',28 'parent' => 'mxp_dev_hooks_usage',29 'title'=> 'hook:ms',30 'href'=> false,31 ));32 }19 public function customize_admin_bar() { 20 global $wp_admin_bar; 21 $wp_admin_bar->add_menu(array( 22 => 'mxp_dev_hooks_usage', 23 'title' => 'Hooks 執行時間', 24 => false, 25 )); 26 $wp_admin_bar->add_menu(array( 27 => 'demo-sub-menu', 28 'parent' => 'mxp_dev_hooks_usage', 29 => 'hook:ms', 30 => false, 31 )); 32 } 33 33 34 // This runs first for all actions and filters.35 // It starts a timer for this hook.36 public function filter_start() {37 $current_filter= current_filter();38 $this->data[$current_filter][]['start'] = microtime(true);39 add_filter($current_filter, array($this, 'filter_end'), 99999);40 }34 // This runs first for all actions and filters. 35 // It starts a timer for this hook. 36 ) { 37 = current_filter(); 38 $this->data[$current_filter][]['start'] = microtime(true); 39 ); 40 } 41 41 42 // This runs last (hopefully) for each hook and records the end time.43 // This has problems if a hook fires inside of itself since it assumes44 // the last entry in the data key for this hook is the matching pair.45 public function filter_end($filter_data = null) {46 $current_filter = current_filter();47 remove_filter($current_filter, array($this, 'filter_end'), 99999);48 end($this->data[$current_filter]);49 $last_key= key($this->data[$current_filter]);50 $this->data[$current_filter][$last_key]['stop'] = microtime(true);51 return $filter_data;52 }42 // This runs last (hopefully) for each hook and records the end time. 43 // This has problems if a hook fires inside of itself since it assumes 44 // the last entry in the data key for this hook is the matching pair. 45 public function filter_end($filter_data = null) { 46 $current_filter = current_filter(); 47 ); 48 end($this->data[$current_filter]); 49 = key($this->data[$current_filter]); 50 $this->data[$current_filter][$last_key]['stop'] = microtime(true); 51 return $filter_data; 52 } 53 53 54 // Processes the results and var_dump()'s them. TODO: Debug bar panel? 55 public function results() { 56 $results = array(); 57 foreach ($this->data as $filter => $calls) { 58 foreach ($calls as $call) { 59 // Skip filters with no end point (i.e. the hook this function is hooked into) 60 if (!isset($call['stop'])) { 61 continue; 62 } 63 if (!isset($results[$filter])) { 64 $results[$filter] = 0; 65 } 66 $results[$filter] = $results[$filter] + ($call['stop'] - $call['start']); 67 } 68 } 69 asort($results, SORT_NUMERIC); 70 $results = array_reverse($results); 71 $now = time(); 72 $new_res = array(); 73 $total = 0; 74 foreach ($results as $hook_name => $time_diff) { 75 $time = round($time_diff, 3); 76 $total += $time; 77 if ($time > 0.01) { 78 $new_res[$hook_name] = $time; 79 } 80 } 81 $insert = array('總計' => round($total, 3)); 82 $resultArray = $insert + $new_res; 83 echo '<script>var mxp_hooks_usage=' . json_encode($resultArray) . ';var ulElement = document.getElementById("wp-admin-bar-mxp_dev_hooks_usage-default");ulElement.innerHTML = "";for (var hook in mxp_hooks_usage) { if (mxp_hooks_usage.hasOwnProperty(hook)) { console.log(hook,mxp_hooks_usage[hook]+" 秒");var liElement = document.createElement("li"); liElement.innerHTML = "<div class=\'ab-item ab-empty-item\'>"+hook + " : " + mxp_hooks_usage[hook]+" 秒</div>"; ulElement.appendChild(liElement); } } 54 // Processes the results and var_dump()'s them. TODO: Debug bar panel? 55 public function results() { 56 $results = array(); 57 foreach ($this->data as $filter => $calls) { 58 foreach ($calls as $call) { 59 // Skip filters with no end point (i.e. the hook this function is hooked into) 60 if (!isset($call['stop'])) { 61 continue; 62 } 63 if (!isset($results[$filter])) { 64 $results[$filter] = 0; 65 } 66 $results[$filter] = $results[$filter] + ($call['stop'] - $call['start']); 67 } 68 } 69 asort($results, SORT_NUMERIC); 70 $results = array_reverse($results); 71 $now = time(); 72 $new_res = array(); 73 $total = 0; 74 foreach ($results as $hook_name => $time_diff) { 75 $time = round($time_diff, 3); 76 $total += $time; 77 if ($time > 0.001) { 78 $new_res[$hook_name] = $time; 79 } 80 } 81 $insert = array('總計' => round($total, 3)); 82 $resultArray = $insert + $new_res; 83 if ((defined('DOING_AJAX') && DOING_AJAX) || wp_doing_cron()) { 84 return; 85 } 86 echo '<script>var mxp_hooks_usage=' . json_encode($resultArray) . ';var ulElement = document.getElementById("wp-admin-bar-mxp_dev_hooks_usage-default");ulElement.innerHTML = "";for (var hook in mxp_hooks_usage) { if (mxp_hooks_usage.hasOwnProperty(hook)) { console.log(hook,mxp_hooks_usage[hook]+" 秒");var liElement = document.createElement("li"); liElement.innerHTML = "<div class=\'ab-item ab-empty-item\'>"+hook + " : " + mxp_hooks_usage[hook]+" 秒</div>"; ulElement.appendChild(liElement); } } 84 87 </script>'; 85 }88 } 86 89 } 87 90 88 if (!function_exists('wp_get_current_user')) { 89 include_once ABSPATH . WPINC . '/pluggable.php'; 91 $cookie = isset($_COOKIE) ? $_COOKIE : array(); 92 $login_flag = false; 93 foreach ($cookie as $cookie_key => $cookie_value) { 94 if (strpos($cookie_key, 'wordpress_logged_in_') === 0 && $cookie_value != '') { 95 $login_flag = true; 96 } 90 97 } 91 if (isset($_REQUEST['debug']) && \is_super_admin()) {92 new MxpDevHooksUsage();98 if (isset($_REQUEST['debug']) && ) { 99 new MxpDevHooksUsage(); 93 100 } -
mxp-dev-tools/trunk/index.php
r3161580 r3162623 7 7 * Requires PHP: 5.6 8 8 * Tested up to: 6.6 9 * Stable tag: 3.2. 010 * Version: 3.2. 09 * Stable tag: 3.2. 10 * Version: 3.2. 11 11 * Author: Chun 12 12 * Author URI: https://www.mxp.tw/contact/ … … 39 39 use SearchReplace; 40 40 use Utility; 41 static $VERSION = '3.2. 0';41 static $VERSION = '3.2.'; 42 42 private $themeforest_api_base_url = 'https://api.envato.com/v3'; 43 43 protected static $instance = null; -
mxp-dev-tools/trunk/mxp-login-path.php
r3161580 r3162623 7 7 * Requires PHP: 5.6 8 8 * Tested up to: 6.6 9 * Stable tag: 3.2. 010 * Version: 3.2. 09 * Stable tag: 3.2. 10 * Version: 3.2. 11 11 * Author: Chun 12 12 * Author URI: https://www.mxp.tw/contact/ -
mxp-dev-tools/trunk/mxp-site-manager.php
r3161580 r3162623 7 7 * Requires PHP: 5.6 8 8 * Tested up to: 6.6 9 * Stable tag: 3.2. 010 * Version: 3.2. 09 * Stable tag: 3.2. 10 * Version: 3.2. 11 11 * Author: Chun 12 12 * Author URI: https://www.mxp.tw/contact/ … … 39 39 class MDTSiteManager { 40 40 public $plugin_slug = 'mdt-site-manager'; 41 public static $VERSION = '3.2. 0';41 public static $VERSION = '3.2.'; 42 42 43 43 public function __construct() { … … 55 55 add_action('template_redirect', array($this, 'verify_login_request'), -1); 56 56 add_action('wp_ajax_mxp_ajax_site_mamager', array($this, 'ajax_action')); 57 58 59 60 61 57 62 // 避免單獨啟用時呼叫判斷 is_super_admin() 噴錯 58 63 if (!function_exists('wp_get_current_user')) { … … 61 66 // 新增「設定」中的外掛選單 62 67 if (is_super_admin()) { 68 69 70 63 71 add_action('admin_menu', array($this, 'admin_menu')); 64 72 } 65 add_action('admin_enqueue_scripts', array($this, 'load_assets'));66 73 } 67 74 … … 102 109 ) 103 110 ); 111 112 113 114 115 116 117 118 119 120 104 121 } 105 122 } -
mxp-dev-tools/trunk/mxp-snippets.php
r3161580 r3162623 7 7 * Requires PHP: 5.6 8 8 * Tested up to: 6.6 9 * Stable tag: 3.2. 010 * Version: 3.2. 09 * Stable tag: 3.2. 10 * Version: 3.2. 11 11 * Author: Chun 12 12 * Author URI: https://www.mxp.tw/contact/ -
mxp-dev-tools/trunk/readme.txt
r3161580 r3162623 6 6 Requires PHP: 5.6 7 7 Tested up to: 6.6 8 Stable tag: 3.2. 08 Stable tag: 3.2. 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 77 77 78 78 == Changelog == 79 80 81 82 83 84 79 85 80 86 = 3.2.0 =
Note: See TracChangeset
for help on using the changeset viewer.