Version Description
Download this release
Release Info
Developer | danielbachhuber |
Plugin | The WP Remote WordPress Plugin |
Version | 2.6.1 |
Comparing to | |
See all releases |
Code changes from version 2.6 to 2.6.1
- .travis.yml +27 -0
- bin/install-wp-tests.sh +32 -0
- inc/class-wprp-core-upgrader-skin.php +23 -0
- inc/class-wprp-plugin-upgrader-skin.php +23 -0
- inc/class-wprp-theme-upgrader-skin.php +24 -0
- languages/index.php +6 -0
- languages/wp-remote-wordpress-plugin.mo +0 -0
- languages/wp-remote-wordpress-plugin.pot +148 -0
- phpunit.xml +14 -0
- plugin.php +68 -69
- readme.txt +12 -4
- tests/bootstrap.php +10 -0
- tests/pluginsTest.php +11 -0
- wprp.admin.php +11 -5
- wprp.api.php +61 -10
- wprp.backups.php +18 -17
- wprp.compatability.php +14 -13
- wprp.hm.backup.php +65 -57
- wprp.plugins.php +98 -4
- wprp.themes.php +113 -19
.travis.yml
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
language: php
|
2 |
+
|
3 |
+
php:
|
4 |
+
- 5.2
|
5 |
+
- 5.3
|
6 |
+
- 5.4
|
7 |
+
|
8 |
+
env:
|
9 |
+
- WP_VERSION=master WP_MULTISITE=0
|
10 |
+
- WP_VERSION=master WP_MULTISITE=1
|
11 |
+
- WP_VERSION=3.5.1 WP_MULTISITE=0
|
12 |
+
- WP_VERSION=3.5.1 WP_MULTISITE=1
|
13 |
+
- WP_VERSION=3.4 WP_MULTISITE=0
|
14 |
+
- WP_VERSION=3.4 WP_MULTISITE=1
|
15 |
+
- WP_VERSION=3.3 WP_MULTISITE=0
|
16 |
+
- WP_VERSION=3.3 WP_MULTISITE=1
|
17 |
+
- WP_VERSION=3.2 WP_MULTISITE=0
|
18 |
+
- WP_VERSION=3.2 WP_MULTISITE=1
|
19 |
+
|
20 |
+
notifications:
|
21 |
+
hipchat: dd6fd66a04b2e8e8c8b2b1fc47f081@WP Remote
|
22 |
+
|
23 |
+
before_script:
|
24 |
+
- export WP_TESTS_DIR=/tmp/wordpress-tests/
|
25 |
+
- bash bin/install-wp-tests.sh wordpress_test root '' $WP_VERSION
|
26 |
+
|
27 |
+
script: phpunit
|
bin/install-wp-tests.sh
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
|
3 |
+
if [ $# -lt 3 ]; then
|
4 |
+
echo "usage: $0 <db-name> <db-user> <db-pass> [wp-version]"
|
5 |
+
exit 1
|
6 |
+
fi
|
7 |
+
|
8 |
+
DB_NAME=$1
|
9 |
+
DB_USER=$2
|
10 |
+
DB_PASS=$3
|
11 |
+
WP_VERSION=${4-master}
|
12 |
+
|
13 |
+
set -ex
|
14 |
+
|
15 |
+
# set up a WP install
|
16 |
+
WP_CORE_DIR=/tmp/wordpress/
|
17 |
+
mkdir -p $WP_CORE_DIR
|
18 |
+
wget -nv -O /tmp/wordpress.tar.gz https://github.com/WordPress/WordPress/tarball/$WP_VERSION
|
19 |
+
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
|
20 |
+
|
21 |
+
# set up testing suite
|
22 |
+
svn co --ignore-externals --quiet http://unit-tests.svn.wordpress.org/trunk/ $WP_TESTS_DIR
|
23 |
+
|
24 |
+
cd $WP_TESTS_DIR
|
25 |
+
cp wp-tests-config-sample.php wp-tests-config.php
|
26 |
+
sed -i "s:dirname( __FILE__ ) . '/wordpress/':'$WP_CORE_DIR':" wp-tests-config.php
|
27 |
+
sed -i "s/yourdbnamehere/$DB_NAME/" wp-tests-config.php
|
28 |
+
sed -i "s/yourusernamehere/$DB_USER/" wp-tests-config.php
|
29 |
+
sed -i "s/yourpasswordhere/$DB_PASS/" wp-tests-config.php
|
30 |
+
|
31 |
+
# create database
|
32 |
+
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"
|
inc/class-wprp-core-upgrader-skin.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WPRP_Core_Upgrader_Skin extends WP_Upgrader_Skin {
|
3 |
+
|
4 |
+
var $feedback;
|
5 |
+
var $error;
|
6 |
+
|
7 |
+
function error( $error ) {
|
8 |
+
$this->error = $error;
|
9 |
+
}
|
10 |
+
|
11 |
+
function feedback( $feedback ) {
|
12 |
+
$this->feedback = $feedback;
|
13 |
+
}
|
14 |
+
|
15 |
+
function before() { }
|
16 |
+
|
17 |
+
function after() { }
|
18 |
+
|
19 |
+
function header() { }
|
20 |
+
|
21 |
+
function footer() { }
|
22 |
+
|
23 |
+
}
|
inc/class-wprp-plugin-upgrader-skin.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WPRP_Plugin_Upgrader_Skin extends Plugin_Installer_Skin {
|
4 |
+
|
5 |
+
var $feedback;
|
6 |
+
var $error;
|
7 |
+
|
8 |
+
function error( $error ) {
|
9 |
+
$this->error = $error;
|
10 |
+
}
|
11 |
+
|
12 |
+
function feedback( $feedback ) {
|
13 |
+
$this->feedback = $feedback;
|
14 |
+
}
|
15 |
+
|
16 |
+
function before() { }
|
17 |
+
|
18 |
+
function after() { }
|
19 |
+
|
20 |
+
function header() { }
|
21 |
+
|
22 |
+
function footer() { }
|
23 |
+
}
|
inc/class-wprp-theme-upgrader-skin.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WPRP_Theme_Upgrader_Skin extends Theme_Installer_Skin {
|
4 |
+
|
5 |
+
var $feedback;
|
6 |
+
var $error;
|
7 |
+
|
8 |
+
function error( $error ) {
|
9 |
+
$this->error = $error;
|
10 |
+
}
|
11 |
+
|
12 |
+
function feedback( $feedback ) {
|
13 |
+
$this->feedback = $feedback;
|
14 |
+
}
|
15 |
+
|
16 |
+
function before() { }
|
17 |
+
|
18 |
+
function after() { }
|
19 |
+
|
20 |
+
function header() { }
|
21 |
+
|
22 |
+
function footer() { }
|
23 |
+
|
24 |
+
}
|
languages/index.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Do not put custom translations here. They will be deleted when you update the WP Remote plugin!
|
4 |
+
*
|
5 |
+
* Keep custom translations for WP Remote Plugin For WordPress in '/wp-content/languages/wpremote/'
|
6 |
+
*/
|
languages/wp-remote-wordpress-plugin.mo
ADDED
Binary file
|
languages/wp-remote-wordpress-plugin.pot
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2013 Human Made Limited
|
2 |
+
# This file is distributed under the same license as the WP Remote plugin.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: WP Remote 2.6.1-alpha\n"
|
6 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/tag/wp-remote-wordpress-plugin\n"
|
7 |
+
"POT-Creation-Date: 2013-08-23 17:33:58+00:00\n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2013-08-23 14:36-0300\n"
|
12 |
+
"Last-Translator: Human Made Limited <hello@hmn.md>\n"
|
13 |
+
"Language-Team: Human Made Limited <hello@hmn.md>\n"
|
14 |
+
"X-Generator: Poedit 1.5.7\n"
|
15 |
+
|
16 |
+
#: plugin.php:47
|
17 |
+
msgid "WP Remote requires PHP version 5.2.4 or greater."
|
18 |
+
msgstr ""
|
19 |
+
|
20 |
+
#: plugin.php:180
|
21 |
+
msgid "The filesystem is not writable with the supplied credentials"
|
22 |
+
msgstr ""
|
23 |
+
|
24 |
+
#: wprp.admin.php:29
|
25 |
+
msgid "WP Remote is almost ready"
|
26 |
+
msgstr ""
|
27 |
+
|
28 |
+
#: wprp.admin.php:29
|
29 |
+
msgid "enter your API key to continue"
|
30 |
+
msgstr ""
|
31 |
+
|
32 |
+
#: wprp.admin.php:33
|
33 |
+
msgid "Save API Key"
|
34 |
+
msgstr ""
|
35 |
+
|
36 |
+
#: wprp.admin.php:39
|
37 |
+
msgid "Don't have a WP Remote account yet?"
|
38 |
+
msgstr ""
|
39 |
+
|
40 |
+
#: wprp.admin.php:39
|
41 |
+
msgid "Sign up"
|
42 |
+
msgstr ""
|
43 |
+
|
44 |
+
#: wprp.admin.php:39
|
45 |
+
msgid "register your site, and report back once you've grabbed your API key."
|
46 |
+
msgstr ""
|
47 |
+
|
48 |
+
#: wprp.admin.php:71
|
49 |
+
msgid "WP Remote API Key successfully added"
|
50 |
+
msgstr ""
|
51 |
+
|
52 |
+
#: wprp.admin.php:71
|
53 |
+
msgid "WP Remote"
|
54 |
+
msgstr ""
|
55 |
+
|
56 |
+
#: wprp.backups.php:140
|
57 |
+
msgid "No backup was found"
|
58 |
+
msgstr ""
|
59 |
+
|
60 |
+
#: wprp.backups.php:190 wprp.backups.php:198
|
61 |
+
msgid "Calculating"
|
62 |
+
msgstr ""
|
63 |
+
|
64 |
+
#: wprp.backups.php:213
|
65 |
+
msgid "Dumping Database %s"
|
66 |
+
msgstr ""
|
67 |
+
|
68 |
+
#: wprp.backups.php:219
|
69 |
+
msgid "Verifying Database Dump %s"
|
70 |
+
msgstr ""
|
71 |
+
|
72 |
+
#: wprp.backups.php:225
|
73 |
+
msgid "Creating zip archive %s"
|
74 |
+
msgstr ""
|
75 |
+
|
76 |
+
#: wprp.backups.php:231
|
77 |
+
msgid "Verifying Zip Archive %s"
|
78 |
+
msgstr ""
|
79 |
+
|
80 |
+
#: wprp.backups.php:326
|
81 |
+
msgid ""
|
82 |
+
"This %s file ensures that other people cannot download your backup files."
|
83 |
+
msgstr ""
|
84 |
+
|
85 |
+
#: wprp.backups.php:335
|
86 |
+
msgid "WP Remote Backup"
|
87 |
+
msgstr ""
|
88 |
+
|
89 |
+
#: wprp.compatability.php:10
|
90 |
+
msgid "BulletProof Security"
|
91 |
+
msgstr ""
|
92 |
+
|
93 |
+
#: wprp.compatability.php:11
|
94 |
+
msgid "Wordfence Security"
|
95 |
+
msgstr ""
|
96 |
+
|
97 |
+
#: wprp.compatability.php:12
|
98 |
+
msgid "Better WP Security"
|
99 |
+
msgstr ""
|
100 |
+
|
101 |
+
#: wprp.compatability.php:13
|
102 |
+
msgid "Wordpress Firewall 2"
|
103 |
+
msgstr ""
|
104 |
+
|
105 |
+
#: wprp.compatability.php:48
|
106 |
+
msgid "Don't show again"
|
107 |
+
msgstr ""
|
108 |
+
|
109 |
+
#: wprp.compatability.php:52
|
110 |
+
msgid "The plugin"
|
111 |
+
msgstr ""
|
112 |
+
|
113 |
+
#: wprp.compatability.php:52
|
114 |
+
msgid "may cause issues with WP Remote."
|
115 |
+
msgstr ""
|
116 |
+
|
117 |
+
#: wprp.compatability.php:54
|
118 |
+
msgid "Click here for instructions on how to resolve this issue"
|
119 |
+
msgstr ""
|
120 |
+
|
121 |
+
#: wprp.hm.backup.php:289
|
122 |
+
msgid "archive filename must be a non empty string"
|
123 |
+
msgstr ""
|
124 |
+
|
125 |
+
#: wprp.hm.backup.php:292
|
126 |
+
msgid "invalid file extension for archive filename"
|
127 |
+
msgstr ""
|
128 |
+
|
129 |
+
#: wprp.hm.backup.php:334
|
130 |
+
msgid "database dump filename must be a non empty string"
|
131 |
+
msgstr ""
|
132 |
+
|
133 |
+
#: wprp.hm.backup.php:337
|
134 |
+
msgid "invalid file extension for database dump filename"
|
135 |
+
msgstr ""
|
136 |
+
|
137 |
+
#: wprp.hm.backup.php:370
|
138 |
+
msgid "Invalid root path %s must be a valid directory path"
|
139 |
+
msgstr ""
|
140 |
+
|
141 |
+
#: wprp.hm.backup.php:401
|
142 |
+
msgid "Invalid backup path %s must be a non empty (string)"
|
143 |
+
msgstr ""
|
144 |
+
|
145 |
+
#: wprp.hm.backup.php:456
|
146 |
+
msgid ""
|
147 |
+
"Invalid backup type %s must be one of (string) file, database or complete"
|
148 |
+
msgstr ""
|
phpunit.xml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<phpunit
|
2 |
+
bootstrap="tests/bootstrap.php"
|
3 |
+
backupGlobals="false"
|
4 |
+
colors="true"
|
5 |
+
convertErrorsToExceptions="true"
|
6 |
+
convertNoticesToExceptions="true"
|
7 |
+
convertWarningsToExceptions="true"
|
8 |
+
>
|
9 |
+
<testsuites>
|
10 |
+
<testsuite>
|
11 |
+
<directory>./tests/</directory>
|
12 |
+
</testsuite>
|
13 |
+
</testsuites>
|
14 |
+
</phpunit>
|
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>. <strong>Deactivate to clear your API Key.</strong>
|
6 |
-
Version: 2.6
|
7 |
Author: Human Made Limited
|
8 |
Author URI: http://hmn.md/
|
9 |
*/
|
@@ -28,9 +28,15 @@ Author URI: http://hmn.md/
|
|
28 |
define( 'WPRP_PLUGIN_SLUG', 'wpremote' );
|
29 |
define( 'WPRP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
|
30 |
|
|
|
|
|
|
|
31 |
if ( ! defined( 'WPR_API_URL' ) )
|
32 |
define( 'WPR_API_URL', 'https://wpremote.com/api/json/' );
|
33 |
|
|
|
|
|
|
|
34 |
// Don't activate on anything less than PHP 5.2.4
|
35 |
if ( version_compare( phpversion(), '5.2.4', '<' ) ) {
|
36 |
|
@@ -58,76 +64,28 @@ if ( empty( $_GET['action'] ) || $_GET['action'] != 'do-core-upgrade' ) :
|
|
58 |
|
59 |
require_once ( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
function error( $error ) {
|
67 |
-
$this->error = $error;
|
68 |
-
}
|
69 |
-
|
70 |
-
function feedback( $feedback ) {
|
71 |
-
$this->feedback = $feedback;
|
72 |
-
}
|
73 |
-
|
74 |
-
function before() { }
|
75 |
-
|
76 |
-
function after() { }
|
77 |
-
|
78 |
-
function header() { }
|
79 |
-
|
80 |
-
function footer() { }
|
81 |
-
|
82 |
-
}
|
83 |
-
|
84 |
-
class WPRP_Theme_Upgrader_Skin extends Theme_Installer_Skin {
|
85 |
-
|
86 |
-
var $feedback;
|
87 |
-
var $error;
|
88 |
-
|
89 |
-
function error( $error ) {
|
90 |
-
$this->error = $error;
|
91 |
-
}
|
92 |
-
|
93 |
-
function feedback( $feedback ) {
|
94 |
-
$this->feedback = $feedback;
|
95 |
-
}
|
96 |
-
|
97 |
-
function before() { }
|
98 |
-
|
99 |
-
function after() { }
|
100 |
-
|
101 |
-
function header() { }
|
102 |
-
|
103 |
-
function footer() { }
|
104 |
-
|
105 |
-
}
|
106 |
-
|
107 |
-
class WPRP_Core_Upgrader_Skin extends WP_Upgrader_Skin {
|
108 |
-
|
109 |
-
var $feedback;
|
110 |
-
var $error;
|
111 |
-
|
112 |
-
function error( $error ) {
|
113 |
-
$this->error = $error;
|
114 |
-
}
|
115 |
-
|
116 |
-
function feedback( $feedback ) {
|
117 |
-
$this->feedback = $feedback;
|
118 |
-
}
|
119 |
-
|
120 |
-
function before() { }
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
function header() { }
|
125 |
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
-
|
|
|
129 |
|
130 |
-
|
|
|
|
|
|
|
131 |
|
132 |
/**
|
133 |
* Catch the API calls and load the API
|
@@ -149,6 +107,19 @@ function wprp_catch_api_call() {
|
|
149 |
}
|
150 |
add_action( 'init', 'wprp_catch_api_call', 1 );
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
function wprp_plugin_update_check() {
|
153 |
|
154 |
$plugin_data = get_plugin_data( __FILE__ );
|
@@ -206,7 +177,7 @@ function _wprp_upgrade_core() {
|
|
206 |
|
207 |
// check for filesystem access
|
208 |
if ( ! _wpr_check_filesystem_access() )
|
209 |
-
return array( 'status' => 'error', 'error' => 'The filesystem is not writable with the supplied credentials' );
|
210 |
|
211 |
// force refresh
|
212 |
wp_version_check();
|
@@ -268,4 +239,32 @@ function _wpr_set_filesystem_credentials( $credentials ) {
|
|
268 |
|
269 |
return $_credentials;
|
270 |
}
|
271 |
-
add_filter( 'request_filesystem_credentials', '_wpr_set_filesystem_credentials' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
/*
|
4 |
Plugin Name: WP Remote
|
5 |
Description: Manage your WordPress site with <a href="https://wpremote.com/">WP Remote</a>. <strong>Deactivate to clear your API Key.</strong>
|
6 |
+
Version: 2.6.1
|
7 |
Author: Human Made Limited
|
8 |
Author URI: http://hmn.md/
|
9 |
*/
|
28 |
define( 'WPRP_PLUGIN_SLUG', 'wpremote' );
|
29 |
define( 'WPRP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
|
30 |
|
31 |
+
if ( ! defined( 'WPR_URL' ) )
|
32 |
+
define( 'WPR_URL', 'https://wpremote.com/' );
|
33 |
+
|
34 |
if ( ! defined( 'WPR_API_URL' ) )
|
35 |
define( 'WPR_API_URL', 'https://wpremote.com/api/json/' );
|
36 |
|
37 |
+
if ( ! defined( 'WPR_LANG_DIR' ) )
|
38 |
+
define( 'WPR_LANG_DIR', apply_filters( 'wpr_filter_lang_dir', trailingslashit( WPRP_PLUGIN_PATH ) . trailingslashit( 'languages' ) ) );
|
39 |
+
|
40 |
// Don't activate on anything less than PHP 5.2.4
|
41 |
if ( version_compare( phpversion(), '5.2.4', '<' ) ) {
|
42 |
|
64 |
|
65 |
require_once ( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
|
66 |
|
67 |
+
// Custom upgrader skins
|
68 |
+
require_once WPRP_PLUGIN_PATH . 'inc/class-wprp-plugin-upgrader-skin.php';
|
69 |
+
require_once WPRP_PLUGIN_PATH . 'inc/class-wprp-theme-upgrader-skin.php';
|
70 |
+
require_once WPRP_PLUGIN_PATH . 'inc/class-wprp-core-upgrader-skin.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
+
endif;
|
|
|
|
|
73 |
|
74 |
+
/**
|
75 |
+
* Get a needed URL on the WP Remote site
|
76 |
+
*
|
77 |
+
* @param string $uri URI for the URL (optional)
|
78 |
+
* @return string $url Fully-qualified URL to WP Remote
|
79 |
+
*/
|
80 |
+
function wprp_get_wpr_url( $uri = '' ) {
|
81 |
|
82 |
+
if ( empty( $uri ) )
|
83 |
+
return WPR_URL;
|
84 |
|
85 |
+
$url = rtrim( WPR_URL, '/' );
|
86 |
+
$uri = trim( $uri, '/' );
|
87 |
+
return $url . '/' . $uri . '/';
|
88 |
+
}
|
89 |
|
90 |
/**
|
91 |
* Catch the API calls and load the API
|
107 |
}
|
108 |
add_action( 'init', 'wprp_catch_api_call', 1 );
|
109 |
|
110 |
+
/**
|
111 |
+
* Get the stored WPR API key
|
112 |
+
*
|
113 |
+
* @return mixed
|
114 |
+
*/
|
115 |
+
function wprp_get_api_keys() {
|
116 |
+
$keys = apply_filters( 'wpr_api_keys', get_option( 'wpr_api_key' ) );
|
117 |
+
if ( ! empty( $keys ) )
|
118 |
+
return (array)$keys;
|
119 |
+
else
|
120 |
+
return array();
|
121 |
+
}
|
122 |
+
|
123 |
function wprp_plugin_update_check() {
|
124 |
|
125 |
$plugin_data = get_plugin_data( __FILE__ );
|
177 |
|
178 |
// check for filesystem access
|
179 |
if ( ! _wpr_check_filesystem_access() )
|
180 |
+
return array( 'status' => 'error', 'error' => __( 'The filesystem is not writable with the supplied credentials', 'wpremote' ) );
|
181 |
|
182 |
// force refresh
|
183 |
wp_version_check();
|
239 |
|
240 |
return $_credentials;
|
241 |
}
|
242 |
+
add_filter( 'request_filesystem_credentials', '_wpr_set_filesystem_credentials' );
|
243 |
+
|
244 |
+
/**
|
245 |
+
*
|
246 |
+
*/
|
247 |
+
function wprp_translations_init() {
|
248 |
+
|
249 |
+
if ( is_admin() ) {
|
250 |
+
|
251 |
+
/** Set unique textdomain string */
|
252 |
+
$wprp_textdomain = 'wpremote';
|
253 |
+
|
254 |
+
/** The 'plugin_locale' filter is also used by default in load_plugin_textdomain() */
|
255 |
+
$plugin_locale = apply_filters( 'plugin_locale', get_locale(), $wprp_textdomain );
|
256 |
+
|
257 |
+
/** Set filter for WordPress languages directory */
|
258 |
+
$wprp_wp_lang_dir = apply_filters(
|
259 |
+
'wprp_filter_wp_lang_dir',
|
260 |
+
trailingslashit( WP_LANG_DIR ) . trailingslashit( 'genesis-layout-extras' ) . $wprp_textdomain . '-' . $plugin_locale . '.mo'
|
261 |
+
);
|
262 |
+
|
263 |
+
/** Translations: First, look in WordPress' "languages" folder = custom & update-secure! */
|
264 |
+
load_textdomain( $wprp_textdomain, $wprp_wp_lang_dir );
|
265 |
+
|
266 |
+
/** Translations: Secondly, look in plugin's "languages" folder = default */
|
267 |
+
load_plugin_textdomain( $wprp_textdomain, FALSE, WPR_LANG_DIR );
|
268 |
+
}
|
269 |
+
}
|
270 |
+
add_action( 'plugins_loaded', 'wprp_translations_init' );
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== The WP Remote WordPress Plugin ===
|
2 |
-
Contributors: humanmade, joehoyle, mattheu,
|
3 |
Tags: wpremote, remote administration, multiple wordpress
|
4 |
-
Requires at least:
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 2.6
|
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,6 +31,14 @@ You can email us at support@wpremote.com for support.
|
|
31 |
|
32 |
== Changelog ==
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
#### 2.6
|
35 |
|
36 |
* Change to using better hmac style authentication
|
1 |
=== The WP Remote WordPress Plugin ===
|
2 |
+
Contributors: humanmade, willmot, joehoyle, danielbachhuber, mattheu, pauldewouters, cuvelier, tcrsavage
|
3 |
Tags: wpremote, remote administration, multiple wordpress
|
4 |
+
Requires at least: 3.0
|
5 |
+
Tested up to: 3.6
|
6 |
+
Stable tag: 2.6.1
|
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.6.1 (26 August 2013)
|
35 |
+
|
36 |
+
* Add multiple API keys to your WP Remote plugin with a `wpr_api_keys` filter if you'd like to use more than WP Remote account with the site.
|
37 |
+
* Plugin now supports localization. Please feel free to [submit your translation](http://translate.hmn.md/projects).
|
38 |
+
* Update `HM Backup` to v2.3
|
39 |
+
* Bug fix: Properly handle timestamp values in database backups.
|
40 |
+
* Bug fix: Use super randomized backup directories.
|
41 |
+
|
42 |
#### 2.6
|
43 |
|
44 |
* Change to using better hmac style authentication
|
tests/bootstrap.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once getenv( 'WP_TESTS_DIR' ) . '/includes/functions.php';
|
4 |
+
|
5 |
+
function _manually_load_plugin() {
|
6 |
+
require dirname( __FILE__ ) . '/../plugin.php';
|
7 |
+
}
|
8 |
+
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
|
9 |
+
|
10 |
+
require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php';
|
tests/pluginsTest.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
*/
|
5 |
+
class WPRemotePluginsTestCase extends WP_UnitTestCase {
|
6 |
+
|
7 |
+
function testGetPlugins() {
|
8 |
+
|
9 |
+
$this->assertTrue( function_exists( 'wprp_catch_api_call' ) );
|
10 |
+
}
|
11 |
+
}
|
wprp.admin.php
CHANGED
@@ -26,11 +26,17 @@ function wprp_add_api_key_admin_notice() { ?>
|
|
26 |
|
27 |
<p>
|
28 |
|
29 |
-
<strong
|
30 |
|
31 |
<input type="text" style="margin-left: 5px; margin-right: 5px; " class="code regular-text" id="wpr_api_key" name="wpr_api_key" />
|
32 |
|
33 |
-
<input type="submit" value="Save API Key" class="button-primary" />
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
</p>
|
36 |
|
@@ -48,7 +54,7 @@ function wprp_add_api_key_admin_notice() { ?>
|
|
48 |
|
49 |
<?php }
|
50 |
|
51 |
-
if ( !
|
52 |
add_action( 'admin_notices', 'wprp_add_api_key_admin_notice' );
|
53 |
|
54 |
/**
|
@@ -58,11 +64,11 @@ if ( ! get_option( 'wpr_api_key' ) )
|
|
58 |
*/
|
59 |
function wprp_api_key_added_admin_notice() {
|
60 |
|
61 |
-
if ( function_exists( 'get_current_screen' ) && get_current_screen()->base != 'plugins' || empty( $_GET['settings-updated'] ) || !
|
62 |
return; ?>
|
63 |
|
64 |
<div id="wprp-message" class="updated">
|
65 |
-
<p><strong
|
66 |
</div>
|
67 |
|
68 |
<?php }
|
26 |
|
27 |
<p>
|
28 |
|
29 |
+
<strong><?php _e( 'WP Remote is almost ready', 'wpremote' ); ?></strong>, <label style="vertical-align: baseline;" for="wpr_api_key"><?php _e( 'enter your API key to continue', 'wpremote' ); ?></label>
|
30 |
|
31 |
<input type="text" style="margin-left: 5px; margin-right: 5px; " class="code regular-text" id="wpr_api_key" name="wpr_api_key" />
|
32 |
|
33 |
+
<input type="submit" value="<?php _e( 'Save API Key','wpremote' ); ?>" class="button-primary" />
|
34 |
+
|
35 |
+
</p>
|
36 |
+
|
37 |
+
<p>
|
38 |
+
|
39 |
+
<strong><?php _e( 'Don\'t have a WP Remote account yet?','wpremote' ); ?></strong> <a href="<?php echo esc_url( wprp_get_wpr_url( '/register/' ) ); ?>" target="_blank"><?php _e( 'Sign up','wpremote' ); ?></a>, <?php _e( 'register your site, and report back once you\'ve grabbed your API key.','wpremote' ); ?>
|
40 |
|
41 |
</p>
|
42 |
|
54 |
|
55 |
<?php }
|
56 |
|
57 |
+
if ( ! wprp_get_api_keys() )
|
58 |
add_action( 'admin_notices', 'wprp_add_api_key_admin_notice' );
|
59 |
|
60 |
/**
|
64 |
*/
|
65 |
function wprp_api_key_added_admin_notice() {
|
66 |
|
67 |
+
if ( function_exists( 'get_current_screen' ) && get_current_screen()->base != 'plugins' || empty( $_GET['settings-updated'] ) || ! wprp_get_api_keys() )
|
68 |
return; ?>
|
69 |
|
70 |
<div id="wprp-message" class="updated">
|
71 |
+
<p><strong><?php _e( 'WP Remote API Key successfully added' ); ?></strong>, close this window to go back to <a href="<?php echo esc_url( wprp_get_wpr_url( '/app/' ) ); ?>"><?php _e( 'WP Remote','wpremote' ); ?></a>.</p>
|
72 |
</div>
|
73 |
|
74 |
<?php }
|
wprp.api.php
CHANGED
@@ -8,7 +8,7 @@ class WPR_API_Request {
|
|
8 |
static function verify_request() {
|
9 |
|
10 |
// Check the API Key
|
11 |
-
if ( !
|
12 |
|
13 |
echo json_encode( 'blank-api-key' );
|
14 |
exit;
|
@@ -18,9 +18,9 @@ class WPR_API_Request {
|
|
18 |
$verify = $_POST['wpr_verify_key'];
|
19 |
unset( $_POST['wpr_verify_key'] );
|
20 |
|
21 |
-
$hash = self::
|
22 |
|
23 |
-
if (
|
24 |
echo json_encode( 'bad-verify-key' );
|
25 |
exit;
|
26 |
}
|
@@ -42,10 +42,17 @@ class WPR_API_Request {
|
|
42 |
|
43 |
}
|
44 |
|
45 |
-
static function
|
46 |
|
47 |
-
$
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
}
|
51 |
|
@@ -58,7 +65,7 @@ class WPR_API_Request {
|
|
58 |
}
|
59 |
|
60 |
static function get_arg( $arg ) {
|
61 |
-
return self::$args[$arg];
|
62 |
}
|
63 |
}
|
64 |
|
@@ -128,9 +135,19 @@ foreach( WPR_API_Request::get_actions() as $action ) {
|
|
128 |
|
129 |
break;
|
130 |
|
|
|
131 |
case 'upgrade_plugin' :
|
132 |
|
133 |
-
$actions[$action] =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
break;
|
136 |
|
@@ -140,15 +157,49 @@ foreach( WPR_API_Request::get_actions() as $action ) {
|
|
140 |
|
141 |
break;
|
142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
case 'get_themes' :
|
144 |
|
145 |
$actions[$action] = _wprp_supports_theme_upgrade() ? _wprp_get_themes() : 'not-implemented';
|
146 |
|
147 |
break;
|
148 |
|
149 |
-
case '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
-
$actions[$action] =
|
152 |
|
153 |
break;
|
154 |
|
8 |
static function verify_request() {
|
9 |
|
10 |
// Check the API Key
|
11 |
+
if ( ! wprp_get_api_keys() ) {
|
12 |
|
13 |
echo json_encode( 'blank-api-key' );
|
14 |
exit;
|
18 |
$verify = $_POST['wpr_verify_key'];
|
19 |
unset( $_POST['wpr_verify_key'] );
|
20 |
|
21 |
+
$hash = self::generate_hashes( $_POST );
|
22 |
|
23 |
+
if ( ! in_array( $verify, $hash, true ) ) {
|
24 |
echo json_encode( 'bad-verify-key' );
|
25 |
exit;
|
26 |
}
|
42 |
|
43 |
}
|
44 |
|
45 |
+
static function generate_hashes( $vars ) {
|
46 |
|
47 |
+
$api_key = wprp_get_api_keys();
|
48 |
+
if ( ! $api_key )
|
49 |
+
return array();
|
50 |
+
|
51 |
+
$hashes = array();
|
52 |
+
foreach( $api_key as $key ) {
|
53 |
+
$hashes[] = hash_hmac( 'sha256', serialize( $vars ), $key );
|
54 |
+
}
|
55 |
+
return $hashes;
|
56 |
|
57 |
}
|
58 |
|
65 |
}
|
66 |
|
67 |
static function get_arg( $arg ) {
|
68 |
+
return ( isset( self::$args[$arg] ) ) ? self::$args[$arg] : '';
|
69 |
}
|
70 |
}
|
71 |
|
135 |
|
136 |
break;
|
137 |
|
138 |
+
case 'update_plugin' :
|
139 |
case 'upgrade_plugin' :
|
140 |
|
141 |
+
$actions[$action] = _wprp_update_plugin( (string) sanitize_text_field( WPR_API_Request::get_arg( 'plugin' ) ) );
|
142 |
+
|
143 |
+
break;
|
144 |
+
|
145 |
+
case 'install_plugin' :
|
146 |
+
|
147 |
+
$api_args = array(
|
148 |
+
'version' => sanitize_text_field( (string)WPR_API_Request::get_arg( 'version' ) ),
|
149 |
+
);
|
150 |
+
$actions[$action] = _wprp_install_plugin( (string) sanitize_text_field( WPR_API_Request::get_arg( 'plugin' ) ), $api_args );
|
151 |
|
152 |
break;
|
153 |
|
157 |
|
158 |
break;
|
159 |
|
160 |
+
case 'deactivate_plugin' :
|
161 |
+
|
162 |
+
$actions[$action] = _wprp_deactivate_plugin( (string) sanitize_text_field( WPR_API_Request::get_arg( 'plugin' ) ) );
|
163 |
+
|
164 |
+
break;
|
165 |
+
|
166 |
+
case 'uninstall_plugin' :
|
167 |
+
|
168 |
+
$actions[$action] = _wprp_uninstall_plugin( (string) sanitize_text_field( WPR_API_Request::get_arg( 'plugin' ) ) );
|
169 |
+
|
170 |
+
break;
|
171 |
+
|
172 |
case 'get_themes' :
|
173 |
|
174 |
$actions[$action] = _wprp_supports_theme_upgrade() ? _wprp_get_themes() : 'not-implemented';
|
175 |
|
176 |
break;
|
177 |
|
178 |
+
case 'install_theme':
|
179 |
+
|
180 |
+
$api_args = array(
|
181 |
+
'version' => sanitize_text_field( (string)WPR_API_Request::get_arg( 'version' ) ),
|
182 |
+
);
|
183 |
+
$actions[$action] = _wprp_install_theme( (string) sanitize_text_field( WPR_API_Request::get_arg( 'theme' ) ), $api_args );
|
184 |
+
|
185 |
+
break;
|
186 |
+
|
187 |
+
case 'activate_theme':
|
188 |
+
|
189 |
+
$actions[$action] = _wprp_activate_theme( (string) sanitize_text_field( WPR_API_Request::get_arg( 'theme' ) ), $api_args );
|
190 |
+
|
191 |
+
break;
|
192 |
+
|
193 |
+
case 'update_theme' :
|
194 |
+
case 'upgrade_theme' : // 'upgrade' is deprecated
|
195 |
+
|
196 |
+
$actions[$action] = _wprp_update_theme( (string) sanitize_text_field( WPR_API_Request::get_arg( 'theme' ) ) );
|
197 |
+
|
198 |
+
break;
|
199 |
+
|
200 |
+
case 'delete_theme':
|
201 |
|
202 |
+
$actions[$action] = _wprp_delete_theme( (string) sanitize_text_field( WPR_API_Request::get_arg( 'theme' ) ) );
|
203 |
|
204 |
break;
|
205 |
|
wprp.backups.php
CHANGED
@@ -85,8 +85,7 @@ class WPRP_Backups extends WPRP_HM_Backup {
|
|
85 |
|
86 |
/**
|
87 |
* Perform a backup of the site
|
88 |
-
*
|
89 |
-
* @return true|WP_Error
|
90 |
*/
|
91 |
public function do_backup() {
|
92 |
|
@@ -133,11 +132,11 @@ class WPRP_Backups extends WPRP_HM_Backup {
|
|
133 |
|
134 |
}
|
135 |
|
136 |
-
return str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $backup );
|
137 |
|
138 |
}
|
139 |
|
140 |
-
return new WP_Error( 'backup-failed', 'No backup was found' );
|
141 |
|
142 |
}
|
143 |
|
@@ -187,7 +186,7 @@ class WPRP_Backups extends WPRP_HM_Backup {
|
|
187 |
|
188 |
// Otherwise the filesize must still be calculating
|
189 |
else
|
190 |
-
return 'Calculating';
|
191 |
|
192 |
}
|
193 |
|
@@ -195,14 +194,14 @@ class WPRP_Backups extends WPRP_HM_Backup {
|
|
195 |
// it can take some time so we have a small timeout then return "Calculating"
|
196 |
wp_remote_get( add_query_arg( array( 'action' => 'wprp_calculate_backup_size', 'backup_excludes' => $this->get_excludes() ), admin_url( 'admin-ajax.php' ) ), array( 'timeout' => 0.1, 'sslverify' => false ) );
|
197 |
|
198 |
-
return 'Calculating';
|
199 |
|
200 |
}
|
201 |
|
202 |
/**
|
203 |
* Hook into the actions fired in HM Backup and set the status
|
204 |
*
|
205 |
-
* @
|
206 |
*/
|
207 |
protected function do_action( $action ) {
|
208 |
|
@@ -210,25 +209,25 @@ class WPRP_Backups extends WPRP_HM_Backup {
|
|
210 |
|
211 |
case 'hmbkp_mysqldump_started' :
|
212 |
|
213 |
-
$this->set_status( sprintf( 'Dumping Database %s', '(<code>' . $this->get_mysqldump_method() . '</code>)' ) );
|
214 |
|
215 |
break;
|
216 |
|
217 |
case 'hmbkp_mysqldump_verify_started' :
|
218 |
|
219 |
-
$this->set_status( sprintf( 'Verifying Database Dump %s', '(<code>' . $this->get_mysqldump_method() . '</code>)' ) );
|
220 |
|
221 |
break;
|
222 |
|
223 |
case 'hmbkp_archive_started' :
|
224 |
|
225 |
-
$this->set_status( sprintf( 'Creating zip archive %s', '(<code>' . $this->get_archive_method() . '</code>)' ) );
|
226 |
|
227 |
break;
|
228 |
|
229 |
case 'hmbkp_archive_verify_started' :
|
230 |
|
231 |
-
$this->set_status( sprintf( 'Verifying Zip Archive %s', '(<code>' . $this->get_archive_method() . '</code>)' ) );
|
232 |
|
233 |
break;
|
234 |
|
@@ -323,7 +322,7 @@ class WPRP_Backups extends WPRP_HM_Backup {
|
|
323 |
// Protect the directory with a .htaccess file on Apache servers
|
324 |
if ( $is_apache && function_exists( 'insert_with_markers' ) && ! file_exists( $htaccess ) && is_writable( $path ) ) {
|
325 |
|
326 |
-
$contents[] = '# ' . sprintf( __( 'This %s file ensures that other people cannot download your backup files.', '
|
327 |
$contents[] = '';
|
328 |
$contents[] = '<IfModule mod_rewrite.c>';
|
329 |
$contents[] = 'RewriteEngine On';
|
@@ -332,7 +331,7 @@ class WPRP_Backups extends WPRP_HM_Backup {
|
|
332 |
$contents[] = '</IfModule>';
|
333 |
$contents[] = '';
|
334 |
|
335 |
-
insert_with_markers( $htaccess, 'WP Remote Backup', $contents );
|
336 |
|
337 |
}
|
338 |
|
@@ -375,9 +374,11 @@ class WPRP_Backups extends WPRP_HM_Backup {
|
|
375 |
|
376 |
foreach ( array( 'AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT', 'SECRET_KEY' ) as $constant )
|
377 |
if ( defined( $constant ) )
|
378 |
-
$key[] = $constant;
|
|
|
|
|
379 |
|
380 |
-
return md5(
|
381 |
|
382 |
}
|
383 |
|
@@ -490,8 +491,8 @@ class WPRP_Backups extends WPRP_HM_Backup {
|
|
490 |
/**
|
491 |
* Handle the backups API calls
|
492 |
*
|
493 |
-
* @param string $
|
494 |
-
* @return
|
495 |
*/
|
496 |
function _wprp_backups_api_call( $action ) {
|
497 |
|
85 |
|
86 |
/**
|
87 |
* Perform a backup of the site
|
88 |
+
* @return bool|WP_Error
|
|
|
89 |
*/
|
90 |
public function do_backup() {
|
91 |
|
132 |
|
133 |
}
|
134 |
|
135 |
+
return str_replace( parent::conform_dir( WP_CONTENT_DIR ), WP_CONTENT_URL, $backup );
|
136 |
|
137 |
}
|
138 |
|
139 |
+
return new WP_Error( 'backup-failed', __( 'No backup was found', 'wpremote' ) );
|
140 |
|
141 |
}
|
142 |
|
186 |
|
187 |
// Otherwise the filesize must still be calculating
|
188 |
else
|
189 |
+
return __( 'Calculating', 'wpremote' );
|
190 |
|
191 |
}
|
192 |
|
194 |
// it can take some time so we have a small timeout then return "Calculating"
|
195 |
wp_remote_get( add_query_arg( array( 'action' => 'wprp_calculate_backup_size', 'backup_excludes' => $this->get_excludes() ), admin_url( 'admin-ajax.php' ) ), array( 'timeout' => 0.1, 'sslverify' => false ) );
|
196 |
|
197 |
+
return __( 'Calculating', 'wpremote' );
|
198 |
|
199 |
}
|
200 |
|
201 |
/**
|
202 |
* Hook into the actions fired in HM Backup and set the status
|
203 |
*
|
204 |
+
* @param $action
|
205 |
*/
|
206 |
protected function do_action( $action ) {
|
207 |
|
209 |
|
210 |
case 'hmbkp_mysqldump_started' :
|
211 |
|
212 |
+
$this->set_status( sprintf( __( 'Dumping Database %s', 'wpremote' ), '(<code>' . $this->get_mysqldump_method() . '</code>)' ) );
|
213 |
|
214 |
break;
|
215 |
|
216 |
case 'hmbkp_mysqldump_verify_started' :
|
217 |
|
218 |
+
$this->set_status( sprintf( __( 'Verifying Database Dump %s', 'wpremote' ), '(<code>' . $this->get_mysqldump_method() . '</code>)' ) );
|
219 |
|
220 |
break;
|
221 |
|
222 |
case 'hmbkp_archive_started' :
|
223 |
|
224 |
+
$this->set_status( sprintf( __( 'Creating zip archive %s', 'wpremote' ), '(<code>' . $this->get_archive_method() . '</code>)' ) );
|
225 |
|
226 |
break;
|
227 |
|
228 |
case 'hmbkp_archive_verify_started' :
|
229 |
|
230 |
+
$this->set_status( sprintf( __( 'Verifying Zip Archive %s', 'wpremote' ), '(<code>' . $this->get_archive_method() . '</code>)' ) );
|
231 |
|
232 |
break;
|
233 |
|
322 |
// Protect the directory with a .htaccess file on Apache servers
|
323 |
if ( $is_apache && function_exists( 'insert_with_markers' ) && ! file_exists( $htaccess ) && is_writable( $path ) ) {
|
324 |
|
325 |
+
$contents[] = '# ' . sprintf( __( 'This %s file ensures that other people cannot download your backup files.', 'wpremote' ), '.htaccess' );
|
326 |
$contents[] = '';
|
327 |
$contents[] = '<IfModule mod_rewrite.c>';
|
328 |
$contents[] = 'RewriteEngine On';
|
331 |
$contents[] = '</IfModule>';
|
332 |
$contents[] = '';
|
333 |
|
334 |
+
insert_with_markers( $htaccess, __( 'WP Remote Backup', 'wpremote' ), $contents );
|
335 |
|
336 |
}
|
337 |
|
374 |
|
375 |
foreach ( array( 'AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT', 'SECRET_KEY' ) as $constant )
|
376 |
if ( defined( $constant ) )
|
377 |
+
$key[] = constant( $constant );
|
378 |
+
|
379 |
+
shuffle( $key );
|
380 |
|
381 |
+
return md5( serialize( $key ) );
|
382 |
|
383 |
}
|
384 |
|
491 |
/**
|
492 |
* Handle the backups API calls
|
493 |
*
|
494 |
+
* @param string $action
|
495 |
+
* @return bool|string|true|void|WP_Error
|
496 |
*/
|
497 |
function _wprp_backups_api_call( $action ) {
|
498 |
|
wprp.compatability.php
CHANGED
@@ -7,17 +7,15 @@ function wprp_get_incompatible_plugins() {
|
|
7 |
|
8 |
// Plugins to check for.
|
9 |
$security_plugins = array(
|
10 |
-
'BulletProof Security',
|
11 |
-
'Wordfence Security',
|
12 |
-
'Better WP Security',
|
13 |
-
'Wordpress Firewall 2'
|
14 |
);
|
15 |
|
16 |
$active_plugins = get_option( 'active_plugins', array() );
|
17 |
$dismissed_plugins = get_option( 'dismissed-plugins', array() );
|
18 |
|
19 |
-
//update_option( 'dismissed-plugins', array() );
|
20 |
-
|
21 |
$plugin_matches = array();
|
22 |
|
23 |
// foreach through activated plugins and split the string to have one name to check results against.
|
@@ -38,19 +36,22 @@ function wprp_get_incompatible_plugins() {
|
|
38 |
*/
|
39 |
function wprp_security_admin_notice() {
|
40 |
|
|
|
|
|
|
|
41 |
foreach ( wprp_get_incompatible_plugins() as $plugin_path => $plugin_name ) :
|
42 |
|
43 |
?>
|
44 |
|
45 |
<div class="error">
|
46 |
|
47 |
-
<a class="close-button button" style="float: right; margin-top: 4px; color: inherit; text-decoration: none; " href="<?php echo add_query_arg( 'wpr_dismiss_plugin_warning', $plugin_path ); ?>"
|
48 |
|
49 |
<p>
|
50 |
|
51 |
-
The plugin <strong><?php echo esc_attr( $plugin_name ); ?></strong> may cause issues with WP Remote.
|
52 |
|
53 |
-
<a href="https://wpremote.com/support-center/troubleshooting/my-site-is-showing-up-as-red/#<?php echo esc_attr( $plugin_name ); ?>" alt="WPRemote Support Center"> Click here for instructions on how to resolve this issue </a>
|
54 |
|
55 |
</p>
|
56 |
|
@@ -67,16 +68,16 @@ add_action( 'admin_notices', 'wprp_security_admin_notice' );
|
|
67 |
*/
|
68 |
function wprp_dismissed_plugin_notice_check() {
|
69 |
|
70 |
-
if ( ! empty( $_GET['wpr_dismiss_plugin_warning'] ) ) {
|
71 |
|
72 |
$dismissed = get_option( 'dismissed-plugins', array() );
|
73 |
-
$dismissed[] = $_GET['wpr_dismiss_plugin_warning'];
|
74 |
|
75 |
update_option( 'dismissed-plugins', $dismissed );
|
76 |
|
77 |
-
|
78 |
exit;
|
79 |
|
80 |
}
|
81 |
}
|
82 |
-
add_action( '
|
7 |
|
8 |
// Plugins to check for.
|
9 |
$security_plugins = array(
|
10 |
+
__( 'BulletProof Security', 'wpremote' ),
|
11 |
+
__( 'Wordfence Security', 'wpremote' ),
|
12 |
+
__( 'Better WP Security', 'wpremote' ),
|
13 |
+
__( 'Wordpress Firewall 2', 'wpremote' )
|
14 |
);
|
15 |
|
16 |
$active_plugins = get_option( 'active_plugins', array() );
|
17 |
$dismissed_plugins = get_option( 'dismissed-plugins', array() );
|
18 |
|
|
|
|
|
19 |
$plugin_matches = array();
|
20 |
|
21 |
// foreach through activated plugins and split the string to have one name to check results against.
|
36 |
*/
|
37 |
function wprp_security_admin_notice() {
|
38 |
|
39 |
+
if ( ! current_user_can( 'install_plugins' ) )
|
40 |
+
return;
|
41 |
+
|
42 |
foreach ( wprp_get_incompatible_plugins() as $plugin_path => $plugin_name ) :
|
43 |
|
44 |
?>
|
45 |
|
46 |
<div class="error">
|
47 |
|
48 |
+
<a class="close-button button" style="float: right; margin-top: 4px; color: inherit; text-decoration: none; " href="<?php echo add_query_arg( 'wpr_dismiss_plugin_warning', $plugin_path ); ?>"><?php _e( 'Don\'t show again','wpremote' ); ?></a>
|
49 |
|
50 |
<p>
|
51 |
|
52 |
+
<?php _e( 'The plugin', 'wpremote' );?> <strong><?php echo esc_attr( $plugin_name ); ?></strong> <?php _e( 'may cause issues with WP Remote.', 'wpremote' ); ?>
|
53 |
|
54 |
+
<a href="https://wpremote.com/support-center/troubleshooting/my-site-is-showing-up-as-red/#<?php echo esc_attr( $plugin_name ); ?>" alt="WPRemote Support Center"> <?php _e( 'Click here for instructions on how to resolve this issue', 'wpremote' ); ?> </a>
|
55 |
|
56 |
</p>
|
57 |
|
68 |
*/
|
69 |
function wprp_dismissed_plugin_notice_check() {
|
70 |
|
71 |
+
if ( current_user_can( 'install_plugins' ) && ! empty( $_GET['wpr_dismiss_plugin_warning'] ) ) {
|
72 |
|
73 |
$dismissed = get_option( 'dismissed-plugins', array() );
|
74 |
+
$dismissed[] = sanitize_text_field( $_GET['wpr_dismiss_plugin_warning'] );
|
75 |
|
76 |
update_option( 'dismissed-plugins', $dismissed );
|
77 |
|
78 |
+
wp_safe_redirect( remove_query_arg( 'wpr_dismiss_plugin_warning' ) );
|
79 |
exit;
|
80 |
|
81 |
}
|
82 |
}
|
83 |
+
add_action( 'admin_init', 'wprp_dismissed_plugin_notice_check' );
|
wprp.hm.backup.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* Generic file and database backup class
|
5 |
*
|
6 |
-
* @version 2.
|
7 |
*/
|
8 |
class WPRP_HM_Backup {
|
9 |
|
@@ -141,13 +141,12 @@ class WPRP_HM_Backup {
|
|
141 |
/**
|
142 |
* Check whether safe mode is active or not
|
143 |
*
|
144 |
-
* @
|
145 |
-
* @static
|
146 |
* @return bool
|
147 |
*/
|
148 |
-
public static function is_safe_mode_active() {
|
149 |
|
150 |
-
if ( ( $safe_mode = @
|
151 |
return true;
|
152 |
|
153 |
return false;
|
@@ -167,8 +166,8 @@ class WPRP_HM_Backup {
|
|
167 |
if ( self::is_safe_mode_active() )
|
168 |
return false;
|
169 |
|
170 |
-
// Is shell_exec disabled?
|
171 |
-
if (
|
172 |
return false;
|
173 |
|
174 |
// Can we issue a simple echo command?
|
@@ -197,7 +196,7 @@ class WPRP_HM_Backup {
|
|
197 |
|
198 |
// If site_url contains home_url and they differ then assume WordPress is installed in a sub directory
|
199 |
if ( $home_url !== $site_url && strpos( $site_url, $home_url ) === 0 )
|
200 |
-
$home_path = trailingslashit( substr( ABSPATH, 0, strrpos( ABSPATH, str_replace( $home_url, '', $site_url ) ) ) );
|
201 |
|
202 |
return self::conform_dir( $home_path );
|
203 |
|
@@ -206,10 +205,8 @@ class WPRP_HM_Backup {
|
|
206 |
/**
|
207 |
* Sanitize a directory path
|
208 |
*
|
209 |
-
* @access public
|
210 |
-
* @static
|
211 |
* @param string $dir
|
212 |
-
* @param bool
|
213 |
* @return string $dir
|
214 |
*/
|
215 |
public static function conform_dir( $dir, $recursive = false ) {
|
@@ -286,10 +283,10 @@ class WPRP_HM_Backup {
|
|
286 |
public function set_archive_filename( $filename ) {
|
287 |
|
288 |
if ( empty( $filename ) || ! is_string( $filename ) )
|
289 |
-
throw new Exception( 'archive filename must be a non empty string' );
|
290 |
|
291 |
if ( pathinfo( $filename, PATHINFO_EXTENSION ) !== 'zip' )
|
292 |
-
throw new Exception( 'invalid file extension for archive filename <code>' . $filename . '</code>' );
|
293 |
|
294 |
$this->archive_filename = strtolower( sanitize_file_name( remove_accents( $filename ) ) );
|
295 |
|
@@ -331,10 +328,10 @@ class WPRP_HM_Backup {
|
|
331 |
public function set_database_dump_filename( $filename ) {
|
332 |
|
333 |
if ( empty( $filename ) || ! is_string( $filename ) )
|
334 |
-
throw new Exception( 'database dump filename must be a non empty string' );
|
335 |
|
336 |
if ( pathinfo( $filename, PATHINFO_EXTENSION ) !== 'sql' )
|
337 |
-
throw new Exception( 'invalid file extension for database dump filename <code>' . $filename . '</code>' );
|
338 |
|
339 |
$this->database_dump_filename = strtolower( sanitize_file_name( remove_accents( $filename ) ) );
|
340 |
|
@@ -367,7 +364,7 @@ class WPRP_HM_Backup {
|
|
367 |
public function set_root( $path ) {
|
368 |
|
369 |
if ( empty( $path ) || ! is_string( $path ) || ! is_dir ( $path ) )
|
370 |
-
throw new Exception( 'Invalid root path <code>' . $path . '</code>
|
371 |
|
372 |
$this->root = self::conform_dir( $path );
|
373 |
|
@@ -398,7 +395,7 @@ class WPRP_HM_Backup {
|
|
398 |
public function set_path( $path ) {
|
399 |
|
400 |
if ( empty( $path ) || ! is_string( $path ) )
|
401 |
-
throw new Exception( 'Invalid backup path <code>' . $path . '</code>
|
402 |
|
403 |
$this->path = self::conform_dir( $path );
|
404 |
|
@@ -453,7 +450,7 @@ class WPRP_HM_Backup {
|
|
453 |
public function set_type( $type ) {
|
454 |
|
455 |
if ( ! is_string( $type ) || ! in_array( $type, array( 'file', 'database', 'complete' ) ) )
|
456 |
-
throw new Exception( 'Invalid backup type
|
457 |
|
458 |
$this->type = $type;
|
459 |
|
@@ -512,7 +509,7 @@ class WPRP_HM_Backup {
|
|
512 |
|
513 |
// Find the one which works
|
514 |
foreach ( $mysqldump_locations as $location )
|
515 |
-
if ( is_executable( self::conform_dir( $location ) ) )
|
516 |
$this->set_mysqldump_command_path( $location );
|
517 |
|
518 |
return $this->mysqldump_command_path;
|
@@ -573,7 +570,7 @@ class WPRP_HM_Backup {
|
|
573 |
|
574 |
// Find the one which works
|
575 |
foreach ( $zip_locations as $location )
|
576 |
-
if ( is_executable( self::conform_dir( $location ) ) )
|
577 |
$this->set_zip_command_path( $location );
|
578 |
|
579 |
return $this->zip_command_path;
|
@@ -656,9 +653,13 @@ class WPRP_HM_Backup {
|
|
656 |
// Path to the mysqldump executable
|
657 |
$cmd = escapeshellarg( $this->get_mysqldump_command_path() );
|
658 |
|
659 |
-
//
|
660 |
$cmd .= ' --no-create-db';
|
661 |
|
|
|
|
|
|
|
|
|
662 |
// Make sure binary data is exported properly
|
663 |
$cmd .= ' --hex-blob';
|
664 |
|
@@ -673,7 +674,7 @@ class WPRP_HM_Backup {
|
|
673 |
$cmd .= ' -h ' . escapeshellarg( $host );
|
674 |
|
675 |
// Set the port if it was set
|
676 |
-
if ( ! empty( $port ) )
|
677 |
$cmd .= ' -P ' . $port;
|
678 |
|
679 |
// The file we're saving too
|
@@ -688,8 +689,14 @@ class WPRP_HM_Backup {
|
|
688 |
// Store any returned data in an error
|
689 |
$stderr = shell_exec( $cmd );
|
690 |
|
691 |
-
|
|
|
|
|
|
|
|
|
|
|
692 |
$this->error( $this->get_mysqldump_method(), $stderr );
|
|
|
693 |
|
694 |
$this->verify_mysqldump();
|
695 |
|
@@ -708,10 +715,18 @@ class WPRP_HM_Backup {
|
|
708 |
|
709 |
$this->do_action( 'hmbkp_mysqldump_started' );
|
710 |
|
711 |
-
$this->db = mysql_pconnect( DB_HOST, DB_USER, DB_PASSWORD );
|
|
|
|
|
|
|
|
|
|
|
|
|
712 |
|
713 |
mysql_select_db( DB_NAME, $this->db );
|
714 |
-
|
|
|
|
|
715 |
|
716 |
// Begin new backup of MySql
|
717 |
$tables = mysql_query( 'SHOW TABLES' );
|
@@ -789,10 +804,10 @@ class WPRP_HM_Backup {
|
|
789 |
$stderr = shell_exec( 'cd ' . escapeshellarg( $this->get_root() ) . ' && ' . escapeshellcmd( $this->get_zip_command_path() ) . ' -rq ' . escapeshellarg( $this->get_archive_filepath() ) . ' ./' . ' 2>&1' );
|
790 |
|
791 |
// Add the database dump to the archive
|
792 |
-
if ( $this->get_type() !== 'file' )
|
793 |
$stderr = shell_exec( 'cd ' . escapeshellarg( $this->get_path() ) . ' && ' . escapeshellcmd( $this->get_zip_command_path() ) . ' -uq ' . escapeshellarg( $this->get_archive_filepath() ) . ' ' . escapeshellarg( $this->get_database_dump_filename() ) . ' 2>&1' );
|
794 |
|
795 |
-
if ( $stderr )
|
796 |
$this->warning( $this->get_archive_method(), $stderr );
|
797 |
|
798 |
$this->verify_archive();
|
@@ -802,9 +817,6 @@ class WPRP_HM_Backup {
|
|
802 |
/**
|
803 |
* Fallback for creating zip archives if zip command is
|
804 |
* unavailable.
|
805 |
-
*
|
806 |
-
* @access public
|
807 |
-
* @param string $path
|
808 |
*/
|
809 |
public function zip_archive() {
|
810 |
|
@@ -853,7 +865,7 @@ class WPRP_HM_Backup {
|
|
853 |
}
|
854 |
|
855 |
// Add the database
|
856 |
-
if ( $this->get_type() !== 'file' )
|
857 |
$zip->addFile( $this->get_database_dump_filepath(), $this->get_database_dump_filename() );
|
858 |
|
859 |
if ( $zip->status )
|
@@ -873,9 +885,6 @@ class WPRP_HM_Backup {
|
|
873 |
* unavailable.
|
874 |
*
|
875 |
* Uses the PclZip library that ships with WordPress
|
876 |
-
*
|
877 |
-
* @access public
|
878 |
-
* @param string $path
|
879 |
*/
|
880 |
public function pcl_zip() {
|
881 |
|
@@ -898,7 +907,7 @@ class WPRP_HM_Backup {
|
|
898 |
$this->warning( $this->get_archive_method(), $archive->errorInfo( true ) );
|
899 |
|
900 |
// Add the database
|
901 |
-
if ( $this->get_type() !== 'file' )
|
902 |
if ( ! $archive->add( $this->get_database_dump_filepath(), PCLZIP_OPT_REMOVE_PATH, $this->get_path() ) )
|
903 |
$this->warning( $this->get_archive_method(), $archive->errorInfo( true ) );
|
904 |
|
@@ -947,16 +956,6 @@ class WPRP_HM_Backup {
|
|
947 |
if ( ! empty( $this->archive_verified ) )
|
948 |
return true;
|
949 |
|
950 |
-
// Verify using the zip command if possible
|
951 |
-
if ( $this->get_zip_command_path() && $this->get_archive_method() === 'zip' ) {
|
952 |
-
|
953 |
-
$verify = shell_exec( escapeshellcmd( $this->get_zip_command_path() ) . ' -T ' . escapeshellarg( $this->get_archive_filepath() ) . ' 2> /dev/null' );
|
954 |
-
|
955 |
-
if ( strpos( $verify, 'OK' ) === false )
|
956 |
-
$this->error( $this->get_archive_method(), $verify );
|
957 |
-
|
958 |
-
}
|
959 |
-
|
960 |
// If there are errors delete the backup file.
|
961 |
if ( $this->get_errors( $this->get_archive_method() ) && file_exists( $this->get_archive_filepath() ) )
|
962 |
unlink( $this->get_archive_filepath() );
|
@@ -982,12 +981,23 @@ class WPRP_HM_Backup {
|
|
982 |
|
983 |
$this->files = array();
|
984 |
|
985 |
-
|
|
|
|
|
986 |
$this->files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $this->get_root(), RecursiveDirectoryIterator::FOLLOW_SYMLINKS ), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD );
|
987 |
|
988 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
989 |
$this->files = $this->get_files_fallback( $this->get_root() );
|
990 |
|
|
|
|
|
991 |
return $this->files;
|
992 |
|
993 |
}
|
@@ -1475,7 +1485,7 @@ class WPRP_HM_Backup {
|
|
1475 |
$field_set[$j] = $this->sql_backquote( mysql_field_name( $result, $j ) );
|
1476 |
$type = mysql_field_type( $result, $j );
|
1477 |
|
1478 |
-
if ( $type === 'tinyint' || $type === 'smallint' || $type === 'mediumint' || $type === 'int' || $type === 'bigint'
|
1479 |
$field_num[$j] = true;
|
1480 |
|
1481 |
else
|
@@ -1613,7 +1623,7 @@ class WPRP_HM_Backup {
|
|
1613 |
* @param string $context
|
1614 |
* @param mixed $error
|
1615 |
*/
|
1616 |
-
|
1617 |
|
1618 |
if ( empty( $context ) || empty( $error ) )
|
1619 |
return;
|
@@ -1637,8 +1647,8 @@ class WPRP_HM_Backup {
|
|
1637 |
if ( empty( $errors ) )
|
1638 |
return;
|
1639 |
|
1640 |
-
foreach ( $errors as $error_context => $
|
1641 |
-
foreach( $
|
1642 |
$this->warning( $error_context, $error );
|
1643 |
|
1644 |
if ( $context )
|
@@ -1682,16 +1692,14 @@ class WPRP_HM_Backup {
|
|
1682 |
}
|
1683 |
|
1684 |
/**
|
1685 |
-
* Custom error handler for catching errors
|
1686 |
*
|
1687 |
-
* @access private
|
1688 |
* @param string $type
|
1689 |
-
* @
|
1690 |
-
* @param string $file
|
1691 |
-
* @param string $line
|
1692 |
*/
|
1693 |
public function error_handler( $type ) {
|
1694 |
|
|
|
1695 |
if ( ( defined( 'E_DEPRECATED' ) && $type === E_DEPRECATED ) || ( defined( 'E_STRICT' ) && $type === E_STRICT ) || error_reporting() === 0 )
|
1696 |
return false;
|
1697 |
|
@@ -1731,4 +1739,4 @@ function wprp_hmbkp_pclzip_callback( $event, &$file ) {
|
|
1731 |
|
1732 |
return true;
|
1733 |
|
1734 |
-
}
|
3 |
/**
|
4 |
* Generic file and database backup class
|
5 |
*
|
6 |
+
* @version 2.3
|
7 |
*/
|
8 |
class WPRP_HM_Backup {
|
9 |
|
141 |
/**
|
142 |
* Check whether safe mode is active or not
|
143 |
*
|
144 |
+
* @param string $ini_get_callback
|
|
|
145 |
* @return bool
|
146 |
*/
|
147 |
+
public static function is_safe_mode_active( $ini_get_callback = 'ini_get' ) {
|
148 |
|
149 |
+
if ( ( $safe_mode = @call_user_func( $ini_get_callback, 'safe_mode' ) ) && strtolower( $safe_mode ) != 'off' )
|
150 |
return true;
|
151 |
|
152 |
return false;
|
166 |
if ( self::is_safe_mode_active() )
|
167 |
return false;
|
168 |
|
169 |
+
// Is shell_exec or escapeshellcmd or escapeshellarg disabled?
|
170 |
+
if ( array_intersect( array( 'shell_exec', 'escapeshellarg', 'escapeshellcmd' ), array_map( 'trim', explode( ',', @ini_get( 'disable_functions' ) ) ) ) )
|
171 |
return false;
|
172 |
|
173 |
// Can we issue a simple echo command?
|
196 |
|
197 |
// If site_url contains home_url and they differ then assume WordPress is installed in a sub directory
|
198 |
if ( $home_url !== $site_url && strpos( $site_url, $home_url ) === 0 )
|
199 |
+
$home_path = trailingslashit( substr( self::conform_dir( ABSPATH ), 0, strrpos( self::conform_dir( ABSPATH ), str_replace( $home_url, '', $site_url ) ) ) );
|
200 |
|
201 |
return self::conform_dir( $home_path );
|
202 |
|
205 |
/**
|
206 |
* Sanitize a directory path
|
207 |
*
|
|
|
|
|
208 |
* @param string $dir
|
209 |
+
* @param bool $recursive (default: false)
|
210 |
* @return string $dir
|
211 |
*/
|
212 |
public static function conform_dir( $dir, $recursive = false ) {
|
283 |
public function set_archive_filename( $filename ) {
|
284 |
|
285 |
if ( empty( $filename ) || ! is_string( $filename ) )
|
286 |
+
throw new Exception( __( 'archive filename must be a non empty string', 'wpremote' ) );
|
287 |
|
288 |
if ( pathinfo( $filename, PATHINFO_EXTENSION ) !== 'zip' )
|
289 |
+
throw new Exception( __( 'invalid file extension for archive filename', 'wpremote' ) . '<code>' . $filename . '</code>' );
|
290 |
|
291 |
$this->archive_filename = strtolower( sanitize_file_name( remove_accents( $filename ) ) );
|
292 |
|
328 |
public function set_database_dump_filename( $filename ) {
|
329 |
|
330 |
if ( empty( $filename ) || ! is_string( $filename ) )
|
331 |
+
throw new Exception( __( 'database dump filename must be a non empty string', 'wpremote' ) );
|
332 |
|
333 |
if ( pathinfo( $filename, PATHINFO_EXTENSION ) !== 'sql' )
|
334 |
+
throw new Exception( __( 'invalid file extension for database dump filename', 'wpremote' ) . '<code>' . $filename . '</code>' );
|
335 |
|
336 |
$this->database_dump_filename = strtolower( sanitize_file_name( remove_accents( $filename ) ) );
|
337 |
|
364 |
public function set_root( $path ) {
|
365 |
|
366 |
if ( empty( $path ) || ! is_string( $path ) || ! is_dir ( $path ) )
|
367 |
+
throw new Exception( sprintf( __( 'Invalid root path %s must be a valid directory path', 'wpremote' ), '<code>' . $path . '</code>' ) );
|
368 |
|
369 |
$this->root = self::conform_dir( $path );
|
370 |
|
395 |
public function set_path( $path ) {
|
396 |
|
397 |
if ( empty( $path ) || ! is_string( $path ) )
|
398 |
+
throw new Exception( sptrinf( __( 'Invalid backup path %s must be a non empty (string)', wpremote ), '<code>' . $path . '</code>' ) );
|
399 |
|
400 |
$this->path = self::conform_dir( $path );
|
401 |
|
450 |
public function set_type( $type ) {
|
451 |
|
452 |
if ( ! is_string( $type ) || ! in_array( $type, array( 'file', 'database', 'complete' ) ) )
|
453 |
+
throw new Exception( sprintf( __( 'Invalid backup type %s must be one of (string) file, database or complete', 'wpremote' ), '<code>' . $type . '</code>' ) );
|
454 |
|
455 |
$this->type = $type;
|
456 |
|
509 |
|
510 |
// Find the one which works
|
511 |
foreach ( $mysqldump_locations as $location )
|
512 |
+
if ( @is_executable( self::conform_dir( $location ) ) )
|
513 |
$this->set_mysqldump_command_path( $location );
|
514 |
|
515 |
return $this->mysqldump_command_path;
|
570 |
|
571 |
// Find the one which works
|
572 |
foreach ( $zip_locations as $location )
|
573 |
+
if ( @is_executable( self::conform_dir( $location ) ) )
|
574 |
$this->set_zip_command_path( $location );
|
575 |
|
576 |
return $this->zip_command_path;
|
653 |
// Path to the mysqldump executable
|
654 |
$cmd = escapeshellarg( $this->get_mysqldump_command_path() );
|
655 |
|
656 |
+
// We don't want to create a new DB
|
657 |
$cmd .= ' --no-create-db';
|
658 |
|
659 |
+
// Allow lock-tables to be overridden
|
660 |
+
if ( ! defined( 'HMBKP_MYSQLDUMP_SINGLE_TRANSACTION' ) || HMBKP_MYSQLDUMP_SINGLE_TRANSACTION !== false )
|
661 |
+
$cmd .= ' --single-transaction';
|
662 |
+
|
663 |
// Make sure binary data is exported properly
|
664 |
$cmd .= ' --hex-blob';
|
665 |
|
674 |
$cmd .= ' -h ' . escapeshellarg( $host );
|
675 |
|
676 |
// Set the port if it was set
|
677 |
+
if ( ! empty( $port ) && is_numeric( $port ) )
|
678 |
$cmd .= ' -P ' . $port;
|
679 |
|
680 |
// The file we're saving too
|
689 |
// Store any returned data in an error
|
690 |
$stderr = shell_exec( $cmd );
|
691 |
|
692 |
+
// Skip the new password warning that is output in mysql > 5.6 (@see http://bugs.mysql.com/bug.php?id=66546)
|
693 |
+
if ( trim( $stderr ) === 'Warning: Using a password on the command line interface can be insecure.' ) {
|
694 |
+
$stderr = '';
|
695 |
+
}
|
696 |
+
|
697 |
+
if ( $stderr ) {
|
698 |
$this->error( $this->get_mysqldump_method(), $stderr );
|
699 |
+
}
|
700 |
|
701 |
$this->verify_mysqldump();
|
702 |
|
715 |
|
716 |
$this->do_action( 'hmbkp_mysqldump_started' );
|
717 |
|
718 |
+
$this->db = @mysql_pconnect( DB_HOST, DB_USER, DB_PASSWORD );
|
719 |
+
|
720 |
+
if ( ! $this->db )
|
721 |
+
$this->db = mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
|
722 |
+
|
723 |
+
if ( ! $this->db )
|
724 |
+
return;
|
725 |
|
726 |
mysql_select_db( DB_NAME, $this->db );
|
727 |
+
|
728 |
+
if ( function_exists( 'mysql_set_charset') )
|
729 |
+
mysql_set_charset( DB_CHARSET, $this->db );
|
730 |
|
731 |
// Begin new backup of MySql
|
732 |
$tables = mysql_query( 'SHOW TABLES' );
|
804 |
$stderr = shell_exec( 'cd ' . escapeshellarg( $this->get_root() ) . ' && ' . escapeshellcmd( $this->get_zip_command_path() ) . ' -rq ' . escapeshellarg( $this->get_archive_filepath() ) . ' ./' . ' 2>&1' );
|
805 |
|
806 |
// Add the database dump to the archive
|
807 |
+
if ( $this->get_type() !== 'file' && file_exists( $this->get_database_dump_filepath() ) )
|
808 |
$stderr = shell_exec( 'cd ' . escapeshellarg( $this->get_path() ) . ' && ' . escapeshellcmd( $this->get_zip_command_path() ) . ' -uq ' . escapeshellarg( $this->get_archive_filepath() ) . ' ' . escapeshellarg( $this->get_database_dump_filename() ) . ' 2>&1' );
|
809 |
|
810 |
+
if ( ! empty( $stderr ) )
|
811 |
$this->warning( $this->get_archive_method(), $stderr );
|
812 |
|
813 |
$this->verify_archive();
|
817 |
/**
|
818 |
* Fallback for creating zip archives if zip command is
|
819 |
* unavailable.
|
|
|
|
|
|
|
820 |
*/
|
821 |
public function zip_archive() {
|
822 |
|
865 |
}
|
866 |
|
867 |
// Add the database
|
868 |
+
if ( $this->get_type() !== 'file' && file_exists( $this->get_database_dump_filepath() ) )
|
869 |
$zip->addFile( $this->get_database_dump_filepath(), $this->get_database_dump_filename() );
|
870 |
|
871 |
if ( $zip->status )
|
885 |
* unavailable.
|
886 |
*
|
887 |
* Uses the PclZip library that ships with WordPress
|
|
|
|
|
|
|
888 |
*/
|
889 |
public function pcl_zip() {
|
890 |
|
907 |
$this->warning( $this->get_archive_method(), $archive->errorInfo( true ) );
|
908 |
|
909 |
// Add the database
|
910 |
+
if ( $this->get_type() !== 'file' && file_exists( $this->get_database_dump_filepath() ) )
|
911 |
if ( ! $archive->add( $this->get_database_dump_filepath(), PCLZIP_OPT_REMOVE_PATH, $this->get_path() ) )
|
912 |
$this->warning( $this->get_archive_method(), $archive->errorInfo( true ) );
|
913 |
|
956 |
if ( ! empty( $this->archive_verified ) )
|
957 |
return true;
|
958 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
959 |
// If there are errors delete the backup file.
|
960 |
if ( $this->get_errors( $this->get_archive_method() ) && file_exists( $this->get_archive_filepath() ) )
|
961 |
unlink( $this->get_archive_filepath() );
|
981 |
|
982 |
$this->files = array();
|
983 |
|
984 |
+
// We only want to use the RecursiveDirectoryIterator if the FOLLOW_SYMLINKS flag is available
|
985 |
+
if ( defined( 'RecursiveDirectoryIterator::FOLLOW_SYMLINKS' ) ) {
|
986 |
+
|
987 |
$this->files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $this->get_root(), RecursiveDirectoryIterator::FOLLOW_SYMLINKS ), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD );
|
988 |
|
989 |
+
// Skip dot files if the SKIP_Dots flag is available
|
990 |
+
if ( defined( 'RecursiveDirectoryIterator::SKIP_DOTS' ) )
|
991 |
+
$this->files->setFlags( RecursiveDirectoryIterator::SKIP_DOTS + RecursiveDirectoryIterator::FOLLOW_SYMLINKS );
|
992 |
+
|
993 |
+
|
994 |
+
// If RecursiveDirectoryIterator::FOLLOW_SYMLINKS isn't available then fallback to a less memory efficient method
|
995 |
+
} else {
|
996 |
+
|
997 |
$this->files = $this->get_files_fallback( $this->get_root() );
|
998 |
|
999 |
+
}
|
1000 |
+
|
1001 |
return $this->files;
|
1002 |
|
1003 |
}
|
1485 |
$field_set[$j] = $this->sql_backquote( mysql_field_name( $result, $j ) );
|
1486 |
$type = mysql_field_type( $result, $j );
|
1487 |
|
1488 |
+
if ( $type === 'tinyint' || $type === 'smallint' || $type === 'mediumint' || $type === 'int' || $type === 'bigint' )
|
1489 |
$field_num[$j] = true;
|
1490 |
|
1491 |
else
|
1623 |
* @param string $context
|
1624 |
* @param mixed $error
|
1625 |
*/
|
1626 |
+
public function error( $context, $error ) {
|
1627 |
|
1628 |
if ( empty( $context ) || empty( $error ) )
|
1629 |
return;
|
1647 |
if ( empty( $errors ) )
|
1648 |
return;
|
1649 |
|
1650 |
+
foreach ( $errors as $error_context => $context_errors )
|
1651 |
+
foreach( $context_errors as $error )
|
1652 |
$this->warning( $error_context, $error );
|
1653 |
|
1654 |
if ( $context )
|
1692 |
}
|
1693 |
|
1694 |
/**
|
1695 |
+
* Custom error handler for catching php errors
|
1696 |
*
|
|
|
1697 |
* @param string $type
|
1698 |
+
* @return bool
|
|
|
|
|
1699 |
*/
|
1700 |
public function error_handler( $type ) {
|
1701 |
|
1702 |
+
// Skip strict & deprecated warnings
|
1703 |
if ( ( defined( 'E_DEPRECATED' ) && $type === E_DEPRECATED ) || ( defined( 'E_STRICT' ) && $type === E_STRICT ) || error_reporting() === 0 )
|
1704 |
return false;
|
1705 |
|
1739 |
|
1740 |
return true;
|
1741 |
|
1742 |
+
}
|
wprp.plugins.php
CHANGED
@@ -70,7 +70,7 @@ function _wprp_get_plugins() {
|
|
70 |
* @param mixed $plugin
|
71 |
* @return array
|
72 |
*/
|
73 |
-
function
|
74 |
|
75 |
include_once ( ABSPATH . 'wp-admin/includes/admin.php' );
|
76 |
|
@@ -134,15 +134,52 @@ function _wprp_upgrade_plugin( $plugin ) {
|
|
134 |
$json = $json->activate_plugin;
|
135 |
|
136 |
if ( empty( $json->status ) )
|
137 |
-
return array( 'status' => 'error', 'error' => 'The plugin was updated, but failed to re-activate. The activation
|
138 |
|
139 |
if ( $json->status != 'success' )
|
140 |
-
return array( 'status' => 'error', 'error' => 'The plugin was updated, but failed to re-activate. The activation
|
141 |
}
|
142 |
|
143 |
return array( 'status' => 'success' );
|
144 |
}
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
function _wprp_activate_plugin( $plugin ) {
|
147 |
|
148 |
include_once ABSPATH . 'wp-admin/includes/plugin.php';
|
@@ -155,6 +192,62 @@ function _wprp_activate_plugin( $plugin ) {
|
|
155 |
return array( 'status' => 'success' );
|
156 |
}
|
157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
/**
|
159 |
* Check if the site can support plugin upgrades
|
160 |
*
|
@@ -203,7 +296,8 @@ function _wpr_get_gravity_form_plugin_data() {
|
|
203 |
return false;
|
204 |
|
205 |
$version_data = GFCommon::get_version_info();
|
206 |
-
$
|
|
|
207 |
|
208 |
if ( empty( $version_data['url'] ) || empty( $version_data['is_valid_key'] ) || empty( $plugin_data['new_version'] ) || empty( $plugin_data['PluginURI'] ) || empty( $plugin_data['slug'] ) )
|
209 |
return false;
|
70 |
* @param mixed $plugin
|
71 |
* @return array
|
72 |
*/
|
73 |
+
function _wprp_update_plugin( $plugin ) {
|
74 |
|
75 |
include_once ( ABSPATH . 'wp-admin/includes/admin.php' );
|
76 |
|
134 |
$json = $json->activate_plugin;
|
135 |
|
136 |
if ( empty( $json->status ) )
|
137 |
+
return array( 'status' => 'error', 'error' => 'The plugin was updated, but failed to re-activate. The activation request returned no response' );
|
138 |
|
139 |
if ( $json->status != 'success' )
|
140 |
+
return array( 'status' => 'error', 'error' => 'The plugin was updated, but failed to re-activate. The activation request returned response: ' . $json->status );
|
141 |
}
|
142 |
|
143 |
return array( 'status' => 'success' );
|
144 |
}
|
145 |
|
146 |
+
/**
|
147 |
+
* Install a plugin on this site
|
148 |
+
*/
|
149 |
+
function _wprp_install_plugin( $plugin, $args = array() ) {
|
150 |
+
|
151 |
+
include_once ABSPATH . 'wp-admin/includes/admin.php';
|
152 |
+
include_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
153 |
+
include_once ABSPATH . 'wp-includes/update.php';
|
154 |
+
|
155 |
+
// Access the plugins_api() helper function
|
156 |
+
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
157 |
+
$api_args = array(
|
158 |
+
'slug' => $plugin,
|
159 |
+
'fields' => array( 'sections' => false )
|
160 |
+
);
|
161 |
+
$api = plugins_api( 'plugin_information', $api_args );
|
162 |
+
|
163 |
+
if ( is_wp_error( $api ) )
|
164 |
+
return array( 'status' => 'error', 'error' => $api->get_error_code() );
|
165 |
+
|
166 |
+
$skin = new WPRP_Plugin_Upgrader_Skin();
|
167 |
+
$upgrader = new Plugin_Upgrader( $skin );
|
168 |
+
|
169 |
+
// The best way to get a download link for a specific version :(
|
170 |
+
// Fortunately, we can depend on a relatively consistent naming pattern
|
171 |
+
if ( ! empty( $args['version'] ) && 'stable' != $args['version'] )
|
172 |
+
$api->download_link = str_replace( $api->version . '.zip', $args['version'] . '.zip', $api->download_link );
|
173 |
+
|
174 |
+
$result = $upgrader->install( $api->download_link );
|
175 |
+
if ( is_wp_error( $result ) )
|
176 |
+
return array( 'status' => 'error', 'error' => $result->get_error_code() );
|
177 |
+
else if ( ! $result )
|
178 |
+
return array( 'status' => 'error', 'error' => 'Unknown error installing plugin.' );
|
179 |
+
|
180 |
+
return array( 'status' => 'success' );
|
181 |
+
}
|
182 |
+
|
183 |
function _wprp_activate_plugin( $plugin ) {
|
184 |
|
185 |
include_once ABSPATH . 'wp-admin/includes/plugin.php';
|
192 |
return array( 'status' => 'success' );
|
193 |
}
|
194 |
|
195 |
+
/**
|
196 |
+
* Deactivate a plugin on this site.
|
197 |
+
*/
|
198 |
+
function _wprp_deactivate_plugin( $plugin ) {
|
199 |
+
|
200 |
+
include_once ABSPATH . 'wp-admin/includes/plugin.php';
|
201 |
+
|
202 |
+
$result = deactivate_plugins( $plugin );
|
203 |
+
|
204 |
+
if ( is_wp_error( $result ) )
|
205 |
+
return array( 'status' => 'error', 'error' => $result->get_error_code() );
|
206 |
+
|
207 |
+
return array( 'status' => 'success' );
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Uninstall a plugin on this site.
|
212 |
+
*/
|
213 |
+
function _wprp_uninstall_plugin( $plugin ) {
|
214 |
+
global $wp_filesystem;
|
215 |
+
|
216 |
+
include_once ABSPATH . 'wp-admin/includes/admin.php';
|
217 |
+
include_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
218 |
+
include_once ABSPATH . 'wp-includes/update.php';
|
219 |
+
|
220 |
+
if ( ! _wpr_check_filesystem_access() || ! WP_Filesystem() )
|
221 |
+
return array( 'status' => 'error', 'error' => 'The filesystem is not writable with the supplied credentials' );
|
222 |
+
|
223 |
+
$plugins_dir = $wp_filesystem->wp_plugins_dir();
|
224 |
+
if ( empty( $plugins_dir ) )
|
225 |
+
return array( 'status' => 'error', 'error' => 'Unable to locate WordPress Plugin directory.' );
|
226 |
+
|
227 |
+
$plugins_dir = trailingslashit( $plugins_dir );
|
228 |
+
|
229 |
+
if ( is_uninstallable_plugin( $plugin ) )
|
230 |
+
uninstall_plugin( $plugin );
|
231 |
+
|
232 |
+
$this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin ) );
|
233 |
+
// If plugin is in its own directory, recursively delete the directory.
|
234 |
+
if ( strpos( $plugin, '/' ) && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory separator AND that it's not the root plugin folder
|
235 |
+
$deleted = $wp_filesystem->delete( $this_plugin_dir, true );
|
236 |
+
else
|
237 |
+
$deleted = $wp_filesystem->delete( $plugins_dir . $plugin );
|
238 |
+
|
239 |
+
if ( $deleted ) {
|
240 |
+
if ( $current = get_site_transient('update_plugins') ) {
|
241 |
+
unset( $current->response[$plugin] );
|
242 |
+
set_site_transient('update_plugins', $current);
|
243 |
+
}
|
244 |
+
return array( 'status' => 'success' );
|
245 |
+
} else {
|
246 |
+
return array( 'status' => 'error', 'error' => 'Plugin uninstalled, but not deleted.' );
|
247 |
+
}
|
248 |
+
|
249 |
+
}
|
250 |
+
|
251 |
/**
|
252 |
* Check if the site can support plugin upgrades
|
253 |
*
|
296 |
return false;
|
297 |
|
298 |
$version_data = GFCommon::get_version_info();
|
299 |
+
$gravity_forms_update = RGForms::premium_update_push( array() );
|
300 |
+
$plugin_data = reset( $gravity_forms_update );
|
301 |
|
302 |
if ( empty( $version_data['url'] ) || empty( $version_data['is_valid_key'] ) || empty( $plugin_data['new_version'] ) || empty( $plugin_data['PluginURI'] ) || empty( $plugin_data['slug'] ) )
|
303 |
return false;
|
wprp.themes.php
CHANGED
@@ -41,7 +41,7 @@ function _wprp_get_themes() {
|
|
41 |
else
|
42 |
$current = get_option( 'update_themes' );
|
43 |
|
44 |
-
foreach ( (array) $themes as $theme ) {
|
45 |
|
46 |
// WordPress 3.4+
|
47 |
if ( is_object( $theme ) && is_a( $theme, 'WP_Theme' ) ) {
|
@@ -49,40 +49,39 @@ function _wprp_get_themes() {
|
|
49 |
$new_version = isset( $current->response[$theme['Template']] ) ? $current->response[$theme['Template']]['new_version'] : null;
|
50 |
|
51 |
$theme_array = array(
|
52 |
-
'Name'
|
53 |
-
'Template'
|
54 |
-
'active'
|
55 |
-
'
|
56 |
-
'
|
57 |
-
'
|
58 |
-
'
|
59 |
-
'
|
60 |
-
'Author' => $theme->get( 'Author' ),
|
61 |
'latest_version' => $new_version ? $new_version : $theme->get( 'Version' ),
|
62 |
-
'Version'
|
63 |
-
'ThemeURI'
|
64 |
);
|
65 |
|
66 |
-
$themes[$
|
67 |
|
68 |
} else {
|
69 |
|
70 |
$new_version = isset( $current->response[$theme['Template']] ) ? $current->response[$theme['Template']]['new_version'] : null;
|
71 |
|
72 |
if ( $active == $theme['Name'] )
|
73 |
-
$themes[$
|
74 |
|
75 |
else
|
76 |
-
$themes[$
|
77 |
|
78 |
if ( $new_version ) {
|
79 |
|
80 |
-
$themes[$
|
81 |
-
$themes[$
|
82 |
|
83 |
} else {
|
84 |
|
85 |
-
$themes[$
|
86 |
|
87 |
}
|
88 |
}
|
@@ -91,13 +90,72 @@ function _wprp_get_themes() {
|
|
91 |
return $themes;
|
92 |
}
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
/**
|
95 |
* Update a theme
|
96 |
*
|
97 |
* @param mixed $theme
|
98 |
* @return array
|
99 |
*/
|
100 |
-
function
|
101 |
|
102 |
include_once ( ABSPATH . 'wp-admin/includes/admin.php' );
|
103 |
|
@@ -132,6 +190,42 @@ function _wprp_upgrade_theme( $theme ) {
|
|
132 |
|
133 |
}
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
/**
|
136 |
* Check if the site can support theme upgrades
|
137 |
*
|
41 |
else
|
42 |
$current = get_option( 'update_themes' );
|
43 |
|
44 |
+
foreach ( (array) $themes as $key => $theme ) {
|
45 |
|
46 |
// WordPress 3.4+
|
47 |
if ( is_object( $theme ) && is_a( $theme, 'WP_Theme' ) ) {
|
49 |
$new_version = isset( $current->response[$theme['Template']] ) ? $current->response[$theme['Template']]['new_version'] : null;
|
50 |
|
51 |
$theme_array = array(
|
52 |
+
'Name' => $theme->get( 'Name' ),
|
53 |
+
'Template' => $theme->get( 'Template' ),
|
54 |
+
'active' => $active == $theme->get( 'Name' ),
|
55 |
+
'Template' => $theme->get_template(),
|
56 |
+
'Stylesheet' => $theme->get_stylesheet(),
|
57 |
+
'Screenshot' => $theme->get_screenshot(),
|
58 |
+
'AuthorURI' => $theme->get( 'AuthorURI' ),
|
59 |
+
'Author' => $theme->get( 'Author' ),
|
|
|
60 |
'latest_version' => $new_version ? $new_version : $theme->get( 'Version' ),
|
61 |
+
'Version' => $theme->get( 'Version' ),
|
62 |
+
'ThemeURI' => $theme->get( 'ThemeURI' )
|
63 |
);
|
64 |
|
65 |
+
$themes[$key] = $theme_array;
|
66 |
|
67 |
} else {
|
68 |
|
69 |
$new_version = isset( $current->response[$theme['Template']] ) ? $current->response[$theme['Template']]['new_version'] : null;
|
70 |
|
71 |
if ( $active == $theme['Name'] )
|
72 |
+
$themes[$key]['active'] = true;
|
73 |
|
74 |
else
|
75 |
+
$themes[$key]['active'] = false;
|
76 |
|
77 |
if ( $new_version ) {
|
78 |
|
79 |
+
$themes[$key]['latest_version'] = $new_version;
|
80 |
+
$themes[$key]['latest_package'] = $current->response[$theme['Template']]['package'];
|
81 |
|
82 |
} else {
|
83 |
|
84 |
+
$themes[$key]['latest_version'] = $theme['Version'];
|
85 |
|
86 |
}
|
87 |
}
|
90 |
return $themes;
|
91 |
}
|
92 |
|
93 |
+
/**
|
94 |
+
* Install a theme
|
95 |
+
*
|
96 |
+
* @param mixed $theme
|
97 |
+
* @param array $args
|
98 |
+
* @return array|bool
|
99 |
+
*/
|
100 |
+
function _wprp_install_theme( $theme, $args = array() ) {
|
101 |
+
|
102 |
+
if ( wp_get_theme( $theme )->exists() )
|
103 |
+
return array( 'status' => 'error', 'error' => 'Theme is already installed.' );
|
104 |
+
|
105 |
+
include_once ABSPATH . 'wp-admin/includes/admin.php';
|
106 |
+
include_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
107 |
+
include_once ABSPATH . 'wp-includes/update.php';
|
108 |
+
|
109 |
+
// Access the themes_api() helper function
|
110 |
+
include_once ABSPATH . 'wp-admin/includes/theme-install.php';
|
111 |
+
$api_args = array(
|
112 |
+
'slug' => $theme,
|
113 |
+
'fields' => array( 'sections' => false )
|
114 |
+
);
|
115 |
+
$api = themes_api( 'theme_information', $api_args );
|
116 |
+
|
117 |
+
if ( is_wp_error( $api ) )
|
118 |
+
return array( 'status' => 'error', 'error' => $api->get_error_code() );
|
119 |
+
|
120 |
+
$skin = new WPRP_Theme_Upgrader_Skin();
|
121 |
+
$upgrader = new Theme_Upgrader( $skin );
|
122 |
+
|
123 |
+
// The best way to get a download link for a specific version :(
|
124 |
+
// Fortunately, we can depend on a relatively consistent naming pattern
|
125 |
+
if ( ! empty( $args['version'] ) && 'stable' != $args['version'] )
|
126 |
+
$api->download_link = str_replace( $api->version . '.zip', $args['version'] . '.zip', $api->download_link );
|
127 |
+
|
128 |
+
$result = $upgrader->install( $api->download_link );
|
129 |
+
if ( is_wp_error( $result ) )
|
130 |
+
return $result;
|
131 |
+
else if ( ! $result )
|
132 |
+
return array( 'status' => 'error', 'error' => 'Unknown error installing theme.' );
|
133 |
+
|
134 |
+
return array( 'status' => 'success' );
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Activate a theme
|
139 |
+
*
|
140 |
+
* @param mixed $theme
|
141 |
+
* @return array
|
142 |
+
*/
|
143 |
+
function _wprp_activate_theme( $theme ) {
|
144 |
+
|
145 |
+
if ( ! wp_get_theme( $theme )->exists() )
|
146 |
+
return array( 'status' => 'error', 'error' => 'Theme is not installed.' );
|
147 |
+
|
148 |
+
switch_theme( $theme );
|
149 |
+
return array( 'status' => 'success' );
|
150 |
+
}
|
151 |
+
|
152 |
/**
|
153 |
* Update a theme
|
154 |
*
|
155 |
* @param mixed $theme
|
156 |
* @return array
|
157 |
*/
|
158 |
+
function _wprp_update_theme( $theme ) {
|
159 |
|
160 |
include_once ( ABSPATH . 'wp-admin/includes/admin.php' );
|
161 |
|
190 |
|
191 |
}
|
192 |
|
193 |
+
/**
|
194 |
+
* Delete a theme.
|
195 |
+
*
|
196 |
+
* @param mixed $theme
|
197 |
+
* @return array
|
198 |
+
*/
|
199 |
+
function _wprp_delete_theme( $theme ) {
|
200 |
+
global $wp_filesystem;
|
201 |
+
|
202 |
+
if ( ! wp_get_theme( $theme )->exists() )
|
203 |
+
return array( 'status' => 'error', 'error' => 'Theme is not installed.' );
|
204 |
+
|
205 |
+
include_once ABSPATH . 'wp-admin/includes/admin.php';
|
206 |
+
include_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
207 |
+
include_once ABSPATH . 'wp-includes/update.php';
|
208 |
+
|
209 |
+
if ( ! _wpr_check_filesystem_access() || ! WP_Filesystem() )
|
210 |
+
return array( 'status' => 'error', 'error' => 'The filesystem is not writable with the supplied credentials' );
|
211 |
+
|
212 |
+
$themes_dir = $wp_filesystem->wp_themes_dir();
|
213 |
+
if ( empty( $themes_dir ) )
|
214 |
+
return array( 'status' => 'error', 'error' => 'Unable to locate WordPress theme directory.' );
|
215 |
+
|
216 |
+
$themes_dir = trailingslashit( $themes_dir );
|
217 |
+
$theme_dir = trailingslashit( $themes_dir . $theme );
|
218 |
+
$deleted = $wp_filesystem->delete( $theme_dir, true );
|
219 |
+
|
220 |
+
if ( ! $deleted )
|
221 |
+
return array( 'status' => 'error', 'error' => sprintf( 'Could not fully delete the theme: %s.', $theme ) );
|
222 |
+
|
223 |
+
// Force refresh of theme update information
|
224 |
+
delete_site_transient('update_themes');
|
225 |
+
|
226 |
+
return array( 'status' => 'success' );
|
227 |
+
}
|
228 |
+
|
229 |
/**
|
230 |
* Check if the site can support theme upgrades
|
231 |
*
|