Version Description
- Refactored verbs to improve add-site function from Sync Dashboard
Download this release
Release Info
Developer | layotte |
Plugin | iThemes Sync |
Version | 2.0.3 |
Comparing to | |
See all releases |
Code changes from version 2.0.2 to 2.0.3
- api.php +3 -0
- history.txt +2 -0
- init.php +1 -1
- lang/ithemes-sync.pot +5 -5
- readme.txt +7 -1
- request-handler.php +7 -1
- settings.php +8 -6
- verbs/manage-site.php +53 -0
api.php
CHANGED
@@ -65,6 +65,7 @@ class Ithemes_Sync_API {
|
|
65 |
'manage-plugins' => 'Ithemes_Sync_Verb_Manage_Plugins',
|
66 |
'manage-reports' => 'Ithemes_Sync_Verb_Manage_Reports',
|
67 |
'manage-roles' => 'Ithemes_Sync_Verb_Manage_Roles',
|
|
|
68 |
'manage-themes' => 'Ithemes_Sync_Verb_Manage_Themes',
|
69 |
'manage-users' => 'Ithemes_Sync_Verb_Manage_Users',
|
70 |
'set-admin-bar-item-whitelist' => 'Ithemes_Sync_Verb_Set_Admin_Bar_Item_Whitelist',
|
@@ -73,6 +74,8 @@ class Ithemes_Sync_API {
|
|
73 |
);
|
74 |
|
75 |
public function __construct() {
|
|
|
|
|
76 |
$GLOBALS['ithemes-sync-api'] = $this;
|
77 |
|
78 |
require_once( $GLOBALS['ithemes_sync_path'] . '/functions.php' );
|
65 |
'manage-plugins' => 'Ithemes_Sync_Verb_Manage_Plugins',
|
66 |
'manage-reports' => 'Ithemes_Sync_Verb_Manage_Reports',
|
67 |
'manage-roles' => 'Ithemes_Sync_Verb_Manage_Roles',
|
68 |
+
'manage-site' => 'Ithemes_Sync_Verb_Manage_Site',
|
69 |
'manage-themes' => 'Ithemes_Sync_Verb_Manage_Themes',
|
70 |
'manage-users' => 'Ithemes_Sync_Verb_Manage_Users',
|
71 |
'set-admin-bar-item-whitelist' => 'Ithemes_Sync_Verb_Set_Admin_Bar_Item_Whitelist',
|
74 |
);
|
75 |
|
76 |
public function __construct() {
|
77 |
+
@ini_set( 'display_errors', 0 );
|
78 |
+
|
79 |
$GLOBALS['ithemes-sync-api'] = $this;
|
80 |
|
81 |
require_once( $GLOBALS['ithemes_sync_path'] . '/functions.php' );
|
history.txt
CHANGED
@@ -184,3 +184,5 @@
|
|
184 |
Initial release to WordPress.org
|
185 |
2.0.1 - 2017-06-21 - Lew Ayotte
|
186 |
Bug Fix: Adding code to get-authentication-token verb to set the scheme to https by default if it should be
|
|
|
|
184 |
Initial release to WordPress.org
|
185 |
2.0.1 - 2017-06-21 - Lew Ayotte
|
186 |
Bug Fix: Adding code to get-authentication-token verb to set the scheme to https by default if it should be
|
187 |
+
2.0.3 - 2017-09-26 - Glenn Ansley
|
188 |
+
Improvement: Refactored verbs to improve add-site function from Sync Dashboard.
|
init.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: iThemes Sync
|
|
4 |
Plugin URI: http://ithemes.com/sync
|
5 |
Description: Manage updates to your WordPress sites easily in one place.
|
6 |
Author: iThemes
|
7 |
-
Version: 2.0.
|
8 |
Author URI: http://ithemes.com/
|
9 |
Domain Path: /lang/
|
10 |
iThemes Package: ithemes-sync
|
4 |
Plugin URI: http://ithemes.com/sync
|
5 |
Description: Manage updates to your WordPress sites easily in one place.
|
6 |
Author: iThemes
|
7 |
+
Version: 2.0.3
|
8 |
Author URI: http://ithemes.com/
|
9 |
Domain Path: /lang/
|
10 |
iThemes Package: ithemes-sync
|
lang/ithemes-sync.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the same license as the iThemes Sync package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: iThemes Sync 2.0.
|
6 |
"Report-Msgid-Bugs-To: http://ithemes.com/support/\n"
|
7 |
-
"POT-Creation-Date: 2017-
|
8 |
"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
@@ -35,7 +35,7 @@ msgstr ""
|
|
35 |
msgid "iThemes Sync is now hidden from your user again."
|
36 |
msgstr ""
|
37 |
|
38 |
-
#. #-#-#-#-# ithemes-sync.pot (iThemes Sync 2.0.
|
39 |
#. Plugin Name of the plugin/theme
|
40 |
#: admin.php:168 admin.php:174 settings-page.php:268
|
41 |
msgid "iThemes Sync"
|
@@ -545,12 +545,12 @@ msgstr ""
|
|
545 |
msgid "Sync"
|
546 |
msgstr ""
|
547 |
|
548 |
-
#: settings.php:
|
549 |
msgid ""
|
550 |
"The user is not authenticated. Could not remove authentication for the user."
|
551 |
msgstr ""
|
552 |
|
553 |
-
#: settings.php:
|
554 |
msgid ""
|
555 |
"A valid user was unable to be found. A valid user is required in order to do "
|
556 |
"a successful ping."
|
2 |
# This file is distributed under the same license as the iThemes Sync package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: iThemes Sync 2.0.3\n"
|
6 |
"Report-Msgid-Bugs-To: http://ithemes.com/support/\n"
|
7 |
+
"POT-Creation-Date: 2017-09-26 14:04:28+00:00\n"
|
8 |
"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
35 |
msgid "iThemes Sync is now hidden from your user again."
|
36 |
msgstr ""
|
37 |
|
38 |
+
#. #-#-#-#-# ithemes-sync.pot (iThemes Sync 2.0.3) #-#-#-#-#
|
39 |
#. Plugin Name of the plugin/theme
|
40 |
#: admin.php:168 admin.php:174 settings-page.php:268
|
41 |
msgid "iThemes Sync"
|
545 |
msgid "Sync"
|
546 |
msgstr ""
|
547 |
|
548 |
+
#: settings.php:133
|
549 |
msgid ""
|
550 |
"The user is not authenticated. Could not remove authentication for the user."
|
551 |
msgstr ""
|
552 |
|
553 |
+
#: settings.php:199
|
554 |
msgid ""
|
555 |
"A valid user was unable to be found. A valid user is required in order to do "
|
556 |
"a successful ping."
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: ithemes, layotte, blepoxp
|
|
3 |
Tags: manage multiple Sites, backup, security, migrate, SEO, manage updates, administration, update manager, reports, sync, google analytics, optimize, uptime, ithemes, customize dashboard, client sites, maintenance, management, google webmaster tools, reporting
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 4.8
|
6 |
-
Stable tag: 2.0.
|
7 |
License: GPLv3 or later
|
8 |
License URI: http://www.gnu.org/licenses/quick-guide-gplv3.html
|
9 |
|
@@ -86,6 +86,12 @@ Make steady, reliable income for WordPress maintenance with iThemes Sync Pro’s
|
|
86 |
|
87 |
== Changelog ==
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
= 2.0.1 =
|
90 |
* Adding code to get-authentication-token verb to set the scheme to https by default if it should be
|
91 |
|
3 |
Tags: manage multiple Sites, backup, security, migrate, SEO, manage updates, administration, update manager, reports, sync, google analytics, optimize, uptime, ithemes, customize dashboard, client sites, maintenance, management, google webmaster tools, reporting
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 4.8
|
6 |
+
Stable tag: 2.0.3
|
7 |
License: GPLv3 or later
|
8 |
License URI: http://www.gnu.org/licenses/quick-guide-gplv3.html
|
9 |
|
86 |
|
87 |
== Changelog ==
|
88 |
|
89 |
+
= 2.0.3 =
|
90 |
+
* Refactored verbs to improve add-site function from Sync Dashboard
|
91 |
+
|
92 |
+
= 2.0.2 =
|
93 |
+
* Turning of PHP Errors when doing AJAX, like WP does
|
94 |
+
|
95 |
= 2.0.1 =
|
96 |
* Adding code to get-authentication-token verb to set the scheme to https by default if it should be
|
97 |
|
request-handler.php
CHANGED
@@ -228,7 +228,8 @@ class Ithemes_Sync_Request_Handler {
|
|
228 |
}
|
229 |
|
230 |
private function parse_request( $request ) {
|
231 |
-
|
|
|
232 |
$this->send_response( new WP_Error( 'site-not-authenticated', 'The site does not have any authenticated users.' ) );
|
233 |
}
|
234 |
|
@@ -247,6 +248,11 @@ class Ithemes_Sync_Request_Handler {
|
|
247 |
$this->send_response( new WP_Error( "missing-var-$index", 'Invalid request.' ) );
|
248 |
}
|
249 |
}
|
|
|
|
|
|
|
|
|
|
|
250 |
|
251 |
if ( ! isset( $this->options['authentications'][$request['user_id']] ) ) {
|
252 |
$this->send_response( new WP_Error( 'user-not-authenticated', 'The requested user is not authenticated.' ) );
|
228 |
}
|
229 |
|
230 |
private function parse_request( $request ) {
|
231 |
+
|
232 |
+
if ( empty( $this->options['authentications'] ) && ( ! empty( $request['action'] ) && 'manage-site' != $request['action'] ) ) {
|
233 |
$this->send_response( new WP_Error( 'site-not-authenticated', 'The site does not have any authenticated users.' ) );
|
234 |
}
|
235 |
|
248 |
$this->send_response( new WP_Error( "missing-var-$index", 'Invalid request.' ) );
|
249 |
}
|
250 |
}
|
251 |
+
|
252 |
+
// If action is manage-site, stop here
|
253 |
+
if ( 'manage-site' == $request['action'] ) {
|
254 |
+
return;
|
255 |
+
}
|
256 |
|
257 |
if ( ! isset( $this->options['authentications'][$request['user_id']] ) ) {
|
258 |
$this->send_response( new WP_Error( 'user-not-authenticated', 'The requested user is not authenticated.' ) );
|
settings.php
CHANGED
@@ -89,21 +89,23 @@ class Ithemes_Sync_Settings {
|
|
89 |
$this->options_modified = true;
|
90 |
}
|
91 |
|
92 |
-
public function add_authentication( $
|
93 |
$this->init();
|
94 |
|
95 |
-
|
96 |
if ( ! isset( $this->options['authentications'] ) || ! is_array( $this->options['authentications'] ) ) {
|
97 |
$this->options['authentications'] = array();
|
98 |
}
|
99 |
|
100 |
-
|
|
|
|
|
|
|
101 |
|
102 |
-
$this->options['authentications'][$
|
103 |
'key' => $key,
|
104 |
'timestamp' => time(),
|
105 |
-
'local_user' => $
|
106 |
-
'username' => $
|
107 |
);
|
108 |
|
109 |
$this->options_modified = true;
|
89 |
$this->options_modified = true;
|
90 |
}
|
91 |
|
92 |
+
public function add_authentication( $sync_site_id, $ithemes_username, $key, $wp_user_login = false ) {
|
93 |
$this->init();
|
94 |
|
|
|
95 |
if ( ! isset( $this->options['authentications'] ) || ! is_array( $this->options['authentications'] ) ) {
|
96 |
$this->options['authentications'] = array();
|
97 |
}
|
98 |
|
99 |
+
if ( empty( $wp_user_login ) ) {
|
100 |
+
$local_user = wp_get_current_user();
|
101 |
+
$wp_user_login = $local_user->user_login;
|
102 |
+
}
|
103 |
|
104 |
+
$this->options['authentications'][$sync_site_id] = array(
|
105 |
'key' => $key,
|
106 |
'timestamp' => time(),
|
107 |
+
'local_user' => $wp_user_login,
|
108 |
+
'username' => $ithemes_username,
|
109 |
);
|
110 |
|
111 |
$this->options_modified = true;
|
verbs/manage-site.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
Implementation of the manage-site verb to add / remove site from sync.
|
5 |
+
Written by Glenn Ansley for iThemes.com
|
6 |
+
Version 1.0.0
|
7 |
+
|
8 |
+
Version History
|
9 |
+
1.0.0 - 2017-09-15 - Glenn Ansley
|
10 |
+
Initial version
|
11 |
+
*/
|
12 |
+
|
13 |
+
class Ithemes_Sync_Verb_Manage_Site extends Ithemes_Sync_Verb {
|
14 |
+
public static $name = 'manage-site';
|
15 |
+
public static $description = 'Allows the site to be synced or unsynced from the Sync dashboard';
|
16 |
+
|
17 |
+
private $default_arguments = array(
|
18 |
+
'action' => false,
|
19 |
+
'site_id' => false,
|
20 |
+
'it_username' => false,
|
21 |
+
'site_key' => false,
|
22 |
+
);
|
23 |
+
|
24 |
+
|
25 |
+
public function run( $arguments ) {
|
26 |
+
$arguments = Ithemes_Sync_Functions::merge_defaults( $arguments, $this->default_arguments );
|
27 |
+
|
28 |
+
if ( empty( $arguments['action'] ) || ! in_array( $arguments['action'], array( 'sync', 'unsync' ) ) ) {
|
29 |
+
return new WP_Error( 'missing-action', 'The action argument is missing or invalid. The action value should be sent in the action argument can contain the value `sync` or `unsync`.' );
|
30 |
+
}
|
31 |
+
|
32 |
+
if ( 'sync' == $arguments['action'] ) {
|
33 |
+
if ( empty( $arguments['site_id'] ) || empty( $arguments['it_username'] ) || empty( $arguments['site_key'] ) ) {
|
34 |
+
return new WP_Error( 'missing-data', 'Missing arguments. Please send `site_id`, `it_username`, and `site_key` as array keys in the argument when action is set to `sync`.' );
|
35 |
+
}
|
36 |
+
|
37 |
+
require_once( $GLOBALS['ithemes_sync_path'] . '/settings.php' );
|
38 |
+
if ( is_callable( array( $GLOBALS['ithemes-sync-settings'], 'add_authentication' ) ) ) {
|
39 |
+
if ( $GLOBALS['ithemes-sync-settings']->add_authentication( $arguments['site_id'], $arguments['it_username'], $arguments['site_key'], $arguments['wp_user_login'] ) ) {
|
40 |
+
return array( 'success' => 1, 'wp_version' => Ithemes_Sync_Functions::get_wordpress_version() );
|
41 |
+
}
|
42 |
+
} else {
|
43 |
+
return new WP_Error( 'method-not-callable', 'Function not found.' ); // This shouldn't happen. Was added during development for tracing purposes.
|
44 |
+
}
|
45 |
+
|
46 |
+
return new WP_Error( 'error-adding-site', 'An unknown error occured trying to Sync this site. Please try again.' );
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
return array( 'success' => 0 );
|
52 |
+
}
|
53 |
+
}
|