__construct(); } function __construct() { global $wpcs_options, $wpcs_langs; $locale = str_replace('_', '-', strtolower(get_locale())); if ($wpcs_options === false) { $wpcs_options = get_option('wpcs_options'); } $this->langs = &$wpcs_langs; $this->options = $wpcs_options; if ( ! empty($_GET['variant']) && in_array($_GET['variant'], array_keys($this->langs))) { $this->admin_lang = $_GET['variant']; } else if (in_array($locale, array_keys($this->langs))) { $this->admin_lang = $locale; } $this->base = str_replace(basename(__FILE__), "", plugin_basename(__FILE__)); $this->url = admin_url('options-general.php?page=' . $this->base . 'wpchinese-switcher.php'); add_filter('plugin_action_links', array(&$this, 'action_links'), 10, 2); if (function_exists('add_options_page')) { add_options_page('WP Chinese Switcher', 'Chinese Switcher', 'manage_options', $this->base . 'wpchinese-switcher.php', array( &$this, 'display_options' )); } wp_enqueue_script('jquery'); } function action_links($links, $file) { if ($file == $this->base . 'wpchinese-switcher.php') { $links[] = 'Settings'; } return $links; } function install_cache_module() { global $wpcs_options; $ret = true; $file = file_get_contents(dirname(__FILE__) . '/wpcs-wp-super-cache-plugin.php'); $used_langs = 'Array()'; if (count($wpcs_options['wpcs_used_langs']) > 0) { $used_langs = "Array('" . implode("', '", $wpcs_options['wpcs_used_langs']) . "')"; } $file = str_replace('##wpcs_auto_language_recong##', $wpcs_options['wpcs_auto_language_recong'], $file); $file = str_replace('##wpcs_used_langs##', $used_langs, $file); $fp = @fopen(WP_PLUGIN_DIR . '/wp-super-cache/plugins/wpcs-wp-super-cache-plugin.php', 'w'); if ($fp) { fputs($fp, $file); fclose($fp); } else { $ret = false; } return true; } function uninstall_cache_module() { return unlink(WP_PLUGIN_DIR . '/wp-super-cache/plugins/wpcs-wp-super-cache-plugin.php'); } function get_cache_status() { if ( ! is_plugin_active('wp-super-cache/wp-cache.php')) { return 0; // not activated } if ( ! file_exists(WP_PLUGIN_DIR . '/wp-super-cache/plugins/wpcs-wp-super-cache-plugin.php')) { return 1; } return 2; } function display_options() { global $wp_rewrite; if ( ! empty($_POST['wpcso_uninstall_nonce'])) { delete_option('wpcs_options'); update_option('rewrite_rules', ''); echo '

WP Chinese Switcher Setting

Uninstall Successfully. 卸载成功, 现在您可以到插件菜单里禁用本插件.
'; return; } else if ($this->options === false) { echo '

WP Chinese Switcher Setting

错误: 没有找到配置信息, 可能由于WordPress系统错误或者您已经卸载了本插件. 您可以尝试禁用本插件后再重新激活.
'; return; } if ( ! empty($_POST['toggle_cache'])) { if ($this->get_cache_status() == 1) { $result = $this->install_cache_module(); if ($result) { echo '

安装WP Super Cache 兼容成功.

'; } else { echo '

错误: 安装WP Super Cache 兼容失败.

'; } } else if ($this->get_cache_status() == 2) { $result = $this->uninstall_cache_module(); if ($result) { echo '

卸载WP Super Cache 兼容成功.

'; } else { echo '

错误: 卸载WP Super Cache 兼容失败.

'; } } } if ( ! empty($_POST['wpcso_submitted'])) { $this->is_submitted = true; $this->process(); if ($this->get_cache_status() == 2) { $this->install_cache_module(); } } ?>
Select Admin Language: navi(); ?>

WP Chinese Switcher Settings

is_submitted && $this->is_success) { ?>

message; ?>

is_submitted && $this->is_error) { ?>

message; ?>

版本 . 文派开源 | 插件主页

单击选项名查看帮助!
自定义"不转换"标签名:
对下面几种中文开启转换功能: langs as $key => $value) { ?> options['wpcs_used_langs']) ? ' checked="checked"' : ''; ?> />
中文搜索关键词简繁转换:
识别浏览器中文语言动作: options['wpcs_auto_language_recong'] == 1 ? ' checked="checked"' : ''; ?> />
使用Cookie保存并识别用户语言偏好:
不转换文章中某些HTML标签里中文: (默认空)
不转换日语(lang="ja")的HTML标签里内容: options['wpcs_no_conversion_ja']) ? ' checked="checked"' : ''; ?> />
不转换HTML中任意内容TAG: <!--wpcs_NC_START-->爱与正义, 剑与魔法, 光荣与梦想<!--wpcs_NC_END-->
options['wpcs_no_conversion_qtag']) ? ' checked="checked"' : ''; ?> />
繁简转换页面永久链接格式:


