Version Description
Download this release
Release Info
Developer | willmot |
Plugin | The WP Remote WordPress Plugin |
Version | 0.5 |
Comparing to | |
See all releases |
Code changes from version 0.4 to 0.5
- plugin.php +26 -1
- readme.txt +2 -2
- wpr.admin.php +0 -0
- wpr.api.php +51 -5
plugin.php
CHANGED
@@ -3,12 +3,14 @@
|
|
3 |
/*
|
4 |
Plugin Name: WP Remote
|
5 |
Description: Extends the functionality of <a href="http://www.wpremote.com">WP Remote</a>.
|
6 |
-
Version: 0.
|
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 |
|
@@ -23,3 +25,26 @@ function wpr_catch_api_call() {
|
|
23 |
}
|
24 |
add_action( 'init', 'wpr_catch_api_call', 1 );
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
/*
|
4 |
Plugin Name: WP Remote
|
5 |
Description: Extends the functionality of <a href="http://www.wpremote.com">WP Remote</a>.
|
6 |
+
Version: 0.5
|
7 |
Author: willmot
|
8 |
Author URI: http://humanmade.co.uk/
|
9 |
*/
|
10 |
|
11 |
require_once( 'wpr.admin.php' );
|
12 |
+
include_once ( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
|
13 |
+
|
14 |
|
15 |
function wpr_catch_api_call() {
|
16 |
|
25 |
}
|
26 |
add_action( 'init', 'wpr_catch_api_call', 1 );
|
27 |
|
28 |
+
|
29 |
+
class WPR_Upgrader_Skin extends Plugin_Installer_Skin {
|
30 |
+
var $feedback;
|
31 |
+
var $error;
|
32 |
+
function error( $error ) {
|
33 |
+
$this->error = $error;
|
34 |
+
}
|
35 |
+
function feedback( $feedback ) {
|
36 |
+
$this->feedback = $feedback;
|
37 |
+
}
|
38 |
+
function before() {
|
39 |
+
|
40 |
+
}
|
41 |
+
function after() {
|
42 |
+
|
43 |
+
}
|
44 |
+
function header() {
|
45 |
+
|
46 |
+
}
|
47 |
+
function footer() {
|
48 |
+
|
49 |
+
}
|
50 |
+
}
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: willmot, joehoyle
|
3 |
Tags: wpremote, remote, xmlrpc
|
4 |
Requires at least: 2.7
|
5 |
-
Tested up to: 3.0
|
6 |
-
Stable tag: 0.
|
7 |
|
8 |
Adds extra functionality for use with WP Remote
|
9 |
|
2 |
Contributors: willmot, joehoyle
|
3 |
Tags: wpremote, remote, xmlrpc
|
4 |
Requires at least: 2.7
|
5 |
+
Tested up to: 3.0.4
|
6 |
+
Stable tag: 0.5
|
7 |
|
8 |
Adds extra functionality for use with WP Remote
|
9 |
|
wpr.admin.php
CHANGED
File without changes
|
wpr.api.php
CHANGED
@@ -27,7 +27,11 @@ foreach( $actions as $action => $value ) :
|
|
27 |
break;
|
28 |
|
29 |
case 'get_plugins' :
|
30 |
-
$actions[$action] = _wpr_get_plugins();
|
|
|
|
|
|
|
|
|
31 |
break;
|
32 |
|
33 |
default :
|
@@ -38,14 +42,17 @@ foreach( $actions as $action => $value ) :
|
|
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' );
|
@@ -54,7 +61,7 @@ function _wpr_get_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;
|
@@ -64,10 +71,49 @@ function _wpr_get_plugins() {
|
|
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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
break;
|
28 |
|
29 |
case 'get_plugins' :
|
30 |
+
$actions[$action] = _wpr_supports_plugin_upgrade() ? _wpr_get_plugins() : 'not-implemented';
|
31 |
+
break;
|
32 |
+
|
33 |
+
case 'upgrade_plugin' :
|
34 |
+
$actions[$action] = _wpr_upgrade_plugin( (string) $_GET['plugin'] );
|
35 |
break;
|
36 |
|
37 |
default :
|
42 |
endforeach;
|
43 |
|
44 |
echo json_encode( $actions );
|
45 |
+
exit;
|
46 |
// functions
|
47 |
|
48 |
function _wpr_get_plugins() {
|
49 |
|
50 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
51 |
|
52 |
+
$plugins = get_plugins();
|
53 |
+
$active = get_option( 'active_plugins', array() );
|
54 |
+
|
55 |
+
wp_update_plugins();
|
56 |
|
57 |
if( function_exists( 'get_site_transient' ) )
|
58 |
$current = get_site_transient( 'update_plugins' );
|
61 |
|
62 |
foreach ( (array) $plugins as $plugin_file => $plugin ) {
|
63 |
|
64 |
+
$new_version = isset( $current->response[$plugin_file] ) ? $current->response[$plugin_file]->new_version : null;
|
65 |
|
66 |
if ( is_plugin_active( $plugin_file ) ) {
|
67 |
$plugins[$plugin_file]['active'] = true;
|
71 |
|
72 |
if ( $new_version ) {
|
73 |
$plugins[$plugin_file]['latest_version'] = $new_version;
|
74 |
+
$plugins[$plugin_file]['latest_package'] = $current->response[$plugin_file]->package;
|
75 |
+
$plugins[$plugin_file]['slug'] = $current->response[$plugin_file]->slug;
|
76 |
} else {
|
77 |
$plugins[$plugin_file]['latest_version'] = $plugin['Version'];
|
78 |
}
|
79 |
}
|
80 |
+
|
81 |
+
global $wp_version;
|
82 |
+
$plugins_args = (object) compact( 'plugins' );
|
83 |
+
|
84 |
|
85 |
return $plugins;
|
86 |
+
}
|
87 |
+
|
88 |
+
function _wpr_upgrade_plugin( $plugin ) {
|
89 |
+
|
90 |
+
include_once ( ABSPATH . 'wp-admin/includes/admin.php' );
|
91 |
+
|
92 |
+
if( !class_exists( 'Plugin_Upgrader' ) )
|
93 |
+
return array( 'status' => 'error', 'error' => 'WordPress version too old for plugin upgrades' );
|
94 |
+
|
95 |
+
$skin = new WPR_Upgrader_Skin();
|
96 |
+
$upgrader = new Plugin_Upgrader( $skin );
|
97 |
+
|
98 |
+
ob_start();
|
99 |
+
$result = $upgrader->upgrade( $plugin );
|
100 |
+
$data = ob_get_contents();
|
101 |
+
ob_clean();
|
102 |
+
|
103 |
+
if( ( !$result && !is_null( $result ) ) || $data )
|
104 |
+
return array( 'status' => 'error', 'error' => 'file_permissions_error' );
|
105 |
+
|
106 |
+
elseif( is_wp_error( $result ) )
|
107 |
+
return array( 'status' => 'error', 'error' => $result->get_error_code() );
|
108 |
+
|
109 |
+
if( $skin->error )
|
110 |
+
return array( 'status' => 'error', 'error' => $skin->error );
|
111 |
+
|
112 |
+
return array( 'status' => 'success' );
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
function _wpr_supports_plugin_upgrade() {
|
117 |
+
return class_exists( 'Plugin_Upgrader' );
|
118 |
+
|
119 |
+
}
|