Version Description
Download this release
Release Info
Developer | creativethemeshq |
Plugin | ![]() |
Version | 1.7.62 |
Comparing to | |
See all releases |
Code changes from version 1.7.61 to 1.7.62
- blocksy-companion.php +1 -1
- framework/extensions/cookies-consent/static/bundle/main.css +1 -1
- framework/extensions/mailchimp/static/bundle/main.css +1 -1
- framework/extensions/product-reviews/static/bundle/main-admin.css +1 -1
- framework/extensions/product-reviews/static/bundle/main.css +1 -1
- framework/extensions/widgets/static/bundle/main.css +1 -1
- readme.txt +4 -1
- static/bundle/dashboard.css +1 -1
- static/bundle/options.css +1 -1
- trunk/LICENSE.txt +339 -0
- trunk/blocksy-companion.php +131 -0
- trunk/framework/autoload.php +135 -0
- trunk/framework/cache-reset-manager.php +175 -0
- trunk/framework/cli.php +82 -0
- trunk/framework/dashboard.php +149 -0
- trunk/framework/extensions-manager-api.php +101 -0
- trunk/framework/extensions-manager.php +338 -0
- trunk/framework/extensions/cookies-consent/config.php +6 -0
- trunk/framework/extensions/cookies-consent/customizer.php +224 -0
- trunk/framework/extensions/cookies-consent/extension.php +93 -0
- trunk/framework/extensions/cookies-consent/global.php +66 -0
- trunk/framework/extensions/cookies-consent/helpers.php +93 -0
- trunk/framework/extensions/cookies-consent/readme.php +38 -0
- trunk/framework/extensions/cookies-consent/static/bundle/main.css +8 -0
- trunk/framework/extensions/cookies-consent/static/bundle/main.js +8 -0
- trunk/framework/extensions/cookies-consent/static/bundle/sync.js +1 -0
- trunk/framework/extensions/cookies-consent/static/images/type-1.svg +37 -0
- trunk/framework/extensions/cookies-consent/static/images/type-2.svg +34 -0
- trunk/framework/extensions/cookies-consent/static/js/ct-events.js +270 -0
- trunk/framework/extensions/cookies-consent/static/js/lazy-load-helpers.js +20 -0
- trunk/framework/extensions/cookies-consent/static/js/main.js +87 -0
- trunk/framework/extensions/cookies-consent/static/js/sync.js +65 -0
- trunk/framework/extensions/cookies-consent/static/js/sync/helpers.js +145 -0
- trunk/framework/extensions/cookies-consent/static/js/variables.js +43 -0
- trunk/framework/extensions/cookies-consent/static/sass/main.scss +173 -0
- trunk/framework/extensions/mailchimp/admin-static/bundle/1.2c9ebf0a36c6c732fee6.js +14 -0
- trunk/framework/extensions/mailchimp/admin-static/bundle/2.976c8f43abfe584b1a9d.js +1 -0
- trunk/framework/extensions/mailchimp/admin-static/bundle/main.js +1 -0
- trunk/framework/extensions/mailchimp/admin-static/bundle/sync.js +1 -0
- trunk/framework/extensions/mailchimp/admin-static/js/ListPicker.js +22 -0
- trunk/framework/extensions/mailchimp/admin-static/js/ListPicker/Implementation.js +124 -0
- trunk/framework/extensions/mailchimp/admin-static/js/main.js +10 -0
- trunk/framework/extensions/mailchimp/admin-static/js/public-path.js +1 -0
- trunk/framework/extensions/mailchimp/admin-static/js/sync.js +78 -0
- trunk/framework/extensions/mailchimp/admin-static/js/variables.js +52 -0
- trunk/framework/extensions/mailchimp/config.php +7 -0
- trunk/framework/extensions/mailchimp/ct-mailchimp/options.php +125 -0
- trunk/framework/extensions/mailchimp/ct-mailchimp/view.php +109 -0
- trunk/framework/extensions/mailchimp/ct-mailchimp/widget.php +22 -0
- trunk/framework/extensions/mailchimp/customizer.php +270 -0
- trunk/framework/extensions/mailchimp/dashboard-static/bundle/main.js +14 -0
- trunk/framework/extensions/mailchimp/dashboard-static/js/EditCredentials.js +157 -0
- trunk/framework/extensions/mailchimp/dashboard-static/js/ListPicker.js +149 -0
- trunk/framework/extensions/mailchimp/dashboard-static/js/Mailchimp.js +95 -0
- trunk/framework/extensions/mailchimp/dashboard-static/js/hooks/useActivationWithRequirements.js +80 -0
- trunk/framework/extensions/mailchimp/dashboard-static/js/main.js +15 -0
- trunk/framework/extensions/mailchimp/extension.php +144 -0
- trunk/framework/extensions/mailchimp/global.php +103 -0
- trunk/framework/extensions/mailchimp/helpers.php +140 -0
- trunk/framework/extensions/mailchimp/mailchimp-manager.php +147 -0
- trunk/framework/extensions/mailchimp/pre-boot.php +111 -0
- trunk/framework/extensions/mailchimp/readme.php +37 -0
- trunk/framework/extensions/mailchimp/static/bundle/main.css +8 -0
- trunk/framework/extensions/mailchimp/static/bundle/main.js +1 -0
- trunk/framework/extensions/mailchimp/static/js/main.js +82 -0
- trunk/framework/extensions/mailchimp/static/sass/main.scss +40 -0
- trunk/framework/extensions/mailchimp/static/sass/single-block.scss +70 -0
- trunk/framework/extensions/mailchimp/static/sass/widget.scss +39 -0
- trunk/framework/extensions/product-reviews/config.php +12 -0
- trunk/framework/extensions/product-reviews/extension.php +316 -0
- trunk/framework/extensions/product-reviews/helpers.php +39 -0
- trunk/framework/extensions/product-reviews/metabox.php +198 -0
- trunk/framework/extensions/product-reviews/pre-boot.php +65 -0
- trunk/framework/extensions/product-reviews/static/bundle/dashboard.js +6 -0
- trunk/framework/extensions/product-reviews/static/bundle/main-admin.css +8 -0
- trunk/framework/extensions/product-reviews/static/bundle/main.css +8 -0
- trunk/framework/extensions/product-reviews/static/js/EditSettings.js +141 -0
- trunk/framework/extensions/product-reviews/static/js/ProductReviews.js +100 -0
- trunk/framework/extensions/product-reviews/static/js/dashboard.js +10 -0
- trunk/framework/extensions/product-reviews/static/sass/actions.scss +18 -0
- trunk/framework/extensions/product-reviews/static/sass/description.scss +5 -0
- trunk/framework/extensions/product-reviews/static/sass/main-admin.scss +8 -0
- trunk/framework/extensions/product-reviews/static/sass/main.scss +23 -0
- trunk/framework/extensions/product-reviews/static/sass/quick-info.scss +32 -0
- trunk/framework/extensions/product-reviews/static/sass/scores.scss +83 -0
- trunk/framework/extensions/product-reviews/static/sass/slider.scss +36 -0
- trunk/framework/extensions/product-reviews/static/sass/title.scss +6 -0
- trunk/framework/extensions/product-reviews/views/single-top.php +243 -0
- trunk/framework/extensions/trending/config.php +6 -0
- trunk/framework/extensions/trending/customizer.php +193 -0
- trunk/framework/extensions/trending/extension.php +76 -0
- trunk/framework/extensions/trending/global.php +53 -0
- trunk/framework/extensions/trending/helpers.php +195 -0
- trunk/framework/extensions/trending/static/bundle/main.js +1 -0
- trunk/framework/extensions/trending/static/bundle/sync.js +1 -0
- trunk/framework/extensions/trending/static/js/main.js +17 -0
- trunk/framework/extensions/trending/static/js/sync.js +42 -0
- trunk/framework/extensions/trending/static/js/trending-block.js +139 -0
- trunk/framework/extensions/widgets/config.php +5 -0
- trunk/framework/extensions/widgets/extension.php +36 -0
- trunk/framework/extensions/widgets/static/bundle/main.css +8 -0
- trunk/framework/extensions/widgets/static/sass/about-me.scss +67 -0
- trunk/framework/extensions/widgets/static/sass/facebook.scss +37 -0
- trunk/framework/extensions/widgets/static/sass/main.scss +7 -0
- trunk/framework/extensions/widgets/static/sass/posts.scss +132 -0
- trunk/framework/extensions/widgets/static/sass/quote.scss +39 -0
- trunk/framework/extensions/widgets/static/sass/social-icons.scss +23 -0
- trunk/framework/extensions/widgets/widgets/ct-about-me/helpers.php +18 -0
- trunk/framework/extensions/widgets/widgets/ct-about-me/options.php +235 -0
- trunk/framework/extensions/widgets/widgets/ct-about-me/view.php +139 -0
- trunk/framework/extensions/widgets/widgets/ct-about-me/widget.php +22 -0
- trunk/framework/extensions/widgets/widgets/ct-advertisement/options.php +84 -0
- trunk/framework/extensions/widgets/widgets/ct-advertisement/view.php +61 -0
- trunk/framework/extensions/widgets/widgets/ct-advertisement/widget.php +22 -0
- trunk/framework/extensions/widgets/widgets/ct-contact-info/options.php +312 -0
- trunk/framework/extensions/widgets/widgets/ct-contact-info/view.php +70 -0
- trunk/framework/extensions/widgets/widgets/ct-contact-info/widget.php +22 -0
- trunk/framework/extensions/widgets/widgets/ct-facebook/options.php +52 -0
- trunk/framework/extensions/widgets/widgets/ct-facebook/view.php +61 -0
- trunk/framework/extensions/widgets/widgets/ct-facebook/widget.php +22 -0
- trunk/framework/extensions/widgets/widgets/ct-posts/options.php +329 -0
- trunk/framework/extensions/widgets/widgets/ct-posts/view.php +224 -0
- trunk/framework/extensions/widgets/widgets/ct-posts/widget.php +23 -0
- trunk/framework/extensions/widgets/widgets/ct-quote/options.php +55 -0
- trunk/framework/extensions/widgets/widgets/ct-quote/view.php +57 -0
- trunk/framework/extensions/widgets/widgets/ct-quote/widget.php +22 -0
- trunk/framework/extensions/widgets/widgets/ct-socials/options.php +106 -0
- trunk/framework/extensions/widgets/widgets/ct-socials/view.php +53 -0
- trunk/framework/extensions/widgets/widgets/ct-socials/widget.php +23 -0
- trunk/framework/features/conditions-manager.php +487 -0
- trunk/framework/features/customizer-options-manager.php +206 -0
- trunk/framework/features/demo-install.php +340 -0
- trunk/framework/features/demo-install/child-theme.php +121 -0
- trunk/framework/features/demo-install/content-eraser.php +179 -0
- trunk/framework/features/demo-install/content-export.php +663 -0
- trunk/framework/features/demo-install/content-installer.php +416 -0
- trunk/framework/features/demo-install/fake-content-eraser.php +273 -0
- trunk/framework/features/demo-install/install-finish.php +194 -0
- trunk/framework/features/demo-install/options-export.php +123 -0
- trunk/framework/features/demo-install/options-import.php +400 -0
- trunk/framework/features/demo-install/parsers.php +701 -0
- trunk/framework/features/demo-install/plugins-uninstaller.php +44 -0
- trunk/framework/features/demo-install/required-plugins.php +85 -0
- trunk/framework/features/demo-install/widgets-export.php +67 -0
- trunk/framework/features/demo-install/widgets-import.php +277 -0
- trunk/framework/features/demo-install/wp-importer.php +1348 -0
- trunk/framework/features/dynamic-css.php +270 -0
- trunk/framework/features/google-analytics.php +110 -0
- trunk/framework/features/header.php +542 -0
- trunk/framework/features/header/account-modal.php +139 -0
- trunk/framework/features/header/header-options.php +178 -0
- trunk/framework/features/header/items/account/config.php +25 -0
- trunk/framework/features/header/items/account/dynamic-styles.php +460 -0
- trunk/framework/features/header/items/account/options.php +946 -0
- trunk/framework/features/header/items/account/sync.js +336 -0
- trunk/framework/features/header/items/account/view.php +56 -0
- trunk/framework/features/header/items/account/views/login.php +97 -0
- trunk/framework/features/header/items/account/views/logout.php +53 -0
- trunk/framework/features/opengraph-meta-data.php +224 -0
- trunk/framework/helpers/blocksy-integration.php +177 -0
- trunk/framework/helpers/helpers.php +102 -0
- trunk/framework/theme-integration.php +356 -0
- trunk/framework/views/blocksy-posts.php +156 -0
- trunk/framework/views/optin.php +6 -0
- trunk/framework/widgets-manager.php +201 -0
- trunk/freemius-pricing/178afa6030e76635dbe835e111d2c507.png +0 -0
- trunk/freemius-pricing/27b5a722a5553d9de0170325267fccec.png +0 -0
- trunk/freemius-pricing/4375c4a3ddc6f637c2ab9a2d7220f91e.png +0 -0
- trunk/freemius-pricing/5480ed23b199531a8cbc05924f26952b.png +0 -0
- trunk/freemius-pricing/b4f3b958f4a019862d81b15f3f8eee3a.svg +402 -0
- trunk/freemius-pricing/c03f665db27af43971565560adfba594.png +0 -0
- trunk/freemius-pricing/cb5fc4f6ec7ada72e986f6e7dde365bf.png +0 -0
- trunk/freemius-pricing/dd89563360f0272635c8f0ab7d7f1402.png +0 -0
- trunk/freemius-pricing/e366d70661d8ad2493bd6afbd779f125.png +0 -0
- trunk/freemius-pricing/f3aac72a8e63997d6bb888f816457e9b.png +0 -0
- trunk/freemius-pricing/f928f1be99776af83e8e6be4baf8ffe7.svg +227 -0
- trunk/freemius-pricing/fde48e4609a6ddc11d639fc2421f2afd.png +0 -0
- trunk/freemius-pricing/freemius-pricing.js +9065 -0
blocksy-companion.php
CHANGED
@@ -3,7 +3,7 @@
|
|
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.
|
7 |
Author: CreativeThemes
|
8 |
Author URI: https://creativethemes.com
|
9 |
Text Domain: blc
|
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.62
|
7 |
Author: CreativeThemes
|
8 |
Author URI: https://creativethemes.com
|
9 |
Text Domain: blc
|
framework/extensions/cookies-consent/static/bundle/main.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/**
|
2 |
-
* - v1.7.
|
3 |
*
|
4 |
* Copyright (c) 2021
|
5 |
* Licensed GPLv2+
|
1 |
/**
|
2 |
+
* - v1.7.62
|
3 |
*
|
4 |
* Copyright (c) 2021
|
5 |
* Licensed GPLv2+
|
framework/extensions/mailchimp/static/bundle/main.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/**
|
2 |
-
* - v1.7.
|
3 |
*
|
4 |
* Copyright (c) 2021
|
5 |
* Licensed GPLv2+
|
1 |
/**
|
2 |
+
* - v1.7.62
|
3 |
*
|
4 |
* Copyright (c) 2021
|
5 |
* Licensed GPLv2+
|
framework/extensions/product-reviews/static/bundle/main-admin.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/**
|
2 |
-
* - v1.7.
|
3 |
*
|
4 |
* Copyright (c) 2021
|
5 |
* Licensed GPLv2+
|
1 |
/**
|
2 |
+
* - v1.7.62
|
3 |
*
|
4 |
* Copyright (c) 2021
|
5 |
* Licensed GPLv2+
|
framework/extensions/product-reviews/static/bundle/main.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/**
|
2 |
-
* - v1.7.
|
3 |
*
|
4 |
* Copyright (c) 2021
|
5 |
* Licensed GPLv2+
|
1 |
/**
|
2 |
+
* - v1.7.62
|
3 |
*
|
4 |
* Copyright (c) 2021
|
5 |
* Licensed GPLv2+
|
framework/extensions/widgets/static/bundle/main.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/**
|
2 |
-
* - v1.7.
|
3 |
*
|
4 |
* Copyright (c) 2021
|
5 |
* Licensed GPLv2+
|
1 |
/**
|
2 |
+
* - v1.7.62
|
3 |
*
|
4 |
* Copyright (c) 2021
|
5 |
* Licensed GPLv2+
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Requires PHP: 7.0
|
|
5 |
Tested up to: 5.6
|
6 |
License: GPLv2 or later
|
7 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
8 |
-
Stable tag: 1.7.
|
9 |
|
10 |
== Description ==
|
11 |
|
@@ -23,6 +23,9 @@ It runs and adds its enhancements only if the Blocksy theme is installed and act
|
|
23 |
2. Activate the plugin by going to **Plugins** page in WordPress admin and clicking on **Activate** link.
|
24 |
|
25 |
== Changelog ==
|
|
|
|
|
|
|
26 |
1.7.61: 2021-02-23
|
27 |
- Fix: Dashboard JavaScript fixes
|
28 |
|
5 |
Tested up to: 5.6
|
6 |
License: GPLv2 or later
|
7 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
8 |
+
Stable tag: 1.7.62
|
9 |
|
10 |
== Description ==
|
11 |
|
23 |
2. Activate the plugin by going to **Plugins** page in WordPress admin and clicking on **Activate** link.
|
24 |
|
25 |
== Changelog ==
|
26 |
+
1.7.62: 2021-02-23
|
27 |
+
- Fix: Dashboard JavaScript fixes
|
28 |
+
|
29 |
1.7.61: 2021-02-23
|
30 |
- Fix: Dashboard JavaScript fixes
|
31 |
|
static/bundle/dashboard.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/**
|
2 |
-
* - v1.7.
|
3 |
*
|
4 |
* Copyright (c) 2021
|
5 |
* Licensed GPLv2+
|
1 |
/**
|
2 |
+
* - v1.7.62
|
3 |
*
|
4 |
* Copyright (c) 2021
|
5 |
* Licensed GPLv2+
|
static/bundle/options.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/**
|
2 |
-
* - v1.7.
|
3 |
*
|
4 |
* Copyright (c) 2021
|
5 |
* Licensed GPLv2+
|
1 |
/**
|
2 |
+
* - v1.7.62
|
3 |
*
|
4 |
* Copyright (c) 2021
|
5 |
* Licensed GPLv2+
|
trunk/LICENSE.txt
ADDED
@@ -0,0 +1,339 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
5 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6 |
+
Everyone is permitted to copy and distribute verbatim copies
|
7 |
+
of this license document, but changing it is not allowed.
|
8 |
+
|
9 |
+
Preamble
|
10 |
+
|
11 |
+
The licenses for most software are designed to take away your
|
12 |
+
freedom to share and change it. By contrast, the GNU General Public
|
13 |
+
License is intended to guarantee your freedom to share and change free
|
14 |
+
software--to make sure the software is free for all its users. This
|
15 |
+
General Public License applies to most of the Free Software
|
16 |
+
Foundation's software and to any other program whose authors commit to
|
17 |
+
using it. (Some other Free Software Foundation software is covered by
|
18 |
+
the GNU Lesser General Public License instead.) You can apply it to
|
19 |
+
your programs, too.
|
20 |
+
|
21 |
+
When we speak of free software, we are referring to freedom, not
|
22 |
+
price. Our General Public Licenses are designed to make sure that you
|
23 |
+
have the freedom to distribute copies of free software (and charge for
|
24 |
+
this service if you wish), that you receive source code or can get it
|
25 |
+
if you want it, that you can change the software or use pieces of it
|
26 |
+
in new free programs; and that you know you can do these things.
|
27 |
+
|
28 |
+
To protect your rights, we need to make restrictions that forbid
|
29 |
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30 |
+
These restrictions translate to certain responsibilities for you if you
|
31 |
+
distribute copies of the software, or if you modify it.
|
32 |
+
|
33 |
+
For example, if you distribute copies of such a program, whether
|
34 |
+
gratis or for a fee, you must give the recipients all the rights that
|
35 |
+
you have. You must make sure that they, too, receive or can get the
|
36 |
+
source code. And you must show them these terms so they know their
|
37 |
+
rights.
|
38 |
+
|
39 |
+
We protect your rights with two steps: (1) copyright the software, and
|
40 |
+
(2) offer you this license which gives you legal permission to copy,
|
41 |
+
distribute and/or modify the software.
|
42 |
+
|
43 |
+
Also, for each author's protection and ours, we want to make certain
|
44 |
+
that everyone understands that there is no warranty for this free
|
45 |
+
software. If the software is modified by someone else and passed on, we
|
46 |
+
want its recipients to know that what they have is not the original, so
|
47 |
+
that any problems introduced by others will not reflect on the origina
|
48 |
+
authors' reputations.
|
49 |
+
|
50 |
+
Finally, any free program is threatened constantly by software
|
51 |
+
patents. We wish to avoid the danger that redistributors of a free
|
52 |
+
program will individually obtain patent licenses, in effect making the
|
53 |
+
program proprietary. To prevent this, we have made it clear that any
|
54 |
+
patent must be licensed for everyone's free use or not licensed at all.
|
55 |
+
|
56 |
+
The precise terms and conditions for copying, distribution and
|
57 |
+
modification follow.
|
58 |
+
|
59 |
+
GNU GENERAL PUBLIC LICENSE
|
60 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61 |
+
|
62 |
+
0. This License applies to any program or other work which contains
|
63 |
+
a notice placed by the copyright holder saying it may be distributed
|
64 |
+
under the terms of this General Public License. The "Program", below,
|
65 |
+
refers to any such program or work, and a "work based on the Program"
|
66 |
+
means either the Program or any derivative work under copyright law:
|
67 |
+
that is to say, a work containing the Program or a portion of it,
|
68 |
+
either verbatim or with modifications and/or translated into another
|
69 |
+
language. (Hereinafter, translation is included without limitation in
|
70 |
+
the term "modification".) Each licensee is addressed as "you".
|
71 |
+
|
72 |
+
Activities other than copying, distribution and modification are not
|
73 |
+
covered by this License; they are outside its scope. The act of
|
74 |
+
running the Program is not restricted, and the output from the Program
|
75 |
+
is covered only if its contents constitute a work based on the
|
76 |
+
Program (independent of having been made by running the Program).
|
77 |
+
Whether that is true depends on what the Program does.
|
78 |
+
|
79 |
+
1. You may copy and distribute verbatim copies of the Program's
|
80 |
+
source code as you receive it, in any medium, provided that you
|
81 |
+
conspicuously and appropriately publish on each copy an appropriate
|
82 |
+
copyright notice and disclaimer of warranty; keep intact all the
|
83 |
+
notices that refer to this License and to the absence of any warranty;
|
84 |
+
and give any other recipients of the Program a copy of this License
|
85 |
+
along with the Program.
|
86 |
+
|
87 |
+
You may charge a fee for the physical act of transferring a copy, and
|
88 |
+
you may at your option offer warranty protection in exchange for a fee.
|
89 |
+
|
90 |
+
2. You may modify your copy or copies of the Program or any portion
|
91 |
+
of it, thus forming a work based on the Program, and copy and
|
92 |
+
distribute such modifications or work under the terms of Section 1
|
93 |
+
above, provided that you also meet all of these conditions:
|
94 |
+
|
95 |
+
a) You must cause the modified files to carry prominent notices
|
96 |
+
stating that you changed the files and the date of any change.
|
97 |
+
|
98 |
+
b) You must cause any work that you distribute or publish, that in
|
99 |
+
whole or in part contains or is derived from the Program or any
|
100 |
+
part thereof, to be licensed as a whole at no charge to all third
|
101 |
+
parties under the terms of this License.
|
102 |
+
|
103 |
+
c) If the modified program normally reads commands interactively
|
104 |
+
when run, you must cause it, when started running for such
|
105 |
+
interactive use in the most ordinary way, to print or display an
|
106 |
+
announcement including an appropriate copyright notice and a
|
107 |
+
notice that there is no warranty (or else, saying that you provide
|
108 |
+
a warranty) and that users may redistribute the program under
|
109 |
+
these conditions, and telling the user how to view a copy of this
|
110 |
+
License. (Exception: if the Program itself is interactive but
|
111 |
+
does not normally print such an announcement, your work based on
|
112 |
+
the Program is not required to print an announcement.)
|
113 |
+
|
114 |
+
These requirements apply to the modified work as a whole. If
|
115 |
+
identifiable sections of that work are not derived from the Program,
|
116 |
+
and can be reasonably considered independent and separate works in
|
117 |
+
themselves, then this License, and its terms, do not apply to those
|
118 |
+
sections when you distribute them as separate works. But when you
|
119 |
+
distribute the same sections as part of a whole which is a work based
|
120 |
+
on the Program, the distribution of the whole must be on the terms of
|
121 |
+
this License, whose permissions for other licensees extend to the
|
122 |
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123 |
+
|
124 |
+
Thus, it is not the intent of this section to claim rights or contest
|
125 |
+
your rights to work written entirely by you; rather, the intent is to
|
126 |
+
exercise the right to control the distribution of derivative or
|
127 |
+
collective works based on the Program.
|
128 |
+
|
129 |
+
In addition, mere aggregation of another work not based on the Program
|
130 |
+
with the Program (or with a work based on the Program) on a volume of
|
131 |
+
a storage or distribution medium does not bring the other work under
|
132 |
+
the scope of this License.
|
133 |
+
|
134 |
+
3. You may copy and distribute the Program (or a work based on it,
|
135 |
+
under Section 2) in object code or executable form under the terms of
|
136 |
+
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
+
|
138 |
+
a) Accompany it with the complete corresponding machine-readable
|
139 |
+
source code, which must be distributed under the terms of Sections
|
140 |
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
+
|
142 |
+
b) Accompany it with a written offer, valid for at least three
|
143 |
+
years, to give any third party, for a charge no more than your
|
144 |
+
cost of physically performing source distribution, a complete
|
145 |
+
machine-readable copy of the corresponding source code, to be
|
146 |
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
+
customarily used for software interchange; or,
|
148 |
+
|
149 |
+
c) Accompany it with the information you received as to the offer
|
150 |
+
to distribute corresponding source code. (This alternative is
|
151 |
+
allowed only for noncommercial distribution and only if you
|
152 |
+
received the program in object code or executable form with such
|
153 |
+
an offer, in accord with Subsection b above.)
|
154 |
+
|
155 |
+
The source code for a work means the preferred form of the work for
|
156 |
+
making modifications to it. For an executable work, complete source
|
157 |
+
code means all the source code for all modules it contains, plus any
|
158 |
+
associated interface definition files, plus the scripts used to
|
159 |
+
control compilation and installation of the executable. However, as a
|
160 |
+
special exception, the source code distributed need not include
|
161 |
+
anything that is normally distributed (in either source or binary
|
162 |
+
form) with the major components (compiler, kernel, and so on) of the
|
163 |
+
operating system on which the executable runs, unless that component
|
164 |
+
itself accompanies the executable.
|
165 |
+
|
166 |
+
If distribution of executable or object code is made by offering
|
167 |
+
access to copy from a designated place, then offering equivalent
|
168 |
+
access to copy the source code from the same place counts as
|
169 |
+
distribution of the source code, even though third parties are not
|
170 |
+
compelled to copy the source along with the object code.
|
171 |
+
|
172 |
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
+
except as expressly provided under this License. Any attempt
|
174 |
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
+
void, and will automatically terminate your rights under this License.
|
176 |
+
However, parties who have received copies, or rights, from you under
|
177 |
+
this License will not have their licenses terminated so long as such
|
178 |
+
parties remain in full compliance.
|
179 |
+
|
180 |
+
5. You are not required to accept this License, since you have not
|
181 |
+
signed it. However, nothing else grants you permission to modify or
|
182 |
+
distribute the Program or its derivative works. These actions are
|
183 |
+
prohibited by law if you do not accept this License. Therefore, by
|
184 |
+
modifying or distributing the Program (or any work based on the
|
185 |
+
Program), you indicate your acceptance of this License to do so, and
|
186 |
+
all its terms and conditions for copying, distributing or modifying
|
187 |
+
the Program or works based on it.
|
188 |
+
|
189 |
+
6. Each time you redistribute the Program (or any work based on the
|
190 |
+
Program), the recipient automatically receives a license from the
|
191 |
+
original licensor to copy, distribute or modify the Program subject to
|
192 |
+
these terms and conditions. You may not impose any further
|
193 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
+
You are not responsible for enforcing compliance by third parties to
|
195 |
+
this License.
|
196 |
+
|
197 |
+
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
+
infringement or for any other reason (not limited to patent issues),
|
199 |
+
conditions are imposed on you (whether by court order, agreement or
|
200 |
+
otherwise) that contradict the conditions of this License, they do not
|
201 |
+
excuse you from the conditions of this License. If you cannot
|
202 |
+
distribute so as to satisfy simultaneously your obligations under this
|
203 |
+
License and any other pertinent obligations, then as a consequence you
|
204 |
+
may not distribute the Program at all. For example, if a patent
|
205 |
+
license would not permit royalty-free redistribution of the Program by
|
206 |
+
all those who receive copies directly or indirectly through you, then
|
207 |
+
the only way you could satisfy both it and this License would be to
|
208 |
+
refrain entirely from distribution of the Program.
|
209 |
+
|
210 |
+
If any portion of this section is held invalid or unenforceable under
|
211 |
+
any particular circumstance, the balance of the section is intended to
|
212 |
+
apply and the section as a whole is intended to apply in other
|
213 |
+
circumstances.
|
214 |
+
|
215 |
+
It is not the purpose of this section to induce you to infringe any
|
216 |
+
patents or other property right claims or to contest validity of any
|
217 |
+
such claims; this section has the sole purpose of protecting the
|
218 |
+
integrity of the free software distribution system, which is
|
219 |
+
implemented by public license practices. Many people have made
|
220 |
+
generous contributions to the wide range of software distributed
|
221 |
+
through that system in reliance on consistent application of that
|
222 |
+
system; it is up to the author/donor to decide if he or she is willing
|
223 |
+
to distribute software through any other system and a licensee cannot
|
224 |
+
impose that choice.
|
225 |
+
|
226 |
+
This section is intended to make thoroughly clear what is believed to
|
227 |
+
be a consequence of the rest of this License.
|
228 |
+
|
229 |
+
8. If the distribution and/or use of the Program is restricted in
|
230 |
+
certain countries either by patents or by copyrighted interfaces, the
|
231 |
+
original copyright holder who places the Program under this License
|
232 |
+
may add an explicit geographical distribution limitation excluding
|
233 |
+
those countries, so that distribution is permitted only in or among
|
234 |
+
countries not thus excluded. In such case, this License incorporates
|
235 |
+
the limitation as if written in the body of this License.
|
236 |
+
|
237 |
+
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
+
of the General Public License from time to time. Such new versions will
|
239 |
+
be similar in spirit to the present version, but may differ in detail to
|
240 |
+
address new problems or concerns.
|
241 |
+
|
242 |
+
Each version is given a distinguishing version number. If the Program
|
243 |
+
specifies a version number of this License which applies to it and "any
|
244 |
+
later version", you have the option of following the terms and conditions
|
245 |
+
either of that version or of any later version published by the Free
|
246 |
+
Software Foundation. If the Program does not specify a version number of
|
247 |
+
this License, you may choose any version ever published by the Free Software
|
248 |
+
Foundation.
|
249 |
+
|
250 |
+
10. If you wish to incorporate parts of the Program into other free
|
251 |
+
programs whose distribution conditions are different, write to the author
|
252 |
+
to ask for permission. For software which is copyrighted by the Free
|
253 |
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
+
make exceptions for this. Our decision will be guided by the two goals
|
255 |
+
of preserving the free status of all derivatives of our free software and
|
256 |
+
of promoting the sharing and reuse of software generally.
|
257 |
+
|
258 |
+
NO WARRANTY
|
259 |
+
|
260 |
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
+
REPAIR OR CORRECTION.
|
269 |
+
|
270 |
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
+
POSSIBILITY OF SUCH DAMAGES.
|
279 |
+
|
280 |
+
END OF TERMS AND CONDITIONS
|
281 |
+
|
282 |
+
How to Apply These Terms to Your New Programs
|
283 |
+
|
284 |
+
If you develop a new program, and you want it to be of the greatest
|
285 |
+
possible use to the public, the best way to achieve this is to make it
|
286 |
+
free software which everyone can redistribute and change under these terms.
|
287 |
+
|
288 |
+
To do so, attach the following notices to the program. It is safest
|
289 |
+
to attach them to the start of each source file to most effectively
|
290 |
+
convey the exclusion of warranty; and each file should have at least
|
291 |
+
the "copyright" line and a pointer to where the full notice is found.
|
292 |
+
|
293 |
+
{description}
|
294 |
+
Copyright (C) {year} {fullname}
|
295 |
+
|
296 |
+
This program is free software; you can redistribute it and/or modify
|
297 |
+
it under the terms of the GNU General Public License as published by
|
298 |
+
the Free Software Foundation; either version 2 of the License, or
|
299 |
+
(at your option) any later version.
|
300 |
+
|
301 |
+
This program is distributed in the hope that it will be useful,
|
302 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
+
GNU General Public License for more details.
|
305 |
+
|
306 |
+
You should have received a copy of the GNU General Public License along
|
307 |
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
+
|
310 |
+
Also add information on how to contact you by electronic and paper mail.
|
311 |
+
|
312 |
+
If the program is interactive, make it output a short notice like this
|
313 |
+
when it starts in an interactive mode:
|
314 |
+
|
315 |
+
Gnomovision version 69, Copyright (C) year name of author
|
316 |
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
+
This is free software, and you are welcome to redistribute it
|
318 |
+
under certain conditions; type `show c' for details.
|
319 |
+
|
320 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
+
parts of the General Public License. Of course, the commands you use may
|
322 |
+
be called something other than `show w' and `show c'; they could even be
|
323 |
+
mouse-clicks or menu items--whatever suits your program.
|
324 |
+
|
325 |
+
You should also get your employer (if you work as a programmer) or your
|
326 |
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
+
necessary. Here is a sample; alter the names:
|
328 |
+
|
329 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
+
|
332 |
+
{signature of Ty Coon}, 1 April 1989
|
333 |
+
Ty Coon, President of Vice
|
334 |
+
|
335 |
+
This General Public License does not permit incorporating your program into
|
336 |
+
proprietary programs. If your program is a subroutine library, you may
|
337 |
+
consider it more useful to permit linking proprietary applications with the
|
338 |
+
library. If this is what you want to do, use the GNU Lesser General
|
339 |
+
Public License instead of this License
|
trunk/blocksy-companion.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
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.62
|
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 |
+
if ( !defined( 'WP_FS__PRODUCT_5115_MULTISITE' ) ) {
|
30 |
+
define( 'WP_FS__PRODUCT_5115_MULTISITE', true );
|
31 |
+
}
|
32 |
+
require_once dirname( __FILE__ ) . '/freemius/start.php';
|
33 |
+
$has_account = true;
|
34 |
+
$instance = \Freemius::instance( 5115, 'blocksy-companion', true );
|
35 |
+
|
36 |
+
if ( in_array( 'white-label', get_option( 'blocksy_active_extensions', [] ) ) && $instance->is_plan( 'agency' ) ) {
|
37 |
+
$settings = get_option( 'blocksy_ext_white_label_settings', [] );
|
38 |
+
if ( $settings && isset( $settings['hide_billing_account'] ) && $settings['hide_billing_account'] ) {
|
39 |
+
$has_account = false;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
$blc_fs = fs_dynamic_init( array(
|
44 |
+
'id' => '5115',
|
45 |
+
'slug' => 'blocksy-companion',
|
46 |
+
'premium_slug' => 'blocksy-companion-pro',
|
47 |
+
'type' => 'plugin',
|
48 |
+
'public_key' => 'pk_b00a5cbae90b2e948015a7d0710f5',
|
49 |
+
'premium_suffix' => 'PRO',
|
50 |
+
'is_premium' => false,
|
51 |
+
'has_addons' => false,
|
52 |
+
'has_paid_plans' => true,
|
53 |
+
'menu' => ( true ? [
|
54 |
+
'slug' => 'ct-dashboard',
|
55 |
+
'support' => false,
|
56 |
+
'contact' => false,
|
57 |
+
'pricing' => true,
|
58 |
+
'account' => $has_account,
|
59 |
+
] : [
|
60 |
+
'support' => false,
|
61 |
+
'contact' => false,
|
62 |
+
'pricing' => false,
|
63 |
+
'account' => false,
|
64 |
+
] ),
|
65 |
+
'is_live' => true,
|
66 |
+
) );
|
67 |
+
function blc_fs()
|
68 |
+
{
|
69 |
+
global $blc_fs ;
|
70 |
+
return $blc_fs;
|
71 |
+
}
|
72 |
+
|
73 |
+
blc_fs();
|
74 |
+
do_action( 'blc_fs_loaded' );
|
75 |
+
blc_fs()->add_filter( 'freemius_pricing_js_path', function ( $d ) {
|
76 |
+
// return BLOCKSY_PATH . 'freemius-pricing/freemius-pricing.js';
|
77 |
+
// Only in DEV!!
|
78 |
+
return WP_CONTENT_DIR . '/plugins/blocksy-companion/freemius-pricing/freemius-pricing.js';
|
79 |
+
} );
|
80 |
+
}
|
81 |
+
|
82 |
+
}
|
83 |
+
|
84 |
+
define( 'BLOCKSY__FILE__', __FILE__ );
|
85 |
+
define( 'BLOCKSY_PLUGIN_BASE', plugin_basename( BLOCKSY__FILE__ ) );
|
86 |
+
define( 'BLOCKSY_PATH', plugin_dir_path( BLOCKSY__FILE__ ) );
|
87 |
+
define( 'BLOCKSY_URL', plugin_dir_url( BLOCKSY__FILE__ ) );
|
88 |
+
add_action( 'init', function () {
|
89 |
+
/**
|
90 |
+
* Load Blocksy textdomain.
|
91 |
+
*
|
92 |
+
* Load gettext translate for Blocksy text domain.
|
93 |
+
*/
|
94 |
+
load_plugin_textdomain( 'blc', false, dirname( BLOCKSY_PLUGIN_BASE ) . '/languages' );
|
95 |
+
} );
|
96 |
+
|
97 |
+
if ( !version_compare( PHP_VERSION, '7.0', '>=' ) ) {
|
98 |
+
add_action( 'admin_notices', 'blc_fail_php_version' );
|
99 |
+
} elseif ( !version_compare( get_bloginfo( 'version' ), '5.0', '>=' ) ) {
|
100 |
+
add_action( 'admin_notices', 'blc_fail_wp_version' );
|
101 |
+
} else {
|
102 |
+
require BLOCKSY_PATH . 'plugin.php';
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Blocksy admin notice for minimum PHP version.
|
107 |
+
*
|
108 |
+
* Warning when the site doesn't have the minimum required PHP version.
|
109 |
+
*/
|
110 |
+
function blc_fail_php_version()
|
111 |
+
{
|
112 |
+
/* translators: %s: PHP version */
|
113 |
+
$message = sprintf( esc_html__( 'Blocksy requires PHP version %s+, plugin is currently NOT RUNNING.', 'blc' ), '7.0' );
|
114 |
+
$html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) );
|
115 |
+
echo wp_kses_post( $html_message ) ;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Blocksy admin notice for minimum WordPress version.
|
120 |
+
*
|
121 |
+
* Warning when the site doesn't have the minimum required WordPress version.
|
122 |
+
*/
|
123 |
+
function blc_fail_wp_version()
|
124 |
+
{
|
125 |
+
/* translators: %s: WordPress version */
|
126 |
+
$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' );
|
127 |
+
$html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) );
|
128 |
+
echo wp_kses_post( $html_message ) ;
|
129 |
+
}
|
130 |
+
|
131 |
+
}
|
trunk/framework/autoload.php
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Blocksy;
|
4 |
+
|
5 |
+
if (! defined('ABSPATH')) {
|
6 |
+
exit; // Exit if accessed directly.
|
7 |
+
}
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Blocksy autoloader.
|
11 |
+
*/
|
12 |
+
class Autoloader {
|
13 |
+
|
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 |
+
'CustomizerOptionsManager' => 'framework/features/customizer-options-manager.php',
|
40 |
+
'DemoInstall' => 'framework/features/demo-install.php',
|
41 |
+
'DemoInstallContentExport' => 'framework/features/demo-install/content-export.php',
|
42 |
+
'DemoInstallWidgetsExport' => 'framework/features/demo-install/widgets-export.php',
|
43 |
+
'DemoInstallOptionsExport' => 'framework/features/demo-install/options-export.php',
|
44 |
+
|
45 |
+
'DemoInstallChildThemeInstaller' => 'framework/features/demo-install/child-theme.php',
|
46 |
+
'DemoInstallPluginsInstaller' => 'framework/features/demo-install/required-plugins.php',
|
47 |
+
'DemoInstallPluginsUninstaller' => 'framework/features/demo-install/plugins-uninstaller.php',
|
48 |
+
'DemoInstallContentInstaller' => 'framework/features/demo-install/content-installer.php',
|
49 |
+
'DemoInstallOptionsInstaller' => 'framework/features/demo-install/options-import.php',
|
50 |
+
'DemoInstallWidgetsInstaller' => 'framework/features/demo-install/widgets-import.php',
|
51 |
+
'DemoInstallContentEraser' => 'framework/features/demo-install/content-eraser.php',
|
52 |
+
'DemoInstallFakeContentEraser' => 'framework/features/demo-install/fake-content-eraser.php',
|
53 |
+
'DemoInstallFinalActions' => 'framework/features/demo-install/install-finish.php',
|
54 |
+
'Premium' => 'framework/premium/pro.php',
|
55 |
+
|
56 |
+
/**
|
57 |
+
* No namespace
|
58 |
+
*/
|
59 |
+
'_BlocksyWidgetFactory' => 'framework/widgets-manager.php',
|
60 |
+
'_Blocksy_WP_Import' => 'framework/features/demo-install/wp-importer.php',
|
61 |
+
]);
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Run autoloader.
|
66 |
+
*
|
67 |
+
* Register a function as `__autoload()` implementation.
|
68 |
+
*
|
69 |
+
* @static
|
70 |
+
*/
|
71 |
+
public static function run() {
|
72 |
+
spl_autoload_register([__CLASS__, 'autoload']);
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Load class.
|
77 |
+
*
|
78 |
+
* For a given class name, require the class file.
|
79 |
+
*
|
80 |
+
* @static
|
81 |
+
*
|
82 |
+
* @param string $relative_class_name Class name.
|
83 |
+
*/
|
84 |
+
private static function load_class($relative_class_name) {
|
85 |
+
if (isset( self::get_classes_map()[$relative_class_name])) {
|
86 |
+
$filename = BLOCKSY_PATH . '/' . self::get_classes_map()[$relative_class_name];
|
87 |
+
} else {
|
88 |
+
$filename = strtolower(
|
89 |
+
preg_replace(
|
90 |
+
['/([a-z])([A-Z])/', '/_/', '/\\\/'],
|
91 |
+
['$1-$2', '-', DIRECTORY_SEPARATOR],
|
92 |
+
$relative_class_name
|
93 |
+
)
|
94 |
+
);
|
95 |
+
|
96 |
+
$filename = BLOCKSY_PATH . $filename . '.php';
|
97 |
+
}
|
98 |
+
|
99 |
+
if (is_readable($filename)) {
|
100 |
+
require $filename;
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Autoload.
|
106 |
+
*
|
107 |
+
* For a given class, check if it exist and load it.
|
108 |
+
*
|
109 |
+
* @static
|
110 |
+
*
|
111 |
+
* @param string $class Class name.
|
112 |
+
*/
|
113 |
+
private static function autoload($class) {
|
114 |
+
if (
|
115 |
+
0 !== strpos($class, __NAMESPACE__ . '\\')
|
116 |
+
&&
|
117 |
+
! isset(self::get_classes_map()['_' . $class])
|
118 |
+
) {
|
119 |
+
return;
|
120 |
+
}
|
121 |
+
|
122 |
+
$relative_class_name = preg_replace('/^' . __NAMESPACE__ . '\\\/', '', $class);
|
123 |
+
|
124 |
+
$final_class_name = __NAMESPACE__ . '\\' . $relative_class_name;
|
125 |
+
|
126 |
+
if (isset(self::get_classes_map()['_' . $relative_class_name])) {
|
127 |
+
$final_class_name = $relative_class_name;
|
128 |
+
$relative_class_name = '_' . $relative_class_name;
|
129 |
+
}
|
130 |
+
|
131 |
+
if (! class_exists($final_class_name)) {
|
132 |
+
self::load_class($relative_class_name);
|
133 |
+
}
|
134 |
+
}
|
135 |
+
}
|
trunk/framework/cache-reset-manager.php
ADDED
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Blocksy;
|
4 |
+
|
5 |
+
class CacheResetManager {
|
6 |
+
public function __construct() {
|
7 |
+
add_action(
|
8 |
+
'blocksy:cache-manager:purge-all',
|
9 |
+
function () {
|
10 |
+
$this->run_cache_purge();
|
11 |
+
}
|
12 |
+
);
|
13 |
+
|
14 |
+
add_action(
|
15 |
+
'upgrader_process_complete',
|
16 |
+
[$this, 'handle_update'],
|
17 |
+
10, 2
|
18 |
+
);
|
19 |
+
}
|
20 |
+
|
21 |
+
public function handle_update($upgrader, $options) {
|
22 |
+
if ($options['action'] !== 'update') {
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
|
26 |
+
if ($options['type'] === 'theme') {
|
27 |
+
if (in_array('blocksy', $options['themes'])) {
|
28 |
+
$this->run_cache_purge();
|
29 |
+
do_action('blocksy:dynamic-css:regenere_css_files');
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
if ($options['type'] === 'plugin') {
|
34 |
+
$plugins = [];
|
35 |
+
|
36 |
+
if (isset($options['plugins']) && is_array($options['plugins'])) {
|
37 |
+
$plugins = $options['plugins'];
|
38 |
+
}
|
39 |
+
|
40 |
+
if (in_array(BLOCKSY_PLUGIN_BASE, $plugins)) {
|
41 |
+
$this->run_cache_purge();
|
42 |
+
do_action('blocksy:dynamic-css:regenere_css_files');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
public function run_cache_purge() {
|
48 |
+
# Purge all W3 Total Cache
|
49 |
+
if (function_exists('w3tc_pgcache_flush')) {
|
50 |
+
w3tc_pgcache_flush();
|
51 |
+
}
|
52 |
+
|
53 |
+
if (function_exists('w3tc_flush_all')) {
|
54 |
+
w3tc_flush_all();
|
55 |
+
}
|
56 |
+
|
57 |
+
# Purge WP Super Cache
|
58 |
+
if (function_exists('wp_cache_clear_cache')) {
|
59 |
+
wp_cache_clear_cache();
|
60 |
+
}
|
61 |
+
|
62 |
+
if (isset($GLOBALS['wp_fastest_cache'])) {
|
63 |
+
if (method_exists($GLOBALS['wp_fastest_cache'], 'deleteCache')) {
|
64 |
+
$GLOBALS['wp_fastest_cache']->deleteCache();
|
65 |
+
$GLOBALS['wp_fastest_cache']->deleteCache(true);
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
if (function_exists('cachify_flush_cache')) {
|
70 |
+
cachify_flush_cache();
|
71 |
+
}
|
72 |
+
|
73 |
+
if (class_exists("comet_cache")) {
|
74 |
+
\comet_cache::clear();
|
75 |
+
}
|
76 |
+
|
77 |
+
if (class_exists("zencache")) {
|
78 |
+
\zencache::clear();
|
79 |
+
}
|
80 |
+
|
81 |
+
if (class_exists('LiteSpeed_Cache_Tags')) {
|
82 |
+
\LiteSpeed_Cache_Tags::add_purge_tag('*');
|
83 |
+
}
|
84 |
+
|
85 |
+
if (function_exists('sg_cachepress_purge_cache')) {
|
86 |
+
sg_cachepress_purge_cache();
|
87 |
+
}
|
88 |
+
|
89 |
+
if (class_exists('LiteSpeed_Cache_Purge')) {
|
90 |
+
\LiteSpeed_Cache_Purge::purge_all('Clear Cache For Me');
|
91 |
+
}
|
92 |
+
|
93 |
+
if (class_exists('WP_Optimize') && defined('WPO_PLUGIN_MAIN_PATH')) {
|
94 |
+
if (! class_exists('WP_Optimize_Cache_Commands')) include_once(WPO_PLUGIN_MAIN_PATH . 'cache/class-cache-commands.php');
|
95 |
+
if (! class_exists('WP_Optimize_Minify_Commands')) include_once(WPO_PLUGIN_MAIN_PATH . 'minify/class-wp-optimize-minify-commands.php');
|
96 |
+
if (! class_exists('WP_Optimize_Minify_Cache_Functions')) include_once(WPO_PLUGIN_MAIN_PATH . 'minify/class-wp-optimize-minify-cache-functions.php');
|
97 |
+
|
98 |
+
if (class_exists('WP_Optimize_Cache_Commands')) {
|
99 |
+
$wpoptimize_cache_commands = new \WP_Optimize_Cache_Commands();
|
100 |
+
$wpoptimize_cache_commands->purge_page_cache();
|
101 |
+
}
|
102 |
+
|
103 |
+
if (class_exists('WP_Optimize_Minify_Commands')) {
|
104 |
+
$wpoptimize_minify_commands = new \WP_Optimize_Minify_Commands();
|
105 |
+
$wpoptimize_minify_commands->purge_minify_cache();
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
if (
|
110 |
+
class_exists('WPaaS\Plugin')
|
111 |
+
&&
|
112 |
+
function_exists('fastvelocity_godaddy_request')
|
113 |
+
) {
|
114 |
+
fastvelocity_godaddy_request('BAN');
|
115 |
+
}
|
116 |
+
|
117 |
+
# Purge WP Engine
|
118 |
+
if (class_exists("WpeCommon")) {
|
119 |
+
if (method_exists('WpeCommon', 'purge_memcached')) {
|
120 |
+
\WpeCommon::purge_memcached();
|
121 |
+
}
|
122 |
+
|
123 |
+
if (method_exists('WpeCommon', 'clear_maxcdn_cache')) {
|
124 |
+
\WpeCommon::clear_maxcdn_cache();
|
125 |
+
}
|
126 |
+
|
127 |
+
if (method_exists('WpeCommon', 'purge_varnish_cache')) {
|
128 |
+
\WpeCommon::purge_varnish_cache();
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
if (function_exists('rocket_clean_domain')) {
|
133 |
+
rocket_clean_domain();
|
134 |
+
}
|
135 |
+
|
136 |
+
if (function_exists('wp_cache_clean_cache')) {
|
137 |
+
global $file_prefix;
|
138 |
+
wp_cache_clean_cache( $file_prefix, true );
|
139 |
+
}
|
140 |
+
|
141 |
+
if (class_exists('autoptimizeCache')) {
|
142 |
+
\autoptimizeCache::clearall();
|
143 |
+
}
|
144 |
+
|
145 |
+
if (function_exists('fvm_purge_all')) {
|
146 |
+
fvm_purge_all();
|
147 |
+
}
|
148 |
+
|
149 |
+
if (function_exists('fastvelocity_purge_others')) {
|
150 |
+
fastvelocity_purge_others();
|
151 |
+
}
|
152 |
+
|
153 |
+
# wordpress default cache
|
154 |
+
if (function_exists('wp_cache_flush')) {
|
155 |
+
wp_cache_flush();
|
156 |
+
}
|
157 |
+
|
158 |
+
# https://wordpress.org/plugins/hummingbird-performance/
|
159 |
+
do_action('wphb_clear_page_cache');
|
160 |
+
|
161 |
+
if (class_exists('Swift_Performance_Cache')) {
|
162 |
+
\Swift_Performance_Cache::clear_all_cache();
|
163 |
+
}
|
164 |
+
|
165 |
+
if (class_exists('\SiteGround_Optimizer\Supercacher\Supercacher')) {
|
166 |
+
\SiteGround_Optimizer\Supercacher\Supercacher::get_instance()->purge_everything();
|
167 |
+
do_action('siteground_delete_assets');
|
168 |
+
}
|
169 |
+
|
170 |
+
if (class_exists('ShortPixelAI')) {
|
171 |
+
\ShortPixelAI::clear_css_cache();
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
trunk/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 |
+
|
trunk/framework/dashboard.php
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Blocksy;
|
4 |
+
|
5 |
+
class Dashboard {
|
6 |
+
public function __construct() {
|
7 |
+
add_action(
|
8 |
+
'admin_enqueue_scripts',
|
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 |
+
$result = [
|
108 |
+
'is_pro' => blc_fs()->is__premium_only(),
|
109 |
+
'is_anonymous' => $is_anonymous,
|
110 |
+
'connect_template' => $connect_template
|
111 |
+
];
|
112 |
+
|
113 |
+
if (Plugin::instance()->premium) {
|
114 |
+
$result['has_beta_consent'] = Plugin::instance()->premium->user_wants_beta_updates();
|
115 |
+
}
|
116 |
+
|
117 |
+
return array_merge($result, $d);
|
118 |
+
}
|
119 |
+
);
|
120 |
+
}
|
121 |
+
|
122 |
+
public function enqueue_static() {
|
123 |
+
if (! function_exists('blocksy_is_dashboard_page')) return;
|
124 |
+
if (! blocksy_is_dashboard_page()) return;
|
125 |
+
|
126 |
+
$data = get_plugin_data(BLOCKSY__FILE__);
|
127 |
+
|
128 |
+
$deps = apply_filters('blocksy-dashboard-scripts-dependencies', [
|
129 |
+
'wp-i18n',
|
130 |
+
'ct-events',
|
131 |
+
'ct-options-scripts'
|
132 |
+
]);
|
133 |
+
|
134 |
+
wp_enqueue_script(
|
135 |
+
'blocksy-dashboard-scripts',
|
136 |
+
BLOCKSY_URL . 'static/bundle/dashboard.js',
|
137 |
+
$deps,
|
138 |
+
$data['Version'],
|
139 |
+
false
|
140 |
+
);
|
141 |
+
|
142 |
+
wp_enqueue_style(
|
143 |
+
'blocksy-dashboard-styles',
|
144 |
+
BLOCKSY_URL . 'static/bundle/dashboard.css',
|
145 |
+
[],
|
146 |
+
$data['Version']
|
147 |
+
);
|
148 |
+
}
|
149 |
+
}
|
trunk/framework/extensions-manager-api.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Blocksy;
|
4 |
+
|
5 |
+
class ExtensionsManagerApi {
|
6 |
+
public function __construct() {
|
7 |
+
$this->attach_ajax_actions();
|
8 |
+
|
9 |
+
if (wp_doing_ajax()) {
|
10 |
+
$manager = Plugin::instance()->extensions;
|
11 |
+
$manager->do_extensions_preboot();
|
12 |
+
}
|
13 |
+
}
|
14 |
+
|
15 |
+
protected $ajax_actions = [
|
16 |
+
'blocksy_extensions_status',
|
17 |
+
'blocksy_extension_activate',
|
18 |
+
'blocksy_extension_deactivate',
|
19 |
+
];
|
20 |
+
|
21 |
+
public function blocksy_extensions_status() {
|
22 |
+
$this->check_capability('edit_theme_options');
|
23 |
+
$manager = Plugin::instance()->extensions;
|
24 |
+
|
25 |
+
$maybe_input = json_decode(file_get_contents('php://input'), true);
|
26 |
+
|
27 |
+
$data = $manager->get_extensions([
|
28 |
+
'forced_reread' => true
|
29 |
+
]);
|
30 |
+
|
31 |
+
if (
|
32 |
+
$maybe_input
|
33 |
+
&&
|
34 |
+
isset($maybe_input['extension'])
|
35 |
+
&&
|
36 |
+
isset($maybe_input['extAction'])
|
37 |
+
) {
|
38 |
+
$ext_preboot = $manager->get($maybe_input['extension'], [
|
39 |
+
'type' => 'preboot'
|
40 |
+
]);
|
41 |
+
|
42 |
+
if (method_exists(
|
43 |
+
$ext_preboot, 'ext_action'
|
44 |
+
)) {
|
45 |
+
$result = $ext_preboot->ext_action($maybe_input['extAction']);
|
46 |
+
|
47 |
+
if ($result) {
|
48 |
+
$data[$maybe_input['extension']]['data'] = $result;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
wp_send_json_success($data);
|
54 |
+
}
|
55 |
+
|
56 |
+
public function blocksy_extension_activate() {
|
57 |
+
$this->check_capability('edit_theme_options');
|
58 |
+
$manager = Plugin::instance()->extensions;
|
59 |
+
|
60 |
+
$manager->activate_extension($this->get_extension_from_request());
|
61 |
+
|
62 |
+
wp_send_json_success();
|
63 |
+
}
|
64 |
+
|
65 |
+
public function blocksy_extension_deactivate() {
|
66 |
+
$this->check_capability('edit_theme_options');
|
67 |
+
$manager = Plugin::instance()->extensions;
|
68 |
+
|
69 |
+
$manager->deactivate_extension($this->get_extension_from_request());
|
70 |
+
|
71 |
+
wp_send_json_success();
|
72 |
+
}
|
73 |
+
|
74 |
+
public function check_capability( $cap = 'install_plugins' ) {
|
75 |
+
$manager = Plugin::instance()->extensions;
|
76 |
+
|
77 |
+
if ( ! $manager->can( $cap ) ) {
|
78 |
+
wp_send_json_error();
|
79 |
+
}
|
80 |
+
|
81 |
+
return true;
|
82 |
+
}
|
83 |
+
|
84 |
+
public function get_extension_from_request() {
|
85 |
+
if ( ! isset( $_POST['ext'] ) ) {
|
86 |
+
wp_send_json_error();
|
87 |
+
}
|
88 |
+
|
89 |
+
return addslashes($_POST['ext']);
|
90 |
+
}
|
91 |
+
|
92 |
+
public function attach_ajax_actions() {
|
93 |
+
foreach ( $this->ajax_actions as $action ) {
|
94 |
+
add_action(
|
95 |
+
'wp_ajax_' . $action,
|
96 |
+
[ $this, $action ]
|
97 |
+
);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
trunk/framework/extensions-manager.php
ADDED
@@ -0,0 +1,338 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Blocksy;
|
4 |
+
|
5 |
+
class ExtensionsManager
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Collection of all the activated extensions.
|
9 |
+
*
|
10 |
+
* @var array The array of all the extension objects.
|
11 |
+
*/
|
12 |
+
private $extensions = array() ;
|
13 |
+
private function get_option_name()
|
14 |
+
{
|
15 |
+
return 'blocksy_active_extensions';
|
16 |
+
}
|
17 |
+
|
18 |
+
public function get( $id, $args = array() )
|
19 |
+
{
|
20 |
+
$args = wp_parse_args( $args, [
|
21 |
+
'type' => 'regular',
|
22 |
+
] );
|
23 |
+
if ( !isset( $this->extensions[$id] ) ) {
|
24 |
+
return null;
|
25 |
+
}
|
26 |
+
|
27 |
+
if ( $args['type'] === 'preboot' ) {
|
28 |
+
if ( !isset( $this->extensions[$id]['__object_preboot'] ) ) {
|
29 |
+
return null;
|
30 |
+
}
|
31 |
+
return $this->extensions[$id]['__object_preboot'];
|
32 |
+
}
|
33 |
+
|
34 |
+
if ( !isset( $this->extensions[$id]['__object'] ) ) {
|
35 |
+
return null;
|
36 |
+
}
|
37 |
+
return $this->extensions[$id]['__object'];
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Collect all available extensions and activate the ones that have to be so.
|
42 |
+
*/
|
43 |
+
public function __construct()
|
44 |
+
{
|
45 |
+
$this->read_installed_extensions();
|
46 |
+
if ( $this->is_dashboard_page() ) {
|
47 |
+
$this->do_extensions_preboot();
|
48 |
+
}
|
49 |
+
foreach ( $this->get_activated_extensions() as $single_id ) {
|
50 |
+
$this->boot_activated_extension_for( $single_id );
|
51 |
+
}
|
52 |
+
add_action( 'activate_blocksy-companion/blocksy-companion.php', [ $this, 'handle_activation' ], 11 );
|
53 |
+
add_action( 'deactivate_blocksy-companion/blocksy-companion.php', [ $this, 'handle_deactivation' ], 11 );
|
54 |
+
}
|
55 |
+
|
56 |
+
public function handle_activation()
|
57 |
+
{
|
58 |
+
ob_start();
|
59 |
+
foreach ( $this->get_activated_extensions() as $id ) {
|
60 |
+
if ( method_exists( $this->get_class_name_for( $id ), "onActivation" ) ) {
|
61 |
+
call_user_func( [ $this->get_class_name_for( $id ), 'onActivation' ] );
|
62 |
+
}
|
63 |
+
}
|
64 |
+
ob_get_clean();
|
65 |
+
}
|
66 |
+
|
67 |
+
public function handle_deactivation()
|
68 |
+
{
|
69 |
+
foreach ( $this->get_activated_extensions() as $id ) {
|
70 |
+
if ( method_exists( $this->get_class_name_for( $id ), "onDeactivation" ) ) {
|
71 |
+
call_user_func( [ $this->get_class_name_for( $id ), 'onDeactivation' ] );
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
public function do_extensions_preboot()
|
77 |
+
{
|
78 |
+
foreach ( array_keys( $this->get_extensions() ) as $single_id ) {
|
79 |
+
$this->maybe_do_extension_preboot( $single_id );
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
private function is_dashboard_page()
|
84 |
+
{
|
85 |
+
global $pagenow ;
|
86 |
+
$is_ct_settings = isset( $_GET['page'] ) && 'ct-dashboard' === $_GET['page'];
|
87 |
+
return $is_ct_settings;
|
88 |
+
}
|
89 |
+
|
90 |
+
public function get_extensions( $args = array() )
|
91 |
+
{
|
92 |
+
$args = wp_parse_args( $args, [
|
93 |
+
'forced_reread' => false,
|
94 |
+
] );
|
95 |
+
|
96 |
+
if ( $args['forced_reread'] ) {
|
97 |
+
foreach ( $this->extensions as $id => $extension ) {
|
98 |
+
$this->extensions[$id]['config'] = $this->read_config_for( $extension['path'] );
|
99 |
+
$this->extensions[$id]['readme'] = $this->read_readme_for( $extension['path'] );
|
100 |
+
}
|
101 |
+
$this->register_fake_extensions();
|
102 |
+
}
|
103 |
+
|
104 |
+
return $this->extensions;
|
105 |
+
}
|
106 |
+
|
107 |
+
public function can( $capability = 'install_plugins' )
|
108 |
+
{
|
109 |
+
$user = wp_get_current_user();
|
110 |
+
// return array_intersect(['administrator'], $user->roles );
|
111 |
+
|
112 |
+
if ( is_multisite() ) {
|
113 |
+
// Only network admin can change files that affects the entire network.
|
114 |
+
$can = current_user_can_for_blog( get_current_blog_id(), $capability );
|
115 |
+
} else {
|
116 |
+
$can = current_user_can( $capability );
|
117 |
+
}
|
118 |
+
|
119 |
+
if ( $can ) {
|
120 |
+
// Also you can use this method to get the capability.
|
121 |
+
$can = $capability;
|
122 |
+
}
|
123 |
+
return $can;
|
124 |
+
}
|
125 |
+
|
126 |
+
public function activate_extension( $id )
|
127 |
+
{
|
128 |
+
if ( !isset( $this->extensions[$id] ) ) {
|
129 |
+
return;
|
130 |
+
}
|
131 |
+
if ( !$this->extensions[$id]['path'] ) {
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
$activated = $this->get_activated_extensions();
|
135 |
+
|
136 |
+
if ( !in_array( strtolower( $id ), $activated ) ) {
|
137 |
+
$path = $this->extensions[$id]['path'];
|
138 |
+
require_once $path . '/extension.php';
|
139 |
+
if ( method_exists( $this->get_class_name_for( $id ), "onActivation" ) ) {
|
140 |
+
call_user_func( [ $this->get_class_name_for( $id ), 'onActivation' ] );
|
141 |
+
}
|
142 |
+
$class = $this->get_class_name_for( $id );
|
143 |
+
// Init extension right away.
|
144 |
+
new $class();
|
145 |
+
}
|
146 |
+
|
147 |
+
$activated[] = strtolower( $id );
|
148 |
+
update_option( $this->get_option_name(), array_unique( $activated ) );
|
149 |
+
Plugin::instance()->dynamic_css->generate_css_files();
|
150 |
+
}
|
151 |
+
|
152 |
+
public function deactivate_extension( $id )
|
153 |
+
{
|
154 |
+
if ( !isset( $this->extensions[$id] ) ) {
|
155 |
+
return;
|
156 |
+
}
|
157 |
+
if ( !$this->extensions[$id]['path'] ) {
|
158 |
+
return;
|
159 |
+
}
|
160 |
+
$activated = $this->get_activated_extensions();
|
161 |
+
if ( in_array( strtolower( $id ), $activated ) ) {
|
162 |
+
if ( method_exists( $this->get_class_name_for( $id ), "onDeactivation" ) ) {
|
163 |
+
call_user_func( [ $this->get_class_name_for( $id ), 'onDeactivation' ] );
|
164 |
+
}
|
165 |
+
}
|
166 |
+
update_option( $this->get_option_name(), array_diff( $activated, [ $id ] ) );
|
167 |
+
Plugin::instance()->dynamic_css->generate_css_files();
|
168 |
+
}
|
169 |
+
|
170 |
+
private function read_installed_extensions()
|
171 |
+
{
|
172 |
+
$paths_to_look_for_extensions = apply_filters( 'blocksy_extensions_paths', [ BLOCKSY_PATH . 'framework/extensions' ] );
|
173 |
+
foreach ( $paths_to_look_for_extensions as $single_path ) {
|
174 |
+
$all_extensions = glob( $single_path . '/*', GLOB_ONLYDIR );
|
175 |
+
foreach ( $all_extensions as $single_extension ) {
|
176 |
+
$this->register_extension_for( $single_extension );
|
177 |
+
}
|
178 |
+
}
|
179 |
+
$this->register_fake_extensions();
|
180 |
+
}
|
181 |
+
|
182 |
+
private function register_fake_extensions()
|
183 |
+
{
|
184 |
+
return;
|
185 |
+
$this->extensions['custom-fonts'] = [
|
186 |
+
'path' => null,
|
187 |
+
'__object' => null,
|
188 |
+
'config' => [
|
189 |
+
'name' => __( 'Custom Fonts', 'blc' ),
|
190 |
+
'description' => __( 'Upload unlimited number of custom fonts.', 'blc' ),
|
191 |
+
'pro' => true,
|
192 |
+
],
|
193 |
+
'readme' => '',
|
194 |
+
'data' => null,
|
195 |
+
];
|
196 |
+
$this->extensions['sidebars'] = [
|
197 |
+
'path' => null,
|
198 |
+
'__object' => null,
|
199 |
+
'config' => [
|
200 |
+
'name' => __( 'Sidebars', 'blc' ),
|
201 |
+
'description' => __( 'Create unlimited number of custom sidebars.', 'blc' ),
|
202 |
+
'pro' => true,
|
203 |
+
],
|
204 |
+
'readme' => '',
|
205 |
+
'data' => null,
|
206 |
+
];
|
207 |
+
$this->extensions['white-label'] = [
|
208 |
+
'path' => null,
|
209 |
+
'__object' => null,
|
210 |
+
'config' => [
|
211 |
+
'name' => __( 'White Label', 'blc' ),
|
212 |
+
'description' => __( 'Change theme/companion branding', 'blc' ),
|
213 |
+
'pro' => true,
|
214 |
+
],
|
215 |
+
'readme' => '',
|
216 |
+
'data' => null,
|
217 |
+
];
|
218 |
+
}
|
219 |
+
|
220 |
+
private function register_extension_for( $path )
|
221 |
+
{
|
222 |
+
$id = str_replace( '_', '-', basename( $path ) );
|
223 |
+
if ( isset( $this->extensions[$id] ) ) {
|
224 |
+
return;
|
225 |
+
}
|
226 |
+
$this->extensions[$id] = [
|
227 |
+
'path' => $path,
|
228 |
+
'__object' => null,
|
229 |
+
'config' => $this->read_config_for( $path ),
|
230 |
+
'readme' => $this->read_readme_for( $path ),
|
231 |
+
'data' => null,
|
232 |
+
];
|
233 |
+
}
|
234 |
+
|
235 |
+
private function maybe_do_extension_preboot( $id )
|
236 |
+
{
|
237 |
+
if ( !isset( $this->extensions[$id] ) ) {
|
238 |
+
return false;
|
239 |
+
}
|
240 |
+
if ( isset( $this->extensions[$id]['__object_preboot'] ) ) {
|
241 |
+
return;
|
242 |
+
}
|
243 |
+
$class_name = explode( '-', $id );
|
244 |
+
$class_name = array_map( 'ucfirst', $class_name );
|
245 |
+
$class_name = 'BlocksyExtension' . implode( '', $class_name ) . 'PreBoot';
|
246 |
+
$path = $this->extensions[$id]['path'];
|
247 |
+
if ( !file_exists( $path . '/pre-boot.php' ) ) {
|
248 |
+
return;
|
249 |
+
}
|
250 |
+
require_once $path . '/pre-boot.php';
|
251 |
+
$this->extensions[$id]['__object_preboot'] = new $class_name();
|
252 |
+
if ( method_exists( $this->extensions[$id]['__object_preboot'], 'ext_data' ) ) {
|
253 |
+
$this->extensions[$id]['data'] = $this->extensions[$id]['__object_preboot']->ext_data();
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
private function boot_activated_extension_for( $id )
|
258 |
+
{
|
259 |
+
if ( !isset( $this->extensions[$id] ) ) {
|
260 |
+
return false;
|
261 |
+
}
|
262 |
+
if ( !isset( $this->extensions[$id]['path'] ) ) {
|
263 |
+
return false;
|
264 |
+
}
|
265 |
+
if ( !$this->extensions[$id]['path'] ) {
|
266 |
+
return false;
|
267 |
+
}
|
268 |
+
if ( isset( $this->extensions[$id]['config']['hidden'] ) && $this->extensions[$id]['config']['hidden'] ) {
|
269 |
+
return;
|
270 |
+
}
|
271 |
+
if ( isset( $this->extensions[$id]['__object'] ) ) {
|
272 |
+
return;
|
273 |
+
}
|
274 |
+
$class_name = explode( '-', $id );
|
275 |
+
$class_name = array_map( 'ucfirst', $class_name );
|
276 |
+
$class_name = 'BlocksyExtension' . implode( '', $class_name );
|
277 |
+
$path = $this->extensions[$id]['path'];
|
278 |
+
if ( !file_exists( $path . '/extension.php' ) ) {
|
279 |
+
return;
|
280 |
+
}
|
281 |
+
require_once $path . '/extension.php';
|
282 |
+
$this->extensions[$id]['__object'] = new $class_name();
|
283 |
+
}
|
284 |
+
|
285 |
+
private function get_class_name_for( $id )
|
286 |
+
{
|
287 |
+
$class_name = explode( '-', $id );
|
288 |
+
$class_name = array_map( 'ucfirst', $class_name );
|
289 |
+
return 'BlocksyExtension' . implode( '', $class_name );
|
290 |
+
}
|
291 |
+
|
292 |
+
private function read_readme_for( $path )
|
293 |
+
{
|
294 |
+
$readme = '';
|
295 |
+
ob_start();
|
296 |
+
if ( is_readable( $path . '/readme.php' ) ) {
|
297 |
+
require $path . '/readme.php';
|
298 |
+
}
|
299 |
+
$readme = ob_get_clean();
|
300 |
+
if ( empty(trim( $readme )) ) {
|
301 |
+
return null;
|
302 |
+
}
|
303 |
+
return trim( $readme );
|
304 |
+
}
|
305 |
+
|
306 |
+
private function read_config_for( $file_path )
|
307 |
+
{
|
308 |
+
$_extract_variables = [
|
309 |
+
'config' => [],
|
310 |
+
];
|
311 |
+
|
312 |
+
if ( is_readable( $file_path . '/config.php' ) ) {
|
313 |
+
require $file_path . '/config.php';
|
314 |
+
foreach ( $_extract_variables as $variable_name => $default_value ) {
|
315 |
+
if ( isset( ${$variable_name} ) ) {
|
316 |
+
$_extract_variables[$variable_name] = ${$variable_name};
|
317 |
+
}
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
$name = explode( '-', basename( $file_path ) );
|
322 |
+
$name = array_map( 'ucfirst', $name );
|
323 |
+
$name = implode( ' ', $name );
|
324 |
+
$_extract_variables['config'] = array_merge( [
|
325 |
+
'name' => $name,
|
326 |
+
'description' => '',
|
327 |
+
'pro' => false,
|
328 |
+
'hidden' => false,
|
329 |
+
], $_extract_variables['config'] );
|
330 |
+
return $_extract_variables['config'];
|
331 |
+
}
|
332 |
+
|
333 |
+
private function get_activated_extensions()
|
334 |
+
{
|
335 |
+
return get_option( $this->get_option_name(), [] );
|
336 |
+
}
|
337 |
+
|
338 |
+
}
|
trunk/framework/extensions/cookies-consent/config.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$config = [
|
4 |
+
'name' => __('Cookies Consent', 'blc'),
|
5 |
+
'description' => __('Enable this extension in order to comply with the GDPR regulations.', 'blc')
|
6 |
+
];
|
trunk/framework/extensions/cookies-consent/customizer.php
ADDED
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$options = [
|
4 |
+
'title' => __('Cookie Consent', 'blc'),
|
5 |
+
'container' => [ 'priority' => 8 ],
|
6 |
+
'options' => [
|
7 |
+
|
8 |
+
'cookie_consent_section_options' => [
|
9 |
+
'type' => 'ct-options',
|
10 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
11 |
+
'inner-options' => [
|
12 |
+
blocksy_rand_md5() => [
|
13 |
+
'type' => 'ct-title',
|
14 |
+
'label' => __( 'Cookies Notification', 'blocksy' ),
|
15 |
+
],
|
16 |
+
|
17 |
+
blocksy_rand_md5() => [
|
18 |
+
'title' => __( 'General', 'blc' ),
|
19 |
+
'type' => 'tab',
|
20 |
+
'options' => [
|
21 |
+
|
22 |
+
'cookie_consent_type' => [
|
23 |
+
'label' => false,
|
24 |
+
'type' => 'ct-image-picker',
|
25 |
+
'value' => 'type-1',
|
26 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
27 |
+
'choices' => [
|
28 |
+
|
29 |
+
'type-1' => [
|
30 |
+
'src' => BLOCKSY_URL . 'framework/extensions/cookies-consent/static/images/type-1.svg',
|
31 |
+
'title' => __( 'Type 1', 'blc' ),
|
32 |
+
],
|
33 |
+
|
34 |
+
'type-2' => [
|
35 |
+
'src' => BLOCKSY_URL . 'framework/extensions/cookies-consent/static/images/type-2.svg',
|
36 |
+
'title' => __( 'Type 2', 'blc' ),
|
37 |
+
],
|
38 |
+
|
39 |
+
],
|
40 |
+
],
|
41 |
+
|
42 |
+
'cookie_consent_period' => [
|
43 |
+
'label' => __('Cookie period', 'blc'),
|
44 |
+
'type' => 'ct-select',
|
45 |
+
'value' => 'forever',
|
46 |
+
'design' => 'inline',
|
47 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
48 |
+
'choices' => blocksy_ordered_keys(
|
49 |
+
|
50 |
+
[
|
51 |
+
'onehour' => __( 'One hour', 'blc' ),
|
52 |
+
'oneday' => __( 'One day', 'blc' ),
|
53 |
+
'oneweek' => __( 'One week', 'blc' ),
|
54 |
+
'onemonth' => __( 'One month', 'blc' ),
|
55 |
+
'threemonths' => __( 'Three months', 'blc' ),
|
56 |
+
'sixmonths' => __( 'Six months', 'blc' ),
|
57 |
+
'oneyear' => __( 'One year', 'blc' ),
|
58 |
+
'forever' => __('Forever', 'blc')
|
59 |
+
]
|
60 |
+
|
61 |
+
),
|
62 |
+
],
|
63 |
+
|
64 |
+
'cookie_consent_content' => [
|
65 |
+
'label' => __( 'Content', 'blc' ),
|
66 |
+
'type' => 'wp-editor',
|
67 |
+
'value' => __('We use cookies to ensure that we give you the best experience on our website.', 'blc'),
|
68 |
+
'disableRevertButton' => true,
|
69 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
70 |
+
|
71 |
+
'quicktags' => false,
|
72 |
+
'mediaButtons' => false,
|
73 |
+
'tinymce' => [
|
74 |
+
'toolbar1' => 'bold,italic,link,alignleft,aligncenter,alignright,undo,redo',
|
75 |
+
],
|
76 |
+
],
|
77 |
+
|
78 |
+
'cookie_consent_button_text' => [
|
79 |
+
'label' => __( 'Button text', 'blc' ),
|
80 |
+
'type' => 'text',
|
81 |
+
'design' => 'block',
|
82 |
+
'value' => __('Accept', 'blc'),
|
83 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
84 |
+
],
|
85 |
+
|
86 |
+
],
|
87 |
+
],
|
88 |
+
|
89 |
+
blocksy_rand_md5() => [
|
90 |
+
'title' => __( 'Design', 'blc' ),
|
91 |
+
'type' => 'tab',
|
92 |
+
'options' => [
|
93 |
+
|
94 |
+
'cookieContentColor' => [
|
95 |
+
'label' => __( 'Font Color', 'blc' ),
|
96 |
+
'type' => 'ct-color-picker',
|
97 |
+
'design' => 'inline',
|
98 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
99 |
+
|
100 |
+
'value' => [
|
101 |
+
'default' => [
|
102 |
+
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
|
103 |
+
],
|
104 |
+
|
105 |
+
'hover' => [
|
106 |
+
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
|
107 |
+
],
|
108 |
+
],
|
109 |
+
|
110 |
+
'pickers' => [
|
111 |
+
[
|
112 |
+
'title' => __( 'Initial', 'blc' ),
|
113 |
+
'id' => 'default',
|
114 |
+
'inherit' => 'var(--color)'
|
115 |
+
],
|
116 |
+
|
117 |
+
[
|
118 |
+
'title' => __( 'Hover', 'blc' ),
|
119 |
+
'id' => 'hover',
|
120 |
+
'inherit' => 'var(--colorHover)'
|
121 |
+
],
|
122 |
+
],
|
123 |
+
],
|
124 |
+
|
125 |
+
'cookieButtonBackground' => [
|
126 |
+
'label' => __( 'Button Color', 'blc' ),
|
127 |
+
'type' => 'ct-color-picker',
|
128 |
+
'design' => 'inline',
|
129 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
130 |
+
'value' => [
|
131 |
+
'default' => [
|
132 |
+
'color' => 'var(--paletteColor1)',
|
133 |
+
],
|
134 |
+
|
135 |
+
'hover' => [
|
136 |
+
'color' => 'var(--paletteColor2)',
|
137 |
+
],
|
138 |
+
],
|
139 |
+
|
140 |
+
'pickers' => [
|
141 |
+
[
|
142 |
+
'title' => __( 'Initial', 'blc' ),
|
143 |
+
'id' => 'default',
|
144 |
+
],
|
145 |
+
|
146 |
+
[
|
147 |
+
'title' => __( 'Hover', 'blc' ),
|
148 |
+
'id' => 'hover',
|
149 |
+
],
|
150 |
+
],
|
151 |
+
],
|
152 |
+
|
153 |
+
'cookieBackground' => [
|
154 |
+
'label' => __( 'Background Color', 'blc' ),
|
155 |
+
'type' => 'ct-color-picker',
|
156 |
+
'design' => 'inline',
|
157 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
158 |
+
|
159 |
+
'value' => [
|
160 |
+
'default' => [
|
161 |
+
'color' => '#ffffff',
|
162 |
+
],
|
163 |
+
],
|
164 |
+
|
165 |
+
'pickers' => [
|
166 |
+
[
|
167 |
+
'title' => __( 'Initial', 'blc' ),
|
168 |
+
'id' => 'default',
|
169 |
+
],
|
170 |
+
],
|
171 |
+
],
|
172 |
+
|
173 |
+
blocksy_rand_md5() => [
|
174 |
+
'type' => 'ct-condition',
|
175 |
+
'condition' => [ 'cookie_consent_type' => 'type-1' ],
|
176 |
+
'options' => [
|
177 |
+
|
178 |
+
'cookieMaxWidth' => [
|
179 |
+
'label' => __( 'Maximum Width', 'blc' ),
|
180 |
+
'type' => 'ct-slider',
|
181 |
+
'value' => 400,
|
182 |
+
'min' => 200,
|
183 |
+
'max' => 500,
|
184 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
185 |
+
],
|
186 |
+
|
187 |
+
],
|
188 |
+
],
|
189 |
+
|
190 |
+
],
|
191 |
+
],
|
192 |
+
|
193 |
+
blocksy_rand_md5() => [
|
194 |
+
'type' => 'ct-title',
|
195 |
+
'label' => __( 'Forms Cookies Content', 'blocksy' ),
|
196 |
+
],
|
197 |
+
|
198 |
+
'forms_cookie_consent_content' => [
|
199 |
+
'label' => false,
|
200 |
+
'type' => 'wp-editor',
|
201 |
+
'value' => sprintf(
|
202 |
+
__('I accept the %sPrivacy Policy%s', 'blc'),
|
203 |
+
'<a href="/privacy-policy">',
|
204 |
+
'</a>'
|
205 |
+
),
|
206 |
+
'desc' => __( 'This text will appear under each comment form and subscribe form.', 'blc' ),
|
207 |
+
// 'attr' => [ 'data-height' => 'heading-label' ],
|
208 |
+
'disableRevertButton' => true,
|
209 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
210 |
+
|
211 |
+
'quicktags' => false,
|
212 |
+
'mediaButtons' => false,
|
213 |
+
'tinymce' => [
|
214 |
+
'toolbar1' => 'bold,italic,link,alignleft,aligncenter,alignright,undo,redo',
|
215 |
+
'forced_root_block' => '',
|
216 |
+
'force_br_newlines' => true,
|
217 |
+
'force_p_newlines' => false
|
218 |
+
],
|
219 |
+
],
|
220 |
+
|
221 |
+
],
|
222 |
+
],
|
223 |
+
],
|
224 |
+
];
|
trunk/framework/extensions/cookies-consent/extension.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once dirname(__FILE__) . '/helpers.php';
|
4 |
+
|
5 |
+
class BlocksyExtensionCookiesConsent {
|
6 |
+
public static function should_display_notification() {
|
7 |
+
return !isset($_COOKIE['blocksy_cookies_consent_accepted']);
|
8 |
+
}
|
9 |
+
|
10 |
+
public function __construct() {
|
11 |
+
add_filter('blocksy:footer:offcanvas-drawer', function ($els) {
|
12 |
+
$els[] = blocksy_ext_cookies_consent_output();
|
13 |
+
return $els;
|
14 |
+
});
|
15 |
+
|
16 |
+
add_filter('blocksy-async-scripts-handles', function ($d) {
|
17 |
+
$d[] = 'blocksy-ext-cookies-consent-scripts';
|
18 |
+
return $d;
|
19 |
+
});
|
20 |
+
|
21 |
+
add_filter(
|
22 |
+
'blocksy_extensions_customizer_options',
|
23 |
+
[$this, 'add_options_panel']
|
24 |
+
);
|
25 |
+
|
26 |
+
add_action(
|
27 |
+
'customize_preview_init',
|
28 |
+
function () {
|
29 |
+
if (! function_exists('get_plugin_data')){
|
30 |
+
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
31 |
+
}
|
32 |
+
|
33 |
+
$data = get_plugin_data(BLOCKSY__FILE__);
|
34 |
+
|
35 |
+
wp_enqueue_script(
|
36 |
+
'blocksy-cookies-consent-customizer-sync',
|
37 |
+
BLOCKSY_URL . 'framework/extensions/cookies-consent/static/bundle/sync.js',
|
38 |
+
[ 'ct-events', 'customize-preview' ],
|
39 |
+
$data['Version'],
|
40 |
+
true
|
41 |
+
);
|
42 |
+
}
|
43 |
+
);
|
44 |
+
|
45 |
+
add_action('wp_enqueue_scripts', function () {
|
46 |
+
if (! function_exists('get_plugin_data')) {
|
47 |
+
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
48 |
+
}
|
49 |
+
|
50 |
+
$data = get_plugin_data(BLOCKSY__FILE__);
|
51 |
+
|
52 |
+
if (is_admin()) {
|
53 |
+
return;
|
54 |
+
}
|
55 |
+
|
56 |
+
wp_enqueue_style(
|
57 |
+
'blocksy-ext-cookies-consent-styles',
|
58 |
+
BLOCKSY_URL . 'framework/extensions/cookies-consent/static/bundle/main.css',
|
59 |
+
['ct-main-styles'],
|
60 |
+
$data['Version']
|
61 |
+
);
|
62 |
+
|
63 |
+
wp_enqueue_script(
|
64 |
+
'blocksy-ext-cookies-consent-scripts',
|
65 |
+
BLOCKSY_URL . 'framework/extensions/cookies-consent/static/bundle/main.js',
|
66 |
+
['ct-events'],
|
67 |
+
$data['Version'],
|
68 |
+
true
|
69 |
+
);
|
70 |
+
});
|
71 |
+
|
72 |
+
add_action('blocksy:global-dynamic-css:enqueue', function ($args) {
|
73 |
+
blocksy_theme_get_dynamic_styles(array_merge([
|
74 |
+
'path' => dirname( __FILE__ ) . '/global.php',
|
75 |
+
'chunk' => 'global'
|
76 |
+
], $args));
|
77 |
+
}, 10, 3);
|
78 |
+
}
|
79 |
+
|
80 |
+
public function add_options_panel($options) {
|
81 |
+
$options['cookie_consent_ext'] = blc_call_fn(
|
82 |
+
[
|
83 |
+
'fn' => 'blocksy_get_options',
|
84 |
+
'default' => 'array'
|
85 |
+
],
|
86 |
+
dirname(__FILE__) . '/customizer.php',
|
87 |
+
[], false
|
88 |
+
);
|
89 |
+
|
90 |
+
return $options;
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
trunk/framework/extensions/cookies-consent/global.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Content color
|
4 |
+
blc_call_fn(['fn' => 'blocksy_output_colors'], [
|
5 |
+
'value' => get_theme_mod('cookieContentColor'),
|
6 |
+
'default' => [
|
7 |
+
'default' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
|
8 |
+
'hover' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
|
9 |
+
],
|
10 |
+
'css' => $css,
|
11 |
+
'variables' => [
|
12 |
+
'default' => [
|
13 |
+
'selector' => '.cookie-notification',
|
14 |
+
'variable' => 'color'
|
15 |
+
],
|
16 |
+
|
17 |
+
'hover' => [
|
18 |
+
'selector' => '.cookie-notification',
|
19 |
+
'variable' => 'colorHover'
|
20 |
+
],
|
21 |
+
],
|
22 |
+
]);
|
23 |
+
|
24 |
+
// Button color
|
25 |
+
blc_call_fn(['fn' => 'blocksy_output_colors'], [
|
26 |
+
'value' => get_theme_mod('cookieButtonBackground'),
|
27 |
+
'default' => [
|
28 |
+
'default' => [ 'color' => 'var(--paletteColor1)' ],
|
29 |
+
'hover' => [ 'color' => 'var(--paletteColor2)' ],
|
30 |
+
],
|
31 |
+
'css' => $css,
|
32 |
+
'variables' => [
|
33 |
+
'default' => [
|
34 |
+
'selector' => '.cookie-notification',
|
35 |
+
'variable' => 'buttonInitialColor'
|
36 |
+
],
|
37 |
+
|
38 |
+
'hover' => [
|
39 |
+
'selector' => '.cookie-notification',
|
40 |
+
'variable' => 'buttonHoverColor'
|
41 |
+
]
|
42 |
+
],
|
43 |
+
]);
|
44 |
+
|
45 |
+
|
46 |
+
// Background color
|
47 |
+
blc_call_fn(['fn' => 'blocksy_output_colors'], [
|
48 |
+
'value' => get_theme_mod('cookieBackground'),
|
49 |
+
'default' => [
|
50 |
+
'default' => [ 'color' => '#ffffff' ],
|
51 |
+
],
|
52 |
+
'css' => $css,
|
53 |
+
'variables' => [
|
54 |
+
'default' => [
|
55 |
+
'selector' => '.cookie-notification',
|
56 |
+
'variable' => 'backgroundColor'
|
57 |
+
],
|
58 |
+
],
|
59 |
+
]);
|
60 |
+
|
61 |
+
$cookieMaxWidth = get_theme_mod( 'cookieMaxWidth', 400 );
|
62 |
+
$css->put(
|
63 |
+
'.cookie-notification',
|
64 |
+
'--maxWidth: ' . $cookieMaxWidth . 'px'
|
65 |
+
);
|
66 |
+
|
trunk/framework/extensions/cookies-consent/helpers.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function blc_ext_cookies_consent_cache() {
|
4 |
+
if (! is_customize_preview()) return;
|
5 |
+
|
6 |
+
blocksy_add_customizer_preview_cache(
|
7 |
+
blocksy_html_tag(
|
8 |
+
'div',
|
9 |
+
[ 'data-id' => 'blocksy-cookies-consent-section' ],
|
10 |
+
blocksy_ext_cookies_consent_output(true)
|
11 |
+
)
|
12 |
+
);
|
13 |
+
}
|
14 |
+
|
15 |
+
function blocksy_ext_cookies_consent_output($forced = false) {
|
16 |
+
if (! $forced) {
|
17 |
+
blc_ext_cookies_consent_cache();
|
18 |
+
}
|
19 |
+
|
20 |
+
/*
|
21 |
+
if (! BlocksyExtensionCookiesConsent::should_display_notification()) {
|
22 |
+
if (! $forced) {
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
}
|
26 |
+
*/
|
27 |
+
|
28 |
+
$content = get_theme_mod(
|
29 |
+
'cookie_consent_content',
|
30 |
+
__('We use cookies to ensure that we give you the best experience on our website.', 'blc')
|
31 |
+
);
|
32 |
+
|
33 |
+
$button_text = get_theme_mod('cookie_consent_button_text', __('Accept', 'blc'));
|
34 |
+
$period = get_theme_mod('cookie_consent_period', 'forever');
|
35 |
+
$type = get_theme_mod('cookie_consent_type', 'type-1');
|
36 |
+
|
37 |
+
$class = 'container';
|
38 |
+
|
39 |
+
if ( $type === 'type-2' ) {
|
40 |
+
$class = 'ct-container';
|
41 |
+
}
|
42 |
+
|
43 |
+
ob_start();
|
44 |
+
|
45 |
+
?>
|
46 |
+
|
47 |
+
|
48 |
+
<div class="cookie-notification ct-fade-in-start" data-period="<?php echo esc_attr($period) ?>" data-type="<?php echo esc_attr($type) ?>">
|
49 |
+
|
50 |
+
<div class="<?php echo esc_attr($class) ?>">
|
51 |
+
<?php if (!empty($content)) { ?>
|
52 |
+
<div class="ct-cookies-content"><?php echo wp_kses_post($content) ?></div>
|
53 |
+
<?php } ?>
|
54 |
+
|
55 |
+
<button type="submit" class="ct-button ct-accept"><?php echo esc_html($button_text) ?></button>
|
56 |
+
|
57 |
+
<?php if ($type === 'type-1' || is_customize_preview()) { ?>
|
58 |
+
<button class="ct-close">×</button>
|
59 |
+
<?php } ?>
|
60 |
+
|
61 |
+
</div>
|
62 |
+
</div>
|
63 |
+
<?php
|
64 |
+
|
65 |
+
return ob_get_clean();
|
66 |
+
}
|
67 |
+
|
68 |
+
function blocksy_ext_cookies_checkbox($prefix = '') {
|
69 |
+
ob_start();
|
70 |
+
|
71 |
+
if (! empty($prefix)) {
|
72 |
+
$prefix = '_' . $prefix;
|
73 |
+
}
|
74 |
+
|
75 |
+
$message = get_theme_mod(
|
76 |
+
'forms_cookie_consent_content',
|
77 |
+
sprintf(
|
78 |
+
__('I accept the %sPrivacy Policy%s', 'blc'),
|
79 |
+
'<a href="/privacy-policy">',
|
80 |
+
'</a>'
|
81 |
+
)
|
82 |
+
);
|
83 |
+
|
84 |
+
?>
|
85 |
+
|
86 |
+
<p class="gdpr-confirm-policy">
|
87 |
+
<input id="gdprconfirm<?php echo $prefix ?>" name="gdprconfirm" type="checkbox" required /><label for="gdprconfirm<?php echo $prefix ?>"><?php echo $message ?></label>
|
88 |
+
</p>
|
89 |
+
|
90 |
+
<?php
|
91 |
+
|
92 |
+
return ob_get_clean();
|
93 |
+
}
|
trunk/framework/extensions/cookies-consent/readme.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<h2><?php echo __('Instructions', 'blc'); ?></h2>
|
2 |
+
|
3 |
+
<p>
|
4 |
+
<?php echo __('After installing and activating the Cookies Consent extension you will be able to configure it from this location:', 'blc') ?>
|
5 |
+
</p>
|
6 |
+
|
7 |
+
<ul class="ct-modal-list">
|
8 |
+
<li>
|
9 |
+
<h4><?php echo __('Customizer', 'blc') ?></h4>
|
10 |
+
<i>
|
11 |
+
<?php
|
12 |
+
echo sprintf(
|
13 |
+
__('Navigate to %s and customize the notification to meet your needs.', 'blc'),
|
14 |
+
sprintf(
|
15 |
+
'<code>%s</code>',
|
16 |
+
__('Customizer ➝ Cookie Consent', 'blc')
|
17 |
+
)
|
18 |
+
);
|
19 |
+
?>
|
20 |
+
</i>
|
21 |
+
</li>
|
22 |
+
</ul>
|
23 |
+
|
24 |
+
<div class="extension-notice">
|
25 |
+
<h4><?php echo __('Known problems with caching plugins', 'blc'); ?></h4>
|
26 |
+
|
27 |
+
<p>
|
28 |
+
<?php
|
29 |
+
echo sprintf(
|
30 |
+
__('Please read %s to find out more information.', 'blc'),
|
31 |
+
sprintf(
|
32 |
+
'<a href="https://creativethemes.com/blocksy/docs/extensions/cookies-consent/#cache/">%s</a>',
|
33 |
+
__('this article', 'blc')
|
34 |
+
)
|
35 |
+
);
|
36 |
+
?>
|
37 |
+
</p>
|
38 |
+
</div>
|
trunk/framework/extensions/cookies-consent/static/bundle/main.css
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* - v1.7.62
|
3 |
+
*
|
4 |
+
* Copyright (c) 2021
|
5 |
+
* Licensed GPLv2+
|
6 |
+
*/
|
7 |
+
|
8 |
+
.cookie-notification{position:fixed;left:0;bottom:0;z-index:999999;color:var(--color)}.cookie-notification a:hover{color:var(--colorHover)}@media (max-width: 479.98px){.cookie-notification>div{flex-direction:column}}@media (max-width: 689.98px){.cookie-notification{right:0}.cookie-notification>div{display:flex;align-items:center;padding-top:15px;padding-bottom:15px}}@media (max-width: 689.98px){.cookie-notification[data-type='type-1']{background:var(--backgroundColor)}}@media (min-width: 690px){.cookie-notification[data-type='type-1']{padding:0 25px 25px 25px}.cookie-notification[data-type='type-1'] .ct-cookies-content{margin-bottom:15px;max-width:90%}}.cookie-notification[data-type='type-1'] .container{position:relative}@media (max-width: 689.98px){.cookie-notification[data-type='type-1'] .container{width:88%;margin:0 auto}}@media (min-width: 690px){.cookie-notification[data-type='type-1'] .container{background:var(--backgroundColor);box-shadow:0px 5px 30px -5px rgba(34,56,101,0.15);padding:25px 40px 25px 25px;border-radius:3px;max-width:var(--maxWidth)}}.cookie-notification[data-type='type-2']{right:0;background:var(--backgroundColor)}@media (min-width: 690px){.cookie-notification[data-type='type-2']{padding:15px 0}.cookie-notification[data-type='type-2'] .ct-container{display:flex;align-items:center;justify-content:center}.cookie-notification[data-type='type-2'] .ct-accept{margin-left:25px}}.cookie-notification[data-type='type-2'] .ct-close{display:none}.cookie-notification .ct-cookies-content{line-height:1.4}.cookie-notification .ct-cookies-content>*:last-child{margin-bottom:0}.cookie-notification .ct-cookies-content a{text-decoration:underline;color:var(--colorHover)}@media (max-width: 479.98px){.cookie-notification .ct-cookies-content{text-align:center;margin-bottom:15px}}@media (max-width: 689.98px){.cookie-notification .ct-cookies-content{font-size:13px}}@media (min-width: 690px){.cookie-notification .ct-cookies-content{font-size:14px}}.cookie-notification .ct-accept{--buttonFontSize: 13px;--buttonMinHeight: 35px;--padding: 0 20px;--buttonShadow: none;--buttonTransform: none}@media (max-width: 479.98px){.cookie-notification .ct-accept{width:100%}}@media (min-width: 480px) and (max-width: 689.98px){.cookie-notification .ct-accept{margin-left:20px}}.cookie-notification .ct-close{display:flex;align-items:center;justify-content:center;width:45px;height:45px;position:absolute;top:0;right:0;opacity:0.5;color:inherit;cursor:pointer;background:transparent}.cookie-notification .ct-close:hover{opacity:1}@media (max-width: 689.98px){.cookie-notification .ct-close{display:none}}.cookie-notification.ct-fade-in-start,.cookie-notification.ct-fade-in-end,.cookie-notification.ct-fade-start,.cookie-notification.ct-fade-end{transition:all 0.3s ease}.cookie-notification.ct-fade-in-start{opacity:0;transform:translate3d(0, 15px, 0)}.cookie-notification.ct-fade-end{opacity:0;transform:translate3d(0, 15px, 0)}
|
trunk/framework/extensions/cookies-consent/static/bundle/main.js
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t,n){var r,o;
|
2 |
+
/*!
|
3 |
+
* JavaScript Cookie v2.2.1
|
4 |
+
* https://github.com/js-cookie/js-cookie
|
5 |
+
*
|
6 |
+
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
7 |
+
* Released under the MIT license
|
8 |
+
*/!function(i){if(void 0===(o="function"==typeof(r=i)?r.call(t,n,t,e):r)||(e.exports=o),!0,e.exports=i(),!!0){var c=window.Cookies,a=window.Cookies=i();a.noConflict=function(){return window.Cookies=c,a}}}((function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function n(r){function o(){}function i(t,n,i){if("undefined"!=typeof document){"number"==typeof(i=e({path:"/"},o.defaults,i)).expires&&(i.expires=new Date(1*new Date+864e5*i.expires)),i.expires=i.expires?i.expires.toUTCString():"";try{var c=JSON.stringify(n);/^[\{\[]/.test(c)&&(n=c)}catch(e){}n=r.write?r.write(n,t):encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var a="";for(var u in i)i[u]&&(a+="; "+u,!0!==i[u]&&(a+="="+i[u].split(";")[0]));return document.cookie=t+"="+n+a}}function c(e,n){if("undefined"!=typeof document){for(var o={},i=document.cookie?document.cookie.split("; "):[],c=0;c<i.length;c++){var a=i[c].split("="),u=a.slice(1).join("=");n||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var f=t(a[0]);if(u=(r.read||r)(u,f)||t(u),n)try{u=JSON.parse(u)}catch(e){}if(o[f]=u,e===f)break}catch(e){}}return e?o[e]:o}}return o.set=i,o.get=function(e){return c(e,!1)},o.getJSON=function(e){return c(e,!0)},o.remove=function(t,n){i(t,"",e(n,{expires:-1}))},o.defaults={},o.withConverter=n,o}((function(){}))}))},function(e,t){e.exports=window.ctEvents},function(e,t){e.exports=window.ctFrontend},function(e,t,n){"use strict";n.r(t);var r=n(1),o=n.n(r),i=n(0),c=n.n(i),a=n(2);function u(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var s=function(){var e=document.querySelector(".cookie-notification");e&&(c.a.get("blocksy_cookies_consent_accepted")?e.remove():(requestAnimationFrame((function(){e.classList.remove("ct-fade-in-start"),e.classList.add("ct-fade-in-end"),d(e,(function(){e.classList.remove("ct-fade-in-end")}))})),u(e.querySelectorAll("button")).map((function(t){t.addEventListener("click",(function(n){if(n.preventDefault(),t.classList.contains("ct-accept")){c.a.set("blocksy_cookies_consent_accepted","true",{expires:new Date(1*new Date+{onehour:36e5,oneday:864e5,oneweek:6048e5,onemonth:26784e5,threemonths:80352e5,sixmonths:160704e5,oneyear:31536e6,forever:864e9}[t.closest("[data-period]").dataset.period])})}e.classList.add("ct-fade-start"),requestAnimationFrame((function(){e.classList.remove("ct-fade-start"),e.classList.add("ct-fade-end"),d(e,(function(){e.parentNode.removeChild(e)}))}))}))}))))};function d(e,t){setTimeout((function(){t()}),300)}Object(a.onDocumentLoaded)((function(){s(),o.a.on("blocksy:cookies:init",(function(){s()}))}))}]);
|
trunk/framework/extensions/cookies-consent/static/bundle/sync.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){e.exports=window.ctEvents},function(e,t,n){"use strict";n.r(t);var r,o=function(e){if([e.top,e.right,e.bottom,e.left].reduce((function(e,t){return!!e&&!("auto"!==t&&t&&t.toString().match(/\d/g))}),!0))return"CT_CSS_SKIP_RULE";var t=["auto"!==e.top&&e.top.toString().match(/\d/g)?e.top:0,"auto"!==e.right&&e.right.toString().match(/\d/g)?e.right:0,"auto"!==e.bottom&&e.bottom.toString().match(/\d/g)?e.bottom:0,"auto"!==e.left&&e.left.toString().match(/\d/g)?e.left:0];return t[0]===t[1]&&t[0]===t[2]&&t[0]===t[3]?t[0]:t[0]===t[2]&&t[1]===t[3]?"".concat(t[0]," ").concat(t[3]):t.join(" ")},c=function(e,t){var n=t.forcedOutput,r=void 0!==n&&n;if("CT_CSS_SKIP_RULE"===e)return"CT_CSS_SKIP_RULE";if("none"===e)return"none";if(!e.enable)return r?"none":"CT_CSS_SKIP_RULE";if(0===parseFloat(e.blur)&&0===parseFloat(e.spread)&&0===parseFloat(e.v_offset)&&0===parseFloat(e.h_offset))return r?"none":"CT_CSS_SKIP_RULE";var o=[];return e.inset&&o.push("inset"),o.push("".concat(e.h_offset,"px")),o.push("".concat(e.v_offset,"px")),0!==parseFloat(e.blur)&&(o.push("".concat(e.blur,"px")),0!==parseFloat(e.spread)&&o.push("".concat(e.spread,"px"))),0===parseFloat(e.blur)&&0!==parseFloat(e.spread)&&(o.push("".concat(e.blur,"px")),o.push("".concat(e.spread,"px"))),o.push(e.color.color),o.join(" ")},i=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"desktop",r={desktop:"ct-main-styles-inline-css",tablet:"ct-main-styles-tablet-inline-css",mobile:"ct-main-styles-mobile-inline-css"},o=document.querySelector("style#".concat(r[n])),c=o.innerText,i="".concat(e["".concat(n,"_selector_prefix")]?"".concat(e["".concat(n,"_selector_prefix")]," "):"").concat(e.selector||":root"),a=null,l=c.match(a);0===c.trim().indexOf(i)?(a=new RegExp("".concat(i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"\\s?{[\\s\\S]*?}"),"gm"),l=c.match(a)):(a=new RegExp("\\}\\s*?".concat(i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"\\s?{[\\s\\S]*?}"),"gm"),l=c.match(a)),l||(0===(c="".concat(c," ").concat(i," { }")).trim().indexOf(i)?(a=new RegExp("".concat(i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"\\s?{[\\s\\S]*?}"),"gm"),l=c.match(a)):(a=new RegExp("\\}\\s*?".concat(i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"\\s?{[\\s\\S]*?}"),"gm"),l=c.match(a))),o.innerText=c.replace(a,l[0].indexOf("--".concat(e.variable,":"))>-1?l[0].replace(new RegExp("--".concat(e.variable,":[\\s\\S]*?;"),"gm"),t.indexOf("CT_CSS_SKIP_RULE")>-1||t.indexOf(e.variable)>-1?"":"--".concat(e.variable,": ").concat(t,";")):l[0].replace(new RegExp("".concat(i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"\\s?{"),"gm"),"".concat(i," {").concat(t.indexOf("CT_CSS_SKIP_RULE")>-1||t.indexOf(e.variable)>-1?"":"--".concat(e.variable,": ").concat(t,";"))))},a=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"desktop",r=(e.type||"").indexOf("color")>-1?t["color"===e.type?"default":e.type.split(":")[1]].color:t;"border"===(e.type||"")&&(r=t&&"none"!==t.style?"".concat(t.width,"px ").concat(t.style," ").concat(t.color.color):"none"),"spacing"===(e.type||"")&&(r=o(t)),"box-shadow"===(e.type||"")&&(r=c(t,e)),i(e,"".concat(r).concat(e.unit||"").concat(e.important?" !important":""),n)},l=function(e,t){var n=t;t=e.extractValue?e.extractValue(t):t,e.whenDone&&e.whenDone(t,n),t=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e&&Object.keys(e).indexOf("desktop")>-1?t?e:e.desktop:t?{desktop:e,tablet:e,mobile:e}:e}(t,!!e.responsive),e.responsive?(e.enabled&&"no"===!wp.customize(e.enabled)()&&(t.mobile="0"+(e.unit?"":"px"),t.tablet="0"+(e.unit?"":"px"),t.desktop="0"+(e.unit?"":"px")),a(e,t.desktop,"desktop"),a(e,t.tablet,"tablet"),a(e,t.mobile,"mobile")):a(e,t)};r={cookieContentColor:[{selector:".cookie-notification",variable:"color",type:"color:default"},{selector:".cookie-notification",variable:"colorHover",type:"color:hover"}],cookieBackground:{selector:".cookie-notification",variable:"backgroundColor",type:"color"},cookieButtonBackground:[{selector:".cookie-notification",variable:"buttonInitialColor",type:"color:default"},{selector:".cookie-notification",variable:"buttonHoverColor",type:"color:hover"}],cookieMaxWidth:{selector:".cookie-notification",variable:"maxWidth",unit:"px"}},wp.customize.bind("change",(function(e){return r[e.id]&&(Array.isArray(r[e.id])?r[e.id]:[r[e.id]]).map((function(t){return l(t,e())}))}));var u=n(0),s=n.n(u);function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,c=void 0;try{for(var i,a=e[Symbol.iterator]();!(r=(i=a.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,c=e}finally{try{r||null==a.return||a.return()}finally{if(o)throw c}}return n}(e,t)||d(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||d(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){if(e){if("string"==typeof e)return m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m(e,t):void 0}}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?b(Object(n),!0).forEach((function(t){v(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=function(){var e=document.createElement("div");return e.innerHTML=document.querySelector(".ct-customizer-preview-cache-container").value,e},g=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"id";if(t||(t=h()),t.querySelector(".ct-customizer-preview-cache [data-".concat(n,'="').concat(e,'"]'))){var r=t.querySelector(".ct-customizer-preview-cache [data-".concat(n,'="').concat(e,'"]')).innerHTML,o=document.createElement("div");return o.innerHTML=r,o}},S=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=y({fragment_id:null,selector:null,parent_selector:null,strategy:"append",whenInserted:function(){},beforeInsert:function(e){},should_insert:!0},e);var t=document.querySelector(e.parent_selector);if(p(document.querySelectorAll("".concat(e.parent_selector," ").concat(e.selector))).map((function(e){return e.parentNode.removeChild(e)})),e.should_insert){var n=g(e.fragment_id);if(n){for(;n.firstElementChild;)if(e.beforeInsert(n.firstElementChild),"append"===e.strategy&&t.appendChild(n.firstElementChild),"firstChild"===e.strategy&&t.insertBefore(n.firstElementChild,t.firstElementChild),e.strategy.indexOf("maybeBefore")>-1){var r=e.strategy.split(":"),o=f(r,2),c=(o[0],o[1]);t.querySelector(c)?t.insertBefore(n.firstElementChild,t.querySelector(c)):t.appendChild(n.firstElementChild)}e.whenInserted()}}};function _(e){return function(e){if(Array.isArray(e))return x(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return x(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return x(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var O=function(){var e=function(e){if(!document.querySelector(".cookie-notification"))return S({fragment_id:"blocksy-cookies-consent-section",selector:".cookie-notification",parent_selector:"#main-container"}),!0}(),t=document.querySelector(".cookie-notification");if(t){t.querySelector(".ct-cookies-content")&&(t.querySelector(".ct-cookies-content").innerHTML=wp.customize("cookie_consent_content")()),t.querySelector("button.ct-accept").innerHTML=wp.customize("cookie_consent_button_text")();var n=wp.customize("cookie_consent_type")();t.dataset.type=n,t.firstElementChild.classList.remove("ct-container","container"),t.firstElementChild.classList.add("type-1"===n?"container":"ct-container"),e&&setTimeout((function(){return s.a.trigger("blocksy:cookies:init")}))}};wp.customize("cookie_consent_content",(function(e){return e.bind((function(e){O()}))})),wp.customize("cookie_consent_button_text",(function(e){return e.bind((function(e){return O()}))})),wp.customize("cookie_consent_type",(function(e){return e.bind((function(e){return O()}))})),wp.customize("forms_cookie_consent_content",(function(e){return e.bind((function(e){return _(document.querySelectorAll(".gdpr-confirm-policy label")).map((function(t){return t.innerHTML=e}))}))}))}]);
|
trunk/framework/extensions/cookies-consent/static/images/type-1.svg
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!-- Generator: Adobe Illustrator 23.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3 |
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
4 |
+
viewBox="0 0 100 70" style="enable-background:new 0 0 100 70;" xml:space="preserve">
|
5 |
+
<style type="text/css">
|
6 |
+
.st0{fill:#FFFFFF;}
|
7 |
+
.st1{fill:#EDEFF0;}
|
8 |
+
.st2{fill:#565D66;}
|
9 |
+
.st3{fill:#4F5459;}
|
10 |
+
.st4{fill:#6E747A;}
|
11 |
+
</style>
|
12 |
+
<path class="st0" d="M13,73.5c-1.4,0-2.5-1.1-2.5-2.5V13c0-1.4,1.1-2.5,2.5-2.5h74c1.4,0,2.5,1.1,2.5,2.5v58c0,1.4-1.1,2.5-2.5,2.5
|
13 |
+
H13z"/>
|
14 |
+
<path class="st1" d="M11,11h78v14H11V11z"/>
|
15 |
+
<path class="st2" d="M87,11c1.1,0,2,0.9,2,2v58c0,1.1-0.9,2-2,2H13c-1.1,0-2-0.9-2-2V13c0-1.1,0.9-2,2-2H87 M87,10H13
|
16 |
+
c-1.7,0-3,1.3-3,3v58c0,1.7,1.3,3,3,3h74c1.6,0,3-1.3,3-3V13C90,11.3,88.6,10,87,10z"/>
|
17 |
+
<path class="st3" d="M77.5,18.5h-4c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h4c0.3,0,0.5,0.2,0.5,0.5S77.8,18.5,77.5,18.5z
|
18 |
+
M70.5,18.5h-4c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h4c0.3,0,0.5,0.2,0.5,0.5S70.8,18.5,70.5,18.5z M63.5,18.5h-4
|
19 |
+
c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h4c0.3,0,0.5,0.2,0.5,0.5S63.8,18.5,63.5,18.5z M22.4,16.5c0.5-0.9,1.4-1.4,2.4-1.4
|
20 |
+
c0.7,0,1.3,0.3,1.8,0.7c-0.1,0-0.3,0-0.4,0.1c-0.4,0.2-0.5,0.8,0,1.1c0.3,0.2,0.4,0.6,0.4,0.9s-0.7,1.5-0.7,1.5l-0.6-2.2V17
|
21 |
+
c0-0.1,0-0.1,0.1-0.2l0.1-0.1h0.3v-0.2H24v0.2h0.1c0.1,0,0.1,0.1,0.2,0.1c0.1,0.1,0.1,0.3,0.2,0.5l0.2,0.8l-0.5,1.2L23.6,17
|
22 |
+
c0,0,0-0.2,0.1-0.2l0.1-0.1v-0.2C23.8,16.5,22.4,16.5,22.4,16.5z M22.7,16.9c0,0-0.1-0.2-0.3-0.2h-0.1c-0.1,0.3-0.2,0.7-0.2,1.1
|
23 |
+
c0,1.1,0.7,2.1,1.7,2.5L22.7,16.9z M27.2,16.5c0.1,0.2,0,0.5-0.1,0.9c-0.3,0.9-0.9,2.4-1.2,3c1-0.4,1.6-1.4,1.6-2.5
|
24 |
+
C27.6,17.4,27.4,16.9,27.2,16.5 M24.9,18.8l-0.7,1.7c0.2,0,0.4,0.1,0.6,0.1s0.5,0,0.7-0.1L24.9,18.8z"/>
|
25 |
+
<g>
|
26 |
+
<path class="st4" d="M48.2,65.9H16.6c-0.5,0-1-0.5-1-1V45.7c0-0.6,0.5-1,1-1h31.6c0.5,0,1,0.4,1,1v19.1
|
27 |
+
C49.2,65.4,48.8,65.9,48.2,65.9z"/>
|
28 |
+
<path class="st0" d="M35.9,53.3h-17c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h17c0.3,0,0.5,0.2,0.5,0.5S36.2,53.3,35.9,53.3z"/>
|
29 |
+
<path class="st0" d="M24.7,56.3h-5.8c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h5.8c0.3,0,0.5,0.2,0.5,0.5S25,56.3,24.7,56.3z"/>
|
30 |
+
<path class="st0" d="M35.9,56.3h-9.2c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h9.2c0.3,0,0.5,0.2,0.5,0.5S36.2,56.3,35.9,56.3z"/>
|
31 |
+
<path class="st0" d="M27.8,63.2h-7.3c-1.1,0-2.1-0.9-2.1-2.1l0,0c0-1.1,0.9-2.1,2.1-2.1h7.3c1.1,0,2.1,0.9,2.1,2.1l0,0
|
32 |
+
C29.9,62.3,28.9,63.2,27.8,63.2z"/>
|
33 |
+
<path class="st0" d="M43.7,53.3h-5.8c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h5.8c0.3,0,0.5,0.2,0.5,0.5S44,53.3,43.7,53.3z"/>
|
34 |
+
<path class="st0" d="M38.7,49.9H19.4c-0.6,0-1-0.5-1-1l0,0c0-0.6,0.5-1,1-1h19.2c0.6,0,1,0.5,1,1l0,0
|
35 |
+
C39.7,49.4,39.2,49.9,38.7,49.9z"/>
|
36 |
+
</g>
|
37 |
+
</svg>
|
trunk/framework/extensions/cookies-consent/static/images/type-2.svg
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!-- Generator: Adobe Illustrator 23.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3 |
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
4 |
+
viewBox="0 0 100 70" style="enable-background:new 0 0 100 70;" xml:space="preserve">
|
5 |
+
<style type="text/css">
|
6 |
+
.st0{fill:#FFFFFF;}
|
7 |
+
.st1{fill:#6E747A;}
|
8 |
+
.st2{fill:#EDEFF0;}
|
9 |
+
.st3{fill:#565D66;}
|
10 |
+
.st4{fill:#4F5459;}
|
11 |
+
</style>
|
12 |
+
<path class="st0" d="M13,73.5c-1.4,0-2.5-1.1-2.5-2.5V13c0-1.4,1.1-2.5,2.5-2.5h74c1.4,0,2.5,1.1,2.5,2.5v58c0,1.4-1.1,2.5-2.5,2.5
|
13 |
+
H13z"/>
|
14 |
+
<g>
|
15 |
+
<rect x="10.4" y="57.2" class="st1" width="79.1" height="13"/>
|
16 |
+
<path class="st0" d="M32.3,66.5h-17c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h17c0.3,0,0.5,0.2,0.5,0.5S32.6,66.5,32.3,66.5z"/>
|
17 |
+
<path class="st0" d="M43.9,66.5h-9.2c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h9.2c0.3,0,0.5,0.2,0.5,0.5S44.2,66.5,43.9,66.5z"/>
|
18 |
+
<path class="st0" d="M84.2,66.1h-7.3c-1.1,0-2.1-0.9-2.1-2.1l0,0c0-1.1,0.9-2.1,2.1-2.1h7.3c1.1,0,2.1,0.9,2.1,2.1l0,0
|
19 |
+
C86.3,65.2,85.4,66.1,84.2,66.1z"/>
|
20 |
+
<path class="st0" d="M51.9,66.5h-5.8c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h5.8c0.3,0,0.5,0.2,0.5,0.5S52.2,66.5,51.9,66.5z"/>
|
21 |
+
<path class="st0" d="M35.1,63H15.9c-0.6,0-1-0.5-1-1l0,0c0-0.6,0.5-1,1-1h19.2c0.6,0,1,0.5,1,1l0,0C36.1,62.6,35.7,63,35.1,63z"/>
|
22 |
+
</g>
|
23 |
+
<path class="st2" d="M11,11h78v14H11V11z"/>
|
24 |
+
<path class="st3" d="M87,11c1.1,0,2,0.9,2,2v58c0,1.1-0.9,2-2,2H13c-1.1,0-2-0.9-2-2V13c0-1.1,0.9-2,2-2H87 M87,10H13
|
25 |
+
c-1.7,0-3,1.3-3,3v58c0,1.7,1.3,3,3,3h74c1.6,0,3-1.3,3-3V13C90,11.3,88.6,10,87,10z"/>
|
26 |
+
<path class="st4" d="M77.5,18.5h-4c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h4c0.3,0,0.5,0.2,0.5,0.5S77.8,18.5,77.5,18.5z
|
27 |
+
M70.5,18.5h-4c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h4c0.3,0,0.5,0.2,0.5,0.5S70.8,18.5,70.5,18.5z M63.5,18.5h-4
|
28 |
+
c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h4c0.3,0,0.5,0.2,0.5,0.5S63.8,18.5,63.5,18.5z M22.4,16.5c0.5-0.9,1.4-1.4,2.4-1.4
|
29 |
+
c0.7,0,1.3,0.3,1.8,0.7c-0.1,0-0.3,0-0.4,0.1c-0.4,0.2-0.5,0.8,0,1.1c0.3,0.2,0.4,0.6,0.4,0.9s-0.7,1.5-0.7,1.5l-0.6-2.2V17
|
30 |
+
c0-0.1,0-0.1,0.1-0.2l0.1-0.1h0.3v-0.2H24v0.2h0.1c0.1,0,0.1,0.1,0.2,0.1c0.1,0.1,0.1,0.3,0.2,0.5l0.2,0.8l-0.5,1.2L23.6,17
|
31 |
+
c0,0,0-0.2,0.1-0.2l0.1-0.1v-0.2C23.8,16.5,22.4,16.5,22.4,16.5z M22.7,16.9c0,0-0.1-0.2-0.3-0.2h-0.1c-0.1,0.3-0.2,0.7-0.2,1.1
|
32 |
+
c0,1.1,0.7,2.1,1.7,2.5L22.7,16.9z M27.2,16.5c0.1,0.2,0,0.5-0.1,0.9c-0.3,0.9-0.9,2.4-1.2,3c1-0.4,1.6-1.4,1.6-2.5
|
33 |
+
C27.6,17.4,27.4,16.9,27.2,16.5 M24.9,18.8l-0.7,1.7c0.2,0,0.4,0.1,0.6,0.1s0.5,0,0.7-0.1L24.9,18.8z"/>
|
34 |
+
</svg>
|
trunk/framework/extensions/cookies-consent/static/js/ct-events.js
ADDED
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Listen and trigger custom events to communicate between javascript components
|
3 |
+
*/
|
4 |
+
window.ctEvents =
|
5 |
+
window.ctEvents ||
|
6 |
+
new (function () {
|
7 |
+
var _events = {}
|
8 |
+
var currentIndentation = 1
|
9 |
+
var debug = false
|
10 |
+
|
11 |
+
this.countAll = function (topic) {
|
12 |
+
return _events[topic]
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Make log helper public
|
17 |
+
*
|
18 |
+
* @param {String} [message]
|
19 |
+
* @param {Object} [data]
|
20 |
+
*/
|
21 |
+
this.log = log
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Enable/Disable Debug
|
25 |
+
* @param {Boolean} enabled
|
26 |
+
*/
|
27 |
+
this.debug = function (enabled) {
|
28 |
+
debug = Boolean(enabled)
|
29 |
+
|
30 |
+
return this
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Add event listener
|
35 |
+
*
|
36 |
+
* @param event {String | Object}
|
37 |
+
* Can be a:
|
38 |
+
* - single event: 'event1'
|
39 |
+
* - space separated event list: 'event1 event2 event2'
|
40 |
+
* - an object: {event1: function () {}, event2: function () {}}
|
41 |
+
*
|
42 |
+
* @param callback {Function}
|
43 |
+
*/
|
44 |
+
this.on = function (topicStringOrObject, listener) {
|
45 |
+
objectMap(
|
46 |
+
splitTopicStringOrObject(topicStringOrObject, listener),
|
47 |
+
function (eventName, listener) {
|
48 |
+
;(_events[eventName] || (_events[eventName] = [])).push(
|
49 |
+
listener
|
50 |
+
)
|
51 |
+
|
52 |
+
debug && log('✚ ' + eventName)
|
53 |
+
}
|
54 |
+
)
|
55 |
+
|
56 |
+
return this
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Same as .on(), but callback will executed only once
|
61 |
+
*/
|
62 |
+
this.one = function (topicStringOrObject, listener) {
|
63 |
+
objectMap(
|
64 |
+
splitTopicStringOrObject(topicStringOrObject, listener),
|
65 |
+
function (eventName, listener) {
|
66 |
+
;(_events[eventName] || (_events[eventName] = [])).push(
|
67 |
+
once(listener)
|
68 |
+
)
|
69 |
+
|
70 |
+
debug && log('✚ [' + eventName + ']')
|
71 |
+
}
|
72 |
+
)
|
73 |
+
|
74 |
+
return this
|
75 |
+
|
76 |
+
// https://github.com/jashkenas/underscore/blob/8fc7032295d60aff3620ef85d4aa6549a55688a0/underscore.js#L946
|
77 |
+
function once(func) {
|
78 |
+
var memo
|
79 |
+
|
80 |
+
var times = 2
|
81 |
+
|
82 |
+
return function () {
|
83 |
+
if (--times > 0) {
|
84 |
+
memo = func.apply(this, arguments)
|
85 |
+
}
|
86 |
+
|
87 |
+
if (times <= 1) func = null
|
88 |
+
|
89 |
+
return memo
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* In order to remove one single listener you should give as an argument
|
96 |
+
* the same callback function. If you want to remove *all* listeners from
|
97 |
+
* a particular event you should not pass the second argument.
|
98 |
+
*
|
99 |
+
* @param topicStringOrObject {String | Object}
|
100 |
+
* @param listener {Function | false}
|
101 |
+
*/
|
102 |
+
this.off = function (topicStringOrObject, listener) {
|
103 |
+
objectMap(
|
104 |
+
splitTopicStringOrObject(topicStringOrObject, listener),
|
105 |
+
function (eventName, listener) {
|
106 |
+
if (_events[eventName]) {
|
107 |
+
if (listener) {
|
108 |
+
_events[eventName].splice(
|
109 |
+
_events[eventName].indexOf(listener) >>> 0,
|
110 |
+
1
|
111 |
+
)
|
112 |
+
} else {
|
113 |
+
_events[eventName] = []
|
114 |
+
}
|
115 |
+
|
116 |
+
debug && log('✖ ' + eventName)
|
117 |
+
}
|
118 |
+
}
|
119 |
+
)
|
120 |
+
|
121 |
+
return this
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Trigger an event. In case you provide multiple events via space-separated
|
126 |
+
* string or an object of events it will execute listeners for each event
|
127 |
+
* separatedly. You can use the "all" event to trigger all events.
|
128 |
+
*
|
129 |
+
* @param topicStringOrObject {String | Object}
|
130 |
+
* @param data {Object}
|
131 |
+
*/
|
132 |
+
this.trigger = function (eventName, data) {
|
133 |
+
objectMap(splitTopicStringOrObject(eventName), function (
|
134 |
+
eventName
|
135 |
+
) {
|
136 |
+
log('╭─ ' + eventName, data)
|
137 |
+
|
138 |
+
changeIndentation(+1)
|
139 |
+
|
140 |
+
try {
|
141 |
+
// TODO: REFACTOR THAT!!!!!!!!!
|
142 |
+
// Maybe this is an occasion for using 'all' event???
|
143 |
+
if (eventName === 'fw:options:init') {
|
144 |
+
fw.options.startListeningToEvents(
|
145 |
+
data.$elements || document.body
|
146 |
+
)
|
147 |
+
}
|
148 |
+
|
149 |
+
;(_events[eventName] || []).map(dispatchSingleEvent)
|
150 |
+
;(_events['all'] || []).map(dispatchSingleEvent)
|
151 |
+
} catch (e) {
|
152 |
+
console.log(
|
153 |
+
'%c [Events] Exception raised.',
|
154 |
+
'color: red; font-weight: bold;'
|
155 |
+
)
|
156 |
+
|
157 |
+
if (typeof console !== 'undefined') {
|
158 |
+
console.error(e)
|
159 |
+
} else {
|
160 |
+
throw e
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
changeIndentation(-1)
|
165 |
+
|
166 |
+
log('╰─ ' + eventName, data)
|
167 |
+
|
168 |
+
function dispatchSingleEvent(listenerDescriptor) {
|
169 |
+
if (!listenerDescriptor) return
|
170 |
+
|
171 |
+
listenerDescriptor.call(window, data)
|
172 |
+
}
|
173 |
+
})
|
174 |
+
|
175 |
+
return this
|
176 |
+
|
177 |
+
function changeIndentation(increment) {
|
178 |
+
if (typeof increment != 'undefined') {
|
179 |
+
currentIndentation += increment > 0 ? +1 : -1
|
180 |
+
}
|
181 |
+
|
182 |
+
if (currentIndentation < 0) {
|
183 |
+
currentIndentation = 0
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Check if an event has listeners
|
190 |
+
* @param {String} [event]
|
191 |
+
* @return {Boolean}
|
192 |
+
*/
|
193 |
+
this.hasListeners = function (eventName) {
|
194 |
+
if (!_events) {
|
195 |
+
return false
|
196 |
+
}
|
197 |
+
|
198 |
+
return (_events[eventName] || []).length > 0
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Probably split string into general purpose object representation for
|
203 |
+
* event names and listeners. This function leaves objects un-modified.
|
204 |
+
*
|
205 |
+
* @param topicStringOrObject {String | Object}
|
206 |
+
* @param listener {Function | false}
|
207 |
+
*
|
208 |
+
* @returns {Object} {
|
209 |
+
* eventname: listener,
|
210 |
+
* otherevent: listener
|
211 |
+
* }
|
212 |
+
*/
|
213 |
+
function splitTopicStringOrObject(topicStringOrObject, listener) {
|
214 |
+
if (typeof topicStringOrObject !== 'string') {
|
215 |
+
return topicStringOrObject
|
216 |
+
}
|
217 |
+
|
218 |
+
var arrayOfEvents = topicStringOrObject
|
219 |
+
.replace(/\s\s+/g, ' ')
|
220 |
+
.trim()
|
221 |
+
.split(' ')
|
222 |
+
|
223 |
+
var len = arrayOfEvents.length
|
224 |
+
|
225 |
+
var listenerDescriptor = Object.create(null)
|
226 |
+
|
227 |
+
for (var i = 0; i < len; i++) {
|
228 |
+
listenerDescriptor[arrayOfEvents[i]] = listener
|
229 |
+
}
|
230 |
+
|
231 |
+
return listenerDescriptor
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* returns a new object with the predicate applied to each value
|
236 |
+
* objectMap({a: 3, b: 5, c: 9}, (key, value) => value + 1); // {a: 4, b: 6, c: 10}
|
237 |
+
* objectMap({a: 3, b: 5, c: 9}, (key, value) => key); // {a: 'a', b: 'b', c: 'c'}
|
238 |
+
* objectMap({a: 3, b: 5, c: 9}, (key, value) => key + value); // {a: 'a3', b: 'b5', c: 'c9'}
|
239 |
+
*
|
240 |
+
* https://github.com/angus-c/just/tree/master/packages/object-map
|
241 |
+
*/
|
242 |
+
function objectMap(obj, predicate) {
|
243 |
+
var result = {}
|
244 |
+
var keys = Object.keys(obj)
|
245 |
+
var len = keys.length
|
246 |
+
|
247 |
+
for (var i = 0; i < len; i++) {
|
248 |
+
var key = keys[i]
|
249 |
+
result[key] = predicate(key, obj[key])
|
250 |
+
}
|
251 |
+
|
252 |
+
return result
|
253 |
+
}
|
254 |
+
|
255 |
+
function log(message, data) {
|
256 |
+
if (!debug) {
|
257 |
+
return
|
258 |
+
}
|
259 |
+
|
260 |
+
if (typeof data != 'undefined') {
|
261 |
+
console.log('[Event] ' + getIndentation() + message, '─', data)
|
262 |
+
} else {
|
263 |
+
console.log('[Event] ' + getIndentation() + message)
|
264 |
+
}
|
265 |
+
|
266 |
+
function getIndentation() {
|
267 |
+
return new Array(currentIndentation).join('│ ')
|
268 |
+
}
|
269 |
+
}
|
270 |
+
})()
|
trunk/framework/extensions/cookies-consent/static/js/lazy-load-helpers.js
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export const markImagesAsLoaded = el =>
|
2 |
+
[...el.querySelectorAll('.ct-image-container.ct-lazy')].map(el => {
|
3 |
+
if (el.querySelector('img')) {
|
4 |
+
el.querySelector('img').setAttribute(
|
5 |
+
'src',
|
6 |
+
el.querySelector('img').dataset.ctLazy
|
7 |
+
)
|
8 |
+
|
9 |
+
if (el.querySelector('img').dataset.ctLazySet) {
|
10 |
+
el.querySelector('img').setAttribute(
|
11 |
+
'srcset',
|
12 |
+
el.querySelector('img').dataset.ctLazySet
|
13 |
+
)
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
el.classList.remove('ct-lazy')
|
18 |
+
el.classList.add('ct-lazy-loaded')
|
19 |
+
})
|
20 |
+
|
trunk/framework/extensions/cookies-consent/static/js/main.js
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import ctEvents from 'ct-events'
|
2 |
+
import cookie from 'js-cookie'
|
3 |
+
import { onDocumentLoaded } from 'blocksy-frontend'
|
4 |
+
|
5 |
+
const initCookies = () => {
|
6 |
+
const notification = document.querySelector('.cookie-notification')
|
7 |
+
|
8 |
+
if (!notification) return
|
9 |
+
|
10 |
+
if (cookie.get('blocksy_cookies_consent_accepted')) {
|
11 |
+
notification.remove()
|
12 |
+
return
|
13 |
+
}
|
14 |
+
|
15 |
+
requestAnimationFrame(() => {
|
16 |
+
notification.classList.remove('ct-fade-in-start')
|
17 |
+
notification.classList.add('ct-fade-in-end')
|
18 |
+
|
19 |
+
whenTransitionEnds(notification, () => {
|
20 |
+
notification.classList.remove('ct-fade-in-end')
|
21 |
+
})
|
22 |
+
})
|
23 |
+
;[...notification.querySelectorAll('button')].map((el) => {
|
24 |
+
el.addEventListener('click', (e) => {
|
25 |
+
e.preventDefault()
|
26 |
+
|
27 |
+
if (el.classList.contains('ct-accept')) {
|
28 |
+
const periods = {
|
29 |
+
onehour: 36e5,
|
30 |
+
oneday: 864e5,
|
31 |
+
oneweek: 7 * 864e5,
|
32 |
+
onemonth: 31 * 864e5,
|
33 |
+
threemonths: 3 * 31 * 864e5,
|
34 |
+
sixmonths: 6 * 31 * 864e5,
|
35 |
+
oneyear: 365 * 864e5,
|
36 |
+
forever: 10000 * 864e5,
|
37 |
+
}
|
38 |
+
|
39 |
+
cookie.set('blocksy_cookies_consent_accepted', 'true', {
|
40 |
+
expires: new Date(
|
41 |
+
new Date() * 1 +
|
42 |
+
periods[el.closest('[data-period]').dataset.period]
|
43 |
+
),
|
44 |
+
})
|
45 |
+
}
|
46 |
+
|
47 |
+
notification.classList.add('ct-fade-start')
|
48 |
+
|
49 |
+
requestAnimationFrame(() => {
|
50 |
+
notification.classList.remove('ct-fade-start')
|
51 |
+
notification.classList.add('ct-fade-end')
|
52 |
+
|
53 |
+
whenTransitionEnds(notification, () => {
|
54 |
+
notification.parentNode.removeChild(notification)
|
55 |
+
})
|
56 |
+
})
|
57 |
+
})
|
58 |
+
})
|
59 |
+
}
|
60 |
+
|
61 |
+
onDocumentLoaded(() => {
|
62 |
+
initCookies()
|
63 |
+
|
64 |
+
ctEvents.on('blocksy:cookies:init', () => {
|
65 |
+
initCookies()
|
66 |
+
})
|
67 |
+
})
|
68 |
+
|
69 |
+
function whenTransitionEnds(el, cb) {
|
70 |
+
setTimeout(() => {
|
71 |
+
cb()
|
72 |
+
}, 300)
|
73 |
+
return
|
74 |
+
|
75 |
+
const end = () => {
|
76 |
+
el.removeEventListener('transitionend', onEnd)
|
77 |
+
cb()
|
78 |
+
}
|
79 |
+
|
80 |
+
const onEnd = (e) => {
|
81 |
+
if (e.target === el) {
|
82 |
+
end()
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
el.addEventListener('transitionend', onEnd)
|
87 |
+
}
|
trunk/framework/extensions/cookies-consent/static/js/sync.js
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import './variables'
|
2 |
+
import ctEvents from 'ct-events'
|
3 |
+
|
4 |
+
import { renderWithStrategy } from './sync/helpers'
|
5 |
+
|
6 |
+
const maybeAnimateCookiesConsent = cb => {
|
7 |
+
if (document.querySelector('.cookie-notification')) return
|
8 |
+
|
9 |
+
renderWithStrategy({
|
10 |
+
fragment_id: 'blocksy-cookies-consent-section',
|
11 |
+
selector: '.cookie-notification',
|
12 |
+
parent_selector: '#main-container'
|
13 |
+
})
|
14 |
+
|
15 |
+
return true
|
16 |
+
}
|
17 |
+
|
18 |
+
const render = () => {
|
19 |
+
const didInsert = maybeAnimateCookiesConsent()
|
20 |
+
|
21 |
+
const notification = document.querySelector('.cookie-notification')
|
22 |
+
|
23 |
+
if (!notification) {
|
24 |
+
return
|
25 |
+
}
|
26 |
+
|
27 |
+
if (notification.querySelector('.ct-cookies-content')) {
|
28 |
+
notification.querySelector(
|
29 |
+
'.ct-cookies-content'
|
30 |
+
).innerHTML = wp.customize('cookie_consent_content')()
|
31 |
+
}
|
32 |
+
|
33 |
+
notification.querySelector('button.ct-accept').innerHTML = wp.customize(
|
34 |
+
'cookie_consent_button_text'
|
35 |
+
)()
|
36 |
+
|
37 |
+
const type = wp.customize('cookie_consent_type')()
|
38 |
+
|
39 |
+
notification.dataset.type = type
|
40 |
+
|
41 |
+
notification.firstElementChild.classList.remove('ct-container', 'container')
|
42 |
+
notification.firstElementChild.classList.add(
|
43 |
+
type === 'type-1' ? 'container' : 'ct-container'
|
44 |
+
)
|
45 |
+
|
46 |
+
if (didInsert) {
|
47 |
+
setTimeout(() => ctEvents.trigger('blocksy:cookies:init'))
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
wp.customize('cookie_consent_content', val =>
|
52 |
+
val.bind(to => {
|
53 |
+
render()
|
54 |
+
})
|
55 |
+
)
|
56 |
+
wp.customize('cookie_consent_button_text', val => val.bind(to => render()))
|
57 |
+
wp.customize('cookie_consent_type', val => val.bind(to => render()))
|
58 |
+
|
59 |
+
wp.customize('forms_cookie_consent_content', val =>
|
60 |
+
val.bind(to =>
|
61 |
+
[...document.querySelectorAll('.gdpr-confirm-policy label')].map(
|
62 |
+
el => (el.innerHTML = to)
|
63 |
+
)
|
64 |
+
)
|
65 |
+
)
|
trunk/framework/extensions/cookies-consent/static/js/sync/helpers.js
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export const getCache = () => {
|
2 |
+
const div = document.createElement('div')
|
3 |
+
|
4 |
+
div.innerHTML = document.querySelector(
|
5 |
+
'.ct-customizer-preview-cache-container'
|
6 |
+
).value
|
7 |
+
|
8 |
+
return div
|
9 |
+
}
|
10 |
+
|
11 |
+
export const getFreshHtmlFor = (id, cache = null, attr = 'id') => {
|
12 |
+
if (!cache) {
|
13 |
+
cache = getCache()
|
14 |
+
}
|
15 |
+
|
16 |
+
if (
|
17 |
+
!cache.querySelector(
|
18 |
+
`.ct-customizer-preview-cache [data-${attr}="${id}"]`
|
19 |
+
)
|
20 |
+
) {
|
21 |
+
return
|
22 |
+
}
|
23 |
+
|
24 |
+
const newHtml = cache.querySelector(
|
25 |
+
`.ct-customizer-preview-cache [data-${attr}="${id}"]`
|
26 |
+
).innerHTML
|
27 |
+
|
28 |
+
const e = document.createElement('div')
|
29 |
+
e.innerHTML = newHtml
|
30 |
+
|
31 |
+
return e
|
32 |
+
}
|
33 |
+
|
34 |
+
export const renderWithStrategy = (args = {}) => {
|
35 |
+
args = {
|
36 |
+
fragment_id: null,
|
37 |
+
|
38 |
+
selector: null,
|
39 |
+
parent_selector: null,
|
40 |
+
|
41 |
+
// append | firstChild | maybeBefore:selector
|
42 |
+
strategy: 'append',
|
43 |
+
whenInserted: () => {},
|
44 |
+
beforeInsert: el => {},
|
45 |
+
|
46 |
+
should_insert: true,
|
47 |
+
|
48 |
+
...args
|
49 |
+
}
|
50 |
+
|
51 |
+
const parent = document.querySelector(args.parent_selector)
|
52 |
+
;[
|
53 |
+
...document.querySelectorAll(`${args.parent_selector} ${args.selector}`)
|
54 |
+
].map(el => el.parentNode.removeChild(el))
|
55 |
+
|
56 |
+
if (!args.should_insert) return
|
57 |
+
|
58 |
+
const el = getFreshHtmlFor(args.fragment_id)
|
59 |
+
|
60 |
+
if (!el) {
|
61 |
+
return
|
62 |
+
}
|
63 |
+
|
64 |
+
while (el.firstElementChild) {
|
65 |
+
args.beforeInsert(el.firstElementChild)
|
66 |
+
|
67 |
+
if (args.strategy === 'append') {
|
68 |
+
parent.appendChild(el.firstElementChild)
|
69 |
+
}
|
70 |
+
|
71 |
+
if (args.strategy === 'firstChild') {
|
72 |
+
parent.insertBefore(el.firstElementChild, parent.firstElementChild)
|
73 |
+
}
|
74 |
+
|
75 |
+
if (args.strategy.indexOf('maybeBefore') > -1) {
|
76 |
+
const [_, selector] = args.strategy.split(':')
|
77 |
+
|
78 |
+
if (parent.querySelector(selector)) {
|
79 |
+
parent.insertBefore(
|
80 |
+
el.firstElementChild,
|
81 |
+
parent.querySelector(selector)
|
82 |
+
)
|
83 |
+
} else {
|
84 |
+
parent.appendChild(el.firstElementChild)
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
args.whenInserted()
|
90 |
+
}
|
91 |
+
|
92 |
+
export const checkAndReplace = (args = {}) => {
|
93 |
+
args = {
|
94 |
+
id: null,
|
95 |
+
|
96 |
+
fragment_id: null,
|
97 |
+
|
98 |
+
selector: null,
|
99 |
+
parent_selector: null,
|
100 |
+
|
101 |
+
// append | firstChild | maybeBefore:selector
|
102 |
+
strategy: 'append',
|
103 |
+
whenInserted: () => {},
|
104 |
+
beforeInsert: el => {},
|
105 |
+
watch: [],
|
106 |
+
|
107 |
+
...args
|
108 |
+
}
|
109 |
+
|
110 |
+
const render = () => {
|
111 |
+
const to = wp.customize(args.id)()
|
112 |
+
|
113 |
+
renderWithStrategy({
|
114 |
+
...args,
|
115 |
+
should_insert: to === 'yes'
|
116 |
+
})
|
117 |
+
}
|
118 |
+
|
119 |
+
wp.customize(args.id, val => val.bind(to => render()))
|
120 |
+
args.watch.map(opt => wp.customize(opt, val => val.bind(() => render())))
|
121 |
+
}
|
122 |
+
|
123 |
+
export const responsiveClassesFor = (id, el) => {
|
124 |
+
el.classList.remove('ct-hidden-sm', 'ct-hidden-md', 'ct-hidden-lg')
|
125 |
+
|
126 |
+
if (!wp.customize(id)) return
|
127 |
+
|
128 |
+
const data = wp.customize(id)() || {
|
129 |
+
mobile: false,
|
130 |
+
tablet: true,
|
131 |
+
desktop: true
|
132 |
+
}
|
133 |
+
|
134 |
+
if (!data.mobile) {
|
135 |
+
el.classList.add('ct-hidden-sm')
|
136 |
+
}
|
137 |
+
|
138 |
+
if (!data.tablet) {
|
139 |
+
el.classList.add('ct-hidden-md')
|
140 |
+
}
|
141 |
+
|
142 |
+
if (!data.desktop) {
|
143 |
+
el.classList.add('ct-hidden-lg')
|
144 |
+
}
|
145 |
+
}
|
trunk/framework/extensions/cookies-consent/static/js/variables.js
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { handleVariablesFor } from 'customizer-sync-helpers'
|
2 |
+
|
3 |
+
handleVariablesFor({
|
4 |
+
cookieContentColor: [
|
5 |
+
{
|
6 |
+
selector: '.cookie-notification',
|
7 |
+
variable: 'color',
|
8 |
+
type: 'color:default'
|
9 |
+
},
|
10 |
+
|
11 |
+
{
|
12 |
+
selector: '.cookie-notification',
|
13 |
+
variable: 'colorHover',
|
14 |
+
type: 'color:hover'
|
15 |
+
}
|
16 |
+
],
|
17 |
+
|
18 |
+
cookieBackground: {
|
19 |
+
selector: '.cookie-notification',
|
20 |
+
variable: 'backgroundColor',
|
21 |
+
type: 'color'
|
22 |
+
},
|
23 |
+
|
24 |
+
cookieButtonBackground: [
|
25 |
+
{
|
26 |
+
selector: '.cookie-notification',
|
27 |
+
variable: 'buttonInitialColor',
|
28 |
+
type: 'color:default'
|
29 |
+
},
|
30 |
+
|
31 |
+
{
|
32 |
+
selector: '.cookie-notification',
|
33 |
+
variable: 'buttonHoverColor',
|
34 |
+
type: 'color:hover'
|
35 |
+
}
|
36 |
+
],
|
37 |
+
|
38 |
+
cookieMaxWidth: {
|
39 |
+
selector: '.cookie-notification',
|
40 |
+
variable: 'maxWidth',
|
41 |
+
unit: 'px'
|
42 |
+
}
|
43 |
+
})
|
trunk/framework/extensions/cookies-consent/static/sass/main.scss
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@import '../../../../../static/sass/common-frontend';
|
2 |
+
|
3 |
+
.cookie-notification {
|
4 |
+
position: fixed;
|
5 |
+
left: 0;
|
6 |
+
bottom: 0;
|
7 |
+
z-index: 999999;
|
8 |
+
color: var(--color);
|
9 |
+
|
10 |
+
a:hover {
|
11 |
+
color: var(--colorHover);
|
12 |
+
}
|
13 |
+
|
14 |
+
@include media-breakpoint-down (xs) {
|
15 |
+
> div {
|
16 |
+
flex-direction: column;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
@include media-breakpoint-down (sm) {
|
21 |
+
right: 0;
|
22 |
+
|
23 |
+
> div {
|
24 |
+
display: flex;
|
25 |
+
align-items: center;
|
26 |
+
padding-top: 15px;
|
27 |
+
padding-bottom: 15px;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
|
32 |
+
// type 1
|
33 |
+
&[data-type='type-1'] {
|
34 |
+
@include media-breakpoint-down (sm) {
|
35 |
+
background: var(--backgroundColor);
|
36 |
+
}
|
37 |
+
|
38 |
+
@include media-breakpoint-up (md) {
|
39 |
+
padding: 0 25px 25px 25px;
|
40 |
+
|
41 |
+
.ct-cookies-content {
|
42 |
+
margin-bottom: 15px;
|
43 |
+
max-width: 90%;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
.container {
|
48 |
+
position: relative;
|
49 |
+
|
50 |
+
@include media-breakpoint-down (sm) {
|
51 |
+
width: 88%;
|
52 |
+
margin: 0 auto;
|
53 |
+
}
|
54 |
+
|
55 |
+
@include media-breakpoint-up (md) {
|
56 |
+
background: var(--backgroundColor);
|
57 |
+
box-shadow: 0px 5px 30px -5px rgba(34, 56, 101, 0.15);
|
58 |
+
padding: 25px 40px 25px 25px;
|
59 |
+
border-radius: 3px;
|
60 |
+
max-width: var(--maxWidth);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
// type 2
|
67 |
+
&[data-type='type-2'] {
|
68 |
+
right: 0;
|
69 |
+
background: var(--backgroundColor);
|
70 |
+
|
71 |
+
@include media-breakpoint-up (md) {
|
72 |
+
padding: 15px 0;
|
73 |
+
|
74 |
+
.ct-container {
|
75 |
+
display: flex;
|
76 |
+
align-items: center;
|
77 |
+
justify-content: center;
|
78 |
+
}
|
79 |
+
|
80 |
+
.ct-accept {
|
81 |
+
margin-left: 25px;
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
.ct-close {
|
86 |
+
display: none;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
|
91 |
+
.ct-cookies-content {
|
92 |
+
line-height: 1.4;
|
93 |
+
|
94 |
+
> *:last-child {
|
95 |
+
margin-bottom: 0;
|
96 |
+
}
|
97 |
+
|
98 |
+
a {
|
99 |
+
text-decoration: underline;
|
100 |
+
color: var(--colorHover);
|
101 |
+
}
|
102 |
+
|
103 |
+
@include media-breakpoint-down (xs) {
|
104 |
+
text-align: center;
|
105 |
+
margin-bottom: 15px;
|
106 |
+
}
|
107 |
+
|
108 |
+
@include media-breakpoint-down (sm) {
|
109 |
+
font-size: 13px;
|
110 |
+
}
|
111 |
+
|
112 |
+
@include media-breakpoint-up (md) {
|
113 |
+
font-size: 14px;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
.ct-accept {
|
118 |
+
--buttonFontSize: 13px;
|
119 |
+
--buttonMinHeight: 35px;
|
120 |
+
--padding: 0 20px;
|
121 |
+
--buttonShadow: none;
|
122 |
+
--buttonTransform: none;
|
123 |
+
|
124 |
+
@include media-breakpoint-down (xs) {
|
125 |
+
width: 100%;
|
126 |
+
}
|
127 |
+
|
128 |
+
@include media-breakpoint-only (sm) {
|
129 |
+
margin-left: 20px;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
.ct-close {
|
134 |
+
display: flex;
|
135 |
+
align-items: center;
|
136 |
+
justify-content: center;
|
137 |
+
width: 45px;
|
138 |
+
height: 45px;
|
139 |
+
position: absolute;
|
140 |
+
top: 0;
|
141 |
+
right: 0;
|
142 |
+
opacity: 0.5;
|
143 |
+
color: inherit;
|
144 |
+
cursor: pointer;
|
145 |
+
background: transparent;
|
146 |
+
|
147 |
+
&:hover {
|
148 |
+
opacity: 1;
|
149 |
+
}
|
150 |
+
|
151 |
+
@include media-breakpoint-down (sm) {
|
152 |
+
display: none;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
// animation
|
157 |
+
&.ct-fade-in-start,
|
158 |
+
&.ct-fade-in-end,
|
159 |
+
&.ct-fade-start,
|
160 |
+
&.ct-fade-end {
|
161 |
+
transition: all 0.3s ease;
|
162 |
+
}
|
163 |
+
|
164 |
+
&.ct-fade-in-start {
|
165 |
+
opacity: 0;
|
166 |
+
transform: translate3d(0, 15px, 0);
|
167 |
+
}
|
168 |
+
|
169 |
+
&.ct-fade-end {
|
170 |
+
opacity: 0;
|
171 |
+
transform: translate3d(0, 15px, 0);
|
172 |
+
}
|
173 |
+
}
|
trunk/framework/extensions/mailchimp/admin-static/bundle/1.2c9ebf0a36c6c732fee6.js
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(window.blocksyMailchimpExtJsonp=window.blocksyMailchimpExtJsonp||[]).push([[1],[,,,,,,function(e,t,n){var o;
|
2 |
+
/*!
|
3 |
+
Copyright (c) 2017 Jed Watson.
|
4 |
+
Licensed under the MIT License (MIT), see
|
5 |
+
http://jedwatson.github.io/classnames
|
6 |
+
*/!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var o=arguments[t];if(o){var i=typeof o;if("string"===i||"number"===i)e.push(o);else if(Array.isArray(o)&&o.length){var s=r.apply(null,o);s&&e.push(s)}else if("object"===i)for(var u in o)n.call(o,u)&&o[u]&&e.push(u)}}return e.join(" ")}e.exports?(r.default=r,e.exports=r):void 0===(o=function(){return r}.apply(t,[]))||(e.exports=o)}()},function(e,t,n){e.exports=n(8)()},function(e,t,n){"use strict";var o=n(9);function r(){}function i(){}i.resetWarningCache=r,e.exports=function(){function e(e,t,n,r,i,s){if(s!==o){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";e.exports=n(11)},function(e,t,n){"use strict";
|
7 |
+
/** @license React v16.13.1
|
8 |
+
* react-is.production.min.js
|
9 |
+
*
|
10 |
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
11 |
+
*
|
12 |
+
* This source code is licensed under the MIT license found in the
|
13 |
+
* LICENSE file in the root directory of this source tree.
|
14 |
+
*/var o="function"==typeof Symbol&&Symbol.for,r=o?Symbol.for("react.element"):60103,i=o?Symbol.for("react.portal"):60106,s=o?Symbol.for("react.fragment"):60107,u=o?Symbol.for("react.strict_mode"):60108,a=o?Symbol.for("react.profiler"):60114,l=o?Symbol.for("react.provider"):60109,p=o?Symbol.for("react.context"):60110,d=o?Symbol.for("react.async_mode"):60111,c=o?Symbol.for("react.concurrent_mode"):60111,h=o?Symbol.for("react.forward_ref"):60112,f=o?Symbol.for("react.suspense"):60113,g=o?Symbol.for("react.suspense_list"):60120,m=o?Symbol.for("react.memo"):60115,v=o?Symbol.for("react.lazy"):60116,y=o?Symbol.for("react.block"):60121,I=o?Symbol.for("react.fundamental"):60117,S=o?Symbol.for("react.responder"):60118,b=o?Symbol.for("react.scope"):60119;function w(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case d:case c:case s:case a:case u:case f:return e;default:switch(e=e&&e.$$typeof){case p:case h:case v:case m:case l:return e;default:return t}}case i:return t}}}function x(e){return w(e)===c}t.AsyncMode=d,t.ConcurrentMode=c,t.ContextConsumer=p,t.ContextProvider=l,t.Element=r,t.ForwardRef=h,t.Fragment=s,t.Lazy=v,t.Memo=m,t.Portal=i,t.Profiler=a,t.StrictMode=u,t.Suspense=f,t.isAsyncMode=function(e){return x(e)||w(e)===d},t.isConcurrentMode=x,t.isContextConsumer=function(e){return w(e)===p},t.isContextProvider=function(e){return w(e)===l},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return w(e)===h},t.isFragment=function(e){return w(e)===s},t.isLazy=function(e){return w(e)===v},t.isMemo=function(e){return w(e)===m},t.isPortal=function(e){return w(e)===i},t.isProfiler=function(e){return w(e)===a},t.isStrictMode=function(e){return w(e)===u},t.isSuspense=function(e){return w(e)===f},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===s||e===c||e===a||e===u||e===f||e===g||"object"==typeof e&&null!==e&&(e.$$typeof===v||e.$$typeof===m||e.$$typeof===l||e.$$typeof===p||e.$$typeof===h||e.$$typeof===I||e.$$typeof===S||e.$$typeof===b||e.$$typeof===y)},t.typeOf=w},function(e,t,n){"use strict";function o(e,t){if(null==e)return{};var n,o,r={},i=Object.keys(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}function i(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var s=n(7),u=n.n(s),a=n(1);n(10);function l(e){return null!=e&&"object"==typeof e&&1===e.nodeType}function p(e,t){return(!t||"hidden"!==e)&&("visible"!==e&&"clip"!==e)}function d(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return p(n.overflowY,t)||p(n.overflowX,t)||function(e){var t=function(e){return e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView.frameElement:null}(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)}(e)}return!1}function c(e,t,n,o,r,i,s,u){return i<e&&s>t||i>e&&s<t?0:i<=e&&u<=n||s>=t&&u>=n?i-e-o:s>t&&u<n||i<e&&u>n?s-t+r:0}var h=0;function f(e){return"function"==typeof e?e:g}function g(){}function m(e,t){null!==e&&function(e,t){var n=t.scrollMode,o=t.block,r=t.inline,i=t.boundary,s=t.skipOverflowHiddenElements,u="function"==typeof i?i:function(e){return e!==i};if(!l(e))throw new TypeError("Invalid target");for(var a=document.scrollingElement||document.documentElement,p=[],h=e;l(h)&&u(h);){if((h=h.parentNode)===a){p.push(h);break}h===document.body&&d(h)&&!d(document.documentElement)||d(h,s)&&p.push(h)}for(var f=window.visualViewport?visualViewport.width:innerWidth,g=window.visualViewport?visualViewport.height:innerHeight,m=window.scrollX||pageXOffset,v=window.scrollY||pageYOffset,y=e.getBoundingClientRect(),I=y.height,S=y.width,b=y.top,w=y.right,x=y.bottom,C=y.left,H="start"===o||"nearest"===o?b:"end"===o?x:b+I/2,O="center"===r?C+S/2:"end"===r?w:C,E=[],P=0;P<p.length;P++){var M=p[P],D=M.getBoundingClientRect(),T=D.height,k=D.width,R=D.top,A=D.right,V=D.bottom,K=D.left;if("if-needed"===n&&b>=0&&C>=0&&x<=g&&w<=f&&b>=R&&x<=V&&C>=K&&w<=A)return E;var _=getComputedStyle(M),L=parseInt(_.borderLeftWidth,10),$=parseInt(_.borderTopWidth,10),B=parseInt(_.borderRightWidth,10),j=parseInt(_.borderBottomWidth,10),W=0,U=0,N="offsetWidth"in M?M.offsetWidth-M.clientWidth-L-B:0,F="offsetHeight"in M?M.offsetHeight-M.clientHeight-$-j:0;if(a===M)W="start"===o?H:"end"===o?H-g:"nearest"===o?c(v,v+g,g,$,j,v+H,v+H+I,I):H-g/2,U="start"===r?O:"center"===r?O-f/2:"end"===r?O-f:c(m,m+f,f,L,B,m+O,m+O+S,S),W=Math.max(0,W+v),U=Math.max(0,U+m);else{W="start"===o?H-R-$:"end"===o?H-V+j+F:"nearest"===o?c(R,V,T,$,j+F,H,H+I,I):H-(R+T/2)+F/2,U="start"===r?O-K-L:"center"===r?O-(K+k/2)+N/2:"end"===r?O-A+B+N:c(K,A,k,L,B+N,O,O+S,S);var z=M.scrollLeft,Y=M.scrollTop;H+=Y-(W=Math.max(0,Math.min(Y+W,M.scrollHeight-T+F))),O+=z-(U=Math.max(0,Math.min(z+U,M.scrollWidth-k+N)))}E.push({el:M,top:W,left:U})}return E}(e,{boundary:t,block:"nearest",scrollMode:"if-needed"}).forEach((function(e){var t=e.el,n=e.top,o=e.left;t.scrollTop=n,t.scrollLeft=o}))}function v(e,t){return e===t||e.contains&&e.contains(t)}function y(e,t){var n;function o(){n&&clearTimeout(n)}function r(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];o(),n=setTimeout((function(){n=null,e.apply(void 0,i)}),t)}return r.cancel=o,r}function I(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return t.some((function(t){return t&&t.apply(void 0,[e].concat(o)),e.preventDownshiftDefault||e.hasOwnProperty("nativeEvent")&&e.nativeEvent.preventDownshiftDefault}))}}function S(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){t.forEach((function(t){"function"==typeof t?t(e):t&&(t.current=e)}))}}function b(e){var t=e.isOpen,n=e.selectedItem,o=e.resultCount,r=e.previousResultCount,i=e.itemToString;return t?o?o!==r?o+" result"+(1===o?" is":"s are")+" available, use up and down arrow keys to navigate. Press Enter key to select.":"":"No results are available.":n?i(n):""}function w(e,t){return!(e=Array.isArray(e)?e[0]:e)&&t?t:e}function x(e){return"string"==typeof e.type}function C(e){return e.props}var H=["highlightedIndex","inputValue","isOpen","selectedItem","type"];function O(e){void 0===e&&(e={});var t={};return H.forEach((function(n){e.hasOwnProperty(n)&&(t[n]=e[n])})),t}function E(e){var t=e.key,n=e.keyCode;return n>=37&&n<=40&&0!==t.indexOf("Arrow")?"Arrow"+t:t}function P(e,t,n){var o=n-1;("number"!=typeof t||t<0||t>=n)&&(t=e>0?-1:o+1);var r=t+e;return r<0?r=o:r>o&&(r=0),r}var M=y((function(){T().textContent=""}),500);function D(e,t){var n=T(t);e&&(n.textContent=e,M())}function T(e){void 0===e&&(e=document);var t=e.getElementById("a11y-status-message");return t||((t=e.createElement("div")).setAttribute("id","a11y-status-message"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions text"),Object.assign(t.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),e.body.appendChild(t),t)}var k=Object.freeze({__proto__:null,unknown:0,mouseUp:1,itemMouseEnter:2,keyDownArrowUp:3,keyDownArrowDown:4,keyDownEscape:5,keyDownEnter:6,keyDownHome:7,keyDownEnd:8,clickItem:9,blurInput:10,changeInput:11,keyDownSpaceButton:12,clickButton:13,blurButton:14,controlledPropUpdatedSelectedItem:15,touchEnd:16}),R=function(){var e=function(e){var t,n;function s(t){var n=e.call(this,t)||this;n.id=n.props.id||"downshift-"+String(h++),n.menuId=n.props.menuId||n.id+"-menu",n.labelId=n.props.labelId||n.id+"-label",n.inputId=n.props.inputId||n.id+"-input",n.getItemId=n.props.getItemId||function(e){return n.id+"-item-"+e},n.input=null,n.items=[],n.itemCount=null,n.previousResultCount=0,n.timeoutIds=[],n.internalSetTimeout=function(e,t){var o=setTimeout((function(){n.timeoutIds=n.timeoutIds.filter((function(e){return e!==o})),e()}),t);n.timeoutIds.push(o)},n.setItemCount=function(e){n.itemCount=e},n.unsetItemCount=function(){n.itemCount=null},n.setHighlightedIndex=function(e,t){void 0===e&&(e=n.props.defaultHighlightedIndex),void 0===t&&(t={}),t=O(t),n.internalSetState(r({highlightedIndex:e},t))},n.clearSelection=function(e){n.internalSetState({selectedItem:null,inputValue:"",highlightedIndex:n.props.defaultHighlightedIndex,isOpen:n.props.defaultIsOpen},e)},n.selectItem=function(e,t,o){t=O(t),n.internalSetState(r({isOpen:n.props.defaultIsOpen,highlightedIndex:n.props.defaultHighlightedIndex,selectedItem:e,inputValue:n.props.itemToString(e)},t),o)},n.selectItemAtIndex=function(e,t,o){var r=n.items[e];null!=r&&n.selectItem(r,t,o)},n.selectHighlightedItem=function(e,t){return n.selectItemAtIndex(n.getState().highlightedIndex,e,t)},n.internalSetState=function(e,t){var o,i,s={},u="function"==typeof e;return!u&&e.hasOwnProperty("inputValue")&&n.props.onInputValueChange(e.inputValue,r({},n.getStateAndHelpers(),{},e)),n.setState((function(t){t=n.getState(t);var a=u?e(t):e;a=n.props.stateReducer(t,a),o=a.hasOwnProperty("selectedItem");var l={},p={};return o&&a.selectedItem!==t.selectedItem&&(i=a.selectedItem),a.type=a.type||0,Object.keys(a).forEach((function(e){t[e]!==a[e]&&(s[e]=a[e]),"type"!==e&&(p[e]=a[e],n.isControlledProp(e)||(l[e]=a[e]))})),u&&a.hasOwnProperty("inputValue")&&n.props.onInputValueChange(a.inputValue,r({},n.getStateAndHelpers(),{},a)),l}),(function(){f(t)(),Object.keys(s).length>1&&n.props.onStateChange(s,n.getStateAndHelpers()),o&&n.props.onSelect(e.selectedItem,n.getStateAndHelpers()),void 0!==i&&n.props.onChange(i,n.getStateAndHelpers()),n.props.onUserAction(s,n.getStateAndHelpers())}))},n.rootRef=function(e){return n._rootNode=e},n.getRootProps=function(e,t){var i,s=void 0===e?{}:e,u=s.refKey,a=void 0===u?"ref":u,l=s.ref,p=o(s,["refKey","ref"]),d=(void 0===t?{}:t).suppressRefError,c=void 0!==d&&d;n.getRootProps.called=!0,n.getRootProps.refKey=a,n.getRootProps.suppressRefError=c;var h=n.getState().isOpen;return r(((i={})[a]=S(l,n.rootRef),i.role="combobox",i["aria-expanded"]=h,i["aria-haspopup"]="listbox",i["aria-owns"]=h?n.menuId:null,i["aria-labelledby"]=n.labelId,i),p)},n.keyDownHandlers={ArrowDown:function(e){var t=this;if(e.preventDefault(),this.getState().isOpen){var n=e.shiftKey?5:1;this.moveHighlightedIndex(n,{type:4})}else this.internalSetState({isOpen:!0,type:4},(function(){var e=t.getItemCount();e>0&&t.setHighlightedIndex(P(1,t.getState().highlightedIndex,e),{type:4})}))},ArrowUp:function(e){var t=this;if(e.preventDefault(),this.getState().isOpen){var n=e.shiftKey?-5:-1;this.moveHighlightedIndex(n,{type:3})}else this.internalSetState({isOpen:!0,type:3},(function(){var e=t.getItemCount();e>0&&t.setHighlightedIndex(P(-1,t.getState().highlightedIndex,e),{type:4})}))},Enter:function(e){var t=this.getState(),n=t.isOpen,o=t.highlightedIndex;if(n&&null!=o){e.preventDefault();var r=this.items[o],i=this.getItemNodeFromIndex(o);if(null==r||i&&i.hasAttribute("disabled"))return;this.selectHighlightedItem({type:6})}},Escape:function(e){e.preventDefault(),this.reset({type:5,selectedItem:null,inputValue:""})}},n.buttonKeyDownHandlers=r({},n.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu({type:12})}}),n.inputKeyDownHandlers=r({},n.keyDownHandlers,{Home:function(e){this.highlightFirstOrLastIndex(e,!0,{type:7})},End:function(e){this.highlightFirstOrLastIndex(e,!1,{type:8})}}),n.getToggleButtonProps=function(e){var t=void 0===e?{}:e,i=t.onClick,s=(t.onPress,t.onKeyDown),u=t.onKeyUp,a=t.onBlur,l=o(t,["onClick","onPress","onKeyDown","onKeyUp","onBlur"]),p=n.getState().isOpen,d={onClick:I(i,n.buttonHandleClick),onKeyDown:I(s,n.buttonHandleKeyDown),onKeyUp:I(u,n.buttonHandleKeyUp),onBlur:I(a,n.buttonHandleBlur)};return r({type:"button",role:"button","aria-label":p?"close menu":"open menu","aria-haspopup":!0,"data-toggle":!0},l.disabled?{}:d,{},l)},n.buttonHandleKeyUp=function(e){e.preventDefault()},n.buttonHandleKeyDown=function(e){var t=E(e);n.buttonKeyDownHandlers[t]&&n.buttonKeyDownHandlers[t].call(i(n),e)},n.buttonHandleClick=function(e){e.preventDefault(),n.props.environment.document.activeElement===n.props.environment.document.body&&e.target.focus(),n.internalSetTimeout((function(){return n.toggleMenu({type:13})}))},n.buttonHandleBlur=function(e){var t=e.target;n.internalSetTimeout((function(){n.isMouseDown||null!=n.props.environment.document.activeElement&&n.props.environment.document.activeElement.id===n.inputId||n.props.environment.document.activeElement===t||n.reset({type:14})}))},n.getLabelProps=function(e){return r({htmlFor:n.inputId,id:n.labelId},e)},n.getInputProps=function(e){var t=void 0===e?{}:e,i=t.onKeyDown,s=t.onBlur,u=t.onChange,a=t.onInput,l=(t.onChangeText,o(t,["onKeyDown","onBlur","onChange","onInput","onChangeText"])),p={};var d,c=n.getState(),h=c.inputValue,f=c.isOpen,g=c.highlightedIndex;l.disabled||((d={}).onChange=I(u,a,n.inputHandleChange),d.onKeyDown=I(i,n.inputHandleKeyDown),d.onBlur=I(s,n.inputHandleBlur),p=d);return r({"aria-autocomplete":"list","aria-activedescendant":f&&"number"==typeof g&&g>=0?n.getItemId(g):null,"aria-controls":f?n.menuId:null,"aria-labelledby":n.labelId,autoComplete:"off",value:h,id:n.inputId},p,{},l)},n.inputHandleKeyDown=function(e){var t=E(e);t&&n.inputKeyDownHandlers[t]&&n.inputKeyDownHandlers[t].call(i(n),e)},n.inputHandleChange=function(e){n.internalSetState({type:11,isOpen:!0,inputValue:e.target.value,highlightedIndex:n.props.defaultHighlightedIndex})},n.inputHandleBlur=function(){n.internalSetTimeout((function(){var e=n.props.environment.document&&!!n.props.environment.document.activeElement&&!!n.props.environment.document.activeElement.dataset&&n.props.environment.document.activeElement.dataset.toggle&&n._rootNode&&n._rootNode.contains(n.props.environment.document.activeElement);n.isMouseDown||e||n.reset({type:10})}))},n.menuRef=function(e){n._menuNode=e},n.getMenuProps=function(e,t){var i,s=void 0===e?{}:e,u=s.refKey,a=void 0===u?"ref":u,l=s.ref,p=o(s,["refKey","ref"]),d=(void 0===t?{}:t).suppressRefError,c=void 0!==d&&d;return n.getMenuProps.called=!0,n.getMenuProps.refKey=a,n.getMenuProps.suppressRefError=c,r(((i={})[a]=S(l,n.menuRef),i.role="listbox",i["aria-labelledby"]=p&&p["aria-label"]?null:n.labelId,i.id=n.menuId,i),p)},n.getItemProps=function(e){var t,i=void 0===e?{}:e,s=i.onMouseMove,u=i.onMouseDown,a=i.onClick,l=(i.onPress,i.index),p=i.item,d=void 0===p?void 0:p,c=o(i,["onMouseMove","onMouseDown","onClick","onPress","index","item"]);void 0===l?(n.items.push(d),l=n.items.indexOf(d)):n.items[l]=d;var h=a,f=((t={onMouseMove:I(s,(function(){l!==n.getState().highlightedIndex&&(n.setHighlightedIndex(l,{type:2}),n.avoidScrolling=!0,n.internalSetTimeout((function(){return n.avoidScrolling=!1}),250))})),onMouseDown:I(u,(function(e){e.preventDefault()}))}).onClick=I(h,(function(){n.selectItemAtIndex(l,{type:9})})),t),g=c.disabled?{onMouseDown:f.onMouseDown}:f;return r({id:n.getItemId(l),role:"option","aria-selected":n.getState().highlightedIndex===l},g,{},c)},n.clearItems=function(){n.items=[]},n.reset=function(e,t){void 0===e&&(e={}),e=O(e),n.internalSetState((function(t){var o=t.selectedItem;return r({isOpen:n.props.defaultIsOpen,highlightedIndex:n.props.defaultHighlightedIndex,inputValue:n.props.itemToString(o)},e)}),t)},n.toggleMenu=function(e,t){void 0===e&&(e={}),e=O(e),n.internalSetState((function(t){var o=t.isOpen;return r({isOpen:!o},o&&{highlightedIndex:n.props.defaultHighlightedIndex},{},e)}),(function(){var o=n.getState(),r=o.isOpen,i=o.highlightedIndex;r&&n.getItemCount()>0&&"number"==typeof i&&n.setHighlightedIndex(i,e),f(t)()}))},n.openMenu=function(e){n.internalSetState({isOpen:!0},e)},n.closeMenu=function(e){n.internalSetState({isOpen:!1},e)},n.updateStatus=y((function(){var e=n.getState(),t=n.items[e.highlightedIndex],o=n.getItemCount(),i=n.props.getA11yStatusMessage(r({itemToString:n.props.itemToString,previousResultCount:n.previousResultCount,resultCount:o,highlightedItem:t},e));n.previousResultCount=o,D(i,n.props.environment.document)}),200);var s=n.props,u=s.defaultHighlightedIndex,a=s.initialHighlightedIndex,l=void 0===a?u:a,p=s.defaultIsOpen,d=s.initialIsOpen,c=void 0===d?p:d,g=s.initialInputValue,m=void 0===g?"":g,v=s.initialSelectedItem,b=void 0===v?null:v,w=n.getState({highlightedIndex:l,isOpen:c,inputValue:m,selectedItem:b});return null!=w.selectedItem&&void 0===n.props.initialInputValue&&(w.inputValue=n.props.itemToString(w.selectedItem)),n.state=w,n}n=e,(t=s).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var u=s.prototype;return u.internalClearTimeouts=function(){this.timeoutIds.forEach((function(e){clearTimeout(e)})),this.timeoutIds=[]},u.getState=function(e){var t=this;return void 0===e&&(e=this.state),Object.keys(e).reduce((function(n,o){return n[o]=t.isControlledProp(o)?t.props[o]:e[o],n}),{})},u.isControlledProp=function(e){return void 0!==this.props[e]},u.getItemCount=function(){var e=this.items.length;return null!=this.itemCount?e=this.itemCount:void 0!==this.props.itemCount&&(e=this.props.itemCount),e},u.getItemNodeFromIndex=function(e){return this.props.environment.document.getElementById(this.getItemId(e))},u.scrollHighlightedItemIntoView=function(){var e=this.getItemNodeFromIndex(this.getState().highlightedIndex);this.props.scrollIntoView(e,this._menuNode)},u.moveHighlightedIndex=function(e,t){var n=this.getItemCount();if(n>0){var o=P(e,this.getState().highlightedIndex,n);this.setHighlightedIndex(o,t)}},u.highlightFirstOrLastIndex=function(e,t,n){var o=this.getItemCount()-1;o<0||!this.getState().isOpen||(e.preventDefault(),this.setHighlightedIndex(t?0:o,n))},u.getStateAndHelpers=function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,o=e.selectedItem,r=e.isOpen,i=this.props.itemToString,s=this.id,u=this.getRootProps,a=this.getToggleButtonProps,l=this.getLabelProps,p=this.getMenuProps,d=this.getInputProps,c=this.getItemProps,h=this.openMenu,f=this.closeMenu,g=this.toggleMenu,m=this.selectItem,v=this.selectItemAtIndex,y=this.selectHighlightedItem,I=this.setHighlightedIndex,S=this.clearSelection,b=this.clearItems;return{getRootProps:u,getToggleButtonProps:a,getLabelProps:l,getMenuProps:p,getInputProps:d,getItemProps:c,reset:this.reset,openMenu:h,closeMenu:f,toggleMenu:g,selectItem:m,selectItemAtIndex:v,selectHighlightedItem:y,setHighlightedIndex:I,clearSelection:S,clearItems:b,setItemCount:this.setItemCount,unsetItemCount:this.unsetItemCount,setState:this.internalSetState,itemToString:i,id:s,highlightedIndex:t,inputValue:n,isOpen:r,selectedItem:o}},u.componentDidMount=function(){var e=this;var t=function(t,n){void 0===n&&(n=!0);var o=e.props.environment.document;return[e._rootNode,e._menuNode].some((function(e){return e&&(v(e,t)||n&&v(e,o.activeElement))}))},n=function(){e.isMouseDown=!0},o=function(n){e.isMouseDown=!1,!t(n.target)&&e.getState().isOpen&&e.reset({type:1},(function(){return e.props.onOuterClick(e.getStateAndHelpers())}))},r=function(){e.isTouchMove=!1},i=function(){e.isTouchMove=!0},s=function(n){var o=t(n.target,!1);e.isTouchMove||o||!e.getState().isOpen||e.reset({type:16},(function(){return e.props.onOuterClick(e.getStateAndHelpers())}))},u=this.props.environment;u.addEventListener("mousedown",n),u.addEventListener("mouseup",o),u.addEventListener("touchstart",r),u.addEventListener("touchmove",i),u.addEventListener("touchend",s),this.cleanup=function(){e.internalClearTimeouts(),e.updateStatus.cancel(),u.removeEventListener("mousedown",n),u.removeEventListener("mouseup",o),u.removeEventListener("touchstart",r),u.removeEventListener("touchmove",i),u.removeEventListener("touchend",s)}},u.shouldScroll=function(e,t){var n=(void 0===this.props.highlightedIndex?this.getState():this.props).highlightedIndex,o=(void 0===t.highlightedIndex?e:t).highlightedIndex;return n&&this.getState().isOpen&&!e.isOpen||n!==o},u.componentDidUpdate=function(e,t){this.isControlledProp("selectedItem")&&this.props.selectedItemChanged(e.selectedItem,this.props.selectedItem)&&this.internalSetState({type:15,inputValue:this.props.itemToString(this.props.selectedItem)}),!this.avoidScrolling&&this.shouldScroll(t,e)&&this.scrollHighlightedItemIntoView(),this.updateStatus()},u.componentWillUnmount=function(){this.cleanup()},u.render=function(){var e=w(this.props.children,g);this.clearItems(),this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getRootProps.suppressRefError=void 0,this.getMenuProps.called=!1,this.getMenuProps.refKey=void 0,this.getMenuProps.suppressRefError=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=w(e(this.getStateAndHelpers()));return t?this.getRootProps.called||this.props.suppressRefError?t:x(t)?Object(a.cloneElement)(t,this.getRootProps(C(t))):void 0:null},s}(a.Component);return e.defaultProps={defaultHighlightedIndex:null,defaultIsOpen:!1,getA11yStatusMessage:b,itemToString:function(e){return null==e?"":String(e)},onStateChange:g,onInputValueChange:g,onUserAction:g,onChange:g,onSelect:g,onOuterClick:g,selectedItemChanged:function(e,t){return e!==t},environment:"undefined"==typeof window?{}:window,stateReducer:function(e,t){return t},suppressRefError:!1,scrollIntoView:m},e.stateChangeTypes=k,e}();u.a.array.isRequired,u.a.func,u.a.func,u.a.func,u.a.bool,u.a.number,u.a.number,u.a.number,u.a.bool,u.a.bool,u.a.bool,u.a.any,u.a.any,u.a.any,u.a.string,u.a.string,u.a.string,u.a.func,u.a.string,u.a.func,u.a.func,u.a.func,u.a.func,u.a.func,u.a.shape({addEventListener:u.a.func,removeEventListener:u.a.func,document:u.a.shape({getElementById:u.a.func,activeElement:u.a.any,body:u.a.any})});"undefined"==typeof window||window;t.a=R}]]);
|
trunk/framework/extensions/mailchimp/admin-static/bundle/2.976c8f43abfe584b1a9d.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
(window.blocksyMailchimpExtJsonp=window.blocksyMailchimpExtJsonp||[]).push([[2],{13:function(e,t,n){"use strict";n.r(t);var r=n(0),a=n(12),c=n(2),i=n(6),o=n.n(i);function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function l(e,t,n,r,a,c,i){try{var o=e[c](i),u=o.value}catch(e){return void n(e)}o.done?t(u):Promise.resolve(u).then(r,a)}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,a=!1,c=void 0;try{for(var i,o=e[Symbol.iterator]();!(r=(i=o.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){a=!0,c=e}finally{try{r||null==o.return||o.return()}finally{if(a)throw c}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var d=null;t.default=function(e){var t=e.value,n=e.onChange,i=s(Object(r.useState)(d||[]),2),f=i[0],p=i[1],m=s(Object(r.useState)(!d),2),b=m[0],v=m[1],h=function(){var e,t=(e=regeneratorRuntime.mark((function e(){var t,n,r,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(!(a.length>0&&void 0!==a[0])||a[0])&&v(!0),(t=new FormData).append("action","blocksy_ext_mailchimp_get_actual_lists"),e.prev=4,e.next=7,fetch(ajaxurl,{method:"POST",body:t});case 7:if(200!==(n=e.sent).status){e.next=18;break}return e.next=11,n.json();case 11:if(!(r=e.sent).success){e.next=18;break}if("api_key_invalid"===r.data.result){e.next=18;break}return v(!1),p(r.data.result),d=r.data.result,e.abrupt("return");case 18:e.next=22;break;case 20:e.prev=20,e.t0=e.catch(4);case 22:v(!1);case 23:case"end":return e.stop()}}),e,null,[[4,20]])})),function(){var t=this,n=arguments;return new Promise((function(r,a){var c=e.apply(t,n);function i(e){l(c,r,a,i,o,"next",e)}function o(e){l(c,r,a,i,o,"throw",e)}i(void 0)}))});return function(){return t.apply(this,arguments)}}();return Object(r.useEffect)((function(){h(!d)}),[]),0===f.length?Object(r.createElement)("div",{className:"ct-select-input"},Object(r.createElement)("input",{disabled:!0,placeholder:b?Object(c.__)("Loading...","blc"):Object(c.__)("Invalid API Key...","blc")})):Object(r.createElement)(a.a,{selectedItem:t||f[0].id,onChange:function(e){return n(e)},itemToString:function(e){return e?(f.find((function(t){return t.id===e}))||{}).name:""}},(function(e){var t=e.getInputProps,n=e.getItemProps,a=(e.getLabelProps,e.getMenuProps),i=e.isOpen,l=(e.inputValue,e.highlightedIndex),s=e.selectedItem,d=e.openMenu;return Object(r.createElement)("div",{className:"ct-select-input"},Object(r.createElement)("input",u({},t({onFocus:function(){return d()},onClick:function(){return d()}}),{placeholder:Object(c.__)("Select list...","blc"),readOnly:!0})),i&&Object(r.createElement)("div",a({className:"ct-select-dropdown"}),f.map((function(e,t){return Object(r.createElement)("div",n({key:e.id,index:t,item:e.id,className:o()("ct-select-dropdown-item",{active:l===t,selected:s===e.id})}),e.name)}))))}))}}}]);
|
trunk/framework/extensions/mailchimp/admin-static/bundle/main.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(e){function t(t){for(var n,o,c=t[0],i=t[1],u=0,a=[];u<c.length;u++)o=c[u],Object.prototype.hasOwnProperty.call(r,o)&&r[o]&&a.push(r[o][0]),r[o]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(l&&l(t);a.length;)a.shift()()}var n={},r={0:0};function o(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.e=function(e){var t=[],n=r[e];if(0!==n)if(n)t.push(n[2]);else{var c=new Promise((function(t,o){n=r[e]=[t,o]}));t.push(n[2]=c);var i,u=document.createElement("script");u.charset="utf-8",u.timeout=120,o.nc&&u.setAttribute("nonce",o.nc),u.src=function(e){return o.p+""+e+"."+{1:"2c9ebf0a36c6c732fee6",2:"976c8f43abfe584b1a9d"}[e]+".js"}(e);var l=new Error;i=function(t){u.onerror=u.onload=null,clearTimeout(a);var n=r[e];if(0!==n){if(n){var o=t&&("load"===t.type?"missing":t.type),c=t&&t.target&&t.target.src;l.message="Loading chunk "+e+" failed.\n("+o+": "+c+")",l.name="ChunkLoadError",l.type=o,l.request=c,n[1](l)}r[e]=void 0}};var a=setTimeout((function(){i({type:"timeout",target:u})}),12e4);u.onerror=u.onload=i,document.head.appendChild(u)}return Promise.all(t)},o.m=e,o.c=n,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o.oe=function(e){throw console.error(e),e};var c=window.blocksyMailchimpExtJsonp=window.blocksyMailchimpExtJsonp||[],i=c.push.bind(c);c.push=t,c=c.slice();for(var u=0;u<c.length;u++)t(c[u]);var l=i;o(o.s=5)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.React},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.ctEvents},function(e,t,n){n.p=blocksy_ext_newsletter_subscribe_localization.public_url},function(e,t,n){"use strict";n.r(t);n(4);var r=n(0),o=n(2),c=n(1),i=Object(c.lazy)((function(){return Promise.all([n.e(1),n.e(2)]).then(n.bind(null,13))})),u=function(e){return Object(r.createElement)("div",null,Object(r.createElement)(c.Suspense,{fallback:Object(r.createElement)("div",{className:"ct-select-input"},Object(r.createElement)("input",{disabled:!0,placeholder:Object(o.__)("Loading...","blc")}))},Object(r.createElement)(i,e)))},l=n(3),a=n.n(l);document.addEventListener("DOMContentLoaded",(function(){return a.a.on("blocksy:options:register",(function(e){e["blocksy-mailchimp"]=u}))}))}]);
|
trunk/framework/extensions/mailchimp/admin-static/bundle/sync.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(e){var t={};function o(c){if(t[c])return t[c].exports;var i=t[c]={i:c,l:!1,exports:{}};return e[c].call(i.exports,i,i.exports,o),i.l=!0,i.exports}o.m=e,o.c=t,o.d=function(e,t,c){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:c})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var c=Object.create(null);if(o.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(c,i,function(t){return e[t]}.bind(null,i));return c},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=1)}([function(e,t){e.exports=window.blocksyCustomizerSync},function(e,t,o){"use strict";o.r(t);var c,i=o(0),n=function(e){if([e.top,e.right,e.bottom,e.left].reduce((function(e,t){return!!e&&!("auto"!==t&&t&&t.toString().match(/\d/g))}),!0))return"CT_CSS_SKIP_RULE";var t=["auto"!==e.top&&e.top.toString().match(/\d/g)?e.top:0,"auto"!==e.right&&e.right.toString().match(/\d/g)?e.right:0,"auto"!==e.bottom&&e.bottom.toString().match(/\d/g)?e.bottom:0,"auto"!==e.left&&e.left.toString().match(/\d/g)?e.left:0];return t[0]===t[1]&&t[0]===t[2]&&t[0]===t[3]?t[0]:t[0]===t[2]&&t[1]===t[3]?"".concat(t[0]," ").concat(t[3]):t.join(" ")},a=function(e,t){var o=t.forcedOutput,c=void 0!==o&&o;if("CT_CSS_SKIP_RULE"===e)return"CT_CSS_SKIP_RULE";if("none"===e)return"none";if(!e.enable)return c?"none":"CT_CSS_SKIP_RULE";if(0===parseFloat(e.blur)&&0===parseFloat(e.spread)&&0===parseFloat(e.v_offset)&&0===parseFloat(e.h_offset))return c?"none":"CT_CSS_SKIP_RULE";var i=[];return e.inset&&i.push("inset"),i.push("".concat(e.h_offset,"px")),i.push("".concat(e.v_offset,"px")),0!==parseFloat(e.blur)&&(i.push("".concat(e.blur,"px")),0!==parseFloat(e.spread)&&i.push("".concat(e.spread,"px"))),0===parseFloat(e.blur)&&0!==parseFloat(e.spread)&&(i.push("".concat(e.blur,"px")),i.push("".concat(e.spread,"px"))),i.push(e.color.color),i.join(" ")},r=function(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"desktop",c={desktop:"ct-main-styles-inline-css",tablet:"ct-main-styles-tablet-inline-css",mobile:"ct-main-styles-mobile-inline-css"},i=document.querySelector("style#".concat(c[o])),n=i.innerText,a="".concat(e["".concat(o,"_selector_prefix")]?"".concat(e["".concat(o,"_selector_prefix")]," "):"").concat(e.selector||":root"),r=null,l=n.match(r);0===n.trim().indexOf(a)?(r=new RegExp("".concat(a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"\\s?{[\\s\\S]*?}"),"gm"),l=n.match(r)):(r=new RegExp("\\}\\s*?".concat(a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"\\s?{[\\s\\S]*?}"),"gm"),l=n.match(r)),l||(0===(n="".concat(n," ").concat(a," { }")).trim().indexOf(a)?(r=new RegExp("".concat(a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"\\s?{[\\s\\S]*?}"),"gm"),l=n.match(r)):(r=new RegExp("\\}\\s*?".concat(a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"\\s?{[\\s\\S]*?}"),"gm"),l=n.match(r))),i.innerText=n.replace(r,l[0].indexOf("--".concat(e.variable,":"))>-1?l[0].replace(new RegExp("--".concat(e.variable,":[\\s\\S]*?;"),"gm"),t.indexOf("CT_CSS_SKIP_RULE")>-1||t.indexOf(e.variable)>-1?"":"--".concat(e.variable,": ").concat(t,";")):l[0].replace(new RegExp("".concat(a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"\\s?{"),"gm"),"".concat(a," {").concat(t.indexOf("CT_CSS_SKIP_RULE")>-1||t.indexOf(e.variable)>-1?"":"--".concat(e.variable,": ").concat(t,";"))))},l=function(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"desktop",c=(e.type||"").indexOf("color")>-1?t["color"===e.type?"default":e.type.split(":")[1]].color:t;"border"===(e.type||"")&&(c=t&&"none"!==t.style?"".concat(t.width,"px ").concat(t.style," ").concat(t.color.color):"none"),"spacing"===(e.type||"")&&(c=n(t)),"box-shadow"===(e.type||"")&&(c=a(t,e)),r(e,"".concat(c).concat(e.unit||"").concat(e.important?" !important":""),o)},s=function(e,t){var o=t;t=e.extractValue?e.extractValue(t):t,e.whenDone&&e.whenDone(t,o),t=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e&&Object.keys(e).indexOf("desktop")>-1?t?e:e.desktop:t?{desktop:e,tablet:e,mobile:e}:e}(t,!!e.responsive),e.responsive?(e.enabled&&"no"===!wp.customize(e.enabled)()&&(t.mobile="0"+(e.unit?"":"px"),t.tablet="0"+(e.unit?"":"px"),t.desktop="0"+(e.unit?"":"px")),l(e,t.desktop,"desktop"),l(e,t.tablet,"tablet"),l(e,t.mobile,"mobile")):l(e,t)};c={mailchimpContent:[{selector:".ct-mailchimp-block",variable:"color",type:"color:default"},{selector:".ct-mailchimp-block",variable:"linkHoverColor",type:"color:hover"}],mailchimpButton:[{selector:".ct-mailchimp-block",variable:"buttonInitialColor",type:"color:default"},{selector:".ct-mailchimp-block",variable:"buttonHoverColor",type:"color:hover"}],mailchimpBackground:{selector:".ct-mailchimp-block",variable:"mailchimpBackground",type:"color"},mailchimpShadow:{selector:".ct-mailchimp-block",type:"box-shadow",variable:"box-shadow",responsive:!0},mailchimpSpacing:{selector:".ct-mailchimp-block",variable:"padding",responsive:!0,unit:""}},wp.customize.bind("change",(function(e){return c[e.id]&&(Array.isArray(c[e.id])?c[e.id]:[c[e.id]]).map((function(t){return s(t,e())}))})),wp.customize("mailchimp_subscribe_visibility",(function(e){return e.bind((function(e){var t=document.querySelector(".ct-mailchimp-block");Object(i.responsiveClassesFor)("mailchimp_subscribe_visibility",t)}))})),(document.body.classList.contains("single")||document.body.classList.contains("page"))&&Object(i.checkAndReplace)({id:"mailchimp_single_post_enabled",strategy:"append",parent_selector:".site-main article",selector:".ct-mailchimp-block",fragment_id:"blocksy-mailchimp-subscribe",watch:["has_mailchimp_name","mailchimp_button_text","mailchimp_title","mailchimp_text","mailchimp_name_label","mailchimp_mail_label"],whenInserted:function(){if(document.body.classList.contains("single")||document.body.classList.contains("page")){var e=document.querySelector(".ct-mailchimp-block");Object(i.responsiveClassesFor)("mailchimp_subscribe_visibility",e),"yes"!==wp.customize("has_mailchimp_name")()?(e.querySelector("[data-fields]").dataset.fields=1,e.querySelector('[name="FNAME"]').remove()):(e.querySelector("[data-fields]").dataset.fields=2,e.querySelector('[name="FNAME"]').setAttribute("placeholder","".concat(wp.customize("mailchimp_name_label")()))),e.querySelector('[name="EMAIL"]').setAttribute("placeholder","".concat(wp.customize("mailchimp_mail_label")()," *")),e.querySelector("button").innerHTML=wp.customize("mailchimp_button_text")(),e.querySelector("h3").innerHTML=wp.customize("mailchimp_title")(),e.querySelector(".ct-mailchimp-description").innerHTML=wp.customize("mailchimp_text")()}}})}]);
|
trunk/framework/extensions/mailchimp/admin-static/js/ListPicker.js
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { createElement, Component } from '@wordpress/element'
|
2 |
+
import { __ } from 'ct-i18n'
|
3 |
+
import { lazy, Suspense } from 'react'
|
4 |
+
|
5 |
+
const ListPickerImplementation = lazy(() =>
|
6 |
+
import('./ListPicker/Implementation')
|
7 |
+
)
|
8 |
+
|
9 |
+
const ListPicker = props => (
|
10 |
+
<div>
|
11 |
+
<Suspense
|
12 |
+
fallback={
|
13 |
+
<div className="ct-select-input">
|
14 |
+
<input disabled placeholder={__('Loading...', 'blc')} />
|
15 |
+
</div>
|
16 |
+
}>
|
17 |
+
<ListPickerImplementation {...props} />
|
18 |
+
</Suspense>
|
19 |
+
</div>
|
20 |
+
)
|
21 |
+
|
22 |
+
export default ListPicker
|
trunk/framework/extensions/mailchimp/admin-static/js/ListPicker/Implementation.js
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import {
|
2 |
+
createElement,
|
3 |
+
Component,
|
4 |
+
useState,
|
5 |
+
useEffect,
|
6 |
+
Fragment
|
7 |
+
} from '@wordpress/element'
|
8 |
+
import Downshift from 'downshift'
|
9 |
+
import { __ } from 'ct-i18n'
|
10 |
+
import classnames from 'classnames'
|
11 |
+
|
12 |
+
let listsCache = null
|
13 |
+
|
14 |
+
const ListPickerImplementation = ({ value, onChange }) => {
|
15 |
+
const [lists, setLists] = useState(listsCache || [])
|
16 |
+
const [isLoadingLists, setListsLoading] = useState(!listsCache)
|
17 |
+
|
18 |
+
const maybeFetchLists = async (verbose = true) => {
|
19 |
+
if (verbose) {
|
20 |
+
setListsLoading(true)
|
21 |
+
}
|
22 |
+
|
23 |
+
const body = new FormData()
|
24 |
+
body.append('action', 'blocksy_ext_mailchimp_get_actual_lists')
|
25 |
+
|
26 |
+
try {
|
27 |
+
const response = await fetch(ajaxurl, {
|
28 |
+
method: 'POST',
|
29 |
+
body
|
30 |
+
})
|
31 |
+
if (response.status === 200) {
|
32 |
+
const body = await response.json()
|
33 |
+
|
34 |
+
if (body.success) {
|
35 |
+
if (body.data.result !== 'api_key_invalid') {
|
36 |
+
setListsLoading(false)
|
37 |
+
setLists(body.data.result)
|
38 |
+
listsCache = body.data.result
|
39 |
+
|
40 |
+
return
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
44 |
+
} catch (e) {}
|
45 |
+
|
46 |
+
setListsLoading(false)
|
47 |
+
}
|
48 |
+
|
49 |
+
useEffect(() => {
|
50 |
+
maybeFetchLists(!listsCache)
|
51 |
+
}, [])
|
52 |
+
|
53 |
+
return lists.length === 0 ? (
|
54 |
+
<div className="ct-select-input">
|
55 |
+
<input
|
56 |
+
disabled
|
57 |
+
placeholder={
|
58 |
+
isLoadingLists
|
59 |
+
? __('Loading...', 'blc')
|
60 |
+
: __('Invalid API Key...', 'blc')
|
61 |
+
}
|
62 |
+
/>
|
63 |
+
</div>
|
64 |
+
) : (
|
65 |
+
<Downshift
|
66 |
+
selectedItem={value || lists[0].id}
|
67 |
+
onChange={selection => onChange(selection)}
|
68 |
+
itemToString={item =>
|
69 |
+
item ? (lists.find(({ id }) => id === item) || {}).name : ''
|
70 |
+
}>
|
71 |
+
{({
|
72 |
+
getInputProps,
|
73 |
+
getItemProps,
|
74 |
+
getLabelProps,
|
75 |
+
getMenuProps,
|
76 |
+
isOpen,
|
77 |
+
inputValue,
|
78 |
+
highlightedIndex,
|
79 |
+
selectedItem,
|
80 |
+
openMenu
|
81 |
+
}) => (
|
82 |
+
<div className="ct-select-input">
|
83 |
+
<input
|
84 |
+
{...getInputProps({
|
85 |
+
onFocus: () => openMenu(),
|
86 |
+
onClick: () => openMenu()
|
87 |
+
})}
|
88 |
+
placeholder={__('Select list...', 'blc')}
|
89 |
+
readOnly
|
90 |
+
/>
|
91 |
+
|
92 |
+
{isOpen && (
|
93 |
+
<div
|
94 |
+
{...getMenuProps({
|
95 |
+
className: 'ct-select-dropdown'
|
96 |
+
})}>
|
97 |
+
{lists.map((item, index) => (
|
98 |
+
<div
|
99 |
+
{...getItemProps({
|
100 |
+
key: item.id,
|
101 |
+
index,
|
102 |
+
item: item.id,
|
103 |
+
className: classnames(
|
104 |
+
'ct-select-dropdown-item',
|
105 |
+
{
|
106 |
+
active:
|
107 |
+
highlightedIndex === index,
|
108 |
+
selected:
|
109 |
+
selectedItem === item.id
|
110 |
+
}
|
111 |
+
)
|
112 |
+
})}>
|
113 |
+
{item.name}
|
114 |
+
</div>
|
115 |
+
))}
|
116 |
+
</div>
|
117 |
+
)}
|
118 |
+
</div>
|
119 |
+
)}
|
120 |
+
</Downshift>
|
121 |
+
)
|
122 |
+
}
|
123 |
+
|
124 |
+
export default ListPickerImplementation
|
trunk/framework/extensions/mailchimp/admin-static/js/main.js
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import './public-path'
|
2 |
+
import { createElement, Fragment, Component } from '@wordpress/element'
|
3 |
+
import ListPicker from './ListPicker'
|
4 |
+
import ctEvents from 'ct-events'
|
5 |
+
|
6 |
+
document.addEventListener('DOMContentLoaded', () =>
|
7 |
+
ctEvents.on('blocksy:options:register', opts => {
|
8 |
+
opts['blocksy-mailchimp'] = ListPicker
|
9 |
+
})
|
10 |
+
)
|
trunk/framework/extensions/mailchimp/admin-static/js/public-path.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
__webpack_public_path__ = blocksy_ext_newsletter_subscribe_localization.public_url
|
trunk/framework/extensions/mailchimp/admin-static/js/sync.js
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { checkAndReplace, responsiveClassesFor } from 'blocksy-customizer-sync'
|
2 |
+
|
3 |
+
import './variables'
|
4 |
+
|
5 |
+
wp.customize('mailchimp_subscribe_visibility', (val) =>
|
6 |
+
val.bind((to) => {
|
7 |
+
const block = document.querySelector('.ct-mailchimp-block')
|
8 |
+
responsiveClassesFor('mailchimp_subscribe_visibility', block)
|
9 |
+
})
|
10 |
+
)
|
11 |
+
|
12 |
+
if (
|
13 |
+
document.body.classList.contains('single') ||
|
14 |
+
document.body.classList.contains('page')
|
15 |
+
) {
|
16 |
+
checkAndReplace({
|
17 |
+
id: 'mailchimp_single_post_enabled',
|
18 |
+
strategy: 'append',
|
19 |
+
|
20 |
+
parent_selector: '.site-main article',
|
21 |
+
selector: '.ct-mailchimp-block',
|
22 |
+
fragment_id: 'blocksy-mailchimp-subscribe',
|
23 |
+
|
24 |
+
watch: [
|
25 |
+
'has_mailchimp_name',
|
26 |
+
'mailchimp_button_text',
|
27 |
+
'mailchimp_title',
|
28 |
+
'mailchimp_text',
|
29 |
+
'mailchimp_name_label',
|
30 |
+
'mailchimp_mail_label',
|
31 |
+
],
|
32 |
+
|
33 |
+
whenInserted: () => {
|
34 |
+
if (
|
35 |
+
!document.body.classList.contains('single') &&
|
36 |
+
!document.body.classList.contains('page')
|
37 |
+
) {
|
38 |
+
return
|
39 |
+
}
|
40 |
+
const block = document.querySelector('.ct-mailchimp-block')
|
41 |
+
|
42 |
+
responsiveClassesFor('mailchimp_subscribe_visibility', block)
|
43 |
+
|
44 |
+
if (wp.customize('has_mailchimp_name')() !== 'yes') {
|
45 |
+
block.querySelector('[data-fields]').dataset.fields = 1
|
46 |
+
block.querySelector('[name="FNAME"]').remove()
|
47 |
+
} else {
|
48 |
+
block.querySelector('[data-fields]').dataset.fields = 2
|
49 |
+
|
50 |
+
block
|
51 |
+
.querySelector('[name="FNAME"]')
|
52 |
+
.setAttribute(
|
53 |
+
'placeholder',
|
54 |
+
`${wp.customize('mailchimp_name_label')()}`
|
55 |
+
)
|
56 |
+
}
|
57 |
+
|
58 |
+
block
|
59 |
+
.querySelector('[name="EMAIL"]')
|
60 |
+
.setAttribute(
|
61 |
+
'placeholder',
|
62 |
+
`${wp.customize('mailchimp_mail_label')()} *`
|
63 |
+
)
|
64 |
+
|
65 |
+
block.querySelector('button').innerHTML = wp.customize(
|
66 |
+
'mailchimp_button_text'
|
67 |
+
)()
|
68 |
+
|
69 |
+
block.querySelector('h3').innerHTML = wp.customize(
|
70 |
+
'mailchimp_title'
|
71 |
+
)()
|
72 |
+
|
73 |
+
block.querySelector(
|
74 |
+
'.ct-mailchimp-description'
|
75 |
+
).innerHTML = wp.customize('mailchimp_text')()
|
76 |
+
},
|
77 |
+
})
|
78 |
+
}
|
trunk/framework/extensions/mailchimp/admin-static/js/variables.js
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { handleVariablesFor } from 'customizer-sync-helpers'
|
2 |
+
|
3 |
+
handleVariablesFor({
|
4 |
+
|
5 |
+
mailchimpContent: [
|
6 |
+
{
|
7 |
+
selector: '.ct-mailchimp-block',
|
8 |
+
variable: 'color',
|
9 |
+
type: 'color:default'
|
10 |
+
},
|
11 |
+
|
12 |
+
{
|
13 |
+
selector: '.ct-mailchimp-block',
|
14 |
+
variable: 'linkHoverColor',
|
15 |
+
type: 'color:hover'
|
16 |
+
}
|
17 |
+
],
|
18 |
+
|
19 |
+
mailchimpButton: [
|
20 |
+
{
|
21 |
+
selector: '.ct-mailchimp-block',
|
22 |
+
variable: 'buttonInitialColor',
|
23 |
+
type: 'color:default'
|
24 |
+
},
|
25 |
+
|
26 |
+
{
|
27 |
+
selector: '.ct-mailchimp-block',
|
28 |
+
variable: 'buttonHoverColor',
|
29 |
+
type: 'color:hover'
|
30 |
+
}
|
31 |
+
],
|
32 |
+
|
33 |
+
mailchimpBackground: {
|
34 |
+
selector: '.ct-mailchimp-block',
|
35 |
+
variable: 'mailchimpBackground',
|
36 |
+
type: 'color'
|
37 |
+
},
|
38 |
+
|
39 |
+
mailchimpShadow: {
|
40 |
+
selector: '.ct-mailchimp-block',
|
41 |
+
type: 'box-shadow',
|
42 |
+
variable: 'box-shadow',
|
43 |
+
responsive: true
|
44 |
+
},
|
45 |
+
|
46 |
+
mailchimpSpacing: {
|
47 |
+
selector: '.ct-mailchimp-block',
|
48 |
+
variable: 'padding',
|
49 |
+
responsive: true,
|
50 |
+
unit: ''
|
51 |
+
}
|
52 |
+
})
|
trunk/framework/extensions/mailchimp/config.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$config = [
|
4 |
+
'name' => __('Mailchimp Subscribe', 'blc'),
|
5 |
+
'description' => __('Display a subscribe form with the help of a widget or a block.', 'blc')
|
6 |
+
];
|
7 |
+
|
trunk/framework/extensions/mailchimp/ct-mailchimp/options.php
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Mailchimp widget
|
4 |
+
*
|
5 |
+
* @copyright 2019-present Creative Themes
|
6 |
+
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
7 |
+
* @package Blocksy
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
$options = [
|
12 |
+
'title' => [
|
13 |
+
'type' => 'text',
|
14 |
+
'label' => __( 'Title', 'blc' ),
|
15 |
+
'field_attr' => [ 'id' => 'widget-title' ],
|
16 |
+
'design' => 'inline',
|
17 |
+
'value' => __( 'Newsletter', 'blc' ),
|
18 |
+
'disableRevertButton' => true,
|
19 |
+
],
|
20 |
+
|
21 |
+
'mailchimp_text' => [
|
22 |
+
'label' => __( 'Message', 'blc' ),
|
23 |
+
'type' => 'textarea',
|
24 |
+
'value' => __( 'Enter your email address below to subscribe to our newsletter', 'blc' ),
|
25 |
+
'design' => 'inline',
|
26 |
+
'disableRevertButton' => true,
|
27 |
+
],
|
28 |
+
|
29 |
+
'mailchimp_list_id_source' => [
|
30 |
+
'type' => 'ct-radio',
|
31 |
+
'label' => __( 'List Source', 'blc' ),
|
32 |
+
'value' => 'default',
|
33 |
+
'view' => 'radio',
|
34 |
+
'inline' => true,
|
35 |
+
'design' => 'inline',
|
36 |
+
'disableRevertButton' => true,
|
37 |
+
'choices' => [
|
38 |
+
'default' => __('Default', 'blc'),
|
39 |
+
'custom' => __('Custom', 'blc'),
|
40 |
+
],
|
41 |
+
],
|
42 |
+
|
43 |
+
blocksy_rand_md5() => [
|
44 |
+
'type' => 'ct-condition',
|
45 |
+
'condition' => [ 'mailchimp_list_id_source' => 'custom' ],
|
46 |
+
'options' => [
|
47 |
+
|
48 |
+
'mailchimp_list_id' => [
|
49 |
+
'label' => __( 'List ID', 'blc' ),
|
50 |
+
'type' => 'blocksy-mailchimp',
|
51 |
+
'value' => '',
|
52 |
+
'design' => 'inline',
|
53 |
+
'disableRevertButton' => true,
|
54 |
+
],
|
55 |
+
|
56 |
+
],
|
57 |
+
],
|
58 |
+
|
59 |
+
'has_mailchimp_name' => [
|
60 |
+
'type' => 'ct-switch',
|
61 |
+
'label' => __( 'Name Field', 'blc' ),
|
62 |
+
'value' => 'no',
|
63 |
+
'disableRevertButton' => true,
|
64 |
+
],
|
65 |
+
|
66 |
+
blocksy_rand_md5() => [
|
67 |
+
'type' => 'ct-condition',
|
68 |
+
'condition' => [ 'has_mailchimp_name' => 'yes' ],
|
69 |
+
'options' => [
|
70 |
+
|
71 |
+
'mailchimp_name_label' => [
|
72 |
+
'type' => 'text',
|
73 |
+
'label' => __( 'Name Label', 'blc' ),
|
74 |
+
'design' => 'inline',
|
75 |
+
'value' => __( 'Your name', 'blc' ),
|
76 |
+
'disableRevertButton' => true,
|
77 |
+
],
|
78 |
+
|
79 |
+
],
|
80 |
+
],
|
81 |
+
|
82 |
+
'mailchimp_mail_label' => [
|
83 |
+
'type' => 'text',
|
84 |
+
'label' => __( 'Mail Label', 'blc' ),
|
85 |
+
'design' => 'inline',
|
86 |
+
'value' => __( 'Your email', 'blc' ),
|
87 |
+
'disableRevertButton' => true,
|
88 |
+
],
|
89 |
+
|
90 |
+
'mailchimp_button_text' => [
|
91 |
+
'type' => 'text',
|
92 |
+
'label' => __( 'Button Label', 'blc' ),
|
93 |
+
'design' => 'inline',
|
94 |
+
'value' => __( 'Subscribe', 'blc' ),
|
95 |
+
'disableRevertButton' => true,
|
96 |
+
],
|
97 |
+
|
98 |
+
'mailchimp_container' => [
|
99 |
+
'label' => __( 'Container Type', 'blc' ),
|
100 |
+
'type' => 'ct-select',
|
101 |
+
'value' => 'default',
|
102 |
+
'design' => 'inline',
|
103 |
+
'disableRevertButton' => true,
|
104 |
+
'choices' => [
|
105 |
+
'default' => __( 'Default', 'blc' ),
|
106 |
+
'boxed' => __( 'Boxed', 'blc' ),
|
107 |
+
],
|
108 |
+
],
|
109 |
+
|
110 |
+
'mailchimp_alignment' => [
|
111 |
+
'type' => 'ct-radio',
|
112 |
+
'label' => __( 'Content Alignment', 'blc' ),
|
113 |
+
'value' => 'left',
|
114 |
+
'view' => 'text',
|
115 |
+
'design' => 'inline',
|
116 |
+
'attr' => [ 'data-type' => 'alignment' ],
|
117 |
+
'disableRevertButton' => true,
|
118 |
+
'choices' => [
|
119 |
+
'left' => '',
|
120 |
+
'center' => '',
|
121 |
+
'right' => '',
|
122 |
+
],
|
123 |
+
],
|
124 |
+
|
125 |
+
];
|
trunk/framework/extensions/mailchimp/ct-mailchimp/view.php
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Mailchimp widget
|
4 |
+
*
|
5 |
+
* @copyright 2019-present Creative Themes
|
6 |
+
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
7 |
+
* @package Blocksy
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
// Widget title
|
12 |
+
$title = blocksy_default_akg( 'title', $atts, __( 'Newsletter', 'blc' ) );
|
13 |
+
|
14 |
+
|
15 |
+
// Message
|
16 |
+
$message = blocksy_default_akg( 'mailchimp_text', $atts, __( 'Enter your email address below to subscribe to our newsletter', 'blc' ) );
|
17 |
+
|
18 |
+
// Button text
|
19 |
+
$button_text = blocksy_default_akg( 'mailchimp_button_text', $atts, __( 'Subscribe', 'blc' ) );
|
20 |
+
|
21 |
+
// Form name
|
22 |
+
$has_name = blocksy_default_akg( 'has_mailchimp_name', $atts, 'no' ) === 'yes';
|
23 |
+
|
24 |
+
$list_id = null;
|
25 |
+
|
26 |
+
if (blocksy_default_akg( 'mailchimp_list_id_source', $atts, 'default' ) === 'custom') {
|
27 |
+
$list_id = blocksy_default_akg( 'mailchimp_list_id', $atts, '' );
|
28 |
+
}
|
29 |
+
|
30 |
+
$manager = new BlocksyMailchimpManager();
|
31 |
+
|
32 |
+
// Button value
|
33 |
+
$mailchimp_data = $manager->get_form_url_and_gdpr_for($list_id);
|
34 |
+
|
35 |
+
if (! $mailchimp_data) {
|
36 |
+
return;
|
37 |
+
}
|
38 |
+
|
39 |
+
$form_url = $mailchimp_data['form_url'];
|
40 |
+
$has_gdpr_fields = $mailchimp_data['has_gdpr_fields'];
|
41 |
+
|
42 |
+
$skip_submit_output = '';
|
43 |
+
|
44 |
+
if ($has_gdpr_fields) {
|
45 |
+
$skip_submit_output = 'data-skip-submit';
|
46 |
+
}
|
47 |
+
|
48 |
+
// container type
|
49 |
+
$container = blocksy_default_akg( 'mailchimp_container', $atts, 'default' );
|
50 |
+
|
51 |
+
$data_container = '';
|
52 |
+
|
53 |
+
if ( $container !== 'default' ) {
|
54 |
+
$data_container = ' data-container=' . $container;
|
55 |
+
}
|
56 |
+
|
57 |
+
// Content alignment
|
58 |
+
$alignment = blocksy_default_akg( 'mailchimp_alignment', $atts, 'left' );
|
59 |
+
|
60 |
+
$name_label = blocksy_default_akg('mailchimp_name_label', $atts, __( 'Your name', 'blc' ));
|
61 |
+
$email_label = blocksy_default_akg('mailchimp_mail_label', $atts, __( 'Your email', 'blc' ));
|
62 |
+
|
63 |
+
$data_alignment = '';
|
64 |
+
|
65 |
+
if ( $alignment !== 'left' ) {
|
66 |
+
$data_alignment = ' data-alignment=' . $alignment;
|
67 |
+
}
|
68 |
+
|
69 |
+
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
70 |
+
echo $before_widget;
|
71 |
+
|
72 |
+
echo '<div class="ct-widget-inner"' . $data_alignment . '' . $data_container . '>';
|
73 |
+
|
74 |
+
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
75 |
+
echo $before_title . wp_kses_post( $title ) . $after_title;
|
76 |
+
|
77 |
+
?>
|
78 |
+
|
79 |
+
|
80 |
+
<form action="<?php echo esc_attr($form_url) ?>" method="post" class="ct-mailchimp-widget-form" target="_blank" <?php echo $skip_submit_output ?>>
|
81 |
+
|
82 |
+
<?php if( !empty( $message ) ) { ?>
|
83 |
+
<div class="ct-mailchimp-description">
|
84 |
+
<?php echo wp_kses_post($message) ?>
|
85 |
+
</div>
|
86 |
+
<?php } ?>
|
87 |
+
|
88 |
+
<?php if ( $has_name ) { ?>
|
89 |
+
<input type="text" name="FNAME" placeholder="<?php esc_attr_e($name_label, 'blc'); ?>" title="<?php echo __('Name', 'blocksy') ?>" />
|
90 |
+
<?php } ?>
|
91 |
+
|
92 |
+
<input type="email" name="EMAIL" placeholder="<?php esc_attr_e($email_label, 'blc'); ?> *" title="<?php echo __('Email', 'blocksy') ?>" required />
|
93 |
+
|
94 |
+
<button class="button">
|
95 |
+
<?php echo esc_html($button_text) ?>
|
96 |
+
</button>
|
97 |
+
|
98 |
+
<div class="ct-mailchimp-message"></div>
|
99 |
+
|
100 |
+
<?php
|
101 |
+
if (function_exists('blocksy_ext_cookies_checkbox')) {
|
102 |
+
echo blocksy_ext_cookies_checkbox('mailchimp');
|
103 |
+
}
|
104 |
+
?>
|
105 |
+
</form>
|
106 |
+
|
107 |
+
</div>
|
108 |
+
|
109 |
+
<?php echo wp_kses_post( $after_widget ); ?>
|
trunk/framework/extensions/mailchimp/ct-mailchimp/widget.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Mailchimp widget
|
4 |
+
*
|
5 |
+
* @copyright 2019-present Creative Themes
|
6 |
+
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
7 |
+
* @package Blocksy
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Blocksy_Widget_Ct_Mailchimp extends BlocksyWidgetFactory {
|
11 |
+
protected function get_config() {
|
12 |
+
return [
|
13 |
+
'name' => __('Newsletter Subscribe', 'blc'),
|
14 |
+
'description' => __('Newsletter subscribe form', 'blc'),
|
15 |
+
];
|
16 |
+
}
|
17 |
+
|
18 |
+
public function get_path() {
|
19 |
+
return dirname(__FILE__);
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
trunk/framework/extensions/mailchimp/customizer.php
ADDED
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$options = [
|
4 |
+
'label' => __( 'Subscribe Form', 'blc' ),
|
5 |
+
'type' => 'ct-panel',
|
6 |
+
'switch' => true,
|
7 |
+
'value' => 'yes',
|
8 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
9 |
+
'inner-options' => [
|
10 |
+
|
11 |
+
blocksy_rand_md5() => [
|
12 |
+
'title' => __( 'General', 'blc' ),
|
13 |
+
'type' => 'tab',
|
14 |
+
'options' => [
|
15 |
+
|
16 |
+
'mailchimp_title' => [
|
17 |
+
'type' => 'text',
|
18 |
+
'label' => __( 'Title', 'blc' ),
|
19 |
+
'field_attr' => [ 'id' => 'widget-title' ],
|
20 |
+
'design' => 'block',
|
21 |
+
'value' => __( 'Newsletter Updates', 'blc' ),
|
22 |
+
'disableRevertButton' => true,
|
23 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
24 |
+
],
|
25 |
+
|
26 |
+
'mailchimp_text' => [
|
27 |
+
'label' => __( 'Message', 'blc' ),
|
28 |
+
'type' => 'textarea',
|
29 |
+
'value' => __( 'Enter your email address below to subscribe to our newsletter', 'blc' ),
|
30 |
+
'design' => 'block',
|
31 |
+
'disableRevertButton' => true,
|
32 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
33 |
+
],
|
34 |
+
|
35 |
+
blocksy_rand_md5() => [
|
36 |
+
'type' => 'ct-divider',
|
37 |
+
'attr' => [ 'data-type' => 'small' ],
|
38 |
+
],
|
39 |
+
|
40 |
+
'mailchimp_list_id_source' => [
|
41 |
+
'type' => 'ct-radio',
|
42 |
+
'label' => __( 'List Source', 'blc' ),
|
43 |
+
'value' => 'default',
|
44 |
+
'view' => 'radio',
|
45 |
+
'inline' => true,
|
46 |
+
'design' => 'inline',
|
47 |
+
'disableRevertButton' => true,
|
48 |
+
'choices' => [
|
49 |
+
'default' => __('Default', 'blc'),
|
50 |
+
'custom' => __('Custom', 'blc'),
|
51 |
+
],
|
52 |
+
|
53 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
54 |
+
],
|
55 |
+
|
56 |
+
blocksy_rand_md5() => [
|
57 |
+
'type' => 'ct-condition',
|
58 |
+
'condition' => [ 'mailchimp_list_id_source' => 'custom' ],
|
59 |
+
'options' => [
|
60 |
+
|
61 |
+
'mailchimp_list_id' => [
|
62 |
+
'label' => __( 'List ID', 'blc' ),
|
63 |
+
'type' => 'blocksy-mailchimp',
|
64 |
+
'value' => '',
|
65 |
+
'design' => 'inline',
|
66 |
+
'disableRevertButton' => true,
|
67 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
68 |
+
],
|
69 |
+
|
70 |
+
],
|
71 |
+
],
|
72 |
+
|
73 |
+
blocksy_rand_md5() => [
|
74 |
+
'type' => 'ct-divider',
|
75 |
+
'attr' => [ 'data-type' => 'small' ],
|
76 |
+
],
|
77 |
+
|
78 |
+
'has_mailchimp_name' => [
|
79 |
+
'type' => 'ct-switch',
|
80 |
+
'label' => __( 'Name Field', 'blc' ),
|
81 |
+
'value' => 'no',
|
82 |
+
'disableRevertButton' => true,
|
83 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
84 |
+
],
|
85 |
+
|
86 |
+
blocksy_rand_md5() => [
|
87 |
+
'type' => 'ct-condition',
|
88 |
+
'condition' => [ 'has_mailchimp_name' => 'yes' ],
|
89 |
+
'options' => [
|
90 |
+
|
91 |
+
'mailchimp_name_label' => [
|
92 |
+
'type' => 'text',
|
93 |
+
'label' => __( 'Name Label', 'blc' ),
|
94 |
+
'design' => 'inline',
|
95 |
+
'value' => __( 'Your name', 'blc' ),
|
96 |
+
'disableRevertButton' => true,
|
97 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
98 |
+
],
|
99 |
+
|
100 |
+
],
|
101 |
+
],
|
102 |
+
|
103 |
+
'mailchimp_mail_label' => [
|
104 |
+
'type' => 'text',
|
105 |
+
'label' => __( 'Mail Label', 'blc' ),
|
106 |
+
'design' => 'inline',
|
107 |
+
'value' => __( 'Your email', 'blc' ),
|
108 |
+
'disableRevertButton' => true,
|
109 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
110 |
+
],
|
111 |
+
|
112 |
+
'mailchimp_button_text' => [
|
113 |
+
'type' => 'text',
|
114 |
+
'label' => __( 'Button Label', 'blc' ),
|
115 |
+
'design' => 'inline',
|
116 |
+
'value' => __( 'Subscribe', 'blc' ),
|
117 |
+
'disableRevertButton' => true,
|
118 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
119 |
+
],
|
120 |
+
|
121 |
+
blocksy_rand_md5() => [
|
122 |
+
'type' => 'ct-divider',
|
123 |
+
],
|
124 |
+
|
125 |
+
'mailchimp_subscribe_visibility' => [
|
126 |
+
'label' => __( 'Visibility', 'blc' ),
|
127 |
+
'type' => 'ct-visibility',
|
128 |
+
'design' => 'block',
|
129 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
130 |
+
'value' => [
|
131 |
+
'desktop' => true,
|
132 |
+
'tablet' => true,
|
133 |
+
'mobile' => false,
|
134 |
+
],
|
135 |
+
|
136 |
+
'choices' => blocksy_ordered_keys([
|
137 |
+
'desktop' => __( 'Desktop', 'blc' ),
|
138 |
+
'tablet' => __( 'Tablet', 'blc' ),
|
139 |
+
'mobile' => __( 'Mobile', 'blc' ),
|
140 |
+
]),
|
141 |
+
],
|
142 |
+
|
143 |
+
],
|
144 |
+
],
|
145 |
+
|
146 |
+
blocksy_rand_md5() => [
|
147 |
+
'title' => __( 'Design', 'blc' ),
|
148 |
+
'type' => 'tab',
|
149 |
+
'options' => [
|
150 |
+
|
151 |
+
'mailchimpContent' => [
|
152 |
+
'label' => __( 'Content Color', 'blc' ),
|
153 |
+
'type' => 'ct-color-picker',
|
154 |
+
'design' => 'inline',
|
155 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
156 |
+
|
157 |
+
'value' => [
|
158 |
+
'default' => [
|
159 |
+
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
|
160 |
+
],
|
161 |
+
|
162 |
+
'hover' => [
|
163 |
+
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
|
164 |
+
],
|
165 |
+
],
|
166 |
+
|
167 |
+
'pickers' => [
|
168 |
+
[
|
169 |
+
'title' => __( 'Initial', 'blc' ),
|
170 |
+
'id' => 'default',
|
171 |
+
'inherit' => 'var(--color)'
|
172 |
+
],
|
173 |
+
|
174 |
+
[
|
175 |
+
'title' => __( 'Hover', 'blc' ),
|
176 |
+
'id' => 'hover',
|
177 |
+
'inherit' => 'var(--linkHoverColor)'
|
178 |
+
],
|
179 |
+
],
|
180 |
+
],
|
181 |
+
|
182 |
+
'mailchimpButton' => [
|
183 |
+
'label' => __( 'Button Color', 'blc' ),
|
184 |
+
'type' => 'ct-color-picker',
|
185 |
+
'design' => 'inline',
|
186 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
187 |
+
|
188 |
+
'value' => [
|
189 |
+
'default' => [
|
190 |
+
'color' => 'var(--paletteColor1)',
|
191 |
+
],
|
192 |
+
|
193 |
+
'hover' => [
|
194 |
+
'color' => 'var(--paletteColor2)',
|
195 |
+
],
|
196 |
+
],
|
197 |
+
|
198 |
+
'pickers' => [
|
199 |
+
[
|
200 |
+
'title' => __( 'Initial', 'blc' ),
|
201 |
+
'id' => 'default',
|
202 |
+
],
|
203 |
+
|
204 |
+
[
|
205 |
+
'title' => __( 'Hover', 'blc' ),
|
206 |
+
'id' => 'hover',
|
207 |
+
],
|
208 |
+
],
|
209 |
+
],
|
210 |
+
|
211 |
+
'mailchimpBackground' => [
|
212 |
+
'label' => __( 'Background Color', 'blc' ),
|
213 |
+
'type' => 'ct-color-picker',
|
214 |
+
'design' => 'inline',
|
215 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
216 |
+
|
217 |
+
'value' => [
|
218 |
+
'default' => [
|
219 |
+
'color' => '#ffffff',
|
220 |
+
],
|
221 |
+
],
|
222 |
+
|
223 |
+
'pickers' => [
|
224 |
+
[
|
225 |
+
'title' => __( 'Initial', 'blc' ),
|
226 |
+
'id' => 'default',
|
227 |
+
],
|
228 |
+
],
|
229 |
+
],
|
230 |
+
|
231 |
+
'mailchimpSpacing' => [
|
232 |
+
'label' => __( 'Container Inner Spacing', 'blc' ),
|
233 |
+
'type' => 'ct-slider',
|
234 |
+
'value' => '40px',
|
235 |
+
'units' => blocksy_units_config([
|
236 |
+
[
|
237 |
+
'unit' => 'px',
|
238 |
+
'min' => 0,
|
239 |
+
'max' => 300,
|
240 |
+
],
|
241 |
+
]),
|
242 |
+
'responsive' => true,
|
243 |
+
'divider' => 'top',
|
244 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
245 |
+
],
|
246 |
+
|
247 |
+
'mailchimpShadow' => [
|
248 |
+
'label' => __( 'Shadow', 'blocksy' ),
|
249 |
+
'type' => 'ct-box-shadow',
|
250 |
+
'responsive' => true,
|
251 |
+
'divider' => 'top',
|
252 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
253 |
+
'value' => blocksy_box_shadow_value([
|
254 |
+
'enable' => true,
|
255 |
+
'h_offset' => 0,
|
256 |
+
'v_offset' => 50,
|
257 |
+
'blur' => 90,
|
258 |
+
'spread' => 0,
|
259 |
+
'inset' => false,
|
260 |
+
'color' => [
|
261 |
+
'color' => 'rgba(210, 213, 218, 0.4)',
|
262 |
+
],
|
263 |
+
])
|
264 |
+
],
|
265 |
+
|
266 |
+
],
|
267 |
+
],
|
268 |
+
|
269 |
+
],
|
270 |
+
];
|
trunk/framework/extensions/mailchimp/dashboard-static/bundle/main.js
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=14)}([function(e,t){e.exports=window.wp.element},function(e,t,n){e.exports=n(9)()},function(e,t){e.exports=window.React},function(e,t){e.exports=window.wp.i18n},function(e,t,n){var r;
|
2 |
+
/*!
|
3 |
+
Copyright (c) 2017 Jed Watson.
|
4 |
+
Licensed under the MIT License (MIT), see
|
5 |
+
http://jedwatson.github.io/classnames
|
6 |
+
*/!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var i=typeof r;if("string"===i||"number"===i)e.push(r);else if(Array.isArray(r)&&r.length){var a=o.apply(null,r);a&&e.push(a)}else if("object"===i)for(var u in r)n.call(r,u)&&r[u]&&e.push(u)}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},function(e,t){e.exports=window.blocksyOptions},function(e,t,n){"use strict";e.exports=n(13)},function(e,t){e.exports=window.ctEvents},function(e,t,n){var r,o,i=n(11),a=n(12),u=(o=[],{activateTrap:function(e){if(o.length>0){var t=o[o.length-1];t!==e&&t.pause()}var n=o.indexOf(e);-1===n||o.splice(n,1),o.push(e)},deactivateTrap:function(e){var t=o.indexOf(e);-1!==t&&o.splice(t,1),o.length>0&&o[o.length-1].unpause()}});function c(e){return setTimeout(e,0)}e.exports=function(e,t){var n=document,o="string"==typeof e?n.querySelector(e):e,s=a({returnFocusOnDeactivate:!0,escapeDeactivates:!0},t),l={firstTabbableNode:null,lastTabbableNode:null,nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1},d={activate:function(e){if(l.active)return;w(),l.active=!0,l.paused=!1,l.nodeFocusedBeforeActivation=n.activeElement;var t=e&&e.onActivate?e.onActivate:s.onActivate;t&&t();return f(),d},deactivate:p,pause:function(){if(l.paused||!l.active)return;l.paused=!0,h()},unpause:function(){if(!l.paused||!l.active)return;l.paused=!1,w(),f()}};return d;function p(e){if(l.active){clearTimeout(r),h(),l.active=!1,l.paused=!1,u.deactivateTrap(d);var t=e&&void 0!==e.onDeactivate?e.onDeactivate:s.onDeactivate;return t&&t(),(e&&void 0!==e.returnFocus?e.returnFocus:s.returnFocusOnDeactivate)&&c((function(){var e;O((e=l.nodeFocusedBeforeActivation,m("setReturnFocus")||e))})),d}}function f(){if(l.active)return u.activateTrap(d),r=c((function(){O(v())})),n.addEventListener("focusin",y,!0),n.addEventListener("mousedown",g,{capture:!0,passive:!1}),n.addEventListener("touchstart",g,{capture:!0,passive:!1}),n.addEventListener("click",I,{capture:!0,passive:!1}),n.addEventListener("keydown",b,{capture:!0,passive:!1}),d}function h(){if(l.active)return n.removeEventListener("focusin",y,!0),n.removeEventListener("mousedown",g,!0),n.removeEventListener("touchstart",g,!0),n.removeEventListener("click",I,!0),n.removeEventListener("keydown",b,!0),d}function m(e){var t=s[e],r=t;if(!t)return null;if("string"==typeof t&&!(r=n.querySelector(t)))throw new Error("`"+e+"` refers to no known node");if("function"==typeof t&&!(r=t()))throw new Error("`"+e+"` did not return a node");return r}function v(){var e;if(!(e=null!==m("initialFocus")?m("initialFocus"):o.contains(n.activeElement)?n.activeElement:l.firstTabbableNode||m("fallbackFocus")))throw new Error("Your focus-trap needs to have at least one focusable element");return e}function g(e){o.contains(e.target)||(s.clickOutsideDeactivates?p({returnFocus:!i.isFocusable(e.target)}):s.allowOutsideClick&&s.allowOutsideClick(e)||e.preventDefault())}function y(e){o.contains(e.target)||e.target instanceof Document||(e.stopImmediatePropagation(),O(l.mostRecentlyFocusedNode||v()))}function b(e){if(!1!==s.escapeDeactivates&&function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e))return e.preventDefault(),void p();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){if(w(),e.shiftKey&&e.target===l.firstTabbableNode)return e.preventDefault(),void O(l.lastTabbableNode);if(!e.shiftKey&&e.target===l.lastTabbableNode)e.preventDefault(),O(l.firstTabbableNode)}(e)}function I(e){s.clickOutsideDeactivates||o.contains(e.target)||s.allowOutsideClick&&s.allowOutsideClick(e)||(e.preventDefault(),e.stopImmediatePropagation())}function w(){var e=i(o);l.firstTabbableNode=e[0]||v(),l.lastTabbableNode=e[e.length-1]||v()}function O(e){e!==n.activeElement&&(e&&e.focus?(e.focus(),l.mostRecentlyFocusedNode=e,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(e)&&e.select()):O(v()))}}},function(e,t,n){"use strict";var r=n(10);function o(){}function i(){}i.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,i,a){if(a!==r){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:o};return n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t){var n=["input","select","textarea","a[href]","button","[tabindex]","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])'],r=n.join(","),o="undefined"==typeof Element?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector;function i(e,t){t=t||{};var n,i,u,c=[],d=[],p=e.querySelectorAll(r);for(t.includeContainer&&o.call(e,r)&&(p=Array.prototype.slice.apply(p)).unshift(e),n=0;n<p.length;n++)a(i=p[n])&&(0===(u=s(i))?c.push(i):d.push({documentOrder:n,tabIndex:u,node:i}));return d.sort(l).map((function(e){return e.node})).concat(c)}function a(e){return!(!u(e)||function(e){return function(e){return d(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t=function(e){for(var t=0;t<e.length;t++)if(e[t].checked)return e[t]}(e.ownerDocument.querySelectorAll('input[type="radio"][name="'+e.name+'"]'));return!t||t===e}(e)}(e)||s(e)<0)}function u(e){return!(e.disabled||function(e){return d(e)&&"hidden"===e.type}(e)||function(e){return null===e.offsetParent||"hidden"===getComputedStyle(e).visibility}(e))}i.isTabbable=function(e){if(!e)throw new Error("No node provided");return!1!==o.call(e,r)&&a(e)},i.isFocusable=function(e){if(!e)throw new Error("No node provided");return!1!==o.call(e,c)&&u(e)};var c=n.concat("iframe").join(",");function s(e){var t=parseInt(e.getAttribute("tabindex"),10);return isNaN(t)?function(e){return"true"===e.contentEditable}(e)?0:e.tabIndex:t}function l(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex}function d(e){return"INPUT"===e.tagName}e.exports=i},function(e,t){e.exports=function(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var o in r)n.call(r,o)&&(e[o]=r[o])}return e};var n=Object.prototype.hasOwnProperty},function(e,t,n){"use strict";
|
7 |
+
/** @license React v16.13.1
|
8 |
+
* react-is.production.min.js
|
9 |
+
*
|
10 |
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
11 |
+
*
|
12 |
+
* This source code is licensed under the MIT license found in the
|
13 |
+
* LICENSE file in the root directory of this source tree.
|
14 |
+
*/var r="function"==typeof Symbol&&Symbol.for,o=r?Symbol.for("react.element"):60103,i=r?Symbol.for("react.portal"):60106,a=r?Symbol.for("react.fragment"):60107,u=r?Symbol.for("react.strict_mode"):60108,c=r?Symbol.for("react.profiler"):60114,s=r?Symbol.for("react.provider"):60109,l=r?Symbol.for("react.context"):60110,d=r?Symbol.for("react.async_mode"):60111,p=r?Symbol.for("react.concurrent_mode"):60111,f=r?Symbol.for("react.forward_ref"):60112,h=r?Symbol.for("react.suspense"):60113,m=r?Symbol.for("react.suspense_list"):60120,v=r?Symbol.for("react.memo"):60115,g=r?Symbol.for("react.lazy"):60116,y=r?Symbol.for("react.block"):60121,b=r?Symbol.for("react.fundamental"):60117,I=r?Symbol.for("react.responder"):60118,w=r?Symbol.for("react.scope"):60119;function O(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case o:switch(e=e.type){case d:case p:case a:case c:case u:case h:return e;default:switch(e=e&&e.$$typeof){case l:case f:case g:case v:case s:return e;default:return t}}case i:return t}}}function S(e){return O(e)===p}t.AsyncMode=d,t.ConcurrentMode=p,t.ContextConsumer=l,t.ContextProvider=s,t.Element=o,t.ForwardRef=f,t.Fragment=a,t.Lazy=g,t.Memo=v,t.Portal=i,t.Profiler=c,t.StrictMode=u,t.Suspense=h,t.isAsyncMode=function(e){return S(e)||O(e)===d},t.isConcurrentMode=S,t.isContextConsumer=function(e){return O(e)===l},t.isContextProvider=function(e){return O(e)===s},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===o},t.isForwardRef=function(e){return O(e)===f},t.isFragment=function(e){return O(e)===a},t.isLazy=function(e){return O(e)===g},t.isMemo=function(e){return O(e)===v},t.isPortal=function(e){return O(e)===i},t.isProfiler=function(e){return O(e)===c},t.isStrictMode=function(e){return O(e)===u},t.isSuspense=function(e){return O(e)===h},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===p||e===c||e===u||e===h||e===m||"object"==typeof e&&null!==e&&(e.$$typeof===g||e.$$typeof===v||e.$$typeof===s||e.$$typeof===l||e.$$typeof===f||e.$$typeof===b||e.$$typeof===I||e.$$typeof===w||e.$$typeof===y)},t.typeOf=O},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n(7),i=n.n(o),a=n(3),u=n(4),c=n.n(u),s=n(2),l=n.n(s),d=n(1),p=n.n(d);function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var m=function(e){e.initialState,e.getInitialState,e.refs,e.getRefs,e.didMount,e.didUpdate,e.willUnmount,e.getSnapshotBeforeUpdate,e.shouldUpdate,e.render;return function(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["initialState","getInitialState","refs","getRefs","didMount","didUpdate","willUnmount","getSnapshotBeforeUpdate","shouldUpdate","render"])},v=function(e){function t(){var n,r;f(this,t);for(var o=arguments.length,i=Array(o),a=0;a<o;a++)i[a]=arguments[a];return n=r=h(this,e.call.apply(e,[this].concat(i))),g.call(r),h(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.getArgs=function(){var e=this.state,t=this.props,n=this._setState,r=this._forceUpdate,o=this._refs;return{state:e,props:m(t),refs:o,setState:n,forceUpdate:r}},t.prototype.componentDidMount=function(){this.props.didMount&&this.props.didMount(this.getArgs())},t.prototype.shouldComponentUpdate=function(e,t){return!this.props.shouldUpdate||this.props.shouldUpdate({props:this.props,state:this.state,nextProps:m(e),nextState:t})},t.prototype.componentWillUnmount=function(){this.props.willUnmount&&this.props.willUnmount({state:this.state,props:m(this.props),refs:this._refs})},t.prototype.componentDidUpdate=function(e,t,n){this.props.didUpdate&&this.props.didUpdate(Object.assign(this.getArgs(),{prevProps:m(e),prevState:t}),n)},t.prototype.getSnapshotBeforeUpdate=function(e,t){return this.props.getSnapshotBeforeUpdate?this.props.getSnapshotBeforeUpdate(Object.assign(this.getArgs(),{prevProps:m(e),prevState:t})):null},t.prototype.render=function(){var e=this.props,t=e.children,n=e.render;return n?n(this.getArgs()):"function"==typeof t?t(this.getArgs()):t||null},t}(l.a.Component);v.defaultProps={getInitialState:function(){},getRefs:function(){return{}}};var g=function(){var e=this;this.state=this.props.initialState||this.props.getInitialState(this.props),this._refs=this.props.refs||this.props.getRefs(this.getArgs()),this._setState=function(){return e.setState.apply(e,arguments)},this._forceUpdate=function(){return e.forceUpdate.apply(e,arguments)}},y=v,b=function(e){var t=e.children,n=e.container,o=void 0===n?document.body:n,i=e.type,a=void 0===i?"reach-portal":i;return Object(r.createElement)(y,{getRefs:function(){return{node:null}},didMount:function(e){var t=e.refs,n=e.forceUpdate,r=o.hasOwnProperty("current")?o.current:o;t.node=document.createElement(a),r.appendChild(t.node),n()},willUnmount:function(e){var t=e.refs.node,n=o.hasOwnProperty("current")?o.current:o;n&&n.removeChild(t)},render:function(e){var n=e.refs.node;return n?Object(r.createPortal)(t,n):null}})};var I=function(e,t){return function(n){if(e&&e(n),!n.defaultPrevented)return t(n)}},w=n(8),O=n.n(w);function S(){return(S=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function x(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var E=function(){},j=function(){},C=function(e,t){var n,r,o;e.disposeAriaHider=(n=e.overlayNode,r=[],o=[],Array.prototype.forEach.call(document.querySelectorAll("body > *"),(function(e){if(e!==n.parentNode){var t=e.getAttribute("aria-hidden");null!==t&&"false"!==t||(r.push(t),o.push(e),e.setAttribute("aria-hidden","true"))}})),function(){o.forEach((function(e,t){var n=r[t];null===n?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n)}))}),e.trap=O()(e.overlayNode,{initialFocus:t?function(){return t.current}:void 0,fallbackFocus:e.contentNode,escapeDeactivates:!1,clickOutsideDeactivates:!1})},_=function(e){var t=e.refs;t.trap.deactivate(),t.disposeAriaHider()},P=React.createContext(),A=React.forwardRef((function(e,t){var n=e.container,o=e.isOpen,i=void 0===o||o,a=e.onDismiss,u=void 0===a?E:a,c=e.initialFocusRef,s=e.onClick,l=e.onKeyDown,d=x(e,["container","isOpen","onDismiss","initialFocusRef","onClick","onKeyDown"]);return Object(r.createElement)(y,{didMount:j},i?Object(r.createElement)(b,{container:n,"data-reach-dialog-wrapper":!0},Object(r.createElement)(y,{refs:{overlayNode:null,contentNode:null},didMount:function(e){var t=e.refs;C(t,c)},willUnmount:_},(function(e){var n=e.refs;return Object(r.createElement)(P.Provider,{value:function(e){return n.contentNode=e}},Object(r.createElement)("div",S({"data-reach-dialog-overlay":!0,onClick:I(s,(function(e){e.stopPropagation(),u()})),onKeyDown:I(l,(function(e){"Escape"===e.key&&(e.stopPropagation(),u())})),ref:function(e){n.overlayNode=e,t&&t(e)}},d)))}))):null)}));A.propTypes={initialFocusRef:function(){}};var k=function(e){return e.stopPropagation()},D=React.forwardRef((function(e,t){var n=e.onClick,o=(e.onKeyDown,x(e,["onClick","onKeyDown"]));return Object(r.createElement)(P.Consumer,null,(function(e){return Object(r.createElement)("div",S({"aria-modal":"true","data-reach-dialog-content":!0,tabIndex:"-1",onClick:I(n,k),ref:function(n){e(n),t&&t(n)}},o))}))})),M=n(5),T=function(e){return!!e},H=function(e){var t=e.items,n=e.isVisible,o=void 0===n?T:n,i=e.render,a=e.className,u=e.onDismiss;return Object(r.createElement)(M.Transition,{items:t,onStart:function(){return document.body.classList[o(t)?"add":"remove"]("ct-dashboard-overlay-open")},config:{duration:200},from:{opacity:0,y:-10},enter:{opacity:1,y:0},leave:{opacity:0,y:10}},(function(e){return o(e)&&function(t){return Object(r.createElement)(A,{style:{opacity:t.opacity},container:document.querySelector("#wpbody"),onDismiss:function(){return u()}},Object(r.createElement)(D,{className:c()("ct-admin-modal",a),style:{transform:"translate3d(0px, ".concat(t.y,"px, 0px)")}},Object(r.createElement)("button",{className:"close-button",onClick:function(){return u()}},"×"),i(e,t)))}}))};function R(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return N(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return N(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function N(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var L=function(e){var t=R(Object(r.useState)(!1),2),n=t[0],o=t[1];return[function(){return o(!0)},Object(r.createElement)(H,{items:n,onDismiss:function(){return o(!1)},render:function(){return Object(r.createElement)("div",{className:"ct-modal-content",dangerouslySetInnerHTML:{__html:e.readme}})}})]};function U(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}function K(){return(K=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function F(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}n(6);function V(e){return null!=e&&"object"==typeof e&&1===e.nodeType}function B(e,t){return(!t||"hidden"!==e)&&("visible"!==e&&"clip"!==e)}function $(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return B(n.overflowY,t)||B(n.overflowX,t)||function(e){var t=function(e){return e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView.frameElement:null}(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)}(e)}return!1}function W(e,t,n,r,o,i,a,u){return i<e&&a>t||i>e&&a<t?0:i<=e&&u<=n||a>=t&&u>=n?i-e-r:a>t&&u<n||i<e&&u>n?a-t+o:0}var z=0;function q(e){return"function"==typeof e?e:Y}function Y(){}function X(e,t){null!==e&&function(e,t){var n=t.scrollMode,r=t.block,o=t.inline,i=t.boundary,a=t.skipOverflowHiddenElements,u="function"==typeof i?i:function(e){return e!==i};if(!V(e))throw new TypeError("Invalid target");for(var c=document.scrollingElement||document.documentElement,s=[],l=e;V(l)&&u(l);){if((l=l.parentNode)===c){s.push(l);break}l===document.body&&$(l)&&!$(document.documentElement)||$(l,a)&&s.push(l)}for(var d=window.visualViewport?visualViewport.width:innerWidth,p=window.visualViewport?visualViewport.height:innerHeight,f=window.scrollX||pageXOffset,h=window.scrollY||pageYOffset,m=e.getBoundingClientRect(),v=m.height,g=m.width,y=m.top,b=m.right,I=m.bottom,w=m.left,O="start"===r||"nearest"===r?y:"end"===r?I:y+v/2,S="center"===o?w+g/2:"end"===o?b:w,x=[],E=0;E<s.length;E++){var j=s[E],C=j.getBoundingClientRect(),_=C.height,P=C.width,A=C.top,k=C.right,D=C.bottom,M=C.left;if("if-needed"===n&&y>=0&&w>=0&&I<=p&&b<=d&&y>=A&&I<=D&&w>=M&&b<=k)return x;var T=getComputedStyle(j),H=parseInt(T.borderLeftWidth,10),R=parseInt(T.borderTopWidth,10),N=parseInt(T.borderRightWidth,10),L=parseInt(T.borderBottomWidth,10),U=0,K=0,F="offsetWidth"in j?j.offsetWidth-j.clientWidth-H-N:0,B="offsetHeight"in j?j.offsetHeight-j.clientHeight-R-L:0;if(c===j)U="start"===r?O:"end"===r?O-p:"nearest"===r?W(h,h+p,p,R,L,h+O,h+O+v,v):O-p/2,K="start"===o?S:"center"===o?S-d/2:"end"===o?S-d:W(f,f+d,d,H,N,f+S,f+S+g,g),U=Math.max(0,U+h),K=Math.max(0,K+f);else{U="start"===r?O-A-R:"end"===r?O-D+L+B:"nearest"===r?W(A,D,_,R,L+B,O,O+v,v):O-(A+_/2)+B/2,K="start"===o?S-M-H:"center"===o?S-(M+P/2)+F/2:"end"===o?S-k+N+F:W(M,k,P,H,N+F,S,S+g,g);var z=j.scrollLeft,q=j.scrollTop;O+=q-(U=Math.max(0,Math.min(q+U,j.scrollHeight-_+B))),S+=z-(K=Math.max(0,Math.min(z+K,j.scrollWidth-P+F)))}x.push({el:j,top:U,left:K})}return x}(e,{boundary:t,block:"nearest",scrollMode:"if-needed"}).forEach((function(e){var t=e.el,n=e.top,r=e.left;t.scrollTop=n,t.scrollLeft=r}))}function G(e,t){return e===t||e.contains&&e.contains(t)}function J(e,t){var n;function r(){n&&clearTimeout(n)}function o(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];r(),n=setTimeout((function(){n=null,e.apply(void 0,i)}),t)}return o.cancel=r,o}function Q(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return t.some((function(t){return t&&t.apply(void 0,[e].concat(r)),e.preventDownshiftDefault||e.hasOwnProperty("nativeEvent")&&e.nativeEvent.preventDownshiftDefault}))}}function Z(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){t.forEach((function(t){"function"==typeof t?t(e):t&&(t.current=e)}))}}function ee(e){var t=e.isOpen,n=e.selectedItem,r=e.resultCount,o=e.previousResultCount,i=e.itemToString;return t?r?r!==o?r+" result"+(1===r?" is":"s are")+" available, use up and down arrow keys to navigate. Press Enter key to select.":"":"No results are available.":n?i(n):""}function te(e,t){return!(e=Array.isArray(e)?e[0]:e)&&t?t:e}function ne(e){return"string"==typeof e.type}function re(e){return e.props}var oe=["highlightedIndex","inputValue","isOpen","selectedItem","type"];function ie(e){void 0===e&&(e={});var t={};return oe.forEach((function(n){e.hasOwnProperty(n)&&(t[n]=e[n])})),t}function ae(e){var t=e.key,n=e.keyCode;return n>=37&&n<=40&&0!==t.indexOf("Arrow")?"Arrow"+t:t}function ue(e,t,n){var r=n-1;("number"!=typeof t||t<0||t>=n)&&(t=e>0?-1:r+1);var o=t+e;return o<0?o=r:o>r&&(o=0),o}var ce=J((function(){le().textContent=""}),500);function se(e,t){var n=le(t);e&&(n.textContent=e,ce())}function le(e){void 0===e&&(e=document);var t=e.getElementById("a11y-status-message");return t||((t=e.createElement("div")).setAttribute("id","a11y-status-message"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions text"),Object.assign(t.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),e.body.appendChild(t),t)}var de=Object.freeze({__proto__:null,unknown:0,mouseUp:1,itemMouseEnter:2,keyDownArrowUp:3,keyDownArrowDown:4,keyDownEscape:5,keyDownEnter:6,keyDownHome:7,keyDownEnd:8,clickItem:9,blurInput:10,changeInput:11,keyDownSpaceButton:12,clickButton:13,blurButton:14,controlledPropUpdatedSelectedItem:15,touchEnd:16}),pe=function(){var e=function(e){var t,n;function r(t){var n=e.call(this,t)||this;n.id=n.props.id||"downshift-"+String(z++),n.menuId=n.props.menuId||n.id+"-menu",n.labelId=n.props.labelId||n.id+"-label",n.inputId=n.props.inputId||n.id+"-input",n.getItemId=n.props.getItemId||function(e){return n.id+"-item-"+e},n.input=null,n.items=[],n.itemCount=null,n.previousResultCount=0,n.timeoutIds=[],n.internalSetTimeout=function(e,t){var r=setTimeout((function(){n.timeoutIds=n.timeoutIds.filter((function(e){return e!==r})),e()}),t);n.timeoutIds.push(r)},n.setItemCount=function(e){n.itemCount=e},n.unsetItemCount=function(){n.itemCount=null},n.setHighlightedIndex=function(e,t){void 0===e&&(e=n.props.defaultHighlightedIndex),void 0===t&&(t={}),t=ie(t),n.internalSetState(K({highlightedIndex:e},t))},n.clearSelection=function(e){n.internalSetState({selectedItem:null,inputValue:"",highlightedIndex:n.props.defaultHighlightedIndex,isOpen:n.props.defaultIsOpen},e)},n.selectItem=function(e,t,r){t=ie(t),n.internalSetState(K({isOpen:n.props.defaultIsOpen,highlightedIndex:n.props.defaultHighlightedIndex,selectedItem:e,inputValue:n.props.itemToString(e)},t),r)},n.selectItemAtIndex=function(e,t,r){var o=n.items[e];null!=o&&n.selectItem(o,t,r)},n.selectHighlightedItem=function(e,t){return n.selectItemAtIndex(n.getState().highlightedIndex,e,t)},n.internalSetState=function(e,t){var r,o,i={},a="function"==typeof e;return!a&&e.hasOwnProperty("inputValue")&&n.props.onInputValueChange(e.inputValue,K({},n.getStateAndHelpers(),{},e)),n.setState((function(t){t=n.getState(t);var u=a?e(t):e;u=n.props.stateReducer(t,u),r=u.hasOwnProperty("selectedItem");var c={},s={};return r&&u.selectedItem!==t.selectedItem&&(o=u.selectedItem),u.type=u.type||0,Object.keys(u).forEach((function(e){t[e]!==u[e]&&(i[e]=u[e]),"type"!==e&&(s[e]=u[e],n.isControlledProp(e)||(c[e]=u[e]))})),a&&u.hasOwnProperty("inputValue")&&n.props.onInputValueChange(u.inputValue,K({},n.getStateAndHelpers(),{},u)),c}),(function(){q(t)(),Object.keys(i).length>1&&n.props.onStateChange(i,n.getStateAndHelpers()),r&&n.props.onSelect(e.selectedItem,n.getStateAndHelpers()),void 0!==o&&n.props.onChange(o,n.getStateAndHelpers()),n.props.onUserAction(i,n.getStateAndHelpers())}))},n.rootRef=function(e){return n._rootNode=e},n.getRootProps=function(e,t){var r,o=void 0===e?{}:e,i=o.refKey,a=void 0===i?"ref":i,u=o.ref,c=U(o,["refKey","ref"]),s=(void 0===t?{}:t).suppressRefError,l=void 0!==s&&s;n.getRootProps.called=!0,n.getRootProps.refKey=a,n.getRootProps.suppressRefError=l;var d=n.getState().isOpen;return K(((r={})[a]=Z(u,n.rootRef),r.role="combobox",r["aria-expanded"]=d,r["aria-haspopup"]="listbox",r["aria-owns"]=d?n.menuId:null,r["aria-labelledby"]=n.labelId,r),c)},n.keyDownHandlers={ArrowDown:function(e){var t=this;if(e.preventDefault(),this.getState().isOpen){var n=e.shiftKey?5:1;this.moveHighlightedIndex(n,{type:4})}else this.internalSetState({isOpen:!0,type:4},(function(){var e=t.getItemCount();e>0&&t.setHighlightedIndex(ue(1,t.getState().highlightedIndex,e),{type:4})}))},ArrowUp:function(e){var t=this;if(e.preventDefault(),this.getState().isOpen){var n=e.shiftKey?-5:-1;this.moveHighlightedIndex(n,{type:3})}else this.internalSetState({isOpen:!0,type:3},(function(){var e=t.getItemCount();e>0&&t.setHighlightedIndex(ue(-1,t.getState().highlightedIndex,e),{type:4})}))},Enter:function(e){var t=this.getState(),n=t.isOpen,r=t.highlightedIndex;if(n&&null!=r){e.preventDefault();var o=this.items[r],i=this.getItemNodeFromIndex(r);if(null==o||i&&i.hasAttribute("disabled"))return;this.selectHighlightedItem({type:6})}},Escape:function(e){e.preventDefault(),this.reset({type:5,selectedItem:null,inputValue:""})}},n.buttonKeyDownHandlers=K({},n.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu({type:12})}}),n.inputKeyDownHandlers=K({},n.keyDownHandlers,{Home:function(e){this.highlightFirstOrLastIndex(e,!0,{type:7})},End:function(e){this.highlightFirstOrLastIndex(e,!1,{type:8})}}),n.getToggleButtonProps=function(e){var t=void 0===e?{}:e,r=t.onClick,o=(t.onPress,t.onKeyDown),i=t.onKeyUp,a=t.onBlur,u=U(t,["onClick","onPress","onKeyDown","onKeyUp","onBlur"]),c=n.getState().isOpen,s={onClick:Q(r,n.buttonHandleClick),onKeyDown:Q(o,n.buttonHandleKeyDown),onKeyUp:Q(i,n.buttonHandleKeyUp),onBlur:Q(a,n.buttonHandleBlur)};return K({type:"button",role:"button","aria-label":c?"close menu":"open menu","aria-haspopup":!0,"data-toggle":!0},u.disabled?{}:s,{},u)},n.buttonHandleKeyUp=function(e){e.preventDefault()},n.buttonHandleKeyDown=function(e){var t=ae(e);n.buttonKeyDownHandlers[t]&&n.buttonKeyDownHandlers[t].call(F(n),e)},n.buttonHandleClick=function(e){e.preventDefault(),n.props.environment.document.activeElement===n.props.environment.document.body&&e.target.focus(),n.internalSetTimeout((function(){return n.toggleMenu({type:13})}))},n.buttonHandleBlur=function(e){var t=e.target;n.internalSetTimeout((function(){n.isMouseDown||null!=n.props.environment.document.activeElement&&n.props.environment.document.activeElement.id===n.inputId||n.props.environment.document.activeElement===t||n.reset({type:14})}))},n.getLabelProps=function(e){return K({htmlFor:n.inputId,id:n.labelId},e)},n.getInputProps=function(e){var t=void 0===e?{}:e,r=t.onKeyDown,o=t.onBlur,i=t.onChange,a=t.onInput,u=(t.onChangeText,U(t,["onKeyDown","onBlur","onChange","onInput","onChangeText"])),c={};var s,l=n.getState(),d=l.inputValue,p=l.isOpen,f=l.highlightedIndex;u.disabled||((s={}).onChange=Q(i,a,n.inputHandleChange),s.onKeyDown=Q(r,n.inputHandleKeyDown),s.onBlur=Q(o,n.inputHandleBlur),c=s);return K({"aria-autocomplete":"list","aria-activedescendant":p&&"number"==typeof f&&f>=0?n.getItemId(f):null,"aria-controls":p?n.menuId:null,"aria-labelledby":n.labelId,autoComplete:"off",value:d,id:n.inputId},c,{},u)},n.inputHandleKeyDown=function(e){var t=ae(e);t&&n.inputKeyDownHandlers[t]&&n.inputKeyDownHandlers[t].call(F(n),e)},n.inputHandleChange=function(e){n.internalSetState({type:11,isOpen:!0,inputValue:e.target.value,highlightedIndex:n.props.defaultHighlightedIndex})},n.inputHandleBlur=function(){n.internalSetTimeout((function(){var e=n.props.environment.document&&!!n.props.environment.document.activeElement&&!!n.props.environment.document.activeElement.dataset&&n.props.environment.document.activeElement.dataset.toggle&&n._rootNode&&n._rootNode.contains(n.props.environment.document.activeElement);n.isMouseDown||e||n.reset({type:10})}))},n.menuRef=function(e){n._menuNode=e},n.getMenuProps=function(e,t){var r,o=void 0===e?{}:e,i=o.refKey,a=void 0===i?"ref":i,u=o.ref,c=U(o,["refKey","ref"]),s=(void 0===t?{}:t).suppressRefError,l=void 0!==s&&s;return n.getMenuProps.called=!0,n.getMenuProps.refKey=a,n.getMenuProps.suppressRefError=l,K(((r={})[a]=Z(u,n.menuRef),r.role="listbox",r["aria-labelledby"]=c&&c["aria-label"]?null:n.labelId,r.id=n.menuId,r),c)},n.getItemProps=function(e){var t,r=void 0===e?{}:e,o=r.onMouseMove,i=r.onMouseDown,a=r.onClick,u=(r.onPress,r.index),c=r.item,s=void 0===c?void 0:c,l=U(r,["onMouseMove","onMouseDown","onClick","onPress","index","item"]);void 0===u?(n.items.push(s),u=n.items.indexOf(s)):n.items[u]=s;var d=a,p=((t={onMouseMove:Q(o,(function(){u!==n.getState().highlightedIndex&&(n.setHighlightedIndex(u,{type:2}),n.avoidScrolling=!0,n.internalSetTimeout((function(){return n.avoidScrolling=!1}),250))})),onMouseDown:Q(i,(function(e){e.preventDefault()}))}).onClick=Q(d,(function(){n.selectItemAtIndex(u,{type:9})})),t),f=l.disabled?{onMouseDown:p.onMouseDown}:p;return K({id:n.getItemId(u),role:"option","aria-selected":n.getState().highlightedIndex===u},f,{},l)},n.clearItems=function(){n.items=[]},n.reset=function(e,t){void 0===e&&(e={}),e=ie(e),n.internalSetState((function(t){var r=t.selectedItem;return K({isOpen:n.props.defaultIsOpen,highlightedIndex:n.props.defaultHighlightedIndex,inputValue:n.props.itemToString(r)},e)}),t)},n.toggleMenu=function(e,t){void 0===e&&(e={}),e=ie(e),n.internalSetState((function(t){var r=t.isOpen;return K({isOpen:!r},r&&{highlightedIndex:n.props.defaultHighlightedIndex},{},e)}),(function(){var r=n.getState(),o=r.isOpen,i=r.highlightedIndex;o&&n.getItemCount()>0&&"number"==typeof i&&n.setHighlightedIndex(i,e),q(t)()}))},n.openMenu=function(e){n.internalSetState({isOpen:!0},e)},n.closeMenu=function(e){n.internalSetState({isOpen:!1},e)},n.updateStatus=J((function(){var e=n.getState(),t=n.items[e.highlightedIndex],r=n.getItemCount(),o=n.props.getA11yStatusMessage(K({itemToString:n.props.itemToString,previousResultCount:n.previousResultCount,resultCount:r,highlightedItem:t},e));n.previousResultCount=r,se(o,n.props.environment.document)}),200);var r=n.props,o=r.defaultHighlightedIndex,i=r.initialHighlightedIndex,a=void 0===i?o:i,u=r.defaultIsOpen,c=r.initialIsOpen,s=void 0===c?u:c,l=r.initialInputValue,d=void 0===l?"":l,p=r.initialSelectedItem,f=void 0===p?null:p,h=n.getState({highlightedIndex:a,isOpen:s,inputValue:d,selectedItem:f});return null!=h.selectedItem&&void 0===n.props.initialInputValue&&(h.inputValue=n.props.itemToString(h.selectedItem)),n.state=h,n}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var o=r.prototype;return o.internalClearTimeouts=function(){this.timeoutIds.forEach((function(e){clearTimeout(e)})),this.timeoutIds=[]},o.getState=function(e){var t=this;return void 0===e&&(e=this.state),Object.keys(e).reduce((function(n,r){return n[r]=t.isControlledProp(r)?t.props[r]:e[r],n}),{})},o.isControlledProp=function(e){return void 0!==this.props[e]},o.getItemCount=function(){var e=this.items.length;return null!=this.itemCount?e=this.itemCount:void 0!==this.props.itemCount&&(e=this.props.itemCount),e},o.getItemNodeFromIndex=function(e){return this.props.environment.document.getElementById(this.getItemId(e))},o.scrollHighlightedItemIntoView=function(){var e=this.getItemNodeFromIndex(this.getState().highlightedIndex);this.props.scrollIntoView(e,this._menuNode)},o.moveHighlightedIndex=function(e,t){var n=this.getItemCount();if(n>0){var r=ue(e,this.getState().highlightedIndex,n);this.setHighlightedIndex(r,t)}},o.highlightFirstOrLastIndex=function(e,t,n){var r=this.getItemCount()-1;r<0||!this.getState().isOpen||(e.preventDefault(),this.setHighlightedIndex(t?0:r,n))},o.getStateAndHelpers=function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,r=e.selectedItem,o=e.isOpen,i=this.props.itemToString,a=this.id,u=this.getRootProps,c=this.getToggleButtonProps,s=this.getLabelProps,l=this.getMenuProps,d=this.getInputProps,p=this.getItemProps,f=this.openMenu,h=this.closeMenu,m=this.toggleMenu,v=this.selectItem,g=this.selectItemAtIndex,y=this.selectHighlightedItem,b=this.setHighlightedIndex,I=this.clearSelection,w=this.clearItems;return{getRootProps:u,getToggleButtonProps:c,getLabelProps:s,getMenuProps:l,getInputProps:d,getItemProps:p,reset:this.reset,openMenu:f,closeMenu:h,toggleMenu:m,selectItem:v,selectItemAtIndex:g,selectHighlightedItem:y,setHighlightedIndex:b,clearSelection:I,clearItems:w,setItemCount:this.setItemCount,unsetItemCount:this.unsetItemCount,setState:this.internalSetState,itemToString:i,id:a,highlightedIndex:t,inputValue:n,isOpen:o,selectedItem:r}},o.componentDidMount=function(){var e=this;var t=function(t,n){void 0===n&&(n=!0);var r=e.props.environment.document;return[e._rootNode,e._menuNode].some((function(e){return e&&(G(e,t)||n&&G(e,r.activeElement))}))},n=function(){e.isMouseDown=!0},r=function(n){e.isMouseDown=!1,!t(n.target)&&e.getState().isOpen&&e.reset({type:1},(function(){return e.props.onOuterClick(e.getStateAndHelpers())}))},o=function(){e.isTouchMove=!1},i=function(){e.isTouchMove=!0},a=function(n){var r=t(n.target,!1);e.isTouchMove||r||!e.getState().isOpen||e.reset({type:16},(function(){return e.props.onOuterClick(e.getStateAndHelpers())}))},u=this.props.environment;u.addEventListener("mousedown",n),u.addEventListener("mouseup",r),u.addEventListener("touchstart",o),u.addEventListener("touchmove",i),u.addEventListener("touchend",a),this.cleanup=function(){e.internalClearTimeouts(),e.updateStatus.cancel(),u.removeEventListener("mousedown",n),u.removeEventListener("mouseup",r),u.removeEventListener("touchstart",o),u.removeEventListener("touchmove",i),u.removeEventListener("touchend",a)}},o.shouldScroll=function(e,t){var n=(void 0===this.props.highlightedIndex?this.getState():this.props).highlightedIndex,r=(void 0===t.highlightedIndex?e:t).highlightedIndex;return n&&this.getState().isOpen&&!e.isOpen||n!==r},o.componentDidUpdate=function(e,t){this.isControlledProp("selectedItem")&&this.props.selectedItemChanged(e.selectedItem,this.props.selectedItem)&&this.internalSetState({type:15,inputValue:this.props.itemToString(this.props.selectedItem)}),!this.avoidScrolling&&this.shouldScroll(t,e)&&this.scrollHighlightedItemIntoView(),this.updateStatus()},o.componentWillUnmount=function(){this.cleanup()},o.render=function(){var e=te(this.props.children,Y);this.clearItems(),this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getRootProps.suppressRefError=void 0,this.getMenuProps.called=!1,this.getMenuProps.refKey=void 0,this.getMenuProps.suppressRefError=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=te(e(this.getStateAndHelpers()));return t?this.getRootProps.called||this.props.suppressRefError?t:ne(t)?Object(s.cloneElement)(t,this.getRootProps(re(t))):void 0:null},r}(s.Component);return e.defaultProps={defaultHighlightedIndex:null,defaultIsOpen:!1,getA11yStatusMessage:ee,itemToString:function(e){return null==e?"":String(e)},onStateChange:Y,onInputValueChange:Y,onUserAction:Y,onChange:Y,onSelect:Y,onOuterClick:Y,selectedItemChanged:function(e,t){return e!==t},environment:"undefined"==typeof window?{}:window,stateReducer:function(e,t){return t},suppressRefError:!1,scrollIntoView:X},e.stateChangeTypes=de,e}();p.a.array.isRequired,p.a.func,p.a.func,p.a.func,p.a.bool,p.a.number,p.a.number,p.a.number,p.a.bool,p.a.bool,p.a.bool,p.a.any,p.a.any,p.a.any,p.a.string,p.a.string,p.a.string,p.a.func,p.a.string,p.a.func,p.a.func,p.a.func,p.a.func,p.a.func,p.a.shape({addEventListener:p.a.func,removeEventListener:p.a.func,document:p.a.shape({getElementById:p.a.func,activeElement:p.a.any,body:p.a.any})});"undefined"==typeof window||window;var fe=pe;function he(){return(he=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function me(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,o)}function ve(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return ge(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ge(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ge(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ye=function(e){var t=e.listId,n=e.apiKey,o=e.onChange,i=ve(Object(r.useState)([]),2),u=i[0],s=i[1],l=ve(Object(r.useState)(!1),2),d=l[0],p=l[1],f=ve(Object(r.useState)({controller:null}),2),h=f[0].controller,m=f[1],v=function(){var e,t=(e=regeneratorRuntime.mark((function e(){var t,r,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h&&h.abort(),p(!0),"AbortController"in window&&(h=new AbortController,m({controller:h})),(t=new FormData).append("api_key",n),t.append("action","blocksy_ext_mailchimp_maybe_get_lists"),e.prev=6,e.next=9,fetch(ctDashboardLocalizations.ajax_url,{method:"POST",signal:h.signal,body:t});case 9:if(200!==(r=e.sent).status){e.next=19;break}return e.next=13,r.json();case 13:if(!(o=e.sent).success){e.next=19;break}if("api_key_invalid"===o.data.result){e.next=19;break}return p(!1),s(o.data.result),e.abrupt("return");case 19:e.next=23;break;case 21:e.prev=21,e.t0=e.catch(6);case 23:s([]),p(!1);case 25:case"end":return e.stop()}}),e,null,[[6,21]])})),function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){me(i,r,o,a,u,"next",e)}function u(e){me(i,r,o,a,u,"throw",e)}a(void 0)}))});return function(){return t.apply(this,arguments)}}();return Object(r.useEffect)((function(){n&&-1!==n.indexOf("-")?v():s([])}),[n]),0===u.length?Object(r.createElement)("div",{className:"ct-select-input"},Object(r.createElement)("input",{disabled:!0,placeholder:d?Object(a.__)("Loading","blc"):Object(a.__)("Invalid API Key...","blc")})):Object(r.createElement)(fe,{selectedItem:t||"",onChange:function(e){return o(e)},itemToString:function(e){return e?(u.find((function(t){return t.id===e}))||{}).name:""}},(function(e){var t=e.getInputProps,n=e.getItemProps,o=(e.getLabelProps,e.getMenuProps),i=e.isOpen,s=(e.inputValue,e.highlightedIndex),l=e.selectedItem,d=e.openMenu;return Object(r.createElement)("div",{className:"ct-select-input"},Object(r.createElement)("input",he({},t({onFocus:function(){return d()},onClick:function(){return d()}}),{placeholder:Object(a.__)("Select list...","blc"),readOnly:!0})),i&&Object(r.createElement)("div",o({className:"ct-select-dropdown"}),u.map((function(e,t){return Object(r.createElement)("div",n({key:e.id,index:t,item:e.id,className:c()("ct-select-dropdown-item",{active:s===t,selected:l===e.id})}),e.name)}))))}))};function be(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,o)}function Ie(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return we(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return we(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function we(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Oe=function(e){var t=e.extension,n=e.isEditingCredentials,o=e.setIsEditingCredentials,i=e.onCredentialsValidated,u=Ie(Object(r.useState)(t.data.api_key),2),s=u[0],l=u[1],d=Ie(Object(r.useState)(t.data.list_id),2),p=d[0],f=d[1],h=Ie(Object(r.useState)(!1),2),m=h[0],v=h[1],g=Ie(Object(r.useState)(!1),2),y=g[0],b=g[1],I=function(){var e,t=(e=regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=new FormData).append("api_key",s),t.append("list_id",p),t.append("action","blocksy_ext_mailchimp_maybe_save_credentials"),v(!0),e.prev=5,e.next=8,fetch(ctDashboardLocalizations.ajax_url,{method:"POST",body:t});case 8:if(200!==(n=e.sent).status){e.next=14;break}return e.next=12,n.json();case 12:(r=e.sent).success&&"api_key_invalid"!==r.data.result&&(i(),b(!1));case 14:b(!0),e.next=20;break;case 17:e.prev=17,e.t0=e.catch(5),b(!0);case 20:return e.next=22,new Promise((function(e){return setTimeout((function(){return e()}),1e3)}));case 22:v(!1);case 23:case"end":return e.stop()}}),e,null,[[5,17]])})),function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){be(i,r,o,a,u,"next",e)}function u(e){be(i,r,o,a,u,"throw",e)}a(void 0)}))});return function(){return t.apply(this,arguments)}}();return Object(r.createElement)(H,{items:n,onDismiss:function(){return o(!1)},className:"ct-mailchimp-modal",render:function(){return Object(r.createElement)("div",{className:c()("ct-modal-content",{"ct-key-invalid":y})},Object(r.createElement)("h2",null,Object(a.__)("API Credentials","blc")),Object(r.createElement)("p",{dangerouslySetInnerHTML:{__html:Object(a.sprintf)(Object(a.__)("Enter your Mailchimp API credentials in the form below. More info on how to generate an API key can be found %shere%s.","blc"),'<a target="_blank" href="https://mailchimp.com/help/about-api-keys/">',"</a>")}}),null,Object(r.createElement)("div",{className:"mailchimp-credentials"},Object(r.createElement)("section",null,Object(r.createElement)("label",null,Object(a.__)("API Key","blc")),Object(r.createElement)("div",{className:"ct-option-input"},Object(r.createElement)("input",{type:"text",onChange:function(e){var t=e.target.value;return l(t)},value:s||""}))),Object(r.createElement)("section",null,Object(r.createElement)("label",null,Object(a.__)("List ID","blc")),Object(r.createElement)(ye,{listId:p,onChange:function(e){return f(e)},apiKey:s})),Object(r.createElement)("section",null,Object(r.createElement)("label",null," "),Object(r.createElement)("button",{className:"ct-button","data-button":"blue",disabled:!s||!p||m,onClick:function(){return I()}},m?Object(a.__)("Loading...","blc"):t.__object?Object(a.__)("Save Settings","blc"):Object(a.__)("Activate","blc")))))}})};function Se(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,o)}function xe(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){Se(i,r,o,a,u,"next",e)}function u(e){Se(i,r,o,a,u,"throw",e)}a(void 0)}))}}function Ee(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return je(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return je(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function je(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ce=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},n=Object(r.useState)(!1),o=Ee(n,2),i=o[0],u=o[1],c=Object(r.useState)(!1),s=Ee(c,2),l=s[0],d=s[1],p=function(){var n=xe(regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return(r=new FormData).append("ext",e.name),r.append("action",e.__object?"blocksy_extension_deactivate":"blocksy_extension_activate"),u(!0),n.prev=4,n.next=7,fetch(ctDashboardLocalizations.ajax_url,{method:"POST",body:r});case 7:t(),n.next=12;break;case 10:n.prev=10,n.t0=n.catch(4);case 12:u(!1);case 13:case"end":return n.stop()}}),n,null,[[4,10]])})));return function(){return n.apply(this,arguments)}}(),f=function(){e.__object||e.data.api_key?p():d(!0)};return[i,f,Object(r.createElement)(r.Fragment,null,e.__object&&e.data.api_key&&Object(r.createElement)("button",{className:"ct-button ct-config-btn","data-button":"white",title:"Edit Credentials",onClick:function(){return d(!0)}},Object(a.__)("Configure","blc")),Object(r.createElement)(Oe,{isEditingCredentials:l,setIsEditingCredentials:d,extension:e,onCredentialsValidated:function(){e.__object||p(),d(!1)}}))]};function _e(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Pe(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Pe(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Pe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ae=function(e){var t=e.extension,n=e.onExtsSync,o=_e(Ce(t,(function(){n()})),3),i=o[0],u=o[1],s=o[2],l=_e(L(t),2),d=l[0],p=l[1];return Object(r.createElement)("li",{className:c()({active:!!t.__object})},Object(r.createElement)("h4",{className:"ct-extension-title"},t.config.name,i&&Object(r.createElement)("svg",{width:"15",height:"15",viewBox:"0 0 100 100"},Object(r.createElement)("g",{transform:"translate(50,50)"},Object(r.createElement)("g",{transform:"scale(1)"},Object(r.createElement)("circle",{cx:"0",cy:"0",r:"50",fill:"#687c93"}),Object(r.createElement)("circle",{cx:"0",cy:"-26",r:"12",fill:"#ffffff",transform:"rotate(161.634)"},Object(r.createElement)("animateTransform",{attributeName:"transform",type:"rotate",calcMode:"linear",values:"0 0 0;360 0 0",keyTimes:"0;1",dur:"1s",begin:"0s",repeatCount:"indefinite"})))))),t.config.description&&Object(r.createElement)("div",{className:"ct-extension-description"},t.config.description),Object(r.createElement)("div",{className:"ct-extension-actions"},Object(r.createElement)("button",{className:c()(t.__object?"ct-button":"ct-button-primary"),"data-button":"white",disabled:i,onClick:function(){return u()}},t.__object?Object(a.__)("Deactivate","blc"):Object(a.__)("Activate","blc")),s,t.readme&&Object(r.createElement)("button",{onClick:function(){return d()},"data-button":"white",className:"ct-minimal-button ct-instruction"},Object(r.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24"},Object(r.createElement)("path",{d:"M12,2C6.477,2,2,6.477,2,12s4.477,10,10,10s10-4.477,10-10S17.523,2,12,2z M12,17L12,17c-0.552,0-1-0.448-1-1v-4 c0-0.552,0.448-1,1-1h0c0.552,0,1,0.448,1,1v4C13,16.552,12.552,17,12,17z M12.5,9h-1C11.224,9,11,8.776,11,8.5v-1 C11,7.224,11.224,7,11.5,7h1C12.776,7,13,7.224,13,7.5v1C13,8.776,12.776,9,12.5,9z"})))),p)};i.a.on("ct:extensions:card",(function(e){var t=e.CustomComponent;"mailchimp"===e.extension.name&&(t.extension=Ae)}))}]);
|
trunk/framework/extensions/mailchimp/dashboard-static/js/EditCredentials.js
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import {
|
2 |
+
createElement,
|
3 |
+
Component,
|
4 |
+
useEffect,
|
5 |
+
useState,
|
6 |
+
Fragment,
|
7 |
+
} from '@wordpress/element'
|
8 |
+
|
9 |
+
import classnames from 'classnames'
|
10 |
+
import { __, sprintf } from 'ct-i18n'
|
11 |
+
import ListPicker from './ListPicker'
|
12 |
+
import Overlay from '../../../../../static/js/helpers/Overlay'
|
13 |
+
import { Select } from 'blocksy-options'
|
14 |
+
|
15 |
+
const EditCredentials = ({
|
16 |
+
extension,
|
17 |
+
isEditingCredentials,
|
18 |
+
setIsEditingCredentials,
|
19 |
+
onCredentialsValidated,
|
20 |
+
}) => {
|
21 |
+
const [apiKey, setApiKey] = useState(extension.data.api_key)
|
22 |
+
const [listId, setListId] = useState(extension.data.list_id)
|
23 |
+
const [isLoading, setIsLoading] = useState(false)
|
24 |
+
const [isApiKeyInvalid, makeKeyInvalid] = useState(false)
|
25 |
+
|
26 |
+
const attemptToSaveCredentials = async () => {
|
27 |
+
const body = new FormData()
|
28 |
+
|
29 |
+
body.append('api_key', apiKey)
|
30 |
+
body.append('list_id', listId)
|
31 |
+
|
32 |
+
body.append('action', 'blocksy_ext_mailchimp_maybe_save_credentials')
|
33 |
+
|
34 |
+
setIsLoading(true)
|
35 |
+
|
36 |
+
try {
|
37 |
+
const response = await fetch(ctDashboardLocalizations.ajax_url, {
|
38 |
+
method: 'POST',
|
39 |
+
body,
|
40 |
+
})
|
41 |
+
|
42 |
+
if (response.status === 200) {
|
43 |
+
const body = await response.json()
|
44 |
+
|
45 |
+
if (body.success) {
|
46 |
+
if (body.data.result !== 'api_key_invalid') {
|
47 |
+
onCredentialsValidated()
|
48 |
+
makeKeyInvalid(false)
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
makeKeyInvalid(true)
|
54 |
+
} catch (e) {
|
55 |
+
makeKeyInvalid(true)
|
56 |
+
}
|
57 |
+
|
58 |
+
await new Promise((r) => setTimeout(() => r(), 1000))
|
59 |
+
|
60 |
+
setIsLoading(false)
|
61 |
+
}
|
62 |
+
|
63 |
+
return (
|
64 |
+
<Overlay
|
65 |
+
items={isEditingCredentials}
|
66 |
+
onDismiss={() => setIsEditingCredentials(false)}
|
67 |
+
className={'ct-mailchimp-modal'}
|
68 |
+
render={() => (
|
69 |
+
<div
|
70 |
+
className={classnames('ct-modal-content', {
|
71 |
+
'ct-key-invalid': isApiKeyInvalid,
|
72 |
+
})}>
|
73 |
+
<h2>{__('API Credentials', 'blc')}</h2>
|
74 |
+
|
75 |
+
<p
|
76 |
+
dangerouslySetInnerHTML={{
|
77 |
+
__html: sprintf(
|
78 |
+
__(
|
79 |
+
'Enter your Mailchimp API credentials in the form below. More info on how to generate an API key can be found %shere%s.',
|
80 |
+
'blc'
|
81 |
+
),
|
82 |
+
'<a target="_blank" href="https://mailchimp.com/help/about-api-keys/">',
|
83 |
+
'</a>'
|
84 |
+
),
|
85 |
+
}}
|
86 |
+
/>
|
87 |
+
|
88 |
+
{null && (
|
89 |
+
<Fragment>
|
90 |
+
<h4>{__('Pick service', 'blc')}</h4>
|
91 |
+
|
92 |
+
<Select
|
93 |
+
onChange={(copy) => {}}
|
94 |
+
option={{
|
95 |
+
placeholder: __(
|
96 |
+
'Pick Mailing Service',
|
97 |
+
'blocksy'
|
98 |
+
),
|
99 |
+
choices: [
|
100 |
+
{
|
101 |
+
key: 'mailchimp',
|
102 |
+
value: 'Mailchimp',
|
103 |
+
},
|
104 |
+
],
|
105 |
+
}}
|
106 |
+
value={'mailchimp'}
|
107 |
+
/>
|
108 |
+
</Fragment>
|
109 |
+
)}
|
110 |
+
|
111 |
+
<div className="mailchimp-credentials">
|
112 |
+
<section>
|
113 |
+
<label>{__('API Key', 'blc')}</label>
|
114 |
+
|
115 |
+
<div className="ct-option-input">
|
116 |
+
<input
|
117 |
+
type="text"
|
118 |
+
onChange={({ target: { value } }) =>
|
119 |
+
setApiKey(value)
|
120 |
+
}
|
121 |
+
value={apiKey || ''}
|
122 |
+
/>
|
123 |
+
</div>
|
124 |
+
</section>
|
125 |
+
|
126 |
+
<section>
|
127 |
+
<label>{__('List ID', 'blc')}</label>
|
128 |
+
|
129 |
+
<ListPicker
|
130 |
+
listId={listId}
|
131 |
+
onChange={(id) => setListId(id)}
|
132 |
+
apiKey={apiKey}
|
133 |
+
/>
|
134 |
+
</section>
|
135 |
+
|
136 |
+
<section>
|
137 |
+
<label> </label>
|
138 |
+
<button
|
139 |
+
className="ct-button"
|
140 |
+
data-button="blue"
|
141 |
+
disabled={!apiKey || !listId || isLoading}
|
142 |
+
onClick={() => attemptToSaveCredentials()}>
|
143 |
+
{isLoading
|
144 |
+
? __('Loading...', 'blc')
|
145 |
+
: !extension.__object
|
146 |
+
? __('Activate', 'blc')
|
147 |
+
: __('Save Settings', 'blc')}
|
148 |
+
</button>
|
149 |
+
</section>
|
150 |
+
</div>
|
151 |
+
</div>
|
152 |
+
)}
|
153 |
+
/>
|
154 |
+
)
|
155 |
+
}
|
156 |
+
|
157 |
+
export default EditCredentials
|
trunk/framework/extensions/mailchimp/dashboard-static/js/ListPicker.js
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import {
|
2 |
+
createElement,
|
3 |
+
Component,
|
4 |
+
useEffect,
|
5 |
+
useState,
|
6 |
+
Fragment,
|
7 |
+
} from '@wordpress/element'
|
8 |
+
import Downshift from 'downshift'
|
9 |
+
import { __ } from 'ct-i18n'
|
10 |
+
import classnames from 'classnames'
|
11 |
+
|
12 |
+
const ListPicker = ({ listId, apiKey, onChange }) => {
|
13 |
+
const [lists, setLists] = useState([])
|
14 |
+
const [isLoadingLists, setListsLoading] = useState(false)
|
15 |
+
|
16 |
+
let [{ controller }, setAbortState] = useState({
|
17 |
+
controller: null,
|
18 |
+
})
|
19 |
+
|
20 |
+
const maybeFetchLists = async () => {
|
21 |
+
if (controller) {
|
22 |
+
controller.abort()
|
23 |
+
}
|
24 |
+
|
25 |
+
setListsLoading(true)
|
26 |
+
|
27 |
+
if ('AbortController' in window) {
|
28 |
+
controller = new AbortController()
|
29 |
+
|
30 |
+
setAbortState({
|
31 |
+
controller,
|
32 |
+
})
|
33 |
+
}
|
34 |
+
|
35 |
+
const body = new FormData()
|
36 |
+
|
37 |
+
body.append('api_key', apiKey)
|
38 |
+
body.append('action', 'blocksy_ext_mailchimp_maybe_get_lists')
|
39 |
+
|
40 |
+
try {
|
41 |
+
const response = await fetch(ctDashboardLocalizations.ajax_url, {
|
42 |
+
method: 'POST',
|
43 |
+
signal: controller.signal,
|
44 |
+
body,
|
45 |
+
})
|
46 |
+
if (response.status === 200) {
|
47 |
+
const body = await response.json()
|
48 |
+
|
49 |
+
if (body.success) {
|
50 |
+
if (body.data.result !== 'api_key_invalid') {
|
51 |
+
setListsLoading(false)
|
52 |
+
setLists(body.data.result)
|
53 |
+
|
54 |
+
return
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
} catch (e) {}
|
59 |
+
|
60 |
+
setLists([])
|
61 |
+
setListsLoading(false)
|
62 |
+
}
|
63 |
+
|
64 |
+
useEffect(() => {
|
65 |
+
if (!apiKey) {
|
66 |
+
setLists([])
|
67 |
+
return
|
68 |
+
}
|
69 |
+
|
70 |
+
if (apiKey.indexOf('-') === -1) {
|
71 |
+
setLists([])
|
72 |
+
return
|
73 |
+
}
|
74 |
+
|
75 |
+
maybeFetchLists()
|
76 |
+
}, [apiKey])
|
77 |
+
|
78 |
+
return lists.length === 0 ? (
|
79 |
+
<div className="ct-select-input">
|
80 |
+
<input
|
81 |
+
disabled
|
82 |
+
placeholder={
|
83 |
+
isLoadingLists
|
84 |
+
? __('Loading', 'blc')
|
85 |
+
: __('Invalid API Key...', 'blc')
|
86 |
+
}
|
87 |
+
/>
|
88 |
+
</div>
|
89 |
+
) : (
|
90 |
+
<Downshift
|
91 |
+
selectedItem={listId || ''}
|
92 |
+
onChange={(selection) => onChange(selection)}
|
93 |
+
itemToString={(item) =>
|
94 |
+
item ? (lists.find(({ id }) => id === item) || {}).name : ''
|
95 |
+
}>
|
96 |
+
{({
|
97 |
+
getInputProps,
|
98 |
+
getItemProps,
|
99 |
+
getLabelProps,
|
100 |
+
getMenuProps,
|
101 |
+
isOpen,
|
102 |
+
inputValue,
|
103 |
+
highlightedIndex,
|
104 |
+
selectedItem,
|
105 |
+
openMenu,
|
106 |
+
}) => (
|
107 |
+
<div className="ct-select-input">
|
108 |
+
<input
|
109 |
+
{...getInputProps({
|
110 |
+
onFocus: () => openMenu(),
|
111 |
+
onClick: () => openMenu(),
|
112 |
+
})}
|
113 |
+
placeholder={__('Select list...', 'blc')}
|
114 |
+
readOnly
|
115 |
+
/>
|
116 |
+
|
117 |
+
{isOpen && (
|
118 |
+
<div
|
119 |
+
{...getMenuProps({
|
120 |
+
className: 'ct-select-dropdown',
|
121 |
+
})}>
|
122 |
+
{lists.map((item, index) => (
|
123 |
+
<div
|
124 |
+
{...getItemProps({
|
125 |
+
key: item.id,
|
126 |
+
index,
|
127 |
+
item: item.id,
|
128 |
+
className: classnames(
|
129 |
+
'ct-select-dropdown-item',
|
130 |
+
{
|
131 |
+
active:
|
132 |
+
highlightedIndex === index,
|
133 |
+
selected:
|
134 |
+
selectedItem === item.id,
|
135 |
+
}
|
136 |
+
),
|
137 |
+
})}>
|
138 |
+
{item.name}
|
139 |
+
</div>
|
140 |
+
))}
|
141 |
+
</div>
|
142 |
+
)}
|
143 |
+
</div>
|
144 |
+
)}
|
145 |
+
</Downshift>
|
146 |
+
)
|
147 |
+
}
|
148 |
+
|
149 |
+
export default ListPicker
|
trunk/framework/extensions/mailchimp/dashboard-static/js/Mailchimp.js
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import {
|
2 |
+
createElement,
|
3 |
+
Component,
|
4 |
+
useEffect,
|
5 |
+
useState,
|
6 |
+
Fragment,
|
7 |
+
} from '@wordpress/element'
|
8 |
+
import { __ } from 'ct-i18n'
|
9 |
+
import classnames from 'classnames'
|
10 |
+
|
11 |
+
import useExtensionReadme from '../../../../../static/js/helpers/useExtensionReadme'
|
12 |
+
// import useActivationAction from '../../../../../static/js/helpers/useActivationAction'
|
13 |
+
import useActivationWithRequirements from './hooks/useActivationWithRequirements'
|
14 |
+
|
15 |
+
const Mailchimp = ({ extension, onExtsSync }) => {
|
16 |
+
const [isLoading, activationAction, ui] = useActivationWithRequirements(
|
17 |
+
extension,
|
18 |
+
() => {
|
19 |
+
onExtsSync()
|
20 |
+
}
|
21 |
+
)
|
22 |
+
|
23 |
+
const [showReadme, readme] = useExtensionReadme(extension)
|
24 |
+
|
25 |
+
return (
|
26 |
+
<li className={classnames({ active: !!extension.__object })}>
|
27 |
+
<h4 className="ct-extension-title">
|
28 |
+
{extension.config.name}
|
29 |
+
|
30 |
+
{isLoading && (
|
31 |
+
<svg width="15" height="15" viewBox="0 0 100 100">
|
32 |
+
<g transform="translate(50,50)">
|
33 |
+
<g transform="scale(1)">
|
34 |
+
<circle cx="0" cy="0" r="50" fill="#687c93" />
|
35 |
+
<circle
|
36 |
+
cx="0"
|
37 |
+
cy="-26"
|
38 |
+
r="12"
|
39 |
+
fill="#ffffff"
|
40 |
+
transform="rotate(161.634)">
|
41 |
+
<animateTransform
|
42 |
+
attributeName="transform"
|
43 |
+
type="rotate"
|
44 |
+
calcMode="linear"
|
45 |
+
values="0 0 0;360 0 0"
|
46 |
+
keyTimes="0;1"
|
47 |
+
dur="1s"
|
48 |
+
begin="0s"
|
49 |
+
repeatCount="indefinite"
|
50 |
+
/>
|
51 |
+
</circle>
|
52 |
+
</g>
|
53 |
+
</g>
|
54 |
+
</svg>
|
55 |
+
)}
|
56 |
+
</h4>
|
57 |
+
|
58 |
+
{extension.config.description && (
|
59 |
+
<div className="ct-extension-description">
|
60 |
+
{extension.config.description}
|
61 |
+
</div>
|
62 |
+
)}
|
63 |
+
|
64 |
+
<div className="ct-extension-actions">
|
65 |
+
<button
|
66 |
+
className={classnames(
|
67 |
+
extension.__object ? 'ct-button' : 'ct-button-primary'
|
68 |
+
)}
|
69 |
+
data-button="white"
|
70 |
+
disabled={isLoading}
|
71 |
+
onClick={() => activationAction()}>
|
72 |
+
{extension.__object
|
73 |
+
? __('Deactivate', 'blc')
|
74 |
+
: __('Activate', 'blc')}
|
75 |
+
</button>
|
76 |
+
|
77 |
+
{ui}
|
78 |
+
|
79 |
+
{extension.readme && (
|
80 |
+
<button
|
81 |
+
onClick={() => showReadme()}
|
82 |
+
data-button="white"
|
83 |
+
className="ct-minimal-button ct-instruction">
|
84 |
+
<svg width="16" height="16" viewBox="0 0 24 24">
|
85 |
+
<path d="M12,2C6.477,2,2,6.477,2,12s4.477,10,10,10s10-4.477,10-10S17.523,2,12,2z M12,17L12,17c-0.552,0-1-0.448-1-1v-4 c0-0.552,0.448-1,1-1h0c0.552,0,1,0.448,1,1v4C13,16.552,12.552,17,12,17z M12.5,9h-1C11.224,9,11,8.776,11,8.5v-1 C11,7.224,11.224,7,11.5,7h1C12.776,7,13,7.224,13,7.5v1C13,8.776,12.776,9,12.5,9z" />
|
86 |
+
</svg>
|
87 |
+
</button>
|
88 |
+
)}
|
89 |
+
</div>
|
90 |
+
{readme}
|
91 |
+
</li>
|
92 |
+
)
|
93 |
+
}
|
94 |
+
|
95 |
+
export default Mailchimp
|
trunk/framework/extensions/mailchimp/dashboard-static/js/hooks/useActivationWithRequirements.js
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import {
|
2 |
+
createElement,
|
3 |
+
Component,
|
4 |
+
useEffect,
|
5 |
+
useState,
|
6 |
+
Fragment,
|
7 |
+
} from '@wordpress/element'
|
8 |
+
|
9 |
+
import EditCredentials from '../EditCredentials'
|
10 |
+
import { __, sprintf } from 'ct-i18n'
|
11 |
+
|
12 |
+
const useActivationWithRequirements = (extension, cb = () => {}) => {
|
13 |
+
const [isLoading, setIsLoading] = useState(false)
|
14 |
+
const [isEditingCredentials, setIsEditingCredentials] = useState(false)
|
15 |
+
|
16 |
+
const toggleActivationState = async () => {
|
17 |
+
const body = new FormData()
|
18 |
+
|
19 |
+
body.append('ext', extension.name)
|
20 |
+
body.append(
|
21 |
+
'action',
|
22 |
+
extension.__object
|
23 |
+
? 'blocksy_extension_deactivate'
|
24 |
+
: 'blocksy_extension_activate'
|
25 |
+
)
|
26 |
+
|
27 |
+
setIsLoading(true)
|
28 |
+
|
29 |
+
try {
|
30 |
+
await fetch(ctDashboardLocalizations.ajax_url, {
|
31 |
+
method: 'POST',
|
32 |
+
body,
|
33 |
+
})
|
34 |
+
|
35 |
+
cb()
|
36 |
+
} catch (e) {}
|
37 |
+
|
38 |
+
setIsLoading(false)
|
39 |
+
}
|
40 |
+
|
41 |
+
const handleActionWithRequirements = () => {
|
42 |
+
if (extension.__object || extension.data.api_key) {
|
43 |
+
toggleActivationState()
|
44 |
+
return
|
45 |
+
}
|
46 |
+
|
47 |
+
setIsEditingCredentials(true)
|
48 |
+
}
|
49 |
+
|
50 |
+
return [
|
51 |
+
isLoading,
|
52 |
+
handleActionWithRequirements,
|
53 |
+
<Fragment>
|
54 |
+
{extension.__object && extension.data.api_key && (
|
55 |
+
<button
|
56 |
+
className="ct-button ct-config-btn"
|
57 |
+
data-button="white"
|
58 |
+
title="Edit Credentials"
|
59 |
+
onClick={() => setIsEditingCredentials(true)}>
|
60 |
+
{__('Configure', 'blc')}
|
61 |
+
</button>
|
62 |
+
)}
|
63 |
+
|
64 |
+
<EditCredentials
|
65 |
+
isEditingCredentials={isEditingCredentials}
|
66 |
+
setIsEditingCredentials={setIsEditingCredentials}
|
67 |
+
extension={extension}
|
68 |
+
onCredentialsValidated={() => {
|
69 |
+
if (!extension.__object) {
|
70 |
+
toggleActivationState()
|
71 |
+
}
|
72 |
+
|
73 |
+
setIsEditingCredentials(false)
|
74 |
+
}}
|
75 |
+
/>
|
76 |
+
</Fragment>,
|
77 |
+
]
|
78 |
+
}
|
79 |
+
|
80 |
+
export default useActivationWithRequirements
|
trunk/framework/extensions/mailchimp/dashboard-static/js/main.js
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import {
|
2 |
+
createElement,
|
3 |
+
Component,
|
4 |
+
useEffect,
|
5 |
+
useState,
|
6 |
+
Fragment,
|
7 |
+
} from '@wordpress/element'
|
8 |
+
import ctEvents from 'ct-events'
|
9 |
+
|
10 |
+
import Mailchimp from './Mailchimp'
|
11 |
+
|
12 |
+
ctEvents.on('ct:extensions:card', ({ CustomComponent, extension }) => {
|
13 |
+
if (extension.name !== 'mailchimp') return
|
14 |
+
CustomComponent.extension = Mailchimp
|
15 |
+
})
|
trunk/framework/extensions/mailchimp/extension.php
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once dirname(__FILE__) . '/helpers.php';
|
4 |
+
require_once dirname(__FILE__) . '/mailchimp-manager.php';
|
5 |
+
|
6 |
+
class BlocksyExtensionMailchimp {
|
7 |
+
public function __construct() {
|
8 |
+
add_action('blocksy:global-dynamic-css:enqueue', function ($args) {
|
9 |
+
blocksy_theme_get_dynamic_styles(array_merge([
|
10 |
+
'path' => dirname( __FILE__ ) . '/global.php',
|
11 |
+
'chunk' => 'global'
|
12 |
+
], $args));
|
13 |
+
}, 10, 3);
|
14 |
+
|
15 |
+
add_filter('blocksy-options-scripts-dependencies', function ($d) {
|
16 |
+
$d[] = 'blocksy-ext-newsletter-subscribe-admin-scripts';
|
17 |
+
return $d;
|
18 |
+
});
|
19 |
+
|
20 |
+
add_action('admin_enqueue_scripts', function () {
|
21 |
+
if (! function_exists('get_plugin_data')) {
|
22 |
+
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
23 |
+
}
|
24 |
+
|
25 |
+
$data = get_plugin_data(BLOCKSY__FILE__);
|
26 |
+
|
27 |
+
wp_register_script(
|
28 |
+
'blocksy-ext-newsletter-subscribe-admin-scripts',
|
29 |
+
BLOCKSY_URL . 'framework/extensions/mailchimp/admin-static/bundle/main.js',
|
30 |
+
[],
|
31 |
+
$data['Version'],
|
32 |
+
true
|
33 |
+
);
|
34 |
+
|
35 |
+
wp_localize_script(
|
36 |
+
'blocksy-ext-newsletter-subscribe-admin-scripts',
|
37 |
+
'blocksy_ext_newsletter_subscribe_localization',
|
38 |
+
[
|
39 |
+
'public_url' => BLOCKSY_URL . 'framework/extensions/mailchimp/admin-static/bundle/',
|
40 |
+
]
|
41 |
+
);
|
42 |
+
});
|
43 |
+
|
44 |
+
add_action('customize_controls_enqueue_scripts', function () {
|
45 |
+
if (! function_exists('get_plugin_data')) {
|
46 |
+
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
47 |
+
}
|
48 |
+
|
49 |
+
$data = get_plugin_data(BLOCKSY__FILE__);
|
50 |
+
|
51 |
+
wp_register_script(
|
52 |
+
'blocksy-ext-newsletter-subscribe-admin-scripts',
|
53 |
+
BLOCKSY_URL . 'framework/extensions/mailchimp/admin-static/bundle/main.js',
|
54 |
+
[],
|
55 |
+
$data['Version'],
|
56 |
+
true
|
57 |
+
);
|
58 |
+
|
59 |
+
wp_localize_script(
|
60 |
+
'blocksy-ext-newsletter-subscribe-admin-scripts',
|
61 |
+
'blocksy_ext_newsletter_subscribe_localization',
|
62 |
+
[
|
63 |
+
'public_url' => BLOCKSY_URL . 'framework/extensions/mailchimp/admin-static/bundle/',
|
64 |
+
]
|
65 |
+
);
|
66 |
+
});
|
67 |
+
|
68 |
+
add_action('wp_enqueue_scripts', function () {
|
69 |
+
if (! function_exists('get_plugin_data')) {
|
70 |
+
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
71 |
+
}
|
72 |
+
|
73 |
+
$data = get_plugin_data(BLOCKSY__FILE__);
|
74 |
+
|
75 |
+
if (is_admin()) {
|
76 |
+
return;
|
77 |
+
}
|
78 |
+
|
79 |
+
wp_enqueue_style(
|
80 |
+
'blocksy-ext-newsletter-subscribe-styles',
|
81 |
+
BLOCKSY_URL . 'framework/extensions/mailchimp/static/bundle/main.css',
|
82 |
+
['ct-main-styles'],
|
83 |
+
$data['Version']
|
84 |
+
);
|
85 |
+
|
86 |
+
wp_enqueue_script(
|
87 |
+
'blocksy-ext-newsletter-subscribe-scripts',
|
88 |
+
BLOCKSY_URL . 'framework/extensions/mailchimp/static/bundle/main.js',
|
89 |
+
['ct-scripts'],
|
90 |
+
$data['Version'],
|
91 |
+
true
|
92 |
+
);
|
93 |
+
});
|
94 |
+
|
95 |
+
add_filter('blocksy_widgets_paths', function ($all_widgets) {
|
96 |
+
$all_widgets[] = dirname(__FILE__) . '/ct-mailchimp';
|
97 |
+
return $all_widgets;
|
98 |
+
});
|
99 |
+
|
100 |
+
add_filter(
|
101 |
+
'blocksy_single_posts_end_customizer_options',
|
102 |
+
function ($opts) {
|
103 |
+
$opts['mailchimp_single_post_enabled'] = blc_call_fn(
|
104 |
+
['fn' => 'blocksy_get_options'],
|
105 |
+
dirname( __FILE__ ) . '/customizer.php',
|
106 |
+
[], false
|
107 |
+
);
|
108 |
+
|
109 |
+
return $opts;
|
110 |
+
}
|
111 |
+
);
|
112 |
+
|
113 |
+
add_filter('blocksy_extensions_metabox_post:elements:before', function ($opts) {
|
114 |
+
$opts['disable_subscribe_form'] = [
|
115 |
+
'label' => __( 'Disable Subscribe Form', 'blc' ),
|
116 |
+
'type' => 'ct-switch',
|
117 |
+
'value' => 'no',
|
118 |
+
];
|
119 |
+
|
120 |
+
return $opts;
|
121 |
+
}, 5);
|
122 |
+
|
123 |
+
add_action(
|
124 |
+
'customize_preview_init',
|
125 |
+
function () {
|
126 |
+
if (! function_exists('get_plugin_data')) {
|
127 |
+
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
128 |
+
}
|
129 |
+
|
130 |
+
$data = get_plugin_data(BLOCKSY__FILE__);
|
131 |
+
|
132 |
+
wp_enqueue_script(
|
133 |
+
'blocksy-newsletter-subscribe-customizer-sync',
|
134 |
+
BLOCKSY_URL . 'framework/extensions/mailchimp/admin-static/bundle/sync.js',
|
135 |
+
[ 'customize-preview', 'ct-events' ],
|
136 |
+
$data['Version'],
|
137 |
+
true
|
138 |
+
);
|
139 |
+
}
|
140 |
+
);
|
141 |
+
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
trunk/framework/extensions/mailchimp/global.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Mailchimp
|
4 |
+
blc_call_fn(['fn' => 'blocksy_output_colors'], [
|
5 |
+
'value' => get_theme_mod('mailchimpContent'),
|
6 |
+
'default' => [
|
7 |
+
'default' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
|
8 |
+
'hover' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
|
9 |
+
],
|
10 |
+
'css' => $css,
|
11 |
+
'variables' => [
|
12 |
+
'default' => [
|
13 |
+
'selector' => '.ct-mailchimp-block',
|
14 |
+
'variable' => 'color'
|
15 |
+
],
|
16 |
+
|
17 |
+
'hover' => [
|
18 |
+
'selector' => '.ct-mailchimp-block',
|
19 |
+
'variable' => 'linkHoverColor'
|
20 |
+
],
|
21 |
+
],
|
22 |
+
]);
|
23 |
+
|
24 |
+
blc_call_fn(['fn' => 'blocksy_output_colors'], [
|
25 |
+
'value' => get_theme_mod('mailchimpButton'),
|
26 |
+
'default' => [
|
27 |
+
'default' => [ 'color' => 'var(--paletteColor1)' ],
|
28 |
+
'hover' => [ 'color' => 'var(--paletteColor2)' ],
|
29 |
+
],
|
30 |
+
'css' => $css,
|
31 |
+
'variables' => [
|
32 |
+
'default' => [
|
33 |
+
'selector' => '.ct-mailchimp-block',
|
34 |
+
'variable' => 'buttonInitialColor'
|
35 |
+
],
|
36 |
+
|
37 |
+
'hover' => [
|
38 |
+
'selector' => '.ct-mailchimp-block',
|
39 |
+
'variable' => 'buttonHoverColor'
|
40 |
+
]
|
41 |
+
],
|
42 |
+
]);
|
43 |
+
|
44 |
+
blc_call_fn(['fn' => 'blocksy_output_colors'], [
|
45 |
+
'value' => get_theme_mod('mailchimpBackground'),
|
46 |
+
'default' => ['default' => [ 'color' => '#ffffff' ]],
|
47 |
+
'css' => $css,
|
48 |
+
'variables' => [
|
49 |
+
'default' => [
|
50 |
+
'selector' => '.ct-mailchimp-block',
|
51 |
+
'variable' => 'backgroundColor'
|
52 |
+
],
|
53 |
+
],
|
54 |
+
]);
|
55 |
+
|
56 |
+
blc_call_fn(['fn' => 'blocksy_output_colors'], [
|
57 |
+
'value' => get_theme_mod('mailchimpShadow'),
|
58 |
+
'default' => ['default' => [ 'color' => 'rgba(210, 213, 218, 0.4)' ]],
|
59 |
+
'css' => $css,
|
60 |
+
'variables' => [
|
61 |
+
'default' => [
|
62 |
+
'selector' => '.ct-mailchimp-block',
|
63 |
+
'variable' => 'mailchimpShadow'
|
64 |
+
],
|
65 |
+
],
|
66 |
+
]);
|
67 |
+
|
68 |
+
blc_call_fn(['fn' => 'blocksy_output_box_shadow'], [
|
69 |
+
'css' => $css,
|
70 |
+
'tablet_css' => $tablet_css,
|
71 |
+
'mobile_css' => $mobile_css,
|
72 |
+
'selector' => '.ct-mailchimp-block',
|
73 |
+
'value' => get_theme_mod(
|
74 |
+
'mailchimpShadow',
|
75 |
+
blc_call_fn(['fn' => 'blocksy_box_shadow_value'], [
|
76 |
+
'enable' => true,
|
77 |
+
'h_offset' => 0,
|
78 |
+
'v_offset' => 50,
|
79 |
+
'blur' => 90,
|
80 |
+
'spread' => 0,
|
81 |
+
'inset' => false,
|
82 |
+
'color' => [
|
83 |
+
'color' => 'rgba(210, 213, 218, 0.4)',
|
84 |
+
],
|
85 |
+
])
|
86 |
+
),
|
87 |
+
'responsive' => true
|
88 |
+
]);
|
89 |
+
|
90 |
+
blc_call_fn(['fn' => 'blocksy_output_responsive'], [
|
91 |
+
'css' => $css,
|
92 |
+
'tablet_css' => $tablet_css,
|
93 |
+
'mobile_css' => $mobile_css,
|
94 |
+
'selector' => '.ct-mailchimp-block',
|
95 |
+
'variableName' => 'padding',
|
96 |
+
'value' => get_theme_mod('mailchimpSpacing', [
|
97 |
+
'mobile' => '40px',
|
98 |
+
'tablet' => '40px',
|
99 |
+
'desktop' => '40px',
|
100 |
+
]),
|
101 |
+
'unit' => ''
|
102 |
+
]);
|
103 |
+
|
trunk/framework/extensions/mailchimp/helpers.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function blc_output_mailchimp_subscribe_form_cache() {
|
4 |
+
if (! is_customize_preview()) return;
|
5 |
+
|
6 |
+
blocksy_add_customizer_preview_cache(
|
7 |
+
blocksy_html_tag(
|
8 |
+
'div',
|
9 |
+
[ 'data-id' => 'blocksy-mailchimp-subscribe' ],
|
10 |
+
blc_ext_mailchimp_subscribe_form(true)
|
11 |
+
)
|
12 |
+
);
|
13 |
+
}
|
14 |
+
|
15 |
+
function blc_ext_mailchimp_subscribe_form($forced = false) {
|
16 |
+
if (! $forced) {
|
17 |
+
blc_output_mailchimp_subscribe_form_cache();
|
18 |
+
}
|
19 |
+
|
20 |
+
if (get_theme_mod('mailchimp_single_post_enabled', 'yes') !== 'yes') {
|
21 |
+
if (! $forced) {
|
22 |
+
return '';
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
if (
|
27 |
+
blocksy_default_akg(
|
28 |
+
'disable_subscribe_form',
|
29 |
+
blc_call_fn([
|
30 |
+
'fn' => 'blocksy_get_post_options',
|
31 |
+
'default' => 'array'
|
32 |
+
]),
|
33 |
+
'no'
|
34 |
+
) === 'yes'
|
35 |
+
) {
|
36 |
+
return '';
|
37 |
+
}
|
38 |
+
|
39 |
+
$title = get_theme_mod('mailchimp_title', __(
|
40 |
+
'Newsletter Updates', 'blc'
|
41 |
+
));
|
42 |
+
|
43 |
+
$description = get_theme_mod('mailchimp_text', __(
|
44 |
+
'Enter your email address below to subscribe to our newsletter',
|
45 |
+
'blc'
|
46 |
+
));
|
47 |
+
|
48 |
+
$button_text = get_theme_mod('mailchimp_button_text', __(
|
49 |
+
'Subscribe', 'blc'
|
50 |
+
));
|
51 |
+
|
52 |
+
$has_name = get_theme_mod( 'has_mailchimp_name', 'no' ) === 'yes';
|
53 |
+
|
54 |
+
$name_label = get_theme_mod('mailchimp_name_label', __( 'Your name', 'blc' ));
|
55 |
+
$email_label = get_theme_mod('mailchimp_mail_label', __( 'Your email', 'blc' ));
|
56 |
+
|
57 |
+
if ($forced) {
|
58 |
+
$has_name = true;
|
59 |
+
}
|
60 |
+
|
61 |
+
$list_id = null;
|
62 |
+
|
63 |
+
if (get_theme_mod( 'mailchimp_list_id_source', 'default' ) === 'custom') {
|
64 |
+
$list_id = get_theme_mod( 'mailchimp_list_id', '' );
|
65 |
+
}
|
66 |
+
|
67 |
+
$manager = new BlocksyMailchimpManager();
|
68 |
+
|
69 |
+
$mailchimp_data = $manager->get_form_url_and_gdpr_for($list_id);
|
70 |
+
|
71 |
+
if (! $mailchimp_data) {
|
72 |
+
return '';
|
73 |
+
}
|
74 |
+
|
75 |
+
$form_url = $mailchimp_data['form_url'];
|
76 |
+
$has_gdpr_fields = $mailchimp_data['has_gdpr_fields'];
|
77 |
+
|
78 |
+
$skip_submit_output = '';
|
79 |
+
|
80 |
+
if ($has_gdpr_fields) {
|
81 |
+
$skip_submit_output = 'data-skip-submit';
|
82 |
+
}
|
83 |
+
|
84 |
+
$class = 'ct-mailchimp-block';
|
85 |
+
|
86 |
+
$class .= ' ' . blc_call_fn(
|
87 |
+
['fn' => 'blocksy_visibility_classes'],
|
88 |
+
get_theme_mod('mailchimp_subscribe_visibility', [
|
89 |
+
'desktop' => true,
|
90 |
+
'tablet' => true,
|
91 |
+
'mobile' => false,
|
92 |
+
])
|
93 |
+
);
|
94 |
+
|
95 |
+
$fields_number = '1';
|
96 |
+
|
97 |
+
if ($has_name) {
|
98 |
+
$fields_number = '2';
|
99 |
+
}
|
100 |
+
|
101 |
+
ob_start();
|
102 |
+
|
103 |
+
?>
|
104 |
+
|
105 |
+
<div class="<?php echo esc_attr($class) ?>">
|
106 |
+
<h3><?php echo esc_html($title) ?></h3>
|
107 |
+
|
108 |
+
<p class="ct-mailchimp-description">
|
109 |
+
<?php echo $description ?>
|
110 |
+
</p>
|
111 |
+
|
112 |
+
<form target="_blank" action="<?php echo esc_attr($form_url) ?>" method="post" class="ct-mailchimp-block-form" <?php echo $skip_submit_output ?>>
|
113 |
+
<section data-fields="<?php echo $fields_number ?>">
|
114 |
+
<?php if ($has_name) { ?>
|
115 |
+
<input type="text" name="FNAME" placeholder="<?php esc_attr_e($name_label, 'blc'); ?>" title="<?php echo __('Name', 'blc') ?>" />
|
116 |
+
<?php } ?>
|
117 |
+
|
118 |
+
<input type="email" name="EMAIL" placeholder="<?php esc_attr_e($email_label, 'blc'); ?> *" title="<?php echo __('Email', 'blc') ?>" required />
|
119 |
+
|
120 |
+
<button class="button">
|
121 |
+
<?php echo esc_html($button_text) ?>
|
122 |
+
</button>
|
123 |
+
</section>
|
124 |
+
|
125 |
+
<div class="ct-mailchimp-message"></div>
|
126 |
+
|
127 |
+
<?php
|
128 |
+
if (function_exists('blocksy_ext_cookies_checkbox')) {
|
129 |
+
echo blocksy_ext_cookies_checkbox('subscribe');
|
130 |
+
}
|
131 |
+
?>
|
132 |
+
|
133 |
+
</form>
|
134 |
+
|
135 |
+
</div>
|
136 |
+
|
137 |
+
<?php
|
138 |
+
|
139 |
+
return ob_get_clean();
|
140 |
+
}
|
trunk/framework/extensions/mailchimp/mailchimp-manager.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class BlocksyMailchimpManager {
|
4 |
+
public function __construct() {
|
5 |
+
}
|
6 |
+
|
7 |
+
public function get_settings() {
|
8 |
+
$option = get_option('blocksy_ext_mailchimp_credentials', []);
|
9 |
+
|
10 |
+
if (empty($option)) {
|
11 |
+
$option = [];
|
12 |
+
}
|
13 |
+
|
14 |
+
return array_merge([
|
15 |
+
'api_key' => null,
|
16 |
+
'list_id' => null
|
17 |
+
], $option);
|
18 |
+
}
|
19 |
+
|
20 |
+
public function set_settings($vals) {
|
21 |
+
update_option('blocksy_ext_mailchimp_credentials', array_merge([
|
22 |
+
'api_key' => null,
|
23 |
+
'list_id' => null
|
24 |
+
], $vals));
|
25 |
+
}
|
26 |
+
|
27 |
+
public function can($capability = 'manage_options') {
|
28 |
+
if (is_multisite()) {
|
29 |
+
// Only network admin can change files that affects the entire network.
|
30 |
+
$can = current_user_can_for_blog( get_current_blog_id(), $capability );
|
31 |
+
} else {
|
32 |
+
$can = current_user_can( $capability );
|
33 |
+
}
|
34 |
+
|
35 |
+
if ($can) {
|
36 |
+
// Also you can use this method to get the capability.
|
37 |
+
$can = $capability;
|
38 |
+
}
|
39 |
+
|
40 |
+
return $can;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function fetch_lists($api_key) {
|
44 |
+
if (! $api_key) {
|
45 |
+
return 'api_key_invalid';
|
46 |
+
}
|
47 |
+
|
48 |
+
if (strpos($api_key, '-') === false) {
|
49 |
+
return 'api_key_invalid';
|
50 |
+
}
|
51 |
+
|
52 |
+
$region = explode('-', $api_key);
|
53 |
+
|
54 |
+
$response = wp_remote_get('https://' . $region[1] . '.api.mailchimp.com/3.0/lists', [
|
55 |
+
'headers' => [
|
56 |
+
'Authorization' => 'Basic ' . base64_encode('asd:' . $api_key)
|
57 |
+
]
|
58 |
+
]);
|
59 |
+
|
60 |
+
if ( ! is_wp_error( $response ) ) {
|
61 |
+
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
62 |
+
return 'api_key_invalid';
|
63 |
+
}
|
64 |
+
|
65 |
+
$body = json_decode(wp_remote_retrieve_body( $response ), true);
|
66 |
+
|
67 |
+
if (! $body) {
|
68 |
+
return 'api_key_invalid';
|
69 |
+
}
|
70 |
+
|
71 |
+
if (! isset($body['lists'])) {
|
72 |
+
return 'api_key_invalid';
|
73 |
+
}
|
74 |
+
|
75 |
+
return array_map(function($list) {
|
76 |
+
return [
|
77 |
+
'name' => $list['name'],
|
78 |
+
'id' => $list['id'],
|
79 |
+
'subscribe_url_long' => $list['subscribe_url_long'],
|
80 |
+
'subscribe_url_long_json' => $this->transform_subscribe_url(
|
81 |
+
$list['subscribe_url_long']
|
82 |
+
),
|
83 |
+
|
84 |
+
'has_gdpr_fields' => $list['marketing_permissions']
|
85 |
+
];
|
86 |
+
}, $body['lists']);
|
87 |
+
} else {
|
88 |
+
return 'api_key_invalid';
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
public function transform_subscribe_url($url) {
|
93 |
+
return str_replace(
|
94 |
+
'subscribe',
|
95 |
+
'subscribe/post-json',
|
96 |
+
$url . '&c=callback'
|
97 |
+
);
|
98 |
+
}
|
99 |
+
|
100 |
+
public function get_form_url_and_gdpr_for($maybe_custom_list = null) {
|
101 |
+
$settings = $this->get_settings();
|
102 |
+
|
103 |
+
if (! isset($settings['api_key'])) {
|
104 |
+
return false;
|
105 |
+
}
|
106 |
+
|
107 |
+
if (! $settings['api_key']) {
|
108 |
+
return false;
|
109 |
+
}
|
110 |
+
|
111 |
+
$lists = $this->fetch_lists($settings['api_key']);
|
112 |
+
|
113 |
+
if (! is_array($lists)) {
|
114 |
+
return false;
|
115 |
+
}
|
116 |
+
|
117 |
+
if (empty($lists)) {
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
|
121 |
+
if ($maybe_custom_list) {
|
122 |
+
$settings['list_id'] = $maybe_custom_list;
|
123 |
+
}
|
124 |
+
|
125 |
+
if (! $settings['list_id']) {
|
126 |
+
return [
|
127 |
+
'form_url' => $lists[0]['subscribe_url_long'],
|
128 |
+
'has_gdpr_fields' => $lists[0]['has_gdpr_fields']
|
129 |
+
];
|
130 |
+
}
|
131 |
+
|
132 |
+
foreach ($lists as $single_list) {
|
133 |
+
if ($single_list['id'] === $settings['list_id']) {
|
134 |
+
return [
|
135 |
+
'form_url' => $single_list['subscribe_url_long'],
|
136 |
+
'has_gdpr_fields' => $single_list['has_gdpr_fields']
|
137 |
+
];
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
return [
|
142 |
+
'form_url' => $lists[0]['subscribe_url_long'],
|
143 |
+
'has_gdpr_fields' => $lists[0]['has_gdpr_fields']
|
144 |
+
];
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
trunk/framework/extensions/mailchimp/pre-boot.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once dirname(__FILE__) . '/mailchimp-manager.php';
|
4 |
+
|
5 |
+
class BlocksyExtensionMailchimpPreBoot {
|
6 |
+
public function __construct() {
|
7 |
+
add_action(
|
8 |
+
'wp_ajax_blocksy_ext_mailchimp_maybe_get_lists',
|
9 |
+
[$this, 'get_lists']
|
10 |
+
);
|
11 |
+
|
12 |
+
add_action(
|
13 |
+
'wp_ajax_blocksy_ext_mailchimp_get_actual_lists',
|
14 |
+
[$this, 'get_actual_lists']
|
15 |
+
);
|
16 |
+
|
17 |
+
add_action(
|
18 |
+
'wp_ajax_blocksy_ext_mailchimp_maybe_save_credentials',
|
19 |
+
[$this, 'save_credentials']
|
20 |
+
);
|
21 |
+
|
22 |
+
add_filter('blocksy-dashboard-scripts-dependencies', function ($s) {
|
23 |
+
$s[] = 'blocksy-ext-mailchimp-dashboard-scripts';
|
24 |
+
return $s;
|
25 |
+
});
|
26 |
+
|
27 |
+
add_action('admin_enqueue_scripts', function () {
|
28 |
+
if (! function_exists('get_plugin_data')) {
|
29 |
+
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
30 |
+
}
|
31 |
+
|
32 |
+
$data = get_plugin_data(BLOCKSY__FILE__);
|
33 |
+
|
34 |
+
wp_register_script(
|
35 |
+
'blocksy-ext-mailchimp-dashboard-scripts',
|
36 |
+
BLOCKSY_URL . 'framework/extensions/mailchimp/dashboard-static/bundle/main.js',
|
37 |
+
[],
|
38 |
+
$data['Version'],
|
39 |
+
true
|
40 |
+
);
|
41 |
+
});
|
42 |
+
}
|
43 |
+
|
44 |
+
public function ext_data() {
|
45 |
+
$m = new BlocksyMailchimpManager();
|
46 |
+
return $m->get_settings();
|
47 |
+
}
|
48 |
+
|
49 |
+
public function save_credentials() {
|
50 |
+
$this->maybe_save_credentials();
|
51 |
+
}
|
52 |
+
|
53 |
+
public function get_actual_lists() {
|
54 |
+
$m = new BlocksyMailchimpManager();
|
55 |
+
|
56 |
+
if ( ! $m->can() ) {
|
57 |
+
wp_send_json_error();
|
58 |
+
}
|
59 |
+
|
60 |
+
$settings = $m->get_settings();
|
61 |
+
|
62 |
+
$lists = $m->fetch_lists($settings['api_key']);
|
63 |
+
|
64 |
+
wp_send_json_success([
|
65 |
+
'result' => $lists
|
66 |
+
]);
|
67 |
+
}
|
68 |
+
|
69 |
+
public function get_lists() {
|
70 |
+
$this->maybe_save_credentials(false);
|
71 |
+
}
|
72 |
+
|
73 |
+
public function maybe_save_credentials($save = true) {
|
74 |
+
$m = new BlocksyMailchimpManager();
|
75 |
+
|
76 |
+
if ( ! $m->can() ) {
|
77 |
+
wp_send_json_error();
|
78 |
+
}
|
79 |
+
|
80 |
+
$lists = $m->fetch_lists($this->get_api_key_from_request());
|
81 |
+
|
82 |
+
if ($save) {
|
83 |
+
if (is_array($lists)) {
|
84 |
+
$m->set_settings([
|
85 |
+
'api_key' => $this->get_api_key_from_request(),
|
86 |
+
'list_id' => $this->get_list_id_from_request(),
|
87 |
+
]);
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
wp_send_json_success([
|
92 |
+
'result' => $lists
|
93 |
+
]);
|
94 |
+
}
|
95 |
+
|
96 |
+
public function get_api_key_from_request() {
|
97 |
+
if ( ! isset( $_POST['api_key'] ) ) {
|
98 |
+
wp_send_json_error();
|
99 |
+
}
|
100 |
+
|
101 |
+
return addslashes( $_POST['api_key'] );
|
102 |
+
}
|
103 |
+
|
104 |
+
public function get_list_id_from_request() {
|
105 |
+
if ( ! isset( $_POST['list_id'] ) ) {
|
106 |
+
wp_send_json_error();
|
107 |
+
}
|
108 |
+
|
109 |
+
return addslashes( $_POST['list_id'] );
|
110 |
+
}
|
111 |
+
}
|
trunk/framework/extensions/mailchimp/readme.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<h2><?php echo __('Instructions', 'blc'); ?></h2>
|
2 |
+
|
3 |
+
<p>
|
4 |
+
<?php echo __('After installing and activating the Mailchimp extension you will have two possibilities to show your subscribe form:', 'blc') ?>
|
5 |
+
</p>
|
6 |
+
|
7 |
+
<ol class="ct-modal-list">
|
8 |
+
<li>
|
9 |
+
<h4><?php echo __('Mailchimp Widget', 'blc') ?></h4>
|
10 |
+
<i>
|
11 |
+
<?php
|
12 |
+
echo sprintf(
|
13 |
+
__('Navigate to %s and place the widget in any widget area you want.', 'blc'),
|
14 |
+
sprintf(
|
15 |
+
'<code>%s</code>',
|
16 |
+
__('Appearance ➝ Widgets', 'blc')
|
17 |
+
)
|
18 |
+
);
|
19 |
+
?>
|
20 |
+
</i>
|
21 |
+
</li>
|
22 |
+
|
23 |
+
<li>
|
24 |
+
<h4><?php echo __('Mailchimp Block', 'blc') ?></h4>
|
25 |
+
<i>
|
26 |
+
<?php
|
27 |
+
echo sprintf(
|
28 |
+
__('Navigate to %s and customize the form and more.', 'blc'),
|
29 |
+
sprintf(
|
30 |
+
'<code>%s</code>',
|
31 |
+
__('Customizer ➝ Single Posts', 'blc')
|
32 |
+
)
|
33 |
+
);
|
34 |
+
?>
|
35 |
+
</i>
|
36 |
+
</li>
|
37 |
+
</ol>
|
trunk/framework/extensions/mailchimp/static/bundle/main.css
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* - v1.7.62
|
3 |
+
*
|
4 |
+
* Copyright (c) 2021
|
5 |
+
* Licensed GPLv2+
|
6 |
+
*/
|
7 |
+
|
8 |
+
.ct-widget-inner[data-alignment="center"]{text-align:center}.ct-widget-inner[data-alignment="right"]{text-align:right}.ct-widget-inner[data-container="boxed"]{padding:30px;background:#fff;border-radius:3px;box-shadow:0px 12px 18px -6px rgba(34,56,101,0.04)}.ct-mailchimp-widget-form .ct-mailchimp-description:not(:empty){margin-bottom:10px}.ct-mailchimp-widget-form>*:not(:first-child){margin-top:10px}.ct-mailchimp-widget-form button{width:100%}.ct-mailchimp-widget-form .gdpr-confirm-policy{--display: inline-flex;--contentSpacing: 0;margin-top:20px}.ct-mailchimp-block{margin-top:60px;text-align:center;color:var(--color);padding:var(--padding);background:var(--backgroundColor);box-shadow:var(--box-shadow);--linkInitialColor: var(--color)}.ct-mailchimp-block>*:first-child{margin-top:20px}.ct-mailchimp-block>*:last-child{margin-bottom:20px}.ct-mailchimp-block>h3{--fontSize: 25px}.ct-mailchimp-block .ct-mailchimp-description:not(:empty){margin-bottom:30px}.ct-mailchimp-block form{max-width:550px;margin:0 auto}@media (min-width: 690px){.ct-mailchimp-block form{width:85%}}.ct-mailchimp-block form button{--buttonMinHeight: var(--formInputHeight);--padding: 0 15px;width:100%}.ct-mailchimp-block form [data-fields]{display:grid;grid-column-gap:15px;grid-row-gap:15px}@media (min-width: 690px){.ct-mailchimp-block form [data-fields="1"]{grid-template-columns:65% 1fr}}@media (min-width: 690px){.ct-mailchimp-block form [data-fields="2"]{grid-template-columns:32.5% 32.5% 1fr}}.ct-mailchimp-block .ct-mailchimp-message,.ct-mailchimp-block .gdpr-confirm-policy{margin-top:15px;--contentSpacing: 0}form[class*="ct-mailchimp"] .button{--buttonFontWeight: 600}.ct-mailchimp-message{display:none;font-size:16px}.ct-mailchimp-message a{text-decoration:underline}.subscribe-error .ct-mailchimp-message{display:block;font-size:14px;color:#e42b2b}.subscribe-success button.button,.subscribe-success input[type="text"],.subscribe-success input[type="email"],.subscribe-success .gdpr-confirm-policy,.subscribe-success .ct-mailchimp-description{display:none}.subscribe-success .ct-mailchimp-message{display:block}
|
trunk/framework/extensions/mailchimp/static/bundle/main.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t){e.exports=window.ctFrontend},function(e,t,r){"use strict";r.r(t);var n=r(0);function o(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}Object(n.onDocumentLoaded)((function(){o(document.querySelectorAll(".ct-mailchimp-widget-form, .ct-mailchimp-block-form")).map((function(e){e.matches("[data-skip-submit]")||e.addEventListener("submit",(function(e){e.preventDefault();var t=e.target;if(t.querySelector('[type="email"]').value.trim()){if(document.getElementById("js-validate-robot")&&""!==document.getElementById("js-validate-robot").value)return!1;for(var r=t.action.replace("subscribe","subscribe/post-json"),n="",o="mailchimpCallback",i=t.querySelectorAll("input"),c=0;c<i.length;c++)n+="&"+i[c].name+"="+encodeURIComponent(i[c].value);n+="&c=".concat(o);var u=document.createElement("script");u.src=r+n,document.body.appendChild(u),t.classList.remove("subscribe-error","subscribe-success"),t.classList.add("subscribe-loading"),window[o]=function(e){delete window[o],document.body.removeChild(u),t.classList.remove("subscribe-loading"),e&&(t.classList.add("error"===e.result?"subscribe-error":"subscribe-success"),t.querySelector(".ct-mailchimp-message").innerHTML=e.msg.replace("0 - ",""))}}}))}))}))}]);
|
trunk/framework/extensions/mailchimp/static/js/main.js
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { onDocumentLoaded } from 'blocksy-frontend'
|
2 |
+
|
3 |
+
onDocumentLoaded(() => {
|
4 |
+
;[
|
5 |
+
...document.querySelectorAll(
|
6 |
+
'.ct-mailchimp-widget-form, .ct-mailchimp-block-form'
|
7 |
+
),
|
8 |
+
].map((el) => {
|
9 |
+
if (el.matches('[data-skip-submit]')) {
|
10 |
+
return
|
11 |
+
}
|
12 |
+
|
13 |
+
el.addEventListener('submit', (e) => {
|
14 |
+
e.preventDefault()
|
15 |
+
const form = e.target
|
16 |
+
|
17 |
+
if (!form.querySelector('[type="email"]').value.trim()) {
|
18 |
+
return
|
19 |
+
}
|
20 |
+
|
21 |
+
// Check for spam
|
22 |
+
if (
|
23 |
+
document.getElementById('js-validate-robot') &&
|
24 |
+
document.getElementById('js-validate-robot').value !== ''
|
25 |
+
) {
|
26 |
+
return false
|
27 |
+
}
|
28 |
+
|
29 |
+
// Get url for mailchimp
|
30 |
+
var url = form.action.replace('subscribe', 'subscribe/post-json')
|
31 |
+
|
32 |
+
// Add form data to object
|
33 |
+
var data = ''
|
34 |
+
|
35 |
+
var callback = 'mailchimpCallback'
|
36 |
+
|
37 |
+
var inputs = form.querySelectorAll('input')
|
38 |
+
|
39 |
+
for (var i = 0; i < inputs.length; i++) {
|
40 |
+
data +=
|
41 |
+
'&' +
|
42 |
+
inputs[i].name +
|
43 |
+
'=' +
|
44 |
+
encodeURIComponent(inputs[i].value)
|
45 |
+
}
|
46 |
+
|
47 |
+
data += `&c=${callback}`
|
48 |
+
|
49 |
+
// Create & add post script to the DOM
|
50 |
+
var script = document.createElement('script')
|
51 |
+
script.src = url + data
|
52 |
+
|
53 |
+
document.body.appendChild(script)
|
54 |
+
|
55 |
+
form.classList.remove('subscribe-error', 'subscribe-success')
|
56 |
+
form.classList.add('subscribe-loading')
|
57 |
+
|
58 |
+
// Callback function
|
59 |
+
window[callback] = function (data) {
|
60 |
+
// Remove post script from the DOM
|
61 |
+
delete window[callback]
|
62 |
+
document.body.removeChild(script)
|
63 |
+
|
64 |
+
form.classList.remove('subscribe-loading')
|
65 |
+
|
66 |
+
if (!data) {
|
67 |
+
return
|
68 |
+
}
|
69 |
+
|
70 |
+
form.classList.add(
|
71 |
+
data.result === 'error'
|
72 |
+
? 'subscribe-error'
|
73 |
+
: 'subscribe-success'
|
74 |
+
)
|
75 |
+
|
76 |
+
form.querySelector(
|
77 |
+
'.ct-mailchimp-message'
|
78 |
+
).innerHTML = data.msg.replace('0 - ', '')
|
79 |
+
}
|
80 |
+
})
|
81 |
+
})
|
82 |
+
})
|
trunk/framework/extensions/mailchimp/static/sass/main.scss
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@import '../../../../../static/sass/common-frontend';
|
2 |
+
@import 'widget';
|
3 |
+
@import 'single-block';
|
4 |
+
|
5 |
+
|
6 |
+
form[class*="ct-mailchimp"] {
|
7 |
+
.button {
|
8 |
+
--buttonFontWeight: 600;
|
9 |
+
}
|
10 |
+
}
|
11 |
+
|
12 |
+
// form messages
|
13 |
+
.ct-mailchimp-message {
|
14 |
+
display: none;
|
15 |
+
font-size: 16px;
|
16 |
+
|
17 |
+
a {
|
18 |
+
text-decoration: underline;
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
.subscribe-error .ct-mailchimp-message {
|
23 |
+
display: block;
|
24 |
+
font-size: 14px;
|
25 |
+
color: #e42b2b;
|
26 |
+
}
|
27 |
+
|
28 |
+
.subscribe-success {
|
29 |
+
button.button,
|
30 |
+
input[type="text"],
|
31 |
+
input[type="email"],
|
32 |
+
.gdpr-confirm-policy,
|
33 |
+
.ct-mailchimp-description {
|
34 |
+
display: none;
|
35 |
+
}
|
36 |
+
|
37 |
+
.ct-mailchimp-message {
|
38 |
+
display: block;
|
39 |
+
}
|
40 |
+
}
|
trunk/framework/extensions/mailchimp/static/sass/single-block.scss
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.ct-mailchimp-block {
|
2 |
+
margin-top: 60px;
|
3 |
+
text-align: center;
|
4 |
+
color: var(--color);
|
5 |
+
padding: var(--padding);
|
6 |
+
background: var(--backgroundColor);
|
7 |
+
box-shadow: var(--box-shadow);
|
8 |
+
--linkInitialColor: var(--color);
|
9 |
+
|
10 |
+
> * {
|
11 |
+
&:first-child {
|
12 |
+
margin-top: 20px;
|
13 |
+
}
|
14 |
+
|
15 |
+
&:last-child {
|
16 |
+
margin-bottom: 20px;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
> h3 {
|
21 |
+
--fontSize: 25px;
|
22 |
+
}
|
23 |
+
|
24 |
+
.ct-mailchimp-description {
|
25 |
+
&:not(:empty) {
|
26 |
+
// margin-top: 10px;
|
27 |
+
margin-bottom: 30px;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
form {
|
32 |
+
max-width: 550px;
|
33 |
+
margin: 0 auto;
|
34 |
+
|
35 |
+
@include media-breakpoint-up (md) {
|
36 |
+
width: 85%;
|
37 |
+
}
|
38 |
+
|
39 |
+
button {
|
40 |
+
--buttonMinHeight: var(--formInputHeight);
|
41 |
+
--padding: 0 15px;
|
42 |
+
width: 100%;
|
43 |
+
}
|
44 |
+
|
45 |
+
[data-fields] {
|
46 |
+
display: grid;
|
47 |
+
grid-column-gap: 15px;
|
48 |
+
grid-row-gap: 15px;
|
49 |
+
}
|
50 |
+
|
51 |
+
[data-fields="1"] {
|
52 |
+
|
53 |
+
@include media-breakpoint-up (md) {
|
54 |
+
grid-template-columns: 65% 1fr;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
[data-fields="2"] {
|
59 |
+
@include media-breakpoint-up (md) {
|
60 |
+
grid-template-columns: 32.5% 32.5% 1fr;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
.ct-mailchimp-message,
|
66 |
+
.gdpr-confirm-policy {
|
67 |
+
margin-top: 15px;
|
68 |
+
--contentSpacing: 0;
|
69 |
+
}
|
70 |
+
}
|
trunk/framework/extensions/mailchimp/static/sass/widget.scss
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.ct-widget-inner {
|
2 |
+
&[data-alignment="center"] {
|
3 |
+
text-align: center;
|
4 |
+
}
|
5 |
+
|
6 |
+
&[data-alignment="right"] {
|
7 |
+
text-align: right;
|
8 |
+
}
|
9 |
+
|
10 |
+
&[data-container="boxed"] {
|
11 |
+
padding: 30px;
|
12 |
+
background: #fff;
|
13 |
+
border-radius: 3px;
|
14 |
+
box-shadow: 0px 12px 18px -6px rgba(34, 56, 101, 0.04);
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
.ct-mailchimp-widget-form {
|
19 |
+
|
20 |
+
.ct-mailchimp-description {
|
21 |
+
&:not(:empty) {
|
22 |
+
margin-bottom: 10px;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
> *:not(:first-child) {
|
27 |
+
margin-top: 10px;
|
28 |
+
}
|
29 |
+
|
30 |
+
button {
|
31 |
+
width: 100%;
|
32 |
+
}
|
33 |
+
|
34 |
+
.gdpr-confirm-policy {
|
35 |
+
--display: inline-flex;
|
36 |
+
--contentSpacing: 0;
|
37 |
+
margin-top: 20px;
|
38 |
+
}
|
39 |
+
}
|
trunk/framework/extensions/product-reviews/config.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$config = [
|
4 |
+
'name' => __('Product Reviews', 'blc'),
|
5 |
+
'description' => __('A custom post type specially designed for creating product reviews.', 'blc'),
|
6 |
+
'require_refresh' => true
|
7 |
+
|
8 |
+
// 'hidden' => true
|
9 |
+
];
|
10 |
+
|
11 |
+
|
12 |
+
|
trunk/framework/extensions/product-reviews/extension.php
ADDED
@@ -0,0 +1,316 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once dirname(__FILE__) . '/helpers.php';
|
4 |
+
|
5 |
+
class BlocksyExtensionProductReviews {
|
6 |
+
public function __construct() {
|
7 |
+
add_filter(
|
8 |
+
'blocksy:options:cpt:page-title-args',
|
9 |
+
function ($args, $cpt) {
|
10 |
+
if ($cpt === 'blc-product-review') {
|
11 |
+
$args['has_hero_type'] = false;
|
12 |
+
}
|
13 |
+
|
14 |
+
return $args;
|
15 |
+
},
|
16 |
+
10, 2
|
17 |
+
);
|
18 |
+
|
19 |
+
add_action('init', [$this, 'declare_cpt']);
|
20 |
+
|
21 |
+
add_action('load-post.php', [$this, 'init_metabox']);
|
22 |
+
add_action('load-post-new.php', [$this, 'init_metabox']);
|
23 |
+
|
24 |
+
add_filter('blocksy:single:has-default-hero', function ($def) {
|
25 |
+
if (! is_singular('blc-product-review')) {
|
26 |
+
return $def;
|
27 |
+
}
|
28 |
+
|
29 |
+
return false;
|
30 |
+
});
|
31 |
+
|
32 |
+
add_filter(
|
33 |
+
'blocksy:hero:type-1:default-alignment',
|
34 |
+
function ($default, $prefix) {
|
35 |
+
if ($prefix === 'blc-product-review_single') {
|
36 |
+
return 'center';
|
37 |
+
}
|
38 |
+
|
39 |
+
return $default;
|
40 |
+
},
|
41 |
+
10, 2
|
42 |
+
);
|
43 |
+
|
44 |
+
add_filter('blocksy:archive:render-card-layers', function ($layers, $prefix) {
|
45 |
+
if ($prefix !== 'blc-product-review_archive') {
|
46 |
+
return $layers;
|
47 |
+
}
|
48 |
+
|
49 |
+
$layers['overall_score'] = blocksy_get_product_review_overall_score();
|
50 |
+
|
51 |
+
return $layers;
|
52 |
+
}, 10, 2);
|
53 |
+
|
54 |
+
add_filter('blocksy:posts-listing:archive-order:default', function ($default, $prefix) {
|
55 |
+
if ($prefix !== 'blc-product-review_archive') {
|
56 |
+
return $default;
|
57 |
+
}
|
58 |
+
|
59 |
+
$default[] = [
|
60 |
+
'id' => 'overall_score',
|
61 |
+
'enabled' => true
|
62 |
+
];
|
63 |
+
|
64 |
+
return $default;
|
65 |
+
}, 10, 2);
|
66 |
+
|
67 |
+
add_filter('blocksy:options:posts-listing-archive-order', function ($option, $prefix) {
|
68 |
+
if ($prefix !== 'blc-product-review_archive') {
|
69 |
+
return $option;
|
70 |
+
}
|
71 |
+
|
72 |
+
$option['value'][] = [
|
73 |
+
'id' => 'overall_score',
|
74 |
+
'enabled' => true
|
75 |
+
];
|
76 |
+
|
77 |
+
$option['settings']['overall_score'] = [
|
78 |
+
'label' => __('Overall Score', 'blocksy'),
|
79 |
+
/*
|
80 |
+
'options' => [
|
81 |
+
'excerpt_length' => [
|
82 |
+
'label' => __('Length', 'blocksy'),
|
83 |
+
'type' => 'ct-number',
|
84 |
+
'design' => 'inline',
|
85 |
+
'value' => 40,
|
86 |
+
'min' => 10,
|
87 |
+
'max' => 100,
|
88 |
+
],
|
89 |
+
],
|
90 |
+
*/
|
91 |
+
];
|
92 |
+
|
93 |
+
return $option;
|
94 |
+
}, 10, 2);
|
95 |
+
|
96 |
+
add_action(
|
97 |
+
'blocksy:content:top',
|
98 |
+
function () {
|
99 |
+
if (! is_singular('blc-product-review')) {
|
100 |
+
return;
|
101 |
+
}
|
102 |
+
|
103 |
+
echo blc_call_fn(
|
104 |
+
['fn' => 'blocksy_render_view'],
|
105 |
+
dirname(__FILE__) . '/views/single-top.php',
|
106 |
+
[]
|
107 |
+
);
|
108 |
+
}
|
109 |
+
);
|
110 |
+
|
111 |
+
add_action('wp_enqueue_scripts', function () {
|
112 |
+
if (! function_exists('get_plugin_data')) {
|
113 |
+
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
114 |
+
}
|
115 |
+
|
116 |
+
$data = get_plugin_data(BLOCKSY__FILE__);
|
117 |
+
|
118 |
+
if (is_admin()) {
|
119 |
+
return;
|
120 |
+
}
|
121 |
+
|
122 |
+
wp_enqueue_style(
|
123 |
+
'blocksy-ext-product-reviews-styles',
|
124 |
+
BLOCKSY_URL . 'framework/extensions/product-reviews/static/bundle/main.css',
|
125 |
+
['ct-main-styles'],
|
126 |
+
$data['Version']
|
127 |
+
);
|
128 |
+
});
|
129 |
+
}
|
130 |
+
|
131 |
+
public function init_metabox() {
|
132 |
+
add_action('add_meta_boxes', [$this, 'setup_meta_box']);
|
133 |
+
add_action('save_post', [$this, 'save_meta_box']);
|
134 |
+
}
|
135 |
+
|
136 |
+
public function declare_cpt() {
|
137 |
+
$settings = $this->get_settings();
|
138 |
+
|
139 |
+
register_post_type('blc-product-review', [
|
140 |
+
'label' => __('Product Reviews', 'blc'),
|
141 |
+
'description' => __( 'Product Reviews', 'blc'),
|
142 |
+
'menu_icon' => 'dashicons-star-filled',
|
143 |
+
'labels' => [
|
144 |
+
'name' => __('Product Reviews', 'blc'),
|
145 |
+
'singular_name' => __('Product Review', 'blc'),
|
146 |
+
'menu_name' => __('Product Reviews', 'blc'),
|
147 |
+
'parent_item_colon' => __('Parent Product Review', 'blc'),
|
148 |
+
'all_items' => __('All Reviews', 'blc'),
|
149 |
+
'view_item' => __('View Product Review', 'blc'),
|
150 |
+
'add_new_item' => __('Add New Product Review', 'blc'),
|
151 |
+
'add_new' => __('Add New Review', 'blc'),
|
152 |
+
'edit_item' => __('Edit Product Review', 'blc'),
|
153 |
+
'update_item' => __('Update Product Review', 'blc'),
|
154 |
+
'search_items' => __('Search Product Review', 'blc'),
|
155 |
+
'not_found' => __('Not Found', 'blc'),
|
156 |
+
'not_found_in_trash' => __('Not found in Trash', 'blc')
|
157 |
+
],
|
158 |
+
'supports' => [
|
159 |
+
'comments',
|
160 |
+
'title', 'editor', 'excerpt',
|
161 |
+
'author', 'thumbnail', 'revisions',
|
162 |
+
'custom-fields'
|
163 |
+
],
|
164 |
+
'show_in_rest' => true,
|
165 |
+
'public' => true,
|
166 |
+
'hierarchical' => false,
|
167 |
+
'show_ui' => true,
|
168 |
+
'show_in_menu' => true,
|
169 |
+
'show_in_nav_menus' => true,
|
170 |
+
'show_in_admin_bar' => true,
|
171 |
+
'has_archive' => true,
|
172 |
+
'can_export' => true,
|
173 |
+
'exclude_from_search' => false,
|
174 |
+
// 'taxonomies' => array('post_tag'),
|
175 |
+
'publicly_queryable' => true,
|
176 |
+
'capability_type' => 'page',
|
177 |
+
'rewrite' => [
|
178 |
+
'slug' => $settings['single_slug']
|
179 |
+
],
|
180 |
+
]);
|
181 |
+
|
182 |
+
register_taxonomy(
|
183 |
+
'blc-product-review-categories',
|
184 |
+
[
|
185 |
+
'blc-product-review'
|
186 |
+
],
|
187 |
+
[
|
188 |
+
'hierarchical' => true,
|
189 |
+
'labels' => [
|
190 |
+
'name' => __('Categories', 'blc'),
|
191 |
+
'singular_name' => __('Category', 'blc'),
|
192 |
+
'search_items' => __('Search Category', 'blc'),
|
193 |
+
'all_items' => __('All Categories', 'blc'),
|
194 |
+
'parent_item' => __('Parent Category', 'blc'),
|
195 |
+
'parent_item_colon' => __('Parent Category:', 'blc'),
|
196 |
+
'edit_item' => __('Edit Category', 'blc'),
|
197 |
+
'update_item' => __('Update Category', 'blc'),
|
198 |
+
'add_new_item' => __('Add New Category', 'blc'),
|
199 |
+
'new_item_name' => __('New Category Name', 'blc'),
|
200 |
+
'menu_name' => __('Categories', 'blc'),
|
201 |
+
],
|
202 |
+
'show_ui' => true,
|
203 |
+
'show_admin_column' => true,
|
204 |
+
'query_var' => true,
|
205 |
+
'show_in_rest' => true,
|
206 |
+
'rewrite' => [
|
207 |
+
'slug' => $settings['category_slug']
|
208 |
+
],
|
209 |
+
]
|
210 |
+
);
|
211 |
+
}
|
212 |
+
|
213 |
+
public function setup_meta_box() {
|
214 |
+
add_meta_box(
|
215 |
+
'blocksy_settings_meta_box',
|
216 |
+
sprintf(
|
217 |
+
// Translators: %s is the theme name.
|
218 |
+
__( '%s Settings', 'blocksy' ),
|
219 |
+
__( 'Blocksy', 'blocksy' )
|
220 |
+
),
|
221 |
+
function ($post) {
|
222 |
+
$values = get_post_meta($post->ID, 'blocksy_product_review_options');
|
223 |
+
|
224 |
+
if (empty($values)) {
|
225 |
+
$values = [[]];
|
226 |
+
}
|
227 |
+
|
228 |
+
$options = blc_call_fn(
|
229 |
+
['fn' => 'blocksy_get_options'],
|
230 |
+
dirname(__FILE__) . '/metabox.php',
|
231 |
+
[],
|
232 |
+
false
|
233 |
+
);
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Note to code reviewers: This line doesn't need to be escaped.
|
237 |
+
* Function blocksy_output_options_panel() used here escapes the value properly.
|
238 |
+
*/
|
239 |
+
echo blocksy_output_options_panel(
|
240 |
+
[
|
241 |
+
'options' => $options,
|
242 |
+
'values' => $values[0],
|
243 |
+
'id_prefix' => 'ct-post-meta-options',
|
244 |
+
'name_prefix' => 'blocksy_product_review_options',
|
245 |
+
'attr' => [
|
246 |
+
'class' => 'ct-meta-box',
|
247 |
+
'data-disable-reverse-button' => 'yes'
|
248 |
+
]
|
249 |
+
]
|
250 |
+
);
|
251 |
+
|
252 |
+
wp_nonce_field(basename(__FILE__), 'blocksy_settings_meta_box');
|
253 |
+
},
|
254 |
+
'blc-product-review', 'normal', 'default'
|
255 |
+
);
|
256 |
+
}
|
257 |
+
|
258 |
+
public function save_meta_box($post_id) {
|
259 |
+
$is_autosave = wp_is_post_autosave($post_id);
|
260 |
+
$is_revision = wp_is_post_revision($post_id);
|
261 |
+
$is_valid_nonce = !! (
|
262 |
+
isset($_POST['blocksy_settings_meta_box']) && wp_verify_nonce(
|
263 |
+
sanitize_text_field(wp_unslash($_POST['blocksy_settings_meta_box'])),
|
264 |
+
basename(__FILE__)
|
265 |
+
)
|
266 |
+
);
|
267 |
+
|
268 |
+
if ($is_autosave || $is_revision || !$is_valid_nonce) {
|
269 |
+
return;
|
270 |
+
}
|
271 |
+
|
272 |
+
$values = [];
|
273 |
+
|
274 |
+
if (isset($_POST['blocksy_product_review_options'][blocksy_post_name()])) {
|
275 |
+
$values = json_decode(
|
276 |
+
wp_unslash($_POST['blocksy_product_review_options'][blocksy_post_name()]),
|
277 |
+
true
|
278 |
+
);
|
279 |
+
}
|
280 |
+
|
281 |
+
update_post_meta(
|
282 |
+
$post_id,
|
283 |
+
'blocksy_product_review_options',
|
284 |
+
$values
|
285 |
+
);
|
286 |
+
}
|
287 |
+
|
288 |
+
public function get_settings() {
|
289 |
+
if (wp_doing_ajax()) {
|
290 |
+
$maybe_input = json_decode(file_get_contents('php://input'), true);
|
291 |
+
|
292 |
+
if (
|
293 |
+
$maybe_input
|
294 |
+
&&
|
295 |
+
isset($maybe_input['extension'])
|
296 |
+
&&
|
297 |
+
$maybe_input['extension'] === 'product-reviews'
|
298 |
+
&&
|
299 |
+
isset($maybe_input['extAction'])
|
300 |
+
&&
|
301 |
+
$maybe_input['extAction']['type'] === 'persist'
|
302 |
+
) {
|
303 |
+
return $maybe_input['extAction']['settings'];
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
return get_option('blocksy_ext_product_reviews_settings', [
|
308 |
+
'single_slug' => 'product-review',
|
309 |
+
'category_slug' => 'product-review-category',
|
310 |
+
]);
|
311 |
+
}
|
312 |
+
|
313 |
+
public function set_settings($value) {
|
314 |
+
update_option('blocksy_ext_product_reviews_settings', $value);
|
315 |
+
}
|
316 |
+
}
|
trunk/framework/extensions/product-reviews/helpers.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function blocksy_get_product_review_overall_score($post_id = null) {
|
4 |
+
if (! $post_id) {
|
5 |
+
global $post;
|
6 |
+
$post_id = $post->ID;
|
7 |
+
}
|
8 |
+
|
9 |
+
$atts = blocksy_get_post_options($post_id, [
|
10 |
+
'meta_id' => 'blocksy_product_review_options'
|
11 |
+
]);
|
12 |
+
|
13 |
+
$scores = blocksy_akg('scores', $atts, []);
|
14 |
+
|
15 |
+
if (empty($scores)) {
|
16 |
+
return '';
|
17 |
+
}
|
18 |
+
|
19 |
+
$output = '<div class="ct-overall-score-layer">';
|
20 |
+
|
21 |
+
$avg_score = round(array_reduce($scores, function ($carry, $score) {
|
22 |
+
return $carry + intval($score['score']);
|
23 |
+
}, 0) / count($scores) * 2) / 2;
|
24 |
+
|
25 |
+
$output .= '<span class="ct-score-label">';
|
26 |
+
$output .= __('Rating', 'blc');
|
27 |
+
$output .= ':</span>';
|
28 |
+
|
29 |
+
$output .= '<span class="ct-average-score">' . $avg_score . '/5</span>';
|
30 |
+
|
31 |
+
$output .= '<div class="star-rating" role="img">';
|
32 |
+
$width = ( ( $avg_score / 5 ) * 100 );
|
33 |
+
$output .= '<span style="width: ' . $width . '%;"></span>';
|
34 |
+
$output .= '</div>';
|
35 |
+
|
36 |
+
$output .= '</div>';
|
37 |
+
|
38 |
+
return $output;
|
39 |
+
}
|
trunk/framework/extensions/product-reviews/metabox.php
ADDED
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$options = [
|
4 |
+
|
5 |
+
blocksy_rand_md5() => [
|
6 |
+
'title' => __( 'General', 'blocksy' ),
|
7 |
+
'type' => 'tab',
|
8 |
+
'options' => [
|
9 |
+
|
10 |
+
'gallery' => [
|
11 |
+
'type' => 'ct-multi-image-uploader',
|
12 |
+
'label' => __('Gallery', 'blc'),
|
13 |
+
'design' => 'inline',
|
14 |
+
'value' => []
|
15 |
+
],
|
16 |
+
|
17 |
+
blocksy_rand_md5() => [
|
18 |
+
'type' => 'ct-divider',
|
19 |
+
],
|
20 |
+
|
21 |
+
'product_button_label' => [
|
22 |
+
'type' => 'text',
|
23 |
+
'label' => __('Affiliate Button Label', 'blc'),
|
24 |
+
'design' => 'inline',
|
25 |
+
'value' => __('Buy Now', 'blc')
|
26 |
+
],
|
27 |
+
|
28 |
+
'product_link' => [
|
29 |
+
'type' => 'text',
|
30 |
+
'label' => __('Affiliate Link', 'blc'),
|
31 |
+
'design' => 'inline',
|
32 |
+
'value' => '#'
|
33 |
+
],
|
34 |
+
|
35 |
+
/*
|
36 |
+
'product_button_icon' => [
|
37 |
+
'type' => 'icon-picker',
|
38 |
+
'label' => __('Button Icon', 'blc'),
|
39 |
+
'design' => 'inline',
|
40 |
+
'value' => [
|
41 |
+
'icon' => 'fas fa-shopping-cart'
|
42 |
+
]
|
43 |
+
],
|
44 |
+
*/
|
45 |
+
|
46 |
+
blocksy_rand_md5() => [
|
47 |
+
'type' => 'ct-divider',
|
48 |
+
],
|
49 |
+
|
50 |
+
'product_read_content_button_label' => [
|
51 |
+
'type' => 'text',
|
52 |
+
'label' => __('Read More Button Label', 'blc'),
|
53 |
+
'design' => 'inline',
|
54 |
+
'value' => __('Read More', 'blc')
|
55 |
+
],
|
56 |
+
|
57 |
+
/*
|
58 |
+
'product_read_content_button_icon' => [
|
59 |
+
'type' => 'icon-picker',
|
60 |
+
'label' => __('Button Icon', 'blc'),
|
61 |
+
'design' => 'inline',
|
62 |
+
'value' => [
|
63 |
+
'icon' => 'fas fa-arrow-down'
|
64 |
+
]
|
65 |
+
],
|
66 |
+
*/
|
67 |
+
|
68 |
+
blocksy_rand_md5() => [
|
69 |
+
'type' => 'ct-divider',
|
70 |
+
],
|
71 |
+
|
72 |
+
'product_description' => [
|
73 |
+
'type' => 'wp-editor',
|
74 |
+
'label' => __('Small Description', 'blc'),
|
75 |
+
'value' => '',
|
76 |
+
'design' => 'inline',
|
77 |
+
]
|
78 |
+
|
79 |
+
],
|
80 |
+
],
|
81 |
+
|
82 |
+
blocksy_rand_md5() => [
|
83 |
+
'title' => __( 'Rating', 'blocksy' ),
|
84 |
+
'type' => 'tab',
|
85 |
+
'options' => [
|
86 |
+
|
87 |
+
'scores' => [
|
88 |
+
'type' => 'ct-addable-box',
|
89 |
+
'label' => __('Scores', 'blc'),
|
90 |
+
'design' => 'inline',
|
91 |
+
'preview-template' => '<%= label %> (<%= score === 1 ? "1 star" : score + " stars" %>)',
|
92 |
+
|
93 |
+
'inner-options' => [
|
94 |
+
'label' => [
|
95 |
+
'type' => 'text',
|
96 |
+
'value' => 'Default'
|
97 |
+
],
|
98 |
+
|
99 |
+
'score' => [
|
100 |
+
'type' => 'ct-number',
|
101 |
+
'value' => 5,
|
102 |
+
'min' => 1,
|
103 |
+
'max' => 5
|
104 |
+
]
|
105 |
+
],
|
106 |
+
|
107 |
+
'value' => [
|
108 |
+
/*
|
109 |
+
[
|
110 |
+
'label' => 'Features',
|
111 |
+
'score' => 5
|
112 |
+
],
|
113 |
+
|
114 |
+
[
|
115 |
+
'label' => 'Quality',
|
116 |
+
'score' => 5
|
117 |
+
]
|
118 |
+
*/
|
119 |
+
]
|
120 |
+
],
|
121 |
+
|
122 |
+
blocksy_rand_md5() => [
|
123 |
+
'type' => 'ct-divider',
|
124 |
+
],
|
125 |
+
|
126 |
+
'product_specs' => [
|
127 |
+
'type' => 'ct-addable-box',
|
128 |
+
'label' => __('Product specs', 'blc'),
|
129 |
+
'design' => 'inline',
|
130 |
+
'preview-template' => '<%= label %>',
|
131 |
+
|
132 |
+
'inner-options' => [
|
133 |
+
'label' => [
|
134 |
+
'type' => 'text',
|
135 |
+
'value' => 'Default'
|
136 |
+
],
|
137 |
+
|
138 |
+
'value' => [
|
139 |
+
'type' => 'text',
|
140 |
+
'value' => ''
|
141 |
+
]
|
142 |
+
],
|
143 |
+
|
144 |
+
'value' => []
|
145 |
+
],
|
146 |
+
|
147 |
+
blocksy_rand_md5() => [
|
148 |
+
'type' => 'ct-divider',
|
149 |
+
],
|
150 |
+
|
151 |
+
'product_pros' => [
|
152 |
+
'type' => 'ct-addable-box',
|
153 |
+
'label' => __('Pros', 'blc'),
|
154 |
+
'design' => 'inline',
|
155 |
+
'preview-template' => '<%= label %>',
|
156 |
+
|
157 |
+
'inner-options' => [
|
158 |
+
'label' => [
|
159 |
+
'type' => 'text',
|
160 |
+
'value' => 'Default'
|
161 |
+
],
|
162 |
+
],
|
163 |
+
|
164 |
+
'value' => []
|
165 |
+
],
|
166 |
+
|
167 |
+
blocksy_rand_md5() => [
|
168 |
+
'type' => 'ct-divider',
|
169 |
+
],
|
170 |
+
|
171 |
+
'product_cons' => [
|
172 |
+
'type' => 'ct-addable-box',
|
173 |
+
'label' => __('Cons', 'blc'),
|
174 |
+
'design' => 'inline',
|
175 |
+
'preview-template' => '<%= label %>',
|
176 |
+
|
177 |
+
'inner-options' => [
|
178 |
+
'label' => [
|
179 |
+
'type' => 'text',
|
180 |
+
'value' => 'Default'
|
181 |
+
],
|
182 |
+
],
|
183 |
+
|
184 |
+
'value' => []
|
185 |
+
],
|
186 |
+
|
187 |
+
],
|
188 |
+
],
|
189 |
+
|
190 |
+
// blocksy_rand_md5() => [
|
191 |
+
// 'title' => __( 'Design', 'blocksy' ),
|
192 |
+
// 'type' => 'tab',
|
193 |
+
// 'options' => [
|
194 |
+
|
195 |
+
// ],
|
196 |
+
// ],
|
197 |
+
];
|
198 |
+
|
trunk/framework/extensions/product-reviews/pre-boot.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class BlocksyExtensionProductReviewsPreBoot {
|
4 |
+
public function __construct() {
|
5 |
+
add_action('admin_enqueue_scripts', function () {
|
6 |
+
if (! function_exists('get_plugin_data')) {
|
7 |
+
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
8 |
+
}
|
9 |
+
|
10 |
+
$data = get_plugin_data(BLOCKSY__FILE__);
|
11 |
+
|
12 |
+
if (! function_exists('blocksy_is_dashboard_page')) return;
|
13 |
+
if (! blocksy_is_dashboard_page()) return;
|
14 |
+
|
15 |
+
wp_enqueue_script(
|
16 |
+
'blocksy-ext-product-reviews-admin-dashboard-scripts',
|
17 |
+
BLOCKSY_URL . 'framework/extensions/product-reviews/static/bundle/dashboard.js',
|
18 |
+
['ct-options-scripts'],
|
19 |
+
$data['Version']
|
20 |
+
);
|
21 |
+
|
22 |
+
wp_enqueue_style(
|
23 |
+
'blocksy-ext-product-reviews-admin-dashboard-styles',
|
24 |
+
BLOCKSY_URL . 'framework/extensions/product-reviews/static/bundle/main-admin.css',
|
25 |
+
[],
|
26 |
+
$data['Version']
|
27 |
+
);
|
28 |
+
});
|
29 |
+
}
|
30 |
+
|
31 |
+
public function ext_action($payload) {
|
32 |
+
$ext = \Blocksy\Plugin::instance()->extensions->get('product-reviews');
|
33 |
+
|
34 |
+
if (
|
35 |
+
! isset($payload['type'])
|
36 |
+
||
|
37 |
+
! isset($payload['settings'])
|
38 |
+
||
|
39 |
+
$payload['type'] !== 'persist'
|
40 |
+
||
|
41 |
+
! $ext
|
42 |
+
) {
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
|
46 |
+
$ext->set_settings($payload['settings']);
|
47 |
+
|
48 |
+
global $wp_rewrite;
|
49 |
+
$wp_rewrite->flush_rules();
|
50 |
+
|
51 |
+
return $this->ext_data([
|
52 |
+
'settings' => $payload['settings']
|
53 |
+
]);
|
54 |
+
}
|
55 |
+
|
56 |
+
public function ext_data($args = []) {
|
57 |
+
return wp_parse_args($args, [
|
58 |
+
'settings' => get_option('blocksy_ext_product_reviews_settings', [
|
59 |
+
'single_slug' => 'product-review',
|
60 |
+
'category_slug' => 'product-review-category',
|
61 |
+
])
|
62 |
+
]);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
trunk/framework/extensions/product-reviews/static/bundle/dashboard.js
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=12)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.i18n},function(e,t,n){var r;
|
2 |
+
/*!
|
3 |
+
Copyright (c) 2017 Jed Watson.
|
4 |
+
Licensed under the MIT License (MIT), see
|
5 |
+
http://jedwatson.github.io/classnames
|
6 |
+
*/!function(){"use strict";var n={}.hasOwnProperty;function a(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var o=typeof r;if("string"===o||"number"===o)e.push(r);else if(Array.isArray(r)&&r.length){var c=a.apply(null,r);c&&e.push(c)}else if("object"===o)for(var i in r)n.call(r,i)&&r[i]&&e.push(i)}}return e.join(" ")}e.exports?(a.default=a,e.exports=a):void 0===(r=function(){return a}.apply(t,[]))||(e.exports=r)}()},function(e,t){e.exports=window.blocksyOptions},function(e,t){e.exports=window.ctEvents},function(e,t){e.exports=window.React},function(e,t,n){var r,a,o=n(10),c=n(11),i=(a=[],{activateTrap:function(e){if(a.length>0){var t=a[a.length-1];t!==e&&t.pause()}var n=a.indexOf(e);-1===n||a.splice(n,1),a.push(e)},deactivateTrap:function(e){var t=a.indexOf(e);-1!==t&&a.splice(t,1),a.length>0&&a[a.length-1].unpause()}});function u(e){return setTimeout(e,0)}e.exports=function(e,t){var n=document,a="string"==typeof e?n.querySelector(e):e,s=c({returnFocusOnDeactivate:!0,escapeDeactivates:!0},t),l={firstTabbableNode:null,lastTabbableNode:null,nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1},f={activate:function(e){if(l.active)return;j(),l.active=!0,l.paused=!1,l.nodeFocusedBeforeActivation=n.activeElement;var t=e&&e.onActivate?e.onActivate:s.onActivate;t&&t();return d(),f},deactivate:p,pause:function(){if(l.paused||!l.active)return;l.paused=!0,m()},unpause:function(){if(!l.paused||!l.active)return;l.paused=!1,j(),d()}};return f;function p(e){if(l.active){clearTimeout(r),m(),l.active=!1,l.paused=!1,i.deactivateTrap(f);var t=e&&void 0!==e.onDeactivate?e.onDeactivate:s.onDeactivate;return t&&t(),(e&&void 0!==e.returnFocus?e.returnFocus:s.returnFocusOnDeactivate)&&u((function(){var e;w((e=l.nodeFocusedBeforeActivation,v("setReturnFocus")||e))})),f}}function d(){if(l.active)return i.activateTrap(f),r=u((function(){w(b())})),n.addEventListener("focusin",h,!0),n.addEventListener("mousedown",y,{capture:!0,passive:!1}),n.addEventListener("touchstart",y,{capture:!0,passive:!1}),n.addEventListener("click",O,{capture:!0,passive:!1}),n.addEventListener("keydown",g,{capture:!0,passive:!1}),f}function m(){if(l.active)return n.removeEventListener("focusin",h,!0),n.removeEventListener("mousedown",y,!0),n.removeEventListener("touchstart",y,!0),n.removeEventListener("click",O,!0),n.removeEventListener("keydown",g,!0),f}function v(e){var t=s[e],r=t;if(!t)return null;if("string"==typeof t&&!(r=n.querySelector(t)))throw new Error("`"+e+"` refers to no known node");if("function"==typeof t&&!(r=t()))throw new Error("`"+e+"` did not return a node");return r}function b(){var e;if(!(e=null!==v("initialFocus")?v("initialFocus"):a.contains(n.activeElement)?n.activeElement:l.firstTabbableNode||v("fallbackFocus")))throw new Error("Your focus-trap needs to have at least one focusable element");return e}function y(e){a.contains(e.target)||(s.clickOutsideDeactivates?p({returnFocus:!o.isFocusable(e.target)}):s.allowOutsideClick&&s.allowOutsideClick(e)||e.preventDefault())}function h(e){a.contains(e.target)||e.target instanceof Document||(e.stopImmediatePropagation(),w(l.mostRecentlyFocusedNode||b()))}function g(e){if(!1!==s.escapeDeactivates&&function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e))return e.preventDefault(),void p();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){if(j(),e.shiftKey&&e.target===l.firstTabbableNode)return e.preventDefault(),void w(l.lastTabbableNode);if(!e.shiftKey&&e.target===l.lastTabbableNode)e.preventDefault(),w(l.firstTabbableNode)}(e)}function O(e){s.clickOutsideDeactivates||a.contains(e.target)||s.allowOutsideClick&&s.allowOutsideClick(e)||(e.preventDefault(),e.stopImmediatePropagation())}function j(){var e=o(a);l.firstTabbableNode=e[0]||b(),l.lastTabbableNode=e[e.length-1]||b()}function w(e){e!==n.activeElement&&(e&&e.focus?(e.focus(),l.mostRecentlyFocusedNode=e,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(e)&&e.select()):w(b()))}}},function(e,t,n){e.exports=n(8)()},function(e,t,n){"use strict";var r=n(9);function a(){}function o(){}o.resetWarningCache=a,e.exports=function(){function e(e,t,n,a,o,c){if(c!==r){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:a};return n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t){var n=["input","select","textarea","a[href]","button","[tabindex]","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])'],r=n.join(","),a="undefined"==typeof Element?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector;function o(e,t){t=t||{};var n,o,i,u=[],f=[],p=e.querySelectorAll(r);for(t.includeContainer&&a.call(e,r)&&(p=Array.prototype.slice.apply(p)).unshift(e),n=0;n<p.length;n++)c(o=p[n])&&(0===(i=s(o))?u.push(o):f.push({documentOrder:n,tabIndex:i,node:o}));return f.sort(l).map((function(e){return e.node})).concat(u)}function c(e){return!(!i(e)||function(e){return function(e){return f(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t=function(e){for(var t=0;t<e.length;t++)if(e[t].checked)return e[t]}(e.ownerDocument.querySelectorAll('input[type="radio"][name="'+e.name+'"]'));return!t||t===e}(e)}(e)||s(e)<0)}function i(e){return!(e.disabled||function(e){return f(e)&&"hidden"===e.type}(e)||function(e){return null===e.offsetParent||"hidden"===getComputedStyle(e).visibility}(e))}o.isTabbable=function(e){if(!e)throw new Error("No node provided");return!1!==a.call(e,r)&&c(e)},o.isFocusable=function(e){if(!e)throw new Error("No node provided");return!1!==a.call(e,u)&&i(e)};var u=n.concat("iframe").join(",");function s(e){var t=parseInt(e.getAttribute("tabindex"),10);return isNaN(t)?function(e){return"true"===e.contentEditable}(e)?0:e.tabIndex:t}function l(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex}function f(e){return"INPUT"===e.tagName}e.exports=o},function(e,t){e.exports=function(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var a in r)n.call(r,a)&&(e[a]=r[a])}return e};var n=Object.prototype.hasOwnProperty},function(e,t,n){"use strict";n.r(t);var r=n(0),a=n(1),o=n(2),c=n.n(o),i=n(4),u=n.n(i),s=n(3),l=n(5),f=n.n(l);n(7);function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var m=function(e){e.initialState,e.getInitialState,e.refs,e.getRefs,e.didMount,e.didUpdate,e.willUnmount,e.getSnapshotBeforeUpdate,e.shouldUpdate,e.render;return function(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["initialState","getInitialState","refs","getRefs","didMount","didUpdate","willUnmount","getSnapshotBeforeUpdate","shouldUpdate","render"])},v=function(e){function t(){var n,r;p(this,t);for(var a=arguments.length,o=Array(a),c=0;c<a;c++)o[c]=arguments[c];return n=r=d(this,e.call.apply(e,[this].concat(o))),b.call(r),d(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.getArgs=function(){var e=this.state,t=this.props,n=this._setState,r=this._forceUpdate,a=this._refs;return{state:e,props:m(t),refs:a,setState:n,forceUpdate:r}},t.prototype.componentDidMount=function(){this.props.didMount&&this.props.didMount(this.getArgs())},t.prototype.shouldComponentUpdate=function(e,t){return!this.props.shouldUpdate||this.props.shouldUpdate({props:this.props,state:this.state,nextProps:m(e),nextState:t})},t.prototype.componentWillUnmount=function(){this.props.willUnmount&&this.props.willUnmount({state:this.state,props:m(this.props),refs:this._refs})},t.prototype.componentDidUpdate=function(e,t,n){this.props.didUpdate&&this.props.didUpdate(Object.assign(this.getArgs(),{prevProps:m(e),prevState:t}),n)},t.prototype.getSnapshotBeforeUpdate=function(e,t){return this.props.getSnapshotBeforeUpdate?this.props.getSnapshotBeforeUpdate(Object.assign(this.getArgs(),{prevProps:m(e),prevState:t})):null},t.prototype.render=function(){var e=this.props,t=e.children,n=e.render;return n?n(this.getArgs()):"function"==typeof t?t(this.getArgs()):t||null},t}(f.a.Component);v.defaultProps={getInitialState:function(){},getRefs:function(){return{}}};var b=function(){var e=this;this.state=this.props.initialState||this.props.getInitialState(this.props),this._refs=this.props.refs||this.props.getRefs(this.getArgs()),this._setState=function(){return e.setState.apply(e,arguments)},this._forceUpdate=function(){return e.forceUpdate.apply(e,arguments)}},y=v,h=function(e){var t=e.children,n=e.container,a=void 0===n?document.body:n,o=e.type,c=void 0===o?"reach-portal":o;return Object(r.createElement)(y,{getRefs:function(){return{node:null}},didMount:function(e){var t=e.refs,n=e.forceUpdate,r=a.hasOwnProperty("current")?a.current:a;t.node=document.createElement(c),r.appendChild(t.node),n()},willUnmount:function(e){var t=e.refs.node,n=a.hasOwnProperty("current")?a.current:a;n&&n.removeChild(t)},render:function(e){var n=e.refs.node;return n?Object(r.createPortal)(t,n):null}})};var g=function(e,t){return function(n){if(e&&e(n),!n.defaultPrevented)return t(n)}},O=n(6),j=n.n(O);function w(){return(w=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function E(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var S=function(){},x=function(){},_=function(e,t){var n,r,a;e.disposeAriaHider=(n=e.overlayNode,r=[],a=[],Array.prototype.forEach.call(document.querySelectorAll("body > *"),(function(e){if(e!==n.parentNode){var t=e.getAttribute("aria-hidden");null!==t&&"false"!==t||(r.push(t),a.push(e),e.setAttribute("aria-hidden","true"))}})),function(){a.forEach((function(e,t){var n=r[t];null===n?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n)}))}),e.trap=j()(e.overlayNode,{initialFocus:t?function(){return t.current}:void 0,fallbackFocus:e.contentNode,escapeDeactivates:!1,clickOutsideDeactivates:!1})},A=function(e){var t=e.refs;t.trap.deactivate(),t.disposeAriaHider()},z=React.createContext(),C=React.forwardRef((function(e,t){var n=e.container,a=e.isOpen,o=void 0===a||a,c=e.onDismiss,i=void 0===c?S:c,u=e.initialFocusRef,s=e.onClick,l=e.onKeyDown,f=E(e,["container","isOpen","onDismiss","initialFocusRef","onClick","onKeyDown"]);return Object(r.createElement)(y,{didMount:x},o?Object(r.createElement)(h,{container:n,"data-reach-dialog-wrapper":!0},Object(r.createElement)(y,{refs:{overlayNode:null,contentNode:null},didMount:function(e){var t=e.refs;_(t,u)},willUnmount:A},(function(e){var n=e.refs;return Object(r.createElement)(z.Provider,{value:function(e){return n.contentNode=e}},Object(r.createElement)("div",w({"data-reach-dialog-overlay":!0,onClick:g(s,(function(e){e.stopPropagation(),i()})),onKeyDown:g(l,(function(e){"Escape"===e.key&&(e.stopPropagation(),i())})),ref:function(e){n.overlayNode=e,t&&t(e)}},f)))}))):null)}));C.propTypes={initialFocusRef:function(){}};var N=function(e){return e.stopPropagation()},P=React.forwardRef((function(e,t){var n=e.onClick,a=(e.onKeyDown,E(e,["onClick","onKeyDown"]));return Object(r.createElement)(z.Consumer,null,(function(e){return Object(r.createElement)("div",w({"aria-modal":"true","data-reach-dialog-content":!0,tabIndex:"-1",onClick:g(n,N),ref:function(n){e(n),t&&t(n)}},a))}))})),k=function(e){return!!e},D=function(e){var t=e.items,n=e.isVisible,a=void 0===n?k:n,o=e.render,i=e.className,u=e.onDismiss;return Object(r.createElement)(s.Transition,{items:t,onStart:function(){return document.body.classList[a(t)?"add":"remove"]("ct-dashboard-overlay-open")},config:{duration:200},from:{opacity:0,y:-10},enter:{opacity:1,y:0},leave:{opacity:0,y:10}},(function(e){return a(e)&&function(t){return Object(r.createElement)(C,{style:{opacity:t.opacity},container:document.querySelector("#wpbody"),onDismiss:function(){return u()}},Object(r.createElement)(P,{className:c()("ct-admin-modal",i),style:{transform:"translate3d(0px, ".concat(t.y,"px, 0px)")}},Object(r.createElement)("button",{className:"close-button",onClick:function(){return u()}},"×"),o(e,t)))}}))};function M(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function T(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?M(Object(n),!0).forEach((function(t){U(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function U(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function I(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,a=!1,o=void 0;try{for(var c,i=e[Symbol.iterator]();!(r=(c=i.next()).done)&&(n.push(c.value),!t||n.length!==t);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==i.return||i.return()}finally{if(a)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return R(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return R(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var F=function(e){var t=e.extsSyncLoading,n=e.extensionData,o=e.onExtsSync,i=I(Object(r.useState)(!1),2),u=i[0],l=i[1],f=I(Object(r.useState)(null),2),p=f[0],d=f[1];return Object(r.createElement)(r.Fragment,null,Object(r.createElement)("button",{className:"ct-button ct-config-btn","data-button":"white",onClick:function(){l(!0),d(n.settings)}},Object(a.__)("Configure","blc")),Object(r.createElement)(D,{items:u,onDismiss:function(){return l(!1)},className:"ct-product-reviews-settings-modal",render:function(){return Object(r.createElement)("div",{className:c()("ct-modal-content")},Object(r.createElement)("h2",null,Object(a.__)("Product Reviews Settings","blc")),Object(r.createElement)("p",{className:"ct-modal-description"},Object(a.__)("Configure the slugs for single and category pages of the product review custom post type.","blc")),Object(r.createElement)("div",{className:"ct-controls-group"},Object(r.createElement)("section",{"data-columns":"medium:2"},Object(r.createElement)(s.OptionsPanel,{onChange:function(e,t){return d((function(n){return T(T({},n),{},U({},e,t))}))},options:{single_slug:{type:"text",value:"",label:Object(a.__)("Single Slug","blc")},category_slug:{type:"text",value:"",label:Object(a.__)("Category Slug","blc")}},value:p||{},hasRevertButton:!1}))),Object(r.createElement)("div",{className:"ct-modal-actions has-divider"},Object(r.createElement)("button",{className:"button-primary",disabled:t||!p,onClick:function(e){e.preventDefault(),p&&(o({extAction:{type:"persist",settings:p}}),l(!1))}},t?Object(r.createElement)("svg",{width:"15",height:"15",viewBox:"0 0 100 100"},Object(r.createElement)("g",{transform:"translate(50,50)"},Object(r.createElement)("g",{transform:"scale(1)"},Object(r.createElement)("circle",{cx:"0",cy:"0",r:"50",fill:"#687c93"}),Object(r.createElement)("circle",{cx:"0",cy:"-26",r:"12",fill:"#ffffff",transform:"rotate(161.634)"},Object(r.createElement)("animateTransform",{attributeName:"transform",type:"rotate",calcMode:"linear",values:"0 0 0;360 0 0",keyTimes:"0;1",dur:"1s",begin:"0s",repeatCount:"indefinite"}))))):Object(a.__)("Save","blc"))))}}))};function L(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,a=!1,o=void 0;try{for(var c,i=e[Symbol.iterator]();!(r=(c=i.next()).done)&&(n.push(c.value),!t||n.length!==t);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==i.return||i.return()}finally{if(a)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return B(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return B(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var q=function(e){var t=L(Object(r.useState)(!1),2),n=t[0],a=t[1];return[function(){return a(!0)},Object(r.createElement)(D,{items:n,onDismiss:function(){return a(!1)},render:function(){return Object(r.createElement)("div",{className:"ct-modal-content",dangerouslySetInnerHTML:{__html:e.readme}})}})]};function K(e,t,n,r,a,o,c){try{var i=e[o](c),u=i.value}catch(e){return void n(e)}i.done?t(u):Promise.resolve(u).then(r,a)}function V(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function c(e){K(o,r,a,c,i,"next",e)}function i(e){K(o,r,a,c,i,"throw",e)}c(void 0)}))}}function H(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,a=!1,o=void 0;try{for(var c,i=e[Symbol.iterator]();!(r=(c=i.next()).done)&&(n.push(c.value),!t||n.length!==t);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==i.return||i.return()}finally{if(a)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return W(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return W(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function W(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var $=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},n=Object(r.useState)(!1),o=H(n,2),c=o[0],i=o[1],u=Object(r.useState)(!1),s=H(u,2),l=s[0],f=s[1],p=ctDashboardLocalizations.plugin_data.is_pro,d=function(){var n=V(regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(p||!e.config.pro){n.next=3;break}return f(!0),n.abrupt("return");case 3:return(r=new FormData).append("ext",e.name),r.append("action",e.__object?"blocksy_extension_deactivate":"blocksy_extension_activate"),i(!0),n.prev=7,n.next=10,fetch(ctDashboardLocalizations.ajax_url,{method:"POST",body:r});case 10:e.config.require_refresh&&location.reload(),t(),n.next=16;break;case 14:n.prev=14,n.t0=n.catch(7);case 16:i(!1);case 17:case"end":return n.stop()}}),n,null,[[7,14]])})));return function(){return n.apply(this,arguments)}}();return[c,d,!p&&e.config.pro?Object(r.createElement)(D,{items:l,onDismiss:function(){return f(!1)},render:function(){return Object(r.createElement)("div",{className:"ct-activation-action-modal"},Object(r.createElement)("svg",{viewBox:"0 0 59.99 60"},Object(r.createElement)("path",{d:"M14.41 43.65c0 .13.08.27.11.41a5.91 5.91 0 010 2.37c-1.78 1.14-3.2 1.19-4.34.68-2.83-1.27-3.81-6-3.81-6s.38-.08 1-.15a6.08 6.08 0 012.64.91 4.17 4.17 0 01-.22-1 6.47 6.47 0 013.2 1 8.14 8.14 0 01.35-5 12.74 12.74 0 01.65-1.62s8.51 4.32 3 9.27a5.81 5.81 0 01-2.34-.68 2 2 0 01-.24-.19zM7.17 15.93q.2.22.42.45a5.74 5.74 0 002.68-.74 5.51 5.51 0 00-.28 2.76 6.79 6.79 0 001.47.81c5 1.94 6.91-5.79 6.91-5.79a13.35 13.35 0 00-4.5-.26 5.64 5.64 0 00-2.15.72 4.42 4.42 0 00.23-.81c.51-2.62-.94-5.82-.94-5.82a13.76 13.76 0 00-2.44 1.51c-2 1.51-4 4-1.53 7a.65.65 0 00.13.17zm.93 16.56a6.7 6.7 0 00.84.76c7.28-1.28 2.36-9.46 2.36-9.46a14.28 14.28 0 00-2.18 1.69 7.39 7.39 0 00-2.13 3.35v-1.19a5.49 5.49 0 00-1.27-1.71 12.75 12.75 0 00-3.94-2.44 13.32 13.32 0 00-.39 1.37c-.49 2-.91 5.69 1.85 7a4.83 4.83 0 001.75.46 8.25 8.25 0 00.86 0 6.45 6.45 0 001.14-1.76 4.41 4.41 0 001.11 1.93zM18.79 9.27c6 1.85 8.82-7.61 8.82-7.61a17.44 17.44 0 00-6.1-.58c-2.92.35-5.71 1.92-5.33 6.76a8.42 8.42 0 002.61 1.43zM49.6 40.93a6.08 6.08 0 00-2.64.91 4.21 4.21 0 00.22-1 11.57 11.57 0 00-1.19-5.59 13.88 13.88 0 00-2.36 1.58c-1.87 1.58-3.82 4.16-1.33 7 .06.08.13.15.2.23s.29.3.46.45a5.69 5.69 0 002.65-.86 5.82 5.82 0 00-.14 2.78 6.75 6.75 0 001.34.68c5.16 1.94 6.81-6 6.81-6a13.28 13.28 0 00-4.02-.18zm-6.49-27.77a10.69 10.69 0 00-1.5.26s1.15 4.53 3.91 5.79c1.18.54 2.66.47 4.47-.81a5.88 5.88 0 00-.16-2.47 1.42 1.42 0 00-.1-.29l.23.13a6 6 0 002.45.61c5.24-5.19-3.42-9.13-3.42-9.13a13.57 13.57 0 00-.54 1.51 8.37 8.37 0 00-.17 5.12 6.62 6.62 0 00-3.29-.81 12.09 12.09 0 00-1.88.09zm15.13 10.33a13.53 13.53 0 00-2.61 1.37 7.1 7.1 0 00-2.64 2.78v1.18a6.69 6.69 0 00-1.73-2.89 13.85 13.85 0 00-2.62-2.14 13.17 13.17 0 00-.82 1.69c-.83 2-1.65 5.4 1 7a6.4 6.4 0 002.16.76 7.35 7.35 0 001-.93 4.26 4.26 0 001-1.76 6.06 6.06 0 00.76 1.3 6.25 6.25 0 00.4.5c7.43.09 4.1-8.86 4.1-8.86zM38.19 9.27c1.55.52 3.41.27 5.61-1.43.51-6.56-4.81-7.11-8.33-6.76a19.24 19.24 0 00-3.1.58S34.25 8 38.19 9.27zM41.99 54h-3v-6a2 2 0 00-2-2h-14a2 2 0 00-2 2v6h-3a2 2 0 00-2 2v3h28v-3a2 2 0 00-2-2zM25.76 21.65l-5.77.84a1 1 0 00-.81.68 1 1 0 00.26 1l4.19 4.11a1 1 0 01.28.88l-.92 5.44-.07.4a1 1 0 00.4 1 1 1 0 001.06.07l3.55-1.88 1.6-.85a1 1 0 01.94 0l2.4 1.27 2.75 1.46a1 1 0 001.05-.07 1 1 0 00.4-1l-1-5.81a1 1 0 01.28-.88l4.19-4.11a1 1 0 00.26-1 1 1 0 00-.81-.68l-5.78-.84a1 1 0 01-.75-.55l-2.57-5.3a1 1 0 00-1.8 0l-1.17 2.39-1.41 2.88a1 1 0 01-.75.55z",fill:"#ffa800"}),Object(r.createElement)("path",{d:"M19.99 22.49l5.78-.84a1 1 0 00.75-.55l1.41-2.88 1.41 2.88a1 1 0 00.75.55l5.78.84a1 1 0 01.56 1.71l-4.19 4.11a1 1 0 00-.29.88l.92 5.4-2.4-1.27a1 1 0 00-.94 0l-1.6.85-1.6-.85a1 1 0 00-.93 0l-2.41 1.28.92-5.41a1 1 0 00-.28-.88l-4.2-4.11a1 1 0 01-.26-1 1 1 0 01.82-.71zm-13 8.07a4.41 4.41 0 001.14 1.93c2.67-1.61 1.85-5 1-7a7.39 7.39 0 00-2.14 3.34 3.49 3.49 0 000 1.7zm11.8-21.29c3.94-1.27 5.82-7.61 5.82-7.61a19.24 19.24 0 00-3.1-.58c-2.92.35-5.71 1.92-5.33 6.76a8.42 8.42 0 002.61 1.43zm-7.31 9.94c2.76-1.26 3.91-5.79 3.91-5.79a10.69 10.69 0 00-1.5-.26 12.35 12.35 0 00-1.9-.09 4.42 4.42 0 01-.23.81 3.48 3.48 0 00-1.46 1.75 5.51 5.51 0 00-.31 2.77 6.79 6.79 0 001.49.81zm37.4 13.28a4.41 4.41 0 001.11-1.93 3.57 3.57 0 000-1.72 7.31 7.31 0 00-2.17-3.34c-.83 2.02-1.61 5.38 1.06 6.99zM45.5 19.21a6.79 6.79 0 001.49-.81 5.51 5.51 0 00-.26-2.76 3.53 3.53 0 00-1.46-1.75 5.79 5.79 0 00-2.13-.72 10.69 10.69 0 00-1.5.26s1.1 4.57 3.86 5.78zm-7.31-9.94a8.42 8.42 0 002.61-1.43c.38-4.84-2.41-6.41-5.33-6.76a19.24 19.24 0 00-3.1.58S34.25 8 38.19 9.27zm8.8 32.57l-1.4 1.8a5.82 5.82 0 00-.14 2.78 6.75 6.75 0 001.34.68c2.83-1.27 3.81-6 3.81-6s-.38-.08-1-.15a6.08 6.08 0 00-2.61.89zm1.42-33.08a8.37 8.37 0 00-.17 5.12l1.46 1.75a1.42 1.42 0 01.1.29.65.65 0 00.13-.16c2.48-2.97.44-5.49-1.52-7zm-6.15 35.08a1.92 1.92 0 00.31-.18 3.55 3.55 0 001.42-1.79 8.1 8.1 0 00-.35-5c-1.92 1.54-3.87 4.13-1.38 6.97zm13.37-19a7.1 7.1 0 00-2.64 2.8v2.91a6.06 6.06 0 00.76 1.3c2.79-1.3 2.37-4.98 1.88-6.99zM11.41 43.65l-1.34-1.75a6.08 6.08 0 00-2.64-.91c-.6.07-1 .15-1 .15s1 4.77 3.81 6a6.75 6.75 0 001.34-.68 5.82 5.82 0 00-.14-2.78zM38.99 54h-3v-6a2 2 0 00-2-2h-11a2 2 0 00-2 2v6h-3a2 2 0 00-2 2v3h25v-3a2 2 0 00-2-2zm-25.6-17.17a8.14 8.14 0 00-.35 5 3.45 3.45 0 001.31 1.72h.05c0 .13.08.27.11.41.07-.08.14-.15.2-.23 2.5-2.73.55-5.32-1.32-6.9z",fill:"#fedd0a"}),Object(r.createElement)("path",{d:"M16.18 7.84C15.8 3 18.59 1.43 21.51 1.08a14.84 14.84 0 013 0C21.6 1.44 18.82 3 19.2 7.84a8.42 8.42 0 002.59 1.43 4.81 4.81 0 01-3 0 8.42 8.42 0 01-2.61-1.43zm-7.61.92c-2 1.51-4 4-1.53 7a.65.65 0 00.13.16q.2.22.42.45a5.91 5.91 0 002.4-.61c-2.45-3-.42-5.49 1.54-7a13.57 13.57 0 00-.54-1.51 13.76 13.76 0 00-2.42 1.51zM15.99 56v3h3v-3a2 2 0 012-2h-3a2 2 0 00-2 2zm7-10a2 2 0 00-2 2v6h3v-6a2 2 0 012-2zM4.35 24.86a13.53 13.53 0 00-2.61-1.37 13.32 13.32 0 00-.39 1.37c-.49 2-.91 5.69 1.85 7a4.83 4.83 0 001.79.46 8.25 8.25 0 00.86 0 5.84 5.84 0 00.4-.5c-2.81-1.27-2.39-4.95-1.9-6.96z",fill:"#fff"}),Object(r.createElement)("path",{d:"M59.18 23.14a1 1 0 00-1.29-.59 14.74 14.74 0 00-3.85 2.26 24.35 24.35 0 00-.45-3.4 23.39 23.39 0 00-1.21-4 1 1 0 00.71-.29 5.42 5.42 0 001.9-4.91c-.64-3.56-5.44-5.78-5.65-5.87a1 1 0 00-1.32.5 14.57 14.57 0 00-.85 2.6 26.55 26.55 0 00-2.37-2.12 6.66 6.66 0 00-2.23-5.7C38.99-1.31 32.36.61 32.08.7a1 1 0 00-.59.48 1 1 0 00-.08.76c.08.28 2.09 6.87 6.51 8.3a5.84 5.84 0 001.74.27 7.41 7.41 0 004.15-1.44 22.7 22.7 0 013.1 3 1.48 1.48 0 000 .21 13.38 13.38 0 00-5.58.15 1 1 0 00-.72 1.21c.06.22 1.39 5.34 4.79 6.59a4.42 4.42 0 001.55.28 6.3 6.3 0 003.59-1.31 1.2 1.2 0 00.26-.29 22.46 22.46 0 01.82 2.88 21.37 21.37 0 01.43 3.47 15 15 0 00-2.86-2.35 1 1 0 00-1.38.34c-.11.2-2.81 4.75-1.3 8a5.31 5.31 0 004.07 2.87c-.08.21-.15.42-.24.63a21.75 21.75 0 01-2.25 4 14.51 14.51 0 00-1.26-4 1 1 0 00-.58-.5 1 1 0 00-.76.06c-.2.1-4.9 2.53-5.38 6.11a5.19 5.19 0 001.7 4.37 22.47 22.47 0 01-2.46 1.34A3 3 0 0036.99 45h-6V34.73l4.15 2.2a2.1 2.1 0 00.94.23 2 2 0 002-2.33l-1-5.81 4.2-4.11a2 2 0 00-1.12-3.4l-5.78-.85-2.59-5.26a2 2 0 00-3.6 0l-2.58 5.26-5.77.85a2 2 0 00-1.11 3.4L22.92 29l-1 5.81a2 2 0 00.8 1.94 2 2 0 002.11.15l4.16-2.17V45h-6a3 3 0 00-2.37 1.18 21 21 0 01-2.46-1.35 5.16 5.16 0 001.7-4.36c-.48-3.58-5.18-6-5.38-6.11a1 1 0 00-.76-.06 1 1 0 00-.58.5 14.38 14.38 0 00-1.26 4 21.11 21.11 0 01-2.25-4c-.09-.21-.16-.42-.24-.64a5.26 5.26 0 004.07-2.86c1.51-3.29-1.19-7.84-1.3-8a1 1 0 00-1.38-.34 15 15 0 00-2.86 2.35 21.37 21.37 0 01.43-3.47 22.46 22.46 0 01.82-2.88 1.2 1.2 0 00.26.29 6.3 6.3 0 003.56 1.28 4.42 4.42 0 001.55-.28c3.4-1.25 4.73-6.37 4.79-6.59a1 1 0 00-.72-1.21 13.57 13.57 0 00-5.58-.15 1.48 1.48 0 000-.21 22.7 22.7 0 013.1-3 7.39 7.39 0 004.15 1.44 5.73 5.73 0 001.73-.27c4.43-1.43 6.44-8 6.52-8.3a1 1 0 00-.08-.76 1 1 0 00-.55-.5c-.28-.09-6.89-2-10.51.92a6.66 6.66 0 00-2.23 5.7 26.55 26.55 0 00-2.37 2.12 14.57 14.57 0 00-.8-2.6 1 1 0 00-1.32-.5c-.2.09-5 2.31-5.65 5.87a5.42 5.42 0 001.91 4.88 1 1 0 00.71.29 23.65 23.65 0 00-1.21 4 24.35 24.35 0 00-.44 3.43 14.74 14.74 0 00-3.9-2.26 1 1 0 00-1.29.59c-.08.21-1.89 5.18.19 8.14a5.37 5.37 0 004.71 2.08h.11a1 1 0 00.73-.36c.09-.1.16-.22.25-.33a24.67 24.67 0 001 2.89 23.67 23.67 0 002.4 4.32 14.22 14.22 0 00-4 .19 1 1 0 00-.77 1.18c0 .22 1.15 5.4 4.49 6.8a4.41 4.41 0 001.75.35 6.4 6.4 0 003.43-1.15 1 1 0 00.44-.64 6.59 6.59 0 00.11-1.08l.84.59a23 23 0 003.51 1.97V53h-2a3 3 0 00-3 3v3a1 1 0 001 1h28a1 1 0 001-1v-3a3 3 0 00-3-3h-2v-4.91a23 23 0 003.51-1.94c.29-.19.56-.41.84-.62a7 7 0 00.11 1.11 1 1 0 00.44.64 6.4 6.4 0 003.43 1.15 4.41 4.41 0 001.75-.35c3.34-1.4 4.45-6.58 4.49-6.8a1 1 0 00-.77-1.18 14.22 14.22 0 00-4-.19 23.67 23.67 0 002.4-4.32 24.67 24.67 0 001-2.89c.09.11.16.23.25.33a1 1 0 00.73.33h.11a5.37 5.37 0 004.71-2.08c2.08-2.96.27-7.93.19-8.14zM38.65 6a22.22 22.22 0 013.4 1.82 4.32 4.32 0 01-3.51.53c-2.55-.82-4.18-4.24-4.86-6 1.81-.38 5.57-.88 7.65.81a4.12 4.12 0 011.42 2.71 23.48 23.48 0 00-3.33-1.75 1 1 0 00-1.31.53A1 1 0 0038.65 6zm-20-2.8c2.08-1.71 5.84-1.2 7.65-.83-.68 1.72-2.31 5.14-4.86 6a4.32 4.32 0 01-3.51-.53A22.22 22.22 0 0121.33 6a1 1 0 00.54-1.31 1 1 0 00-1.31-.53 24 24 0 00-3.33 1.75 4.12 4.12 0 011.42-2.73zM5.92 30.41a5.66 5.66 0 01-.58.94 3.27 3.27 0 01-2.71-1.21c-1-1.37-.65-3.75-.26-5.28a8.32 8.32 0 013.62 3.05v.61a4.45 4.45 0 00-.15.9 4.12 4.12 0 00.08.99zm6-15.39c1.25-1.11 3.66-1 5.21-.83-.55 1.47-1.64 3.61-3.21 4.18a3.23 3.23 0 01-2.93-.54 3.27 3.27 0 01.89-2.83zm-4.93-2.45c.29-1.65 2.21-3.11 3.56-3.91a8.35 8.35 0 01.38 4.61 3.81 3.81 0 00-.32.24 4.52 4.52 0 00-1.05 1.37 3.53 3.53 0 01-.56.25h-.01a4.51 4.51 0 01-.95.22 3.26 3.26 0 01-1.05-2.78zm.91 17c.09-1.7 1.78-3.37 3.09-4.32.66 1.42 1.4 3.7.7 5.23a3.23 3.23 0 01-2.43 1.69 3.25 3.25 0 01-1.41-2.63zm5.78 16.29a3.26 3.26 0 01-2.94.41c-1.55-.65-2.55-2.84-3-4.34a8.39 8.39 0 014.58.65 2.92 2.92 0 00.17.36 4.51 4.51 0 001.1 1.32 4.53 4.53 0 01.04 1.57zm3.08-2.36a5 5 0 01-.85-.21h-.08A2.84 2.84 0 0114.16 42c-.8-1.46-.22-3.8.34-5.27 1.32.86 3.16 2.4 3.38 4.06a3.28 3.28 0 01-1.17 2.68zm7.19-8.3l1-5.8a2 2 0 00-.57-1.77l-4.19-4.11 5.77-.85a2 2 0 001.51-1.1l2.52-5.3 2.58 5.27a2 2 0 001.51 1.1l5.77.84-4.19 4.12a2 2 0 00-.57 1.76l1 5.8-5.15-2.73a2 2 0 00-1.88 0zM21.99 48a1 1 0 011-1h14a1 1 0 011 1v5h-16zm20 7a1 1 0 011 1v2h-26v-2a1 1 0 011-1h24zm3.83-13a2.84 2.84 0 01-1.62 1.28h-.07a6.37 6.37 0 01-.86.21 3.28 3.28 0 01-1.17-2.73c.22-1.66 2.06-3.2 3.38-4.06.56 1.45 1.14 3.79.34 5.3zm6.5-.05c-.48 1.5-1.48 3.69-3 4.34a3.26 3.26 0 01-2.94-.41 4.53 4.53 0 01.12-1.6 4.51 4.51 0 001.1-1.32c.07-.12.11-.24.17-.36a8.39 8.39 0 014.55-.7zM46.1 18.37c-1.57-.57-2.66-2.71-3.21-4.18 1.55-.22 4-.28 5.21.83a3.27 3.27 0 01.89 2.81 3.26 3.26 0 01-2.89.54zm4.67 13.8a3.23 3.23 0 01-2.43-1.69c-.7-1.52 0-3.8.71-5.23 1.25.95 3 2.62 3.08 4.29a3.25 3.25 0 01-1.36 2.63zm1.22-16.82a4.75 4.75 0 01-1-.22 3.87 3.87 0 01-.55-.25 4.52 4.52 0 00-1-1.37 3.81 3.81 0 00-.32-.24 8.45 8.45 0 01.38-4.61c1.35.8 3.27 2.25 3.56 3.9a3.27 3.27 0 01-1.07 2.79zm5.36 14.79a3.27 3.27 0 01-2.71 1.21 5.66 5.66 0 01-.58-.94 4.09 4.09 0 00.06-1 5.28 5.28 0 00-.15-.9v-.6a8.37 8.37 0 013.6-3.06c.42 1.54.74 3.92-.22 5.29zM33.99 50a1 1 0 01-1 1h-6a1 1 0 010-2h6a1 1 0 011 1z"})),Object(r.createElement)("h2",null,"Upgrade to Pro"),Object(r.createElement)("p",null,Object(a.__)("Upgrade to the Pro version and get instant full access to all premium extensions and features.","blc")),Object(r.createElement)("button",{className:"ct-button-primary"},Object(a.__)("Upgrade Now","blc")))}}):null]};function Y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,a=!1,o=void 0;try{for(var c,i=e[Symbol.iterator]();!(r=(c=i.next()).done)&&(n.push(c.value),!t||n.length!==t);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==i.return||i.return()}finally{if(a)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return G(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return G(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function G(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var J=function(e){var t=e.extsSyncLoading,n=e.extension,o=e.onExtsSync,i=Y($(n,(function(){return o()})),2),u=i[0],s=i[1],l=Y(q(n),2),f=l[0],p=l[1];return Object(r.createElement)("li",{className:c()({active:!!n.__object})},Object(r.createElement)("h4",{className:"ct-extension-title"},n.config.name,u&&Object(r.createElement)("svg",{width:"15",height:"15",viewBox:"0 0 100 100"},Object(r.createElement)("g",{transform:"translate(50,50)"},Object(r.createElement)("g",{transform:"scale(1)"},Object(r.createElement)("circle",{cx:"0",cy:"0",r:"50",fill:"#687c93"}),Object(r.createElement)("circle",{cx:"0",cy:"-26",r:"12",fill:"#ffffff",transform:"rotate(161.634)"},Object(r.createElement)("animateTransform",{attributeName:"transform",type:"rotate",calcMode:"linear",values:"0 0 0;360 0 0",keyTimes:"0;1",dur:"1s",begin:"0s",repeatCount:"indefinite"})))))),n.config.description&&Object(r.createElement)("div",{className:"ct-extension-description"},n.config.description),Object(r.createElement)("div",{className:"ct-extension-actions"},Object(r.createElement)("button",{className:c()(n.__object?"ct-button":"ct-button-primary"),"data-button":"white",disabled:u,onClick:function(){s()}},n.__object?Object(a.__)("Deactivate","blc"):Object(a.__)("Activate","blc")),n.__object&&Object(r.createElement)(F,{extsSyncLoading:t,extensionData:n.data,onExtsSync:o}),n.readme&&Object(r.createElement)("button",{onClick:function(){return f()},"data-button":"white",className:"ct-minimal-button ct-instruction"},Object(r.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24"},Object(r.createElement)("path",{d:"M12,2C6.477,2,2,6.477,2,12s4.477,10,10,10s10-4.477,10-10S17.523,2,12,2z M12,17L12,17c-0.552,0-1-0.448-1-1v-4 c0-0.552,0.448-1,1-1h0c0.552,0,1,0.448,1,1v4C13,16.552,12.552,17,12,17z M12.5,9h-1C11.224,9,11,8.776,11,8.5v-1 C11,7.224,11.224,7,11.5,7h1C12.776,7,13,7.224,13,7.5v1C13,8.776,12.776,9,12.5,9z"})))),p)};u.a.on("ct:extensions:card",(function(e){var t=e.CustomComponent;"product-reviews"===e.extension.name&&(t.extension=J)}))}]);
|
trunk/framework/extensions/product-reviews/static/bundle/main-admin.css
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* - v1.7.62
|
3 |
+
*
|
4 |
+
* Copyright (c) 2021
|
5 |
+
* Licensed GPLv2+
|
6 |
+
*/
|
7 |
+
|
8 |
+
.ct-product-reviews-settings-modal .ct-controls-group{padding-top:30px;margin-top:5px;border-top:1px dashed #eee}
|
trunk/framework/extensions/product-reviews/static/bundle/main.css
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* - v1.7.62
|
3 |
+
*
|
4 |
+
* Copyright (c) 2021
|
5 |
+
* Licensed GPLv2+
|
6 |
+
*/
|
7 |
+
|
8 |
+
.ct-product-hero .flexy-container{overflow:hidden}@media (max-width: 999.98px){.ct-product-hero .flexy-pills{--thumbs-spacing: 10px}}@media (min-width: 1000px){.ct-product-hero .flexy-pills{max-width:70%;margin:-8% auto 0 auto;--thumbs-spacing: 20px}}.ct-product-hero .flexy-pills ol{margin:0 calc(var(--thumbs-spacing) * -1)}.ct-product-hero .flexy-pills li{padding-top:var(--thumbs-spacing);padding-left:var(--thumbs-spacing);padding-right:var(--thumbs-spacing)}.ct-product-hero .flexy-pills li img{width:100%;border-radius:3px;border-radius:2px;border:3px solid #fff}.ct-product-hero .hero-section{margin-top:var(--margin-bottom)}.ct-product-scores{display:grid;grid-column-gap:25px;grid-row-gap:25px;margin:0 auto;max-width:800px}@media (min-width: 690px){.ct-product-scores{grid-template-columns:2fr 1fr}}.ct-product-scores:not(:last-child){margin-bottom:60px}.ct-product-scores li{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;padding:10px 20px;background:rgba(243,243,243,0.5);border-radius:2px}.ct-product-scores li:hover{background:#f3f3f3}.ct-product-scores li>span{font-size:15px;font-weight:500}.ct-overall-score{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:20px;color:#fff;border-radius:2px;background:#1A202C}.ct-overall-score .ct-average-score{font-size:55px;font-weight:800;line-height:normal;margin-bottom:10px}.ct-overall-score .ct-score-label{font-size:15px;font-weight:700;text-transform:uppercase;letter-spacing:0.02em;color:#fff;margin:15px 0 0 0}.ct-overall-score-layer{display:flex;flex-wrap:wrap;align-items:center}.ct-overall-score-layer .ct-score-label,.ct-overall-score-layer .ct-average-score{font-size:14px;font-weight:600}.ct-overall-score-layer .ct-average-score{margin:0 5px}.ct-overall-score-layer .star-rating{margin-left:auto}.ct-product-actions{display:flex;align-items:center;justify-content:center}.ct-product-actions:not(:last-child){margin-bottom:60px}.ct-product-actions .ct-button:not(:last-child){margin-right:25px}.ct-product-actions .ct-icon-container{color:inherit;margin-left:10px}.ct-product-description:not(:last-child){margin-bottom:60px}.ct-product-info{display:grid;grid-template-columns:var(--grid-template-columns);grid-column-gap:40px;grid-row-gap:40px;border-top:1px solid #ececec;padding-top:var(--content-vertical-spacing, 60px)}@media (min-width: 1000px){.ct-product-info{--grid-template-columns: 1.5fr 1fr 1fr}}@media (min-width: 690px) and (max-width: 999.98px){.ct-product-info{--grid-template-columns: 1fr 1fr}}@media (min-width: 690px) and (max-width: 999.98px){.ct-specs{grid-column:1/-1}}.ct-specs ul{display:grid;grid-column-gap:40px}@media (min-width: 690px){.ct-specs ul{grid-template-columns:repeat(2, 1fr)}}.ct-product-hero{padding-top:var(--content-vertical-spacing, 60px)}.ct-product-hero .ct-container{padding-bottom:var(--content-vertical-spacing, 60px);border-bottom:1px solid #ececec}.ct-product-hero ul{--listIndent: 0;--listStyleType: none;--contentSpacing: 0}
|
trunk/framework/extensions/product-reviews/static/js/EditSettings.js
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import {
|
2 |
+
createElement,
|
3 |
+
Component,
|
4 |
+
useEffect,
|
5 |
+
useState,
|
6 |
+
Fragment,
|
7 |
+
} from '@wordpress/element'
|
8 |
+
import ctEvents from 'ct-events'
|
9 |
+
|
10 |
+
import { OptionsPanel } from 'blocksy-options'
|
11 |
+
import nanoid from 'nanoid'
|
12 |
+
|
13 |
+
import classnames from 'classnames'
|
14 |
+
import { __, sprintf } from 'ct-i18n'
|
15 |
+
import Overlay from '../../../../../static/js/helpers/Overlay'
|
16 |
+
|
17 |
+
const EditSettings = ({ extsSyncLoading, extensionData, onExtsSync }) => {
|
18 |
+
const [isEditing, setIsEditing] = useState(false)
|
19 |
+
const [settings, setSettings] = useState(null)
|
20 |
+
|
21 |
+
return (
|
22 |
+
<Fragment>
|
23 |
+
<button
|
24 |
+
className="ct-button ct-config-btn"
|
25 |
+
data-button="white"
|
26 |
+
onClick={() => {
|
27 |
+
setIsEditing(true)
|
28 |
+
setSettings(extensionData.settings)
|
29 |
+
}}>
|
30 |
+
{__('Configure', 'blc')}
|
31 |
+
</button>
|
32 |
+
|
33 |
+
<Overlay
|
34 |
+
items={isEditing}
|
35 |
+
onDismiss={() => setIsEditing(false)}
|
36 |
+
className={'ct-product-reviews-settings-modal'}
|
37 |
+
render={() => (
|
38 |
+
<div className={classnames('ct-modal-content')}>
|
39 |
+
<h2>{__('Product Reviews Settings', 'blc')}</h2>
|
40 |
+
|
41 |
+
<p className="ct-modal-description">
|
42 |
+
{__(
|
43 |
+
'Configure the slugs for single and category pages of the product review custom post type.',
|
44 |
+
'blc'
|
45 |
+
)}
|
46 |
+
</p>
|
47 |
+
|
48 |
+
<div className="ct-controls-group">
|
49 |
+
<section data-columns="medium:2">
|
50 |
+
<OptionsPanel
|
51 |
+
onChange={(optionId, optionValue) =>
|
52 |
+
setSettings((settings) => ({
|
53 |
+
...settings,
|
54 |
+
[optionId]: optionValue,
|
55 |
+
}))
|
56 |
+
}
|
57 |
+
options={{
|
58 |
+
single_slug: {
|
59 |
+
type: 'text',
|
60 |
+
value: '',
|
61 |
+
label: __('Single Slug', 'blc'),
|
62 |
+
},
|
63 |
+
|
64 |
+
category_slug: {
|
65 |
+
type: 'text',
|
66 |
+
value: '',
|
67 |
+
label: __('Category Slug', 'blc'),
|
68 |
+
},
|
69 |
+
}}
|
70 |
+
value={settings || {}}
|
71 |
+
hasRevertButton={false}
|
72 |
+
/>
|
73 |
+
</section>
|
74 |
+
</div>
|
75 |
+
|
76 |
+
<div className="ct-modal-actions has-divider">
|
77 |
+
<button
|
78 |
+
className="button-primary"
|
79 |
+
disabled={extsSyncLoading || !settings}
|
80 |
+
onClick={(e) => {
|
81 |
+
e.preventDefault()
|
82 |
+
|
83 |
+
if (!settings) {
|
84 |
+
return
|
85 |
+
}
|
86 |
+
|
87 |
+
onExtsSync({
|
88 |
+
extAction: {
|
89 |
+
type: 'persist',
|
90 |
+
settings,
|
91 |
+
},
|
92 |
+
})
|
93 |
+
|
94 |
+
setIsEditing(false)
|
95 |
+
}}>
|
96 |
+
{extsSyncLoading ? (
|
97 |
+
<svg
|
98 |
+
width="15"
|
99 |
+
height="15"
|
100 |
+
viewBox="0 0 100 100">
|
101 |
+
<g transform="translate(50,50)">
|
102 |
+
<g transform="scale(1)">
|
103 |
+
<circle
|
104 |
+
cx="0"
|
105 |
+
cy="0"
|
106 |
+
r="50"
|
107 |
+
fill="#687c93"
|
108 |
+
/>
|
109 |
+
<circle
|
110 |
+
cx="0"
|
111 |
+
cy="-26"
|
112 |
+
r="12"
|
113 |
+
fill="#ffffff"
|
114 |
+
transform="rotate(161.634)">
|
115 |
+
<animateTransform
|
116 |
+
attributeName="transform"
|
117 |
+
type="rotate"
|
118 |
+
calcMode="linear"
|
119 |
+
values="0 0 0;360 0 0"
|
120 |
+
keyTimes="0;1"
|
121 |
+
dur="1s"
|
122 |
+
begin="0s"
|
123 |
+
repeatCount="indefinite"
|
124 |
+
/>
|
125 |
+
</circle>
|
126 |
+
</g>
|
127 |
+
</g>
|
128 |
+
</svg>
|
129 |
+
) : (
|
130 |
+
__('Save', 'blc')
|
131 |
+
)}
|
132 |
+
</button>
|
133 |
+
</div>
|
134 |
+
</div>
|
135 |
+
)}
|
136 |
+
/>
|
137 |
+
</Fragment>
|
138 |
+
)
|
139 |
+
}
|
140 |
+
|
141 |
+
export default EditSettings
|
trunk/framework/extensions/product-reviews/static/js/ProductReviews.js
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import {
|
2 |
+
createElement,
|
3 |
+
Component,
|
4 |
+
useEffect,
|
5 |
+
useState,
|
6 |
+
Fragment,
|
7 |
+
} from '@wordpress/element'
|
8 |
+
import { __ } from 'ct-i18n'
|
9 |
+
import classnames from 'classnames'
|
10 |
+
|
11 |
+
import EditSettings from './EditSettings'
|
12 |
+
import useExtensionReadme from '../../../../../static/js/helpers/useExtensionReadme'
|
13 |
+
import useActivationAction from '../../../../../static/js/helpers/useActivationAction'
|
14 |
+
|
15 |
+
const ProductReviews = ({ extsSyncLoading, extension, onExtsSync }) => {
|
16 |
+
const [isLoading, activationAction] = useActivationAction(extension, () =>
|
17 |
+
onExtsSync()
|
18 |
+
)
|
19 |
+
|
20 |
+
const [showReadme, readme] = useExtensionReadme(extension)
|
21 |
+
|
22 |
+
return (
|
23 |
+
<li className={classnames({ active: !!extension.__object })}>
|
24 |
+
<h4 className="ct-extension-title">
|
25 |
+
{extension.config.name}
|
26 |
+
|
27 |
+
{isLoading && (
|
28 |
+
<svg width="15" height="15" viewBox="0 0 100 100">
|
29 |
+
<g transform="translate(50,50)">
|
30 |
+
<g transform="scale(1)">
|
31 |
+
<circle cx="0" cy="0" r="50" fill="#687c93" />
|
32 |
+
<circle
|
33 |
+
cx="0"
|
34 |
+
cy="-26"
|
35 |
+
r="12"
|
36 |
+
fill="#ffffff"
|
37 |
+
transform="rotate(161.634)">
|
38 |
+
<animateTransform
|
39 |
+
attributeName="transform"
|
40 |
+
type="rotate"
|
41 |
+
calcMode="linear"
|
42 |
+
values="0 0 0;360 0 0"
|
43 |
+
keyTimes="0;1"
|
44 |
+
dur="1s"
|
45 |
+
begin="0s"
|
46 |
+
repeatCount="indefinite"
|
47 |
+
/>
|
48 |
+
</circle>
|
49 |
+
</g>
|
50 |
+
</g>
|
51 |
+
</svg>
|
52 |
+
)}
|
53 |
+
</h4>
|
54 |
+
|
55 |
+
{extension.config.description && (
|
56 |
+
<div className="ct-extension-description">
|
57 |
+
{extension.config.description}
|
58 |
+
</div>
|
59 |
+
)}
|
60 |
+
|
61 |
+
<div className="ct-extension-actions">
|
62 |
+
<button
|
63 |
+
className={classnames(
|
64 |
+
extension.__object ? 'ct-button' : 'ct-button-primary'
|
65 |
+
)}
|
66 |
+
data-button="white"
|
67 |
+
disabled={isLoading}
|
68 |
+
onClick={() => {
|
69 |
+
activationAction()
|
70 |
+
}}>
|
71 |
+
{extension.__object
|
72 |
+
? __('Deactivate', 'blc')
|
73 |
+
: __('Activate', 'blc')}
|
74 |
+
</button>
|
75 |
+
|
76 |
+
{extension.__object && (
|
77 |
+
<EditSettings
|
78 |
+
extsSyncLoading={extsSyncLoading}
|
79 |
+
extensionData={extension.data}
|
80 |
+
onExtsSync={onExtsSync}
|
81 |
+
/>
|
82 |
+
)}
|
83 |
+
|
84 |
+
{extension.readme && (
|
85 |
+
<button
|
86 |
+
onClick={() => showReadme()}
|
87 |
+
data-button="white"
|
88 |
+
className="ct-minimal-button ct-instruction">
|
89 |
+
<svg width="16" height="16" viewBox="0 0 24 24">
|
90 |
+
<path d="M12,2C6.477,2,2,6.477,2,12s4.477,10,10,10s10-4.477,10-10S17.523,2,12,2z M12,17L12,17c-0.552,0-1-0.448-1-1v-4 c0-0.552,0.448-1,1-1h0c0.552,0,1,0.448,1,1v4C13,16.552,12.552,17,12,17z M12.5,9h-1C11.224,9,11,8.776,11,8.5v-1 C11,7.224,11.224,7,11.5,7h1C12.776,7,13,7.224,13,7.5v1C13,8.776,12.776,9,12.5,9z" />
|
91 |
+
</svg>
|
92 |
+
</button>
|
93 |
+
)}
|
94 |
+
</div>
|
95 |
+
{readme}
|
96 |
+
</li>
|
97 |
+
)
|
98 |
+
}
|
99 |
+
|
100 |
+
export default ProductReviews
|
trunk/framework/extensions/product-reviews/static/js/dashboard.js
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { createElement } from '@wordpress/element'
|
2 |
+
|
3 |
+
import ProductReviews from './ProductReviews'
|
4 |
+
|
5 |
+
import ctEvents from 'ct-events'
|
6 |
+
|
7 |
+
ctEvents.on('ct:extensions:card', ({ CustomComponent, extension }) => {
|
8 |
+
if (extension.name !== 'product-reviews') return
|
9 |
+
CustomComponent.extension = ProductReviews
|
10 |
+
})
|
trunk/framework/extensions/product-reviews/static/sass/actions.scss
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.ct-product-actions {
|
2 |
+
display: flex;
|
3 |
+
align-items: center;
|
4 |
+
justify-content: center;
|
5 |
+
|
6 |
+
&:not(:last-child) {
|
7 |
+
margin-bottom: 60px;
|
8 |
+
}
|
9 |
+
|
10 |
+
.ct-button:not(:last-child) {
|
11 |
+
margin-right: 25px;
|
12 |
+
}
|
13 |
+
|
14 |
+
.ct-icon-container {
|
15 |
+
color: inherit;
|
16 |
+
margin-left: 10px;
|
17 |
+
}
|
18 |
+
}
|
trunk/framework/extensions/product-reviews/static/sass/description.scss
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.ct-product-description {
|
2 |
+
&:not(:last-child) {
|
3 |
+
margin-bottom: 60px;
|
4 |
+
}
|
5 |
+
}
|
trunk/framework/extensions/product-reviews/static/sass/main-admin.scss
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.ct-product-reviews-settings-modal {
|
2 |
+
|
3 |
+
.ct-controls-group {
|
4 |
+
padding-top: 30px;
|
5 |
+
margin-top: 5px;
|
6 |
+
border-top: 1px dashed #eee;
|
7 |
+
}
|
8 |
+
}
|
trunk/framework/extensions/product-reviews/static/sass/main.scss
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@import '../../../../../static/sass/common-frontend';
|
2 |
+
@import 'slider';
|
3 |
+
@import 'title';
|
4 |
+
@import 'scores';
|
5 |
+
@import 'actions';
|
6 |
+
@import 'description';
|
7 |
+
@import 'quick-info';
|
8 |
+
|
9 |
+
.ct-product-hero {
|
10 |
+
padding-top: var(--content-vertical-spacing, 60px);
|
11 |
+
|
12 |
+
.ct-container {
|
13 |
+
padding-bottom: var(--content-vertical-spacing, 60px);
|
14 |
+
border-bottom: 1px solid #ececec;
|
15 |
+
}
|
16 |
+
|
17 |
+
ul {
|
18 |
+
--listIndent: 0;
|
19 |
+
// --listItemSpacing: 0;
|
20 |
+
--listStyleType: none;
|
21 |
+
--contentSpacing: 0;
|
22 |
+
}
|
23 |
+
}
|
trunk/framework/extensions/product-reviews/static/sass/quick-info.scss
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.ct-product-info {
|
2 |
+
display: grid;
|
3 |
+
grid-template-columns: var(--grid-template-columns);
|
4 |
+
grid-column-gap: 40px;
|
5 |
+
grid-row-gap: 40px;
|
6 |
+
|
7 |
+
border-top: 1px solid #ececec;
|
8 |
+
padding-top: var(--content-vertical-spacing, 60px);
|
9 |
+
|
10 |
+
@include media-breakpoint-up (lg) {
|
11 |
+
--grid-template-columns: 1.5fr 1fr 1fr;
|
12 |
+
}
|
13 |
+
|
14 |
+
@include media-breakpoint-only (md) {
|
15 |
+
--grid-template-columns: 1fr 1fr;
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
.ct-specs {
|
20 |
+
@include media-breakpoint-only (md) {
|
21 |
+
grid-column: 1/-1;
|
22 |
+
}
|
23 |
+
|
24 |
+
ul {
|
25 |
+
display: grid;
|
26 |
+
grid-column-gap: 40px;
|
27 |
+
|
28 |
+
@include media-breakpoint-up (md) {
|
29 |
+
grid-template-columns: repeat(2, 1fr);
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
trunk/framework/extensions/product-reviews/static/sass/scores.scss
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.ct-product-scores {
|
2 |
+
display: grid;
|
3 |
+
grid-column-gap: 25px;
|
4 |
+
grid-row-gap: 25px;
|
5 |
+
margin: 0 auto;
|
6 |
+
max-width: 800px;
|
7 |
+
|
8 |
+
@include media-breakpoint-up (md) {
|
9 |
+
grid-template-columns: 2fr 1fr;
|
10 |
+
}
|
11 |
+
|
12 |
+
&:not(:last-child) {
|
13 |
+
margin-bottom: 60px;
|
14 |
+
}
|
15 |
+
|
16 |
+
li {
|
17 |
+
display: flex;
|
18 |
+
flex-wrap: wrap;
|
19 |
+
align-items: center;
|
20 |
+
justify-content: space-between;
|
21 |
+
padding: 10px 20px;
|
22 |
+
background: rgba(243, 243, 243, 0.5);
|
23 |
+
border-radius: 2px;
|
24 |
+
// --listItemSpacing: 5px;
|
25 |
+
|
26 |
+
&:hover {
|
27 |
+
background: rgba(243, 243, 243, 1);
|
28 |
+
}
|
29 |
+
|
30 |
+
> span {
|
31 |
+
font-size: 15px;
|
32 |
+
font-weight: 500;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
.ct-overall-score {
|
38 |
+
display: flex;
|
39 |
+
flex-direction: column;
|
40 |
+
align-items: center;
|
41 |
+
justify-content: center;
|
42 |
+
padding: 20px;
|
43 |
+
color: #fff;
|
44 |
+
border-radius: 2px;
|
45 |
+
background: #1A202C;
|
46 |
+
|
47 |
+
.ct-average-score {
|
48 |
+
font-size: 55px;
|
49 |
+
font-weight: 800;
|
50 |
+
line-height: normal;
|
51 |
+
margin-bottom: 10px;
|
52 |
+
}
|
53 |
+
|
54 |
+
.ct-score-label {
|
55 |
+
font-size: 15px;
|
56 |
+
font-weight: 700;
|
57 |
+
text-transform: uppercase;
|
58 |
+
letter-spacing: 0.02em;
|
59 |
+
color: #fff;
|
60 |
+
margin: 15px 0 0 0;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
// layer
|
65 |
+
.ct-overall-score-layer {
|
66 |
+
display: flex;
|
67 |
+
flex-wrap: wrap;
|
68 |
+
align-items: center;
|
69 |
+
|
70 |
+
.ct-score-label,
|
71 |
+
.ct-average-score {
|
72 |
+
font-size: 14px;
|
73 |
+
font-weight: 600;
|
74 |
+
}
|
75 |
+
|
76 |
+
.ct-average-score {
|
77 |
+
margin: 0 5px;
|
78 |
+
}
|
79 |
+
|
80 |
+
.star-rating {
|
81 |
+
margin-left: auto;
|
82 |
+
}
|
83 |
+
}
|
trunk/framework/extensions/product-reviews/static/sass/slider.scss
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.ct-product-hero {
|
2 |
+
|
3 |
+
.flexy-container {
|
4 |
+
overflow: hidden;
|
5 |
+
}
|
6 |
+
|
7 |
+
.flexy-pills {
|
8 |
+
@include media-breakpoint-down (md) {
|
9 |
+
--thumbs-spacing: 10px;
|
10 |
+
}
|
11 |
+
|
12 |
+
@include media-breakpoint-up (lg) {
|
13 |
+
max-width: 70%;
|
14 |
+
margin: -8% auto 0 auto;
|
15 |
+
|
16 |
+
--thumbs-spacing: 20px;
|
17 |
+
}
|
18 |
+
|
19 |
+
ol {
|
20 |
+
margin: 0 calc(var(--thumbs-spacing) * -1);
|
21 |
+
}
|
22 |
+
|
23 |
+
li {
|
24 |
+
padding-top: var(--thumbs-spacing);
|
25 |
+
padding-left: var(--thumbs-spacing);
|
26 |
+
padding-right: var(--thumbs-spacing);
|
27 |
+
|
28 |
+
img {
|
29 |
+
width: 100%;
|
30 |
+
border-radius: 3px;
|
31 |
+
border-radius: 2px;
|
32 |
+
border: 3px solid #fff;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
trunk/framework/extensions/product-reviews/static/sass/title.scss
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.ct-product-hero {
|
2 |
+
|
3 |
+
.hero-section {
|
4 |
+
margin-top: var(--margin-bottom);
|
5 |
+
}
|
6 |
+
}
|
trunk/framework/extensions/product-reviews/views/single-top.php
ADDED
@@ -0,0 +1,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$atts = blocksy_get_post_options(null, [
|
4 |
+
'meta_id' => 'blocksy_product_review_options'
|
5 |
+
]);
|
6 |
+
|
7 |
+
$gallery_images = array_map(function ($item) {
|
8 |
+
return $item['attachment_id'];
|
9 |
+
}, blocksy_akg('gallery', $atts, []));
|
10 |
+
|
11 |
+
$thumb_id = get_post_thumbnail_id();
|
12 |
+
|
13 |
+
if ($thumb_id) {
|
14 |
+
array_unshift($gallery_images, intval($thumb_id));
|
15 |
+
} else {
|
16 |
+
$gallery_images = [];
|
17 |
+
}
|
18 |
+
|
19 |
+
echo '<section class="ct-product-hero">';
|
20 |
+
echo '<div class="ct-container">';
|
21 |
+
if (count($gallery_images) === 1) {
|
22 |
+
$attachment_id = $gallery_images[0];
|
23 |
+
|
24 |
+
$image_href = wp_get_attachment_image_src(
|
25 |
+
$attachment_id,
|
26 |
+
'full'
|
27 |
+
);
|
28 |
+
|
29 |
+
$width = null;
|
30 |
+
$height = null;
|
31 |
+
|
32 |
+
if ($image_href) {
|
33 |
+
$width = $image_href[1];
|
34 |
+
$height = $image_href[2];
|
35 |
+
|
36 |
+
$image_href = $image_href[0];
|
37 |
+
}
|
38 |
+
|
39 |
+
echo blocksy_image([
|
40 |
+
'attachment_id' => $gallery_images[0],
|
41 |
+
'size' => 'full',
|
42 |
+
'ratio' => '2/1',
|
43 |
+
'tag_name' => 'a',
|
44 |
+
'html_atts' => array_merge([
|
45 |
+
'href' => $image_href
|
46 |
+
], $width ? [
|
47 |
+
'data-width' => $width,
|
48 |
+
'data-height' => $height
|
49 |
+
] : []),
|
50 |
+
]);
|
51 |
+
}
|
52 |
+
|
53 |
+
if (count($gallery_images) > 1) {
|
54 |
+
$args = [
|
55 |
+
'images' => $gallery_images,
|
56 |
+
'size' => 'full',
|
57 |
+
'images_ratio' => '2/1'
|
58 |
+
];
|
59 |
+
|
60 |
+
$args['pills_images'] = $gallery_images;
|
61 |
+
|
62 |
+
if (count($gallery_images) <= 5) {
|
63 |
+
} else {
|
64 |
+
$args['pills_have_arrows'] = true;
|
65 |
+
$args['pills_container_attr'] = [
|
66 |
+
'data-flexy' => 'no'
|
67 |
+
];
|
68 |
+
}
|
69 |
+
|
70 |
+
echo blocksy_flexy($args);
|
71 |
+
}
|
72 |
+
|
73 |
+
echo blocksy_output_hero_section([
|
74 |
+
'type' => 'type-1'
|
75 |
+
]);
|
76 |
+
|
77 |
+
$scores = blocksy_akg('scores', $atts, []);
|
78 |
+
|
79 |
+
if (! empty($scores)) {
|
80 |
+
echo '<div class="ct-product-scores">';
|
81 |
+
|
82 |
+
echo '<ul>';
|
83 |
+
|
84 |
+
foreach ($scores as $single_score) {
|
85 |
+
echo '<li>';
|
86 |
+
echo '<span>' . $single_score['label'] . '</span>';
|
87 |
+
|
88 |
+
echo '<div class="star-rating" role="img">';
|
89 |
+
$width = ( ( intval($single_score['score']) / 5 ) * 100 );
|
90 |
+
|
91 |
+
echo '<span style="width: ' . $width . '%;">Rated <strong class="rating">3</strong> out of 5</span>';
|
92 |
+
echo '</div>';
|
93 |
+
echo '</li>';
|
94 |
+
}
|
95 |
+
|
96 |
+
echo '</ul>';
|
97 |
+
|
98 |
+
echo '<div class="ct-overall-score">';
|
99 |
+
|
100 |
+
$avg_score = round(array_reduce($scores, function ($carry, $score) {
|
101 |
+
return $carry + intval($score['score']);
|
102 |
+
}, 0) / count($scores) * 2) / 2;
|
103 |
+
|
104 |
+
echo '<span class="ct-average-score">' . $avg_score . '/5</span>';
|
105 |
+
|
106 |
+
echo '<div class="star-rating" role="img">';
|
107 |
+
$width = ( ( $avg_score / 5 ) * 100 );
|
108 |
+
echo '<span style="width: ' . $width . '%;"></span>';
|
109 |
+
echo '</div>';
|
110 |
+
|
111 |
+
echo '<span class="ct-score-label">';
|
112 |
+
echo __('Overall Score', 'blc');
|
113 |
+
echo '</span>';
|
114 |
+
echo '</div>';
|
115 |
+
|
116 |
+
echo '</div>';
|
117 |
+
}
|
118 |
+
|
119 |
+
echo '<div class="ct-product-actions">';
|
120 |
+
|
121 |
+
$product_link = blocksy_akg('product_link', $atts, '#');
|
122 |
+
$product_button_label = blocksy_akg(
|
123 |
+
'product_button_label',
|
124 |
+
$atts,
|
125 |
+
__('Buy Now', 'blc')
|
126 |
+
);
|
127 |
+
|
128 |
+
$product_read_content_button_label = blocksy_akg(
|
129 |
+
'product_read_content_button_label',
|
130 |
+
$atts,
|
131 |
+
__('Read More', 'blc')
|
132 |
+
);
|
133 |
+
|
134 |
+
if (! empty($product_button_label)) {
|
135 |
+
echo '<a href="#post-' . get_the_ID() . '" class="ct-button">';
|
136 |
+
echo $product_read_content_button_label;
|
137 |
+
|
138 |
+
/*
|
139 |
+
echo blc_get_icon([
|
140 |
+
'icon_descriptor' => blocksy_akg('product_read_content_button_icon', $atts, [
|
141 |
+
'icon' => 'fas fa-arrow-down'
|
142 |
+
]),
|
143 |
+
]);
|
144 |
+
*/
|
145 |
+
|
146 |
+
echo '</a>';
|
147 |
+
}
|
148 |
+
|
149 |
+
if (! empty($product_button_label) && ! empty($product_link)) {
|
150 |
+
echo '<a href="' . esc_url($product_link) . '" class="ct-button">';
|
151 |
+
echo $product_button_label;
|
152 |
+
|
153 |
+
/*
|
154 |
+
echo blc_get_icon([
|
155 |
+
'icon_descriptor' => blocksy_akg('product_button_icon', $atts, [
|
156 |
+
'icon' => 'fas fa-cart-arrow-down'
|
157 |
+
]),
|
158 |
+
]);
|
159 |
+
*/
|
160 |
+
|
161 |
+
echo '</a>';
|
162 |
+
}
|
163 |
+
|
164 |
+
echo '</div>';
|
165 |
+
|
166 |
+
$product_specs = blocksy_akg('product_specs', $atts, []);
|
167 |
+
$product_pros = blocksy_akg('product_pros', $atts, []);
|
168 |
+
$product_cons = blocksy_akg('product_cons', $atts, []);
|
169 |
+
$product_description = blocksy_akg('product_description', $atts, '');
|
170 |
+
|
171 |
+
if (! empty($product_description)) {
|
172 |
+
echo '<div class="ct-product-description">';
|
173 |
+
|
174 |
+
echo '<div class="entry-content">';
|
175 |
+
echo do_shortcode($product_description);
|
176 |
+
echo '</div>';
|
177 |
+
|
178 |
+
echo '</div>';
|
179 |
+
}
|
180 |
+
|
181 |
+
if (
|
182 |
+
! empty($product_specs)
|
183 |
+
||
|
184 |
+
! empty($product_pros)
|
185 |
+
||
|
186 |
+
! empty($product_cons)
|
187 |
+
) {
|
188 |
+
echo '<div class="ct-product-info">';
|
189 |
+
|
190 |
+
if (! empty($product_specs)) {
|
191 |
+
echo '<div class="ct-specs">';
|
192 |
+
echo '<h5>' . __('Specs', 'blc') . '</h5>';
|
193 |
+
|
194 |
+
echo '<ul>';
|
195 |
+
|
196 |
+
foreach ($product_specs as $single_spec) {
|
197 |
+
echo '<li>';
|
198 |
+
echo '<b>' . blocksy_akg('label', $single_spec, '') . ': </b>';
|
199 |
+
echo blocksy_akg('value', $single_spec, '');
|
200 |
+
echo '</li>';
|
201 |
+
}
|
202 |
+
|
203 |
+
echo '</ul>';
|
204 |
+
echo '</div>';
|
205 |
+
}
|
206 |
+
|
207 |
+
if (! empty($product_pros)) {
|
208 |
+
echo '<div>';
|
209 |
+
echo '<h5>' . __('Pros', 'blc') . '</h5>';
|
210 |
+
|
211 |
+
echo '<ul>';
|
212 |
+
|
213 |
+
foreach ($product_pros as $single_pro) {
|
214 |
+
echo '<li>';
|
215 |
+
echo blocksy_akg('label', $single_pro, '');
|
216 |
+
echo '</li>';
|
217 |
+
}
|
218 |
+
|
219 |
+
echo '</ul>';
|
220 |
+
echo '</div>';
|
221 |
+
}
|
222 |
+
|
223 |
+
if (! empty($product_cons)) {
|
224 |
+
echo '<div>';
|
225 |
+
echo '<h5>' . __('Cons', 'blc') . '</h5>';
|
226 |
+
|
227 |
+
echo '<ul>';
|
228 |
+
|
229 |
+
foreach ($product_cons as $single_cons) {
|
230 |
+
echo '<li>';
|
231 |
+
echo blocksy_akg('label', $single_cons, '');
|
232 |
+
echo '</li>';
|
233 |
+
}
|
234 |
+
|
235 |
+
echo '</ul>';
|
236 |
+
echo '</div>';
|
237 |
+
}
|
238 |
+
|
239 |
+
echo '</div>';
|
240 |
+
}
|
241 |
+
|
242 |
+
echo '</div>';
|
243 |
+
echo '</section>';
|
trunk/framework/extensions/trending/config.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$config = [
|
4 |
+
'title' => __('Trending Block', 'blc'),
|
5 |
+
'description' => __('Display a trending list of posts, products or custom post types at the bottom of your website.', 'blc')
|
6 |
+
];
|
trunk/framework/extensions/trending/customizer.php
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$all_post_types = [
|
4 |
+
'post' => __('Posts', 'blc')
|
5 |
+
];
|
6 |
+
|
7 |
+
if (class_exists('WooCommerce')) {
|
8 |
+
$all_post_types['product'] = __('Products', 'blc');
|
9 |
+
}
|
10 |
+
|
11 |
+
if (function_exists('blocksy_manager')) {
|
12 |
+
$post_types = blocksy_manager()->post_types->get_supported_post_types();
|
13 |
+
|
14 |
+
foreach ($post_types as $single_post_type) {
|
15 |
+
$post_type_object = get_post_type_object($single_post_type);
|
16 |
+
|
17 |
+
if (! $post_type_object) {
|
18 |
+
continue;
|
19 |
+
}
|
20 |
+
|
21 |
+
$all_post_types[$single_post_type] = $post_type_object->labels->singular_name;
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
$options = [
|
26 |
+
'title' => __('Trending Posts', 'blc'),
|
27 |
+
'container' => [ 'priority' => 8 ],
|
28 |
+
'options' => [
|
29 |
+
'trending_posts_section_options' => [
|
30 |
+
'type' => 'ct-options',
|
31 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
32 |
+
'inner-options' => [
|
33 |
+
blocksy_rand_md5() => [
|
34 |
+
'type' => 'ct-title',
|
35 |
+
'label' => __( 'Trending Posts', 'blocksy' ),
|
36 |
+
],
|
37 |
+
|
38 |
+
blocksy_rand_md5() => [
|
39 |
+
'title' => __( 'General', 'blc' ),
|
40 |
+
'type' => 'tab',
|
41 |
+
'options' => [
|
42 |
+
'trending_block_post_type' => count($all_post_types) > 1 ? [
|
43 |
+
'label' => __( 'Post Type', 'blc' ),
|
44 |
+
'type' => 'ct-select',
|
45 |
+
'value' => 'post',
|
46 |
+
'design' => 'inline',
|
47 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
48 |
+
'choices' => blocksy_ordered_keys($all_post_types),
|
49 |
+
|
50 |
+
'sync' => [
|
51 |
+
'selector' => '.ct-trending-block',
|
52 |
+
'render' => function () {
|
53 |
+
echo blc_get_trending_block();
|
54 |
+
}
|
55 |
+
],
|
56 |
+
] : [
|
57 |
+
'label' => __('Post Type', 'blc'),
|
58 |
+
'type' => 'hidden',
|
59 |
+
'value' => 'post',
|
60 |
+
'design' => 'none',
|
61 |
+
'setting' => ['transport' => 'postMessage'],
|
62 |
+
],
|
63 |
+
|
64 |
+
'trending_block_filter' => [
|
65 |
+
'label' => __( 'Trending From', 'blc' ),
|
66 |
+
'type' => 'ct-select',
|
67 |
+
'value' => 'all_time',
|
68 |
+
'view' => 'text',
|
69 |
+
'design' => 'inline',
|
70 |
+
'setting' => [ 'transport' => 'postMessage' ],
|
71 |
+
'choices' => blocksy_ordered_keys(
|
72 |
+
[
|
73 |
+
'all_time' => __( 'All Time', 'blc' ),
|
74 |
+
'last_24_hours' => __( 'Last 24 Hours', 'blc' ),
|
75 |
+
'last_7_days' => __( 'Last 7 Days', 'blc' ),
|
76 |
+
'last_month' => __( 'Last Month', 'blc' ),
|
77 |
+
]
|
78 |
+
),
|
79 |
+
|
80 |
+
'sync' => [
|
81 |
+
'selector' => '.ct-trending-block',
|
82 |
+
'render' => function () {
|
83 |
+
echo blocksy_get_trending_block();
|
84 |
+
}
|
85 |
+
],
|
86 |
+
],
|
87 |
+
|
88 |
+
blocksy_rand_md5() => [
|
89 |
+
'type' => 'ct-divider',
|
90 |
+
],
|
91 |
+
|
92 |
+
'trendingBlockContainerSpacing' => [
|
93 |
+
'label' => __( 'Container Inner Spacing', 'blc' ),
|
94 |
+
'type' => 'ct-slider',
|
95 |
+
'value' => [
|
96 |
+
'mobile' => '30px',
|
97 |
+
'tablet' => '30px',
|
98 |
+
'desktop' => '30px',
|
99 |
+
],
|
100 |
+
'units' => blocksy_units_config([
|
101 |
+
[
|
102 |
+
'unit' => 'px',
|
103 |
+
'min' => 0,
|
104 |
+
'max' => 100,
|
105 |
+
],
|
106 |
+
]),
|
107 |
+
'responsive' => true,
|
108 |
+
'sync' => 'live',
|
109 |
+
],
|
110 |
+
|
111 |
+
blocksy_rand_md5() => [
|
112 |
+
'type' => 'ct-divider',
|
113 |
+
],
|
114 |
+
|
115 |
+
'trending_block_visibility' => [
|
116 |
+
'label' => __( 'Container Visibility', 'blc' ),
|
117 |
+
'type' => 'ct-visibility',
|
118 |
+
'design' => 'block',
|
119 |
+
'sync' => 'live',
|
120 |
+
|
121 |
+
'value' => [
|
122 |
+
'desktop' => true,
|
123 |
+
'tablet' => true,
|
124 |
+
'mobile' => false,
|
125 |
+
],
|
126 |
+
|
127 |
+
'choices' => blocksy_ordered_keys([
|
128 |
+
'desktop' => __( 'Desktop', 'blc' ),
|
129 |
+
'tablet' => __( 'Tablet', 'blc' ),
|
130 |
+
'mobile' => __( 'Mobile', 'blc' ),
|
131 |
+
]),
|
132 |
+
],
|
133 |
+
|
134 |
+
],
|
135 |
+
],
|
136 |
+
|
137 |
+
blocksy_rand_md5() => [
|
138 |
+
'title' => __( 'Design', 'blc' ),
|
139 |
+
'type' => 'tab',
|
140 |
+
'options' => [
|
141 |
+
|
142 |
+
'trendingBlockFontColor' => [
|
143 |
+
'label' => __( 'Font Color', 'blc' ),
|
144 |
+
'type' => 'ct-color-picker',
|
145 |
+
'design' => 'inline',
|
146 |
+
'sync' => 'live',
|
147 |
+
|
148 |
+
'value' => [
|
149 |
+
'default' => [
|
150 |
+
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
|
151 |
+
],
|
152 |
+
|
153 |
+
'hover' => [
|
154 |
+
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
|
155 |
+
],
|
156 |
+
],
|
157 |
+
|
158 |
+
'pickers' => [
|
159 |
+
[
|
160 |
+
'title' => __( 'Initial', 'blc' ),
|
161 |
+
'id' => 'default',
|
162 |
+
'inherit' => 'var(--color)'
|
163 |
+
|