From 1e48ad40fa1807b13ecf6c9fac2e16c5671484d7 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 1 Feb 2013 11:14:25 -0500 Subject: [PATCH] change this plugin to be a network wide plugin now. so the wptc client will be loaded network wide, and any blog can get connect with trac repository. --- wp-trac-client/admin-settings.php | 18 +++++++++--------- wp-trac-client/wp-trac-client.php | 30 ++++++++++++++++-------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/wp-trac-client/admin-settings.php b/wp-trac-client/admin-settings.php index 9f1f06d..4e30593 100644 --- a/wp-trac-client/admin-settings.php +++ b/wp-trac-client/admin-settings.php @@ -6,9 +6,9 @@ $_POST['wptc_settings_form_submit'] == 'Y') { // save settings submit. save user input to database. - update_blog_option(get_current_blog_id(), 'wptc_rpcurl', $_POST['wptc_rpcurl']); - update_blog_option(get_current_blog_id(), 'wptc_username', $_POST['wptc_username']); - update_blog_option(get_current_blog_id(), 'wptc_password', $_POST['wptc_password']); + update_site_option('wptc_rpcurl', $_POST['wptc_rpcurl']); + update_site_option('wptc_username', $_POST['wptc_username']); + update_site_option('wptc_password', $_POST['wptc_password']); // show the message. echo '

Settings Updated

'; @@ -17,9 +17,9 @@ if (isset($_POST['wptc_quicktest_form_submit']) && $_POST['wptc_quicktest_form_submit'] == 'Y') { - $rpcurl = get_blog_option(get_current_blog_id(), 'wptc_rpcurl'); - $username = get_blog_option(get_current_blog_id(), 'wptc_username'); - $password = get_blog_option(get_current_blog_id(), 'wptc_password'); + $rpcurl = get_site_option('wptc_rpcurl'); + $username = get_site_option('wptc_username'); + $password = get_site_option('wptc_password'); if ($rpcurl) { require_once 'Zend/XmlRpc/Client.php'; $client = new Zend_XmlRpc_Client($rpcurl); @@ -49,19 +49,19 @@ Trac XML-RPC URL: + value="" size="88"/> Trac User Name: + value="" size="58"/> Trac Password: + value="" size="58"/> diff --git a/wp-trac-client/wp-trac-client.php b/wp-trac-client/wp-trac-client.php index 0efae5f..df4a350 100644 --- a/wp-trac-client/wp-trac-client.php +++ b/wp-trac-client/wp-trac-client.php @@ -23,21 +23,23 @@ // this will work for symlink path too. $my_plugin_file = __FILE__; -if (isset($plugin)) { - $my_plugin_file = $plugin; -} -else if (isset($mu_plugin)) { - $my_plugin_file = $mu_plugin; -} -else if (isset($network_plugin)) { - $my_plugin_file = $network_plugin; -} +//if (isset($plugin)) { +// $my_plugin_file = $plugin; +//} +//else if (isset($mu_plugin)) { +// $my_plugin_file = $mu_plugin; +//} +//else if (isset($network_plugin)) { +// $my_plugin_file = $network_plugin; +//} + +//var_dump($my_plugin_file); define('MY_PLUGIN_FILE', $my_plugin_file); define('MY_PLUGIN_PATH', WP_PLUGIN_DIR.'/'.basename(dirname($my_plugin_file))); // load the Zend Framework. - +// show error message. ini_set('display_errors', 1); add_action('plugins_loaded', 'zend_framework_init'); function zend_framework_init() { @@ -96,9 +98,9 @@ function register_resources() { function get_wptc_client() { // get the settings from current blog - $rpcurl = get_blog_option(get_current_blog_id(), 'wptc_rpcurl'); - $username = get_blog_option(get_current_blog_id(), 'wptc_username'); - $password = get_blog_option(get_current_blog_id(), 'wptc_password'); + $rpcurl = get_site_option('wptc_rpcurl'); + $username = get_site_option('wptc_username'); + $password = get_site_option('wptc_password'); if ($rpcurl) { require_once 'Zend/XmlRpc/Client.php'; $wptc_client = new Zend_XmlRpc_Client($rpcurl); @@ -109,7 +111,7 @@ function get_wptc_client() { } // we need a admin page on dashboard for configuration. -add_action('admin_menu', 'wptc_admin_init'); +add_action('network_admin_menu', 'wptc_admin_init'); /** * the main function to set up admin page. */