Version Description
Download this release
Release Info
Developer | creativethemeshq |
Plugin | Blocksy Companion |
Version | 1.7.32 |
Comparing to | |
See all releases |
Code changes from version 1.0.3 to 1.7.32
- blocksy-companion.php +100 -48
- framework/autoload.php +57 -27
- framework/cache-reset-manager.php +167 -0
- framework/cli.php +82 -0
- framework/dashboard.php +105 -1
- framework/edd/theme-updater-admin.php +449 -0
- framework/edd/theme-updater-class.php +165 -0
- framework/extensions-manager-api.php +33 -6
- framework/extensions-manager.php +331 -208
- framework/extensions/cookies-consent/config.php +2 -1
- framework/extensions/cookies-consent/customizer.php +66 -19
- framework/extensions/cookies-consent/extension.php +65 -18
- framework/extensions/cookies-consent/global.php +53 -31
- framework/extensions/cookies-consent/helpers.php +18 -15
- framework/extensions/cookies-consent/readme.php +17 -5
- framework/extensions/cookies-consent/static/bundle/main.css +3 -3
- framework/extensions/cookies-consent/static/bundle/main.js +3 -3
- framework/extensions/cookies-consent/static/bundle/sync.js +1 -1
- framework/extensions/cookies-consent/static/images/type-1.svg +16 -23
- framework/extensions/cookies-consent/static/images/type-2.svg +17 -29
- framework/extensions/cookies-consent/static/js/ct-events.js +270 -0
- framework/extensions/cookies-consent/static/js/helpers.js +7 -0
- framework/extensions/cookies-consent/static/js/lazy-load-helpers.js +20 -0
- framework/extensions/cookies-consent/static/js/main.js +3 -2
- framework/extensions/cookies-consent/static/js/sync.js +16 -5
- framework/extensions/cookies-consent/static/js/sync/helpers.js +145 -0
- framework/extensions/cookies-consent/static/js/variables.js +17 -7
- framework/extensions/cookies-consent/static/sass/main.scss +28 -29
- framework/extensions/mailchimp/admin-static/bundle/1.2c9ebf0a36c6c732fee6.js +14 -0
- framework/extensions/mailchimp/admin-static/bundle/2.976c8f43abfe584b1a9d.js +1 -0
- framework/extensions/mailchimp/admin-static/bundle/main.js +1 -1
- framework/extensions/mailchimp/admin-static/bundle/sync.js +1 -1
- framework/extensions/mailchimp/admin-static/js/ListPicker.js +1 -1
- framework/extensions/mailchimp/admin-static/js/ListPicker/Implementation.js +4 -2
- framework/extensions/mailchimp/admin-static/js/main.js +1 -0
- framework/extensions/mailchimp/admin-static/js/sync.js +56 -29
- framework/extensions/mailchimp/admin-static/js/variables.js +23 -10
- framework/extensions/mailchimp/config.php +1 -0
- framework/extensions/mailchimp/ct-mailchimp/options.php +26 -2
- framework/extensions/mailchimp/ct-mailchimp/view.php +30 -18
- framework/extensions/mailchimp/customizer.php +81 -45
- framework/extensions/mailchimp/dashboard-static/bundle/main.js +4 -10
- framework/extensions/mailchimp/dashboard-static/js/EditCredentials.js +72 -92
- framework/extensions/mailchimp/dashboard-static/js/ListPicker.js +15 -16
- framework/extensions/mailchimp/dashboard-static/js/Mailchimp.js +36 -7
- framework/extensions/mailchimp/dashboard-static/js/hooks/useActivationWithRequirements.js +10 -11
- framework/extensions/mailchimp/dashboard-static/js/main.js +1 -0
- framework/extensions/mailchimp/extension.php +54 -20
- framework/extensions/mailchimp/global.php +80 -42
- framework/extensions/mailchimp/helpers.php +51 -17
- framework/extensions/mailchimp/mailchimp-manager.php +37 -10
- framework/extensions/mailchimp/pre-boot.php +0 -1
- framework/extensions/mailchimp/readme.php +5 -11
- framework/extensions/mailchimp/static/bundle/main.css +3 -3
- framework/extensions/mailchimp/static/bundle/main.js +1 -0
- framework/extensions/mailchimp/static/js/main.js +82 -0
- framework/extensions/mailchimp/static/sass/main.scss +28 -18
- framework/extensions/mailchimp/static/sass/single-block.scss +42 -26
- framework/extensions/mailchimp/static/sass/widget.scss +21 -19
- framework/extensions/trending/config.php +6 -0
- framework/extensions/trending/customizer.php +193 -0
- framework/extensions/trending/extension.php +83 -0
- framework/extensions/trending/global.php +53 -0
- framework/extensions/trending/helpers.php +195 -0
- framework/extensions/trending/static/bundle/main.css +7 -0
- framework/extensions/trending/static/bundle/main.js +1 -0
- framework/extensions/trending/static/bundle/sync.js +1 -0
- framework/extensions/trending/static/js/main.js +17 -0
- framework/extensions/trending/static/js/sync.js +42 -0
- framework/extensions/trending/static/js/trending-block.js +139 -0
- framework/extensions/trending/static/sass/main.scss +0 -0
- framework/extensions/widgets/static/bundle/main.css +3 -3
- framework/extensions/widgets/static/sass/about-me.scss +67 -0
- framework/extensions/widgets/static/sass/contact-info.scss +19 -26
- framework/extensions/widgets/static/sass/facebook.scss +37 -0
- framework/extensions/widgets/static/sass/main.scss +4 -0
- framework/extensions/widgets/static/sass/posts.scss +118 -35
- framework/extensions/widgets/static/sass/quote.scss +39 -0
- framework/extensions/widgets/static/sass/social-icons.scss +23 -0
- framework/extensions/widgets/widgets/ct-about-me/helpers.php +18 -0
- framework/extensions/widgets/widgets/ct-about-me/options.php +235 -0
- framework/extensions/widgets/widgets/ct-about-me/view.php +139 -0
- framework/extensions/widgets/widgets/ct-about-me/widget.php +22 -0
- framework/extensions/widgets/widgets/ct-advertisement/view.php +9 -3
- framework/extensions/widgets/widgets/ct-advertisement/widget.php +1 -0
- framework/extensions/widgets/widgets/ct-contact-info/options.php +51 -17
- framework/extensions/widgets/widgets/ct-contact-info/view.php +10 -88
- framework/extensions/widgets/widgets/ct-contact-info/widget.php +1 -0
- framework/extensions/widgets/widgets/ct-facebook/options.php +52 -0
- framework/extensions/widgets/widgets/ct-facebook/view.php +61 -0
- framework/extensions/widgets/widgets/ct-facebook/widget.php +22 -0
- framework/extensions/widgets/widgets/ct-posts/options.php +272 -61
- framework/extensions/widgets/widgets/ct-posts/view.php +168 -67
- framework/extensions/widgets/widgets/ct-posts/widget.php +1 -0
- framework/extensions/widgets/widgets/ct-quote/options.php +55 -0
- framework/extensions/widgets/widgets/ct-quote/view.php +57 -0
- framework/extensions/widgets/widgets/ct-quote/widget.php +22 -0
- framework/extensions/widgets/widgets/ct-socials/options.php +8 -58
- framework/extensions/widgets/widgets/ct-socials/view.php +7 -9
- framework/extensions/widgets/widgets/ct-socials/widget.php +1 -0
- framework/extensions/woocommerce-extra/config.php +7 -0
- framework/extensions/woocommerce-extra/customizer.php +45 -0
- framework/extensions/woocommerce-extra/extension.php +100 -0
- framework/extensions/woocommerce-extra/floating-cart.php +92 -0
- framework/extensions/woocommerce-extra/global.php +70 -0
- framework/extensions/woocommerce-extra/helpers.php +281 -0
- framework/extensions/woocommerce-extra/readme.php +37 -0
- framework/extensions/woocommerce-extra/static/bundle/main.css +8 -0
- framework/extensions/woocommerce-extra/static/bundle/main.js +1 -0
- framework/extensions/woocommerce-extra/static/bundle/sync.js +1 -0
- framework/extensions/woocommerce-extra/static/js/floating-cart.js +94 -0
- framework/extensions/woocommerce-extra/static/js/helpers.js +15 -0
- framework/extensions/woocommerce-extra/static/js/main.js +217 -0
- framework/extensions/woocommerce-extra/static/js/sync.js +19 -0
- framework/extensions/woocommerce-extra/static/js/variables.js +28 -0
- framework/extensions/woocommerce-extra/static/sass/floating-bar/main.scss +156 -0
- framework/extensions/woocommerce-extra/static/sass/main.scss +3 -0
- framework/extensions/woocommerce-extra/static/sass/quick-view/main.scss +8 -0
- framework/extensions/woocommerce-extra/static/sass/quick-view/quick-view-button.scss +44 -0
- framework/extensions/woocommerce-extra/static/sass/quick-view/quick-view-card.scss +39 -0
- framework/extensions/woocommerce-extra/static/sass/quick-view/quick-view-gallery.scss +32 -0
- framework/extensions/woocommerce-extra/static/sass/quick-view/quick-view-loader.scss +10 -0
- framework/extensions/woocommerce-extra/static/sass/quick-view/quick-view-modal.scss +23 -0
- framework/extensions/woocommerce-extra/static/sass/quick-view/quick-view-summary.scss +63 -0
- framework/features/conditions-manager.php +455 -0
- framework/features/demo-install.php +340 -0
- framework/features/demo-install/child-theme.php +121 -0
- framework/features/demo-install/content-eraser.php +175 -0
- framework/features/demo-install/content-export.php +663 -0
- framework/features/demo-install/content-installer.php +416 -0
- framework/features/demo-install/fake-content-eraser.php +273 -0
- framework/features/demo-install/install-finish.php +189 -0
- framework/features/demo-install/options-export.php +106 -0
- framework/features/demo-install/options-import.php +319 -0
- framework/features/demo-install/parsers.php +701 -0
- framework/features/demo-install/plugins-uninstaller.php +44 -0
- framework/features/demo-install/required-plugins.php +85 -0
- framework/features/demo-install/widgets-export.php +67 -0
- framework/features/demo-install/widgets-import.php +277 -0
- framework/features/demo-install/wp-importer.php +1345 -0
- framework/features/dynamic-css.php +270 -0
- framework/features/google-analytics.php +63 -37
- framework/features/header.php +520 -0
- framework/features/header/account-modal.php +125 -0
- framework/features/header/header-options.php +177 -0
- framework/features/header/items/account/config.php +24 -0
- framework/features/header/items/account/dynamic-styles.php +277 -0
- framework/features/header/items/account/options.php +388 -0
- framework/features/header/items/account/sync.js +169 -0
- framework/features/header/items/account/view.php +101 -0
- framework/features/opengraph-meta-data.php +224 -0
- framework/helpers/blocksy-integration.php +177 -0
- framework/helpers/helpers.php +102 -0
- framework/theme-integration.php +228 -14
- framework/views/optin.php +6 -0
- framework/widgets-manager.php +40 -31
- freemius-pricing/178afa6030e76635dbe835e111d2c507.png +0 -0
- freemius-pricing/27b5a722a5553d9de0170325267fccec.png +0 -0
- freemius-pricing/4375c4a3ddc6f637c2ab9a2d7220f91e.png +0 -0
- freemius-pricing/5480ed23b199531a8cbc05924f26952b.png +0 -0
- freemius-pricing/b4f3b958f4a019862d81b15f3f8eee3a.svg +402 -0
- freemius-pricing/c03f665db27af43971565560adfba594.png +0 -0
- freemius-pricing/cb5fc4f6ec7ada72e986f6e7dde365bf.png +0 -0
- freemius-pricing/dd89563360f0272635c8f0ab7d7f1402.png +0 -0
- freemius-pricing/e366d70661d8ad2493bd6afbd779f125.png +0 -0
- freemius-pricing/f3aac72a8e63997d6bb888f816457e9b.png +0 -0
- freemius-pricing/f928f1be99776af83e8e6be4baf8ffe7.svg +227 -0
- freemius-pricing/fde48e4609a6ddc11d639fc2421f2afd.png +0 -0
- freemius-pricing/freemius-pricing.js +27 -0
blocksy-companion.php
CHANGED
@@ -3,65 +3,117 @@
|
|
3 |
/*
|
4 |
Plugin Name: Blocksy Companion
|
5 |
Description: This plugin is the companion for the Blocksy theme, it runs and adds its enhacements only if the Blocksy theme is installed and active.
|
6 |
-
Version: 1.
|
7 |
Author: CreativeThemes
|
8 |
Author URI: https://creativethemes.com
|
9 |
Text Domain: blc
|
10 |
Domain Path: /languages/
|
11 |
-
Network: true
|
12 |
License: GPLv2 or later
|
13 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
14 |
*/
|
15 |
|
16 |
-
if ( !
|
17 |
-
|
|
|
18 |
}
|
19 |
-
define( 'BLOCKSY__FILE__', __FILE__ );
|
20 |
-
define( 'BLOCKSY_PLUGIN_BASE', plugin_basename( BLOCKSY__FILE__ ) );
|
21 |
-
define( 'BLOCKSY_PATH', plugin_dir_path( BLOCKSY__FILE__ ) );
|
22 |
-
define( 'BLOCKSY_URL', plugin_dir_url( BLOCKSY__FILE__ ) );
|
23 |
|
24 |
-
add_action( 'plugins_loaded', 'blc_load_plugin_textdomain' );
|
25 |
|
26 |
-
if (
|
27 |
-
|
28 |
-
} elseif ( ! version_compare( get_bloginfo( 'version' ), '5.0', '>=' ) ) {
|
29 |
-
add_action( 'admin_notices', 'blc_fail_wp_version' );
|
30 |
} else {
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
/**
|
45 |
-
* Blocksy admin notice for minimum PHP version.
|
46 |
-
*
|
47 |
-
* Warning when the site doesn't have the minimum required PHP version.
|
48 |
-
*/
|
49 |
-
function blc_fail_php_version() {
|
50 |
-
/* translators: %s: PHP version */
|
51 |
-
$message = sprintf( esc_html__( 'Blocksy requires PHP version %s+, plugin is currently NOT RUNNING.', 'blc' ), '7.0' );
|
52 |
-
$html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) );
|
53 |
-
echo wp_kses_post( $html_message );
|
54 |
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Blocksy admin notice for minimum WordPress version.
|
58 |
-
*
|
59 |
-
* Warning when the site doesn't have the minimum required WordPress version.
|
60 |
-
*/
|
61 |
-
function blc_fail_wp_version() {
|
62 |
-
/* translators: %s: WordPress version */
|
63 |
-
$message = sprintf( esc_html__( 'Blocksy requires WordPress version %s+. Because you are using an earlier version, the plugin is currently NOT RUNNING.', 'blc' ), '5.0' );
|
64 |
-
$html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) );
|
65 |
-
echo wp_kses_post( $html_message );
|
66 |
-
}
|
67 |
-
|
3 |
/*
|
4 |
Plugin Name: Blocksy Companion
|
5 |
Description: This plugin is the companion for the Blocksy theme, it runs and adds its enhacements only if the Blocksy theme is installed and active.
|
6 |
+
Version: 1.7.32
|
7 |
Author: CreativeThemes
|
8 |
Author URI: https://creativethemes.com
|
9 |
Text Domain: blc
|
10 |
Domain Path: /languages/
|
|
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
*/
|
14 |
|
15 |
+
if ( !defined( 'ABSPATH' ) ) {
|
16 |
+
exit;
|
17 |
+
// Exit if accessed directly.
|
18 |
}
|
|
|
|
|
|
|
|
|
19 |
|
|
|
20 |
|
21 |
+
if ( function_exists( 'blc_fs' ) ) {
|
22 |
+
blc_fs()->set_basename( false, __FILE__ );
|
|
|
|
|
23 |
} else {
|
24 |
+
|
25 |
+
if ( !function_exists( 'blc_fs' ) ) {
|
26 |
+
global $blc_fs ;
|
27 |
+
|
28 |
+
if ( !isset( $blc_fs ) ) {
|
29 |
+
// Include Freemius SDK.
|
30 |
+
require_once dirname( __FILE__ ) . '/freemius/start.php';
|
31 |
+
$blc_fs = fs_dynamic_init( array(
|
32 |
+
'id' => '5115',
|
33 |
+
'slug' => 'blocksy-companion',
|
34 |
+
'premium_slug' => 'blocksy-companion-pro',
|
35 |
+
'type' => 'plugin',
|
36 |
+
'public_key' => 'pk_b00a5cbae90b2e948015a7d0710f5',
|
37 |
+
'premium_suffix' => 'PRO',
|
38 |
+
'is_premium' => false,
|
39 |
+
'has_addons' => false,
|
40 |
+
'has_paid_plans' => true,
|
41 |
+
'menu' => ( true ? [
|
42 |
+
'slug' => 'ct-dashboard',
|
43 |
+
'support' => false,
|
44 |
+
'contact' => false,
|
45 |
+
'pricing' => true,
|
46 |
+
'account' => true,
|
47 |
+
] : [
|
48 |
+
'support' => false,
|
49 |
+
'contact' => false,
|
50 |
+
'pricing' => false,
|
51 |
+
'account' => false,
|
52 |
+
] ),
|
53 |
+
'is_live' => true,
|
54 |
+
) );
|
55 |
+
function blc_fs()
|
56 |
+
{
|
57 |
+
global $blc_fs ;
|
58 |
+
return $blc_fs;
|
59 |
+
}
|
60 |
+
|
61 |
+
blc_fs();
|
62 |
+
do_action( 'blc_fs_loaded' );
|
63 |
+
blc_fs()->add_filter( 'freemius_pricing_js_path', function ( $d ) {
|
64 |
+
// return BLOCKSY_PATH . 'freemius-pricing/freemius-pricing.js';
|
65 |
+
// Only in DEV!!
|
66 |
+
return WP_CONTENT_DIR . '/plugins/blocksy-companion/freemius-pricing/freemius-pricing.js';
|
67 |
+
} );
|
68 |
+
}
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
define( 'BLOCKSY__FILE__', __FILE__ );
|
73 |
+
define( 'BLOCKSY_PLUGIN_BASE', plugin_basename( BLOCKSY__FILE__ ) );
|
74 |
+
define( 'BLOCKSY_PATH', plugin_dir_path( BLOCKSY__FILE__ ) );
|
75 |
+
define( 'BLOCKSY_URL', plugin_dir_url( BLOCKSY__FILE__ ) );
|
76 |
+
add_action( 'init', function () {
|
77 |
+
/**
|
78 |
+
* Load Blocksy textdomain.
|
79 |
+
*
|
80 |
+
* Load gettext translate for Blocksy text domain.
|
81 |
+
*/
|
82 |
+
load_plugin_textdomain( 'blc', false, dirname( BLOCKSY_PLUGIN_BASE ) . '/languages' );
|
83 |
+
} );
|
84 |
+
|
85 |
+
if ( !version_compare( PHP_VERSION, '7.0', '>=' ) ) {
|
86 |
+
add_action( 'admin_notices', 'blc_fail_php_version' );
|
87 |
+
} elseif ( !version_compare( get_bloginfo( 'version' ), '5.0', '>=' ) ) {
|
88 |
+
add_action( 'admin_notices', 'blc_fail_wp_version' );
|
89 |
+
} else {
|
90 |
+
require BLOCKSY_PATH . 'plugin.php';
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Blocksy admin notice for minimum PHP version.
|
95 |
+
*
|
96 |
+
* Warning when the site doesn't have the minimum required PHP version.
|
97 |
+
*/
|
98 |
+
function blc_fail_php_version()
|
99 |
+
{
|
100 |
+
/* translators: %s: PHP version */
|
101 |
+
$message = sprintf( esc_html__( 'Blocksy requires PHP version %s+, plugin is currently NOT RUNNING.', 'blc' ), '7.0' );
|
102 |
+
$html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) );
|
103 |
+
echo wp_kses_post( $html_message ) ;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Blocksy admin notice for minimum WordPress version.
|
108 |
+
*
|
109 |
+
* Warning when the site doesn't have the minimum required WordPress version.
|
110 |
+
*/
|
111 |
+
function blc_fail_wp_version()
|
112 |
+
{
|
113 |
+
/* translators: %s: WordPress version */
|
114 |
+
$message = sprintf( esc_html__( 'Blocksy requires WordPress version %s+. Because you are using an earlier version, the plugin is currently NOT RUNNING.', 'blc' ), '5.0' );
|
115 |
+
$html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) );
|
116 |
+
echo wp_kses_post( $html_message ) ;
|
117 |
+
}
|
118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
framework/autoload.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
namespace Blocksy;
|
4 |
|
5 |
-
if (
|
6 |
exit; // Exit if accessed directly.
|
7 |
}
|
8 |
|
@@ -14,25 +14,55 @@ class Autoloader {
|
|
14 |
/**
|
15 |
* Classes map.
|
16 |
*
|
17 |
-
* Maps
|
18 |
*
|
19 |
* @static
|
20 |
*
|
21 |
* @var array Classes used by blocksy.
|
22 |
*/
|
23 |
-
private static
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
28 |
|
29 |
-
|
|
|
|
|
|
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
/**
|
38 |
* Run autoloader.
|
@@ -42,7 +72,7 @@ class Autoloader {
|
|
42 |
* @static
|
43 |
*/
|
44 |
public static function run() {
|
45 |
-
spl_autoload_register(
|
46 |
}
|
47 |
|
48 |
/**
|
@@ -54,14 +84,14 @@ class Autoloader {
|
|
54 |
*
|
55 |
* @param string $relative_class_name Class name.
|
56 |
*/
|
57 |
-
private static function load_class(
|
58 |
-
if (
|
59 |
-
$filename = BLOCKSY_PATH . '/' . self
|
60 |
} else {
|
61 |
$filename = strtolower(
|
62 |
preg_replace(
|
63 |
-
[
|
64 |
-
[
|
65 |
$relative_class_name
|
66 |
)
|
67 |
);
|
@@ -69,7 +99,7 @@ class Autoloader {
|
|
69 |
$filename = BLOCKSY_PATH . $filename . '.php';
|
70 |
}
|
71 |
|
72 |
-
if (
|
73 |
require $filename;
|
74 |
}
|
75 |
}
|
@@ -83,26 +113,26 @@ class Autoloader {
|
|
83 |
*
|
84 |
* @param string $class Class name.
|
85 |
*/
|
86 |
-
private static function autoload(
|
87 |
if (
|
88 |
-
0 !== strpos(
|
89 |
&&
|
90 |
-
! isset(
|
91 |
) {
|
92 |
return;
|
93 |
}
|
94 |
|
95 |
-
$relative_class_name = preg_replace(
|
96 |
|
97 |
$final_class_name = __NAMESPACE__ . '\\' . $relative_class_name;
|
98 |
|
99 |
-
if (
|
100 |
$final_class_name = $relative_class_name;
|
101 |
$relative_class_name = '_' . $relative_class_name;
|
102 |
}
|
103 |
|
104 |
-
if (
|
105 |
-
self::load_class(
|
106 |
}
|
107 |
}
|
108 |
}
|
2 |
|
3 |
namespace Blocksy;
|
4 |
|
5 |
+
if (! defined('ABSPATH')) {
|
6 |
exit; // Exit if accessed directly.
|
7 |
}
|
8 |
|
14 |
/**
|
15 |
* Classes map.
|
16 |
*
|
17 |
+
* Maps Blocksy classes to file names.
|
18 |
*
|
19 |
* @static
|
20 |
*
|
21 |
* @var array Classes used by blocksy.
|
22 |
*/
|
23 |
+
private static function get_classes_map() {
|
24 |
+
return apply_filters('blocksy_autoloader_classes_map', [
|
25 |
+
'ExtensionsManager' => 'framework/extensions-manager.php',
|
26 |
+
'ExtensionsManagerApi' => 'framework/extensions-manager-api.php',
|
27 |
+
'Dashboard' => 'framework/dashboard.php',
|
28 |
+
'ThemeIntegration' => 'framework/theme-integration.php',
|
29 |
+
'CacheResetManager' => 'framework/cache-reset-manager.php',
|
30 |
|
31 |
+
'GoogleAnalytics' => 'framework/features/google-analytics.php',
|
32 |
+
'OpenGraphMetaData' => 'framework/features/opengraph-meta-data.php',
|
33 |
+
'HeaderAdditions' => 'framework/features/header.php',
|
34 |
+
'ConditionsManager' => 'framework/features/conditions-manager.php',
|
35 |
|
36 |
+
'Cli' => 'framework/cli.php',
|
37 |
+
|
38 |
+
'DynamicCss' => 'framework/features/dynamic-css.php',
|
39 |
+
'DemoInstall' => 'framework/features/demo-install.php',
|
40 |
+
'DemoInstallContentExport' => 'framework/features/demo-install/content-export.php',
|
41 |
+
'DemoInstallWidgetsExport' => 'framework/features/demo-install/widgets-export.php',
|
42 |
+
'DemoInstallOptionsExport' => 'framework/features/demo-install/options-export.php',
|
43 |
+
|
44 |
+
'DemoInstallChildThemeInstaller' => 'framework/features/demo-install/child-theme.php',
|
45 |
+
'DemoInstallPluginsInstaller' => 'framework/features/demo-install/required-plugins.php',
|
46 |
+
'DemoInstallPluginsUninstaller' => 'framework/features/demo-install/plugins-uninstaller.php',
|
47 |
+
'DemoInstallContentInstaller' => 'framework/features/demo-install/content-installer.php',
|
48 |
+
'DemoInstallOptionsInstaller' => 'framework/features/demo-install/options-import.php',
|
49 |
+
'DemoInstallWidgetsInstaller' => 'framework/features/demo-install/widgets-import.php',
|
50 |
+
'DemoInstallContentEraser' => 'framework/features/demo-install/content-eraser.php',
|
51 |
+
'DemoInstallFakeContentEraser' => 'framework/features/demo-install/fake-content-eraser.php',
|
52 |
+
'DemoInstallFinalActions' => 'framework/features/demo-install/install-finish.php',
|
53 |
+
'Premium' => 'framework/premium/pro.php',
|
54 |
+
|
55 |
+
/**
|
56 |
+
* No namespace
|
57 |
+
*/
|
58 |
+
'_BlocksyWidgetFactory' => 'framework/widgets-manager.php',
|
59 |
+
'_Blocksy_WP_Import' => 'framework/features/demo-install/wp-importer.php',
|
60 |
+
|
61 |
+
// TODO: remove when getting rid of EDD
|
62 |
+
'_EDD_SL_Plugin_Updater' => 'framework/edd/EDD_SL_Plugin_Updater.php',
|
63 |
+
'_EDD_Theme_Updater_Admin' => 'framework/edd/theme-updater-admin.php'
|
64 |
+
]);
|
65 |
+
}
|
66 |
|
67 |
/**
|
68 |
* Run autoloader.
|
72 |
* @static
|
73 |
*/
|
74 |
public static function run() {
|
75 |
+
spl_autoload_register([__CLASS__, 'autoload']);
|
76 |
}
|
77 |
|
78 |
/**
|
84 |
*
|
85 |
* @param string $relative_class_name Class name.
|
86 |
*/
|
87 |
+
private static function load_class($relative_class_name) {
|
88 |
+
if (isset( self::get_classes_map()[$relative_class_name])) {
|
89 |
+
$filename = BLOCKSY_PATH . '/' . self::get_classes_map()[$relative_class_name];
|
90 |
} else {
|
91 |
$filename = strtolower(
|
92 |
preg_replace(
|
93 |
+
['/([a-z])([A-Z])/', '/_/', '/\\\/'],
|
94 |
+
['$1-$2', '-', DIRECTORY_SEPARATOR],
|
95 |
$relative_class_name
|
96 |
)
|
97 |
);
|
99 |
$filename = BLOCKSY_PATH . $filename . '.php';
|
100 |
}
|
101 |
|
102 |
+
if (is_readable($filename)) {
|
103 |
require $filename;
|
104 |
}
|
105 |
}
|
113 |
*
|
114 |
* @param string $class Class name.
|
115 |
*/
|
116 |
+
private static function autoload($class) {
|
117 |
if (
|
118 |
+
0 !== strpos($class, __NAMESPACE__ . '\\')
|
119 |
&&
|
120 |
+
! isset(self::get_classes_map()['_' . $class])
|
121 |
) {
|
122 |
return;
|
123 |
}
|
124 |
|
125 |
+
$relative_class_name = preg_replace('/^' . __NAMESPACE__ . '\\\/', '', $class);
|
126 |
|
127 |
$final_class_name = __NAMESPACE__ . '\\' . $relative_class_name;
|
128 |
|
129 |
+
if (isset(self::get_classes_map()['_' . $relative_class_name])) {
|
130 |
$final_class_name = $relative_class_name;
|
131 |
$relative_class_name = '_' . $relative_class_name;
|
132 |
}
|
133 |
|
134 |
+
if (! class_exists($final_class_name)) {
|
135 |
+
self::load_class($relative_class_name);
|
136 |
}
|
137 |
}
|
138 |
}
|
framework/cache-reset-manager.php
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Blocksy;
|
4 |
+
|
5 |
+
class CacheResetManager {
|
6 |
+
public function __construct() {
|
7 |
+
add_action(
|
8 |
+
'upgrader_process_complete',
|
9 |
+
[$this, 'handle_update'],
|
10 |
+
10, 2
|
11 |
+
);
|
12 |
+
}
|
13 |
+
|
14 |
+
public function handle_update($upgrader, $options) {
|
15 |
+
if ($options['action'] !== 'update') {
|
16 |
+
return;
|
17 |
+
}
|
18 |
+
|
19 |
+
if ($options['type'] === 'theme') {
|
20 |
+
if (in_array('blocksy', $options['themes'])) {
|
21 |
+
$this->run_cache_purge();
|
22 |
+
do_action('blocksy:dynamic-css:regenere_css_files');
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
if ($options['type'] === 'plugin') {
|
27 |
+
$plugins = [];
|
28 |
+
|
29 |
+
if (isset($options['plugins']) && is_array($options['plugins'])) {
|
30 |
+
$plugins = $options['plugins'];
|
31 |
+
}
|
32 |
+
|
33 |
+
if (in_array(BLOCKSY_PLUGIN_BASE, $plugins)) {
|
34 |
+
$this->run_cache_purge();
|
35 |
+
do_action('blocksy:dynamic-css:regenere_css_files');
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
public function run_cache_purge() {
|
41 |
+
# Purge all W3 Total Cache
|
42 |
+
if (function_exists('w3tc_pgcache_flush')) {
|
43 |
+
w3tc_pgcache_flush();
|
44 |
+
}
|
45 |
+
|
46 |
+
if (function_exists('w3tc_flush_all')) {
|
47 |
+
w3tc_flush_all();
|
48 |
+
}
|
49 |
+
|
50 |
+
# Purge WP Super Cache
|
51 |
+
if (function_exists('wp_cache_clear_cache')) {
|
52 |
+
wp_cache_clear_cache();
|
53 |
+
}
|
54 |
+
|
55 |
+
if (isset($GLOBALS['wp_fastest_cache'])) {
|
56 |
+
if (method_exists($GLOBALS['wp_fastest_cache'], 'deleteCache')) {
|
57 |
+
$GLOBALS['wp_fastest_cache']->deleteCache();
|
58 |
+
$GLOBALS['wp_fastest_cache']->deleteCache(true);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
if (function_exists('cachify_flush_cache')) {
|
63 |
+
cachify_flush_cache();
|
64 |
+
}
|
65 |
+
|
66 |
+
if (class_exists("comet_cache")) {
|
67 |
+
\comet_cache::clear();
|
68 |
+
}
|
69 |
+
|
70 |
+
if (class_exists("zencache")) {
|
71 |
+
\zencache::clear();
|
72 |
+
}
|
73 |
+
|
74 |
+
if (class_exists('LiteSpeed_Cache_Tags')) {
|
75 |
+
\LiteSpeed_Cache_Tags::add_purge_tag('*');
|
76 |
+
}
|
77 |
+
|
78 |
+
if (function_exists('sg_cachepress_purge_cache')) {
|
79 |
+
sg_cachepress_purge_cache();
|
80 |
+
}
|
81 |
+
|
82 |
+
if (class_exists('LiteSpeed_Cache_Purge')) {
|
83 |
+
\LiteSpeed_Cache_Purge::purge_all('Clear Cache For Me');
|
84 |
+
}
|
85 |
+
|
86 |
+
if (class_exists('WP_Optimize') && defined('WPO_PLUGIN_MAIN_PATH')) {
|
87 |
+
if (! class_exists('WP_Optimize_Cache_Commands')) include_once(WPO_PLUGIN_MAIN_PATH . 'cache/class-cache-commands.php');
|
88 |
+
if (! class_exists('WP_Optimize_Minify_Commands')) include_once(WPO_PLUGIN_MAIN_PATH . 'minify/class-wp-optimize-minify-commands.php');
|
89 |
+
|
90 |
+
if (class_exists('WP_Optimize_Cache_Commands')) {
|
91 |
+
$wpoptimize_cache_commands = new \WP_Optimize_Cache_Commands();
|
92 |
+
$wpoptimize_cache_commands->purge_page_cache();
|
93 |
+
}
|
94 |
+
|
95 |
+
if (class_exists('WP_Optimize_Minify_Commands')) {
|
96 |
+
$wpoptimize_minify_commands = new \WP_Optimize_Minify_Commands();
|
97 |
+
$wpoptimize_minify_commands->purge_minify_cache();
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
if (
|
102 |
+
class_exists('WPaaS\Plugin')
|
103 |
+
&&
|
104 |
+
function_exists('fastvelocity_godaddy_request')
|
105 |
+
) {
|
106 |
+
fastvelocity_godaddy_request('BAN');
|
107 |
+
}
|
108 |
+
|
109 |
+
# Purge WP Engine
|
110 |
+
if (class_exists("WpeCommon")) {
|
111 |
+
if (method_exists('WpeCommon', 'purge_memcached')) {
|
112 |
+
\WpeCommon::purge_memcached();
|
113 |
+
}
|
114 |
+
|
115 |
+
if (method_exists('WpeCommon', 'clear_maxcdn_cache')) {
|
116 |
+
\WpeCommon::clear_maxcdn_cache();
|
117 |
+
}
|
118 |
+
|
119 |
+
if (method_exists('WpeCommon', 'purge_varnish_cache')) {
|
120 |
+
\WpeCommon::purge_varnish_cache();
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
if (function_exists('rocket_clean_domain')) {
|
125 |
+
rocket_clean_domain();
|
126 |
+
}
|
127 |
+
|
128 |
+
if (function_exists('wp_cache_clean_cache')) {
|
129 |
+
global $file_prefix;
|
130 |
+
wp_cache_clean_cache( $file_prefix, true );
|
131 |
+
}
|
132 |
+
|
133 |
+
if (class_exists('autoptimizeCache')) {
|
134 |
+
\autoptimizeCache::clearall();
|
135 |
+
}
|
136 |
+
|
137 |
+
if (function_exists('fvm_purge_all')) {
|
138 |
+
fvm_purge_all();
|
139 |
+
}
|
140 |
+
|
141 |
+
if (function_exists('fastvelocity_purge_others')) {
|
142 |
+
fastvelocity_purge_others();
|
143 |
+
}
|
144 |
+
|
145 |
+
# wordpress default cache
|
146 |
+
if (function_exists('wp_cache_flush')) {
|
147 |
+
wp_cache_flush();
|
148 |
+
}
|
149 |
+
|
150 |
+
# https://wordpress.org/plugins/hummingbird-performance/
|
151 |
+
do_action('wphb_clear_page_cache');
|
152 |
+
|
153 |
+
if (class_exists('Swift_Performance_Cache')) {
|
154 |
+
\Swift_Performance_Cache::clear_all_cache();
|
155 |
+
}
|
156 |
+
|
157 |
+
if (class_exists('\SiteGround_Optimizer\Supercacher\Supercacher')) {
|
158 |
+
\SiteGround_Optimizer\Supercacher\Supercacher::get_instance()->purge_everything();
|
159 |
+
do_action('siteground_delete_assets');
|
160 |
+
}
|
161 |
+
|
162 |
+
if (class_exists('ShortPixelAI')) {
|
163 |
+
\ShortPixelAI::clear_css_cache();
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
framework/cli.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Blocksy;
|
4 |
+
|
5 |
+
class Cli {
|
6 |
+
public function __construct() {
|
7 |
+
\WP_CLI::add_command('blocksy demo plugins', function ($args) {
|
8 |
+
$plugins = [
|
9 |
+
'coblocks',
|
10 |
+
'elementor',
|
11 |
+
'contact-form-7',
|
12 |
+
'woocommerce'
|
13 |
+
];
|
14 |
+
|
15 |
+
foreach ($plugins as $plugin) {
|
16 |
+
\WP_CLI::runcommand('plugin install ' . $plugin, [] );
|
17 |
+
\WP_CLI::runcommand('plugin activate ' . $plugin, [] );
|
18 |
+
}
|
19 |
+
});
|
20 |
+
|
21 |
+
\WP_CLI::add_command('blocksy demo options', function ($args) {
|
22 |
+
$options = new DemoInstallOptionsInstaller([
|
23 |
+
'has_streaming' => false,
|
24 |
+
'demo_name' => 'Main:elementor'
|
25 |
+
]);
|
26 |
+
|
27 |
+
$options->import();
|
28 |
+
});
|
29 |
+
|
30 |
+
\WP_CLI::add_command('blocksy widgets drop', function ($args) {
|
31 |
+
$sidebars_widgets = get_option('sidebars_widgets', array());
|
32 |
+
|
33 |
+
if (! isset($sidebars_widgets['wp_inactive_widgets'])) {
|
34 |
+
$sidebars_widgets['wp_inactive_widgets'] = [];
|
35 |
+
}
|
36 |
+
|
37 |
+
foreach ($sidebars_widgets as $sidebar_id => $widgets) {
|
38 |
+
if (! $widgets) continue;
|
39 |
+
if ($sidebar_id === 'wp_inactive_widgets') {
|
40 |
+
continue;
|
41 |
+
}
|
42 |
+
|
43 |
+
if ($sidebar_id === 'array_version') {
|
44 |
+
continue;
|
45 |
+
}
|
46 |
+
|
47 |
+
foreach ($widgets as $widget_id) {
|
48 |
+
$sidebars_widgets['wp_inactive_widgets'][] = $widget_id;
|
49 |
+
}
|
50 |
+
|
51 |
+
$sidebars_widgets[$sidebar_id] = [];
|
52 |
+
}
|
53 |
+
|
54 |
+
update_option('sidebars_widgets', $sidebars_widgets);
|
55 |
+
unset($sidebars_widgets['array_version']);
|
56 |
+
|
57 |
+
set_theme_mod('sidebars_widgets', [
|
58 |
+
'time' => time(),
|
59 |
+
'data' => $sidebars_widgets
|
60 |
+
]);
|
61 |
+
});
|
62 |
+
|
63 |
+
\WP_CLI::add_command('blocksy demo widgets', function ($args) {
|
64 |
+
$options = new DemoInstallWidgetsInstaller([
|
65 |
+
'has_streaming' => false,
|
66 |
+
'demo_name' => 'Blocksy News:elementor'
|
67 |
+
]);
|
68 |
+
|
69 |
+
$options->import();
|
70 |
+
});
|
71 |
+
|
72 |
+
\WP_CLI::add_command('blocksy demo content', function ($args) {
|
73 |
+
$options = new DemoInstallContentInstaller([
|
74 |
+
'has_streaming' => false,
|
75 |
+
'demo_name' => 'Main:elementor'
|
76 |
+
]);
|
77 |
+
|
78 |
+
$options->import();
|
79 |
+
});
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
framework/dashboard.php
CHANGED
@@ -9,6 +9,109 @@ class Dashboard {
|
|
9 |
[ $this, 'enqueue_static' ],
|
10 |
100
|
11 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
}
|
13 |
|
14 |
public function enqueue_static() {
|
@@ -19,6 +122,7 @@ class Dashboard {
|
|
19 |
|
20 |
$deps = apply_filters('blocksy-dashboard-scripts-dependencies', [
|
21 |
'wp-i18n',
|
|
|
22 |
'ct-options-scripts'
|
23 |
]);
|
24 |
|
@@ -27,7 +131,7 @@ class Dashboard {
|
|
27 |
BLOCKSY_URL . 'static/bundle/dashboard.js',
|
28 |
$deps,
|
29 |
$data['Version'],
|
30 |
-
|
31 |
);
|
32 |
|
33 |
wp_enqueue_style(
|
9 |
[ $this, 'enqueue_static' ],
|
10 |
100
|
11 |
);
|
12 |
+
|
13 |
+
add_action('admin_body_class', function ($class) {
|
14 |
+
if (blc_fs()->is_activation_mode()) {
|
15 |
+
$class .= ' blocksy-fs-optin-dashboard';
|
16 |
+
}
|
17 |
+
|
18 |
+
return $class;
|
19 |
+
});
|
20 |
+
|
21 |
+
blc_fs()->add_filter(
|
22 |
+
'connect-message_on-premium',
|
23 |
+
function ($text) {
|
24 |
+
if (strpos($text, '<br>') !== false) {
|
25 |
+
$exploded_message = explode('<br>', $text);
|
26 |
+
|
27 |
+
$text = '<span>' . $exploded_message[0] . '</span>' . $exploded_message[1];
|
28 |
+
}
|
29 |
+
|
30 |
+
return $text;
|
31 |
+
}
|
32 |
+
);
|
33 |
+
|
34 |
+
blc_fs()->add_filter(
|
35 |
+
'connect_message_on_update',
|
36 |
+
function (
|
37 |
+
$message,
|
38 |
+
$user_first_name,
|
39 |
+
$product_title,
|
40 |
+
$user_login,
|
41 |
+
$site_link,
|
42 |
+
$freemius_link
|
43 |
+
) {
|
44 |
+
$is_network_upgrade_mode = ( fs_is_network_admin() && blc_fs()->is_network_upgrade_mode() );
|
45 |
+
$slug = blc_fs()->get_slug();
|
46 |
+
$is_gdpr_required = \FS_GDPR_Manager::instance()->is_required();
|
47 |
+
$hey_x_text = esc_html( sprintf( fs_text_x_inline( 'Hey %s,', 'greeting', 'hey-x', $slug ), $user_first_name ) );
|
48 |
+
|
49 |
+
$default_optin_message = $is_gdpr_required ?
|
50 |
+
fs_text_inline( 'Never miss an important update - opt in to our security & feature updates notifications, educational content, offers, and non-sensitive diagnostic tracking with %4$s. If you skip this, that\'s okay! %1$s will still work just fine.', 'connect-message_on-update', $slug ) :
|
51 |
+
fs_text_inline( 'Never miss an important update - opt in to our security & feature updates notifications, and non-sensitive diagnostic tracking with %4$s. If you skip this, that\'s okay! %1$s will still work just fine.', 'connect-message_on-update', $slug );
|
52 |
+
|
53 |
+
return (($is_network_upgrade_mode ?
|
54 |
+
'' :
|
55 |
+
/* translators: %s: name (e.g. Hey John,) */
|
56 |
+
'<span>' . $hey_x_text . '</span>'
|
57 |
+
) .
|
58 |
+
sprintf(
|
59 |
+
esc_html( $default_optin_message ),
|
60 |
+
'<b>' . esc_html( blc_fs()->get_plugin_name() ) . '</b>',
|
61 |
+
'<b>' . $user_login . '</b>',
|
62 |
+
$site_link,
|
63 |
+
$freemius_link
|
64 |
+
));
|
65 |
+
|
66 |
+
}, 10, 6
|
67 |
+
);
|
68 |
+
|
69 |
+
blc_fs()->add_action('connect/before', function () {
|
70 |
+
$path = dirname(__FILE__) . '/views/optin.php';
|
71 |
+
|
72 |
+
echo blc_call_fn(
|
73 |
+
['fn' => 'blocksy_render_view'],
|
74 |
+
$path,
|
75 |
+
[]
|
76 |
+
);
|
77 |
+
});
|
78 |
+
|
79 |
+
blc_fs()->add_action('connect/after', function () {
|
80 |
+
echo '</div>';
|
81 |
+
});
|
82 |
+
|
83 |
+
add_action(
|
84 |
+
'wp_ajax_blocksy_fs_connect_again',
|
85 |
+
function () {
|
86 |
+
if (! current_user_can('edit_theme_options')) {
|
87 |
+
wp_send_json_error();
|
88 |
+
}
|
89 |
+
|
90 |
+
blc_fs()->connect_again();
|
91 |
+
wp_send_json_success();
|
92 |
+
}
|
93 |
+
);
|
94 |
+
|
95 |
+
add_filter(
|
96 |
+
'blocksy_dashboard_localizations',
|
97 |
+
function ($d) {
|
98 |
+
$is_anonymous = blc_fs()->is_anonymous();
|
99 |
+
$connect_template = '';
|
100 |
+
|
101 |
+
if ($is_anonymous) {
|
102 |
+
ob_start();
|
103 |
+
blc_fs()->_connect_page_render();
|
104 |
+
$connect_template = ob_get_clean();
|
105 |
+
}
|
106 |
+
|
107 |
+
return array_merge([
|
108 |
+
'is_pro' => blc_fs()->is__premium_only(),
|
109 |
+
'is_anonymous' => $is_anonymous,
|
110 |
+
'connect_template' => $connect_template,
|
111 |
+
'has_beta_consent' => Plugin::instance()->user_wants_beta_updates()
|
112 |
+
], $d);
|
113 |
+
}
|
114 |
+
);
|
115 |
}
|
116 |
|
117 |
public function enqueue_static() {
|
122 |
|
123 |
$deps = apply_filters('blocksy-dashboard-scripts-dependencies', [
|
124 |
'wp-i18n',
|
125 |
+
'ct-events',
|
126 |
'ct-options-scripts'
|
127 |
]);
|
128 |
|
131 |
BLOCKSY_URL . 'static/bundle/dashboard.js',
|
132 |
$deps,
|
133 |
$data['Version'],
|
134 |
+
false
|
135 |
);
|
136 |
|
137 |
wp_enqueue_style(
|
framework/edd/theme-updater-admin.php
ADDED
@@ -0,0 +1,449 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Theme updater admin page and functions.
|
4 |
+
*
|
5 |
+
* @package EDD Theme Updater
|
6 |
+
*/
|
7 |
+
|
8 |
+
class EDD_Theme_Updater_Admin {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Variables required for the theme updater
|
12 |
+
*
|
13 |
+
* @since 1.0.0
|
14 |
+
* @type string
|
15 |
+
*/
|
16 |
+
protected $remote_api_url = null;
|
17 |
+
protected $theme_slug = null;
|
18 |
+
protected $version = null;
|
19 |
+
protected $author = null;
|
20 |
+
protected $download_id = null;
|
21 |
+
protected $renew_url = null;
|
22 |
+
protected $strings = null;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Initialize the class.
|
26 |
+
*
|
27 |
+
* @since 1.0.0
|
28 |
+
*/
|
29 |
+
function __construct( $config = array(), $strings = array() ) {
|
30 |
+
|
31 |
+
$config = wp_parse_args( $config, array(
|
32 |
+
'remote_api_url' => 'http://easydigitaldownloads.com',
|
33 |
+
'theme_slug' => get_template(),
|
34 |
+
'item_name' => '',
|
35 |
+
'license' => '',
|
36 |
+
'version' => '',
|
37 |
+
'author' => '',
|
38 |
+
'download_id' => '',
|
39 |
+
'renew_url' => ''
|
40 |
+
) );
|
41 |
+
|
42 |
+
// Set config arguments
|
43 |
+
$this->remote_api_url = $config['remote_api_url'];
|
44 |
+
$this->item_name = $config['item_name'];
|
45 |
+
$this->theme_slug = sanitize_key( $config['theme_slug'] );
|
46 |
+
$this->version = $config['version'];
|
47 |
+
$this->author = $config['author'];
|
48 |
+
$this->download_id = $config['download_id'];
|
49 |
+
$this->renew_url = $config['renew_url'];
|
50 |
+
|
51 |
+
// Populate version fallback
|
52 |
+
if ( '' == $config['version'] ) {
|
53 |
+
$theme = wp_get_theme( $this->theme_slug );
|
54 |
+
$this->version = $theme->get( 'Version' );
|
55 |
+
}
|
56 |
+
|
57 |
+
// Strings passed in from the updater config
|
58 |
+
$this->strings = $strings;
|
59 |
+
|
60 |
+
add_action( 'admin_init', array( $this, 'updater' ) );
|
61 |
+
// add_action( 'admin_init', array( $this, 'register_option' ) );
|
62 |
+
// add_action( 'admin_init', array( $this, 'license_action' ) );
|
63 |
+
// add_action( 'admin_menu', array( $this, 'license_menu' ) );
|
64 |
+
// add_action( 'update_option_' . $this->theme_slug . '_license_key', array( $this, 'activate_license' ), 10, 2 );
|
65 |
+
add_filter( 'http_request_args', array( $this, 'disable_wporg_request' ), 5, 2 );
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Creates the updater class.
|
70 |
+
*
|
71 |
+
* since 1.0.0
|
72 |
+
*/
|
73 |
+
function updater() {
|
74 |
+
|
75 |
+
/* If there is no valid license key status, don't allow updates. */
|
76 |
+
if ( get_option( $this->theme_slug . '_license_key_status', false) != 'valid' ) {
|
77 |
+
// return;
|
78 |
+
}
|
79 |
+
|
80 |
+
if ( !class_exists( 'EDD_Theme_Updater' ) ) {
|
81 |
+
// Load our custom theme updater
|
82 |
+
include( dirname( __FILE__ ) . '/theme-updater-class.php' );
|
83 |
+
}
|
84 |
+
|
85 |
+
new EDD_Theme_Updater(
|
86 |
+
array(
|
87 |
+
'remote_api_url' => $this->remote_api_url,
|
88 |
+
'version' => $this->version,
|
89 |
+
// 'license' => trim( get_option( $this->theme_slug . '_license_key' ) ),
|
90 |
+
'license' => '123456',
|
91 |
+
'item_name' => $this->item_name,
|
92 |
+
'author' => $this->author
|
93 |
+
),
|
94 |
+
$this->strings
|
95 |
+
);
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Adds a menu item for the theme license under the appearance menu.
|
100 |
+
*
|
101 |
+
* since 1.0.0
|
102 |
+
*/
|
103 |
+
function license_menu() {
|
104 |
+
|
105 |
+
$strings = $this->strings;
|
106 |
+
|
107 |
+
add_theme_page(
|
108 |
+
$strings['theme-license'],
|
109 |
+
$strings['theme-license'],
|
110 |
+
'manage_options',
|
111 |
+
$this->theme_slug . '-license',
|
112 |
+
array( $this, 'license_page' )
|
113 |
+
);
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Outputs the markup used on the theme license page.
|
118 |
+
*
|
119 |
+
* since 1.0.0
|
120 |
+
*/
|
121 |
+
function license_page() {
|
122 |
+
|
123 |
+
$strings = $this->strings;
|
124 |
+
|
125 |
+
$license = trim( get_option( $this->theme_slug . '_license_key' ) );
|
126 |
+
$status = get_option( $this->theme_slug . '_license_key_status', false );
|
127 |
+
|
128 |
+
// Checks license status to display under license key
|
129 |
+
if ( ! $license ) {
|
130 |
+
$message = $strings['enter-key'];
|
131 |
+
} else {
|
132 |
+
// delete_transient( $this->theme_slug . '_license_message' );
|
133 |
+
if ( ! get_transient( $this->theme_slug . '_license_message', false ) ) {
|
134 |
+
set_transient( $this->theme_slug . '_license_message', $this->check_license(), ( 60 * 60 * 24 ) );
|
135 |
+
}
|
136 |
+
$message = get_transient( $this->theme_slug . '_license_message' );
|
137 |
+
}
|
138 |
+
?>
|
139 |
+
<div class="wrap">
|
140 |
+
<h2><?php echo $strings['theme-license'] ?></h2>
|
141 |
+
<form method="post" action="options.php">
|
142 |
+
|
143 |
+
<?php settings_fields( $this->theme_slug . '-license' ); ?>
|
144 |
+
|
145 |
+
<table class="form-table">
|
146 |
+
<tbody>
|
147 |
+
|
148 |
+
<tr valign="top">
|
149 |
+
<th scope="row" valign="top">
|
150 |
+
<?php echo $strings['license-key']; ?>
|
151 |
+
</th>
|
152 |
+
<td>
|
153 |
+
<input id="<?php echo $this->theme_slug; ?>_license_key" name="<?php echo $this->theme_slug; ?>_license_key" type="text" class="regular-text" value="<?php echo esc_attr( $license ); ?>" />
|
154 |
+
<p class="description">
|
155 |
+
<?php echo $message; ?>
|
156 |
+
</p>
|
157 |
+
</td>
|
158 |
+
</tr>
|
159 |
+
|
160 |
+
<?php if ( $license ) { ?>
|
161 |
+
<tr valign="top">
|
162 |
+
<th scope="row" valign="top">
|
163 |
+
<?php echo $strings['license-action']; ?>
|
164 |
+
</th>
|
165 |
+
<td>
|
166 |
+
<?php
|
167 |
+
wp_nonce_field( $this->theme_slug . '_nonce', $this->theme_slug . '_nonce' );
|
168 |
+
if ( 'valid' == $status ) { ?>
|
169 |
+
<input type="submit" class="button-secondary" name="<?php echo $this->theme_slug; ?>_license_deactivate" value="<?php esc_attr_e( $strings['deactivate-license'] ); ?>"/>
|
170 |
+
<?php } else { ?>
|
171 |
+
<input type="submit" class="button-secondary" name="<?php echo $this->theme_slug; ?>_license_activate" value="<?php esc_attr_e( $strings['activate-license'] ); ?>"/>
|
172 |
+
<?php }
|
173 |
+
?>
|
174 |
+
</td>
|
175 |
+
</tr>
|
176 |
+
<?php } ?>
|
177 |
+
|
178 |
+
</tbody>
|
179 |
+
</table>
|
180 |
+
<?php submit_button(); ?>
|
181 |
+
</form>
|
182 |
+
<?php
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Registers the option used to store the license key in the options table.
|
187 |
+
*
|
188 |
+
* since 1.0.0
|
189 |
+
*/
|
190 |
+
function register_option() {
|
191 |
+
register_setting(
|
192 |
+
$this->theme_slug . '-license',
|
193 |
+
$this->theme_slug . '_license_key',
|
194 |
+
array( $this, 'sanitize_license' )
|
195 |
+
);
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Sanitizes the license key.
|
200 |
+
*
|
201 |
+
* since 1.0.0
|
202 |
+
*
|
203 |
+
* @param string $new License key that was submitted.
|
204 |
+
* @return string $new Sanitized license key.
|
205 |
+
*/
|
206 |
+
function sanitize_license( $new ) {
|
207 |
+
|
208 |
+
$old = get_option( $this->theme_slug . '_license_key' );
|
209 |
+
|
210 |
+
if ( $old && $old != $new ) {
|
211 |
+
// New license has been entered, so must reactivate
|
212 |
+
delete_option( $this->theme_slug . '_license_key_status' );
|
213 |
+
delete_transient( $this->theme_slug . '_license_message' );
|
214 |
+
}
|
215 |
+
|
216 |
+
return $new;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Makes a call to the API.
|
221 |
+
*
|
222 |
+
* @since 1.0.0
|
223 |
+
*
|
224 |
+
* @param array $api_params to be used for wp_remote_get.
|
225 |
+
* @return array $response decoded JSON response.
|
226 |
+
*/
|
227 |
+
function get_api_response( $api_params ) {
|
228 |
+
|
229 |
+
// Call the custom API.
|
230 |
+
$response = wp_remote_get(
|
231 |
+
add_query_arg( $api_params, $this->remote_api_url ),
|
232 |
+
array( 'timeout' => 15, 'sslverify' => false )
|
233 |
+
);
|
234 |
+
|
235 |
+
// Make sure the response came back okay.
|
236 |
+
if ( is_wp_error( $response ) ) {
|
237 |
+
return false;
|
238 |
+
}
|
239 |
+
|
240 |
+
$response = json_decode( wp_remote_retrieve_body( $response ) );
|
241 |
+
|
242 |
+
return $response;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Activates the license key.
|
247 |
+
*
|
248 |
+
* @since 1.0.0
|
249 |
+
*/
|
250 |
+
function activate_license() {
|
251 |
+
|
252 |
+
$license = trim( get_option( $this->theme_slug . '_license_key' ) );
|
253 |
+
|
254 |
+
// Data to send in our API request.
|
255 |
+
$api_params = array(
|
256 |
+
'edd_action' => 'activate_license',
|
257 |
+
'license' => $license,
|
258 |
+
'item_name' => urlencode( $this->item_name )
|
259 |
+
);
|
260 |
+
|
261 |
+
$license_data = $this->get_api_response( $api_params );
|
262 |
+
|
263 |
+
// $response->license will be either "active" or "inactive"
|
264 |
+
if ( $license_data && isset( $license_data->license ) ) {
|
265 |
+
update_option( $this->theme_slug . '_license_key_status', $license_data->license );
|
266 |
+
delete_transient( $this->theme_slug . '_license_message' );
|
267 |
+
}
|
268 |
+
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Deactivates the license key.
|
273 |
+
*
|
274 |
+
* @since 1.0.0
|
275 |
+
*/
|
276 |
+
function deactivate_license() {
|
277 |
+
|
278 |
+
// Retrieve the license from the database.
|
279 |
+
$license = trim( get_option( $this->theme_slug . '_license_key' ) );
|
280 |
+
|
281 |
+
// Data to send in our API request.
|
282 |
+
$api_params = array(
|
283 |
+
'edd_action' => 'deactivate_license',
|
284 |
+
'license' => $license,
|
285 |
+
'item_name' => urlencode( $this->item_name )
|
286 |
+
);
|
287 |
+
|
288 |
+
$license_data = $this->get_api_response( $api_params );
|
289 |
+
|
290 |
+
// $license_data->license will be either "deactivated" or "failed"
|
291 |
+
if ( $license_data && ( $license_data->license == 'deactivated' ) ) {
|
292 |
+
delete_option( $this->theme_slug . '_license_key_status' );
|
293 |
+
delete_transient( $this->theme_slug . '_license_message' );
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Constructs a renewal link
|
299 |
+
*
|
300 |
+
* @since 1.0.0
|
301 |
+
*/
|
302 |
+
function get_renewal_link() {
|
303 |
+
|
304 |
+
// If a renewal link was passed in the config, use that
|
305 |
+
if ( '' != $this->renew_url ) {
|
306 |
+
return $this->renew_url;
|
307 |
+
}
|
308 |
+
|
309 |
+
// If download_id was passed in the config, a renewal link can be constructed
|
310 |
+
// $license_key = trim( get_option( $this->theme_slug . '_license_key', false ) );
|
311 |
+
$license_key = '123456';
|
312 |
+
|
313 |
+
if ( '' != $this->download_id && $license_key ) {
|
314 |
+
$url = esc_url( $this->remote_api_url );
|
315 |
+
$url .= '/checkout/?edd_license_key=' . $license_key . '&download_id=' . $this->download_id;
|
316 |
+
return $url;
|
317 |
+
}
|
318 |
+
|
319 |
+
// Otherwise return the remote_api_url
|
320 |
+
return $this->remote_api_url;
|
321 |
+
|
322 |
+
}
|
323 |
+
|
324 |
+
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Checks if a license action was submitted.
|
328 |
+
*
|
329 |
+
* @since 1.0.0
|
330 |
+
*/
|
331 |
+
function license_action() {
|
332 |
+
|
333 |
+
if ( isset( $_POST[ $this->theme_slug . '_license_activate' ] ) ) {
|
334 |
+
if ( check_admin_referer( $this->theme_slug . '_nonce', $this->theme_slug . '_nonce' ) ) {
|
335 |
+
$this->activate_license();
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
if ( isset( $_POST[$this->theme_slug . '_license_deactivate'] ) ) {
|
340 |
+
if ( check_admin_referer( $this->theme_slug . '_nonce', $this->theme_slug . '_nonce' ) ) {
|
341 |
+
$this->deactivate_license();
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Checks if license is valid and gets expire date.
|
349 |
+
*
|
350 |
+
* @since 1.0.0
|
351 |
+
*
|
352 |
+
* @return string $message License status message.
|
353 |
+
*/
|
354 |
+
function check_license() {
|
355 |
+
|
356 |
+
$license = trim( get_option( $this->theme_slug . '_license_key' ) );
|
357 |
+
$strings = $this->strings;
|
358 |
+
|
359 |
+
$api_params = array(
|
360 |
+
'edd_action' => 'check_license',
|
361 |
+
'license' => $license,
|
362 |
+
'item_name' => urlencode( $this->item_name )
|
363 |
+
);
|
364 |
+
|
365 |
+
$license_data = $this->get_api_response( $api_params );
|
366 |
+
|
367 |
+
// If response doesn't include license data, return
|
368 |
+
if ( !isset( $license_data->license ) ) {
|
369 |
+
$message = $strings['license-unknown'];
|
370 |
+
return $message;
|
371 |
+
}
|
372 |
+
|
373 |
+
// Get expire date
|
374 |
+
$expires = false;
|
375 |
+
if ( isset( $license_data->expires ) ) {
|
376 |
+
$expires = date_i18n( get_option( 'date_format' ), strtotime( $license_data->expires ) );
|
377 |
+
$renew_link = '<a href="' . esc_url( $this->get_renewal_link() ) . '" target="_blank">' . $strings['renew'] . '</a>';
|
378 |
+
}
|
379 |
+
|
380 |
+
// Get site counts
|
381 |
+
$site_count = $license_data->site_count;
|
382 |
+
$license_limit = $license_data->license_limit;
|
383 |
+
|
384 |
+
// If unlimited
|
385 |
+
if ( 0 == $license_limit ) {
|
386 |
+
$license_limit = $strings['unlimited'];
|
387 |
+
}
|
388 |
+
|
389 |
+
if ( $license_data->license == 'valid' ) {
|
390 |
+
$message = $strings['license-key-is-active'] . ' ';
|
391 |
+
if ( $expires ) {
|
392 |
+
$message .= sprintf( $strings['expires%s'], $expires ) . ' ';
|
393 |
+
}
|
394 |
+
if ( $site_count && $license_limit ) {
|
395 |
+
$message .= sprintf( $strings['%1$s/%2$-sites'], $site_count, $license_limit );
|
396 |
+
}
|
397 |
+
} else if ( $license_data->license == 'expired' ) {
|
398 |
+
if ( $expires ) {
|
399 |
+
$message = sprintf( $strings['license-key-expired-%s'], $expires );
|
400 |
+
} else {
|
401 |
+
$message = $strings['license-key-expired'];
|
402 |
+
}
|
403 |
+
if ( $renew_link ) {
|
404 |
+
$message .= ' ' . $renew_link;
|
405 |
+
}
|
406 |
+
} else if ( $license_data->license == 'invalid' ) {
|
407 |
+
$message = $strings['license-keys-do-not-match'];
|
408 |
+
} else if ( $license_data->license == 'inactive' ) {
|
409 |
+
$message = $strings['license-is-inactive'];
|
410 |
+
} else if ( $license_data->license == 'disabled' ) {
|
411 |
+
$message = $strings['license-key-is-disabled'];
|
412 |
+
} else if ( $license_data->license == 'site_inactive' ) {
|
413 |
+
// Site is inactive
|
414 |
+
$message = $strings['site-is-inactive'];
|
415 |
+
} else {
|
416 |
+
$message = $strings['license-status-unknown'];
|
417 |
+
}
|
418 |
+
|
419 |
+
return $message;
|
420 |
+
}
|
421 |
+
|
422 |
+
/**
|
423 |
+
* Disable requests to wp.org repository for this theme.
|
424 |
+
*
|
425 |
+
* @since 1.0.0
|
426 |
+
*/
|
427 |
+
function disable_wporg_request( $r, $url ) {
|
428 |
+
return $r;
|
429 |
+
|
430 |
+
// If it's not a theme update request, bail.
|
431 |
+
if ( 0 !== strpos( $url, 'https://api.wordpress.org/themes/update-check/1.1/' ) ) {
|
432 |
+
return $r;
|
433 |
+
}
|
434 |
+
|
435 |
+
// Decode the JSON response
|
436 |
+
$themes = json_decode( $r['body']['themes'] );
|
437 |
+
|
438 |
+
// Remove the active parent and child themes from the check
|
439 |
+
$parent = get_option( 'template' );
|
440 |
+
$child = get_option( 'stylesheet' );
|
441 |
+
unset( $themes->themes->$parent );
|
442 |
+
unset( $themes->themes->$child );
|
443 |
+
|
444 |
+
// Encode the updated JSON response
|
445 |
+
$r['body']['themes'] = json_encode( $themes );
|
446 |
+
|
447 |
+
return $r;
|
448 |
+
}
|
449 |
+
}
|
framework/edd/theme-updater-class.php
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Theme updater class.
|
4 |
+
*
|
5 |
+
* @package EDD Theme Updater
|
6 |
+
*/
|
7 |
+
|
8 |
+
class EDD_Theme_Updater {
|
9 |
+
|
10 |
+
private $remote_api_url;
|
11 |
+
private $request_data;
|
12 |
+
private $response_key;
|
13 |
+
private $theme_slug;
|
14 |
+
private $license_key;
|
15 |
+
private $version;
|
16 |
+
private $author;
|
17 |
+
protected $strings = null;
|
18 |
+
|
19 |
+
function __construct( $args = array(), $strings = array() ) {
|
20 |
+
|
21 |
+
$args = wp_parse_args( $args, array(
|
22 |
+
'remote_api_url' => 'http://easydigitaldownloads.com',
|
23 |
+
'request_data' => array(),
|
24 |
+
'theme_slug' => get_template(),
|
25 |
+
'item_name' => '',
|
26 |
+
'license' => '',
|
27 |
+
'version' => '',
|
28 |
+
'author' => ''
|
29 |
+
) );
|
30 |
+
extract( $args );
|
31 |
+
|
32 |
+
$this->license = $license;
|
33 |
+
$this->item_name = $item_name;
|
34 |
+
$this->version = $version;
|
35 |
+
$this->theme_slug = sanitize_key( $theme_slug );
|
36 |
+
$this->author = $author;
|
37 |
+
$this->remote_api_url = $remote_api_url;
|
38 |
+
$this->response_key = $this->theme_slug . '-update-response';
|
39 |
+
$this->strings = $strings;
|
40 |
+
|
41 |
+
add_filter( 'site_transient_update_themes', array( &$this, 'theme_update_transient' ) );
|
42 |
+
add_filter( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) );
|
43 |
+
add_action( 'load-update-core.php', array( &$this, 'delete_theme_update_transient' ) );
|
44 |
+
add_action( 'load-themes.php', array( &$this, 'delete_theme_update_transient' ) );
|
45 |
+
add_action( 'load-themes.php', array( &$this, 'load_themes_screen' ) );
|
46 |
+
}
|
47 |
+
|
48 |
+
function load_themes_screen() {
|
49 |
+
add_thickbox();
|
50 |
+
add_action( 'admin_notices', array( &$this, 'update_nag' ) );
|
51 |
+
}
|
52 |
+
|
53 |
+
function update_nag() {
|
54 |
+
|
55 |
+
$strings = $this->strings;
|
56 |
+
|
57 |
+
$theme = wp_get_theme( $this->theme_slug );
|
58 |
+
|
59 |
+
$api_response = get_transient( $this->response_key );
|
60 |
+
|
61 |
+
if ( false === $api_response ) {
|
62 |
+
return;
|
63 |
+
}
|
64 |
+
|
65 |
+
$update_url = wp_nonce_url( 'update.php?action=upgrade-theme&theme=' . urlencode( $this->theme_slug ), 'upgrade-theme_' . $this->theme_slug );
|
66 |
+
$update_onclick = ' onclick="if ( confirm(\'' . esc_js( $strings['update-notice'] ) . '\') ) {return true;}return false;"';
|
67 |
+
|
68 |
+
if ( version_compare( $this->version, $api_response->new_version, '<' ) ) {
|
69 |
+
|
70 |
+
echo '<div id="update-nag">';
|
71 |
+
printf(
|
72 |
+
$strings['update-available'],
|
73 |
+
$theme->get( 'Name' ),
|
74 |
+
$api_response->new_version,
|
75 |
+
'#TB_inline?width=640&inlineId=' . $this->theme_slug . '_changelog',
|
76 |
+
$theme->get( 'Name' ),
|
77 |
+
$update_url,
|
78 |
+
$update_onclick
|
79 |
+
);
|
80 |
+
echo '</div>';
|
81 |
+
echo '<div id="' . $this->theme_slug . '_' . 'changelog" style="display:none;">';
|
82 |
+
echo wpautop( $api_response->sections['changelog'] );
|
83 |
+
echo '</div>';
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
function theme_update_transient($value) {
|
88 |
+
$update_data = $this->check_for_update();
|
89 |
+
|
90 |
+
if ($update_data && ! isset($value->response[$this->theme_slug])) {
|
91 |
+
$value->response[$this->theme_slug] = @$update_data;
|
92 |
+
}
|
93 |
+
|
94 |
+
if (
|
95 |
+
$update_data
|
96 |
+
&&
|
97 |
+
isset($value->response[$this->theme_slug])
|
98 |
+
&&
|
99 |
+
isset($value->response[$this->theme_slug]['new_version'])
|
100 |
+
&&
|
101 |
+
version_compare(
|
102 |
+
$update_data['new_version'],
|
103 |
+
$value->response[$this->theme_slug]['new_version']
|
104 |
+
) > 0
|
105 |
+
) {
|
106 |
+
$value->response[$this->theme_slug] = $update_data;
|
107 |
+
}
|
108 |
+
|
109 |
+
return $value;
|
110 |
+
}
|
111 |
+
|
112 |
+
function delete_theme_update_transient() {
|
113 |
+
delete_transient($this->response_key);
|
114 |
+
}
|
115 |
+
|
116 |
+
function check_for_update() {
|
117 |
+
$update_data = get_transient( $this->response_key );
|
118 |
+
|
119 |
+
if ( false === $update_data ) {
|
120 |
+
$failed = false;
|
121 |
+
|
122 |
+
$api_params = array(
|
123 |
+
'edd_action' => 'get_version',
|
124 |
+
'license' => $this->license,
|
125 |
+
'name' => $this->item_name,
|
126 |
+
'slug' => $this->theme_slug,
|
127 |
+
'author' => $this->author
|
128 |
+
);
|
129 |
+
|
130 |
+
$response = wp_remote_post( $this->remote_api_url, array( 'timeout' => 15, 'body' => $api_params ) );
|
131 |