Changeset 1354181
- Timestamp:
- 02/19/2016 02:39:21 PM (10 years ago)
- Location:
- wp-switch-util/trunk
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
README.md (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
-
wp_switch_util.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-switch-util/trunk
- Property svn:ignore
-
old new 1 1 .git 2 .idea
-
- Property svn:ignore
-
wp-switch-util/trunk/README.md
r1352649 r1354181 27 27 #### Installation 28 28 29 **Installation** 30 29 31 1. Upload the plugin files to the `/wp-content/plugins/wp-switch-util` directory, or install the plugin through the WordPress plugins screen directly. 30 32 2. Activate the plugin through the 'Plugins' screen in WordPress 31 33 3. Use the Settings->Wp Switch Util screen to configure the plugin 32 34 33 -- 35 **安装方法** 34 36 35 37 1. 上传本插件文件到`/wp-content/plugins/wp-switch-util`目录,或者通过Wordpress插件安装画面自动安装。 … … 40 42 #### Changelog 41 43 42 = 0.0.3 = 44 **0.1.0** 45 46 * Fixed the bug that can't disable revision. 47 * 解决版本更新的问题 48 49 **0.0.3** 43 50 44 51 * Fixed the bug that can't disable auto save. 45 46 --47 48 52 * 解决自动保存的BUG 49 53 50 = 0.0.2 = 54 **0.0.2** 51 55 52 56 * Upgrade the bug that the plugin can't cache avatar on HTTPS protocol. 53 57 * Change the folder that avatar is cached to `/cache/avatar`. 54 55 --56 57 58 * 解决HTTPS协议下不能缓存头像的问题。 58 59 * 修改缓存头像目录到`/cache/avatar`。 59 60 60 = 0.0.1 = 61 **0.0.1** 61 62 62 63 * New. -
wp-switch-util/trunk/readme.txt
r1352649 r1354181 22 22 * Disable pingback in site 23 23 * Disable the admin bar 24 25 ------------------------26 24 27 25 这个插件实现了以下功能: … … 58 56 == Changelog == 59 57 58 = 0.1.0 = 59 60 * Fixed the bug that can't disable revision. 61 * 解决版本更新的问题 62 60 63 = 0.0.3 = 61 64 62 65 * Fixed the bug that can't disable auto save. 63 64 --65 66 66 * 解决自动保存的BUG 67 67 … … 70 70 * Upgrade the bug that the plugin can't cache avatar on HTTPS protocol. 71 71 * Change the folder that avatar is cached to `/cache/avatar`. 72 73 --74 75 72 * 解决HTTPS协议下不能缓存头像的问题。 76 73 * 修改缓存头像目录到`/cache/avatar`。 -
wp-switch-util/trunk/wp_switch_util.php
r1352649 r1354181 1 1 <?php 2 2 3 /** 3 Plugin Name: WP Switch Util 4 Plugin URI: http://yutuo.net/archives/f685d2dbbb176e86.html 5 Description: This plugin can: cache the avatar, format you url, disable the histroy, disable auto save, disable admin bar 6 Version: 0.0.3 7 Author: yutuo 8 Author URI: http://yutuo.net 9 Text Domain: wp_su 10 Domain Path: /wp-switch-util 11 License: GPL v3 - http://www.gnu.org/licenses/gpl.html 12 */ 13 class WPSwitchUtilConfig { 4 * Plugin Name: WP Switch Util 5 * Plugin URI: http://yutuo.net/archives/f685d2dbbb176e86.html 6 * Description: This plugin can: cache the avatar, format you url, disable the histroy, disable auto save, disable admin bar 7 * Version: 0.1.0 8 * Author: yutuo 9 * Author URI: http://yutuo.net 10 * Text Domain: wp_su 11 * Domain Path: /wp-switch-util 12 * License: GPL v3 - http://www.gnu.org/licenses/gpl.html 13 */ 14 class WPSwitchUtilConfig 15 { 14 16 /** 保存的KEY */ 15 17 const CONFIG_OPTIONS_KEY = 'wp_su_options'; 16 18 17 19 /** 默认设置 */ 18 static $DEFAULT_OPTION = array (19 'cacheavatar' => '0',20 'cacheday' => '15',21 'mdb5url' => '0',22 'mdb5length' => '16',23 'changeword' => '0',24 'autosave' => '0',25 'hirstroy' => '0',26 'pingback' => '0',27 'adminbar' => '0',20 static $DEFAULT_OPTION = array( 21 'cacheavatar' => '0', 22 'cacheday' => '15', 23 'mdb5url' => '0', 24 'mdb5length' => '16', 25 'changeword' => '0', 26 'autosave' => '0', 27 'hirstroy' => '0', 28 'pingback' => '0', 29 'adminbar' => '0', 28 30 ); 29 31 } 30 32 31 class WPSwitchUtil { 33 class WPSwitchUtil 34 { 32 35 /** 本Plugin文件夹实际目录 */ 33 36 var $pluginDir; … … 36 39 /** 设置 */ 37 40 var $options; 41 38 42 /** 构造函数 */ 39 function WPSwitchUtil() { 43 function WPSwitchUtil() 44 { 40 45 $this->pluginDir = dirname(plugin_basename(__FILE__)); 41 46 $this->currentUrl = get_option('siteurl') . '/wp-content/plugins/' . basename(dirname(__FILE__)); 42 47 $this->options = get_option(WPSwitchUtilConfig::CONFIG_OPTIONS_KEY); 43 48 } 49 44 50 /** 启用 */ 45 function activate() { 51 function activate() 52 { 46 53 update_option(WPSwitchUtilConfig::CONFIG_OPTIONS_KEY, WPSwitchUtilConfig::$DEFAULT_OPTION); 47 54 } 55 48 56 /** 停用 */ 49 function deActivate() { 57 function deActivate() 58 { 50 59 delete_option(WPSwitchUtilConfig::CONFIG_OPTIONS_KEY); 51 60 } 61 52 62 /** 初始化 */ 53 function init() { 63 function init() 64 { 54 65 load_plugin_textdomain('wp_su', false, $this->pluginDir . '/lang'); 55 66 } 67 56 68 /** 在设置菜单添加链接 */ 57 function menuLink() { 69 function menuLink() 70 { 58 71 add_options_page('Wp Switch Util Settings', __('Wp Switch Util', 'wp_su'), 'manage_options', 'wpSwitchUtil', 59 array ($this, 'optionPage')); 60 } 72 array($this, 'optionPage')); 73 } 74 61 75 /** 插件设置链接 */ 62 function actionLink($links, $file) { 76 function actionLink($links, $file) 77 { 63 78 if ($file != plugin_basename(__FILE__)) { 64 79 return $links; … … 68 83 return $links; 69 84 } 85 70 86 /** 插件设置页面 */ 71 function optionPage() { 87 function optionPage() 88 { 72 89 $current_path = dirname(__FILE__) . '/inc/wp_switch_util_setting.php'; 73 90 include $current_path; 74 91 } 92 75 93 /** 头像缓存 */ 76 function cacheAvatar($avatar, $id_or_email, $size, $default) { 94 function cacheAvatar($avatar, $id_or_email, $size, $default) 95 { 77 96 // URL目录地址 78 $current_path = content_url() . '/cache/avatar/'; 97 $current_path = content_url() . '/cache/avatar/'; 79 98 // 保存目录 80 99 $out_folder = WP_CONTENT_DIR . '/cache/avatar/'; … … 98 117 return $avatar; 99 118 } 119 100 120 /** MDB5的URL */ 101 function mdb5Url($postname) { 121 function mdb5Url($postname) 122 { 102 123 $post_title = $_POST['post_title']; 103 124 $str = mb_convert_encoding($post_title, 'UTF-8'); … … 109 130 return $md5_str; 110 131 } 132 111 133 /** 不转换半角到全角 */ 112 function changeWord() { 134 function changeWord() 135 { 113 136 $filters_to_remove = array( 114 137 'comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title', … … 118 141 ); 119 142 120 foreach ($filters_to_remove as $a_filter) {143 foreach ($filters_to_remove as $a_filter) { 121 144 remove_filter($a_filter, 'wptexturize'); 122 145 } 123 146 } 147 124 148 /** 禁止自动保存 */ 125 function disableAutoSave() { 149 function disableAutoSave() 150 { 126 151 wp_deregister_script('autosave'); 127 152 } 128 /** 阻止站内文章Pingback */ 129 function disablePingbackSelf(&$links) { 130 $home = get_option('home'); 131 foreach ($links as $l => $link) { 132 if (0 === strpos($link, $home)) { 133 unset($links[$l]); 134 } 135 } 136 137 } 153 154 /** 阻止站内文章Pingback */ 155 function disablePingbackSelf(&$links) 156 { 157 $home = get_option('home'); 158 foreach ($links as $l => $link) { 159 if (0 === strpos($link, $home)) { 160 unset($links[$l]); 161 } 162 } 163 164 } 165 138 166 /** 不显示AdminBar */ 139 function hideAdminBar() { 167 function hideAdminBar() 168 { 140 169 return false; 141 170 } 171 142 172 /** 应用插件 */ 143 function apply() { 173 function apply() 174 { 144 175 // 启用 145 register_activation_hook(__FILE__, array ($this, 'activate'));176 register_activation_hook(__FILE__, array($this, 'activate')); 146 177 // 停用 147 register_deactivation_hook(__FILE__, array ($this, 'deActivate'));178 register_deactivation_hook(__FILE__, array($this, 'deActivate')); 148 179 // 初始化 149 add_action('init', array ($this, 'init'));180 add_action('init', array($this, 'init')); 150 181 // 管理页面 151 add_action('admin_menu', array ($this, 'menuLink'));182 add_action('admin_menu', array($this, 'menuLink')); 152 183 // 插件链接 153 add_action('plugin_action_links', array ($this, 'actionLink'), 10, 2);184 add_action('plugin_action_links', array($this, 'actionLink'), 10, 2); 154 185 155 186 if (!is_array($this->options)) { … … 162 193 // MDB5的URL 163 194 if (array_key_exists('mdb5url', $this->options) && $this->options['mdb5url'] == '1') { 164 add_filter('name_save_pre', array ($this, 'mdb5Url'));195 add_filter('name_save_pre', array($this, 'mdb5Url')); 165 196 } 166 197 // 不转换半角到全角 … … 170 201 // 禁止自动保存 171 202 if (array_key_exists('autosave', $this->options) && $this->options['autosave'] == '1') { 172 add_action('wp_print_scripts', array ($this, 'disableAutoSave'));203 add_action('wp_print_scripts', array($this, 'disableAutoSave')); 173 204 } 174 205 // 禁止历史版本 175 206 if (array_key_exists('hirstroy', $this->options) && $this->options['hirstroy'] == '1') { 176 remove_action('p re_post_update', 'wp_save_post_revision');207 remove_action('post_updated', 'wp_save_post_revision'); 177 208 } 178 209 // 阻止站内文章Pingback 179 if (array_key_exists('pingback', $this->options) && $this->options['pingback'] == '1') {180 add_action('pre_ping', array ($this, 'disablePingbackSelf'));210 if (array_key_exists('pingback', $this->options) && $this->options['pingback'] == '1') { 211 add_action('pre_ping', array($this, 'disablePingbackSelf')); 181 212 } 182 213 // 不显示AdminBar 183 214 if (array_key_exists('adminbar', $this->options) && $this->options['adminbar'] == '1') { 184 add_filter('show_admin_bar', array ($this, 'hideAdminBar')); 185 } 186 } 187 188 function getImageFilesToDisk($url, $out_folder, $save_day) { 215 add_filter('show_admin_bar', array($this, 'hideAdminBar')); 216 } 217 } 218 219 function getImageFilesToDisk($url, $out_folder, $save_day) 220 { 189 221 $url = str_replace('&', '&', $url); 190 222 // 图片文件名取得 … … 192 224 return ''; 193 225 } 194 226 195 227 $pre_file_name = $match[1]; 196 228 $size = $match[2]; 197 229 $level = $match[3]; 198 $file_name = $pre_file_name . '.png'; 230 $file_name = $pre_file_name . '.png'; 199 231 $out_folder = $out_folder . $size . '/'; 200 232 if (!file_exists($out_folder)) { … … 217 249 } 218 250 219 function getDftImageFilesToDisk($out_folder, $size) { 251 function getDftImageFilesToDisk($out_folder, $size) 252 { 220 253 $url = "http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=${size}&d=monsterid&r=G"; 221 254 $file_name = 'ad516503a11cd5ca435acc9bb6523536.png'; … … 234 267 } 235 268 236 function curl_file_get_contents($durl) { 269 function curl_file_get_contents($durl) 270 { 237 271 $ch = curl_init(); 238 272 curl_setopt($ch, CURLOPT_URL, $durl); 239 273 curl_setopt($ch, CURLOPT_TIMEOUT, 5); 240 274 curl_setopt($ch, CURLOPT_USERAGENT, _USERAGENT_); 241 curl_setopt($ch, CURLOPT_REFERER, _REFERER_);275 curl_setopt($ch, CURLOPT_REFERER, _REFERER_); 242 276 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 243 277 $r = curl_exec($ch);
Note: See TracChangeset
for help on using the changeset viewer.