对页面内容整体转换: options['wpcs_use_fullpage_conversion'] == 1 ? ' checked="checked"' : ''; ?> />
get_cache_status(); ?>
WP Super Cache兼容:
已安装'; } else if (empty($this->options['wpcs_browser_redirect']) && empty($this->options['wpcs_use_cookie_variant'])) { echo '
未开启"识别浏览器中文语言动作"和"使用Cookie保存并识别用户语言偏好"功能. 无需安装
'; } else { echo '
未安装
'; } ?>
WP Super Cache未开启缓存'; } else if ( ! empty($GLOBALS['super_cache_enabled'])) { echo '
警告: WP Super Cache未设为"legacy page caching"模式, 本兼容模块无法正常工作.
'; } } ?>
默认情况下, 本插件的"识别浏览器中文语言动作"和"使用Cookie保存并识别用户语言偏好"这两个功能与缓存插件不兼容. 如果您使用的是WP Super Cache的"Legacy page caching"缓存模式, 您可以点击下面的按钮安装WP Super Cache兼容. 注意: 如果您没有开启"识别浏览器中文语言动作"和"使用Cookie保存并识别用户语言偏好"这两个功能(默认均为关闭), 则无需安装此兼容; 安装本兼容将增加WP Super Cache的缓存磁盘空间占用; 仅支持WP Super Cache插件的"Legacy page caching"模式, 不支持"PHP Cache"和"mod_rewrite cache"模式. (WP Super Cache 插件安装后默认为"PHP Cache"模式, 您必须手动切换到"Legacy"模式.)
get_cache_status() == 1) { echo "安装兼容"; } else { echo "卸载兼容"; } ?>" get_cache_status() == 0 || (empty($this->options['wpcs_browser_redirect']) && empty($this->options['wpcs_use_cookie_variant']))) { echo 'disabled="disabled"'; } ?> />
卸载本插件:
确定卸载本插件?
admin_lang) { wpcs_load_conversion_table(); $o = limit_zhconversion($o, $this->langs[$this->admin_lang][0]); } echo $o; } function navi() { $variant = ! empty($_GET['variant']) ? $_GET['variant'] : ''; $str = '默认/ 默认 '; if ( ! $this->options['wpcs_used_langs']) { return $str; } foreach ($this->langs as $key => $value) { $str .= '' . $value[2] . ' '; } return $str; } function process() { global $wp_rewrite, $wpcs_options; $langs = array(); foreach ($this->langs as $key => $value) { if (isset($_POST['wpcso_variant_' . $key])) { $langs[] = $key; } } $options = array( 'wpcs_used_langs' => $langs, 'wpcs_search_conversion' => intval($_POST['wpcso_search_conversion']), 'wpcs_browser_redirect' => intval($_POST['wpcso_browser_redirect']), 'wpcs_use_cookie_variant' => intval($_POST['wpcso_use_cookie_variant']), 'wpcs_use_fullpage_conversion' => (isset($_POST['wpcso_use_fullpage_conversion']) ? 1 : 0), 'wpcs_trackback_plugin_author' => (isset($_POST['wpcso_trackback_plugin_author']) ? intval($_POST['wpcso_trackback_plugin_author']) : 0), 'wpcs_add_author_link' => (isset($_POST['wpcso_add_author_link']) ? 1 : 0), 'wpcs_use_permalink' => intval($_POST['wpcso_use_permalink']), 'wpcs_auto_language_recong' => (isset($_POST['wpcso_auto_language_recong']) ? 1 : 0), 'wpcs_no_conversion_tag' => trim($_POST['wpcso_no_conversion_tag'], " \t\n\r\0\x0B,|"), 'wpcs_no_conversion_ja' => (isset($_POST['wpcso_no_conversion_ja']) ? 1 : 0), 'wpcs_no_conversion_qtag' => (isset($_POST['wpcso_no_conversion_qtag']) ? 1 : 0), 'nctip' => trim($_POST['wpcso_no_conversion_tip']), ); foreach ($this->langs as $lang => $value) { if ( ! empty($_POST[$value[1]])) { $options[$value[1]] = trim($_POST[$value[1]]); } } if ($this->get_cache_status() == 2 && empty($options['wpcs_browser_redirect']) && empty($options['wpcs_use_cookie_variant'])) { $this->uninstall_cache_module(); } if ($options['wpcs_trackback_plugin_author'] == 1) { $options['wpcs_trackback_plugin_author'] = $this->trackback(); if ($options['wpcs_trackback_plugin_author'] == 2) { $this->message .= '已成功向插件主页发送Trackback。感谢您的支持。
'; } else { $this->message .= '向插件主页发送Trackback失败,您可以尝试重新提交。
'; } } if ($options['wpcs_add_author_link'] == 1 && $this->options['wpcs_add_author_link'] == 0) { if ($options['wpcs_add_author_link'] = wp_insert_link(array( 'link_target' => '_blank', 'link_description' => '小野大神的 Blog,关注文明与幻想。', 'link_rss' => 'https://oogami.name/feed/', 'link_name' => '小野大神', 'link_url' => 'https://oogami.name/' ))) { $this->message .= '已成功添加插件作者的主页链接。感谢您的支持
'; } else { $options['wpcs_add_author_link'] = 0; $this->message .= '添加插件作者主页链接失败。请重试。
'; } } else if ($options['wpcs_add_author_link'] == 0 && $this->options['wpcs_add_author_link'] != 0) { if (wp_delete_link($this->options['wpcs_add_author_link'])) { $this->message .= '已删除插件作者的主页链接。
'; } } $wpcs_options = $options; //因为可能需要刷新rewrite规则, 必须立即更新wpcs_options全局变量 if ($this->options['wpcs_use_permalink'] != $options['wpcs_use_permalink'] || ($this->options['wpcs_use_permalink'] != 0 && $this->options['wpcs_used_langs'] != $options['wpcs_used_langs']) ) { if ( ! has_filter('rewrite_rules_array', 'wpcs_rewrite_rules')) { add_filter('rewrite_rules_array', 'wpcs_rewrite_rules'); } $wp_rewrite->flush_rules(); } update_option('wpcs_options', $options); $this->options = $options; $this->is_success = true; $this->message .= '
设置已更新。'; } function trackback() { $options = array(); $options['timeout'] = 4; $options['body'] = array( 'title' => 'WPCS Trackback', 'url' => get_option('home') . '/', 'blog_name' => get_option('blogname'), 'excerpt' => 'Hello, I am using the WP Chinese Switcher Plugin Version ' . wpcs_VERSION ); $response = @wp_remote_post('https://oogami.name/project/wpcs/trackback/', $options); $message = 'WPCS Version ' . wpcs_VERSION . "\n"; $message .= get_option('home') . '/'; @wp_mail('support@feibisi.com', 'WPCS Feedback - ' . get_option('blogname'), $message); if (is_wp_error($response)) { return 0; } return 2; } }