__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 Super Cache 兼容成功.
错误: 安装WP Super Cache 兼容失败.
卸载WP Super Cache 兼容成功.
错误: 卸载WP Super Cache 兼容失败.
message; ?>
message; ?>