The WP Remote WordPress Plugin - Version 2.3

Version Description

Download this release

Release Info

Developer willmot
Plugin Icon 128x128 The WP Remote WordPress Plugin
Version 2.3
Comparing to
See all releases

Code changes from version 2.2.5 to 2.3

Files changed (5) hide show
  1. plugin.php +38 -4
  2. readme.txt +8 -2
  3. wprp.api.php +33 -17
  4. wprp.plugins.php +64 -15
  5. wprp.themes.php +4 -0
plugin.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin Name: WP Remote
5
  Description: Manage your WordPress site with <a href="https://wpremote.com/">WP Remote</a>. Deactivate to clear your API Key.
6
- Version: 2.2.5
7
  Author: Human Made Limited
8
  Author URI: http://hmn.md/
9
  */
@@ -143,11 +143,15 @@ function wprp_catch_api_call() {
143
  add_action( 'init', 'wprp_catch_api_call', 1 );
144
 
145
  function _wprp_upgrade_core() {
146
-
147
  include_once ( ABSPATH . 'wp-admin/includes/admin.php' );
148
  include_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
149
  include_once ( ABSPATH . 'wp-includes/update.php' );
150
 
 
 
 
 
151
  // force refresh
152
  wp_version_check();
153
 
@@ -170,7 +174,7 @@ function _wprp_upgrade_core() {
170
  return $result;
171
 
172
  global $wp_current_db_version, $wp_db_version;
173
-
174
  // we have to include version.php so $wp_db_version
175
  // will take the version of the updated version of wordpress
176
  require( ABSPATH . WPINC . '/version.php' );
@@ -178,4 +182,34 @@ function _wprp_upgrade_core() {
178
  wp_upgrade();
179
 
180
  return true;
181
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  /*
4
  Plugin Name: WP Remote
5
  Description: Manage your WordPress site with <a href="https://wpremote.com/">WP Remote</a>. Deactivate to clear your API Key.
6
+ Version: 2.3
7
  Author: Human Made Limited
8
  Author URI: http://hmn.md/
9
  */
143
  add_action( 'init', 'wprp_catch_api_call', 1 );
144
 
145
  function _wprp_upgrade_core() {
146
+
147
  include_once ( ABSPATH . 'wp-admin/includes/admin.php' );
148
  include_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
149
  include_once ( ABSPATH . 'wp-includes/update.php' );
150
 
151
+ // check for filesystem access
152
+ if ( ! _wpr_check_filesystem_access() )
153
+ return array( 'status' => 'error', 'error' => 'The filesystem is not writable with the supplied credentials' );
154
+
155
  // force refresh
156
  wp_version_check();
157
 
174
  return $result;
175
 
176
  global $wp_current_db_version, $wp_db_version;
177
+
178
  // we have to include version.php so $wp_db_version
179
  // will take the version of the updated version of wordpress
180
  require( ABSPATH . WPINC . '/version.php' );
182
  wp_upgrade();
183
 
184
  return true;
185
+ }
186
+
187
+ function _wpr_check_filesystem_access() {
188
+
189
+ ob_start();
190
+ $success = request_filesystem_credentials();
191
+ ob_end_clean();
192
+
193
+ return (bool) $success;
194
+ }
195
+
196
+ function _wpr_set_filesystem_credentials( $credentials ) {
197
+
198
+ if ( empty( $_GET['filesystem_details'] ) )
199
+ return $credentials;
200
+
201
+ $_credentials = array(
202
+ 'username' => $_GET['filesystem_details']['credentials']['username'],
203
+ 'password' => $_GET['filesystem_details']['credentials']['password'],
204
+ 'hostname' => $_GET['filesystem_details']['credentials']['hostname'],
205
+ 'connection_type' => $_GET['filesystem_details']['method']
206
+ );
207
+
208
+ // check whether the credentials can be used
209
+ if ( ! WP_Filesystem( $_credentials ) ) {
210
+ return $credentials;
211
+ }
212
+
213
+ return $_credentials;
214
+ }
215
+ add_filter( 'request_filesystem_credentials', '_wpr_set_filesystem_credentials' );
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: humanmade, joehoyle, mattheu, tcrsavage, willmot
3
  Tags: wpremote, remote administration, multiple wordpress
4
  Requires at least: 2.9
5
- Tested up to: 3.4.1
6
- Stable tag: 2.2.5
7
 
8
  WP Remote is a free web app that enables you to easily manage all of your WordPress powered sites from one place.
9
 
@@ -31,7 +31,13 @@ You can email us at support@wpremote.com for support.
31
 
32
  == Changelog ==
33
 
 
 
 
 
 
34
  #### 2.2.5
 
35
  * Implemented API call for Core updates
36
 
37
  #### 2.2.4
2
  Contributors: humanmade, joehoyle, mattheu, tcrsavage, willmot
3
  Tags: wpremote, remote administration, multiple wordpress
4
  Requires at least: 2.9
5
+ Tested up to: 3.5
6
+ Stable tag: 2.3
7
 
8
  WP Remote is a free web app that enables you to easily manage all of your WordPress powered sites from one place.
9
 
31
 
32
  == Changelog ==
33
 
34
+ #### 2.3
35
+
36
+ * WP_Filesystem support for servers which don't allow PHP direct filesystem access.
37
+ * Support for monitoring and updating Gravity Forms.
38
+
39
  #### 2.2.5
40
+
41
  * Implemented API call for Core updates
42
 
43
  #### 2.2.4
wprp.api.php CHANGED
@@ -28,15 +28,30 @@ foreach( $actions as $action => $value ) {
28
  case 'get_plugin_version' :
29
 
30
  $actions[$action] = '1.1';
31
-
32
  break;
33
-
34
  case 'get_filesystem_method' :
35
 
36
  $actions[$action] = get_filesystem_method();
37
-
38
  break;
39
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  case 'get_wp_version' :
41
 
42
  global $wp_version;
@@ -62,13 +77,13 @@ foreach( $actions as $action => $value ) {
62
  $actions[$action] = _wprp_upgrade_plugin( (string) $_GET['plugin'] );
63
 
64
  break;
65
-
66
  case 'activate_plugin' :
67
-
68
  $actions[$action] = _wprp_activate_plugin( (string) $_GET['plugin'] );
69
-
70
  break;
71
-
72
  case 'get_themes' :
73
 
74
  $actions[$action] = _wprp_supports_theme_upgrade() ? _wprp_get_themes() : 'not-implemented';
@@ -85,31 +100,32 @@ foreach( $actions as $action => $value ) {
85
  case 'delete_backup' :
86
  case 'supports_backups' :
87
  case 'get_backup' :
88
-
89
  $actions[$action] = _wprp_backups_api_call( $action );
90
 
91
  break;
92
-
93
  // get site info
94
  case 'get_site_info' :
95
-
96
- $actions[$action] = array(
97
- 'site_url' => get_site_url(),
98
- 'home_url' => get_home_url(),
99
  'admin_url' => get_admin_url(),
100
- 'backups' => _wprp_get_backups_info()
101
  );
102
-
103
  break;
104
 
105
  default :
106
 
107
  $actions[$action] = 'not-implemented';
108
-
109
  break;
110
 
111
  }
112
 
113
  }
 
114
  echo json_encode( $actions );
115
  exit;
28
  case 'get_plugin_version' :
29
 
30
  $actions[$action] = '1.1';
31
+
32
  break;
33
+
34
  case 'get_filesystem_method' :
35
 
36
  $actions[$action] = get_filesystem_method();
37
+
38
  break;
39
+
40
+ case 'get_supported_filesystem_methods' :
41
+
42
+ $actions[$action] = array();
43
+
44
+ if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') )
45
+ $actions[$action][] = 'ftp';
46
+
47
+ if ( extension_loaded('ftp') )
48
+ $actions[$action][] = 'ftps';
49
+
50
+ if ( extension_loaded('ssh2') && function_exists('stream_get_contents') )
51
+ $actions[$action][] = 'ssh';
52
+
53
+ break;
54
+
55
  case 'get_wp_version' :
56
 
57
  global $wp_version;
77
  $actions[$action] = _wprp_upgrade_plugin( (string) $_GET['plugin'] );
78
 
79
  break;
80
+
81
  case 'activate_plugin' :
82
+
83
  $actions[$action] = _wprp_activate_plugin( (string) $_GET['plugin'] );
84
+
85
  break;
86
+
87
  case 'get_themes' :
88
 
89
  $actions[$action] = _wprp_supports_theme_upgrade() ? _wprp_get_themes() : 'not-implemented';
100
  case 'delete_backup' :
101
  case 'supports_backups' :
102
  case 'get_backup' :
103
+
104
  $actions[$action] = _wprp_backups_api_call( $action );
105
 
106
  break;
107
+
108
  // get site info
109
  case 'get_site_info' :
110
+
111
+ $actions[$action] = array(
112
+ 'site_url' => get_site_url(),
113
+ 'home_url' => get_home_url(),
114
  'admin_url' => get_admin_url(),
115
+ 'backups' => _wprp_get_backups_info()
116
  );
117
+
118
  break;
119
 
120
  default :
121
 
122
  $actions[$action] = 'not-implemented';
123
+
124
  break;
125
 
126
  }
127
 
128
  }
129
+
130
  echo json_encode( $actions );
131
  exit;
wprp.plugins.php CHANGED
@@ -9,19 +9,21 @@ function _wprp_get_plugins() {
9
 
10
  require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
11
 
 
 
12
  // Get all plugins
13
  $plugins = get_plugins();
14
 
15
  // Get the list of active plugins
16
  $active = get_option( 'active_plugins', array() );
17
-
18
  // Delete the transient so wp_update_plugins can get fresh data
19
  if ( function_exists( 'get_site_transient' ) )
20
  delete_site_transient( 'update_plugins' );
21
-
22
  else
23
  delete_transient( 'update_plugins' );
24
-
25
  // Force a plugin update check
26
  wp_update_plugins();
27
 
@@ -38,7 +40,7 @@ function _wprp_get_plugins() {
38
 
39
  foreach ( (array) $plugins as $plugin_file => $plugin ) {
40
 
41
- $new_version = isset( $current->response[$plugin_file] ) ? $current->response[$plugin_file]->new_version : null;
42
 
43
  if ( is_plugin_active( $plugin_file ) )
44
  $plugins[$plugin_file]['active'] = true;
@@ -75,6 +77,12 @@ function _wprp_upgrade_plugin( $plugin ) {
75
  if ( ! _wprp_supports_plugin_upgrade() )
76
  return array( 'status' => 'error', 'error' => 'WordPress version too old for plugin upgrades' );
77
 
 
 
 
 
 
 
78
  $skin = new WPRP_Plugin_Upgrader_Skin();
79
  $upgrader = new Plugin_Upgrader( $skin );
80
  $is_active = is_plugin_active( $plugin );
@@ -99,7 +107,7 @@ function _wprp_upgrade_plugin( $plugin ) {
99
 
100
  // If the plugin was activited, we have to re-activate it
101
  if ( $is_active ) {
102
-
103
  // we can not use the "normal" way or lazy activating, as thet requires wpremote to be activated
104
  if ( strpos( $plugin, 'wpremote' ) !== false ) {
105
  activate_plugin( $plugin, '', false, true );
@@ -107,28 +115,28 @@ function _wprp_upgrade_plugin( $plugin ) {
107
  }
108
 
109
 
110
- // we do a remote request to activate, as we don;t want to kill any installs
111
  $url = add_query_arg( 'wpr_api_key', $_GET['wpr_api_key'], get_bloginfo( 'url' ) );
112
  $url = add_query_arg( 'actions', 'activate_plugin', $url );
113
  $url = add_query_arg( 'plugin', $plugin, $url );
114
-
115
  $request = wp_remote_get( $url );
116
 
117
  if ( is_wp_error( $request ) ) {
118
  return array( 'status' => 'error', 'error' => $request->get_error_code() );
119
  }
120
-
121
  $body = wp_remote_retrieve_body( $request );
122
-
123
-
124
  if ( ! $json = @json_decode( $body ) )
125
  return array( 'status' => 'error', 'error' => 'The plugin was updated, but failed to re-activate.' );
126
-
127
  $json = $json->activate_plugin;
128
-
129
  if ( empty( $json->status ) )
130
  return array( 'status' => 'error', 'error' => 'The plugin was updated, but failed to re-activate. The activation reuest returned no response' );
131
-
132
  if ( $json->status != 'success' )
133
  return array( 'status' => 'error', 'error' => 'The plugin was updated, but failed to re-activate. The activation reuest returned response: ' . $json->status );
134
  }
@@ -137,14 +145,14 @@ function _wprp_upgrade_plugin( $plugin ) {
137
  }
138
 
139
  function _wprp_activate_plugin( $plugin ) {
140
-
141
  include_once ABSPATH . 'wp-admin/includes/plugin.php';
142
 
143
  $result = activate_plugin( $plugin );
144
 
145
  if ( is_wp_error( $result ) )
146
  return array( 'status' => 'error', 'error' => $result->get_error_code() );
147
-
148
  return array( 'status' => 'success' );
149
  }
150
 
@@ -161,4 +169,45 @@ function _wprp_supports_plugin_upgrade() {
161
 
162
  return class_exists( 'Plugin_Upgrader' );
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  }
9
 
10
  require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
11
 
12
+ _wpr_add_non_extend_plugin_support();
13
+
14
  // Get all plugins
15
  $plugins = get_plugins();
16
 
17
  // Get the list of active plugins
18
  $active = get_option( 'active_plugins', array() );
19
+
20
  // Delete the transient so wp_update_plugins can get fresh data
21
  if ( function_exists( 'get_site_transient' ) )
22
  delete_site_transient( 'update_plugins' );
23
+
24
  else
25
  delete_transient( 'update_plugins' );
26
+
27
  // Force a plugin update check
28
  wp_update_plugins();
29
 
40
 
41
  foreach ( (array) $plugins as $plugin_file => $plugin ) {
42
 
43
+ $new_version = isset( $current->response[$plugin_file] ) ? $current->response[$plugin_file]->new_version : null;
44
 
45
  if ( is_plugin_active( $plugin_file ) )
46
  $plugins[$plugin_file]['active'] = true;
77
  if ( ! _wprp_supports_plugin_upgrade() )
78
  return array( 'status' => 'error', 'error' => 'WordPress version too old for plugin upgrades' );
79
 
80
+ _wpr_add_non_extend_plugin_support();
81
+
82
+ // check for filesystem access
83
+ if ( ! _wpr_check_filesystem_access() )
84
+ return array( 'status' => 'error', 'error' => 'The filesystem is not writable with the supplied credentials' );
85
+
86
  $skin = new WPRP_Plugin_Upgrader_Skin();
87
  $upgrader = new Plugin_Upgrader( $skin );
88
  $is_active = is_plugin_active( $plugin );
107
 
108
  // If the plugin was activited, we have to re-activate it
109
  if ( $is_active ) {
110
+
111
  // we can not use the "normal" way or lazy activating, as thet requires wpremote to be activated
112
  if ( strpos( $plugin, 'wpremote' ) !== false ) {
113
  activate_plugin( $plugin, '', false, true );
115
  }
116
 
117
 
118
+ // we do a remote request to activate, as we don;t want to kill any installs
119
  $url = add_query_arg( 'wpr_api_key', $_GET['wpr_api_key'], get_bloginfo( 'url' ) );
120
  $url = add_query_arg( 'actions', 'activate_plugin', $url );
121
  $url = add_query_arg( 'plugin', $plugin, $url );
122
+
123
  $request = wp_remote_get( $url );
124
 
125
  if ( is_wp_error( $request ) ) {
126
  return array( 'status' => 'error', 'error' => $request->get_error_code() );
127
  }
128
+
129
  $body = wp_remote_retrieve_body( $request );
130
+
131
+
132
  if ( ! $json = @json_decode( $body ) )
133
  return array( 'status' => 'error', 'error' => 'The plugin was updated, but failed to re-activate.' );
134
+
135
  $json = $json->activate_plugin;
136
+
137
  if ( empty( $json->status ) )
138
  return array( 'status' => 'error', 'error' => 'The plugin was updated, but failed to re-activate. The activation reuest returned no response' );
139
+
140
  if ( $json->status != 'success' )
141
  return array( 'status' => 'error', 'error' => 'The plugin was updated, but failed to re-activate. The activation reuest returned response: ' . $json->status );
142
  }
145
  }
146
 
147
  function _wprp_activate_plugin( $plugin ) {
148
+
149
  include_once ABSPATH . 'wp-admin/includes/plugin.php';
150
 
151
  $result = activate_plugin( $plugin );
152
 
153
  if ( is_wp_error( $result ) )
154
  return array( 'status' => 'error', 'error' => $result->get_error_code() );
155
+
156
  return array( 'status' => 'success' );
157
  }
158
 
169
 
170
  return class_exists( 'Plugin_Upgrader' );
171
 
172
+ }
173
+
174
+ function _wpr_add_non_extend_plugin_support() {
175
+
176
+ add_filter( 'pre_set_site_transient_update_plugins', function( $value ) {
177
+
178
+ foreach( $non_extend_list = _wprp_get_non_extend_plugins_data() as $key => $anon_function ) {
179
+
180
+ if ( ( $returned = $non_extend_list[$key]() ) )
181
+ $value->response[$returned->plugin_location] = $returned;
182
+ }
183
+
184
+ return $value;
185
+
186
+ } );
187
+ }
188
+
189
+ function _wprp_get_non_extend_plugins_data() {
190
+
191
+ return array(
192
+ 'gravity_forms' => function() {
193
+
194
+ if ( ! class_exists('GFCommon') || ! method_exists( 'GFCommon', 'get_version_info' ) || ! method_exists( 'RGForms', 'premium_update_push' ) )
195
+ return false;
196
+
197
+ $version_data = GFCommon::get_version_info();
198
+ $plugin_data = reset( RGForms::premium_update_push( array() ) );
199
+
200
+ if ( empty( $version_data['url'] ) || empty( $version_data['is_valid_key'] ) || empty( $plugin_data['new_version'] ) || empty( $plugin_data['PluginURI'] ) || empty( $plugin_data['slug'] ) )
201
+ return false;
202
+
203
+ return (object) array(
204
+ 'plugin_location' => $plugin_data['slug'], //Not in standard structure but don't forget to include it!
205
+ 'id' => 999999999,
206
+ 'slug' => 'gravityforms',
207
+ 'url' => $plugin_data['PluginURI'],
208
+ 'package' => $version_data['url'],
209
+ 'new_version' => $version_data['version']
210
+ );
211
+ }
212
+ );
213
  }
wprp.themes.php CHANGED
@@ -92,6 +92,10 @@ function _wprp_upgrade_theme( $theme ) {
92
  if ( ! _wprp_supports_theme_upgrade() )
93
  return array( 'status' => 'error', 'error' => 'WordPress version too old for theme upgrades' );
94
 
 
 
 
 
95
  $skin = new WPRP_Theme_Upgrader_Skin();
96
  $upgrader = new Theme_Upgrader( $skin );
97
 
92
  if ( ! _wprp_supports_theme_upgrade() )
93
  return array( 'status' => 'error', 'error' => 'WordPress version too old for theme upgrades' );
94
 
95
+ // check for filesystem access
96
+ if ( ! _wpr_check_filesystem_access() )
97
+ return array( 'status' => 'error', 'error' => 'The filesystem is not writable with the supplied credentials' );
98
+
99
  $skin = new WPRP_Theme_Upgrader_Skin();
100
  $upgrader = new Theme_Upgrader( $skin );
101