Version Description
- 18th December 2019 =
- Added - Responsive theme Rollback
- Added - Import Process status Log
Download this release
Release Info
Developer | cyberchimps |
Plugin | Responsive Add Ons |
Version | 2.2.0 |
Comparing to | |
See all releases |
Code changes from version 2.1.1 to 2.2.0
- admin/rollback/class-loader.php +109 -0
- admin/rollback/class-product.php +314 -0
- admin/rollback/class-responsive-plugin-install-helper.php +165 -0
- admin/rollback/class-rollback.php +278 -0
- admin/rollback/common/class-abstract-module.php +46 -0
- admin/rollback/common/class-module-factory.php +57 -0
- admin/rollback/start.php +38 -0
- analytics/includes/analytics-core-functions.php +264 -1
- analytics/includes/class-analytics.php +19 -24
- analytics/templates/forms/deactivation/form.php +2 -2
- includes/importers/batch-processing/class-responsive-ready-sites-batch-processing.php +7 -5
- includes/importers/batch-processing/helpers/class-wp-background-process-responsive.php +3 -1
- includes/importers/class-responsive-ready-sites-importer-log.php +415 -0
- includes/importers/class-responsive-ready-sites-importer.php +35 -12
- includes/importers/wxr-importer/class-responsive-ready-sites-wxr-importer.php +5 -0
- readme.txt +65 -20
- responsive-add-ons.php +50 -6
admin/rollback/class-loader.php
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The main loader class for Responsive
|
4 |
+
*
|
5 |
+
* @package Responsive
|
6 |
+
* @since 3.24
|
7 |
+
*/
|
8 |
+
|
9 |
+
namespace ResponsiveSDK;
|
10 |
+
|
11 |
+
use ResponsiveSDK\Common\Module_Factory;
|
12 |
+
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
14 |
+
exit;
|
15 |
+
}
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Singleton loader for Responsive SDK.
|
20 |
+
*/
|
21 |
+
final class Loader {
|
22 |
+
/**
|
23 |
+
* Singleton instance.
|
24 |
+
*
|
25 |
+
* @var Loader instance The singleton instance
|
26 |
+
*/
|
27 |
+
private static $instance;
|
28 |
+
/**
|
29 |
+
* Current loader version.
|
30 |
+
*
|
31 |
+
* @var string $version The class version.
|
32 |
+
*/
|
33 |
+
private static $version = '3.14';
|
34 |
+
/**
|
35 |
+
* Holds registered products.
|
36 |
+
*
|
37 |
+
* @var array The products which use the SDK.
|
38 |
+
*/
|
39 |
+
private static $products = [];
|
40 |
+
/**
|
41 |
+
* Holds available modules to load.
|
42 |
+
*
|
43 |
+
* @var array The modules which SDK will be using.
|
44 |
+
*/
|
45 |
+
private static $available_modules = [
|
46 |
+
'rollback',
|
47 |
+
|
48 |
+
];
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Initialize the sdk logic.
|
52 |
+
*/
|
53 |
+
public static function init() {
|
54 |
+
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Loader ) ) {
|
55 |
+
self::$instance = new Loader();
|
56 |
+
$modules = array_merge( self::$available_modules, apply_filters( 'responsive_sdk_modules', [] ) );
|
57 |
+
self::$available_modules = $modules;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Register product into SDK.
|
63 |
+
*
|
64 |
+
* @param string $base_file The product base file.
|
65 |
+
*
|
66 |
+
* @return Loader The singleton object.
|
67 |
+
*/
|
68 |
+
public static function add_product( $base_file ) {
|
69 |
+
|
70 |
+
if ( ! is_file( $base_file ) ) {
|
71 |
+
return self::$instance;
|
72 |
+
}
|
73 |
+
$product = new Product( $base_file );
|
74 |
+
|
75 |
+
Module_Factory::attach( $product, self::get_modules() );
|
76 |
+
|
77 |
+
self::$products[ $product->get_slug() ] = $product;
|
78 |
+
|
79 |
+
return self::$instance;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Get all registered modules by the SDK.
|
84 |
+
*
|
85 |
+
* @return array Modules available.
|
86 |
+
*/
|
87 |
+
public static function get_modules() {
|
88 |
+
return self::$available_modules;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Get all products using the SDK.
|
93 |
+
*
|
94 |
+
* @return array Products available.
|
95 |
+
*/
|
96 |
+
public static function get_products() {
|
97 |
+
return self::$products;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Get the version of the SDK.
|
102 |
+
*
|
103 |
+
* @return string The version.
|
104 |
+
*/
|
105 |
+
public static function get_version() {
|
106 |
+
return self::$version;
|
107 |
+
}
|
108 |
+
|
109 |
+
}
|
admin/rollback/class-product.php
ADDED
@@ -0,0 +1,314 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The product model class for Responsive SDK
|
4 |
+
*
|
5 |
+
* @package ResponsiveSDK
|
6 |
+
* @since 3.24
|
7 |
+
*/
|
8 |
+
|
9 |
+
namespace ResponsiveSDK;
|
10 |
+
|
11 |
+
// Exit if accessed directly.
|
12 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
13 |
+
exit;
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Product model for Responsive SDK.
|
18 |
+
*/
|
19 |
+
class Product {
|
20 |
+
/**
|
21 |
+
* Define theme type string.
|
22 |
+
*/
|
23 |
+
const THEME_TYPE = 'theme';
|
24 |
+
/**
|
25 |
+
* Current product slug.
|
26 |
+
*
|
27 |
+
* @var string $slug THe product slug.
|
28 |
+
*/
|
29 |
+
private $slug;
|
30 |
+
/**
|
31 |
+
* Product basefile, with the proper metadata.
|
32 |
+
*
|
33 |
+
* @var string $basefile The file with headers.
|
34 |
+
*/
|
35 |
+
private $basefile;
|
36 |
+
/**
|
37 |
+
* Type of the product.
|
38 |
+
*
|
39 |
+
* @var string $type The product type ( plugin | theme ).
|
40 |
+
*/
|
41 |
+
private $type;
|
42 |
+
/**
|
43 |
+
* The file name.
|
44 |
+
*
|
45 |
+
* @var string $file The file name.
|
46 |
+
*/
|
47 |
+
private $file;
|
48 |
+
/**
|
49 |
+
* Product name, fetched from the file headers.
|
50 |
+
*
|
51 |
+
* @var string $name The product name.
|
52 |
+
*/
|
53 |
+
private $name;
|
54 |
+
/**
|
55 |
+
* Product normalized key.
|
56 |
+
*
|
57 |
+
* @var string $key The product ready key.
|
58 |
+
*/
|
59 |
+
private $key;
|
60 |
+
/**
|
61 |
+
* Product store url.
|
62 |
+
*
|
63 |
+
* @var string $store_url The store url.
|
64 |
+
*/
|
65 |
+
private $store_url;
|
66 |
+
/**
|
67 |
+
* Product install timestamp.
|
68 |
+
*
|
69 |
+
* @var int $install The date of install.
|
70 |
+
*/
|
71 |
+
private $install;
|
72 |
+
/**
|
73 |
+
* Product store/author name.
|
74 |
+
*
|
75 |
+
* @var string $store_name The store name.
|
76 |
+
*/
|
77 |
+
private $store_name;
|
78 |
+
/**
|
79 |
+
* Does the product requires license.
|
80 |
+
*
|
81 |
+
* @var bool $requires_license Either user needs to activate it with license.
|
82 |
+
*/
|
83 |
+
private $requires_license;
|
84 |
+
/**
|
85 |
+
* Is the product available on wordpress.org
|
86 |
+
*
|
87 |
+
* @var bool $wordpress_available Either is available on WordPress or not.
|
88 |
+
*/
|
89 |
+
private $wordpress_available;
|
90 |
+
/**
|
91 |
+
* Current version of the product.
|
92 |
+
*
|
93 |
+
* @var string $version The product version.
|
94 |
+
*/
|
95 |
+
private $version;
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Responsive_SDK_Product constructor.
|
99 |
+
*
|
100 |
+
* @param string $basefile Product basefile.
|
101 |
+
*/
|
102 |
+
public function __construct( $basefile ) {
|
103 |
+
if ( ! empty( $basefile ) ) {
|
104 |
+
if ( is_file( $basefile ) ) {
|
105 |
+
$this->basefile = $basefile;
|
106 |
+
$this->setup_from_path();
|
107 |
+
$this->setup_from_fileheaders();
|
108 |
+
}
|
109 |
+
}
|
110 |
+
$install = get_option( $this->get_key() . '_install', 0 );
|
111 |
+
if ( 0 === $install ) {
|
112 |
+
$install = time();
|
113 |
+
update_option( $this->get_key() . '_install', time() );
|
114 |
+
}
|
115 |
+
$this->install = $install;
|
116 |
+
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Setup props from path.
|
121 |
+
*/
|
122 |
+
public function setup_from_path() {
|
123 |
+
$this->file = basename( $this->basefile );
|
124 |
+
$dir = dirname( $this->basefile );
|
125 |
+
$this->slug = basename( $dir );
|
126 |
+
$exts = explode( '.', $this->basefile );
|
127 |
+
$ext = $exts[ count( $exts ) - 1 ];
|
128 |
+
if ( 'css' === $ext ) {
|
129 |
+
$this->type = 'theme';
|
130 |
+
}
|
131 |
+
if ( 'php' === $ext ) {
|
132 |
+
$this->type = 'plugin';
|
133 |
+
}
|
134 |
+
$this->key = self::key_ready_name( $this->slug );
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Normalize string.
|
139 |
+
*
|
140 |
+
* @param string $string the String to be normalized for cron handler.
|
141 |
+
*
|
142 |
+
* @return string $name The normalized string.
|
143 |
+
*/
|
144 |
+
public static function key_ready_name( $string ) {
|
145 |
+
return str_replace( '-', '_', strtolower( trim( $string ) ) );
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Setup props from fileheaders.
|
150 |
+
*/
|
151 |
+
public function setup_from_fileheaders() {
|
152 |
+
$file_headers = array(
|
153 |
+
'Requires License' => 'Requires License',
|
154 |
+
'WordPress Available' => 'WordPress Available',
|
155 |
+
'Pro Slug' => 'Pro Slug',
|
156 |
+
'Version' => 'Version',
|
157 |
+
);
|
158 |
+
if ( 'plugin' === $this->type ) {
|
159 |
+
$file_headers['Name'] = 'Plugin Name';
|
160 |
+
$file_headers['AuthorName'] = 'Author';
|
161 |
+
$file_headers['AuthorURI'] = 'Author URI';
|
162 |
+
}
|
163 |
+
if ( 'theme' === $this->type ) {
|
164 |
+
$file_headers['Name'] = 'Theme Name';
|
165 |
+
$file_headers['AuthorName'] = 'Author';
|
166 |
+
$file_headers['AuthorURI'] = 'Author URI';
|
167 |
+
}
|
168 |
+
$file_headers = get_file_data( $this->basefile, $file_headers );
|
169 |
+
|
170 |
+
$this->name = $file_headers['Name'];
|
171 |
+
$this->store_name = $file_headers['AuthorName'];
|
172 |
+
$this->author_url = $file_headers['AuthorURI'];
|
173 |
+
$this->store_url = $file_headers['AuthorURI'];
|
174 |
+
|
175 |
+
$this->wordpress_available = ( 'yes' === $file_headers['WordPress Available'] ) ? true : false;
|
176 |
+
$this->version = $file_headers['Version'];
|
177 |
+
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Return the product key.
|
182 |
+
*
|
183 |
+
* @return string The product key.
|
184 |
+
*/
|
185 |
+
public function get_key() {
|
186 |
+
return $this->key;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Check if the product is either theme or plugin.
|
191 |
+
*
|
192 |
+
* @return string Product type.
|
193 |
+
*/
|
194 |
+
public function get_type() {
|
195 |
+
return $this->type;
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Return if the product is used as a theme.
|
200 |
+
*
|
201 |
+
* @return bool Is theme ?
|
202 |
+
*/
|
203 |
+
public function is_theme() {
|
204 |
+
return self::THEME_TYPE === $this->type;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Returns the product slug.
|
209 |
+
*
|
210 |
+
* @return string The product slug.
|
211 |
+
*/
|
212 |
+
public function get_slug() {
|
213 |
+
return $this->slug;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* The magic var_dump info method.
|
218 |
+
*
|
219 |
+
* @return array Debug info.
|
220 |
+
*/
|
221 |
+
public function __debugInfo() {
|
222 |
+
return array(
|
223 |
+
'name' => $this->name,
|
224 |
+
'slug' => $this->slug,
|
225 |
+
'version' => $this->version,
|
226 |
+
'basefile' => $this->basefile,
|
227 |
+
'key' => $this->key,
|
228 |
+
'type' => $this->type,
|
229 |
+
'store_name' => $this->store_name,
|
230 |
+
'store_url' => $this->store_url,
|
231 |
+
'wordpress_available' => $this->wordpress_available,
|
232 |
+
);
|
233 |
+
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Getter for product version.
|
238 |
+
*
|
239 |
+
* @return string The product version.
|
240 |
+
*/
|
241 |
+
public function get_version() {
|
242 |
+
return $this->version;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* If product is available on wordpress.org or not.
|
247 |
+
*
|
248 |
+
* @return bool Either is wp available or not.
|
249 |
+
*/
|
250 |
+
public function is_wordpress_available() {
|
251 |
+
return $this->wordpress_available;
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Return friendly name.
|
256 |
+
*
|
257 |
+
* @return string Friendly name.
|
258 |
+
*/
|
259 |
+
public function get_friendly_name() {
|
260 |
+
$name = apply_filters( $this->get_key() . '_friendly_name', trim( str_replace( 'Lite', '', $this->get_name() ) ) );
|
261 |
+
$name = rtrim( $name, '- ()' );
|
262 |
+
|
263 |
+
return $name;
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Getter for product name.
|
268 |
+
*
|
269 |
+
* @return string The product name.
|
270 |
+
*/
|
271 |
+
public function get_name() {
|
272 |
+
return $this->name;
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Returns product basefile, which holds the metaheaders.
|
277 |
+
*
|
278 |
+
* @return string The product basefile.
|
279 |
+
*/
|
280 |
+
public function get_basefile() {
|
281 |
+
return $this->basefile;
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Returns product filename.
|
286 |
+
*
|
287 |
+
* @return string The product filename.
|
288 |
+
*/
|
289 |
+
public function get_file() {
|
290 |
+
return $this->file;
|
291 |
+
}
|
292 |
+
/**
|
293 |
+
* Return the install timestamp.
|
294 |
+
*
|
295 |
+
* @return int The install timestamp.
|
296 |
+
*/
|
297 |
+
public function get_install_time() {
|
298 |
+
return $this->install;
|
299 |
+
}
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Returns the URL of the product base file.
|
303 |
+
*
|
304 |
+
* @param string $path The path to the file.
|
305 |
+
*
|
306 |
+
* @return string The URL of the product base file.
|
307 |
+
*/
|
308 |
+
public function get_base_url( $path = '/' ) {
|
309 |
+
if ( $this->type ) {
|
310 |
+
return plugins_url( $path, $this->basefile );
|
311 |
+
}
|
312 |
+
}
|
313 |
+
|
314 |
+
}
|
admin/rollback/class-responsive-plugin-install-helper.php
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin install helper.
|
4 |
+
*
|
5 |
+
* @package Responsive
|
6 |
+
* @since Responsive 1.1.31
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class Responsive_Plugin_Install_Helper
|
11 |
+
*/
|
12 |
+
class Responsive_Plugin_Install_Helper {
|
13 |
+
/**
|
14 |
+
* Instance of class.
|
15 |
+
*
|
16 |
+
* @var bool $instance instance variable.
|
17 |
+
*/
|
18 |
+
private static $instance;
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Check if instance already exists.
|
23 |
+
*
|
24 |
+
* @return Responsive_Plugin_Install_Helper
|
25 |
+
*/
|
26 |
+
public static function instance() {
|
27 |
+
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Responsive_Plugin_Install_Helper ) ) {
|
28 |
+
self::$instance = new Responsive_Plugin_Install_Helper();
|
29 |
+
}
|
30 |
+
return self::$instance;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Get plugin path based on plugin slug.
|
35 |
+
*
|
36 |
+
* @param string $slug Plugin slug.
|
37 |
+
*
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
public static function get_plugin_path( $slug ) {
|
41 |
+
switch ( $slug ) {
|
42 |
+
case 'wplegalpages':
|
43 |
+
return $slug . '/wplegalpages.php';
|
44 |
+
case 'gdpr-cookie-consent':
|
45 |
+
return $slug . '/gdpr-cookie-consent.php';
|
46 |
+
default:
|
47 |
+
return $slug . '/' . $slug . '.php';
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Generate action button html.
|
53 |
+
*
|
54 |
+
* @param string $slug plugin slug.
|
55 |
+
* @param array $settings settings.
|
56 |
+
*
|
57 |
+
* @return string
|
58 |
+
*/
|
59 |
+
public function get_button_html( $slug, $settings = array() ) {
|
60 |
+
$button = '';
|
61 |
+
$redirect = '';
|
62 |
+
if ( ! empty( $settings ) && array_key_exists( 'redirect', $settings ) ) {
|
63 |
+
$redirect = $settings['redirect'];
|
64 |
+
}
|
65 |
+
$state = $this->check_plugin_state( $slug );
|
66 |
+
if ( empty( $slug ) ) {
|
67 |
+
return '';
|
68 |
+
}
|
69 |
+
|
70 |
+
$additional = '';
|
71 |
+
|
72 |
+
if ( 'deactivate' === $state ) {
|
73 |
+
$additional = ' action_button active';
|
74 |
+
}
|
75 |
+
|
76 |
+
$button .= '<div class=" plugin-card-' . esc_attr( $slug ) . esc_attr( $additional ) . '" style="padding: 8px 0 5px;">';
|
77 |
+
|
78 |
+
$plugin_link_suffix = self::get_plugin_path( $slug );
|
79 |
+
|
80 |
+
$nonce = add_query_arg(
|
81 |
+
array(
|
82 |
+
'action' => 'activate',
|
83 |
+
'plugin' => rawurlencode( $plugin_link_suffix ),
|
84 |
+
'plugin_status' => 'all',
|
85 |
+
'paged' => '1',
|
86 |
+
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $plugin_link_suffix ),
|
87 |
+
),
|
88 |
+
network_admin_url( 'plugins.php' )
|
89 |
+
);
|
90 |
+
switch ( $state ) {
|
91 |
+
case 'install':
|
92 |
+
$button .= '<a data-redirect="' . esc_url( $redirect ) . '" data-slug="' . esc_attr( $slug ) . '" class="install-now responsive-install-plugin button " href="' . esc_url( $nonce ) . '" data-name="' . esc_attr( $slug ) . '" aria-label="Install ' . esc_attr( $slug ) . '">' . __( 'Install and activate', 'responsive' ) . '</a>';
|
93 |
+
break;
|
94 |
+
|
95 |
+
case 'activate':
|
96 |
+
$button .= '<a data-redirect="' . esc_url( $redirect ) . '" data-slug="' . esc_attr( $slug ) . '" class="activate-now button button-primary" href="' . esc_url( $nonce ) . '" aria-label="Activate ' . esc_attr( $slug ) . '">' . esc_html__( 'Activate', 'responsive' ) . '</a>';
|
97 |
+
break;
|
98 |
+
|
99 |
+
case 'deactivate':
|
100 |
+
$nonce = add_query_arg(
|
101 |
+
array(
|
102 |
+
'action' => 'deactivate',
|
103 |
+
'plugin' => rawurlencode( $plugin_link_suffix ),
|
104 |
+
'plugin_status' => 'all',
|
105 |
+
'paged' => '1',
|
106 |
+
'_wpnonce' => wp_create_nonce( 'deactivate-plugin_' . $plugin_link_suffix ),
|
107 |
+
),
|
108 |
+
network_admin_url( 'plugins.php' )
|
109 |
+
);
|
110 |
+
|
111 |
+
$button .= '<a data-redirect="' . esc_url( $redirect ) . '" data-slug="' . esc_attr( $slug ) . '" class="deactivate-now button" href="' . esc_url( $nonce ) . '" data-name="' . esc_attr( $slug ) . '" aria-label="Deactivate ' . esc_attr( $slug ) . '">' . esc_html__( 'Deactivate', 'responsive' ) . '</a>';
|
112 |
+
break;
|
113 |
+
|
114 |
+
case 'enable_cpt':
|
115 |
+
$url = admin_url( 'admin.php?page=jetpack#/settings' );
|
116 |
+
$button .= '<a data-redirect="' . esc_url( $redirect ) . '" class="button" href="' . esc_url( $url ) . '">' . esc_html__( 'Activate', 'responsive' ) . ' ' . esc_html__( 'Jetpack Portfolio', 'responsive' ) . '</a>';
|
117 |
+
break;
|
118 |
+
} // End switch.
|
119 |
+
$button .= '</div>';
|
120 |
+
return $button;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Check plugin state.
|
125 |
+
*
|
126 |
+
* @param string $slug plugin slug.
|
127 |
+
*
|
128 |
+
* @return bool
|
129 |
+
*/
|
130 |
+
public function check_plugin_state( $slug ) {
|
131 |
+
$plugin_link_suffix = self::get_plugin_path( $slug );
|
132 |
+
|
133 |
+
if ( file_exists( ABSPATH . 'wp-content/plugins/' . $plugin_link_suffix ) ) {
|
134 |
+
$needs = is_plugin_active( $plugin_link_suffix ) ? 'deactivate' : 'activate';
|
135 |
+
if ( 'deactivate' === $needs && ! post_type_exists( 'portfolio' ) && 'jetpack' === $slug ) {
|
136 |
+
return 'enable_cpt';
|
137 |
+
}
|
138 |
+
|
139 |
+
return $needs;
|
140 |
+
} else {
|
141 |
+
return 'install';
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Enqueue Function.
|
147 |
+
*/
|
148 |
+
public function enqueue_scripts() {
|
149 |
+
wp_enqueue_script( 'plugin-install' );
|
150 |
+
wp_enqueue_script( 'updates' );
|
151 |
+
wp_enqueue_script( 'responsive-plugin-install-helper', get_template_directory_uri() . '/inc/customizer/controls/ui/helper-plugin-install/helper-script.js', array( 'jquery' ), RESPONSIVE_THEME_VERSION, true );
|
152 |
+
wp_localize_script(
|
153 |
+
'responsive-plugin-install-helper',
|
154 |
+
'responsive_plugin_helper',
|
155 |
+
array(
|
156 |
+
'activating' => esc_html__( 'Activating ', 'responsive' ),
|
157 |
+
)
|
158 |
+
);
|
159 |
+
wp_localize_script(
|
160 |
+
'responsive-plugin-install-helper',
|
161 |
+
'pagenow',
|
162 |
+
array( 'import' )
|
163 |
+
);
|
164 |
+
}
|
165 |
+
}
|
admin/rollback/class-rollback.php
ADDED
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The rollback class for Responsive SDK.
|
4 |
+
*
|
5 |
+
* @package ResponsiveSDK
|
6 |
+
* @since 3.24
|
7 |
+
*/
|
8 |
+
|
9 |
+
namespace ResponsiveSDK\Modules;
|
10 |
+
|
11 |
+
// Exit if accessed directly.
|
12 |
+
use ResponsiveSDK\Common\Abstract_Module;
|
13 |
+
use ResponsiveSDK\Product;
|
14 |
+
|
15 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
16 |
+
exit;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Rollback for Responsive SDK.
|
21 |
+
*/
|
22 |
+
class Rollback extends Abstract_Module {
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Add js scripts for themes rollback.
|
26 |
+
*/
|
27 |
+
public function add_footer() {
|
28 |
+
$screen = get_current_screen();
|
29 |
+
if ( ! isset( $screen->parent_file ) ) {
|
30 |
+
return;
|
31 |
+
}
|
32 |
+
if ( 'themes.php' !== $screen->parent_file ) {
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
if ( ! $this->product->is_theme() ) {
|
36 |
+
return;
|
37 |
+
}
|
38 |
+
$version = $this->get_rollback();
|
39 |
+
if ( empty( $version ) ) {
|
40 |
+
return;
|
41 |
+
}
|
42 |
+
?>
|
43 |
+
<script type="text/javascript">
|
44 |
+
jQuery(document).ready(function ($) {
|
45 |
+
setInterval(checkTheme, 500);
|
46 |
+
|
47 |
+
function checkTheme() {
|
48 |
+
var theme = '<?php echo esc_attr( $this->product->get_slug() ); ?>-action';
|
49 |
+
|
50 |
+
if (jQuery('#' + theme).length > 0) {
|
51 |
+
if (jQuery('.theme-overlay.active').is(':visible')) {
|
52 |
+
if (jQuery('#' + theme + '-rollback').length === 0) {
|
53 |
+
jQuery('.theme-actions .active-theme').prepend('<a class="button" style="float:left" id="' + theme + '-rollback" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin-post.php?action=' . $this->product->get_key() . '_rollback' ), $this->product->get_key() . '_rollback' ) ); ?>">Rollback to v<?php echo esc_attr( $version['version'] ); ?></a>')
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
58 |
+
}
|
59 |
+
})
|
60 |
+
|
61 |
+
</script>
|
62 |
+
<?php
|
63 |
+
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Get the last rollback for this product.
|
68 |
+
*
|
69 |
+
* @return array The rollback version.
|
70 |
+
*/
|
71 |
+
public function get_rollback() {
|
72 |
+
$rollback = array();
|
73 |
+
$versions = $this->get_api_versions();
|
74 |
+
$versions = apply_filters( $this->product->get_key() . '_rollbacks', $versions );
|
75 |
+
if ( empty( $versions ) ) {
|
76 |
+
return $rollback;
|
77 |
+
}
|
78 |
+
if ( $versions ) {
|
79 |
+
usort( $versions, array( $this, 'sort_rollback_array' ) );
|
80 |
+
foreach ( $versions as $version ) {
|
81 |
+
if ( isset( $version['version'] ) && isset( $version['url'] ) && version_compare( $this->product->get_version(), $version['version'], '>' ) ) {
|
82 |
+
$rollback = $version;
|
83 |
+
break;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
return $rollback;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Get versions array from wp.org
|
92 |
+
*
|
93 |
+
* @return array Array of versions.
|
94 |
+
*/
|
95 |
+
private function get_api_versions() {
|
96 |
+
$cache_key = $this->product->get_key() . '_' . preg_replace( '/[^0-9a-zA-Z ]/m', '', $this->product->get_version() ) . 'versions';
|
97 |
+
$cache_versions = get_transient( $cache_key );
|
98 |
+
if ( false === $cache_versions ) {
|
99 |
+
$versions = $this->get_remote_versions();
|
100 |
+
set_transient( $cache_key, $versions, 5 * DAY_IN_SECONDS );
|
101 |
+
} else {
|
102 |
+
$versions = is_array( $cache_versions ) ? $cache_versions : array();
|
103 |
+
}
|
104 |
+
|
105 |
+
return $versions;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Get remote versions zips.
|
110 |
+
*
|
111 |
+
* @return array Array of available versions.
|
112 |
+
*/
|
113 |
+
private function get_remote_versions() {
|
114 |
+
$url = $this->get_versions_api_url();
|
115 |
+
|
116 |
+
if ( empty( $url ) ) {
|
117 |
+
return [];
|
118 |
+
}
|
119 |
+
$response = wp_remote_get( $url );
|
120 |
+
if ( is_wp_error( $response ) ) {
|
121 |
+
return array();
|
122 |
+
}
|
123 |
+
$response = wp_remote_retrieve_body( $response );
|
124 |
+
|
125 |
+
if ( is_serialized( $response ) ) {
|
126 |
+
$response = maybe_unserialize( $response );
|
127 |
+
} else {
|
128 |
+
$response = json_decode( $response );
|
129 |
+
}
|
130 |
+
|
131 |
+
if ( ! is_object( $response ) ) {
|
132 |
+
return array();
|
133 |
+
}
|
134 |
+
if ( ! isset( $response->versions ) ) {
|
135 |
+
return array();
|
136 |
+
}
|
137 |
+
|
138 |
+
$versions = array();
|
139 |
+
foreach ( $response->versions as $key => $value ) {
|
140 |
+
$versions[] = array(
|
141 |
+
'version' => is_object( $value ) ? $value->version : $key,
|
142 |
+
'url' => is_object( $value ) ? $value->file : $value,
|
143 |
+
);
|
144 |
+
}
|
145 |
+
|
146 |
+
return $versions;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Return url where to check for versions.
|
151 |
+
*
|
152 |
+
* @return string Url where to check for versions.
|
153 |
+
*/
|
154 |
+
private function get_versions_api_url() {
|
155 |
+
if ( $this->product->is_theme() ) {
|
156 |
+
return sprintf( 'https://api.wordpress.org/themes/info/1.1/?action=theme_information&request[slug]=%s&request[fields][versions]=true', $this->product->get_slug() );
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Start the rollback operation.
|
162 |
+
*/
|
163 |
+
public function start_rollback() {
|
164 |
+
if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], $this->product->get_key() . '_rollback' ) ) {
|
165 |
+
wp_nonce_ays( '' );
|
166 |
+
}
|
167 |
+
|
168 |
+
if ( $this->product->is_theme() ) {
|
169 |
+
$this->start_rollback_theme();
|
170 |
+
|
171 |
+
return;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Start the rollback operation for the theme.
|
178 |
+
*/
|
179 |
+
private function start_rollback_theme() {
|
180 |
+
add_filter( 'update_theme_complete_actions', array( $this, 'alter_links_theme_upgrade' ) );
|
181 |
+
$rollback = $this->get_rollback();
|
182 |
+
$transient = get_site_transient( 'update_themes' );
|
183 |
+
$folder = $this->product->get_slug();
|
184 |
+
$version = $rollback['version'];
|
185 |
+
$temp_array = array(
|
186 |
+
'new_version' => $version,
|
187 |
+
'package' => $rollback['url'],
|
188 |
+
);
|
189 |
+
|
190 |
+
$transient->response[ $folder . '/style.css' ] = $temp_array;
|
191 |
+
set_site_transient( 'update_themes', $transient );
|
192 |
+
|
193 |
+
$transient = get_transient( $this->product->get_key() . '_warning_rollback' );
|
194 |
+
|
195 |
+
if ( false === $transient ) {
|
196 |
+
set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 );
|
197 |
+
require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
|
198 |
+
$title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version );
|
199 |
+
$theme = $folder . '/style.css';
|
200 |
+
$nonce = 'upgrade-theme_' . $theme;
|
201 |
+
$url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme );
|
202 |
+
|
203 |
+
$upgrader = new \Theme_Upgrader( new \Theme_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'theme' ) ) );
|
204 |
+
$upgrader->upgrade( $theme );
|
205 |
+
delete_transient( $this->product->get_key() . '_warning_rollback' );
|
206 |
+
wp_die(
|
207 |
+
'',
|
208 |
+
$title,
|
209 |
+
array(
|
210 |
+
'response' => 200,
|
211 |
+
)
|
212 |
+
);
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Alter links and remove duplicate customize message.
|
218 |
+
*
|
219 |
+
* @param array $links Array of old links.
|
220 |
+
*
|
221 |
+
* @return mixed Array of links.
|
222 |
+
*/
|
223 |
+
public function alter_links_theme_upgrade( $links ) {
|
224 |
+
if ( isset( $links['preview'] ) ) {
|
225 |
+
$links['preview'] = str_replace( '<span aria-hidden="true">Customize</span>', '', $links['preview'] );
|
226 |
+
}
|
227 |
+
|
228 |
+
return $links;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Loads product object.
|
233 |
+
*
|
234 |
+
* @param Product $product Product object.
|
235 |
+
*
|
236 |
+
* @return bool Should we load the module?
|
237 |
+
*/
|
238 |
+
public function can_load( $product ) {
|
239 |
+
if ( $product->is_theme() && ! current_user_can( 'switch_themes' ) ) {
|
240 |
+
return false;
|
241 |
+
}
|
242 |
+
return true;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Sort the rollbacks array in descending order.
|
247 |
+
*
|
248 |
+
* @param mixed $a First version to compare.
|
249 |
+
* @param mixed $b Second version to compare.
|
250 |
+
*
|
251 |
+
* @return bool Which version is greater?
|
252 |
+
*/
|
253 |
+
public function sort_rollback_array( $a, $b ) {
|
254 |
+
return version_compare( $a['version'], $b['version'], '<' ) > 0;
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Load module logic.
|
259 |
+
*
|
260 |
+
* @param Product $product Product object.
|
261 |
+
*
|
262 |
+
* @return $this Module object.
|
263 |
+
*/
|
264 |
+
public function load( $product ) {
|
265 |
+
$this->product = $product;
|
266 |
+
$this->add_hooks();
|
267 |
+
|
268 |
+
return $this;
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Set the rollback hook. Strangely, this does not work if placed in the Responsive_SDK_Rollback class, so it is being called from there instead.
|
273 |
+
*/
|
274 |
+
public function add_hooks() {
|
275 |
+
add_action( 'admin_post_' . $this->product->get_key() . '_rollback', array( $this, 'start_rollback' ) );
|
276 |
+
add_action( 'admin_footer', array( $this, 'add_footer' ) );
|
277 |
+
}
|
278 |
+
}
|
admin/rollback/common/class-abstract-module.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The abstract class for module definition.
|
4 |
+
*
|
5 |
+
* @package ResponsiveSDK
|
6 |
+
* @since 3.24
|
7 |
+
*/
|
8 |
+
|
9 |
+
namespace ResponsiveSDK\Common;
|
10 |
+
|
11 |
+
use ResponsiveSDK\Product;
|
12 |
+
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
14 |
+
exit;
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Class Abstract_Module.
|
19 |
+
*
|
20 |
+
* @package ResponsiveSDK\Common
|
21 |
+
*/
|
22 |
+
abstract class Abstract_Module {
|
23 |
+
/**
|
24 |
+
* Product which use the module.
|
25 |
+
*
|
26 |
+
* @var Product $product Product object.
|
27 |
+
*/
|
28 |
+
protected $product = null;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Can load the module for the selected product.
|
32 |
+
*
|
33 |
+
* @param Product $product Product data.
|
34 |
+
*
|
35 |
+
* @return bool Should load module?
|
36 |
+
*/
|
37 |
+
public abstract function can_load( $product );
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Bootstrap the module.
|
41 |
+
*
|
42 |
+
* @param Product $product Product object.
|
43 |
+
*/
|
44 |
+
public abstract function load( $product );
|
45 |
+
|
46 |
+
}
|
admin/rollback/common/class-module-factory.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The module factory class.
|
4 |
+
*
|
5 |
+
* @package ResponsiveSDK
|
6 |
+
* @since 3.24
|
7 |
+
*/
|
8 |
+
|
9 |
+
namespace ResponsiveSDK\Common;
|
10 |
+
|
11 |
+
use ResponsiveSDK\Product;
|
12 |
+
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
14 |
+
exit;
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Class Job_Factory
|
19 |
+
*
|
20 |
+
* @package ResponsiveSDK\Common
|
21 |
+
*/
|
22 |
+
class Module_Factory {
|
23 |
+
/**
|
24 |
+
* Map which contains all the modules loaded for each product.
|
25 |
+
*
|
26 |
+
* @var array Mapping array.
|
27 |
+
*/
|
28 |
+
private static $modules_attached = [];
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Load availabe modules for the selected product.
|
32 |
+
*
|
33 |
+
* @param Product $product Loaded product.
|
34 |
+
* @param array $modules List of modules.
|
35 |
+
*/
|
36 |
+
public static function attach( $product, $modules ) {
|
37 |
+
|
38 |
+
if ( ! isset( self::$modules_attached[ $product->get_slug() ] ) ) {
|
39 |
+
self::$modules_attached[ $product->get_slug() ] = [];
|
40 |
+
}
|
41 |
+
|
42 |
+
foreach ( $modules as $module ) {
|
43 |
+
$class = 'ResponsiveSDK\\Modules\\' . ucwords( $module, '_' );
|
44 |
+
/**
|
45 |
+
* Module object.
|
46 |
+
*
|
47 |
+
* @var Abstract_Module $module_object Module instance.
|
48 |
+
*/
|
49 |
+
$module_object = new $class( $product );
|
50 |
+
|
51 |
+
if ( ! $module_object->can_load( $product ) ) {
|
52 |
+
continue;
|
53 |
+
}
|
54 |
+
self::$modules_attached[ $product->get_slug() ][ $module ] = $module_object->load( $product );
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
admin/rollback/start.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* File responsible for sdk files loading.
|
4 |
+
*
|
5 |
+
* @package Responsive
|
6 |
+
* @since 3.24
|
7 |
+
*/
|
8 |
+
|
9 |
+
namespace ResponsiveSDK;
|
10 |
+
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
}
|
14 |
+
if ( ! class_exists( 'Responsive_Plugin_Install_Helper' ) ) {
|
15 |
+
require_once dirname( __FILE__ ) . '/class-responsive-plugin-install-helper.php';
|
16 |
+
}
|
17 |
+
$products = apply_filters( 'responsive_sdk_products', array() );
|
18 |
+
$diretory_path = dirname( __FILE__ );
|
19 |
+
$files_to_load = [
|
20 |
+
$diretory_path . '/class-loader.php',
|
21 |
+
$diretory_path . '/class-product.php',
|
22 |
+
$diretory_path . '/common/class-abstract-module.php',
|
23 |
+
$diretory_path . '/common/class-module-factory.php',
|
24 |
+
$diretory_path . '/class-rollback.php',
|
25 |
+
];
|
26 |
+
$files_to_load = array_merge( $files_to_load, apply_filters( 'responsive_sdk_required_files', [] ) );
|
27 |
+
|
28 |
+
foreach ( $files_to_load as $file ) {
|
29 |
+
if ( is_file( $file ) ) {
|
30 |
+
include $file;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
Loader::init();
|
35 |
+
|
36 |
+
foreach ( $products as $product ) {
|
37 |
+
Loader::add_product( $product );
|
38 |
+
}
|
analytics/includes/analytics-core-functions.php
CHANGED
@@ -241,6 +241,269 @@ if ( ! function_exists( 'as_enqueue_local_style' ) ) {
|
|
241 |
* @param string $media Media.
|
242 |
*/
|
243 |
function as_enqueue_local_style( $handle, $path, $deps = array(), $ver = false, $media = 'all' ) {
|
244 |
-
wp_enqueue_style( $handle, as_asset_url( WP_STAT__DIR_CSS . '/' . trim( $path, '/' ) ), $deps,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
}
|
246 |
}
|
241 |
* @param string $media Media.
|
242 |
*/
|
243 |
function as_enqueue_local_style( $handle, $path, $deps = array(), $ver = false, $media = 'all' ) {
|
244 |
+
wp_enqueue_style( $handle, as_asset_url( WP_STAT__DIR_CSS . '/' . trim( $path, '/' ) ), $deps, '1.2.2', $media );
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
if ( ! function_exists( '_as_text_inline' ) ) {
|
249 |
+
/**
|
250 |
+
* Retrieve an inline translated text by key.
|
251 |
+
*
|
252 |
+
* @author CyberChimps
|
253 |
+
* @since 1.0.1
|
254 |
+
*
|
255 |
+
* @param string $text Translatable string.
|
256 |
+
* @param string $key String key for overrides.
|
257 |
+
* @param string $slug Module slug for overrides.
|
258 |
+
*
|
259 |
+
* @return string
|
260 |
+
*
|
261 |
+
* @global $fs_text_overrides
|
262 |
+
*/
|
263 |
+
function _as_text_inline( $text, $key = '', $slug = 'analytics' ) {
|
264 |
+
list( $text, $text_domain ) = as_text_and_domain( $text, $key, $slug );
|
265 |
+
|
266 |
+
// Avoid misleading Theme Check warning.
|
267 |
+
$fn = 'translate';
|
268 |
+
|
269 |
+
return $fn( $text, $text_domain );
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
if ( ! function_exists( 'as_text_and_domain' ) ) {
|
274 |
+
/**
|
275 |
+
* Get a translatable text and its text domain.
|
276 |
+
*
|
277 |
+
* @author CyberChimps
|
278 |
+
* @since 1.0.1
|
279 |
+
*
|
280 |
+
* @param string $text Translatable string.
|
281 |
+
* @param string $key String key for overrides.
|
282 |
+
* @param string $slug Module slug for overrides.
|
283 |
+
*
|
284 |
+
* @return string[]
|
285 |
+
*/
|
286 |
+
function as_text_and_domain( $text, $key, $slug ) {
|
287 |
+
$override = as_text_override( $text, $key, $slug );
|
288 |
+
|
289 |
+
if ( false === $override ) {
|
290 |
+
// No override, use FS text domain.
|
291 |
+
$text_domain = 'analytics';
|
292 |
+
} else {
|
293 |
+
// Found an override.
|
294 |
+
$text = $override;
|
295 |
+
// Use the module's text domain.
|
296 |
+
$text_domain = $slug;
|
297 |
+
}
|
298 |
+
|
299 |
+
return array( $text, $text_domain );
|
300 |
+
}
|
301 |
+
}
|
302 |
+
if ( ! function_exists( 'as_text_override' ) ) {
|
303 |
+
/**
|
304 |
+
* Get a translatable text override if exists, or `false`.
|
305 |
+
*
|
306 |
+
* @author CyberChimps
|
307 |
+
* @since 1.0.1
|
308 |
+
*
|
309 |
+
* @param string $text Translatable string.
|
310 |
+
* @param string $key String key for overrides.
|
311 |
+
* @param string $slug Module slug for overrides.
|
312 |
+
*
|
313 |
+
* @return string|false
|
314 |
+
*/
|
315 |
+
function as_text_override( $text, $key, $slug ) {
|
316 |
+
global $as_text_overrides;
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Check if string is overridden.
|
320 |
+
*/
|
321 |
+
if ( ! isset( $as_text_overrides[ $slug ] ) ) {
|
322 |
+
return false;
|
323 |
+
}
|
324 |
+
|
325 |
+
if ( empty( $key ) ) {
|
326 |
+
$key = strtolower( str_replace( ' ', '-', $text ) );
|
327 |
+
}
|
328 |
+
|
329 |
+
if ( isset( $as_text_overrides[ $slug ][ $key ] ) ) {
|
330 |
+
return $as_text_overrides[ $slug ][ $key ];
|
331 |
+
}
|
332 |
+
|
333 |
+
$lower_key = strtolower( $key );
|
334 |
+
if ( isset( $as_text_overrides[ $slug ][ $lower_key ] ) ) {
|
335 |
+
return $as_text_overrides[ $slug ][ $lower_key ];
|
336 |
+
}
|
337 |
+
|
338 |
+
return false;
|
339 |
+
}
|
340 |
+
}
|
341 |
+
|
342 |
+
if ( ! function_exists( 'as_enqueue_local_script' ) ) {
|
343 |
+
function as_enqueue_local_script( $handle, $path, $deps = array(), $ver = false, $in_footer = 'all' ) {
|
344 |
+
wp_enqueue_script( $handle, as_asset_url( WP_STAT__DIR_JS . '/' . trim( $path, '/' ) ), $deps, $ver, $in_footer );
|
345 |
+
}
|
346 |
+
}
|
347 |
+
|
348 |
+
if ( ! function_exists( 'as_text_inline' ) ) {
|
349 |
+
/**
|
350 |
+
* Retrieve an inline translated text by key.
|
351 |
+
*
|
352 |
+
* @author CyberChimps
|
353 |
+
* @since 1.0.1
|
354 |
+
*
|
355 |
+
* @param string $text Translatable string.
|
356 |
+
* @param string $key String key for overrides.
|
357 |
+
* @param string $slug Module slug for overrides.
|
358 |
+
*
|
359 |
+
* @return string
|
360 |
+
*
|
361 |
+
* @global $fs_text_overrides
|
362 |
+
*/
|
363 |
+
function as_text_inline( $text, $key = '', $slug = 'analytics' ) {
|
364 |
+
return _as_text_inline( $text, $key, $slug );
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Retrieve an inline translated text by key with a context.
|
370 |
+
*
|
371 |
+
* @author CyberChimps
|
372 |
+
* @since 1.0.1
|
373 |
+
*
|
374 |
+
* @param string $text Translatable string.
|
375 |
+
* @param string $context Context information for the translators.
|
376 |
+
* @param string $key String key for overrides.
|
377 |
+
* @param string $slug Module slug for overrides.
|
378 |
+
*
|
379 |
+
* @return string
|
380 |
+
*
|
381 |
+
* @global $fs_text_overrides
|
382 |
+
*/
|
383 |
+
function _as_text_x_inline( $text, $context, $key = '', $slug = 'analytics' ) {
|
384 |
+
list( $text, $text_domain ) = as_text_and_domain( $text, $key, $slug );
|
385 |
+
|
386 |
+
// Avoid misleading Theme Check warning.
|
387 |
+
$fn = 'translate_with_gettext_context';
|
388 |
+
|
389 |
+
return $fn( $text, $context, $text_domain );
|
390 |
+
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Retrieve an inline translated text by key with a context.
|
394 |
+
*
|
395 |
+
* @author CyberChimps
|
396 |
+
* @since 1.0.1
|
397 |
+
*
|
398 |
+
* @param string $text Translatable string.
|
399 |
+
* @param string $context Context information for the translators.
|
400 |
+
* @param string $key String key for overrides.
|
401 |
+
* @param string $slug Module slug for overrides.
|
402 |
+
*
|
403 |
+
* @return string
|
404 |
+
*
|
405 |
+
* @global $fs_text_overrides
|
406 |
+
*/
|
407 |
+
function as_text_x_inline( $text, $context, $key = '', $slug = 'analytics' ) {
|
408 |
+
return _as_text_x_inline( $text, $context, $key, $slug );
|
409 |
+
}
|
410 |
+
|
411 |
+
if ( ! function_exists( 'as_esc_html_echo_x_inline' ) ) {
|
412 |
+
/**
|
413 |
+
* @author CyberChimps
|
414 |
+
* @since 1.0.1
|
415 |
+
*
|
416 |
+
* @param string $text Translatable string.
|
417 |
+
* @param string $context Context information for the translators.
|
418 |
+
* @param string $key String key for overrides.
|
419 |
+
* @param string $slug Module slug for overrides.
|
420 |
+
*/
|
421 |
+
function as_esc_html_echo_x_inline( $text, $context, $key = '', $slug = 'analytics' ) {
|
422 |
+
echo esc_html( _as_text_x_inline( $text, $context, $key, $slug ) );
|
423 |
+
}
|
424 |
+
}
|
425 |
+
|
426 |
+
if ( ! function_exists( 'as_sort_by_priority' ) ) {
|
427 |
+
/**
|
428 |
+
* Sorts an array by the value of the priority key.
|
429 |
+
*
|
430 |
+
* @author CyberChimps
|
431 |
+
* @since 1.0.1
|
432 |
+
*
|
433 |
+
* @param $a
|
434 |
+
* @param $b
|
435 |
+
*
|
436 |
+
* @return int
|
437 |
+
*/
|
438 |
+
function as_sort_by_priority( $a, $b ) {
|
439 |
+
|
440 |
+
// If b has a priority and a does not, b wins.
|
441 |
+
if ( ! isset( $a['priority'] ) && isset( $b['priority'] ) ) {
|
442 |
+
return 1;
|
443 |
+
} // If b has a priority and a does not, b wins.
|
444 |
+
elseif ( isset( $a['priority'] ) && ! isset( $b['priority'] ) ) {
|
445 |
+
return - 1;
|
446 |
+
} // If neither has a priority or both priorities are equal its a tie.
|
447 |
+
elseif ( ( ! isset( $a['priority'] ) && ! isset( $b['priority'] ) ) || $a['priority'] === $b['priority'] ) {
|
448 |
+
return 0;
|
449 |
+
}
|
450 |
+
|
451 |
+
// If both have priority return the winner.
|
452 |
+
return ( $a['priority'] < $b['priority'] ) ? - 1 : 1;
|
453 |
+
}
|
454 |
+
}
|
455 |
+
if ( ! function_exists( 'as_esc_html_echo_inline' ) ) {
|
456 |
+
/**
|
457 |
+
* @author CyberChimps
|
458 |
+
* @since 1.0.1
|
459 |
+
*
|
460 |
+
* @param string $text Translatable string.
|
461 |
+
* @param string $key String key for overrides.
|
462 |
+
* @param string $slug Module slug for overrides.
|
463 |
+
*/
|
464 |
+
function as_esc_html_echo_inline( $text, $key = '', $slug = 'analytics' ) {
|
465 |
+
echo esc_html( _as_text_inline( $text, $key, $slug ) );
|
466 |
+
}
|
467 |
+
}
|
468 |
+
|
469 |
+
/**
|
470 |
+
* Output an inline translated text.
|
471 |
+
*
|
472 |
+
* @author CyberChimps
|
473 |
+
* @since 1.0.1
|
474 |
+
*
|
475 |
+
* @param string $text Translatable string.
|
476 |
+
* @param string $key String key for overrides.
|
477 |
+
* @param string $slug Module slug for overrides.
|
478 |
+
*/
|
479 |
+
function as_echo_inline( $text, $key = '', $slug = 'analytics' ) {
|
480 |
+
echo _as_text_inline( $text, $key, $slug );
|
481 |
+
}
|
482 |
+
|
483 |
+
if ( ! function_exists( 'as_apply_filter' ) ) {
|
484 |
+
/**
|
485 |
+
* Apply filter for specific plugin.
|
486 |
+
*
|
487 |
+
* @author CyberChimps
|
488 |
+
* @since 1.0.1
|
489 |
+
*
|
490 |
+
* @param string $module_unique_affix Module's unique affix.
|
491 |
+
* @param string $tag The name of the filter hook.
|
492 |
+
* @param mixed $value The value on which the filters hooked to `$tag` are applied on.
|
493 |
+
*
|
494 |
+
* @return mixed The filtered value after all hooked functions are applied to it.
|
495 |
+
*
|
496 |
+
* @uses apply_filters()
|
497 |
+
*/
|
498 |
+
function as_apply_filter( $module_unique_affix, $tag, $value ) {
|
499 |
+
$args = func_get_args();
|
500 |
+
|
501 |
+
return call_user_func_array(
|
502 |
+
'apply_filters',
|
503 |
+
array_merge(
|
504 |
+
array( "as_{$tag}_{$module_unique_affix}" ),
|
505 |
+
array_slice( $args, 2 )
|
506 |
+
)
|
507 |
+
);
|
508 |
}
|
509 |
}
|
analytics/includes/class-analytics.php
CHANGED
@@ -191,6 +191,19 @@ class Analytics {
|
|
191 |
if ( is_admin() ) {
|
192 |
add_action( 'admin_init', array( &$this, '_hook_action_links_and_register_account_hooks' ) );
|
193 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
}
|
195 |
|
196 |
/**
|
@@ -341,24 +354,7 @@ class Analytics {
|
|
341 |
);
|
342 |
|
343 |
if ( $show_deactivation_feedback_form ) {
|
344 |
-
|
345 |
-
Check the type of user:
|
346 |
-
* 1. Long-term (long-term)
|
347 |
-
* 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term).
|
348 |
-
* 3. Short-term (short-term)
|
349 |
-
*/
|
350 |
-
|
351 |
-
$is_long_term_user = true;
|
352 |
-
|
353 |
-
if ( $is_long_term_user ) {
|
354 |
-
$user_type = 'long-term';
|
355 |
-
} else {
|
356 |
-
if ( ! $this->is_registered() && ! $this->is_anonymous() ) {
|
357 |
-
$user_type = 'non-registered-and-non-anonymous-short-term';
|
358 |
-
} else {
|
359 |
-
$user_type = 'short-term';
|
360 |
-
}
|
361 |
-
}
|
362 |
|
363 |
$uninstall_reasons = $this->_get_uninstall_reasons( $user_type );
|
364 |
|
@@ -653,14 +649,14 @@ class Analytics {
|
|
653 |
$params['deactivation_reason'] = $reason['deactivation_reason'];
|
654 |
$params['reason_info'] = $reason['info'];
|
655 |
$params['platform_version'] = get_bloginfo( 'version' );
|
656 |
-
if ( $reason['is_anonymous'] ) {
|
657 |
-
$params['user_nickname'] = '';
|
658 |
-
$params['user_email'] = '';
|
659 |
-
$params['site_url'] = '';
|
660 |
-
} else {
|
661 |
$params['user_nickname'] = $current_user->user_nicename;
|
662 |
$params['user_email'] = $current_user->user_email;
|
663 |
$params['site_url'] = get_site_url();
|
|
|
|
|
|
|
|
|
664 |
}
|
665 |
$params['slug'] = $this->_slug;
|
666 |
$params['product_name'] = $this->_product_name;
|
@@ -778,5 +774,4 @@ class Analytics {
|
|
778 |
static function is_plugins_page() {
|
779 |
return ( 'plugins.php' === self::get_current_page() );
|
780 |
}
|
781 |
-
|
782 |
}
|
191 |
if ( is_admin() ) {
|
192 |
add_action( 'admin_init', array( &$this, '_hook_action_links_and_register_account_hooks' ) );
|
193 |
}
|
194 |
+
|
195 |
+
add_action( 'wp_ajax_set-user-consent', array( &$this, 'set_user_consent' ) );
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Set user content on form submission
|
200 |
+
*
|
201 |
+
* @since 1.0.1
|
202 |
+
*/
|
203 |
+
public function set_user_consent() {
|
204 |
+
$value = isset( $_REQUEST['value'] ) ? $_REQUEST['value'] : '';
|
205 |
+
update_option( 'allow_user_data_' . $this->get_slug(), $value );
|
206 |
+
wp_send_json_success();
|
207 |
}
|
208 |
|
209 |
/**
|
354 |
);
|
355 |
|
356 |
if ( $show_deactivation_feedback_form ) {
|
357 |
+
$user_type = 'long-term';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
|
359 |
$uninstall_reasons = $this->_get_uninstall_reasons( $user_type );
|
360 |
|
649 |
$params['deactivation_reason'] = $reason['deactivation_reason'];
|
650 |
$params['reason_info'] = $reason['info'];
|
651 |
$params['platform_version'] = get_bloginfo( 'version' );
|
652 |
+
if ( $reason['is_anonymous'] || 'yes' === get_option( 'allow_user_data_' . $this->get_slug(), 'no' ) ) {
|
|
|
|
|
|
|
|
|
653 |
$params['user_nickname'] = $current_user->user_nicename;
|
654 |
$params['user_email'] = $current_user->user_email;
|
655 |
$params['site_url'] = get_site_url();
|
656 |
+
} else {
|
657 |
+
$params['user_nickname'] = '';
|
658 |
+
$params['user_email'] = '';
|
659 |
+
$params['site_url'] = '';
|
660 |
}
|
661 |
$params['slug'] = $this->_slug;
|
662 |
$params['product_name'] = $this->_product_name;
|
774 |
static function is_plugins_page() {
|
775 |
return ( 'plugins.php' === self::get_current_page() );
|
776 |
}
|
|
|
777 |
}
|
analytics/templates/forms/deactivation/form.php
CHANGED
@@ -60,7 +60,7 @@ HTML;
|
|
60 |
if ( $is_anonymous ) {
|
61 |
$anonymous_feedback_checkbox_html = sprintf(
|
62 |
'<label class="anonymous-feedback-label"><input type="checkbox" class="anonymous-feedback-checkbox"> %s</label>',
|
63 |
-
__( '
|
64 |
);
|
65 |
}
|
66 |
}
|
@@ -250,7 +250,7 @@ as_enqueue_local_style( 'as_dialog_boxes', '/admin/dialog-boxes.css' );
|
|
250 |
$modal.find('.reason-input').remove();
|
251 |
$modal.find( '.internal-message' ).hide();
|
252 |
$modal.find('.button-deactivate').html('<?php echo esc_js( sprintf(
|
253 |
-
__( 'Submit & %s', 'analytics'
|
254 |
$as->is_plugin() ?
|
255 |
$deactivate_text :
|
256 |
sprintf( $activate_x_text, $theme_text )
|
60 |
if ( $is_anonymous ) {
|
61 |
$anonymous_feedback_checkbox_html = sprintf(
|
62 |
'<label class="anonymous-feedback-label"><input type="checkbox" class="anonymous-feedback-checkbox"> %s</label>',
|
63 |
+
__( 'Send contact details for help', 'analytics' )
|
64 |
);
|
65 |
}
|
66 |
}
|
250 |
$modal.find('.reason-input').remove();
|
251 |
$modal.find( '.internal-message' ).hide();
|
252 |
$modal.find('.button-deactivate').html('<?php echo esc_js( sprintf(
|
253 |
+
__( 'Submit & %s', 'analytics', $slug ),
|
254 |
$as->is_plugin() ?
|
255 |
$deactivate_text :
|
256 |
sprintf( $activate_x_text, $theme_text )
|
includes/importers/batch-processing/class-responsive-ready-sites-batch-processing.php
CHANGED
@@ -68,8 +68,8 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Batch_Processing' ) ) :
|
|
68 |
// Prepare Page Builders.
|
69 |
require_once $responsive_ready_sites_batch_processing . 'class-responsive-ready-sites-batch-processing-elementor.php';
|
70 |
|
71 |
-
//Menu fix
|
72 |
-
|
73 |
|
74 |
self::$process_all = new WP_Background_Process_Responsive();
|
75 |
|
@@ -86,6 +86,8 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Batch_Processing' ) ) :
|
|
86 |
*/
|
87 |
public function start_process() {
|
88 |
|
|
|
|
|
89 |
// Add "elementor" in import [queue].
|
90 |
// @todo Remove required `allow_url_fopen` support.
|
91 |
if ( ini_get( 'allow_url_fopen' ) ) {
|
@@ -95,10 +97,10 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Batch_Processing' ) ) :
|
|
95 |
}
|
96 |
}
|
97 |
|
98 |
-
|
99 |
-
|
100 |
|
101 |
-
|
102 |
self::$process_all->save()->dispatch();
|
103 |
}
|
104 |
|
68 |
// Prepare Page Builders.
|
69 |
require_once $responsive_ready_sites_batch_processing . 'class-responsive-ready-sites-batch-processing-elementor.php';
|
70 |
|
71 |
+
// Menu fix.
|
72 |
+
require_once $responsive_ready_sites_batch_processing . 'class-responsive-ready-sites-batch-processing-menu.php';
|
73 |
|
74 |
self::$process_all = new WP_Background_Process_Responsive();
|
75 |
|
86 |
*/
|
87 |
public function start_process() {
|
88 |
|
89 |
+
Responsive_Ready_Sites_Importer_Log::add( 'Batch Process Started!' );
|
90 |
+
|
91 |
// Add "elementor" in import [queue].
|
92 |
// @todo Remove required `allow_url_fopen` support.
|
93 |
if ( ini_get( 'allow_url_fopen' ) ) {
|
97 |
}
|
98 |
}
|
99 |
|
100 |
+
// Add "misc" in import [queue].
|
101 |
+
self::$process_all->push_to_queue( Responsive_Ready_Sites_Batch_Processing_Menu::get_instance() );
|
102 |
|
103 |
+
// Dispatch Queue.
|
104 |
self::$process_all->save()->dispatch();
|
105 |
}
|
106 |
|
includes/importers/batch-processing/helpers/class-wp-background-process-responsive.php
CHANGED
@@ -56,8 +56,10 @@ if ( class_exists( 'WP_Background_Process' ) ) :
|
|
56 |
|
57 |
parent::complete();
|
58 |
|
|
|
|
|
59 |
// Delete Log file.
|
60 |
-
delete_option( '
|
61 |
|
62 |
}
|
63 |
|
56 |
|
57 |
parent::complete();
|
58 |
|
59 |
+
Responsive_Ready_Sites_Importer_Log::add( 'Batch Process Complete!' );
|
60 |
+
|
61 |
// Delete Log file.
|
62 |
+
delete_option( 'responsive_ready_sites_recent_import_log_file' );
|
63 |
|
64 |
}
|
65 |
|
includes/importers/class-responsive-ready-sites-importer-log.php
ADDED
@@ -0,0 +1,415 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Responsive Ready Sites Importer Log
|
4 |
+
*
|
5 |
+
* @since 2.2.0
|
6 |
+
* @package Responsive Ready Sites
|
7 |
+
*/
|
8 |
+
|
9 |
+
defined( 'ABSPATH' ) || exit;
|
10 |
+
|
11 |
+
if ( ! class_exists( 'Responsive_Ready_Sites_Importer_Log' ) ) :
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Responsive Ready Sites Importer
|
15 |
+
*/
|
16 |
+
class Responsive_Ready_Sites_Importer_Log {
|
17 |
+
/**
|
18 |
+
* Instance
|
19 |
+
*
|
20 |
+
* @since 2.2.0
|
21 |
+
* @var (Object) Class object
|
22 |
+
*/
|
23 |
+
private static $_instance = null;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Log File
|
27 |
+
*
|
28 |
+
* @since 2.2.0
|
29 |
+
* @var (Object) Class object
|
30 |
+
*/
|
31 |
+
private static $log_file = null;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Set Instance
|
35 |
+
*
|
36 |
+
* @since 2.2.0
|
37 |
+
*
|
38 |
+
* @return object Class object.
|
39 |
+
*/
|
40 |
+
public static function get_instance() {
|
41 |
+
if ( ! isset( self::$_instance ) ) {
|
42 |
+
self::$_instance = new self();
|
43 |
+
}
|
44 |
+
|
45 |
+
return self::$_instance;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Constructor.
|
50 |
+
*
|
51 |
+
* @since 2.2.0
|
52 |
+
*/
|
53 |
+
private function __construct() {
|
54 |
+
|
55 |
+
// Check file read/write permissions.
|
56 |
+
add_action( 'admin_init', array( $this, 'has_file_read_write' ) );
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Check file read/write permissions and process.
|
62 |
+
*
|
63 |
+
* @since 2.2.0
|
64 |
+
* @return null
|
65 |
+
*/
|
66 |
+
function has_file_read_write() {
|
67 |
+
|
68 |
+
// Get user credentials for WP file-system API.
|
69 |
+
$responsive_ready_sites_import = wp_nonce_url( admin_url( 'themes.php?page=responsive-add-ons' ), 'responsive-add-ons' );
|
70 |
+
$creds = request_filesystem_credentials( $responsive_ready_sites_import, '', false, false, null );
|
71 |
+
if ( false === $creds ) {
|
72 |
+
return;
|
73 |
+
}
|
74 |
+
|
75 |
+
// Set log file.
|
76 |
+
self::set_log_file();
|
77 |
+
|
78 |
+
// Initial AJAX Import Hooks.
|
79 |
+
add_action( 'responsive_ready_sites_import_start', array( $this, 'start' ), 10, 2 );
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Add log file URL in UI response.
|
84 |
+
*
|
85 |
+
* @since 2.2.0
|
86 |
+
*/
|
87 |
+
public static function add_log_file_url() {
|
88 |
+
|
89 |
+
$upload_dir = self::log_dir();
|
90 |
+
$upload_path = trailingslashit( $upload_dir['url'] );
|
91 |
+
$file_abs_url = get_option( 'responsive_ready_sites_recent_import_log_file', self::$log_file );
|
92 |
+
$file_url = $upload_path . basename( $file_abs_url );
|
93 |
+
|
94 |
+
return array(
|
95 |
+
'abs_url' => $file_abs_url,
|
96 |
+
'url' => $file_url,
|
97 |
+
);
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Current Time for log.
|
102 |
+
*
|
103 |
+
* @since 2.2.0
|
104 |
+
* @return string Current time with time zone.
|
105 |
+
*/
|
106 |
+
public static function current_time() {
|
107 |
+
return gmdate( 'H:i:s' ) . ' ' . date_default_timezone_get();
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Import Start
|
112 |
+
*
|
113 |
+
* @since 2.2.0
|
114 |
+
* @param array $data Import Data.
|
115 |
+
* @param string $demo_api_uri Import site API URL.
|
116 |
+
* @return void
|
117 |
+
*/
|
118 |
+
function start( $data = array(), $demo_api_uri = '' ) {
|
119 |
+
|
120 |
+
self::add( 'Started Import Process' );
|
121 |
+
|
122 |
+
self::add( '# System Details: ' );
|
123 |
+
self::add( "Debug Mode \t\t: " . self::get_debug_mode() );
|
124 |
+
self::add( "Operating System \t: " . self::get_os() );
|
125 |
+
self::add( "Software \t\t: " . self::get_software() );
|
126 |
+
self::add( "MySQL version \t\t: " . self::get_mysql_version() );
|
127 |
+
self::add( "XML Reader \t\t: " . self::get_xmlreader_status() );
|
128 |
+
self::add( "PHP Version \t\t: " . self::get_php_version() );
|
129 |
+
self::add( "PHP Max Input Vars \t: " . self::get_php_max_input_vars() );
|
130 |
+
self::add( "PHP Max Post Size \t: " . self::get_php_max_post_size() );
|
131 |
+
self::add( "PHP Extension GD \t: " . self::get_php_extension_gd() );
|
132 |
+
self::add( "PHP Max Execution Time \t: " . self::get_max_execution_time() );
|
133 |
+
self::add( "Max Upload Size \t: " . size_format( wp_max_upload_size() ) );
|
134 |
+
self::add( "Memory Limit \t\t: " . self::get_memory_limit() );
|
135 |
+
self::add( "Timezone \t\t: " . self::get_timezone() );
|
136 |
+
self::add( PHP_EOL . '-----' . PHP_EOL );
|
137 |
+
self::add( 'Importing Started! - ' . self::current_time() );
|
138 |
+
|
139 |
+
self::add( '---' . PHP_EOL );
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Get an instance of WP_Filesystem_Direct.
|
144 |
+
*
|
145 |
+
* @since 2.2.0
|
146 |
+
* @return object A WP_Filesystem_Direct instance.
|
147 |
+
*/
|
148 |
+
public static function get_filesystem() {
|
149 |
+
global $wp_filesystem;
|
150 |
+
|
151 |
+
require_once ABSPATH . '/wp-admin/includes/file.php';
|
152 |
+
|
153 |
+
WP_Filesystem();
|
154 |
+
|
155 |
+
return $wp_filesystem;
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Get Log File
|
160 |
+
*
|
161 |
+
* @since 2.2.0
|
162 |
+
* @return string log file URL.
|
163 |
+
*/
|
164 |
+
public static function get_log_file() {
|
165 |
+
return self::$log_file;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Log file directory
|
170 |
+
*
|
171 |
+
* @since 2.2.0
|
172 |
+
* @param string $dir_name Directory Name.
|
173 |
+
* @return array Uploads directory array.
|
174 |
+
*/
|
175 |
+
public static function log_dir( $dir_name = 'responsive-add-ons' ) {
|
176 |
+
|
177 |
+
$upload_dir = wp_upload_dir();
|
178 |
+
|
179 |
+
// Build the paths.
|
180 |
+
$dir_info = array(
|
181 |
+
'path' => $upload_dir['basedir'] . '/' . $dir_name . '/',
|
182 |
+
'url' => $upload_dir['baseurl'] . '/' . $dir_name . '/',
|
183 |
+
);
|
184 |
+
|
185 |
+
$files = array(
|
186 |
+
array(
|
187 |
+
'base' => $upload_dir['basedir'] . '/' . $dir_name,
|
188 |
+
'file' => '.htaccess',
|
189 |
+
'content' => 'deny from all',
|
190 |
+
),
|
191 |
+
);
|
192 |
+
|
193 |
+
foreach ( $files as $file ) {
|
194 |
+
if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) {
|
195 |
+
$file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fopen
|
196 |
+
if ( $file_handle ) {
|
197 |
+
fwrite( $file_handle, $file['content'] ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite
|
198 |
+
fclose( $file_handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose
|
199 |
+
}
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
return $dir_info;
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Set log file
|
208 |
+
*
|
209 |
+
* @since 2.2.0
|
210 |
+
*/
|
211 |
+
public static function set_log_file() {
|
212 |
+
|
213 |
+
$upload_dir = self::log_dir();
|
214 |
+
|
215 |
+
$upload_path = trailingslashit( $upload_dir['path'] );
|
216 |
+
|
217 |
+
// File format e.g. 'import-31-Oct-2017-06-39-12.txt'.
|
218 |
+
self::$log_file = $upload_path . 'import-' . gmdate( 'd-M-Y-h-i-s' ) . '.txt';
|
219 |
+
|
220 |
+
if ( ! get_option( 'responsive_ready_sites_recent_import_log_file', false ) ) {
|
221 |
+
update_option( 'responsive_ready_sites_recent_import_log_file', self::$log_file );
|
222 |
+
}
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Write content to a file.
|
227 |
+
*
|
228 |
+
* @since 2.2.0
|
229 |
+
* @param string $content content to be saved to the file.
|
230 |
+
*/
|
231 |
+
public static function add( $content ) {
|
232 |
+
|
233 |
+
if ( get_option( 'responsive_ready_sites_recent_import_log_file', false ) ) {
|
234 |
+
$log_file = get_option( 'responsive_ready_sites_recent_import_log_file', self::$log_file );
|
235 |
+
} else {
|
236 |
+
$log_file = self::$log_file;
|
237 |
+
}
|
238 |
+
|
239 |
+
$existing_data = '';
|
240 |
+
if ( file_exists( $log_file ) ) {
|
241 |
+
$existing_data = self::get_filesystem()->get_contents( $log_file );
|
242 |
+
}
|
243 |
+
|
244 |
+
// Style separator.
|
245 |
+
$separator = PHP_EOL;
|
246 |
+
|
247 |
+
self::get_filesystem()->put_contents( $log_file, $existing_data . $separator . $content, FS_CHMOD_FILE );
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Debug Mode
|
252 |
+
*
|
253 |
+
* @since 2.2.0
|
254 |
+
* @return string Enabled for Debug mode ON and Disabled for Debug mode Off.
|
255 |
+
*/
|
256 |
+
public static function get_debug_mode() {
|
257 |
+
if ( WP_DEBUG ) {
|
258 |
+
return __( 'Enabled', 'responsive-addons' );
|
259 |
+
}
|
260 |
+
|
261 |
+
return __( 'Disabled', 'responsive-addons' );
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Memory Limit
|
266 |
+
*
|
267 |
+
* @since 2.2.0
|
268 |
+
* @return string Memory limit.
|
269 |
+
*/
|
270 |
+
public static function get_memory_limit() {
|
271 |
+
|
272 |
+
$required_memory = '64M';
|
273 |
+
$memory_limit_in_bytes_current = wp_convert_hr_to_bytes( WP_MEMORY_LIMIT );
|
274 |
+
$memory_limit_in_bytes_required = wp_convert_hr_to_bytes( $required_memory );
|
275 |
+
|
276 |
+
if ( $memory_limit_in_bytes_current < $memory_limit_in_bytes_required ) {
|
277 |
+
return sprintf(
|
278 |
+
/* translators: %1$s Memory Limit, %2$s Recommended memory limit. */
|
279 |
+
_x( 'Current memory limit %1$s. We recommend setting memory to at least %2$s.', 'Recommended Memory Limit', 'responsive-addons' ),
|
280 |
+
WP_MEMORY_LIMIT,
|
281 |
+
$required_memory
|
282 |
+
);
|
283 |
+
}
|
284 |
+
|
285 |
+
return WP_MEMORY_LIMIT;
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Timezone
|
290 |
+
*
|
291 |
+
* @since 2.2.0
|
292 |
+
* @see https://codex.wordpress.org/Option_Reference/
|
293 |
+
*
|
294 |
+
* @return string Current timezone.
|
295 |
+
*/
|
296 |
+
public static function get_timezone() {
|
297 |
+
$timezone = get_option( 'timezone_string' );
|
298 |
+
|
299 |
+
if ( ! $timezone ) {
|
300 |
+
return get_option( 'gmt_offset' );
|
301 |
+
}
|
302 |
+
|
303 |
+
return $timezone;
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* XML Reader
|
308 |
+
*
|
309 |
+
* @since 2.2.0
|
310 |
+
* @return string Current XML Reader status.
|
311 |
+
*/
|
312 |
+
public static function get_xmlreader_status() {
|
313 |
+
|
314 |
+
if ( class_exists( 'XMLReader' ) ) {
|
315 |
+
return __( 'Yes', 'responsive-addons' );
|
316 |
+
}
|
317 |
+
|
318 |
+
return __( 'No', 'responsive-addons' );
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Operating System
|
323 |
+
*
|
324 |
+
* @since 2.2.0
|
325 |
+
* @return string Current Operating System.
|
326 |
+
*/
|
327 |
+
public static function get_os() {
|
328 |
+
return PHP_OS;
|
329 |
+
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* Server Software
|
333 |
+
*
|
334 |
+
* @since 2.2.0
|
335 |
+
* @return string Current Server Software.
|
336 |
+
*/
|
337 |
+
public static function get_software() {
|
338 |
+
return $_SERVER['SERVER_SOFTWARE'];
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* MySql Version
|
343 |
+
*
|
344 |
+
* @since 2.2.0
|
345 |
+
* @return string Current MySql Version.
|
346 |
+
*/
|
347 |
+
public static function get_mysql_version() {
|
348 |
+
global $wpdb;
|
349 |
+
return $wpdb->db_version();
|
350 |
+
}
|
351 |
+
|
352 |
+
/**
|
353 |
+
* PHP Version
|
354 |
+
*
|
355 |
+
* @since 2.2.0
|
356 |
+
* @return string Current PHP Version.
|
357 |
+
*/
|
358 |
+
public static function get_php_version() {
|
359 |
+
if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
|
360 |
+
return _x( 'We recommend to use php 5.4 or higher', 'PHP Version', 'responsive-addons' );
|
361 |
+
}
|
362 |
+
return PHP_VERSION;
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* PHP Max Input Vars
|
367 |
+
*
|
368 |
+
* @since 2.2.0
|
369 |
+
* @return string Current PHP Max Input Vars
|
370 |
+
*/
|
371 |
+
public static function get_php_max_input_vars() {
|
372 |
+
return ini_get( 'max_input_vars' ); // phpcs:disable PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* PHP Max Post Size
|
377 |
+
*
|
378 |
+
* @since 2.2.0
|
379 |
+
* @return string Current PHP Max Post Size
|
380 |
+
*/
|
381 |
+
public static function get_php_max_post_size() {
|
382 |
+
return ini_get( 'post_max_size' );
|
383 |
+
}
|
384 |
+
|
385 |
+
/**
|
386 |
+
* PHP Max Execution Time
|
387 |
+
*
|
388 |
+
* @since 2.2.0
|
389 |
+
* @return string Current Max Execution Time
|
390 |
+
*/
|
391 |
+
public static function get_max_execution_time() {
|
392 |
+
return ini_get( 'max_execution_time' );
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* PHP GD Extension
|
397 |
+
*
|
398 |
+
* @since 2.2.0
|
399 |
+
* @return string Current PHP GD Extension
|
400 |
+
*/
|
401 |
+
public static function get_php_extension_gd() {
|
402 |
+
if ( extension_loaded( 'gd' ) ) {
|
403 |
+
return __( 'Yes', 'responsive-addons' );
|
404 |
+
}
|
405 |
+
|
406 |
+
return __( 'No', 'responsive-addons' );
|
407 |
+
}
|
408 |
+
|
409 |
+
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Kicking this off by calling 'get_instance()' method
|
413 |
+
*/
|
414 |
+
Responsive_Ready_Sites_Importer_Log::get_instance();
|
415 |
+
endif;
|
includes/importers/class-responsive-ready-sites-importer.php
CHANGED
@@ -49,6 +49,7 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Importer' ) ) :
|
|
49 |
add_action( 'init', array( $this, 'load_importer' ) );
|
50 |
|
51 |
$responsive_ready_sites_importers_dir = plugin_dir_path( __FILE__ );
|
|
|
52 |
include_once $responsive_ready_sites_importers_dir . 'class-responsive-ready-sites-widgets-importer.php';
|
53 |
include_once $responsive_ready_sites_importers_dir . 'class-responsive-ready-sites-options-importer.php';
|
54 |
|
@@ -90,6 +91,7 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Importer' ) ) :
|
|
90 |
if ( class_exists( '\Elementor\Plugin' ) ) {
|
91 |
Elementor\Plugin::$instance->posts_css_manager->clear_cache();
|
92 |
}
|
|
|
93 |
}
|
94 |
|
95 |
/**
|
@@ -196,6 +198,8 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Importer' ) ) :
|
|
196 |
|
197 |
if ( isset( $wxr_url ) ) {
|
198 |
|
|
|
|
|
199 |
// Download XML file.
|
200 |
$xml_path = self::download_file( $wxr_url );
|
201 |
|
@@ -260,6 +264,8 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Importer' ) ) :
|
|
260 |
|
261 |
// Set meta for tracking the form imported from demo site.
|
262 |
update_post_meta( $new_id, '_responsive_ready_sites_imported_wp_forms', true );
|
|
|
|
|
263 |
}
|
264 |
|
265 |
if ( $new_id ) {
|
@@ -300,6 +306,8 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Importer' ) ) :
|
|
300 |
|
301 |
if ( ! empty( $customizer_data ) ) {
|
302 |
|
|
|
|
|
303 |
// Set meta for tracking the post.
|
304 |
update_option( '_responsive_sites_old_customizer_data', $customizer_data );
|
305 |
|
@@ -340,6 +348,8 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Importer' ) ) :
|
|
340 |
|
341 |
$widgets_data = ( isset( $_POST['widgets_data'] ) ) ? (object) json_decode( stripcslashes( $_POST['widgets_data'] ) ) : ''; //phpcs:ignore
|
342 |
|
|
|
|
|
343 |
if ( ! empty( $widgets_data ) ) {
|
344 |
|
345 |
$widgets_importer = Responsive_Ready_Sites_Widgets_Importer::instance();
|
@@ -372,6 +382,7 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Importer' ) ) :
|
|
372 |
|
373 |
// Set meta for tracking the post.
|
374 |
if ( is_array( $options_data ) ) {
|
|
|
375 |
update_option( '_responsive_ready_sites_old_site_options', $options_data );
|
376 |
}
|
377 |
|
@@ -562,6 +573,8 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Importer' ) ) :
|
|
562 |
*/
|
563 |
public function reset_customizer_data() {
|
564 |
|
|
|
|
|
565 |
delete_option( 'responsive_theme_options' );
|
566 |
|
567 |
wp_send_json_success();
|
@@ -577,6 +590,8 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Importer' ) ) :
|
|
577 |
|
578 |
$options = get_option( '_responsive_ready_sites_old_site_options', array() );
|
579 |
|
|
|
|
|
580 |
if ( $options ) {
|
581 |
foreach ( $options as $option_key => $option_value ) {
|
582 |
delete_option( $option_key );
|
@@ -624,11 +639,16 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Importer' ) ) :
|
|
624 |
* @since 1.3.0
|
625 |
* @return void
|
626 |
*/
|
627 |
-
public function delete_imported_posts() {
|
628 |
-
$post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) :
|
629 |
-
$message = 'Deleted - Post ID ' . $post_id . ' - ' . get_post_type( $post_id ) . ' - ' . get_the_title( $post_id );
|
630 |
|
631 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
632 |
|
633 |
/* translators: %s is the post ID */
|
634 |
wp_send_json_success( $message );
|
@@ -640,13 +660,15 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Importer' ) ) :
|
|
640 |
* @since 1.3.0
|
641 |
* @return void
|
642 |
*/
|
643 |
-
public function delete_imported_wp_forms() {
|
644 |
-
$post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) :
|
645 |
-
|
646 |
-
$message = 'Deleted - Form ID ' . $post_id . ' - ' . get_post_type( $post_id ) . ' - ' . get_the_title( $post_id );
|
647 |
-
|
648 |
-
wp_delete_post( $post_id, true );
|
649 |
|
|
|
|
|
|
|
|
|
|
|
|
|
650 |
/* translators: %s is the form ID */
|
651 |
wp_send_json_success( $message );
|
652 |
}
|
@@ -657,9 +679,9 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Importer' ) ) :
|
|
657 |
* @since 1.3.0
|
658 |
* @return void
|
659 |
*/
|
660 |
-
public function delete_imported_terms() {
|
661 |
|
662 |
-
$term_id = isset( $_REQUEST['term_id'] ) ? absint( $_REQUEST['term_id'] ) :
|
663 |
|
664 |
$message = '';
|
665 |
|
@@ -667,6 +689,7 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Importer' ) ) :
|
|
667 |
$term = get_term( $term_id );
|
668 |
if ( $term ) {
|
669 |
$message = 'Deleted - Term ' . $term_id . ' - ' . $term->name . ' ' . $term->taxonomy;
|
|
|
670 |
wp_delete_term( $term_id, $term->taxonomy );
|
671 |
}
|
672 |
}
|
49 |
add_action( 'init', array( $this, 'load_importer' ) );
|
50 |
|
51 |
$responsive_ready_sites_importers_dir = plugin_dir_path( __FILE__ );
|
52 |
+
require_once $responsive_ready_sites_importers_dir . 'class-responsive-ready-sites-importer-log.php';
|
53 |
include_once $responsive_ready_sites_importers_dir . 'class-responsive-ready-sites-widgets-importer.php';
|
54 |
include_once $responsive_ready_sites_importers_dir . 'class-responsive-ready-sites-options-importer.php';
|
55 |
|
91 |
if ( class_exists( '\Elementor\Plugin' ) ) {
|
92 |
Elementor\Plugin::$instance->posts_css_manager->clear_cache();
|
93 |
}
|
94 |
+
Responsive_Ready_Sites_Importer_Log::add( 'Complete ' );
|
95 |
}
|
96 |
|
97 |
/**
|
198 |
|
199 |
if ( isset( $wxr_url ) ) {
|
200 |
|
201 |
+
Responsive_Ready_Sites_Importer_Log::add( 'Importing from XML ' . $wxr_url );
|
202 |
+
|
203 |
// Download XML file.
|
204 |
$xml_path = self::download_file( $wxr_url );
|
205 |
|
264 |
|
265 |
// Set meta for tracking the form imported from demo site.
|
266 |
update_post_meta( $new_id, '_responsive_ready_sites_imported_wp_forms', true );
|
267 |
+
|
268 |
+
Responsive_Ready_Sites_Importer_Log::add( 'Inserted WP Form ' . $new_id );
|
269 |
}
|
270 |
|
271 |
if ( $new_id ) {
|
306 |
|
307 |
if ( ! empty( $customizer_data ) ) {
|
308 |
|
309 |
+
Responsive_Ready_Sites_Importer_Log::add( 'Imported Customizer Settings ' . wp_json_encode( $customizer_data ) );
|
310 |
+
|
311 |
// Set meta for tracking the post.
|
312 |
update_option( '_responsive_sites_old_customizer_data', $customizer_data );
|
313 |
|
348 |
|
349 |
$widgets_data = ( isset( $_POST['widgets_data'] ) ) ? (object) json_decode( stripcslashes( $_POST['widgets_data'] ) ) : ''; //phpcs:ignore
|
350 |
|
351 |
+
Responsive_Ready_Sites_Importer_Log::add( 'Imported - Widgets ' . wp_json_encode( $widgets_data ) );
|
352 |
+
|
353 |
if ( ! empty( $widgets_data ) ) {
|
354 |
|
355 |
$widgets_importer = Responsive_Ready_Sites_Widgets_Importer::instance();
|
382 |
|
383 |
// Set meta for tracking the post.
|
384 |
if ( is_array( $options_data ) ) {
|
385 |
+
Responsive_Ready_Sites_Importer_Log::add( 'Imported - Site Options ' . wp_json_encode( $options_data ) );
|
386 |
update_option( '_responsive_ready_sites_old_site_options', $options_data );
|
387 |
}
|
388 |
|
573 |
*/
|
574 |
public function reset_customizer_data() {
|
575 |
|
576 |
+
Responsive_Ready_Sites_Importer_Log::add( 'Deleted customizer Settings ' . wp_json_encode( get_option( 'responsive_theme_options', array() ) ) );
|
577 |
+
|
578 |
delete_option( 'responsive_theme_options' );
|
579 |
|
580 |
wp_send_json_success();
|
590 |
|
591 |
$options = get_option( '_responsive_ready_sites_old_site_options', array() );
|
592 |
|
593 |
+
Responsive_Ready_Sites_Importer_Log::add( 'Deleted - Site Options ' . wp_json_encode( $options ) );
|
594 |
+
|
595 |
if ( $options ) {
|
596 |
foreach ( $options as $option_key => $option_value ) {
|
597 |
delete_option( $option_key );
|
639 |
* @since 1.3.0
|
640 |
* @return void
|
641 |
*/
|
642 |
+
public function delete_imported_posts( $post_id = 0 ) {
|
643 |
+
$post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : $post_id;
|
|
|
644 |
|
645 |
+
$message = '';
|
646 |
+
if ( $post_id ) {
|
647 |
+
$message = 'Deleted - Post ID ' . $post_id . ' - ' . get_post_type( $post_id ) . ' - ' . get_the_title( $post_id );
|
648 |
+
|
649 |
+
Responsive_Ready_Sites_Importer_Log::add( $message );
|
650 |
+
wp_delete_post( $post_id, true );
|
651 |
+
}
|
652 |
|
653 |
/* translators: %s is the post ID */
|
654 |
wp_send_json_success( $message );
|
660 |
* @since 1.3.0
|
661 |
* @return void
|
662 |
*/
|
663 |
+
public function delete_imported_wp_forms( $post_id = 0 ) {
|
664 |
+
$post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : $post_id;
|
|
|
|
|
|
|
|
|
665 |
|
666 |
+
$message = '';
|
667 |
+
if ( $post_id ) {
|
668 |
+
$message = 'Deleted - Form ID ' . $post_id . ' - ' . get_post_type( $post_id ) . ' - ' . get_the_title( $post_id );
|
669 |
+
Responsive_Ready_Sites_Importer_Log::add( $message );
|
670 |
+
wp_delete_post( $post_id, true );
|
671 |
+
}
|
672 |
/* translators: %s is the form ID */
|
673 |
wp_send_json_success( $message );
|
674 |
}
|
679 |
* @since 1.3.0
|
680 |
* @return void
|
681 |
*/
|
682 |
+
public function delete_imported_terms( $term_id = 0 ) {
|
683 |
|
684 |
+
$term_id = isset( $_REQUEST['term_id'] ) ? absint( $_REQUEST['term_id'] ) : $term_id;
|
685 |
|
686 |
$message = '';
|
687 |
|
689 |
$term = get_term( $term_id );
|
690 |
if ( $term ) {
|
691 |
$message = 'Deleted - Term ' . $term_id . ' - ' . $term->name . ' ' . $term->taxonomy;
|
692 |
+
Responsive_Ready_Sites_Importer_Log::add( $message );
|
693 |
wp_delete_term( $term_id, $term->taxonomy );
|
694 |
}
|
695 |
}
|
includes/importers/wxr-importer/class-responsive-ready-sites-wxr-importer.php
CHANGED
@@ -389,6 +389,7 @@ if ( ! class_exists( 'Responsive_Ready_Sites_WXR_Importer' ) ) :
|
|
389 |
* @return void
|
390 |
*/
|
391 |
public function track_post( $post_id ) {
|
|
|
392 |
update_post_meta( $post_id, '_responsive_ready_sites_imported_post', true );
|
393 |
}
|
394 |
|
@@ -399,6 +400,10 @@ if ( ! class_exists( 'Responsive_Ready_Sites_WXR_Importer' ) ) :
|
|
399 |
* @return void
|
400 |
*/
|
401 |
public function track_term( $term_id ) {
|
|
|
|
|
|
|
|
|
402 |
update_term_meta( $term_id, '_responsive_ready_sites_imported_term', true );
|
403 |
}
|
404 |
|
389 |
* @return void
|
390 |
*/
|
391 |
public function track_post( $post_id ) {
|
392 |
+
Responsive_Ready_Sites_Importer_Log::add( 'Inserted - Post ' . $post_id . ' - ' . get_post_type( $post_id ) . ' - ' . get_the_title( $post_id ) );
|
393 |
update_post_meta( $post_id, '_responsive_ready_sites_imported_post', true );
|
394 |
}
|
395 |
|
400 |
* @return void
|
401 |
*/
|
402 |
public function track_term( $term_id ) {
|
403 |
+
$term = get_term( $term_id );
|
404 |
+
if ( $term ) {
|
405 |
+
Responsive_Ready_Sites_Importer_Log::add( 'Inserted - Term ' . $term_id . ' - ' . wp_json_encode( $term ) );
|
406 |
+
}
|
407 |
update_term_meta( $term_id, '_responsive_ready_sites_imported_term', true );
|
408 |
}
|
409 |
|
readme.txt
CHANGED
@@ -1,40 +1,81 @@
|
|
1 |
-
=== Responsive Ready Sites Importer ===
|
2 |
Contributors: cyberchimps
|
3 |
Donate Link: http://cyberchimps.com
|
4 |
-
Tags:
|
5 |
Requires at least: 5.0
|
6 |
Tested up to: 5.3
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag: 2.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
12 |
-
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
|
20 |
-
|
|
|
|
|
21 |
|
22 |
-
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
== Frequently Asked Questions ==
|
40 |
|
@@ -61,6 +102,10 @@ Absolutely not! Once you install the plugin, it will take care of all other depe
|
|
61 |
4. Your website is ready
|
62 |
|
63 |
== Changelog ==
|
|
|
|
|
|
|
|
|
64 |
= 2.1.1 - 12th December 2019 =
|
65 |
* Fix - Responsive Ready Sites Importer plugin only works with Responsive theme
|
66 |
|
@@ -152,4 +197,4 @@ Absolutely not! Once you install the plugin, it will take care of all other depe
|
|
152 |
* Bug fixes
|
153 |
|
154 |
= 1.0.0 =
|
155 |
-
* Initial set up and release
|
1 |
+
=== Responsive Ready Sites: One Click Demo Importer ===
|
2 |
Contributors: cyberchimps
|
3 |
Donate Link: http://cyberchimps.com
|
4 |
+
Tags: One Click Demo Import, Rollback, Elementor,
|
5 |
Requires at least: 5.0
|
6 |
Tested up to: 5.3
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 2.2.0
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
12 |
+
Adds one click demo import of ready-to-use, Elementor website templates and rollback functionality to the Responsive WordPress theme.
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
+
The Responsive Add-ons plugin extends the popular [Responsive theme](https://wordpress.org/themes/responsive/). It adds the following features to the theme:
|
17 |
+
|
18 |
+
- One click demo import of ready-to-use, Elementor website templates
|
19 |
+
- Ability to rollback the Responsive theme to a previous version
|
20 |
+
|
21 |
+
= What are ready-to-use website templates? =
|
22 |
+
The Responsive theme comes with ready-to-use [website templates](https://cyberchimps.com/responsive-ready-websites/).
|
23 |
+
|
24 |
+
Website templates help you save time designing your website. All you have to do is import a template, edit it with a drag & drop editor and launch.
|
25 |
+
|
26 |
+
These website templates have the following features:
|
27 |
+
|
28 |
+
- Pre-designed pages such as homepage, about, services and contact.
|
29 |
+
- Responsive designs that work on all devices.
|
30 |
+
- Designed with Elementor page builder for easy drag & drop editing.
|
31 |
+
- Copyright free stock images, that you can use on your website.
|
32 |
+
- Automatically installs all necessary plugins.
|
33 |
+
|
34 |
+
= What website templates can I import? =
|
35 |
+
Responsive comes with 30+ ready-to-use WordPress [website templates](https://cyberchimps.com/responsive-ready-websites/).
|
36 |
+
|
37 |
+
**Business Website Templates For Responsive Theme**
|
38 |
+
|
39 |
+
- Startup WordPress Template
|
40 |
+
- Business WordPress Template
|
41 |
+
- Corporate WordPress Template
|
42 |
|
43 |
+
**Health & Fitness Website Templates For Responsive Theme**
|
44 |
|
45 |
+
- Health Coach WordPress Template
|
46 |
+
- Gym WordPress Template
|
47 |
+
- Yoga WordPress Template
|
48 |
|
49 |
+
**Local Business Website Templates For Responsive Theme**
|
50 |
|
51 |
+
- Accountant WordPress Template
|
52 |
+
- Lawyer WordPress Template
|
53 |
+
- Restaurant WordPress Template
|
54 |
+
- Photography WordPress Template
|
55 |
+
- Tattoo Studio WordPress Templates
|
56 |
|
57 |
+
**Real Estate Website Templates For Responsive Theme**
|
58 |
|
59 |
+
- Construction WordPress Template
|
60 |
+
- Real Estate WordPress Template
|
61 |
+
- Interior Decorator WordPress Template
|
62 |
|
63 |
+
**Blogs Templates For Responsive Theme**
|
64 |
+
|
65 |
+
- Cooking & Recipe Blog WordPress Templates
|
66 |
+
- Travel Blog WordPress Templates
|
67 |
+
- Lifestyle Blog WordPress Templates
|
68 |
+
|
69 |
+
**WooCommerce WordPress Templates**
|
70 |
+
|
71 |
+
- General store website templates
|
72 |
+
- Fashion & jewellery website templates
|
73 |
+
- Furniture store website templates
|
74 |
+
|
75 |
+
= How to import ready sites? =
|
76 |
+
Here's how it works:
|
77 |
+
|
78 |
+
[youtube https://www.youtube.com/watch?v=JNeQKg1QJhk&t=2s]
|
79 |
|
80 |
== Frequently Asked Questions ==
|
81 |
|
102 |
4. Your website is ready
|
103 |
|
104 |
== Changelog ==
|
105 |
+
= 2.2.0 - 18th December 2019 =
|
106 |
+
* Added - Responsive theme Rollback
|
107 |
+
* Added - Import Process status Log
|
108 |
+
|
109 |
= 2.1.1 - 12th December 2019 =
|
110 |
* Fix - Responsive Ready Sites Importer plugin only works with Responsive theme
|
111 |
|
197 |
* Bug fixes
|
198 |
|
199 |
= 1.0.0 =
|
200 |
+
* Initial set up and release
|
responsive-add-ons.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Responsive Ready Sites Importer
|
4 |
Plugin URI: http://wordpress.org/plugins/responsive-add-ons/
|
5 |
Description: Import Responsive Ready Sites that help you launch your website quickly. Just import, update & hit the launch button.
|
6 |
-
Version: 2.
|
7 |
Author: CyberChimps
|
8 |
Author URI: http://www.cyberchimps.com
|
9 |
License: GPL2
|
@@ -52,7 +52,7 @@ if ( ! function_exists( 'ra_fs' ) ) {
|
|
52 |
'slug' => 'responsive-add-ons',
|
53 |
'product_name' => 'Responsive Ready Sites Importer',
|
54 |
'module_type' => 'plugin',
|
55 |
-
'version' => '2.
|
56 |
'plugin_basename' => 'responsive-add-ons/responsive-add-ons.php',
|
57 |
) );
|
58 |
}
|
@@ -122,6 +122,7 @@ if( !class_exists( 'Responsive_Addons' ) ) {
|
|
122 |
|
123 |
add_action( 'init', array( $this, 'app_output_buffer' ) );
|
124 |
self::set_api_url();
|
|
|
125 |
}
|
126 |
|
127 |
/**
|
@@ -245,6 +246,7 @@ if( !class_exists( 'Responsive_Addons' ) ) {
|
|
245 |
* Stuff to do when you activate
|
246 |
*/
|
247 |
public static function activate() {
|
|
|
248 |
}
|
249 |
|
250 |
/**
|
@@ -691,7 +693,17 @@ if( !class_exists( 'Responsive_Addons' ) ) {
|
|
691 |
|
692 |
$file_name = 'responsive-ready-sites-backup-' . date( 'd-M-Y-h-i-s' ) . '.json';
|
693 |
$old_settings = get_option( 'responsive_theme_options', array() );
|
694 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
695 |
wp_send_json_success();
|
696 |
}
|
697 |
|
@@ -1015,6 +1027,38 @@ if( class_exists( 'Responsive_Addons' ) ) {
|
|
1015 |
$responsive = new Responsive_Addons();
|
1016 |
}
|
1017 |
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
Plugin Name: Responsive Ready Sites Importer
|
4 |
Plugin URI: http://wordpress.org/plugins/responsive-add-ons/
|
5 |
Description: Import Responsive Ready Sites that help you launch your website quickly. Just import, update & hit the launch button.
|
6 |
+
Version: 2.2.0
|
7 |
Author: CyberChimps
|
8 |
Author URI: http://www.cyberchimps.com
|
9 |
License: GPL2
|
52 |
'slug' => 'responsive-add-ons',
|
53 |
'product_name' => 'Responsive Ready Sites Importer',
|
54 |
'module_type' => 'plugin',
|
55 |
+
'version' => '2.2.0',
|
56 |
'plugin_basename' => 'responsive-add-ons/responsive-add-ons.php',
|
57 |
) );
|
58 |
}
|
122 |
|
123 |
add_action( 'init', array( $this, 'app_output_buffer' ) );
|
124 |
self::set_api_url();
|
125 |
+
|
126 |
}
|
127 |
|
128 |
/**
|
246 |
* Stuff to do when you activate
|
247 |
*/
|
248 |
public static function activate() {
|
249 |
+
add_option( 'analytics_activation_redirect_responsive-add-ons', true );
|
250 |
}
|
251 |
|
252 |
/**
|
693 |
|
694 |
$file_name = 'responsive-ready-sites-backup-' . date( 'd-M-Y-h-i-s' ) . '.json';
|
695 |
$old_settings = get_option( 'responsive_theme_options', array() );
|
696 |
+
|
697 |
+
$upload_dir = Responsive_Ready_Sites_Importer_Log::get_instance()->log_dir();
|
698 |
+
$upload_path = trailingslashit( $upload_dir['path'] );
|
699 |
+
$log_file = $upload_path . $file_name;
|
700 |
+
$file_system = Responsive_Ready_Sites_Importer_Log::get_instance()->get_filesystem();
|
701 |
+
|
702 |
+
// If file Write fails
|
703 |
+
if ( false === $file_system->put_contents( $log_file, json_encode( $old_settings ), FS_CHMOD_FILE ) ) {
|
704 |
+
update_option( 'responsive_ready_sites_' . $file_name, $old_settings );
|
705 |
+
}
|
706 |
+
|
707 |
wp_send_json_success();
|
708 |
}
|
709 |
|
1027 |
$responsive = new Responsive_Addons();
|
1028 |
}
|
1029 |
|
1030 |
+
// load the latest sdk version from the active Responsive theme.
|
1031 |
+
if ( ! function_exists( 'responsive_sdk_load_latest' ) ) :
|
1032 |
+
/**
|
1033 |
+
* Always load the latest sdk version.
|
1034 |
+
*/
|
1035 |
+
function responsive_sdk_load_latest() {
|
1036 |
+
/**
|
1037 |
+
* Don't load the library if we are on < 5.4.
|
1038 |
+
*/
|
1039 |
+
if ( version_compare( PHP_VERSION, '5.4.32', '<' ) ) {
|
1040 |
+
return;
|
1041 |
+
}
|
1042 |
+
require_once dirname( __FILE__ ) . '/admin/rollback/start.php';
|
1043 |
+
}
|
1044 |
+
endif;
|
1045 |
+
add_action( 'init', 'responsive_sdk_load_latest' );
|
1046 |
+
|
1047 |
+
|
1048 |
+
if ( ! function_exists( 'responsive_addon_load_sdk' ) ) {
|
1049 |
+
/**
|
1050 |
+
* Loads products array.
|
1051 |
+
*
|
1052 |
+
* @param array $products All products.
|
1053 |
+
*
|
1054 |
+
* @return array Products array.
|
1055 |
+
*/
|
1056 |
+
function responsive_addon_load_sdk( $products ) {
|
1057 |
+
$theme_name = wp_get_theme();
|
1058 |
+
if ( 'Responsive' === $theme_name->get( 'Name' ) ) {
|
1059 |
+
$products[] = get_template_directory() . '/style.css';
|
1060 |
+
}
|
1061 |
+
return $products;
|
1062 |
+
}
|
1063 |
+
}
|
1064 |
+
add_filter( 'responsive_sdk_products', 'responsive_addon_load_sdk' );
|