The WP Remote WordPress Plugin - Version 0.4

Version Description

Download this release

Release Info

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

Code changes from version 0.3 to 0.4

plugin.php CHANGED
@@ -3,12 +3,23 @@
3
  /*
4
  Plugin Name: WP Remote
5
  Description: Extends the functionality of <a href="http://www.wpremote.com">WP Remote</a>.
6
- Version: 0.3
7
  Author: willmot
8
  Author URI: http://humanmade.co.uk/
9
  */
10
 
11
- require_once( 'wpr.extend-xmlrpc.php' );
12
- require_once( 'wpr.plugin.php' );
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- tj_add_rewrite_rule( 'wpremote-api', null, dirname( __FILE__ ) . '/wpr.api.php' );
3
  /*
4
  Plugin Name: WP Remote
5
  Description: Extends the functionality of <a href="http://www.wpremote.com">WP Remote</a>.
6
+ Version: 0.4
7
  Author: willmot
8
  Author URI: http://humanmade.co.uk/
9
  */
10
 
11
+ require_once( 'wpr.admin.php' );
12
+
13
+ function wpr_catch_api_call() {
14
+
15
+ if( !urldecode( $_GET['wpr_api_key'] ) || !isset( $_GET['actions'] ) ) {
16
+ return;
17
+ }
18
+
19
+ require_once( 'wpr.api.php' );
20
+
21
+ exit;
22
+
23
+ }
24
+ add_action( 'init', 'wpr_catch_api_call', 1 );
25
 
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: willmot, joehoyle
3
  Tags: wpremote, remote, xmlrpc
4
  Requires at least: 2.7
5
  Tested up to: 3.0
6
- Stable tag: 0.3
7
 
8
  Adds extra functionality for use with WP Remote
9
 
3
  Tags: wpremote, remote, xmlrpc
4
  Requires at least: 2.7
5
  Tested up to: 3.0
6
+ Stable tag: 0.4
7
 
8
  Adds extra functionality for use with WP Remote
9
 
wpr.plugin.php → wpr.admin.php RENAMED
File without changes
wpr.api.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- if( !urlencode( $_GET['api_key'] ) || urlencode( $_GET['api_key'] ) !== get_option( 'wpr_api_key' ) || !isset( $_GET['actions'] ) ) {
4
  echo json_encode( 'bad-api-key' );
5
  exit;
6
  }
@@ -37,4 +37,37 @@ foreach( $actions as $action => $value ) :
37
 
38
  endforeach;
39
 
40
- echo json_encode( $actions );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
+ if( !isset( $_GET['wpr_api_key'] ) || urldecode( $_GET['wpr_api_key'] ) !== get_option( 'wpr_api_key' ) || !isset( $_GET['actions'] ) ) {
4
  echo json_encode( 'bad-api-key' );
5
  exit;
6
  }
37
 
38
  endforeach;
39
 
40
+ echo json_encode( $actions );
41
+
42
+ // functions
43
+
44
+ function _wpr_get_plugins() {
45
+
46
+ require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
47
+
48
+ $plugins = get_plugins( );
49
+
50
+ if( function_exists( 'get_site_transient' ) )
51
+ $current = get_site_transient( 'update_plugins' );
52
+ else
53
+ $current = get_transient( 'update_plugins' );
54
+
55
+ foreach ( (array) $plugins as $plugin_file => $plugin ) {
56
+
57
+ $new_version = $current->response[$plugin_file]->new_version;
58
+
59
+ if ( is_plugin_active( $plugin_file ) ) {
60
+ $plugins[$plugin_file]['active'] = true;
61
+ } else {
62
+ $plugins[$plugin_file]['active'] = false;
63
+ }
64
+
65
+ if ( $new_version ) {
66
+ $plugins[$plugin_file]['latest_version'] = $new_version;
67
+ } else {
68
+ $plugins[$plugin_file]['latest_version'] = $plugin['Version'];
69
+ }
70
+ }
71
+
72
+ return $plugins;
73
+ }
wpr.extend-xmlrpc.php DELETED
@@ -1,74 +0,0 @@
1
- <?php
2
-
3
- function wpr_attach_new_xmlrpc($methods) {
4
-
5
- if( !isset( $methods['wp.getPluginList'] ) ) {
6
- $methods['wp.getPluginList'] = 'wpr_get_plugin_list';
7
- }
8
-
9
- return $methods;
10
- }
11
-
12
- add_action('xmlrpc_methods', 'wpr_attach_new_xmlrpc');
13
-
14
- function wpr_get_plugin_list( $args ) {
15
-
16
- $blog_id = (int) $args[0];
17
- $username = $args[1];
18
- $password = $args[2];
19
-
20
- //check if xmlrpc is enabled
21
- if ( !get_option( 'enable_xmlrpc' ) ) {
22
- return new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this blog. An admin user can enable them at %s'), admin_url('options-writing.php') ) );
23
- }
24
-
25
- //authenticate the user
26
- $user = wp_authenticate($username, $password);
27
-
28
- if (is_wp_error($user)) {
29
- return new IXR_Error(403, __('Bad login/pass combination.'));
30
- }
31
-
32
- set_current_user( $user->ID );
33
-
34
- //don't allow anyone to get them via xml rpc
35
- if ( !current_user_can( 'activate_plugins' ) ) {
36
- return new IXR_Error( 401, __( 'Sorry, you cannot manage plugins.' ) );
37
- }
38
-
39
- do_action( 'xmlrpc_call', 'wp.getPluginList' );
40
-
41
- return _wpr_get_plugins();
42
-
43
- }
44
-
45
- function _wpr_get_plugins() {
46
-
47
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
48
-
49
- $plugins = get_plugins( );
50
-
51
- if( function_exists( 'get_site_transient' ) )
52
- $current = get_site_transient( 'update_plugins' );
53
- else
54
- $current = get_transient( 'update_plugins' );
55
-
56
- foreach ( (array) $plugins as $plugin_file => $plugin ) {
57
-
58
- $new_version = $current->response[$plugin_file]->new_version;
59
-
60
- if ( is_plugin_active( $plugin_file ) ) {
61
- $plugins[$plugin_file]['active'] = true;
62
- } else {
63
- $plugins[$plugin_file]['active'] = false;
64
- }
65
-
66
- if ( $new_version ) {
67
- $plugins[$plugin_file]['latest_version'] = $new_version;
68
- } else {
69
- $plugins[$plugin_file]['latest_version'] = $plugin['Version'];
70
- }
71
- }
72
-
73
- return $plugins;
74
- }