templating

This commit is contained in:
rizal.productzilla 2024-04-01 16:08:46 +07:00
parent b8ae357805
commit e38e8b231d
2927 changed files with 983517 additions and 0 deletions

View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the origina
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{description}
Copyright (C) {year} {fullname}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License

View File

@ -0,0 +1,145 @@
<?php
/*
Plugin Name: Blocksy Companion
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.
Version: 2.0.37
Author: CreativeThemes
Author URI: https://creativethemes.com
Text Domain: blocksy-companion
Domain Path: /languages/
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
if ( !defined( 'ABSPATH' ) ) {
exit;
// Exit if accessed directly.
}
register_activation_hook( __FILE__, function () {
if ( class_exists( '\\Blocksy\\Plugin' ) && !function_exists( 'blc_fs' ) ) {
$to_deactivate = plugin_basename( str_replace( '-pro/', '/', __FILE__ ) );
if ( is_plugin_active( $to_deactivate ) ) {
deactivate_plugins( $to_deactivate );
}
}
if ( isset( $_REQUEST['action'] ) && 'activate-selected' === $_REQUEST['action'] && isset( $_POST['checked'] ) && count( $_POST['checked'] ) > 1 ) {
return;
}
add_option( 'blc_activation_redirect', wp_get_current_user()->ID );
} );
if ( function_exists( 'blc_fs' ) || class_exists( '\\Blocksy\\Plugin' ) ) {
if ( function_exists( 'blc_fs' ) ) {
blc_fs()->set_basename( false, __FILE__ );
}
} else {
if ( !function_exists( 'blc_fs' ) && file_exists( dirname( __FILE__ ) . '/freemius/start.php' ) && is_admin() ) {
global $blc_fs ;
if ( !isset( $blc_fs ) ) {
if ( !defined( 'WP_FS__PRODUCT_5115_MULTISITE' ) ) {
define( 'WP_FS__PRODUCT_5115_MULTISITE', true );
}
require_once dirname( __FILE__ ) . '/freemius/start.php';
$has_account = true;
$instance = \Freemius::instance( 5115, 'blocksy-companion', true );
if ( in_array( 'white-label', get_option( 'blocksy_active_extensions', [] ) ) && ($instance->is_plan( 'agency' ) || $instance->is_plan( 'agency_v2' )) ) {
$settings = get_option( 'blocksy_ext_white_label_settings', [] );
if ( $settings && isset( $settings['hide_billing_account'] ) && $settings['hide_billing_account'] ) {
$has_account = false;
}
}
$blc_fs = fs_dynamic_init( array(
'id' => '5115',
'slug' => 'blocksy-companion',
'premium_slug' => 'blocksy-companion-pro',
'type' => 'plugin',
'public_key' => 'pk_b00a5cbae90b2e948015a7d0710f5',
'premium_suffix' => 'PRO',
'is_premium' => false,
'has_addons' => false,
'has_paid_plans' => true,
'menu' => ( true ? [
'slug' => 'ct-dashboard',
'support' => false,
'contact' => false,
'pricing' => true,
'account' => $has_account,
] : [
'support' => false,
'contact' => false,
'pricing' => false,
'account' => false,
] ),
'is_live' => true,
) );
function blc_fs()
{
global $blc_fs ;
// if (! is_admin()) {
// throw new Error('Called in frontend!');
// }
return $blc_fs;
}
blc_fs();
do_action( 'blc_fs_loaded' );
}
}
define( 'BLOCKSY__FILE__', __FILE__ );
define( 'BLOCKSY_PLUGIN_BASE', plugin_basename( BLOCKSY__FILE__ ) );
define( 'BLOCKSY_PATH', plugin_dir_path( BLOCKSY__FILE__ ) );
define( 'BLOCKSY_URL', plugin_dir_url( BLOCKSY__FILE__ ) );
add_action( 'init', function () {
/**
* Load Blocksy textdomain.
*
* Load gettext translate for Blocksy text domain.
*/
load_plugin_textdomain( 'blocksy-companion', false, dirname( BLOCKSY_PLUGIN_BASE ) . '/languages' );
} );
if ( !version_compare( PHP_VERSION, '7.0', '>=' ) ) {
add_action( 'admin_notices', 'blc_fail_php_version' );
} elseif ( !version_compare( get_bloginfo( 'version' ), '5.0', '>=' ) ) {
add_action( 'admin_notices', 'blc_fail_wp_version' );
} else {
require BLOCKSY_PATH . 'plugin.php';
}
/**
* Blocksy admin notice for minimum PHP version.
*
* Warning when the site doesn't have the minimum required PHP version.
*/
function blc_fail_php_version()
{
/* translators: %s: PHP version */
$message = sprintf( esc_html__( 'Blocksy requires PHP version %s+, plugin is currently NOT RUNNING.', 'blocksy-companion' ), '7.0' );
$html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) );
echo wp_kses_post( $html_message ) ;
}
/**
* Blocksy admin notice for minimum WordPress version.
*
* Warning when the site doesn't have the minimum required WordPress version.
*/
function blc_fail_wp_version()
{
/* translators: %s: WordPress version */
$message = sprintf( esc_html__( 'Blocksy requires WordPress version %s+. Because you are using an earlier version, the plugin is currently NOT RUNNING.', 'blocksy-companion' ), '5.0' );
$html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) );
echo wp_kses_post( $html_message ) ;
}
}

View File

@ -0,0 +1,158 @@
<?php
namespace Blocksy;
if (! defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
/**
* Blocksy autoloader.
*/
class Autoloader {
private static $classes_map = null;
/**
* Classes map.
*
* Maps Blocksy classes to file names.
*
* @static
*
* @var array Classes used by blocksy.
*/
private static function get_classes_map() {
if (self::$classes_map) {
return self::$classes_map;
}
self::$classes_map = [
'Capabilities' => 'framework/includes/capabilities.php',
'ExtensionsManager' => 'framework/includes/extensions-manager.php',
'ExtensionWithFeatures' => 'framework/includes/extension-with-features.php',
'ExtensionsManagerApi' => 'framework/includes/extensions-manager-api.php',
'Dashboard' => 'framework/dashboard.php',
'ThemeIntegration' => 'framework/theme-integration.php',
'AccountAuth' => 'framework/features/account-auth.php',
'CacheResetManager' => 'framework/cache-reset-manager.php',
'GoogleAnalytics' => 'framework/features/google-analytics.php',
'OpenGraphMetaData' => 'framework/features/opengraph-meta-data.php',
'HeaderAdditions' => 'framework/features/header.php',
'ConditionsManager' => 'framework/features/conditions-manager.php',
'ConditionsRulesResolver' => 'framework/features/conditions/rules-resolver.php',
'Cli' => 'framework/cli.php',
'SvgHandling' => 'framework/features/svg.php',
'DynamicCss' => 'framework/features/dynamic-css.php',
'CustomizerOptionsManager' => 'framework/features/customizer-options-manager.php',
'DemoInstall' => 'framework/features/demo-install.php',
'DemoInstallContentExport' => 'framework/features/demo-install/content-export.php',
'DemoInstallWidgetsExport' => 'framework/features/demo-install/widgets-export.php',
'DemoInstallOptionsExport' => 'framework/features/demo-install/options-export.php',
'DemoInstallChildThemeInstaller' => 'framework/features/demo-install/child-theme.php',
'DemoInstallPluginsInstaller' => 'framework/features/demo-install/required-plugins.php',
'DemoInstallPluginsUninstaller' => 'framework/features/demo-install/plugins-uninstaller.php',
'DemoInstallContentInstaller' => 'framework/features/demo-install/content-installer.php',
'DemoInstallOptionsInstaller' => 'framework/features/demo-install/options-import.php',
'DemoInstallWidgetsInstaller' => 'framework/features/demo-install/widgets-import.php',
'DemoInstallContentEraser' => 'framework/features/demo-install/content-eraser.php',
'DemoInstallFakeContentEraser' => 'framework/features/demo-install/fake-content-eraser.php',
'DemoInstallFinalActions' => 'framework/features/demo-install/install-finish.php',
'Premium' => 'framework/premium/pro.php',
/**
* No namespace
*/
'_Blocksy_WP_Import' => 'framework/features/demo-install/wp-importer.php',
];
$autoload = [];
if (is_readable(dirname(__FILE__) . '/premium/autoload.php')) {
require dirname(__FILE__) . '/premium/autoload.php';
}
foreach ($autoload as $class_name => $file_name) {
self::$classes_map[$class_name] = $file_name;
}
return self::$classes_map;
}
/**
* Run autoloader.
*
* Register a function as `__autoload()` implementation.
*
* @static
*/
public static function run() {
spl_autoload_register([__CLASS__, 'autoload']);
}
/**
* Load class.
*
* For a given class name, require the class file.
*
* @static
*
* @param string $relative_class_name Class name.
*/
private static function load_class($relative_class_name) {
if (isset(self::get_classes_map()[$relative_class_name])) {
$filename = BLOCKSY_PATH . '/' . self::get_classes_map()[$relative_class_name];
} else {
$filename = strtolower(
preg_replace(
['/([a-z])([A-Z])/', '/_/', '/\\\/'],
['$1-$2', '-', DIRECTORY_SEPARATOR],
$relative_class_name
)
);
$filename = BLOCKSY_PATH . $filename . '.php';
}
if (is_readable($filename)) {
require $filename;
}
}
/**
* Autoload.
*
* For a given class, check if it exist and load it.
*
* @static
*
* @param string $class Class name.
*/
private static function autoload($class) {
if (
0 !== strpos($class, __NAMESPACE__ . '\\')
&&
! isset(self::get_classes_map()['_' . $class])
) {
return;
}
$relative_class_name = preg_replace('/^' . __NAMESPACE__ . '\\\/', '', $class);
$final_class_name = __NAMESPACE__ . '\\' . $relative_class_name;
if (isset(self::get_classes_map()['_' . $relative_class_name])) {
$final_class_name = $relative_class_name;
$relative_class_name = '_' . $relative_class_name;
}
if (! class_exists($final_class_name)) {
self::load_class($relative_class_name);
}
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace Blocksy;
class CacheResetManager {
public function is_there_any_page_caching() {
$page_is_cached = false;
if (class_exists('W3TC\Cache')) {
$w3_conf = \W3TC\Dispatcher::config();
$page_is_cached = !! $w3_conf->get_boolean('pgcache.enabled');
}
if (class_exists('LiteSpeed\Control')) {
$control = \LiteSpeed\Root::cls('Control');
$page_is_cached = (
$control->conf('cache') && \LiteSpeed\Control::is_cacheable()
);
}
if (class_exists('WPO_Cache_Config')) {
$cache_config = \WPO_Cache_Config::instance();
$page_is_cached = !! $cache_config->get_option('enable_page_caching');
}
if (class_exists('SiteGround_Optimizer\Options\Options')) {
$siteground_optimizer_file_caching = \SiteGround_Optimizer\Options\Options::is_enabled(
'siteground_optimizer_file_caching'
);
$siteground_optimizer_enable_cache = \SiteGround_Optimizer\Options\Options::is_enabled(
'siteground_optimizer_enable_cache'
);
$page_is_cached = (
$siteground_optimizer_file_caching
||
$siteground_optimizer_enable_cache
);
}
if (class_exists('\WP_Rocket\Buffer\Cache')) {
$page_is_cached = \WP_Rocket\Buffer\Cache::can_generate_caching_files();
}
if (class_exists("\CF\API\Plugin")) {
if (\CF\API\Plugin::SETTING_PLUGIN_SPECIFIC_CACHE === "plugin_specific_cache") {
$page_is_cached = true;
}
}
global $super_cache_enabled;
if (isset($super_cache_enabled)) {
$page_is_cached = $super_cache_enabled;
}
return apply_filters(
'blocksy:cache-manager:page-is-cached',
$page_is_cached
);
}
}

View File

@ -0,0 +1,212 @@
<?php
namespace Blocksy;
/*
add_action('blocksy:customizer:load:before', function () {
$_REQUEST['wp_customize'] = 'on';
_wp_customize_include();
global $wp_customize;
$wp_customize->wp_loaded();
});
*/
class Cli {
public function __construct() {
/**
* Move all widgets to the inactive widgets area.
*/
\WP_CLI::add_command('blocksy widgets drop', function ($args) {
$sidebars_widgets = get_option('sidebars_widgets', array());
if (! isset($sidebars_widgets['wp_inactive_widgets'])) {
$sidebars_widgets['wp_inactive_widgets'] = [];
}
foreach ($sidebars_widgets as $sidebar_id => $widgets) {
if (! $widgets) continue;
if ($sidebar_id === 'wp_inactive_widgets') {
continue;
}
if ($sidebar_id === 'array_version') {
continue;
}
foreach ($widgets as $widget_id) {
$sidebars_widgets['wp_inactive_widgets'][] = $widget_id;
}
$sidebars_widgets[$sidebar_id] = [];
}
update_option('sidebars_widgets', $sidebars_widgets);
unset($sidebars_widgets['array_version']);
set_theme_mod('sidebars_widgets', [
'time' => time(),
'data' => $sidebars_widgets
]);
});
/**
* Kick start the demo import process.
*
* ## OPTIONS
*
* <demo>
* : The demo name.
*
* <builder>
* : The builder name. Default to `gutenberg`.
*/
\WP_CLI::add_command('blocksy demo import:start', function ($cli_argv) {
$args = $this->get_demo_args($cli_argv);
Plugin::instance()->demo->set_current_demo(
$args['demo'] . ':' . $args['builder']
);
$demo_data = Plugin::instance()->demo->fetch_single_demo([
'demo' => $args['demo'],
'builder' => $args['builder']
]);
});
/**
* Import the plugins required by the demo.
*
* ## OPTIONS
*
* <demo>
* : The demo name.
*
* <builder>
* : The builder name. Default to `gutenberg`.
*/
\WP_CLI::add_command('blocksy demo import:plugins', function ($cli_argv) {
$args = $this->get_demo_args($cli_argv);
$demo_data = Plugin::instance()->demo->fetch_single_demo([
'demo' => $args['demo'],
'builder' => $args['builder']
]);
$plugins = new DemoInstallPluginsInstaller([
'has_streaming' => false,
'plugins' => implode(':', $demo_data['plugins'])
]);
$plugins->import();
});
/**
* Import the options required by the demo.
*
* ## OPTIONS
*
* <demo>
* : The demo name.
*
* <builder>
* : The builder name. Default to `gutenberg`.
*/
\WP_CLI::add_command('blocksy demo import:options', function ($cli_argv) {
$args = $this->get_demo_args($cli_argv);
$options = new DemoInstallOptionsInstaller([
'has_streaming' => false,
'demo_name' => $args['demo'] . ':' . $args['builder']
]);
$options->import();
});
/**
* Import the widgets required by the demo.
*
* ## OPTIONS
*
* <demo>
* : The demo name.
*
* <builder>
* : The builder name. Default to `gutenberg`.
*/
\WP_CLI::add_command('blocksy demo import:widgets', function ($cli_argv) {
$args = $this->get_demo_args($cli_argv);
$widgets = new DemoInstallWidgetsInstaller([
'has_streaming' => false,
'demo_name' => $args['demo'] . ':' . $args['builder']
]);
$widgets->import();
});
/**
* Import the content required by the demo.
*
* ## OPTIONS
*
* <demo>
* : The demo name.
*
* <builder>
* : The builder name. Default to `gutenberg`.
*/
\WP_CLI::add_command('blocksy demo import:content', function ($cli_argv) {
$args = $this->get_demo_args($cli_argv);
$content = new DemoInstallContentInstaller([
'has_streaming' => false,
'demo_name' => $args['demo'] . ':' . $args['builder']
]);
$content->import();
});
/**
* Clean the currently installed demo.
*/
\WP_CLI::add_command('blocksy demo clean', function ($cli_argv) {
update_option('blocksy_ext_demos_current_demo', null);
$eraser = new DemoInstallContentEraser([
'has_streaming' => false
]);
$eraser->import();
});
/**
* Finish the demo import process.
*/
\WP_CLI::add_command('blocksy demo import:finish', function ($args) {
$finish = new DemoInstallFinalActions([
'has_streaming' => false
]);
$finish->import();
});
}
private function get_demo_args($cli_argv) {
if (empty($cli_argv)) {
echo 'Please provide demo name.';
exit;
}
if (! isset($cli_argv[1])) {
$cli_argv[1] = '';
}
return [
'demo' => $cli_argv[0],
'builder' => $cli_argv[1]
];
}
}

View File

@ -0,0 +1,425 @@
<?php
namespace Blocksy;
class Dashboard {
public function __construct() {
add_filter(
'blocksy:dashboard:redirect-after-activation',
function ($url) {
return add_query_arg(
'page',
'ct-dashboard',
admin_url('admin.php')
);
}
);
add_filter(
'blocksy_add_menu_page',
function ($res, $options) {
add_menu_page(
$options['title'],
$options['menu-title'],
$options['permision'],
$options['top-level-handle'],
$options['callback'],
$options['icon-url'],
2
);
add_submenu_page(
$options['top-level-handle'],
$options['title'],
__('Dashboard', 'blocksy-companion'),
$options['permision'],
$options['top-level-handle']
);
return true;
},
10, 2
);
add_action(
'admin_menu',
[$this, 'setup_framework_page'],
5
);
add_filter(
'blocksy:dashboard:redirect-after-activation',
function ($url) {
return add_query_arg(
'page',
'ct-dashboard',
admin_url('admin.php')
);
}
);
add_action(
'admin_menu',
function () {
if (Plugin::instance()->check_if_blocksy_is_activated()) {
return;
}
$menu_slug = plugin_basename('ct-dashboard');
$hookname = get_plugin_page_hookname('ct-dashboard', '');
remove_all_actions($hookname);
add_action(
$hookname,
function () {
$this->welcome_page_template();
}
);
},
99999999999
);
add_action(
'admin_enqueue_scripts',
[$this, 'enqueue_static'],
100
);
add_action('admin_body_class', function ($class) {
if (! Plugin::instance()->check_if_blocksy_is_activated()) {
return $class;
}
if (function_exists('blc_fs') && blc_fs()->is_activation_mode()) {
$class .= ' blocksy-fs-optin-dashboard';
}
return $class;
});
if (function_exists('blc_fs')) {
blc_fs()->add_filter('hide_plan_change', '__return_true');
blc_fs()->add_filter(
'plugin_icon',
function ($url) {
return BLOCKSY_PATH . '/static/img/logo.jpg';
}
);
blc_fs()->add_filter(
'permission_diagnostic_default',
'__return_false'
);
blc_fs()->add_filter(
'show_deactivation_feedback_form',
'__return_false'
);
blc_fs()->add_filter('hide_freemius_powered_by', '__return_true');
blc_fs()->add_filter( 'show_deactivation_subscription_cancellation', '__return_false' );
blc_fs()->add_filter(
'connect-message_on-premium',
function ($text) {
if (strpos($text, '<br>') !== false) {
$exploded_message = explode('<br>', $text);
$text = '<span>' . $exploded_message[0] . '</span>' . $exploded_message[1];
}
return $text;
}
);
blc_fs()->add_filter(
'connect_message_on_update',
function (
$message,
$user_first_name,
$product_title,
$user_login,
$site_link,
$freemius_link
) {
$is_network_upgrade_mode = ( fs_is_network_admin() && blc_fs()->is_network_upgrade_mode() );
$slug = blc_fs()->get_slug();
$is_gdpr_required = \FS_GDPR_Manager::instance()->is_required();
$hey_x_text = esc_html( blc_safe_sprintf( fs_text_x_inline( 'Hey %s,', 'greeting', 'hey-x', $slug ), $user_first_name ) );
$default_optin_message = $is_gdpr_required ?
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 ) :
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 );
$default_optin_message = 'Never miss an important update - opt in to our security & feature updates notifications, educational content, offers, and non-sensitive diagnostic tracking with.';
return (($is_network_upgrade_mode ?
'' :
/* translators: %s: name (e.g. Hey John,) */
'<span>' . $hey_x_text . '</span>'
) .
blc_safe_sprintf(
esc_html( $default_optin_message ),
'<b>' . esc_html( blc_fs()->get_plugin_name() ) . '</b>',
'<b>' . $user_login . '</b>',
$site_link,
$freemius_link
));
}, 10, 6
);
blc_fs()->add_action('connect/before', function () {
$path = dirname(__FILE__) . '/views/optin.php';
echo blocksy_render_view(
$path,
[]
);
});
blc_fs()->add_action('connect/after', function () {
echo '</div>';
});
add_action(
'wp_ajax_blocksy_fs_connect_again',
function () {
if (! current_user_can('edit_theme_options')) {
wp_send_json_error();
}
blc_fs()->connect_again();
wp_send_json_success();
}
);
}
add_filter(
'blocksy_dashboard_localizations',
function ($d) {
$result = [
'is_pro' => false,
'is_anonymous' => false,
'connect_template' => ''
];
if (function_exists('blc_fs')) {
$is_anonymous = blc_fs()->is_anonymous();
$connect_template = '';
if ($is_anonymous) {
ob_start();
blc_fs()->_connect_page_render();
$connect_template = ob_get_clean();
}
$current_plan = blc_get_capabilities()->get_plan();
// $current_plan = 'free';
$result = [
'is_pro' => $current_plan !== 'free',
'current_plan' => $current_plan,
'pro_starter_sites' => blc_get_capabilities()->get_features()['pro_starter_sites'],
'pro_starter_sites_enhanced' => blc_get_capabilities()->get_features()['pro_starter_sites_enhanced'],
'is_anonymous' => $is_anonymous,
'connect_template' => $connect_template
];
}
if (
Plugin::instance()->premium
&&
is_callable([
Plugin::instance()->premium,
'user_wants_beta_updates'
])
) {
$result['has_beta_consent'] = Plugin::instance()->premium->user_wants_beta_updates();
}
return array_merge($result, $d);
}
);
add_action('admin_init', function ($plugin) {
if (wp_doing_ajax()) {
return;
}
if (! is_admin()) {
return;
}
if (! is_user_logged_in()) {
return;
}
if (is_network_admin()) {
return;
}
if (intval(get_option('blc_activation_redirect', false)) === wp_get_current_user()->ID) {
delete_option('blc_activation_redirect');
exit(wp_redirect(admin_url('admin.php?page=ct-dashboard')));
}
});
}
public function enqueue_static() {
if (! $this->is_dashboard_page()) return;
$data = get_plugin_data(BLOCKSY__FILE__);
$deps = apply_filters('blocksy-dashboard-scripts-dependencies', [
'wp-i18n',
'ct-events',
'ct-options-scripts'
]);
if (Plugin::instance()->check_if_blocksy_is_activated()) {
wp_enqueue_script(
'blocksy-dashboard-scripts',
BLOCKSY_URL . 'static/bundle/dashboard.js',
$deps,
$data['Version'],
false
);
} else {
wp_enqueue_script(
'blocksy-dashboard-scripts',
BLOCKSY_URL . 'static/bundle/dashboard-no-theme.js',
[
'underscore',
'react',
'react-dom',
'wp-element',
'wp-date',
'wp-i18n',
'updates'
],
$data['Version'],
false
);
$slug = 'blocksy';
$localize_data = [
'themeIsInstalled' => (
!! wp_get_theme($slug)
&&
! wp_get_theme($slug)->errors()
),
'activate'=> current_user_can('switch_themes') ? wp_nonce_url(admin_url('themes.php?action=activate&amp;stylesheet=' . $slug), 'switch-theme_' . $slug) : null
];
$blocksy_data = Plugin::instance()->is_blocksy_data;
if ($blocksy_data && $blocksy_data['is_correct_theme']) {
$localize_data['theme_version_mismatch'] = true;
$localize_data['run_updates'] = self_admin_url('update-core.php');
}
wp_localize_script(
'blocksy-dashboard-scripts',
'ctDashboardLocalizations',
$localize_data
);
wp_dequeue_style('ct-dashboard-styles');
}
wp_enqueue_style(
'blocksy-dashboard-styles',
BLOCKSY_URL . 'static/bundle/dashboard.min.css',
['wp-components'],
$data['Version']
);
}
public function setup_framework_page() {
if (! current_user_can('manage_options')) {
return;
}
$data = get_plugin_data(BLOCKSY__FILE__);
$options = [
'title' => __('Blocksy', 'blocksy-companion'),
'menu-title' => __('Blocksy', 'blocksy-companion'),
'permision' => 'manage_options',
'top-level-handle' => 'ct-dashboard',
'callback' => [$this, 'welcome_page_template'],
'icon-url' => apply_filters(
'blocksy:dashboard:icon-url',
'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgMzUgMzUiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDM1IDM1OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxwYXRoIGQ9Ik0yMS42LDIxLjNjMCwwLjYtMC41LDEuMS0xLjEsMS4xaC0zLjVsLTAuOS0yLjJoNC40QzIxLjEsMjAuMiwyMS42LDIwLjcsMjEuNiwyMS4zeiBNMjAuNiwxMy41aC00LjRsMC45LDIuMmgzLjUKCWMwLjYsMCwxLjEtMC41LDEuMS0xLjFDMjEuNiwxNCwyMS4xLDEzLjUsMjAuNiwxMy41eiBNMzUsMTcuNUMzNSwyNy4yLDI3LjIsMzUsMTcuNSwzNUM3LjgsMzUsMCwyNy4yLDAsMTcuNUMwLDcuOCw3LjgsMCwxNy41LDAKCUMyNy4yLDAsMzUsNy44LDM1LDE3LjV6IE0yNSwxNy45YzAuNy0wLjksMS4xLTIuMSwxLjEtMy40YzAtMS4yLTAuNC0yLjQtMS4xLTMuM2MtMS0xLjQtMi42LTIuMy00LjQtMi4zYzAsMC0wLjEsMC0wLjEsMHYwSDkuOQoJYy0wLjMsMC0wLjUsMC4zLTAuNCwwLjVsMi42LDYuMkg5LjljLTAuMywwLTAuNSwwLjMtMC40LDAuNUwxNCwyNi45aDYuNWMzLjEsMCw1LjYtMi41LDUuNi01LjZDMjYuMiwyMCwyNS44LDE4LjksMjUsMTcuOQoJQzI1LjEsMTcuOSwyNS4xLDE3LjksMjUsMTcuOXoiLz4KPC9zdmc+Cg=='
),
'position' => 2,
];
add_menu_page(
$options['title'],
$options['menu-title'],
$options['permision'],
$options['top-level-handle'],
$options['callback'],
$options['icon-url'],
2
);
}
public function is_dashboard_page() {
global $pagenow;
if (is_network_admin()) {
$is_ct_settings =
// 'themes.php' === $pagenow &&
isset( $_GET['page'] ) && 'blocksy-companion' === $_GET['page'];
return $is_ct_settings;
}
$is_ct_settings =
// 'themes.php' === $pagenow &&
isset( $_GET['page'] ) && 'ct-dashboard' === $_GET['page'];
return $is_ct_settings;
}
public function welcome_page_template() {
if (! current_user_can('manage_options')) {
wp_die(
esc_html(
__( 'You do not have sufficient permissions to access this page.', 'blocksy-companion' )
)
);
}
echo '<div id="ct-dashboard"></div>';
}
}
if (! function_exists('blocksy_render_view')) {
function blocksy_render_view(
$file_path,
$view_variables = [],
$default_value = ''
) {
if (! is_file($file_path)) {
return $default_value;
}
// phpcs:ignore WordPress.PHP.DontExtract.extract_extract
extract($view_variables, EXTR_REFS);
unset($view_variables);
ob_start();
require $file_path;
return ob_get_clean();
}
}

View File

@ -0,0 +1,13 @@
<?php
$config = [
// translators: This is a brand name. Preferably to not be translated
'name' => _x('Cookies Consent', 'Extension Brand Name', 'blocksy-companion'),
'description' => __('Display a cookie acceptance box in order to comply with the privacy regulations in your country.', 'blocksy-companion'),
'documentation' => 'https://creativethemes.com/blocksy/docs/extensions/cookies-consent/',
// 'video' => 'https://www.youtube.com/watch?v=6ZQY9Z9ZQZQ',
'customize' => admin_url('customize.php?ct_autofocus=cookie_consent_ext'),
'icon' => '<svg with="16" height="16" viewBox="0 0 16 16"><path d="M0 8c0-4.4 3.6-8 8-8 .6 0 1.3.1 1.9.2.2 0 .3.2.4.4 0 .2 0 .4-.1.5-.5.3-.7.8-.7 1.4 0 1 .7 1.8 1.6 2 .3.1.4.3.4.5 0 1.1.9 2 2 2 .6 0 1.1-.3 1.5-.7.1-.1.3-.2.5-.2.2.1.3.2.4.4.1.5.1 1 .1 1.5 0 4.4-3.6 8-8 8s-8-3.6-8-8zm5-2c0-.6-.4-1-1-1s-1 .4-1 1 .4 1 1 1 1-.4 1-1zm3 3c.6 0 1-.4 1-1s-.4-1-1-1-1 .4-1 1 .4 1 1 1zm3 3c0-.6-.4-1-1-1s-1 .4-1 1 .4 1 1 1 1-.4 1-1zm-6 0c.6 0 1-.4 1-1s-.4-1-1-1-1 .4-1 1 .4 1 1 1z"/></svg>',
];

View File

@ -0,0 +1,333 @@
<?php
$options = [
// translators: This is a brand name. Preferably to not be translated
'title' => _x('Cookies Consent', 'Extension Brand Name', 'blocksy-companion'),
'container' => [ 'priority' => 8 ],
'options' => [
'cookie_consent_section_options' => [
'type' => 'ct-options',
'setting' => [ 'transport' => 'postMessage' ],
'inner-options' => [
blocksy_rand_md5() => [
'title' => __( 'General', 'blocksy-companion' ),
'type' => 'tab',
'options' => [
'cookie_consent_type' => [
'label' => false,
'type' => 'ct-image-picker',
'value' => 'type-1',
'setting' => [ 'transport' => 'postMessage' ],
'choices' => [
'type-1' => [
'src' => BLOCKSY_URL . 'framework/extensions/cookies-consent/static/images/type-1.svg',
'title' => __( 'Type 1', 'blocksy-companion' ),
],
'type-2' => [
'src' => BLOCKSY_URL . 'framework/extensions/cookies-consent/static/images/type-2.svg',
'title' => __( 'Type 2', 'blocksy-companion' ),
],
],
],
'cookie_consent_period' => [
'label' => __('Cookie period', 'blocksy-companion'),
'type' => 'ct-select',
'value' => 'forever',
'design' => 'inline',
'setting' => [ 'transport' => 'postMessage' ],
'choices' => blocksy_ordered_keys(
[
'onehour' => __( 'One hour', 'blocksy-companion' ),
'oneday' => __( 'One day', 'blocksy-companion' ),
'oneweek' => __( 'One week', 'blocksy-companion' ),
'onemonth' => __( 'One month', 'blocksy-companion' ),
'threemonths' => __( 'Three months', 'blocksy-companion' ),
'sixmonths' => __( 'Six months', 'blocksy-companion' ),
'oneyear' => __( 'One year', 'blocksy-companion' ),
'forever' => __('Forever', 'blocksy-companion')
]
),
],
'cookie_consent_content' => [
'label' => __( 'Content', 'blocksy-companion' ),
'type' => 'wp-editor',
'value' => __('We use cookies to ensure that we give you the best experience on our website.', 'blocksy-companion'),
'disableRevertButton' => true,
'setting' => [ 'transport' => 'postMessage' ],
'quicktags' => false,
'mediaButtons' => false,
'tinymce' => [
'toolbar1' => 'bold,italic,link,alignleft,aligncenter,alignright,undo,redo',
],
],
'cookie_consent_button_text' => [
'label' => __( 'Accept Button text', 'blocksy-companion' ),
'type' => 'text',
'design' => 'block',
'divider' => 'top',
'value' => __('Accept', 'blocksy-companion'),
'setting' => [ 'transport' => 'postMessage' ],
],
'cookie_consent_decline_button_text' => [
'label' => __( 'Decline Button text', 'blocksy-companion' ),
'type' => 'text',
'design' => 'block',
'value' => __('Decline', 'blocksy-companion'),
'setting' => [ 'transport' => 'postMessage' ],
],
blocksy_rand_md5() => [
'type' => 'ct-condition',
'condition' => [ 'cookie_consent_type' => 'type-1' ],
'options' => [
'cookieMaxWidth' => [
'label' => __( 'Maximum Width', 'blocksy-companion' ),
'type' => 'ct-slider',
'value' => 400,
'min' => 200,
'max' => 500,
'divider' => 'top',
'setting' => [ 'transport' => 'postMessage' ],
],
],
],
blocksy_rand_md5() => [
'type' => 'ct-title',
'label' => __( 'Forms Cookies Content', 'blocksy-companion' ),
],
'forms_cookie_consent_content' => [
'label' => false,
'type' => 'wp-editor',
'value' => blc_safe_sprintf(
__('I accept the %sPrivacy Policy%s*', 'blocksy-companion'),
'<a href="' . get_privacy_policy_url() . '">',
'</a>'
),
'desc' => __( 'This text will appear under each comment form and subscribe form.', 'blocksy-companion' ),
// 'attr' => [ 'data-height' => 'heading-label' ],
'disableRevertButton' => true,
'setting' => [ 'transport' => 'postMessage' ],
'quicktags' => false,
'mediaButtons' => false,
'tinymce' => [
'toolbar1' => 'bold,italic,link,alignleft,aligncenter,alignright,undo,redo',
'forced_root_block' => '',
'force_br_newlines' => true,
'force_p_newlines' => false
],
],
],
],
blocksy_rand_md5() => [
'title' => __( 'Design', 'blocksy-companion' ),
'type' => 'tab',
'options' => [
'cookieContentColor' => [
'label' => __( 'Text Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
'hover' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
'inherit' => 'var(--theme-text-color)'
],
[
'title' => __( 'Hover', 'blocksy-companion' ),
'id' => 'hover',
'inherit' => 'var(--theme-link-hover-color)'
],
],
],
'cookieBackground' => [
'label' => __( 'Background Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => 'var(--theme-palette-color-8)',
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
],
],
],
blocksy_rand_md5() => [
'type' => 'ct-title',
'label' => __( 'Accept Button', 'blocksy-companion' ),
],
'cookieButtonText' => [
'label' => __( 'Font Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
// 'divider' => 'top',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
'hover' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
'inherit' => 'var(--theme-button-text-initial-color)',
],
[
'title' => __( 'Hover', 'blocksy-companion' ),
'id' => 'hover',
'inherit' => 'var(--theme-button-text-hover-color)',
],
],
],
'cookieButtonBackground' => [
'label' => __( 'Background Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
// 'divider' => 'top',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
'hover' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
'inherit' => 'var(--theme-button-background-initial-color)'
],
[
'title' => __( 'Hover', 'blocksy-companion' ),
'id' => 'hover',
'inherit' => 'var(--theme-button-background-hover-color)'
],
],
],
blocksy_rand_md5() => [
'type' => 'ct-title',
'label' => __( 'Decline Button', 'blocksy-companion' ),
],
'cookieDeclineButtonText' => [
'label' => __( 'Font Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
// 'divider' => 'top',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => 'var(--theme-palette-color-3)',
],
'hover' => [
'color' => 'var(--theme-palette-color-3)',
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
],
[
'title' => __( 'Hover', 'blocksy-companion' ),
'id' => 'hover',
],
],
],
'cookieDeclineButtonBackground' => [
'label' => __( 'Background Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
// 'divider' => 'top',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => 'rgba(224, 229, 235, 0.6)',
],
'hover' => [
'color' => 'rgba(224, 229, 235, 1)',
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
],
[
'title' => __( 'Hover', 'blocksy-companion' ),
'id' => 'hover',
],
],
],
],
],
],
],
],
];

View File

@ -0,0 +1,171 @@
<?php
require_once dirname(__FILE__) . '/helpers.php';
class BlocksyExtensionCookiesConsent {
public static function should_display_notification() {
return ! isset($_COOKIE['blocksy_cookies_consent_accepted']);
}
public static function has_consent() {
return (
isset($_COOKIE['blocksy_cookies_consent_accepted'])
&&
$_COOKIE['blocksy_cookies_consent_accepted'] === 'true'
);
}
public function __construct() {
add_filter('blocksy-async-scripts-handles', function ($d) {
$d[] = 'blocksy-ext-cookies-consent-scripts';
return $d;
});
add_filter(
'blocksy_extensions_customizer_options',
[$this, 'add_options_panel']
);
add_action(
'customize_preview_init',
function () {
if (! function_exists('get_plugin_data')){
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
}
$data = get_plugin_data(BLOCKSY__FILE__);
wp_enqueue_script(
'blocksy-cookies-consent-customizer-sync',
BLOCKSY_URL . 'framework/extensions/cookies-consent/static/bundle/sync.js',
[ 'ct-scripts', 'customize-preview' ],
$data['Version'],
true
);
}
);
add_action('wp_enqueue_scripts', function () {
if (! function_exists('get_plugin_data')) {
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
$data = get_plugin_data(BLOCKSY__FILE__);
if (is_admin()) {
return;
}
wp_enqueue_script(
'blocksy-ext-cookies-consent-scripts',
BLOCKSY_URL . 'framework/extensions/cookies-consent/static/bundle/main.js',
['ct-scripts'],
$data['Version'],
true
);
}, 50);
add_filter('blocksy:general:ct-scripts-localizations', function ($data) {
$data['dynamic_styles']['cookie_notification'] = blocksy_cdn_url(
BLOCKSY_URL . 'framework/extensions/cookies-consent/static/bundle/main.min.css'
);
return $data;
});
add_action(
'blocksy:global-dynamic-css:enqueue',
'BlocksyExtensionCookiesConsent::add_global_styles',
10, 3
);
add_action(
'pre_comment_on_post',
function ($post_id) {
$data = wp_unslash($_POST);
if (! isset($data['comment_post_ID'])) {
return;
}
if (
! isset($data['ct_has_gdprconfirm'])
||
$data['ct_has_gdprconfirm'] !== 'yes'
) {
return;
}
if (
! isset($data['gdprconfirm'])
||
$data['gdprconfirm'] !== 'on'
) {
wp_die(
'<p>' . __('Please accept the Privacy Policy in order to comment.', 'blocksy-companion') . '</p>',
__('Comment Submission Failure', 'blocksy-companion'),
array(
'response' => $data,
'back_link' => true,
)
);
}
}
);
add_action('wp', function() {
add_filter('woocommerce_product_review_comment_form_args', [$this, 'change_comment_form']);
}, 999);
add_action('wp_ajax_blc_load_cookies_consent_data', [
$this,
'blc_load_cookies_consent_data',
]);
add_action(
'wp_ajax_nopriv_blc_load_cookies_consent_data',
[$this, 'blc_load_cookies_consent_data']
);
}
public function blc_load_cookies_consent_data() {
$scripts = apply_filters('blocksy:cookies-consent:scripts-to-load', [], PHP_INT_MAX);
wp_send_json_success([
'scripts' => $scripts,
'consent_output' => blocksy_ext_cookies_consent_output(),
]);
}
public function change_comment_form($comment_form) {
$comment_form['comment_field'] .= blocksy_ext_cookies_checkbox('reviews');
return $comment_form;
}
static public function add_global_styles($args) {
blocksy_theme_get_dynamic_styles(array_merge([
'path' => dirname(__FILE__) . '/global.php',
'chunk' => 'global',
], $args));
}
static public function onDeactivation() {
remove_action(
'blocksy:global-dynamic-css:enqueue',
'BlocksyExtensionCookiesConsent::add_global_styles',
10, 3
);
}
public function add_options_panel($options) {
$options['cookie_consent_ext'] = blocksy_get_options(
dirname(__FILE__) . '/customizer.php',
[],
false
);
return $options;
}
}

View File

@ -0,0 +1,127 @@
<?php
// Content color
blocksy_output_colors([
'value' => blocksy_get_theme_mod('cookieContentColor'),
'default' => [
'default' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
'hover' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
],
'css' => $css,
'variables' => [
'default' => [
'selector' => '.cookie-notification',
'variable' => 'theme-text-color'
],
'hover' => [
'selector' => '.cookie-notification',
'variable' => 'theme-link-hover-color'
],
],
]);
// Accept button color
blocksy_output_colors([
'value' => blocksy_get_theme_mod('cookieButtonText'),
'default' => [
'default' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
'hover' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
],
'css' => $css,
'variables' => [
'default' => [
'selector' => '.cookie-notification .ct-cookies-accept-button',
'variable' => 'theme-button-text-initial-color'
],
'hover' => [
'selector' => '.cookie-notification .ct-cookies-accept-button',
'variable' => 'theme-button-text-hover-color'
]
],
]);
blocksy_output_colors([
'value' => blocksy_get_theme_mod('cookieButtonBackground'),
'default' => [
'default' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
'hover' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
],
'css' => $css,
'variables' => [
'default' => [
'selector' => '.cookie-notification .ct-cookies-accept-button',
'variable' => 'theme-button-background-initial-color'
],
'hover' => [
'selector' => '.cookie-notification .ct-cookies-accept-button',
'variable' => 'theme-button-background-hover-color'
]
],
]);
// Decline button color
blocksy_output_colors([
'value' => blocksy_get_theme_mod('cookieDeclineButtonText'),
'default' => [
'default' => [ 'color' => 'var(--theme-palette-color-3)' ],
'hover' => [ 'color' => 'var(--theme-palette-color-3)' ],
],
'css' => $css,
'variables' => [
'default' => [
'selector' => '.cookie-notification .ct-cookies-decline-button',
'variable' => 'theme-button-text-initial-color'
],
'hover' => [
'selector' => '.cookie-notification .ct-cookies-decline-button',
'variable' => 'theme-button-text-hover-color'
]
],
]);
blocksy_output_colors([
'value' => blocksy_get_theme_mod('cookieDeclineButtonBackground'),
'default' => [
'default' => [ 'color' => 'rgba(224, 229, 235, 0.6)' ],
'hover' => [ 'color' => 'rgba(224, 229, 235, 1)' ],
],
'css' => $css,
'variables' => [
'default' => [
'selector' => '.cookie-notification .ct-cookies-decline-button',
'variable' => 'theme-button-background-initial-color'
],
'hover' => [
'selector' => '.cookie-notification .ct-cookies-decline-button',
'variable' => 'theme-button-background-hover-color'
]
],
]);
// Background color
blocksy_output_colors([
'value' => blocksy_get_theme_mod('cookieBackground'),
'default' => [
'default' => [ 'color' => 'var(--theme-palette-color-8)' ],
],
'css' => $css,
'variables' => [
'default' => [
'selector' => '.cookie-notification',
'variable' => 'backgroundColor'
],
],
]);
$cookieMaxWidth = blocksy_get_theme_mod( 'cookieMaxWidth', 400 );
$css->put(
'.cookie-notification',
'--maxWidth: ' . $cookieMaxWidth . 'px'
);

View File

@ -0,0 +1,71 @@
<?php
function blocksy_ext_cookies_consent_output() {
$content = blocksy_get_theme_mod(
'cookie_consent_content',
__('We use cookies to ensure that we give you the best experience on our website.', 'blocksy-companion')
);
$accept_button_text = blocksy_get_theme_mod('cookie_consent_button_text', __('Accept', 'blocksy-companion'));
$decline_button_text = blocksy_get_theme_mod('cookie_consent_decline_button_text', __('Decline', 'blocksy-companion'));
$period = blocksy_get_theme_mod('cookie_consent_period', 'forever');
$type = blocksy_get_theme_mod('cookie_consent_type', 'type-1');
$class = 'container';
if ( $type === 'type-2' ) {
$class = 'ct-container';
}
ob_start();
?>
<div class="cookie-notification ct-fade-in-start" data-period="<?php echo esc_attr($period) ?>" data-type="<?php echo esc_attr($type) ?>">
<div class="<?php echo esc_attr($class) ?>">
<?php if (!empty($content)) { ?>
<div class="ct-cookies-content"><?php echo wp_kses_post($content) ?></div>
<?php } ?>
<div class="ct-button-group">
<button type="button" class="ct-button ct-cookies-accept-button"><?php echo esc_html($accept_button_text) ?></button>
<button type="button" class="ct-button ct-cookies-decline-button"><?php echo esc_html($decline_button_text) ?></button>
</div>
</div>
</div>
<?php
return ob_get_clean();
}
function blocksy_ext_cookies_checkbox($prefix = '') {
ob_start();
if (! empty($prefix)) {
$prefix = '_' . $prefix;
}
$message = blocksy_get_theme_mod(
'forms_cookie_consent_content',
blc_safe_sprintf(
__('I accept the %sPrivacy Policy%s', 'blocksy-companion'),
'<a href="' . get_privacy_policy_url() . '">',
'</a>'
)
);
?>
<p class="gdpr-confirm-policy">
<input name="ct_has_gdprconfirm" type="hidden" value="yes">
<input id="gdprconfirm<?php echo $prefix ?>" class="ct-checkbox" name="gdprconfirm" type="checkbox" required><label for="gdprconfirm<?php echo $prefix ?>"><?php echo $message ?></label>
</p>
<?php
return ob_get_clean();
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
/**
* - v2.0.37
*
* Copyright (c) 2024
* Licensed GPLv2+
*/
.cookie-notification{position:fixed;inset-inline-start:var(--theme-frame-size, 0px);bottom:var(--theme-frame-size, 0px);z-index:999999;color:var(--theme-text-color)}@media(max-width: 689.98px){.cookie-notification{inset-inline-end:var(--theme-frame-size, 0px)}}.cookie-notification>div{display:flex;flex-direction:column;gap:20px;padding:20px 0}@media(max-width: 689.98px){.cookie-notification>div{align-items:center}}@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] .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,.15);padding:30px;border-radius:3px;max-width:var(--maxWidth)}}.cookie-notification[data-type=type-2]{inset-inline-end:var(--theme-frame-size, 0px);padding-inline-end:var(--scrollbar-width, 0px);background:var(--backgroundColor)}@media(min-width: 690px){.cookie-notification[data-type=type-2] .ct-container{flex-direction:initial;align-items:center;justify-content:center}}.cookie-notification .ct-cookies-content{font-size:14px;line-height:1.4}.cookie-notification .ct-cookies-content>*:last-child{margin-bottom:0}.cookie-notification .ct-cookies-content a{text-decoration:underline}@media(max-width: 689.98px){.cookie-notification .ct-cookies-content{text-align:center}}.cookie-notification .ct-button-group{display:flex;gap:10px}.cookie-notification .ct-button-group .ct-button{--theme-button-font-size: 13px;--theme-button-min-height: 35px;--theme-button-padding: 0 20px;--theme-button-shadow: none;--theme-button-transform: none}@media(max-width: 479.98px){.cookie-notification .ct-button-group .ct-button{flex:1}}.cookie-notification.ct-fade-in-start,.cookie-notification.ct-fade-in-end,.cookie-notification.ct-fade-start,.cookie-notification.ct-fade-end{transition:all .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)}

View File

@ -0,0 +1 @@
!function(){"use strict";var t={n:function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,{a:o}),o},d:function(e,o){for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},e=window.ctEvents;function o(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,n)}return o}function n(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?o(Object(n),!0).forEach((function(e){r(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function r(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function c(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);"Object"===o&&t.constructor&&(o=t.constructor.name);if("Map"===o||"Set"===o)return Array.from(t);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return i(t,e)}(t)||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(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,n=new Array(e);o<e;o++)n[o]=t[o];return n}t.n(e)().on("ct:customizer:sync:collect-variable-descriptors",(function(t){t.result=n(n({},t.result),{},{cookieContentColor:[{selector:".cookie-notification",variable:"theme-text-color",type:"color:default"},{selector:".cookie-notification",variable:"theme-link-hover-color",type:"color:hover"}],cookieBackground:{selector:".cookie-notification",variable:"backgroundColor",type:"color"},cookieButtonText:[{selector:".cookie-notification .ct-cookies-accept-button",variable:"theme-button-text-initial-color",type:"color:default"},{selector:".cookie-notification .ct-cookies-accept-button",variable:"theme-button-text-hover-color",type:"color:hover"}],cookieButtonBackground:[{selector:".cookie-notification .ct-cookies-accept-button",variable:"theme-button-background-initial-color",type:"color:default"},{selector:".cookie-notification .ct-cookies-accept-button",variable:"theme-button-background-hover-color",type:"color:hover"}],cookieDeclineButtonText:[{selector:".cookie-notification .ct-cookies-decline-button",variable:"theme-button-text-initial-color",type:"color:default"},{selector:".cookie-notification .ct-cookies-decline-button",variable:"theme-button-text-hover-color",type:"color:hover"}],cookieDeclineButtonBackground:[{selector:".cookie-notification .ct-cookies-decline-button",variable:"theme-button-background-initial-color",type:"color:default"},{selector:".cookie-notification .ct-cookies-decline-button",variable:"theme-button-background-hover-color",type:"color:hover"}],cookieMaxWidth:{selector:".cookie-notification",variable:"maxWidth",unit:"px"}})}));var u=function(){var 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-cookies-accept-button").innerHTML=wp.customize("cookie_consent_button_text")();var e=wp.customize("cookie_consent_type")();t.dataset.type=e,t.firstElementChild.classList.remove("ct-container","container"),t.firstElementChild.classList.add("type-1"===e?"container":"ct-container")}};wp.customize("cookie_consent_content",(function(t){return t.bind((function(t){u()}))})),wp.customize("cookie_consent_button_text",(function(t){return t.bind((function(t){return u()}))})),wp.customize("cookie_consent_type",(function(t){return t.bind((function(t){return u()}))})),wp.customize("forms_cookie_consent_content",(function(t){return t.bind((function(t){return c(document.querySelectorAll(".gdpr-confirm-policy label")).map((function(e){return e.innerHTML=t}))}))}))}();

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<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"
viewBox="0 0 100 70" style="enable-background:new 0 0 100 70;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;}
.st1{fill:#EDEFF0;}
.st2{fill:#565D66;}
.st3{fill:#4F5459;}
.st4{fill:#6E747A;}
</style>
<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
H13z"/>
<path class="st1" d="M11,11h78v14H11V11z"/>
<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
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"/>
<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
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
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
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
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
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
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
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"/>
<g>
<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
C49.2,65.4,48.8,65.9,48.2,65.9z"/>
<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"/>
<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"/>
<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"/>
<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
C29.9,62.3,28.9,63.2,27.8,63.2z"/>
<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"/>
<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
C39.7,49.4,39.2,49.9,38.7,49.9z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<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"
viewBox="0 0 100 70" style="enable-background:new 0 0 100 70;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;}
.st1{fill:#6E747A;}
.st2{fill:#EDEFF0;}
.st3{fill:#565D66;}
.st4{fill:#4F5459;}
</style>
<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
H13z"/>
<g>
<rect x="10.4" y="57.2" class="st1" width="79.1" height="13"/>
<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"/>
<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"/>
<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
C86.3,65.2,85.4,66.1,84.2,66.1z"/>
<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"/>
<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"/>
</g>
<path class="st2" d="M11,11h78v14H11V11z"/>
<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
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"/>
<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
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
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
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
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
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
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
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"/>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,270 @@
/**
* Listen and trigger custom events to communicate between javascript components
*/
window.ctEvents =
window.ctEvents ||
new (function () {
var _events = {}
var currentIndentation = 1
var debug = false
this.countAll = function (topic) {
return _events[topic]
}
/**
* Make log helper public
*
* @param {String} [message]
* @param {Object} [data]
*/
this.log = log
/**
* Enable/Disable Debug
* @param {Boolean} enabled
*/
this.debug = function (enabled) {
debug = Boolean(enabled)
return this
}
/**
* Add event listener
*
* @param event {String | Object}
* Can be a:
* - single event: 'event1'
* - space separated event list: 'event1 event2 event2'
* - an object: {event1: function () {}, event2: function () {}}
*
* @param callback {Function}
*/
this.on = function (topicStringOrObject, listener) {
objectMap(
splitTopicStringOrObject(topicStringOrObject, listener),
function (eventName, listener) {
;(_events[eventName] || (_events[eventName] = [])).push(
listener
)
debug && log('✚ ' + eventName)
}
)
return this
}
/**
* Same as .on(), but callback will executed only once
*/
this.one = function (topicStringOrObject, listener) {
objectMap(
splitTopicStringOrObject(topicStringOrObject, listener),
function (eventName, listener) {
;(_events[eventName] || (_events[eventName] = [])).push(
once(listener)
)
debug && log('✚ [' + eventName + ']')
}
)
return this
// https://github.com/jashkenas/underscore/blob/8fc7032295d60aff3620ef85d4aa6549a55688a0/underscore.js#L946
function once(func) {
var memo
var times = 2
return function () {
if (--times > 0) {
memo = func.apply(this, arguments)
}
if (times <= 1) func = null
return memo
}
}
}
/**
* In order to remove one single listener you should give as an argument
* the same callback function. If you want to remove *all* listeners from
* a particular event you should not pass the second argument.
*
* @param topicStringOrObject {String | Object}
* @param listener {Function | false}
*/
this.off = function (topicStringOrObject, listener) {
objectMap(
splitTopicStringOrObject(topicStringOrObject, listener),
function (eventName, listener) {
if (_events[eventName]) {
if (listener) {
_events[eventName].splice(
_events[eventName].indexOf(listener) >>> 0,
1
)
} else {
_events[eventName] = []
}
debug && log('✖ ' + eventName)
}
}
)
return this
}
/**
* Trigger an event. In case you provide multiple events via space-separated
* string or an object of events it will execute listeners for each event
* separatedly. You can use the "all" event to trigger all events.
*
* @param topicStringOrObject {String | Object}
* @param data {Object}
*/
this.trigger = function (eventName, data) {
objectMap(splitTopicStringOrObject(eventName), function (
eventName
) {
log('╭─ ' + eventName, data)
changeIndentation(+1)
try {
// TODO: REFACTOR THAT!!!!!!!!!
// Maybe this is an occasion for using 'all' event???
if (eventName === 'fw:options:init') {
fw.options.startListeningToEvents(
data.$elements || document.body
)
}
;(_events[eventName] || []).map(dispatchSingleEvent)
;(_events['all'] || []).map(dispatchSingleEvent)
} catch (e) {
console.log(
'%c [Events] Exception raised.',
'color: red; font-weight: bold;'
)
if (typeof console !== 'undefined') {
console.error(e)
} else {
throw e
}
}
changeIndentation(-1)
log('╰─ ' + eventName, data)
function dispatchSingleEvent(listenerDescriptor) {
if (!listenerDescriptor) return
listenerDescriptor.call(window, data)
}
})
return this
function changeIndentation(increment) {
if (typeof increment != 'undefined') {
currentIndentation += increment > 0 ? +1 : -1
}
if (currentIndentation < 0) {
currentIndentation = 0
}
}
}
/**
* Check if an event has listeners
* @param {String} [event]
* @return {Boolean}
*/
this.hasListeners = function (eventName) {
if (!_events) {
return false
}
return (_events[eventName] || []).length > 0
}
/**
* Probably split string into general purpose object representation for
* event names and listeners. This function leaves objects un-modified.
*
* @param topicStringOrObject {String | Object}
* @param listener {Function | false}
*
* @returns {Object} {
* eventname: listener,
* otherevent: listener
* }
*/
function splitTopicStringOrObject(topicStringOrObject, listener) {
if (typeof topicStringOrObject !== 'string') {
return topicStringOrObject
}
var arrayOfEvents = topicStringOrObject
.replace(/\s\s+/g, ' ')
.trim()
.split(' ')
var len = arrayOfEvents.length
var listenerDescriptor = Object.create(null)
for (var i = 0; i < len; i++) {
listenerDescriptor[arrayOfEvents[i]] = listener
}
return listenerDescriptor
}
/**
* returns a new object with the predicate applied to each value
* objectMap({a: 3, b: 5, c: 9}, (key, value) => value + 1); // {a: 4, b: 6, c: 10}
* objectMap({a: 3, b: 5, c: 9}, (key, value) => key); // {a: 'a', b: 'b', c: 'c'}
* objectMap({a: 3, b: 5, c: 9}, (key, value) => key + value); // {a: 'a3', b: 'b5', c: 'c9'}
*
* https://github.com/angus-c/just/tree/master/packages/object-map
*/
function objectMap(obj, predicate) {
var result = {}
var keys = Object.keys(obj)
var len = keys.length
for (var i = 0; i < len; i++) {
var key = keys[i]
result[key] = predicate(key, obj[key])
}
return result
}
function log(message, data) {
if (!debug) {
return
}
if (typeof data != 'undefined') {
console.log('[Event] ' + getIndentation() + message, '─', data)
} else {
console.log('[Event] ' + getIndentation() + message)
}
function getIndentation() {
return new Array(currentIndentation).join('│ ')
}
}
})()

View File

@ -0,0 +1,192 @@
import ctEvents from 'ct-events'
import cookie from 'js-cookie'
import { loadStyle } from 'blocksy-frontend'
const onKeydown = (event) => {
if (event.keyCode !== 27) return
hideCookieConsent(document.querySelector('.cookie-notification'))
}
const showCookieConsent = (node) => {
document.addEventListener('keyup', onKeydown)
requestAnimationFrame(() => {
node.classList.remove('ct-fade-in-start')
node.classList.add('ct-fade-in-end')
whenTransitionEnds(node, () => {
node.classList.remove('ct-fade-in-end')
})
})
}
const hideCookieConsent = (node) => {
document.removeEventListener('keyup', onKeydown)
node.classList.add('ct-fade-start')
requestAnimationFrame(() => {
node.classList.remove('ct-fade-start')
node.classList.add('ct-fade-end')
whenTransitionEnds(node, () => {
node.parentNode.removeChild(node)
})
})
}
export const onDocumentLoaded = (cb) => {
if (/comp|inter|loaded/.test(document.readyState)) {
cb()
} else {
document.addEventListener('DOMContentLoaded', cb, false)
}
}
let cookiesData = {}
const mountCookieNotification = () => {
const notification = document.querySelector('.cookie-notification')
showCookieConsent(notification)
;[...notification.querySelectorAll('button')].map((el) => {
el.addEventListener('click', (e) => {
e.preventDefault()
if (el.classList.contains('ct-cookies-accept-button')) {
const periods = {
onehour: 36e5,
oneday: 864e5,
oneweek: 7 * 864e5,
onemonth: 31 * 864e5,
threemonths: 3 * 31 * 864e5,
sixmonths: 6 * 31 * 864e5,
oneyear: 365 * 864e5,
forever: 10000 * 864e5,
}
cookie.set('blocksy_cookies_consent_accepted', 'true', {
expires: new Date(
new Date() * 1 +
periods[el.closest('[data-period]').dataset.period]
),
sameSite: 'lax',
})
if (cookiesData && cookiesData.scripts) {
cookiesData.scripts.map((scriptTag) => {
const parser = new DOMParser()
const html = parser.parseFromString(
scriptTag,
'text/html'
)
const scriptsToLoad = html.querySelectorAll('script')
if (!scriptsToLoad) return
;[...scriptsToLoad].map((script) => {
const newTag = document.createElement('script')
if (script.innerHTML) {
newTag.innerHTML = script.innerHTML
}
;[...script.attributes].map(({ name, value }) => {
newTag.setAttribute(name, value)
})
document.head.appendChild(newTag)
})
})
}
}
if (el.classList.contains('ct-cookies-decline-button')) {
const periods = {
onehour: 36e5,
oneday: 864e5,
oneweek: 7 * 864e5,
onemonth: 31 * 864e5,
threemonths: 3 * 31 * 864e5,
sixmonths: 6 * 31 * 864e5,
oneyear: 365 * 864e5,
forever: 10000 * 864e5,
}
cookie.set('blocksy_cookies_consent_accepted', 'no', {
expires: new Date(
new Date() * 1 +
periods[el.closest('[data-period]').dataset.period]
),
sameSite: 'lax',
})
}
hideCookieConsent(notification)
})
})
}
const initCookies = () => {
if (cookie.get('blocksy_cookies_consent_accepted')) {
return
}
const body = new FormData()
body.append('action', 'blc_load_cookies_consent_data')
fetch(ct_localizations.ajax_url, {
method: 'POST',
body,
})
.then((r) => r.json())
.then(({ data }) => {
cookiesData = data
const drawerCanvas = document.querySelector(
'.ct-drawer-canvas[data-location="start"]'
)
loadStyle(ct_localizations.dynamic_styles.cookie_notification).then(
() => {
drawerCanvas.insertAdjacentHTML(
'beforeend',
cookiesData.consent_output
)
mountCookieNotification()
}
)
})
}
onDocumentLoaded(() => {
initCookies()
if (ctEvents) {
ctEvents.on('blocksy:cookies:init', () => {
initCookies()
})
}
})
function whenTransitionEnds(el, cb) {
setTimeout(() => {
cb()
}, 300)
return
const end = () => {
el.removeEventListener('transitionend', onEnd)
cb()
}
const onEnd = (e) => {
if (e.target === el) {
end()
}
}
el.addEventListener('transitionend', onEnd)
}

View File

@ -0,0 +1,43 @@
import './variables'
import ctEvents from 'ct-events'
const render = () => {
const notification = document.querySelector('.cookie-notification')
if (!notification) {
return
}
if (notification.querySelector('.ct-cookies-content')) {
notification.querySelector('.ct-cookies-content').innerHTML =
wp.customize('cookie_consent_content')()
}
notification.querySelector('button.ct-cookies-accept-button').innerHTML =
wp.customize('cookie_consent_button_text')()
const type = wp.customize('cookie_consent_type')()
notification.dataset.type = type
notification.firstElementChild.classList.remove('ct-container', 'container')
notification.firstElementChild.classList.add(
type === 'type-1' ? 'container' : 'ct-container'
)
}
wp.customize('cookie_consent_content', (val) =>
val.bind((to) => {
render()
})
)
wp.customize('cookie_consent_button_text', (val) => val.bind((to) => render()))
wp.customize('cookie_consent_type', (val) => val.bind((to) => render()))
wp.customize('forms_cookie_consent_content', (val) =>
val.bind((to) =>
[...document.querySelectorAll('.gdpr-confirm-policy label')].map(
(el) => (el.innerHTML = to)
)
)
)

View File

@ -0,0 +1,23 @@
export const responsiveClassesFor = (id, el) => {
el.classList.remove('ct-hidden-sm', 'ct-hidden-md', 'ct-hidden-lg')
if (!wp.customize(id)) return
const data = wp.customize(id)() || {
mobile: false,
tablet: true,
desktop: true,
}
if (!data.mobile) {
el.classList.add('ct-hidden-sm')
}
if (!data.tablet) {
el.classList.add('ct-hidden-md')
}
if (!data.desktop) {
el.classList.add('ct-hidden-lg')
}
}

View File

@ -0,0 +1,91 @@
import ctEvents from 'ct-events'
ctEvents.on(
'ct:customizer:sync:collect-variable-descriptors',
(allVariables) => {
allVariables.result = {
...allVariables.result,
cookieContentColor: [
{
selector: '.cookie-notification',
variable: 'theme-text-color',
type: 'color:default',
},
{
selector: '.cookie-notification',
variable: 'theme-link-hover-color',
type: 'color:hover',
},
],
cookieBackground: {
selector: '.cookie-notification',
variable: 'backgroundColor',
type: 'color',
},
cookieButtonText: [
{
selector: '.cookie-notification .ct-cookies-accept-button',
variable: 'theme-button-text-initial-color',
type: 'color:default',
},
{
selector: '.cookie-notification .ct-cookies-accept-button',
variable: 'theme-button-text-hover-color',
type: 'color:hover',
},
],
cookieButtonBackground: [
{
selector: '.cookie-notification .ct-cookies-accept-button',
variable: 'theme-button-background-initial-color',
type: 'color:default',
},
{
selector: '.cookie-notification .ct-cookies-accept-button',
variable: 'theme-button-background-hover-color',
type: 'color:hover',
},
],
cookieDeclineButtonText: [
{
selector: '.cookie-notification .ct-cookies-decline-button',
variable: 'theme-button-text-initial-color',
type: 'color:default',
},
{
selector: '.cookie-notification .ct-cookies-decline-button',
variable: 'theme-button-text-hover-color',
type: 'color:hover',
},
],
cookieDeclineButtonBackground: [
{
selector: '.cookie-notification .ct-cookies-decline-button',
variable: 'theme-button-background-initial-color',
type: 'color:default',
},
{
selector: '.cookie-notification .ct-cookies-decline-button',
variable: 'theme-button-background-hover-color',
type: 'color:hover',
},
],
cookieMaxWidth: {
selector: '.cookie-notification',
variable: 'maxWidth',
unit: 'px',
},
}
}
)

View File

@ -0,0 +1,124 @@
@import '../../../../../static/sass/frontend/common-frontend/functions';
@import '../../../../../static/sass/frontend/common-frontend/mixins';
.cookie-notification {
position: fixed;
inset-inline-start: var(--theme-frame-size, 0px);
bottom: var(--theme-frame-size, 0px);
z-index: 999999;
color: var(--theme-text-color);
@include media-breakpoint-down (sm) {
inset-inline-end: var(--theme-frame-size, 0px);
}
> div {
display: flex;
flex-direction: column;
gap: 20px;
padding: 20px 0;
@include media-breakpoint-down (sm) {
align-items: center;
}
}
// type 1
&[data-type='type-1'] {
@include media-breakpoint-down (sm) {
background: var(--backgroundColor);
}
@include media-breakpoint-up (md) {
padding: 0 25px 25px 25px;
}
.container {
position: relative;
@include media-breakpoint-down (sm) {
width: 88%;
margin: 0 auto;
}
@include media-breakpoint-up (md) {
background: var(--backgroundColor);
box-shadow: 0px 5px 30px -5px rgba(34, 56, 101, 0.15);
padding: 30px;
border-radius: 3px;
max-width: var(--maxWidth);
}
}
}
// type 2
&[data-type='type-2'] {
inset-inline-end: var(--theme-frame-size, 0px);
padding-inline-end: var(--scrollbar-width, 0px);
background: var(--backgroundColor);
@include media-breakpoint-up (md) {
.ct-container {
flex-direction: initial;
align-items: center;
justify-content: center;
}
}
}
.ct-cookies-content {
font-size: 14px;
line-height: 1.4;
> *:last-child {
margin-bottom: 0;
}
a {
text-decoration: underline;
}
@include media-breakpoint-down (sm) {
text-align: center;
}
}
.ct-button-group {
display: flex;
gap: 10px;
.ct-button {
--theme-button-font-size: 13px;
--theme-button-min-height: 35px;
--theme-button-padding: 0 20px;
--theme-button-shadow: none;
--theme-button-transform: none;
@include media-breakpoint-down (xs) {
flex: 1;
}
}
}
// animation
&.ct-fade-in-start,
&.ct-fade-in-end,
&.ct-fade-start,
&.ct-fade-end {
transition: all 0.3s ease;
}
&.ct-fade-in-start {
opacity: 0;
transform: translate3d(0, 15px, 0);
}
&.ct-fade-end {
opacity: 0;
transform: translate3d(0, 15px, 0);
}
}

View File

@ -0,0 +1 @@
"use strict";(globalThis.blocksyNewsletterSubscribeExtJsonp=globalThis.blocksyNewsletterSubscribeExtJsonp||[]).push([[564],{564:function(e,t,n){n.r(t);var r=n(381),a=n(343),o=n(652),i=n(184),c=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},u.apply(this,arguments)}function s(e,t,n,r,a,o,i){try{var c=e[o](i),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,a)}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 i,c=e[Symbol.iterator]();!(r=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==c.return||c.return()}finally{if(a)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return d(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 d(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 d(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=null;t.default=function(e){var t=e.value,n=e.onChange,i=l((0,r.useState)(f||[]),2),d=i[0],p=i[1],m=l((0,r.useState)(!f),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_newsletter_subscribe_get_actual_lists"),t.append("nonce",(window.ctDashboardLocalizations||window.ct_localizations||window.ct_customizer_localizations).dashboard_actions_nonce),e.prev=5,e.next=8,fetch(ajaxurl,{method:"POST",body:t});case 8:if(200!==(n=e.sent).status){e.next=19;break}return e.next=12,n.json();case 12:if(!(r=e.sent).success){e.next=19;break}if("api_key_invalid"===r.data.result){e.next=19;break}return v(!1),p(r.data.result),f=r.data.result,e.abrupt("return");case 19:e.next=23;break;case 21:e.prev=21,e.t0=e.catch(5);case 23:v(!1);case 24:case"end":return e.stop()}}),e,null,[[5,21]])})),function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){s(o,r,a,i,c,"next",e)}function c(e){s(o,r,a,i,c,"throw",e)}i(void 0)}))});return function(){return t.apply(this,arguments)}}();return(0,r.useEffect)((function(){h(!f)}),[]),0===d.length?(0,r.createElement)("div",{className:"ct-select-input"},(0,r.createElement)("input",{disabled:!0,placeholder:b?(0,o.__)("Loading...","blocksy-companion"):(0,o.__)("Invalid API Key...","blocksy-companion")})):(0,r.createElement)(a.ZP,{selectedItem:t||d[0].id,onChange:function(e){return n(e)},itemToString:function(e){return e?(d.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,s=(e.inputValue,e.highlightedIndex),l=e.selectedItem,f=e.openMenu;return(0,r.createElement)("div",{className:"ct-select-input"},(0,r.createElement)("input",u({},t({onFocus:function(){return f()},onClick:function(){return f()}}),{placeholder:(0,o.__)("Select list...","blocksy-companion"),readOnly:!0})),i&&(0,r.createElement)("div",a({className:"ct-select-dropdown"}),d.map((function(e,t){return(0,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)}))))}))}}}]);

View File

@ -0,0 +1,8 @@
/**
* - v2.0.37
*
* Copyright (c) 2024
* Licensed GPLv2+
*/
.ct-newsletter-subscribe-form{display:grid;gap:var(--theme-form-field-gap, 10px);--theme-link-initial-color: var(--text-color, var(--theme-text-color))}@media(min-width: 690px){.ct-newsletter-subscribe-form[data-columns="2"]{grid-template-columns:1fr auto}}@media(min-width: 690px){.ct-newsletter-subscribe-form[data-columns="3"]{grid-template-columns:1fr 1fr auto}}.ct-newsletter-subscribe-form .wp-element-button{width:100%;--theme-button-min-height: var(--theme-form-field-height, 40px);--theme-button-border-radius: var(--theme-form-field-border-radius, 3px)}.ct-newsletter-subscribe-form .gdpr-confirm-policy,.ct-newsletter-subscribe-form .ct-newsletter-subscribe-message{grid-column:1/-1;margin:0}.ct-newsletter-subscribe-form .ct-newsletter-subscribe-message{display:none}.ct-newsletter-subscribe-form .ct-newsletter-subscribe-message a{text-decoration:underline}.ct-newsletter-subscribe-form.subscribe-error .ct-newsletter-subscribe-message,.ct-newsletter-subscribe-form.subscribe-success .ct-newsletter-subscribe-message{display:block}.ct-newsletter-subscribe-form.subscribe-error .ct-newsletter-subscribe-message{color:#e42b2b;font-size:14px}.ct-newsletter-subscribe-form.subscribe-success *:not(.ct-newsletter-subscribe-message){display:none}.ct-newsletter-subscribe-container{margin-top:60px;padding:var(--padding, 30px);color:var(--text-color, var(--theme-text-color));border-radius:var(--theme-border-radius, 0px);border:var(--newsletter-container-border, none);box-shadow:var(--theme-box-shadow, 0px 12px 18px -6px rgba(34, 56, 101, 0.04))}.ct-newsletter-subscribe-container h3{font-size:20px}.ct-newsletter-subscribe-container>*{text-align:center;margin-inline:auto}@media(min-width: 690px){.ct-newsletter-subscribe-container>*{width:80%}}.ct-newsletter-subscribe-container>*:first-child{margin-top:20px}.ct-newsletter-subscribe-container>*:last-child{margin-bottom:20px}.ct-newsletter-subscribe-block form .wp-element-button{border:none;box-sizing:border-box}.ct-newsletter-subscribe-block .gdpr-confirm-policy{pointer-events:none}.ct-newsletter-subscribe-block .gdpr-confirm-policy label{font-size:13px}

View File

@ -0,0 +1 @@
!function(){var e,t,n={427:function(e,t,n){n.p=blocksy_ext_newsletter_subscribe_localization.public_url},313:function(e){"use strict";e.exports=window.React},381:function(e){"use strict";e.exports=window.wp.element},652:function(e){"use strict";e.exports=window.wp.i18n}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return n[e](i,i.exports,o),i.exports}o.m=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.d=function(e,t){for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.f={},o.e=function(e){return Promise.all(Object.keys(o.f).reduce((function(t,n){return o.f[n](e,t),t}),[]))},o.u=function(e){return e+"."+{260:"08e21e7588d65a504adc",564:"64a07c0cc89e5f236217"}[e]+".js"},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e={},t="blocksy-companion:",o.l=function(n,r,i,c){if(e[n])e[n].push(r);else{var u,a;if(void 0!==i)for(var l=document.getElementsByTagName("script"),s=0;s<l.length;s++){var f=l[s];if(f.getAttribute("src")==n||f.getAttribute("data-webpack")==t+i){u=f;break}}u||(a=!0,(u=document.createElement("script")).charset="utf-8",u.timeout=120,o.nc&&u.setAttribute("nonce",o.nc),u.setAttribute("data-webpack",t+i),u.src=n),e[n]=[r];var d=function(t,r){u.onerror=u.onload=null,clearTimeout(p);var o=e[n];if(delete e[n],u.parentNode&&u.parentNode.removeChild(u),o&&o.forEach((function(e){return e(r)})),t)return t(r)},p=setTimeout(d.bind(null,void 0,{type:"timeout",target:u}),12e4);u.onerror=d.bind(null,u.onerror),u.onload=d.bind(null,u.onload),a&&document.head.appendChild(u)}},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");n.length&&(e=n[n.length-1].src)}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e}(),function(){var e={179:0};o.f.j=function(t,n){var r=o.o(e,t)?e[t]:void 0;if(0!==r)if(r)n.push(r[2]);else{var i=new Promise((function(n,o){r=e[t]=[n,o]}));n.push(r[2]=i);var c=o.p+o.u(t),u=new Error;o.l(c,(function(n){if(o.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var i=n&&("load"===n.type?"missing":n.type),c=n&&n.target&&n.target.src;u.message="Loading chunk "+t+" failed.\n("+i+": "+c+")",u.name="ChunkLoadError",u.type=i,u.request=c,r[1](u)}}),"chunk-"+t,t)}};var t=function(t,n){var r,i,[c,u,a]=n,l=0;if(c.some((function(t){return 0!==e[t]}))){for(r in u)o.o(u,r)&&(o.m[r]=u[r]);if(a)a(o)}for(t&&t(n);l<c.length;l++)i=c[l],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},n=globalThis.blocksyNewsletterSubscribeExtJsonp=globalThis.blocksyNewsletterSubscribeExtJsonp||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))}(),function(){"use strict";o(427);var e=o(381),t=o(652),n=o(313),r=(0,n.lazy)((function(){return Promise.all([o.e(260),o.e(564)]).then(o.bind(o,564))})),i=function(o){return(0,e.createElement)("div",null,(0,e.createElement)(n.Suspense,{fallback:(0,e.createElement)("div",{className:"ct-select-input"},(0,e.createElement)("input",{disabled:!0,placeholder:(0,t.__)("Loading...","blocksy-companion")}))},(0,e.createElement)(r,o)))},c=window.ctEvents,u=o.n(c);document.addEventListener("DOMContentLoaded",(function(){return u().on("blocksy:options:register",(function(e){e["blocksy-newsletter-subscribe"]=i}))}))}()}();

View File

@ -0,0 +1 @@
!function(){"use strict";var e={n:function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,{a:r}),r},d:function(t,r){for(var s in r)e.o(r,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:r[s]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t=window.blocksyCustomizerSync,r=window.ctEvents;function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function n(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}e.n(r)().on("ct:customizer:sync:collect-variable-descriptors",(function(e){e.result=n(n(n({},e.result),{},{newsletter_subscribe_title_color:{selector:".ct-newsletter-subscribe-container",variable:"theme-heading-color",type:"color:default",responsive:!0},newsletter_subscribe_content:[{selector:".ct-newsletter-subscribe-container",variable:"text-color",type:"color:default"},{selector:".ct-newsletter-subscribe-container",variable:"theme-link-hover-color",type:"color:hover"}],newsletter_subscribe_button:[{selector:".ct-newsletter-subscribe-container",variable:"theme-button-background-initial-color",type:"color:default"},{selector:".ct-newsletter-subscribe-container",variable:"theme-button-background-hover-color",type:"color:hover"}],newsletter_subscribe_input_font_color:[{selector:".ct-newsletter-subscribe-container",variable:"theme-form-text-initial-color",type:"color:default"},{selector:".ct-newsletter-subscribe-container",variable:"theme-form-text-focus-color",type:"color:focus"}],newsletter_subscribe_border_color:[{selector:".ct-newsletter-subscribe-container",variable:"theme-form-field-border-initial-color",type:"color:default"},{selector:".ct-newsletter-subscribe-container",variable:"theme-form-field-border-focus-color",type:"color:focus"}],newsletter_subscribe_input_background:[{selector:".ct-newsletter-subscribe-container",variable:"theme-form-field-background-initial-color",type:"color:default"},{selector:".ct-newsletter-subscribe-container",variable:"theme-form-field-background-focus-color",type:"color:focus"}]},(0,t.handleBackgroundOptionFor)({id:"newsletter_subscribe_container_background",selector:".ct-newsletter-subscribe-container",responsive:!0})),{},{newsletter_subscribe_container_border:{selector:".ct-newsletter-subscribe-container",variable:"newsletter-container-border",type:"border",responsive:!0,skip_none:!0},newsletter_subscribe_shadow:{selector:".ct-newsletter-subscribe-container",type:"box-shadow",variable:"theme-box-shadow",responsive:!0},newsletter_subscribe_container_spacing:{selector:".ct-newsletter-subscribe-container",type:"spacing",variable:"padding",responsive:!0},newsletter_subscribe_container_border_radius:{selector:".ct-newsletter-subscribe-container",type:"spacing",variable:"theme-border-radius",responsive:!0}})})),wp.customize("newsletter_subscribe_subscribe_visibility",(function(e){return e.bind((function(e){var r=document.querySelector(".ct-newsletter-subscribe-container");(0,t.responsiveClassesFor)("newsletter_subscribe_subscribe_visibility",r)}))})),(document.body.classList.contains("single")||document.body.classList.contains("page"))&&(0,t.watchOptionsWithPrefix)({getPrefix:function(){return""},getOptionsForPrefix:function(){return["newsletter_subscribe_button_text","newsletter_subscribe_title","newsletter_subscribe_text","newsletter_subscribe_name_label","newsletter_subscribe_mail_label"]},render:function(){if(document.body.classList.contains("single")||document.body.classList.contains("page")){var e=document.querySelector(".ct-newsletter-subscribe-container");e&&((0,t.responsiveClassesFor)("newsletter_subscribe_subscribe_visibility",e),e.querySelector('[name="FNAME"]')&&e.querySelector('[name="FNAME"]').setAttribute("placeholder","".concat(wp.customize("newsletter_subscribe_name_label")())),e.querySelector('[name="EMAIL"]').setAttribute("placeholder","".concat(wp.customize("newsletter_subscribe_mail_label")()," *")),e.querySelector("button").innerHTML=wp.customize("newsletter_subscribe_button_text")(),e.querySelector("h3").innerHTML=wp.customize("newsletter_subscribe_title")(),e.querySelector(".ct-newsletter-subscribe-container > p").innerHTML=wp.customize("newsletter_subscribe_text")())}}})}();

View File

@ -0,0 +1,22 @@
import { createElement, Component } from '@wordpress/element'
import { __ } from 'ct-i18n'
import { lazy, Suspense } from 'react'
const ListPickerImplementation = lazy(() =>
import('./ListPicker/Implementation')
)
const ListPicker = (props) => (
<div>
<Suspense
fallback={
<div className="ct-select-input">
<input disabled placeholder={__('Loading...', 'blocksy-companion')} />
</div>
}>
<ListPickerImplementation {...props} />
</Suspense>
</div>
)
export default ListPicker

View File

@ -0,0 +1,137 @@
import {
createElement,
Component,
useState,
useEffect,
Fragment,
} from '@wordpress/element'
import Downshift from 'downshift'
import { __ } from 'ct-i18n'
import classnames from 'classnames'
let listsCache = null
const ListPickerImplementation = ({ value, onChange }) => {
const [lists, setLists] = useState(listsCache || [])
const [isLoadingLists, setListsLoading] = useState(!listsCache)
const maybeFetchLists = async (verbose = true) => {
if (verbose) {
setListsLoading(true)
}
const body = new FormData()
body.append(
'action',
'blocksy_ext_newsletter_subscribe_get_actual_lists'
)
body.append(
'nonce',
(
window.ctDashboardLocalizations ||
window.ct_localizations ||
window.ct_customizer_localizations
).dashboard_actions_nonce
)
try {
const response = await fetch(ajaxurl, {
method: 'POST',
body,
})
if (response.status === 200) {
const body = await response.json()
if (body.success) {
if (body.data.result !== 'api_key_invalid') {
setListsLoading(false)
setLists(body.data.result)
listsCache = body.data.result
return
}
}
}
} catch (e) {}
setListsLoading(false)
}
useEffect(() => {
maybeFetchLists(!listsCache)
}, [])
return lists.length === 0 ? (
<div className="ct-select-input">
<input
disabled
placeholder={
isLoadingLists
? __('Loading...', 'blocksy-companion')
: __('Invalid API Key...', 'blocksy-companion')
}
/>
</div>
) : (
<Downshift
selectedItem={value || lists[0].id}
onChange={(selection) => onChange(selection)}
itemToString={(item) =>
item ? (lists.find(({ id }) => id === item) || {}).name : ''
}>
{({
getInputProps,
getItemProps,
getLabelProps,
getMenuProps,
isOpen,
inputValue,
highlightedIndex,
selectedItem,
openMenu,
}) => (
<div className="ct-select-input">
<input
{...getInputProps({
onFocus: () => openMenu(),
onClick: () => openMenu(),
})}
placeholder={__('Select list...', 'blocksy-companion')}
readOnly
/>
{isOpen && (
<div
{...getMenuProps({
className: 'ct-select-dropdown',
})}>
{lists.map((item, index) => (
<div
{...getItemProps({
key: item.id,
index,
item: item.id,
className: classnames(
'ct-select-dropdown-item',
{
active:
highlightedIndex === index,
selected:
selectedItem === item.id,
}
),
})}>
{item.name}
</div>
))}
</div>
)}
</div>
)}
</Downshift>
)
}
export default ListPickerImplementation

View File

@ -0,0 +1,10 @@
import './public-path'
import { createElement, Fragment, Component } from '@wordpress/element'
import ListPicker from './ListPicker'
import ctEvents from 'ct-events'
document.addEventListener('DOMContentLoaded', () =>
ctEvents.on('blocksy:options:register', (opts) => {
opts['blocksy-newsletter-subscribe'] = ListPicker
})
)

View File

@ -0,0 +1,294 @@
import { createElement } from '@wordpress/element'
import { __ } from 'ct-i18n'
import { colors } from './colors'
import {
InspectorControls,
useBlockProps,
withColors,
} from '@wordpress/block-editor'
import { PanelBody } from '@wordpress/components'
import { OptionsPanel, ColorsPanel } from 'blocksy-options'
import Preview from './Preview'
import { options } from '.'
const Edit = ({
attributes,
setAttributes,
clientId,
inputFontColor,
setInputFontColor,
inputFontColorFocus,
setInputFontColorFocus,
inputIconColor,
setInputIconColor,
inputIconColorFocus,
setInputIconColorFocus,
inputBorderColor,
setInputBorderColor,
inputBorderColorFocus,
setInputBorderColorFocus,
inputBackgroundColor,
setInputBackgroundColor,
inputBackgroundColorFocus,
setInputBackgroundColorFocus,
buttonBackgroundColor,
setButtonBackgroundColor,
buttonBackgroundColorHover,
setButtonBackgroundColorHover,
}) => {
const radius = attributes?.style?.border?.radius
const blockProps = useBlockProps({
style: {
'--theme-form-text-initial-color': inputFontColor?.color,
'--theme-form-text-focus-color': inputFontColorFocus?.color,
'--theme-form-field-border-initial-color': inputBorderColor?.color,
'--theme-form-field-border-focus-color':
inputBorderColorFocus?.color,
'--theme-form-field-background-initial-color':
inputBackgroundColor?.color,
'--theme-form-field-background-focus-color':
inputBackgroundColorFocus?.color,
...(attributes?.newsletter_subscribe_height
? {
'--theme-form-field-height': `${attributes.newsletter_subscribe_height}px`,
}
: {}),
...(radius
? {
'--theme-form-field-border-radius': `${
typeof radius === 'string'
? radius
: `${radius.topLeft} ${radius.topRight} ${radius.bottomLeft} ${radius.bottomRight}`
}`,
}
: {}),
...(attributes?.newsletter_subscribe_gap
? {
'--theme-form-field-gap': `${attributes.newsletter_subscribe_gap}px`,
}
: {}),
},
})
return (
<div {...blockProps}>
<Preview
attributes={attributes}
setAttributes={setAttributes}
buttonStyles={{
...(inputIconColor?.color
? {
'--theme-button-text-initial-color':
inputIconColor.color,
}
: {}),
...(inputIconColorFocus?.color
? {
'--theme-button-text-hover-color':
inputIconColorFocus.color,
}
: {}),
...(buttonBackgroundColor?.color
? {
'--theme-button-background-initial-color':
buttonBackgroundColor.color,
}
: {}),
...(buttonBackgroundColorHover?.color
? {
'--theme-button-background-hover-color':
buttonBackgroundColorHover.color,
}
: {}),
}}
/>
<InspectorControls>
<PanelBody>
<OptionsPanel
purpose={'gutenberg'}
onChange={(optionId, optionValue) => {
setAttributes({
[optionId]: optionValue,
})
}}
options={options}
value={attributes}
hasRevertButton={false}
/>
</PanelBody>
</InspectorControls>
<InspectorControls group="styles">
<ColorsPanel
label={__('Input Font Color', 'blocksy')}
resetAll={() => {
setInputFontColor(colors.inputFontColor)
setInputFontColorFocus(colors.inputFontColorFocus)
}}
panelId={clientId}
settings={[
{
colorValue: inputFontColor.color,
label: __('Initial', 'blocksy'),
enableAlpha: true,
onColorChange: (value) =>
setInputFontColor(
value || colors.inputFontColor
),
},
{
colorValue: inputFontColorFocus.color,
label: __('Focus', 'blocksy'),
enableAlpha: true,
onColorChange: (value) =>
setInputFontColorFocus(
value || colors.inputFontColorFocus
),
},
]}
/>
<ColorsPanel
label={__('Input Border Color', 'blocksy')}
resetAll={() => {
setInputBorderColor(colors.inputBorderColor)
setInputBorderColorFocus(colors.inputBorderColorFocus)
}}
panelId={clientId}
settings={[
{
colorValue: inputBorderColor.color,
label: __('Initial', 'blocksy'),
enableAlpha: true,
onColorChange: (value) =>
setInputBorderColor(
value || colors.inputBorderColor
),
},
{
colorValue: inputBorderColorFocus.color,
label: __('Focus', 'blocksy'),
enableAlpha: true,
onColorChange: (value) =>
setInputBorderColorFocus(
value || colors.inputBorderColorFocus
),
},
]}
/>
<ColorsPanel
label={__('Input Background Color', 'blocksy')}
resetAll={() => {
setInputBackgroundColor(colors.inputBackgroundColor)
setInputBackgroundColorFocus(
colors.inputBackgroundColorFocus
)
}}
panelId={clientId}
settings={[
{
colorValue: inputBackgroundColor.color,
label: __('Initial', 'blocksy'),
enableAlpha: true,
onColorChange: (value) =>
setInputBackgroundColor(
value || colors.inputBackgroundColor
),
},
{
colorValue: inputBackgroundColorFocus.color,
label: __('Focus', 'blocksy'),
enableAlpha: true,
onColorChange: (value) =>
setInputBackgroundColorFocus(
value || colors.inputBackgroundColorFocus
),
},
]}
/>
<ColorsPanel
label={__('Button Text Color', 'blocksy')}
resetAll={() => {
setInputIconColor(colors.inputIconColor)
setInputIconColorFocus(colors.inputIconColorFocus)
}}
panelId={clientId}
settings={[
{
colorValue: inputIconColor.color,
label: __('Initial', 'blocksy'),
enableAlpha: true,
onColorChange: (value) =>
setInputIconColor(
value || colors.inputIconColor
),
},
{
colorValue: inputIconColorFocus.color,
label: __('Hover', 'blocksy'),
enableAlpha: true,
onColorChange: (value) =>
setInputIconColorFocus(
value || colors.inputIconColorFocus
),
},
]}
/>
<ColorsPanel
label={__('Button Background Color', 'blocksy')}
resetAll={() => {
setButtonBackgroundColor(colors.buttonBackgroundColor)
setButtonBackgroundColorHover(
colors.buttonBackgroundColorHover
)
}}
panelId={clientId}
settings={[
{
colorValue: buttonBackgroundColor.color,
label: __('Initial', 'blocksy'),
enableAlpha: true,
onColorChange: (value) =>
setButtonBackgroundColor(
value || colors.buttonBackgroundColor
),
},
{
colorValue: buttonBackgroundColorHover.color,
label: __('Hover', 'blocksy'),
enableAlpha: true,
onColorChange: (value) =>
setButtonBackgroundColorHover(
value || colors.buttonBackgroundColorHover
),
},
]}
/>
</InspectorControls>
</div>
)
}
export default withColors(
{ textColor: 'color' },
{ inputFontColor: 'color' },
{ inputFontColorFocus: 'color' },
{ inputIconColor: 'color' },
{ inputIconColorFocus: 'color' },
{ inputBorderColor: 'color' },
{ inputBorderColorFocus: 'color' },
{ inputBackgroundColor: 'color' },
{ inputBackgroundColorFocus: 'color' },
{ buttonBackgroundColor: 'color' },
{ buttonBackgroundColorHover: 'color' }
)(Edit)

View File

@ -0,0 +1,98 @@
import { createElement } from '@wordpress/element'
import { RichText } from '@wordpress/block-editor'
import { __ } from 'ct-i18n'
const { has_cookies_checkbox } = window.blc_newsletter_data
const cookies_checkbox_enabled = !!parseInt(has_cookies_checkbox)
const Preview = ({ attributes, buttonStyles, setAttributes }) => {
const {
newsletter_subscribe_view_type,
newsletter_subscribe_name_label,
newsletter_subscribe_button_text,
has_newsletter_subscribe_name,
newsletter_subscribe_mail_label,
} = attributes
return (
<div className="ct-newsletter-subscribe-block">
<form
action="#"
method="post"
target="_blank"
className="ct-newsletter-subscribe-form"
{...(newsletter_subscribe_view_type !== 'inline'
? {}
: {
'data-columns':
has_newsletter_subscribe_name === 'yes' ? 3 : 2,
})}
data-provider="convertkit">
{has_newsletter_subscribe_name === 'yes' ? (
<input
type="text"
name="FNAME"
title="Name"
value={newsletter_subscribe_name_label}
onChange={(e) => {
setAttributes({
newsletter_subscribe_name_label: e.target.value,
})
}}
/>
) : null}
<input
type="email"
name="EMAIL"
title="Email"
required=""
value={newsletter_subscribe_mail_label}
onChange={(e) => {
setAttributes({
newsletter_subscribe_mail_label: e.target.value,
})
}}
/>
<RichText
className="wp-element-button"
style={{ ...buttonStyles }}
tagName="span"
value={newsletter_subscribe_button_text}
placeholder="Search"
allowedFormats={[]}
onChange={(content) =>
setAttributes({
newsletter_subscribe_button_text: content,
})
}
/>
{cookies_checkbox_enabled ? (
<p className="gdpr-confirm-policy">
<input
name="ct_has_gdprconfirm"
type="hidden"
value="yes"
/>
<input
id="gdprconfirm_newsletter-subscribe"
className="ct-checkbox"
name="gdprconfirm"
type="checkbox"
required=""
/>
<label for="gdprconfirm_newsletter-subscribe">
I accept the{' '}
<a href="/privacy-policy">Privacy Policy</a>
</label>
</p>
) : null}
<div className="ct-newsletter-subscribe-message"></div>
</form>
</div>
)
}
export default Preview

View File

@ -0,0 +1,30 @@
import { getColorsDefaults } from 'blocksy-options'
export const colors = {
inputFontColor: '',
customInputFontColor: '',
inputFontColorFocus: '',
customInputFontColorFocus: '',
inputIconColor: '',
customInputIconColor: '',
inputIconColorFocus: '',
customInputIconColorFocus: '',
inputBorderColor: '',
customInputBorderColor: '',
inputBorderColorFocus: '',
customInputBorderColorFocus: '',
inputBackgroundColor: '',
customInputBackgroundColor: '',
inputBackgroundColorFocus: '',
customInputBackgroundColorFocus: '',
buttonBackgroundColor: '',
customButtonBackgroundColor: '',
buttonBackgroundColorHover: '',
customButtonBackgroundColorHover: '',
}
export const colorsDefaults = getColorsDefaults(colors)

View File

@ -0,0 +1,73 @@
import { createElement } from '@wordpress/element'
import { __ } from 'ct-i18n'
import { registerBlockType } from '@wordpress/blocks'
import Edit from './Edit'
import { getAttributesFromOptions, getOptionsForBlock } from 'blocksy-options'
import { colorsDefaults } from './colors'
export const options = getOptionsForBlock('newsletter')
export const defaultAttributes = getAttributesFromOptions(options)
registerBlockType('blocksy/newsletter', {
apiVersion: 3,
title: __('Newsletter Controls', 'blocksy-companion'),
icon: {
src: (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
className="wc-block-editor-components-block-icon">
<path d="M19 5H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zM5 6.5h14c.3 0 .5.2.5.5v.9L12 13.6 4.5 7.9V7c0-.3.2-.5.5-.5zm14 11H5c-.3 0-.5-.2-.5-.5V9.8l7.5 5.6 7.5-5.6V17c0 .3-.2.5-.5.5z" />
</svg>
),
},
category: 'widgets',
supports: {
html: false,
multiple: false,
inserter: false,
lock: false,
__experimentalBorder: {
color: false,
radius: true,
width: false,
__experimentalSkipSerialization: true,
__experimentalDefaultControls: {
color: false,
radius: true,
width: false,
},
},
},
parent: ['blocksy/widgets-wrapper'],
attributes: { ...defaultAttributes, ...colorsDefaults },
edit: (props) => <Edit {...props} />,
save: () => <div>Blocksy: Newsletter</div>,
})
wp.blocks.registerBlockVariation('blocksy/widgets-wrapper', {
name: 'blocksy-newsletter',
title: __('Newsletter', 'blocksy-companion'),
attributes: {
heading: __('Newsletter', 'blocksy-companion'),
block: 'blocksy/newsletter',
hasDescription: true,
description:
defaultAttributes?.newsletter_subscribe_text?.default || '',
},
isActive: (attributes) => attributes.block === 'blocksy/newsletter',
icon: {
src: (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
className="wc-block-editor-components-block-icon">
<path d="M19 5H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zM5 6.5h14c.3 0 .5.2.5.5v.9L12 13.6 4.5 7.9V7c0-.3.2-.5.5-.5zm14 11H5c-.3 0-.5-.2-.5-.5V9.8l7.5 5.6 7.5-5.6V17c0 .3-.2.5-.5.5z" />
</svg>
),
},
})

View File

@ -0,0 +1 @@
__webpack_public_path__ = blocksy_ext_newsletter_subscribe_localization.public_url

View File

@ -0,0 +1,79 @@
import {
responsiveClassesFor,
watchOptionsWithPrefix,
} from 'blocksy-customizer-sync'
import './variables'
wp.customize('newsletter_subscribe_subscribe_visibility', (val) =>
val.bind((to) => {
const block = document.querySelector('.ct-newsletter-subscribe-container')
responsiveClassesFor('newsletter_subscribe_subscribe_visibility', block)
})
)
if (
document.body.classList.contains('single') ||
document.body.classList.contains('page')
) {
watchOptionsWithPrefix({
getPrefix: () => '',
getOptionsForPrefix: () => [
'newsletter_subscribe_button_text',
'newsletter_subscribe_title',
'newsletter_subscribe_text',
'newsletter_subscribe_name_label',
'newsletter_subscribe_mail_label',
],
render: () => {
if (
!document.body.classList.contains('single') &&
!document.body.classList.contains('page')
) {
return
}
const block = document.querySelector(
'.ct-newsletter-subscribe-container'
)
if (!block) {
return
}
responsiveClassesFor(
'newsletter_subscribe_subscribe_visibility',
block
)
if (block.querySelector('[name="FNAME"]')) {
block
.querySelector('[name="FNAME"]')
.setAttribute(
'placeholder',
`${wp.customize('newsletter_subscribe_name_label')()}`
)
}
block
.querySelector('[name="EMAIL"]')
.setAttribute(
'placeholder',
`${wp.customize('newsletter_subscribe_mail_label')()} *`
)
block.querySelector('button').innerHTML = wp.customize(
'newsletter_subscribe_button_text'
)()
block.querySelector('h3').innerHTML = wp.customize(
'newsletter_subscribe_title'
)()
block.querySelector(
'.ct-newsletter-subscribe-container > p'
).innerHTML = wp.customize('newsletter_subscribe_text')()
},
})
}

View File

@ -0,0 +1,122 @@
import { handleBackgroundOptionFor } from 'blocksy-customizer-sync'
import ctEvents from 'ct-events'
ctEvents.on(
'ct:customizer:sync:collect-variable-descriptors',
(allVariables) => {
allVariables.result = {
...allVariables.result,
newsletter_subscribe_title_color: {
selector: '.ct-newsletter-subscribe-container',
variable: 'theme-heading-color',
type: 'color:default',
responsive: true,
},
newsletter_subscribe_content: [
{
selector: '.ct-newsletter-subscribe-container',
variable: 'text-color',
type: 'color:default',
},
{
selector: '.ct-newsletter-subscribe-container',
variable: 'theme-link-hover-color',
type: 'color:hover',
},
],
newsletter_subscribe_button: [
{
selector: '.ct-newsletter-subscribe-container',
variable: 'theme-button-background-initial-color',
type: 'color:default',
},
{
selector: '.ct-newsletter-subscribe-container',
variable: 'theme-button-background-hover-color',
type: 'color:hover',
},
],
newsletter_subscribe_input_font_color: [
{
selector: '.ct-newsletter-subscribe-container',
variable: 'theme-form-text-initial-color',
type: 'color:default',
},
{
selector: '.ct-newsletter-subscribe-container',
variable: 'theme-form-text-focus-color',
type: 'color:focus',
},
],
newsletter_subscribe_border_color: [
{
selector: '.ct-newsletter-subscribe-container',
variable: 'theme-form-field-border-initial-color',
type: 'color:default',
},
{
selector: '.ct-newsletter-subscribe-container',
variable: 'theme-form-field-border-focus-color',
type: 'color:focus',
},
],
newsletter_subscribe_input_background: [
{
selector: '.ct-newsletter-subscribe-container',
variable: 'theme-form-field-background-initial-color',
type: 'color:default',
},
{
selector: '.ct-newsletter-subscribe-container',
variable: 'theme-form-field-background-focus-color',
type: 'color:focus',
},
],
...handleBackgroundOptionFor({
id: 'newsletter_subscribe_container_background',
selector: '.ct-newsletter-subscribe-container',
responsive: true,
}),
newsletter_subscribe_container_border: {
selector: '.ct-newsletter-subscribe-container',
variable: 'newsletter-container-border',
type: 'border',
responsive: true,
skip_none: true,
},
newsletter_subscribe_shadow: {
selector: '.ct-newsletter-subscribe-container',
type: 'box-shadow',
variable: 'theme-box-shadow',
responsive: true,
},
newsletter_subscribe_container_spacing: {
selector: '.ct-newsletter-subscribe-container',
type: 'spacing',
variable: 'padding',
responsive: true,
},
newsletter_subscribe_container_border_radius: {
selector: '.ct-newsletter-subscribe-container',
type: 'spacing',
variable: 'theme-border-radius',
responsive: true,
},
}
}
)

View File

@ -0,0 +1,58 @@
@import "../../static/sass/main.scss";
.ct-newsletter-subscribe-block {
form {
// input[type="text"],
// input[type="email"] {
// height: var(--theme-form-field-height, 40px);
// font-size: var(--theme-form-font-size, 16px);
// color: var(--theme-form-text-initial-color, var(--theme-text-color));
// padding: var(--has-classic-forms, var(--theme-form-field-padding, 0 12px));
// margin-inline: 0;
// border-width: var(--theme-form-field-border-width, 1px);
// border-style: var(--theme-form-field-border-style, solid);
// border-color: var(--theme-form-field-border-initial-color);
// border-radius: var(--has-classic-forms, var(--theme-form-field-border-radius, 3px));
// background-color: var(--has-classic-forms, var(--theme-form-field-background-initial-color));
// &::placeholder {
// opacity: 0.6;
// color: inherit;
// }
// &:focus {
// outline: none;
// box-shadow: none;
// color: var(--theme-form-text-focus-color, var(--theme-text-color));
// border-color: var(--theme-form-field-border-focus-color);
// background-color: var(--has-classic-forms, var(--theme-form-field-background-focus-color));
// }
// }
// input[type="checkbox"] {
// margin: 0;
// margin-inline-end: 0.7em;
// box-shadow: none;
// background: transparent;
// border-width: var(--form-selection-control-border-width, var(--theme-form-field-border-width, 1px));
// border-style: solid;
// border-color: var(--theme-form-selection-field-initial-color);
// border-radius: var(--theme-form-checkbox-border-radius, 3px);
// }
.wp-element-button {
border: none;
box-sizing: border-box;
}
}
.gdpr-confirm-policy {
pointer-events: none;
label {
font-size: 13px;
}
}
}

View File

@ -0,0 +1,14 @@
<?php
$autoload = [
'Provider' => 'includes/provider.php',
'MailchimpProvider' => 'providers/mailchimp.php',
'BrevoProvider' => 'providers/brevo.php',
'CampaignMonitorProvider' => 'providers/campaign-monitor.php',
'MailerliteClassicProvider' => 'providers/mailerlite-classic.php',
'MailerliteNewProvider' => 'providers/mailerlite-new.php',
'ConvertKitProvider' => 'providers/convertkit.php',
'DemoProvider' => 'providers/demo.php'
];

View File

@ -0,0 +1,12 @@
<?php
$config = [
// translators: This is a brand name. Preferably to not be translated
'name' => _x('Newsletter Subscribe', 'Extension Brand Name', 'blocksy-companion'),
'description' => __('Easily capture new leads for your newsletter with the help of a widget, shortcode or even a block inserted on your pages or posts.', 'blocksy-companion'),
'documentation' => 'https://creativethemes.com/blocksy/docs/extensions/newsletter-subscribe/',
'video' => 'https://creativethemes.com/blocksy/video-tutorials/shorts/newsletter-everywhere/',
'customize' => admin_url('customize.php?ct_autofocus=single_blog_posts:newsletter_subscribe_single_post_enabled'),
'icon' => '<svg width="16" height="16" viewBox="0 0 16 16"><path d="M13.8 1.5H2.2C1 1.5 0 2.4 0 3.6v8.7c0 1.2 1 2.2 2.2 2.2h11.6c1.2 0 2.2-1 2.2-2.2V3.6c0-1.2-1-2.1-2.2-2.1zm-.2 3.9L10.7 8 9.6 9c-1 .6-2.2.6-3.2 0L5.3 8 2.4 5.4c-.3-.3-.3-.7 0-1 .3-.3.7-.3 1 0L7 7.6c.6.5 1.4.5 2 0l3.6-3.3c.3-.3.8-.2 1 0 .3.4.3.8 0 1.1z"/></svg>',
];

View File

@ -0,0 +1,124 @@
<?php
/**
* Newsletter Subscribe widget
*
* @copyright 2019-present Creative Themes
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @package Blocksy
*/
$options = [
'newsletter_subscribe_text' => [
'label' => __('Text', 'blocksy-companion'),
'type' => 'hidden',
'value' => __(
'Enter your email address below and subscribe to our newsletter',
'blocksy-companion'
),
'desc' => __(
'You can add here some arbitrary HTML code.',
'blocksy-companion'
),
'disableRevertButton' => true,
'setting' => ['transport' => 'postMessage'],
'mediaButtons' => false,
'tinymce' => [
'toolbar1' => 'bold,italic,link,undo,redo',
],
],
'newsletter_subscribe_list_id_source' => [
'type' => 'ct-radio',
'label' => __('List Source', 'blocksy-companion'),
'value' => 'default',
'view' => 'radio',
'inline' => true,
'disableRevertButton' => true,
'choices' => [
'default' => __('Default', 'blocksy-companion'),
'custom' => __('Custom', 'blocksy-companion'),
],
],
blocksy_rand_md5() => [
'type' => 'ct-condition',
'condition' => ['newsletter_subscribe_list_id_source' => 'custom'],
'options' => [
'newsletter_subscribe_list_id' => [
'label' => __('List ID', 'blocksy-companion'),
'type' => 'blocksy-newsletter-subscribe',
'value' => '',
'disableRevertButton' => true,
],
],
],
'newsletter_subscribe_view_type' => [
'type' => 'ct-radio',
'label' => __('Form Style', 'blocksy-companion'),
'value' => 'inline',
'view' => 'radio',
'inline' => true,
'divider' => 'top:full',
'disableRevertButton' => true,
'choices' => [
'inline' => __('Inline', 'blocksy-companion'),
'stacked' => __('Stacked', 'blocksy-companion'),
],
],
'newsletter_subscribe_height' => [
'label' => __( 'Input Height', 'blocksy' ),
'type' => 'ct-slider',
'min' => 40,
'max' => 80,
'value' => '',
'responsive' => false,
'divider' => 'top:full',
'setting' => [ 'transport' => 'postMessage' ],
],
'newsletter_subscribe_gap' => [
'label' => __( 'Fields Gap', 'blocksy' ),
'type' => 'ct-slider',
'min' => 0,
'max' => 50,
'value' => '',
'responsive' => false,
'setting' => [ 'transport' => 'postMessage' ],
],
'has_newsletter_subscribe_name' => [
'type' => 'ct-switch',
'label' => __('Name Field', 'blocksy-companion'),
'value' => 'no',
'divider' => 'top:full',
'disableRevertButton' => true,
],
blocksy_rand_md5() => [
'type' => 'ct-condition',
'condition' => ['has_newsletter_subscribe_name' => 'yes'],
'options' => [
'newsletter_subscribe_name_label' => [
'type' => 'hidden',
'label' => __('Name Label', 'blocksy-companion'),
'value' => __('Your name', 'blocksy-companion'),
],
],
],
'newsletter_subscribe_mail_label' => [
'type' => 'hidden',
'label' => __('Mail Label', 'blocksy-companion'),
'value' => __('Your email *', 'blocksy-companion'),
],
'newsletter_subscribe_button_text' => [
'type' => 'hidden',
'label' => __('Button Label', 'blocksy-companion'),
'value' => __('Subscribe', 'blocksy-companion'),
],
];

View File

@ -0,0 +1,254 @@
<?php
/**
* Newsletter Subscribe widget
*
* @copyright 2019-present Creative Themes
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @package Blocksy
*/
// Widget title
$title = blocksy_default_akg(
'title',
$atts,
__('Newsletter', 'blocksy-companion')
);
// Button text
$button_text = blocksy_default_akg(
'newsletter_subscribe_button_text',
$atts,
__('Subscribe', 'blocksy-companion')
);
$style = '';
$newsletter_subscribe_height = blocksy_default_akg('newsletter_subscribe_height', $atts, '');
$newsletter_subscribe_gap = blocksy_default_akg('newsletter_subscribe_gap', $atts, '');
if (! empty($newsletter_subscribe_height)) {
$style .= '--theme-form-field-height:' . $newsletter_subscribe_height . 'px;';
}
if (! empty($newsletter_subscribe_gap)) {
$style .= '--theme-form-field-gap:' . $newsletter_subscribe_gap . 'px;';
}
if (isset($atts['style']['border']['radius'])) {
if (
gettype($atts['style']['border']['radius']) === 'string'
&&
! empty(gettype($atts['style']['border']['radius']))
) {
$style .= '--theme-form-field-border-radius:' . $atts['style']['border']['radius'] . ';';
} else if (
gettype($atts['style']['border']['radius']) === 'array'
&&
! empty($atts['style']['border']['radius'])
) {
$style .= '--theme-form-field-border-radius:' . $atts['style']['border']['radius']['topLeft'] . $atts['style']['border']['radius']['topRight'] . $atts['style']['border']['radius']['bottomLeft'] . $atts['style']['border']['radius']['bottomRight'] . ';';
}
unset($atts['style']['border']);
}
$colors = [
'--theme-form-text-initial-color' => blocksy_default_akg('customInputFontColor', $atts, ''),
'--theme-form-text-focus-color' => blocksy_default_akg('customInputFontFocusColor', $atts, ''),
'--theme-form-field-border-initial-color' => blocksy_default_akg('customInputBorderColor', $atts, ''),
'--theme-form-field-border-focus-color' => blocksy_default_akg('customInputBorderColorFocus', $atts, ''),
'--theme-form-field-background-initial-color' => blocksy_default_akg('customInputBackgroundColor', $atts, ''),
'--theme-form-field-background-focus-color' => blocksy_default_akg('customInputBackgroundColorFocus', $atts, ''),
];
if (isset($atts['inputFontColor'])) {
$var = $atts['inputFontColor'];
$colors['--theme-form-text-initial-color'] = "var(--wp--preset--color--$var)";
}
if (isset($atts['inputFontColorFocus'])) {
$var = $atts['inputFontColorFocus'];
$colors['--theme-form-text-focus-color'] = "var(--wp--preset--color--$var)";
}
if (isset($atts['inputBorderColor'])) {
$var = $atts['inputBorderColor'];
$colors['--theme-form-field-border-initial-color'] = "var(--wp--preset--color--$var)";
}
if (isset($atts['inputBorderColorFocus'])) {
$var = $atts['inputBorderColorFocus'];
$colors['--theme-form-field-border-focus-color'] = "var(--wp--preset--color--$var)";
}
if (isset($atts['inputBackgroundColor'])) {
$var = $atts['inputBackgroundColor'];
$colors['--theme-form-field-background-initial-color'] = "var(--wp--preset--color--$var)";
}
if (isset($atts['inputBackgroundColorFocus'])) {
$var = $atts['inputBackgroundColorFocus'];
$colors['--theme-form-field-background-focus-color'] = "var(--wp--preset--color--$var)";
}
$colors_css = '';
foreach ($colors as $key => $value) {
if (empty($value)) {
continue;
}
$colors_css .= $key . ':' . $value . ';';
}
// Form name
$has_name =
blocksy_default_akg('has_newsletter_subscribe_name', $atts, 'no') === 'yes';
$list_id = null;
if (
blocksy_default_akg(
'newsletter_subscribe_list_id_source',
$atts,
'default'
) === 'custom'
) {
$list_id = blocksy_default_akg('newsletter_subscribe_list_id', $atts, '');
}
$manager = \Blocksy\Extensions\NewsletterSubscribe\Provider::get_for_settings();
// Button value
$provider_data = $manager->get_form_url_and_gdpr_for($list_id);
if (!$provider_data) {
return;
}
if ($provider_data['provider'] === 'mailerlite') {
$settings = $manager->get_settings();
$provider_data['provider'] .= ':' . $settings['list_id'];
}
$form_url = $provider_data['form_url'];
$has_gdpr_fields = $provider_data['has_gdpr_fields'];
$name_label = blocksy_default_akg(
'newsletter_subscribe_name_label',
$atts,
__('Your name', 'blocksy-companion')
);
$email_label = blocksy_default_akg(
'newsletter_subscribe_mail_label',
$atts,
__('Your email *', 'blocksy-companion')
);
$view_type = blocksy_default_akg(
'newsletter_subscribe_view_type',
$atts,
'inline'
);
$fields_number = '2';
if ($has_name) {
$fields_number = '3';
}
echo '<div class="ct-newsletter-subscribe-block">';
$form_attrs = [
'action' => esc_attr($form_url),
'method' => 'post',
'target' => '_blank',
'class' => 'ct-newsletter-subscribe-form',
'data-provider' => $provider_data['provider'],
];
if ($view_type === 'inline') {
$form_attrs['data-columns'] = $fields_number;
}
$skip_submit_output = '';
if ($has_gdpr_fields) {
$form_attrs['data-skip-submit'] = '';
}
if (! empty($style) || ! empty($colors_css)) {
$form_attrs['style'] = $style . $colors_css;
}
$button_colors = [];
$button_colors = array_merge(
$button_colors,
[
'--theme-button-text-initial-color' => blocksy_default_akg('customInputIconColor', $atts, ''),
'--theme-button-text-hover-color' => blocksy_default_akg('customInputIconColorFocus', $atts, ''),
'--theme-button-background-initial-color' => blocksy_default_akg('customButtonBackgroundColor', $atts, ''),
'--theme-button-background-hover-color' => blocksy_default_akg('customButtonBackgroundColorHover', $atts, ''),
]
);
if (isset($atts['inputIconColor'])) {
$var = $atts['inputIconColor'];
$button_colors['--theme-button-text-initial-color'] = "var(--wp--preset--color--$var)";
}
if (isset($atts['inputIconColorFocus'])) {
$var = $atts['inputIconColorFocus'];
$button_colors['--theme-button-text-hover-color'] = "var(--wp--preset--color--$var)";
}
if (isset($atts['buttonBackgroundColor'])) {
$var = $atts['buttonBackgroundColor'];
$button_colors['--theme-button-background-initial-color'] = "var(--wp--preset--color--$var)";
}
if (isset($atts['buttonBackgroundColorHover'])) {
$var = $atts['buttonBackgroundColorHover'];
$button_colors['--theme-button-background-hover-color'] = "var(--wp--preset--color--$var)";
}
$button_colors_css = '';
foreach ($button_colors as $key => $value) {
if (empty($value)) {
continue;
}
$button_colors_css .= $key . ':' . $value . ';';
}
?>
<form <?php echo blocksy_attr_to_html($form_attrs); ?>>
<?php if ($has_name) { ?>
<input
type="text"
name="FNAME"
placeholder="<?php esc_attr_e($name_label, 'blocksy-companion'); ?>"
title="<?php echo __('Name', 'blocksy-companion'); ?>">
<?php } ?>
<input
type="email"
name="EMAIL"
placeholder="<?php esc_attr_e($email_label, 'blocksy-companion'); ?>"
title="<?php echo __('Email', 'blocksy-companion'); ?>"
required>
<button class="wp-element-button" <?php echo ! empty($button_colors_css) ? 'style="' . esc_attr($button_colors_css) . '"' : '' ?>>
<?php echo esc_html($button_text); ?>
</button>
<?php
if (function_exists('blocksy_ext_cookies_checkbox')) {
echo blocksy_ext_cookies_checkbox('newsletter-subscribe');
}
?>
<div class="ct-newsletter-subscribe-message"></div>
</form>
</div>

View File

@ -0,0 +1,411 @@
<?php
$options = [
'label' => __( 'Subscribe Form', 'blocksy-companion' ),
'type' => 'ct-panel',
'switch' => true,
'value' => 'yes',
'sync' => blocksy_sync_single_post_container(),
'inner-options' => [
blocksy_rand_md5() => [
'title' => __( 'General', 'blocksy-companion' ),
'type' => 'tab',
'options' => [
'newsletter_subscribe_title' => [
'type' => 'text',
'label' => __( 'Title', 'blocksy-companion' ),
'design' => 'block',
'value' => __( 'Newsletter Updates', 'blocksy-companion' ),
'disableRevertButton' => true,
'setting' => [ 'transport' => 'postMessage' ],
],
'newsletter_subscribe_text' => [
'label' => __( 'Description', 'blocksy-companion' ),
'type' => 'textarea',
'value' => __( 'Enter your email address below and subscribe to our newsletter', 'blocksy-companion' ),
'design' => 'block',
'disableRevertButton' => true,
'setting' => [ 'transport' => 'postMessage' ],
],
blocksy_rand_md5() => [
'type' => 'ct-divider',
'attr' => [ 'data-type' => 'small' ],
],
'newsletter_subscribe_list_id_source' => [
'type' => 'ct-radio',
'label' => __( 'List Source', 'blocksy-companion' ),
'value' => 'default',
'view' => 'radio',
'inline' => true,
'design' => 'inline',
'disableRevertButton' => true,
'choices' => [
'default' => __('Default', 'blocksy-companion'),
'custom' => __('Custom', 'blocksy-companion'),
],
'setting' => [ 'transport' => 'postMessage' ],
],
blocksy_rand_md5() => [
'type' => 'ct-condition',
'condition' => [ 'newsletter_subscribe_list_id_source' => 'custom' ],
'options' => [
'newsletter_subscribe_list_id' => [
'label' => __( 'List ID', 'blocksy-companion' ),
'type' => 'blocksy-newsletter-subscribe',
'value' => '',
'design' => 'inline',
'disableRevertButton' => true,
'setting' => [ 'transport' => 'postMessage' ],
],
],
],
blocksy_rand_md5() => [
'type' => 'ct-divider',
'attr' => [ 'data-type' => 'small' ],
],
'has_newsletter_subscribe_name' => [
'type' => 'ct-switch',
'label' => __( 'Name Field', 'blocksy-companion' ),
'value' => 'no',
'disableRevertButton' => true,
'sync' => blocksy_sync_single_post_container([
'loader_selector' => '.ct-newsletter-subscribe-container'
]),
],
blocksy_rand_md5() => [
'type' => 'ct-condition',
'condition' => [ 'has_newsletter_subscribe_name' => 'yes' ],
'options' => [
'newsletter_subscribe_name_label' => [
'type' => 'text',
'label' => __( 'Name Label', 'blocksy-companion' ),
'design' => 'inline',
'value' => __( 'Your name', 'blocksy-companion' ),
'disableRevertButton' => true,
'setting' => [ 'transport' => 'postMessage' ],
],
],
],
'newsletter_subscribe_mail_label' => [
'type' => 'text',
'label' => __( 'Mail Label', 'blocksy-companion' ),
'design' => 'inline',
'value' => __( 'Your email', 'blocksy-companion' ),
'disableRevertButton' => true,
'setting' => [ 'transport' => 'postMessage' ],
],
'newsletter_subscribe_button_text' => [
'type' => 'text',
'label' => __( 'Button Label', 'blocksy-companion' ),
'design' => 'inline',
'value' => __( 'Subscribe', 'blocksy-companion' ),
'disableRevertButton' => true,
'setting' => [ 'transport' => 'postMessage' ],
],
blocksy_rand_md5() => [
'type' => 'ct-divider',
],
'newsletter_subscribe_subscribe_visibility' => [
'label' => __( 'Visibility', 'blocksy-companion' ),
'type' => 'ct-visibility',
'design' => 'block',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'desktop' => true,
'tablet' => true,
'mobile' => false,
],
'choices' => blocksy_ordered_keys([
'desktop' => __( 'Desktop', 'blocksy-companion' ),
'tablet' => __( 'Tablet', 'blocksy-companion' ),
'mobile' => __( 'Mobile', 'blocksy-companion' ),
]),
],
],
],
blocksy_rand_md5() => [
'title' => __( 'Design', 'blocksy-companion' ),
'type' => 'tab',
'options' => [
'newsletter_subscribe_title_color' => [
'label' => __( 'Title Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
'inherit' => 'var(--theme-heading-color, var(--theme-heading-3-color, var(--theme-headings-color)))'
],
],
],
'newsletter_subscribe_content' => [
'label' => __( 'Text Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
'hover' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
'inherit' => 'var(--theme-text-color)'
],
[
'title' => __( 'Hover', 'blocksy-companion' ),
'id' => 'hover',
'inherit' => 'var(--theme-link-hover-color)'
],
],
],
'newsletter_subscribe_input_font_color' => [
'label' => __( 'Input Font Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
'divider' => 'top',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
'focus' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
'inherit' => 'var(--theme-form-text-initial-color, var(--theme-text-color))'
],
[
'title' => __( 'Focus', 'blocksy-companion' ),
'id' => 'focus',
'inherit' => 'var(--theme-form-text-focus-color, var(--theme-text-color))'
],
],
],
'newsletter_subscribe_border_color' => [
'label' => __( 'Input Border Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
'focus' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
'inherit' => 'var(--theme-form-field-border-initial-color)'
],
[
'title' => __( 'Focus', 'blocksy-companion' ),
'id' => 'focus',
'inherit' => 'var(--theme-form-field-border-focus-color)'
],
],
],
blocksy_rand_md5() => [
'type' => 'ct-condition',
'condition' => ['forms_type' => 'classic-forms'],
'values_source' => 'global',
'options' => [
'newsletter_subscribe_input_background' => [
'label' => __( 'Input Background Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword(),
],
'focus' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword(),
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
],
[
'title' => __( 'Focus', 'blocksy-companion' ),
'id' => 'focus',
],
],
],
],
],
'newsletter_subscribe_button' => [
'label' => __( 'Button Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => 'var(--theme-palette-color-1)',
],
'hover' => [
'color' => 'var(--theme-palette-color-2)',
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
],
[
'title' => __( 'Hover', 'blocksy-companion' ),
'id' => 'hover',
],
],
],
'newsletter_subscribe_container_background' => [
'label' => __( 'Container Background', 'blocksy-companion' ),
'type' => 'ct-background',
'design' => 'block:right',
'responsive' => true,
'divider' => 'top:full',
'sync' => 'live',
'value' => blocksy_background_default_value([
'backgroundColor' => [
'default' => [
'color' => 'var(--theme-palette-color-8)',
],
],
])
],
'newsletter_subscribe_container_border' => [
'label' => __( 'Container Border', 'blocksy-companion' ),
'type' => 'ct-border',
'sync' => 'live',
'design' => 'block',
'divider' => 'top',
'value' => [
'width' => 1,
'style' => 'none',
'color' => [
'color' => 'var(--theme-palette-color-5)',
],
],
'responsive' => true,
],
'newsletter_subscribe_shadow' => [
'label' => __( 'Container Shadow', 'blocksy-companion' ),
'type' => 'ct-box-shadow',
'responsive' => true,
'divider' => 'top',
'setting' => [ 'transport' => 'postMessage' ],
'value' => blocksy_box_shadow_value([
'enable' => true,
'h_offset' => 0,
'v_offset' => 50,
'blur' => 90,
'spread' => 0,
'inset' => false,
'color' => [
'color' => 'rgba(210, 213, 218, 0.4)',
],
])
],
'newsletter_subscribe_container_spacing' => [
'label' => __( 'Container Inner Spacing', 'blocksy-companion' ),
'type' => 'ct-spacing',
'divider' => 'top',
'setting' => [ 'transport' => 'postMessage' ],
'value' => blocksy_spacing_value([
'top' => '30px',
'left' => '30px',
'right' => '30px',
'bottom' => '30px',
]),
'responsive' => true
],
'newsletter_subscribe_container_border_radius' => [
'label' => __( 'Container Border Radius', 'blocksy-companion' ),
'type' => 'ct-spacing',
'divider' => 'top',
'setting' => [ 'transport' => 'postMessage' ],
'value' => blocksy_spacing_value(),
'responsive' => true
],
],
],
],
];

View File

@ -0,0 +1,334 @@
import {
createElement,
Component,
useEffect,
useState,
useMemo,
useReducer,
Fragment,
} from '@wordpress/element'
import classnames from 'classnames'
import { __, sprintf } from 'ct-i18n'
import ListPicker from './ListPicker'
import Overlay from '../../../../../static/js/helpers/Overlay'
import { Select } from 'blocksy-options'
import useProExtensionInFree from '../../../../../static/js/dashboard/helpers/useProExtensionInFree'
const freeProviders = ['mailchimp', 'demo']
const EditCredentials = ({ extension, onCredentialsValidated }) => {
const [provider, setProvider] = useState(extension.data.provider)
const [apiKey, setApiKey] = useState(extension.data.api_key)
const [listId, setListId] = useState(extension.data.list_id)
const [isLoading, setIsLoading] = useState(false)
const { isPro, showNotice, content } = useProExtensionInFree(extension, {
strategy: 'pro',
})
useEffect(() => {
if (
extension.data &&
!freeProviders.includes(extension.data.provider) &&
!isPro
) {
setProvider(freeProviders[0])
}
}, [])
const attemptToSaveCredentials = async () => {
const body = new FormData()
body.append('provider', provider)
body.append('api_key', apiKey)
body.append('list_id', listId)
body.append(
'action',
'blocksy_ext_newsletter_subscribe_maybe_save_credentials'
)
body.append('nonce', ctDashboardLocalizations.dashboard_actions_nonce)
setIsLoading(true)
try {
const response = await fetch(ctDashboardLocalizations.ajax_url, {
method: 'POST',
body,
})
if (response.status === 200) {
const body = await response.json()
if (body.success) {
if (body.data.result !== 'api_key_invalid') {
onCredentialsValidated()
}
}
}
} catch (e) {}
await new Promise((r) => setTimeout(() => r(), 1000))
setIsLoading(false)
}
return (
<div
className={classnames(
'ct-extension-options ct-newsletter-subscribe-options'
)}>
<h4>{__('Connect Newsletter Provider', 'blocksy-companion')}</h4>
<div
className="ct-newsletter-credentials"
data-columns={provider.indexOf('mailerlite') > -1 ? 4 : 3}>
<section>
<label>{__('Provider', 'blocksy-companion')}</label>
<Select
onChange={(copy) => {
if (!isPro && !freeProviders.includes(copy)) {
setProvider(copy)
setTimeout(() => {
setProvider(freeProviders[0])
})
showNotice()
return
}
setProvider(copy)
}}
option={{
placeholder: __(
'Pick Mailing Service',
'blocksy-companion'
),
choices: [
{
key: 'mailchimp',
value: 'Mailchimp',
},
{
key: 'mailerlite-new',
value: 'Mailerlite',
},
{
key: 'brevo',
value: 'Brevo (Sendinblue)',
},
{
key: 'campaignmonitor',
value: 'Campaign Monitor',
},
{
key: 'convertkit',
value: 'ConvertKit',
},
{
key: 'demo',
value: 'Demo',
},
],
}}
value={
provider.indexOf('mailerlite') > -1
? 'mailerlite'
: provider
}
/>
</section>
{provider.indexOf('mailerlite') > -1 && (
<section>
<label>{__('API Version', 'blocksy-companion')}</label>
<Select
onChange={(copy) => {
setProvider(
copy === 'new'
? 'mailerlite-new'
: 'mailerlite'
)
}}
option={{
placeholder: __(
'Pick Mailing Service',
'blocksy-companion'
),
choices: [
{
key: 'classic',
value: 'Classic',
},
{
key: 'new',
value: 'New',
},
],
}}
value={
provider === 'mailerlite-new'
? 'new'
: 'classic'
}
/>
</section>
)}
{(freeProviders.includes(provider) ||
ctDashboardLocalizations.plugin_data.is_pro) && (
<Fragment>
<section>
<label>{__('API Key', 'blocksy-companion')}</label>
<div className="ct-option-input">
<input
type="text"
onChange={({ target: { value } }) =>
setApiKey(value)
}
value={apiKey || ''}
/>
</div>
</section>
<section>
<label>{__('List ID', 'blocksy-companion')}</label>
<ListPicker
listId={listId}
onChange={(id) => setListId(id)}
provider={provider}
apiKey={apiKey}
/>
</section>
</Fragment>
)}
</div>
{provider === 'mailchimp' && (
<span
className="ct-option-description"
dangerouslySetInnerHTML={{
__html: sprintf(
__(
'More information on how to generate an API key for Mailchimp can be found %shere%s.',
'blocksy-companion'
),
'<a target="_blank" href="https://mailchimp.com/help/about-api-keys/">',
'</a>'
),
}}
/>
)}
{ctDashboardLocalizations.plugin_data.is_pro &&
provider.indexOf('mailerlite') > -1 && (
<span
className="ct-option-description"
dangerouslySetInnerHTML={{
__html: sprintf(
__(
'More information on how to generate an API key for Mailerlite can be found %shere%s. Please note that it is required at least one group to be created in your account for the integration to work. More info on how to create a group %shere%s.',
'blocksy-companion'
),
'<a target="_blank" href="https://www.mailerlite.com/help/where-to-find-the-mailerlite-api-key-and-documentation">',
'</a>',
'<a target="_blank" href="https://www.mailerlite.com/help/how-to-create-and-use-groups">',
'</a>'
),
}}
/>
)}
{provider.indexOf('demo') > -1 && (
<span
className="ct-option-description"
dangerouslySetInnerHTML={{
__html: __(
'This provider is used only for testing purposes. It doesnt register any real subscribers.',
'blocksy-companion'
),
}}
/>
)}
{ctDashboardLocalizations.plugin_data.is_pro &&
provider === 'brevo' && (
<span
className="ct-option-description"
dangerouslySetInnerHTML={{
__html: sprintf(
__(
'More information on how to generate an API key for Brevo can be found %shere%s.',
'blocksy-companion'
),
'<a target="_blank" href="https://help.brevo.com/hc/en-us/articles/209467485-Create-and-manage-your-API-keys">',
'</a>'
),
}}
/>
)}
{ctDashboardLocalizations.plugin_data.is_pro &&
provider === 'convertkit' && (
<span
className="ct-option-description"
dangerouslySetInnerHTML={{
__html: sprintf(
__(
'More information on how to generate an API key for ConvertKit can be found %shere%s.',
'blocksy-companion'
),
'<a target="_blank" href="https://developers.convertkit.com/#api-basics">',
'</a>'
),
}}
/>
)}
{ctDashboardLocalizations.plugin_data.is_pro &&
provider === 'campaignmonitor' && (
<span
className="ct-option-description"
dangerouslySetInnerHTML={{
__html: sprintf(
__(
'More information on how to generate an API key for Campaign Monitor can be found %shere%s.',
'blocksy-companion'
),
'<a target="_blank" href="https://help.campaignmonitor.com/api-keys">',
'</a>'
),
}}
/>
)}
<button
className="ct-button-primary"
disabled={!apiKey || !listId || isLoading}
onClick={() => attemptToSaveCredentials()}>
{isLoading
? __('Loading...', 'blocksy-companion')
: __('Save Settings', 'blocksy-companion')}
</button>
{content}
</div>
)
}
export default EditCredentials

View File

@ -0,0 +1,154 @@
import {
createElement,
Component,
useEffect,
useState,
Fragment,
} from '@wordpress/element'
import Downshift from 'downshift'
import { __ } from 'ct-i18n'
import classnames from 'classnames'
const ListPicker = ({ listId, provider, apiKey, onChange }) => {
const [lists, setLists] = useState([])
const [isLoadingLists, setListsLoading] = useState(false)
let [{ controller }, setAbortState] = useState({
controller: null,
})
const maybeFetchLists = async () => {
if (controller) {
controller.abort()
}
setListsLoading(true)
if ('AbortController' in window) {
controller = new AbortController()
setAbortState({
controller,
})
}
const body = new FormData()
body.append('api_key', apiKey)
body.append('provider', provider)
body.append(
'action',
'blocksy_ext_newsletter_subscribe_maybe_get_lists'
)
body.append('nonce', ctDashboardLocalizations.dashboard_actions_nonce)
try {
const response = await fetch(ctDashboardLocalizations.ajax_url, {
method: 'POST',
signal: controller.signal,
body,
})
if (response.status === 200) {
const body = await response.json()
if (body.success) {
if (body.data.result !== 'api_key_invalid') {
setListsLoading(false)
setLists(
body.data.result.map((list) => ({
...list,
id: list.id.toString(),
}))
)
return
}
}
}
} catch (e) {}
setLists([])
setListsLoading(false)
}
useEffect(() => {
if (!apiKey) {
setLists([])
return
}
maybeFetchLists()
}, [provider, apiKey])
return lists.length === 0 ? (
<div className={classnames('ct-select-input', 'ct-no-results')}>
<input
disabled
placeholder={
isLoadingLists ? __('Fetching...', 'blocksy-companion') : ''
}
/>
</div>
) : (
<Downshift
selectedItem={listId || ''}
onChange={(selection) => onChange(selection)}
itemToString={(item) =>
item ? (lists.find(({ id }) => id === item) || {}).name : ''
}>
{({
getInputProps,
getItemProps,
getLabelProps,
getMenuProps,
isOpen,
inputValue,
highlightedIndex,
selectedItem,
openMenu,
}) => (
<div className="ct-select-input">
<input
{...getInputProps({
onFocus: () => openMenu(),
onClick: () => openMenu(),
})}
placeholder={__('Select list...', 'blocksy-companion')}
readOnly
/>
{isOpen && (
<div
{...getMenuProps({
className: 'ct-select-dropdown',
})}>
{lists.map((item, index) => (
<div
{...getItemProps({
key: item.id,
index,
item: item.id,
className: classnames(
'ct-select-dropdown-item',
{
active:
highlightedIndex === index,
selected:
selectedItem === item.id,
}
),
})}>
{item.name}
</div>
))}
</div>
)}
</div>
)}
</Downshift>
)
}
export default ListPicker

View File

@ -0,0 +1,45 @@
import { createElement, useState, Fragment } from '@wordpress/element'
import { __ } from 'ct-i18n'
import classnames from 'classnames'
import EditCredentials from './EditCredentials'
const NewsletterSubscribe = ({ extension, onExtsSync }) => {
const toggleActivationState = async () => {
const body = new FormData()
body.append('ext', extension.name)
body.append(
'action',
extension.__object
? 'blocksy_extension_deactivate'
: 'blocksy_extension_activate'
)
body.append('nonce', ctDashboardLocalizations.dashboard_actions_nonce)
try {
await fetch(ctDashboardLocalizations.ajax_url, {
method: 'POST',
body,
})
onExtsSync()
} catch (e) {}
}
return (
<EditCredentials
extension={extension}
onCredentialsValidated={() => {
if (extension.__object) {
return
}
toggleActivationState()
}}
/>
)
}
export default NewsletterSubscribe

View File

@ -0,0 +1,27 @@
import { createElement } from '@wordpress/element'
import { addFilter } from '@wordpress/hooks'
import NewsletterSubscribe from './NewsletterSubscribe'
addFilter(
'blocksy.extensions.current_extension_content',
'blocksy',
(contentDescriptor, { extension, onExtsSync }) => {
if (extension.name !== 'newsletter-subscribe') return contentDescriptor
return {
...contentDescriptor,
...(extension.data.api_key
? {}
: {
activationStrategy: 'from-custom-content',
}),
content: (
<NewsletterSubscribe
extension={extension}
onExtsSync={onExtsSync}
/>
),
}
}
)

View File

@ -0,0 +1,49 @@
.ct-newsletter-subscribe-options {
padding-top: 40px;
border-top: 1px dashed #eee;
.ct-newsletter-credentials {
display: grid;
grid-column-gap: 10px;
&[data-columns="3"] {
grid-template-columns: repeat(3, 1fr);
}
&[data-columns="4"] {
grid-template-columns: repeat(4, 1fr);
}
section {
display: flex;
flex-direction: column;
min-width: 0;
}
label {
display: block;
font-size: 12px;
font-weight: 500;
letter-spacing: 0.1px;
margin-bottom: 10px;
}
input {
--input-height: 35px;
}
.ct-select-input {
&.ct-no-results:after {
display: none;
}
}
}
.ct-option-description {
display: block;
opacity: 0.8;
color: inherit;
margin-bottom: 30px;
}
}

View File

@ -0,0 +1,355 @@
<?php
require_once dirname(__FILE__) . '/helpers.php';
class BlocksyExtensionNewsletterSubscribe {
public function __construct() {
add_action('enqueue_block_editor_assets', function () {
if (! function_exists('get_plugin_data')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$data = get_plugin_data(BLOCKSY__FILE__);
wp_enqueue_script(
'blocksy-ext-newsletter-subscribe-admin-scripts',
BLOCKSY_URL .
'framework/extensions/newsletter-subscribe/admin-static/bundle/main.js',
['ct-options-scripts'],
$data['Version']
);
wp_localize_script(
'blocksy-ext-newsletter-subscribe-admin-scripts',
'blocksy_ext_newsletter_subscribe_localization',
[
'public_url' =>
BLOCKSY_URL .
'framework/extensions/newsletter-subscribe/admin-static/bundle/',
]
);
});
add_action('customize_controls_enqueue_scripts', function () {
if (! function_exists('get_plugin_data')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$data = get_plugin_data(BLOCKSY__FILE__);
wp_register_script(
'blocksy-ext-newsletter-subscribe-admin-scripts',
BLOCKSY_URL . 'framework/extensions/newsletter-subscribe/admin-static/bundle/main.js',
[],
$data['Version'],
true
);
wp_localize_script(
'blocksy-ext-newsletter-subscribe-admin-scripts',
'blocksy_ext_newsletter_subscribe_localization',
[
'public_url' => BLOCKSY_URL . 'framework/extensions/newsletter-subscribe/admin-static/bundle/',
]
);
});
add_filter(
'render_block',
function ($block_content, $block) {
if ($block['blockName'] === 'blocksy/newsletter') {
wp_enqueue_style('blocksy-block-newsletter-styles');
}
return $block_content;
},
10,
2
);
add_action(
'wp_enqueue_scripts',
function () {
if (! function_exists('get_plugin_data')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$data = get_plugin_data(BLOCKSY__FILE__);
if (is_admin()) {
return;
}
wp_register_style(
'blocksy-block-newsletter-styles',
BLOCKSY_URL . 'framework/extensions/newsletter-subscribe/static/bundle/main.min.css',
['ct-main-styles'],
$data['Version']
);
$obj = get_queried_object();
if (
$obj
&&
! empty($obj->post_content)
&&
has_shortcode(
$obj->post_content,
'blocksy_newsletter_subscribe'
)
) {
wp_enqueue_style('blocksy-block-newsletter-styles');
}
if (
blocksy_get_theme_mod('newsletter_subscribe_single_post_enabled', 'yes') === 'yes'
&&
get_post_type() === 'post'
) {
wp_enqueue_style('blocksy-block-newsletter-styles');
}
},
45
);
add_filter('blocksy:frontend:dynamic-js-chunks', function ($chunks) {
$chunks[] = [
'id' => 'blocksy_ext_newsletter_subscribe',
'selector' => implode(', ', [
'.ct-newsletter-subscribe-form:not([data-skip-submit])',
]),
'url' => blocksy_cdn_url(
BLOCKSY_URL .
'framework/extensions/newsletter-subscribe/static/bundle/main.js'
),
'trigger' => 'submit',
];
return $chunks;
});
add_filter(
'blocksy_single_posts_end_customizer_options',
function ($opts, $prefix) {
if ($prefix !== 'single_blog_post') {
return $opts;
}
$opts['newsletter_subscribe_single_post_enabled'] = blocksy_get_options(
dirname(__FILE__) . '/customizer.php',
[],
false
);
return $opts;
},
10,
2
);
add_filter(
'blocksy_extensions_metabox_post:elements:before',
function ($opts) {
$opts['disable_subscribe_form'] = [
'label' => __(
'Disable Subscribe Form',
'blocksy-companion'
),
'type' => 'ct-switch',
'value' => 'no',
];
return $opts;
},
5
);
add_action('customize_preview_init', function () {
if (!function_exists('get_plugin_data')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$data = get_plugin_data(BLOCKSY__FILE__);
wp_enqueue_script(
'blocksy-newsletter-subscribe-customizer-sync',
BLOCKSY_URL .
'framework/extensions/newsletter-subscribe/admin-static/bundle/sync.js',
['customize-preview', 'ct-customizer'],
$data['Version'],
true
);
});
add_action('wp_ajax_blc_newsletter_subscribe_process_ajax_subscribe', [
$this,
'newsletter_subscribe_process_ajax_subscribe',
]);
add_action(
'wp_ajax_nopriv_blc_newsletter_subscribe_process_ajax_subscribe',
[$this, 'newsletter_subscribe_process_ajax_subscribe']
);
add_shortcode('blocksy_newsletter_subscribe', function (
$args,
$content
) {
$args = wp_parse_args($args, [
'has_title' => false,
'has_description' => false,
'button_text' => __('Subscribe', 'blocksy-companion'),
// no | yes
'has_name' => 'no',
'name_label' => __('Your name', 'blocksy-companion'),
'email_label' => __('Your email', 'blocksy-companion'),
'list_id' => '',
'class' => '',
]);
$args['class'] =
'ct-newsletter-subscribe-shortcode ' . $args['class'];
return blc_ext_newsletter_subscribe_output_form($args);
});
add_action(
'blocksy:global-dynamic-css:enqueue',
'BlocksyExtensionNewsletterSubscribe::add_global_styles',
10,
3
);
add_action('init', [$this, 'blocksy_newsletter_block']);
add_action('enqueue_block_editor_assets', [$this, 'enqueue_admin']);
add_filter('blocksy:gutenberg-blocks-data', function ($data) {
$options_file =
BLOCKSY_PATH .
'framework/extensions/newsletter-subscribe/ct-newsletter-subscribe/options.php';
$options = blocksy_akg(
'options',
blocksy_get_variables_from_file(
$options_file,
['options' => []]
)
);
$data['newsletter'] = $options;
return $data;
});
}
public function render_block($attributes) {
$file_path = BLOCKSY_PATH . 'framework/extensions/newsletter-subscribe/ct-newsletter-subscribe/view.php';
if (! file_exists($file_path)) {
return '<p>Default widget view. Please create a <i>view.php</i> file.</p>';
}
return blocksy_render_view($file_path, [
'atts' => $attributes,
]);
}
public function blocksy_newsletter_block() {
register_block_type('blocksy/newsletter', [
'render_callback' => [$this, 'render_block'],
]);
}
public function enqueue_admin() {
$deps = [
'wp-blocks',
'wp-element',
'wp-block-editor',
];
global $wp_customize;
if ($wp_customize) {
$deps[] = 'ct-customizer-controls';
} else {
$deps[] = 'ct-options-scripts';
}
wp_enqueue_script(
'blocksy/newsletter',
BLOCKSY_URL .
'framework/extensions/newsletter-subscribe/admin-static/bundle/newsletter-block.js',
$deps
);
$data = [
'has_cookies_checkbox' => function_exists('blocksy_ext_cookies_checkbox'),
];
wp_localize_script(
'blocksy/newsletter',
'blc_newsletter_data',
$data
);
wp_enqueue_style(
'blocksy/newsletter',
BLOCKSY_URL .
'framework/extensions/newsletter-subscribe/admin-static/bundle/admin.min.css'
);
}
public static function add_global_styles($args) {
blocksy_theme_get_dynamic_styles(
array_merge(
[
'path' => dirname(__FILE__) . '/global.php',
'chunk' => 'global',
],
$args
)
);
}
public static function onDeactivation() {
remove_action(
'blocksy:global-dynamic-css:enqueue',
'BlocksyExtensionNewsletterSubscribe::add_global_styles',
10,
3
);
}
public function newsletter_subscribe_process_ajax_subscribe() {
if (!isset($_POST['EMAIL'])) {
wp_send_json_error();
}
if (!isset($_POST['GROUP'])) {
wp_send_json_error();
}
$email = $_POST['EMAIL'];
$name = '';
$group = $_POST['GROUP'];
if (isset($_POST['FNAME'])) {
$name = $_POST['FNAME'];
}
$manager = \Blocksy\Extensions\NewsletterSubscribe\Provider::get_for_settings();
$result = $manager->subscribe_form([
'email' => $email,
'name' => $name,
'group' => $group,
]);
wp_send_json_success($result);
}
}

View File

@ -0,0 +1,207 @@
<?php
$forms_type = blocksy_get_theme_mod('forms_type', 'classic-forms');
blocksy_output_colors([
'value' => blocksy_get_theme_mod('newsletter_subscribe_title_color'),
'default' => [
'default' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
],
'css' => $css,
'variables' => [
'default' => [
'selector' => '.ct-newsletter-subscribe-container',
'variable' => 'theme-heading-color'
],
],
]);
blocksy_output_colors([
'value' => blocksy_get_theme_mod('newsletter_subscribe_content'),
'default' => [
'default' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
'hover' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
],
'css' => $css,
'variables' => [
'default' => [
'selector' => '.ct-newsletter-subscribe-container',
'variable' => 'text-color'
],
'hover' => [
'selector' => '.ct-newsletter-subscribe-container',
'variable' => 'theme-link-hover-color'
],
],
]);
blocksy_output_colors([
'value' => blocksy_get_theme_mod('newsletter_subscribe_button'),
'default' => [
'default' => [ 'color' => 'var(--theme-palette-color-1)' ],
'hover' => [ 'color' => 'var(--theme-palette-color-2)' ],
],
'css' => $css,
'variables' => [
'default' => [
'selector' => '.ct-newsletter-subscribe-container',
'variable' => 'theme-button-background-initial-color'
],
'hover' => [
'selector' => '.ct-newsletter-subscribe-container',
'variable' => 'theme-button-background-hover-color'
]
],
]);
blocksy_output_colors([
'value' => blocksy_get_theme_mod('newsletter_subscribe_input_font_color'),
'default' => [
'default' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
'focus' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
],
'css' => $css,
'variables' => [
'default' => [
'selector' => '.ct-newsletter-subscribe-container',
'variable' => 'theme-form-text-initial-color'
],
'focus' => [
'selector' => '.ct-newsletter-subscribe-container',
'variable' => 'theme-form-text-focus-color'
],
],
]);
blocksy_output_colors([
'value' => blocksy_get_theme_mod('newsletter_subscribe_border_color'),
'default' => [
'default' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
'focus' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
],
'css' => $css,
'variables' => [
'default' => [
'selector' => '.ct-newsletter-subscribe-container',
'variable' => 'theme-form-field-border-initial-color'
],
'focus' => [
'selector' => '.ct-newsletter-subscribe-container',
'variable' => 'theme-form-field-border-focus-color'
],
],
]);
if ($forms_type !== 'classic-forms' || is_customize_preview()) {
blocksy_output_colors([
'value' => blocksy_get_theme_mod('newsletter_subscribe_input_background'),
'default' => [
'default' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword() ],
'focus' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword() ],
],
'css' => $css,
'variables' => [
'default' => [
'selector' => '.ct-newsletter-subscribe-container',
'variable' => 'theme-form-field-background-initial-color'
],
'focus' => [
'selector' => '.ct-newsletter-subscribe-container',
'variable' => 'theme-form-field-background-focus-color'
],
],
]);
}
blocksy_output_background_css([
'selector' => '.ct-newsletter-subscribe-container',
'css' => $css,
'tablet_css' => $tablet_css,
'mobile_css' => $mobile_css,
'value' => blocksy_get_theme_mod(
'newsletter_subscribe_container_background',
blocksy_background_default_value([
'backgroundColor' => [
'default' => [
'color' => 'var(--theme-palette-color-8)'
],
],
])
),
'responsive' => true,
]);
blocksy_output_border([
'css' => $css,
'tablet_css' => $tablet_css,
'mobile_css' => $mobile_css,
'selector' => '.ct-newsletter-subscribe-container',
'variableName' => 'newsletter-container-border',
'value' => blocksy_get_theme_mod('newsletter_subscribe_container_border'),
'skip_none' => true,
'default' => [
'width' => 1,
'style' => 'none',
'color' => [
'color' => 'var(--theme-palette-color-5)',
],
],
'responsive' => true,
'skip_none' => true
]);
blocksy_output_box_shadow([
'css' => $css,
'tablet_css' => $tablet_css,
'mobile_css' => $mobile_css,
'selector' => '.ct-newsletter-subscribe-container',
'value' => blocksy_get_theme_mod(
'newsletter_subscribe_shadow',
blocksy_box_shadow_value([
'enable' => true,
'h_offset' => 0,
'v_offset' => 50,
'blur' => 90,
'spread' => 0,
'inset' => false,
'color' => [
'color' => 'rgba(210, 213, 218, 0.4)',
],
])
),
'responsive' => true
]);
blocksy_output_spacing([
'css' => $css,
'tablet_css' => $tablet_css,
'mobile_css' => $mobile_css,
'selector' => '.ct-newsletter-subscribe-container',
'property' => 'padding',
'value' => blocksy_get_theme_mod(
'newsletter_subscribe_container_spacing',
blocksy_spacing_value([
'top' => '30px',
'left' => '30px',
'right' => '30px',
'bottom' => '30px',
])
)
]);
blocksy_output_spacing([
'css' => $css,
'tablet_css' => $tablet_css,
'mobile_css' => $mobile_css,
'selector' => '.ct-newsletter-subscribe-container',
'property' => 'theme-border-radius',
'value' => blocksy_get_theme_mod(
'newsletter_subscribe_container_border_radius',
blocksy_spacing_value()
)
]);

View File

@ -0,0 +1,157 @@
<?php
function blc_ext_newsletter_subscribe_form() {
if (blocksy_get_theme_mod('newsletter_subscribe_single_post_enabled', 'yes') !== 'yes') {
return '';
}
if (
blocksy_default_akg(
'disable_subscribe_form',
blocksy_get_post_options(),
'no'
) === 'yes'
) {
return '';
}
$args = [
'title' => blocksy_get_theme_mod(
'newsletter_subscribe_title',
__('Newsletter Updates', 'blocksy-companion')
),
'description' => blocksy_get_theme_mod('newsletter_subscribe_text', __(
'Enter your email address below and subscribe to our newsletter',
'blocksy-companion'
)),
'button_text' => blocksy_get_theme_mod(
'newsletter_subscribe_button_text',
__('Subscribe', 'blocksy-companion')
),
'has_name' => blocksy_get_theme_mod('has_newsletter_subscribe_name', 'no'),
'name_label' => blocksy_get_theme_mod(
'newsletter_subscribe_name_label',
__('Your name', 'blocksy-companion')
),
'email_label' => blocksy_get_theme_mod(
'newsletter_subscribe_mail_label',
__('Your email', 'blocksy-companion')
)
];
$list_id = null;
if (blocksy_get_theme_mod(
'newsletter_subscribe_list_id_source',
'default'
) === 'custom') {
$args['list_id'] = blocksy_get_theme_mod('newsletter_subscribe_list_id', '');
}
$args['class'] = 'ct-newsletter-subscribe-container ' . blocksy_visibility_classes(
blocksy_get_theme_mod('newsletter_subscribe_subscribe_visibility', [
'desktop' => true,
'tablet' => true,
'mobile' => false,
])
);
return blc_ext_newsletter_subscribe_output_form($args);
}
function blc_ext_newsletter_subscribe_output_form($args = []) {
$args = wp_parse_args($args, [
'has_title' => true,
'has_description' => true,
'title' => __(
'Newsletter Updates', 'blocksy-companion'
),
'description' => __(
'Enter your email address below to subscribe to our newsletter',
'blocksy-companion'
),
'button_text' => __(
'Subscribe', 'blocksy-companion'
),
'has_name' => 'no',
'name_label' => __('Your name', 'blocksy-companion'),
'email_label' => __('Your email', 'blocksy-companion'),
'list_id' => '',
'class' => ''
]);
$has_name = $args['has_name'] === 'yes';
$manager = \Blocksy\Extensions\NewsletterSubscribe\Provider::get_for_settings();
$provider_data = $manager->get_form_url_and_gdpr_for($args['list_id']);
if (! $provider_data) {
return '';
}
if ($provider_data['provider'] !== 'mailchimp') {
$settings = $manager->get_settings();
$provider_data['provider'] .= ':' . $settings['list_id'];
}
$form_url = $provider_data['form_url'];
$has_gdpr_fields = $provider_data['has_gdpr_fields'];
$skip_submit_output = '';
if ($has_gdpr_fields) {
$skip_submit_output = 'data-skip-submit';
}
$fields_number = '2';
if ($has_name) {
$fields_number = '3';
}
ob_start();
?>
<div class="<?php echo esc_attr(trim($args['class'])) ?>">
<?php if ($args['has_title']) { ?>
<h3><?php echo esc_html($args['title']) ?></h3>
<?php } ?>
<?php if ($args['has_description'] && ! empty($args['description'])) { ?>
<p>
<?php echo $args['description'] ?>
</p>
<?php } ?>
<form target="_blank" action="<?php echo esc_attr($form_url) ?>" method="post"
data-provider="<?php echo $provider_data['provider'] ?>"
class="ct-newsletter-subscribe-form"
data-columns="<?php echo $fields_number ?>"
<?php echo $skip_submit_output ?>>
<?php if ($has_name) { ?>
<input type="text" name="FNAME" placeholder="<?php esc_attr_e($args['name_label'], 'blocksy-companion'); ?>" aria-label="<?php echo __('First name', 'blocksy-companion') ?>">
<?php } ?>
<input type="email" name="EMAIL" placeholder="<?php esc_attr_e($args['email_label'], 'blocksy-companion'); ?> *" aria-label="<?php echo __('Email address', 'blocksy-companion') ?>" required>
<button class="wp-element-button">
<?php echo esc_html($args['button_text']) ?>
</button>
<?php if (function_exists('blocksy_ext_cookies_checkbox')) {
echo blocksy_ext_cookies_checkbox('subscribe');
} ?>
<div class="ct-newsletter-subscribe-message"></div>
</form>
</div>
<?php
return ob_get_clean();
}

View File

@ -0,0 +1,97 @@
<?php
namespace Blocksy\Extensions\NewsletterSubscribe;
class Provider {
static public function get_for_settings() {
$m = new Provider();
$settings = $m->get_settings();
return Provider::get_for_provider(
$settings['provider']
);
}
static public function get_for_provider($provider) {
if ($provider === 'mailchimp') {
return new MailchimpProvider();
}
if ($provider === 'brevo') {
return new BrevoProvider();
}
if ($provider === 'campaignmonitor') {
return new CampaignMonitorProvider();
}
if ($provider === 'mailerlite-new') {
return new MailerliteNewProvider();
}
if ($provider === 'convertkit') {
return new ConvertKitProvider();
}
if ($provider === 'demo') {
return new DemoProvider();
}
return new MailerliteClassicProvider();
}
public function fetch_lists($api_key) {
return [];
}
public function get_settings() {
$option = get_option('blocksy_ext_mailchimp_credentials', []);
if (empty($option)) {
$option = [];
}
$free_providers = ['mailchimp', 'demo'];
if (
isset($option['provider'])
&&
! in_array($option['provider'], $free_providers)
&&
blc_get_capabilities()->get_plan() === 'free'
) {
$option['provider'] = $free_providers[0];
}
return array_merge([
'provider' => 'mailchimp',
'api_key' => null,
'list_id' => null
], $option);
}
public function set_settings($vals) {
update_option('blocksy_ext_mailchimp_credentials', array_merge([
'provider' => 'mailchimp',
'api_key' => null,
'list_id' => null
], $vals));
}
public function can($capability = 'manage_options') {
if (is_multisite()) {
// Only network admin can change files that affects the entire network.
$can = current_user_can_for_blog( get_current_blog_id(), $capability );
} else {
$can = current_user_can( $capability );
}
if ($can) {
// Also you can use this method to get the capability.
$can = $capability;
}
return $can;
}
}

View File

@ -0,0 +1,132 @@
<?php
class BlocksyExtensionNewsletterSubscribePreBoot {
public function __construct() {
add_filter('blocksy-dashboard-scripts-dependencies', function ($s) {
$s[] = 'blocksy-ext-mailchimp-dashboard-scripts';
return $s;
});
add_action('admin_enqueue_scripts', function () {
if (! function_exists('get_plugin_data')) {
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
$data = get_plugin_data(BLOCKSY__FILE__);
wp_register_script(
'blocksy-ext-mailchimp-dashboard-scripts',
BLOCKSY_URL . 'framework/extensions/newsletter-subscribe/dashboard-static/bundle/main.js',
[],
$data['Version'],
true
);
});
add_action(
'wp_ajax_blocksy_ext_newsletter_subscribe_maybe_get_lists',
[$this, 'get_lists']
);
add_action(
'wp_ajax_blocksy_ext_newsletter_subscribe_get_actual_lists',
[$this, 'get_actual_lists']
);
add_action(
'wp_ajax_blocksy_ext_newsletter_subscribe_maybe_save_credentials',
[$this, 'save_credentials']
);
}
public function ext_data() {
$m = new \Blocksy\Extensions\NewsletterSubscribe\MailchimpProvider();
return $m->get_settings();
}
public function save_credentials() {
if (! check_ajax_referer('ct-dashboard', 'nonce', false)) {
wp_send_json_error('nonce');
}
$this->maybe_save_credentials();
}
public function get_actual_lists() {
if (! check_ajax_referer('ct-dashboard', 'nonce', false)) {
wp_send_json_error('nonce');
}
$m = \Blocksy\Extensions\NewsletterSubscribe\Provider::get_for_settings();
if (! $m->can()) {
wp_send_json_error();
}
$settings = $m->get_settings();
$lists = $m->fetch_lists($settings['api_key']);
wp_send_json_success([
'result' => $lists
]);
}
public function get_lists() {
if (! check_ajax_referer('ct-dashboard', 'nonce', false)) {
wp_send_json_error('nonce');
}
$this->maybe_save_credentials(false);
}
public function maybe_save_credentials($save = true) {
$provider = $this->get_provider_from_request();
$m = \Blocksy\Extensions\NewsletterSubscribe\Provider::get_for_provider($provider);
if (! $m->can()) {
wp_send_json_error();
}
$lists = $m->fetch_lists($this->get_api_key_from_request());
if ($save) {
if (is_array($lists)) {
$m->set_settings([
'provider' => $this->get_provider_from_request(),
'api_key' => $this->get_api_key_from_request(),
'list_id' => $this->get_list_id_from_request(),
]);
}
}
wp_send_json_success([
'result' => $lists
]);
}
public function get_provider_from_request() {
if (! isset($_POST['provider'])) {
wp_send_json_error();
}
return addslashes($_POST['provider']);
}
public function get_api_key_from_request() {
if (! isset($_POST['api_key'])) {
wp_send_json_error();
}
return addslashes($_POST['api_key']);
}
public function get_list_id_from_request() {
if (! isset($_POST['list_id'])) {
wp_send_json_error();
}
return addslashes($_POST['list_id']);
}
}

View File

@ -0,0 +1,121 @@
<?php
namespace Blocksy\Extensions\NewsletterSubscribe;
class BrevoProvider extends Provider {
public function fetch_lists($api_key) {
if (! $api_key) {
return 'api_key_invalid';
}
$response = wp_remote_get(
'https://api.brevo.com/v3/contacts/lists?limit=50&offset=0&sort=desc',
[
'headers' => [
'api-key' => $api_key
]
]
);
if (! is_wp_error($response)) {
if (200 !== wp_remote_retrieve_response_code($response)) {
return 'api_key_invalid';
}
$body = json_decode(wp_remote_retrieve_body($response), true);
if (! $body || ! isset($body['lists'])) {
return 'api_key_invalid';
}
return array_map(function($list) {
return [
'name' => $list['name'],
'id' => $list['id'],
];
}, $body['lists']);
} else {
return 'api_key_invalid';
}
}
public function get_form_url_and_gdpr_for($maybe_custom_list = null) {
return [
'form_url' => '#',
'has_gdpr_fields' => false,
'provider' => 'brevo'
];
}
public function subscribe_form($args = []) {
$args = wp_parse_args($args, [
'email' => '',
'name' => '',
'group' => ''
]);
$settings = $this->get_settings();
$curl = curl_init();
$lname = '';
$fname = '';
if (! empty($args['name'])) {
$parts = explode(' ', $args['name']);
$lname = array_pop($parts);
$fname = implode(' ', $parts);
}
curl_setopt_array($curl, array(
// CURLOPT_URL => "https://api.mailerlite.com/api/v2/groups/" . $args['group'] . "/subscribers",
CURLOPT_URL => 'https://api.brevo.com/v3/contacts',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => $args['email'],
'attributes' => [
'FIRSTNAME' => $fname,
'LASTNAME' => $lname
],
'listIds' => [intval($settings['list_id'])]
]),
CURLOPT_HTTPHEADER => array(
"content-type: application/json",
"api-key: " . $settings['api_key']
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return [
'result' => 'no',
'error' => $err
];
} else {
$response = json_decode($response, true);
if (isset($response['code'])) {
return [
'result' => 'no',
'message' => $response['message']
];
}
return [
'result' => 'yes',
'message' => __('Thank you for subscribing to our newsletter!', 'blocksy-companion')
];
}
}
}

View File

@ -0,0 +1,141 @@
<?php
namespace Blocksy\Extensions\NewsletterSubscribe;
class CampaignMonitorProvider extends Provider {
public function fetch_lists($api_key) {
if (! $api_key) {
return 'api_key_invalid';
}
$response = wp_remote_get(
'https://api.createsend.com/api/v3.3/clients.json',
[
'headers' => [
'Authorization' => 'Basic ' . base64_encode($api_key . ':x')
]
]
);
if (is_wp_error($response)) {
return 'api_key_invalid';
}
if (200 !== wp_remote_retrieve_response_code($response)) {
return 'api_key_invalid';
}
$clients = json_decode(wp_remote_retrieve_body($response), true);
if (
! $clients
||
empty($clients)
||
! isset($clients[0]['ClientID'])
) {
return 'api_key_invalid';
}
$response = wp_remote_get(
'https://api.createsend.com/api/v3.3/clients/' . $clients[0]['ClientID'] . '/lists.json',
[
'headers' => [
'Authorization' => 'Basic ' . base64_encode($api_key . ':x')
]
]
);
if (is_wp_error($response)) {
return 'api_key_invalid';
}
if (200 !== wp_remote_retrieve_response_code($response)) {
return 'api_key_invalid';
}
$lists = json_decode(wp_remote_retrieve_body($response), true);
if (
! $lists
||
empty($lists)
) {
return 'api_key_invalid';
}
return array_map(function($list) {
return [
'name' => $list['Name'],
'id' => $list['ListID']
];
}, $lists);
}
public function get_form_url_and_gdpr_for($maybe_custom_list = null) {
return [
'form_url' => '#',
'has_gdpr_fields' => false,
'provider' => 'campaignmonitor'
];
}
public function subscribe_form($args = []) {
$args = wp_parse_args($args, [
'email' => '',
'name' => '',
'group' => ''
]);
$settings = $this->get_settings();
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.createsend.com/api/v3.3/subscribers/' . $args['group'] . '.json',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'EmailAddress' => $args['email'],
'Name' => $args['name'],
'ConsentToTrack' => 'Yes'
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => $settings['api_key'] . ':x'
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return [
'result' => 'no',
'error' => $err
];
} else {
$response = json_decode($response, true);
if (isset($response['Code'])) {
return [
'result' => 'no',
'message' => $response['Message']
];
}
return [
'result' => 'yes',
'message' => __('Thank you for subscribing to our newsletter!', 'blocksy-companion')
];
}
}
}

View File

@ -0,0 +1,102 @@
<?php
namespace Blocksy\Extensions\NewsletterSubscribe;
class ConvertKitProvider extends Provider {
public function fetch_lists($api_key) {
if (! $api_key) {
return 'api_key_invalid';
}
$response = wp_remote_get(
'https://api.convertkit.com/v3/forms/?api_key=' . $api_key,
[]
);
if (! is_wp_error($response)) {
if (200 !== wp_remote_retrieve_response_code($response)) {
return 'api_key_invalid';
}
$body = json_decode(wp_remote_retrieve_body($response), true);
if (! $body || ! isset($body['forms'])) {
return 'api_key_invalid';
}
return array_map(function($list) {
return [
'name' => $list['name'],
'id' => $list['id'],
];
}, $body['forms']);
} else {
return 'api_key_invalid';
}
}
public function get_form_url_and_gdpr_for($maybe_custom_list = null) {
return [
'form_url' => '#',
'has_gdpr_fields' => false,
'provider' => 'convertkit'
];
}
public function subscribe_form($args = []) {
$args = wp_parse_args($args, [
'email' => '',
'name' => '',
]);
$settings = $this->get_settings();
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.convertkit.com/v3/forms/' . $settings['list_id'] . '/subscribe',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'api_key' => $settings['api_key'],
'email' => $args['email'],
'first_name' => $args['name'],
]),
CURLOPT_HTTPHEADER => array(
"content-type: application/json; charset=utf-8"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return [
'result' => 'no',
'error' => $err
];
} else {
$response = json_decode($response, true);
if (isset($response['code'])) {
return [
'result' => 'no',
'message' => $response['message']
];
}
return [
'result' => 'yes',
'message' => __('Thank you for subscribing to our newsletter!', 'blocksy-companion')
];
}
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace Blocksy\Extensions\NewsletterSubscribe;
class DemoProvider extends Provider {
public function __construct() {
}
public function fetch_lists($api_key) {
if (! $api_key) {
return 'api_key_invalid';
}
return [
[
'name' => __('Demo List', 'blocksy-companion'),
'id' => 'demolist'
]
];
}
public function get_form_url_and_gdpr_for($maybe_custom_list = null) {
return [
'form_url' => '#',
'has_gdpr_fields' => false,
'provider' => 'demo'
];
}
public function subscribe_form($args = []) {
$args = wp_parse_args($args, [
'email' => '',
'name' => '',
'group' => ''
]);
return [
// 'response' => $response,
'result' => 'yes',
'message' => __('Thank you for subscribing to our newsletter!', 'blocksy-companion')
];
}
}

View File

@ -0,0 +1,117 @@
<?php
namespace Blocksy\Extensions\NewsletterSubscribe;
class MailchimpProvider extends Provider {
public function __construct() {
}
public function fetch_lists($api_key) {
if (! $api_key) {
return 'api_key_invalid';
}
if (strpos($api_key, '-') === false) {
return 'api_key_invalid';
}
$region = explode('-', $api_key);
$response = wp_remote_get(
'https://' . $region[1] . '.api.mailchimp.com/3.0/lists?count=1000',
[
'timeout' => 2,
'headers' => [
'Authorization' => 'Basic ' . base64_encode(
'asd:' . $api_key
)
]
]
);
if (! is_wp_error($response)) {
if (200 !== wp_remote_retrieve_response_code($response)) {
return 'api_key_invalid';
}
$body = json_decode(wp_remote_retrieve_body($response), true);
if (! $body) {
return 'api_key_invalid';
}
if (! isset($body['lists'])) {
return 'api_key_invalid';
}
return array_map(function($list) {
return [
'name' => $list['name'],
'id' => $list['id'],
'subscribe_url_long' => $list['subscribe_url_long'],
'subscribe_url_long_json' => str_replace(
'subscribe',
'subscribe/post-json',
$list['subscribe_url_long'] . '&c=callback'
),
'has_gdpr_fields' => $list['marketing_permissions']
];
}, $body['lists']);
} else {
return 'api_key_invalid';
}
}
public function get_form_url_and_gdpr_for($maybe_custom_list = null) {
$settings = $this->get_settings();
if (! isset($settings['api_key'])) {
return false;
}
if (! $settings['api_key']) {
return false;
}
$lists = $this->fetch_lists($settings['api_key']);
if (! is_array($lists)) {
return false;
}
if (empty($lists)) {
return false;
}
if ($maybe_custom_list) {
$settings['list_id'] = $maybe_custom_list;
}
if (! $settings['list_id']) {
return [
'form_url' => $lists[0]['subscribe_url_long'],
'has_gdpr_fields' => $lists[0]['has_gdpr_fields'],
'provider' => 'mailchimp'
];
}
foreach ($lists as $single_list) {
if ($single_list['id'] === $settings['list_id']) {
return [
'form_url' => $single_list['subscribe_url_long'],
'has_gdpr_fields' => $single_list['has_gdpr_fields'],
'provider' => 'mailchimp'
];
}
}
return [
'form_url' => $lists[0]['subscribe_url_long'],
'has_gdpr_fields' => $lists[0]['has_gdpr_fields'],
'provider' => 'mailchimp'
];
}
}

View File

@ -0,0 +1,107 @@
<?php
namespace Blocksy\Extensions\NewsletterSubscribe;
class MailerliteClassicProvider extends Provider {
public function fetch_lists($api_key) {
if (! $api_key) {
return 'api_key_invalid';
}
$response = wp_remote_get(
'https://api.mailerlite.com/api/v2/groups',
[
'headers' => [
'X-MailerLite-ApiKey' => $api_key
]
]
);
if (! is_wp_error($response)) {
if (200 !== wp_remote_retrieve_response_code($response)) {
return 'api_key_invalid';
}
$body = json_decode(wp_remote_retrieve_body($response), true);
if (! $body) {
return 'api_key_invalid';
}
return array_map(function($list) {
return [
'name' => $list['name'],
'id' => $list['id'],
];
}, $body);
} else {
return 'api_key_invalid';
}
}
public function get_form_url_and_gdpr_for($maybe_custom_list = null) {
return [
'form_url' => '#',
'has_gdpr_fields' => false,
'provider' => 'mailerlite'
];
}
public function subscribe_form($args = []) {
$args = wp_parse_args($args, [
'email' => '',
'name' => '',
'group' => ''
]);
$settings = $this->get_settings();
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.mailerlite.com/api/v2/groups/" . $args['group'] . "/subscribers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => $args['email'],
'name' => $args['name']
]),
CURLOPT_HTTPHEADER => array(
"content-type: application/json",
"x-mailerlite-apikey: " . $settings['api_key']
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return [
'result' => 'no',
'error' => $err
];
}
$response = json_decode($response, true);
if (isset($response['error'])) {
return [
// 'response' => $response,
'result' => 'no',
'message' => $response['error']['message']
];
}
return [
// 'response' => $response,
'result' => 'yes',
'message' => __('Thank you for subscribing to our newsletter!', 'blocksy-companion')
];
}
}

View File

@ -0,0 +1,127 @@
<?php
namespace Blocksy\Extensions\NewsletterSubscribe;
class MailerliteNewProvider extends Provider {
public function fetch_lists($api_key) {
if (! $api_key) {
return 'api_key_invalid';
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://connect.mailerlite.com/api/groups',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"content-type: application/json",
"Authorization: Bearer " . $api_key
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return 'api_key_invalid';
}
$response = json_decode($response, true);
if (
isset($response['error'])
||
! isset($response['data'])
||
! is_array($response['data'])
) {
return 'api_key_invalid';
}
return array_map(function($list) {
return [
'name' => $list['name'],
'id' => $list['id'],
];
}, $response['data']);
}
public function get_form_url_and_gdpr_for($maybe_custom_list = null) {
return [
'form_url' => '#',
'has_gdpr_fields' => false,
'provider' => 'mailerlite'
];
}
public function subscribe_form($args = []) {
$args = wp_parse_args($args, [
'email' => '',
'name' => '',
'group' => ''
]);
$settings = $this->get_settings();
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://connect.mailerlite.com/api/subscribers',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => $args['email'],
'fields' => [
'name' => $args['name']
],
'groups' => [
$args['group']
]
]),
CURLOPT_HTTPHEADER => array(
"content-type: application/json",
"Authorization: Bearer " . $settings['api_key']
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return [
'result' => 'no',
'error' => $err
];
}
$response = json_decode($response, true);
if (isset($response['error'])) {
return [
// 'response' => $response,
'result' => 'no',
'message' => $response['error']['message']
];
}
return [
// 'response' => $response,
'result' => 'yes',
'message' => __('Thank you for subscribing to our newsletter!', 'blocksy-companion')
];
}
}

View File

@ -0,0 +1 @@
!function(){"use strict";var e=window.ctFrontend;(0,e.registerDynamicChunk)("blocksy_ext_newsletter_subscribe",{mount:function(e,s){var r=s.event.target;"mailchimp"===r.dataset.provider&&function(e){if(e.querySelector('[type="email"]').value.trim()){if(document.getElementById("js-validate-robot")&&""!==document.getElementById("js-validate-robot").value)return!1;for(var s=e.action.replace("subscribe","subscribe/post-json"),r="",t="mailchimpCallback",c=e.querySelectorAll("input"),i=0;i<c.length;i++)r+="&"+c[i].name+"="+encodeURIComponent(c[i].value);r+="&c=".concat(t);var a=document.createElement("script");a.src=s+r,document.body.appendChild(a),e.classList.remove("subscribe-error","subscribe-success"),e.classList.add("subscribe-loading"),window[t]=function(s){delete window[t],document.body.removeChild(a),e.classList.remove("subscribe-loading"),s&&(e.classList.add("error"===s.result?"subscribe-error":"subscribe-success"),e.querySelector(".ct-newsletter-subscribe-message").innerHTML=s.msg.replace("0 - ",""))}}}(r),-1===r.dataset.provider.indexOf("mailchimp")&&function(e){var s=new FormData(e);s.append("action","blc_newsletter_subscribe_process_ajax_subscribe"),s.append("GROUP",e.dataset.provider.split(":")[1]),e.classList.remove("subscribe-error","subscribe-success"),e.classList.add("subscribe-loading"),fetch(ct_localizations.ajax_url,{method:"POST",body:s}).then((function(e){return e.json()})).then((function(s){s.success;var r=s.data;e.classList.remove("subscribe-loading"),e.classList.add("no"===r.result?"subscribe-error":"subscribe-success"),e.querySelector(".ct-newsletter-subscribe-message").innerHTML=r.message}))}(r)}})}();

View File

@ -0,0 +1,8 @@
/**
* - v2.0.37
*
* Copyright (c) 2024
* Licensed GPLv2+
*/
.ct-newsletter-subscribe-form{display:grid;gap:var(--theme-form-field-gap, 10px);--theme-link-initial-color: var(--text-color, var(--theme-text-color))}@media(min-width: 690px){.ct-newsletter-subscribe-form[data-columns="2"]{grid-template-columns:1fr auto}}@media(min-width: 690px){.ct-newsletter-subscribe-form[data-columns="3"]{grid-template-columns:1fr 1fr auto}}.ct-newsletter-subscribe-form .wp-element-button{width:100%;--theme-button-min-height: var(--theme-form-field-height, 40px);--theme-button-border-radius: var(--theme-form-field-border-radius, 3px)}.ct-newsletter-subscribe-form .gdpr-confirm-policy,.ct-newsletter-subscribe-form .ct-newsletter-subscribe-message{grid-column:1/-1;margin:0}.ct-newsletter-subscribe-form .ct-newsletter-subscribe-message{display:none}.ct-newsletter-subscribe-form .ct-newsletter-subscribe-message a{text-decoration:underline}.ct-newsletter-subscribe-form.subscribe-error .ct-newsletter-subscribe-message,.ct-newsletter-subscribe-form.subscribe-success .ct-newsletter-subscribe-message{display:block}.ct-newsletter-subscribe-form.subscribe-error .ct-newsletter-subscribe-message{color:#e42b2b;font-size:14px}.ct-newsletter-subscribe-form.subscribe-success *:not(.ct-newsletter-subscribe-message){display:none}.ct-newsletter-subscribe-container{margin-top:60px;padding:var(--padding, 30px);color:var(--text-color, var(--theme-text-color));border-radius:var(--theme-border-radius, 0px);border:var(--newsletter-container-border, none);box-shadow:var(--theme-box-shadow, 0px 12px 18px -6px rgba(34, 56, 101, 0.04))}.ct-newsletter-subscribe-container h3{font-size:20px}.ct-newsletter-subscribe-container>*{text-align:center;margin-inline:auto}@media(min-width: 690px){.ct-newsletter-subscribe-container>*{width:80%}}.ct-newsletter-subscribe-container>*:first-child{margin-top:20px}.ct-newsletter-subscribe-container>*:last-child{margin-bottom:20px}

View File

@ -0,0 +1,101 @@
import { registerDynamicChunk } from 'blocksy-frontend'
const submitMailchimp = (form) => {
if (!form.querySelector('[type="email"]').value.trim()) {
return
}
// Check for spam
if (
document.getElementById('js-validate-robot') &&
document.getElementById('js-validate-robot').value !== ''
) {
return false
}
// Get url for mailchimp
var url = form.action.replace('subscribe', 'subscribe/post-json')
// Add form data to object
var data = ''
var callback = 'mailchimpCallback'
var inputs = form.querySelectorAll('input')
for (var i = 0; i < inputs.length; i++) {
data += '&' + inputs[i].name + '=' + encodeURIComponent(inputs[i].value)
}
data += `&c=${callback}`
// Create & add post script to the DOM
var script = document.createElement('script')
script.src = url + data
document.body.appendChild(script)
form.classList.remove('subscribe-error', 'subscribe-success')
form.classList.add('subscribe-loading')
// Callback function
window[callback] = function (data) {
// Remove post script from the DOM
delete window[callback]
document.body.removeChild(script)
form.classList.remove('subscribe-loading')
if (!data) {
return
}
form.classList.add(
data.result === 'error' ? 'subscribe-error' : 'subscribe-success'
)
form.querySelector('.ct-newsletter-subscribe-message').innerHTML =
data.msg.replace('0 - ', '')
}
}
const submitAjax = (form) => {
const body = new FormData(form)
body.append('action', 'blc_newsletter_subscribe_process_ajax_subscribe')
body.append('GROUP', form.dataset.provider.split(':')[1])
form.classList.remove('subscribe-error', 'subscribe-success')
form.classList.add('subscribe-loading')
fetch(ct_localizations.ajax_url, {
method: 'POST',
body,
})
.then((r) => r.json())
.then(({ success, data }) => {
form.classList.remove('subscribe-loading')
form.classList.add(
data.result === 'no' ? 'subscribe-error' : 'subscribe-success'
)
form.querySelector('.ct-newsletter-subscribe-message').innerHTML =
data.message
})
}
registerDynamicChunk('blocksy_ext_newsletter_subscribe', {
mount: (el, { event }) => {
const form = event.target
if (form.dataset.provider === 'mailchimp') {
submitMailchimp(form)
}
if (form.dataset.provider.indexOf('mailchimp') === -1) {
submitAjax(form)
}
},
})

View File

@ -0,0 +1,63 @@
.ct-newsletter-subscribe-form {
display: grid;
gap: var(--theme-form-field-gap, 10px);
--theme-link-initial-color: var(--text-color, var(--theme-text-color));
&[data-columns="2"] {
@include media-breakpoint-up(md) {
grid-template-columns: 1fr auto;
}
}
&[data-columns="3"] {
@include media-breakpoint-up(md) {
grid-template-columns: 1fr 1fr auto;
}
}
.wp-element-button {
width: 100%;
--theme-button-min-height: var(--theme-form-field-height, 40px);
--theme-button-border-radius: var(--theme-form-field-border-radius, 3px);
}
.gdpr-confirm-policy,
.ct-newsletter-subscribe-message {
grid-column: 1/-1;
margin: 0;
}
.ct-newsletter-subscribe-message {
display: none;
a {
text-decoration: underline;
}
}
&.subscribe-error,
&.subscribe-success {
.ct-newsletter-subscribe-message {
display: block;
}
}
&.subscribe-error {
.ct-newsletter-subscribe-message {
color: #e42b2b;
font-size: 14px;
}
}
&.subscribe-success {
*:not(.ct-newsletter-subscribe-message) {
display: none;
}
}
}

View File

@ -0,0 +1,5 @@
@import '../../../../../static/sass/frontend/common-frontend/functions';
@import '../../../../../static/sass/frontend/common-frontend/mixins';
@import 'common';
@import 'single-block';

View File

@ -0,0 +1,29 @@
.ct-newsletter-subscribe-container {
margin-top: 60px;
padding: var(--padding, 30px);
color: var(--text-color, var(--theme-text-color));
border-radius: var(--theme-border-radius, 0px);
border: var(--newsletter-container-border, none);
box-shadow: var(--theme-box-shadow, 0px 12px 18px -6px rgba(34, 56, 101, 0.04));
h3 {
font-size: 20px;
}
> * {
text-align: center;
margin-inline: auto;
@include media-breakpoint-up(md) {
width: 80%;
}
&:first-child {
margin-top: 20px;
}
&:last-child {
margin-bottom: 20px;
}
}
}

View File

@ -0,0 +1,13 @@
<?php
$config = [
// translators: This is a brand name. Preferably to not be translated
'name' => _x('Product Reviews', 'Extension Brand Name', 'blocksy-companion'),
'description' => __('This extension lets you easily create an affiliate marketing type of website by giving you options to create a personalized product review and use your affiliate links to direct your readers to the purchase page.', 'blocksy-companion'),
'documentation' => 'https://creativethemes.com/blocksy/docs/extensions/product-reviews/',
'video' => 'https://youtu.be/Zv31rmKgaZw',
'customize' => admin_url('customize.php?ct_autofocus=post_type_archive_blc-product-review'),
'icon' => '<svg width="16" height="16" viewBox="0 0 16 16"><path d="m8.7.5 1.8 4c.1.2.3.4.6.5l4.1.6c.7 0 1 .8.5 1.3l-3 3.1c-.2.2-.2.5-.2.7l.7 4.3c.1.6-.6 1.2-1.1.9l-3.7-2.1c-.2-.2-.5-.2-.7 0L4 15.9c-.6.3-1.3-.2-1.1-.9l.7-4.3c.1-.2-.1-.6-.2-.7l-3-3.1c-.6-.5-.4-1.3.3-1.4l4.1-.6c.2 0 .5-.2.6-.5l1.8-4c.4-.5 1.2-.5 1.5.1z"/></svg>',
];

View File

@ -0,0 +1,21 @@
.ct-product-reviews-options {
padding-top: 40px;
border-top: 1px dashed #eee;
form {
display: grid;
grid-template-columns: 1fr 1fr 150px;
gap: 10px;
align-items: end;
margin-top: 25px;
}
.ct-control {
--options-vertical-spacing: 0;
--options-horizontal-spacing: 0;
.ct-option-input {
--input-height: 35px;
}
}
}

View File

@ -0,0 +1,715 @@
<?php
require_once dirname(__FILE__) . '/helpers.php';
class BlocksyExtensionProductReviews {
public function __construct() {
add_action(
'blocksy:hero:title:before',
function () {
if (! is_singular('blc-product-review')) {
return;
}
$atts = apply_filters(
'blocksy:ext:product-reviews:frontend:atts',
blocksy_get_post_options(null, [
'meta_id' => 'blocksy_product_review_options'
]),
get_the_ID()
);
$product_review_entity = blocksy_akg(
'product_review_entity',
$atts,
'Thing'
);
$maybe_schema = blocksy_schema_org_definitions('itemReviewed', [
'to_merge' => [
'itemtype' => "https://schema.org/" . $product_review_entity
]
]);
if (! $maybe_schema) {
return;
}
echo '<div ' . $maybe_schema . '>';
echo '<meta itemprop="name" content="' . get_the_title() . '">';
if (get_the_post_thumbnail_url()) {
echo '<meta itemprop="image" content="' . get_the_post_thumbnail_url() . '">';
}
$product_description = blocksy_akg('product_description', $atts, '');
if (! empty($product_description)) {
echo blocksy_html_tag('meta', [
'itemprop' => 'description',
'content' => strip_tags($product_description)
]);
}
if ($product_review_entity === 'Product') {
$product_entity_sku = blocksy_akg('product_entity_sku', $atts, '');
$product_entity_brand = blocksy_akg('product_entity_brand', $atts, '');
$product_entity_price = blocksy_akg('product_entity_price', $atts, '');
if (! empty($product_entity_sku)) {
echo blocksy_html_tag('meta', [
'itemprop' => 'sku',
'content' => $product_entity_sku
]);
}
if (! empty($product_entity_brand)) {
echo blocksy_html_tag(
'div',
[
'itemprop' => 'brand',
'itemscope' => '',
'itemtype' => 'https://schema.org/Brand'
],
blocksy_html_tag(
'meta',
[
'itemprop' => 'name',
'content' => $product_entity_brand
]
)
);
}
$product_link = blocksy_akg('product_link', $atts, '#');
$offers_contents = '';
if (! empty($product_link)) {
$offers_contents .= blocksy_html_tag('link', [
'itemprop' => 'url',
'href' => $product_link
]);
}
$offers_contents .= blocksy_html_tag('meta', [
'itemprop' => 'availability',
'content' => 'https://schema.org/InStock'
]);
if (! empty($product_entity_price)) {
$parsed_price = preg_replace(
"/[^0-9.,]/",
"",
$product_entity_price
);
$parsed_currency = preg_replace(
"/[0-9.,]/",
"",
$product_entity_price
);
$offers_contents .= blocksy_html_tag('meta', [
'itemprop' => 'price',
'content' => $parsed_price
]);
$currencies = [
'$' => 'USD',
'€' => 'EUR',
'₡' => 'CRC',
'£' => 'GBP',
'₪' => 'ILS',
'₹' => 'INR',
'¥' => 'JPY',
'₩' => 'KRW',
'₦' => 'NGN',
'₱' => 'PHP',
'zł' => 'PLN',
'₲' => 'PYG',
'฿' => 'THB',
'₴' => 'UAH',
'₫' => 'VND'
];
if ($parsed_currency && isset($currencies[$parsed_currency])) {
$parsed_currency = $currencies[$parsed_currency];
}
$offers_contents .= blocksy_html_tag('meta', [
'itemprop' => 'priceCurrency',
'content' => $parsed_currency
]);
}
echo blocksy_html_tag(
'div',
[
'itemprop' => 'offers',
'itemscope' => '',
'itemtype' => 'https://schema.org/Offer'
],
$offers_contents
);
}
}
);
add_action(
'blocksy:hero:title:after',
function () {
if (! is_singular('blc-product-review')) {
return;
}
$maybe_schema = blocksy_schema_org_definitions('itemReviewed');
if (! $maybe_schema) {
return;
}
echo '</div>';
}
);
add_filter(
'blocksy:options:cpt:page-title-args',
function ($args, $cpt) {
if ($cpt === 'blc-product-review') {
$args['has_hero_type'] = false;
}
return $args;
},
10, 2
);
add_action(
'customize_preview_init',
function () {
if (! function_exists('get_plugin_data')){
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
}
$data = get_plugin_data(BLOCKSY__FILE__);
wp_enqueue_script(
'blocksy-product-reviews-customizer-sync',
BLOCKSY_URL . 'framework/extensions/product-reviews/static/bundle/sync.js',
[ 'ct-scripts', 'customize-preview', 'blocksy-companion-sync-scripts' ],
$data['Version'],
true
);
}
);
add_action('init', [$this, 'declare_cpt']);
add_action('load-post.php', [$this, 'init_metabox']);
add_action('load-post-new.php', [$this, 'init_metabox']);
add_filter('blocksy:single:has-default-hero', function ($def) {
if (! is_singular('blc-product-review')) {
return $def;
}
return false;
});
add_filter(
'blocksy:hero:type-1:default-alignment',
function ($default, $prefix) {
if ($prefix === 'blc-product-review_single') {
return 'center';
}
return $default;
},
10, 2
);
add_filter('blocksy:archive:render-card-layers', function ($layers, $prefix) {
if ($prefix !== 'blc-product-review_archive') {
return $layers;
}
$layers['overall_score'] = blocksy_get_product_review_overall_score();
return $layers;
}, 10, 2);
add_filter(
'blocksy:options:posts-listing:design:before_card_background',
function ($opts, $prefix) {
if ($prefix !== 'blc-product-review_archive') {
return $opts;
}
$opts[blocksy_rand_md5()] = [
'type' => 'ct-condition',
'condition' => [
$prefix . '_archive_order:array-ids:overall_score:enabled' => '!no'
],
'options' => [
$prefix . '_star_rating_color' => [
'label' => __( 'Star Rating Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
'divider' => 'top:full',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
'inactive' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
],
'pickers' => [
[
'title' => __( 'Active', 'blocksy-companion' ),
'id' => 'default',
'inherit' => '#FDA256'
],
[
'title' => __( 'Inactive', 'blocksy-companion' ),
'id' => 'inactive',
'inherit' => '#F9DFCC'
],
],
]
]
];
return $opts;
},
10, 2
);
add_filter('blocksy:posts-listing:archive-order:default', function ($default, $prefix) {
if ($prefix !== 'blc-product-review_archive') {
return $default;
}
$default[] = [
'id' => 'overall_score',
'enabled' => true
];
return $default;
}, 10, 2);
add_filter('blocksy:options:posts-listing-archive-order', function ($option, $prefix) {
if ($prefix !== 'blc-product-review_archive') {
return $option;
}
$option['value'][] = [
'id' => 'overall_score',
'enabled' => true
];
$option['settings']['overall_score'] = [
'label' => __('Overall Score', 'blocksy-companion'),
/*
'options' => [
'excerpt_length' => [
'label' => __('Length', 'blocksy-companion'),
'type' => 'ct-number',
'design' => 'inline',
'value' => 40,
'min' => 10,
'max' => 100,
],
],
*/
];
return $option;
}, 10, 2);
add_action(
'blocksy:template:before',
function () {
if (! is_singular('blc-product-review')) {
return;
}
echo blocksy_render_view(
dirname(__FILE__) . '/views/single-top.php',
[]
);
}
);
add_action('wp_enqueue_scripts', function () {
if (! function_exists('get_plugin_data')) {
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
$data = get_plugin_data(BLOCKSY__FILE__);
if (is_admin()) {
return;
}
wp_enqueue_style(
'blocksy-ext-product-reviews-styles',
BLOCKSY_URL . 'framework/extensions/product-reviews/static/bundle/main.min.css',
['ct-main-styles'],
$data['Version']
);
}, 50);
add_filter('blocksy_single_posts_post_elements_start', function ($options, $prefix) {
if ($prefix !== 'blc-product-review_single') {
return $options;
}
$options[$prefix . '_reviews_summary'] = [
'label' => __( 'Review Summary', 'blocksy-companion' ),
'type' => 'ct-panel',
'setting' => [ 'transport' => 'postMessage' ],
'inner-options' => [
blocksy_rand_md5() => [
'title' => __( 'General', 'blocksy-companion' ),
'type' => 'tab',
'options' => [
$prefix . '_product_scores_width' => [
'label' => __( 'Scores Box Width', 'blocksy-companion' ),
'type' => 'ct-slider',
'min' => 0,
'max' => 1200,
'value' => 800,
// 'responsive' => true,
'setting' => [ 'transport' => 'postMessage' ],
],
$prefix . '_has_read_more' => [
'label' => __('Read More Button', 'blocksy-companion'),
'type' => 'ct-switch',
'value' => 'yes',
'divider' => 'top',
'sync' => blocksy_sync_single_post_container([
'prefix' => $prefix,
'loader_selector' => '.ct-product-actions-group'
])
],
$prefix . '_has_buy_now' => [
'label' => __('Buy Now Button', 'blocksy-companion'),
'type' => 'ct-switch',
'value' => 'yes',
'divider' => 'top',
'sync' => blocksy_sync_single_post_container([
'prefix' => $prefix,
'loader_selector' => '.ct-product-actions-group'
])
],
],
],
blocksy_rand_md5() => [
'title' => __( 'Design', 'blocksy-companion' ),
'type' => 'tab',
'options' => [
$prefix . '_star_rating_color' => [
'label' => __( 'Star Rating Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
'inactive' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
],
'pickers' => [
[
'title' => __( 'Active', 'blocksy-companion' ),
'id' => 'default',
'inherit' => '#FDA256'
],
[
'title' => __( 'Inactive', 'blocksy-companion' ),
'id' => 'inactive',
'inherit' => '#F9DFCC'
],
],
],
$prefix . '_overall_score_text' => [
'label' => __( 'Overll Score Text', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
'divider' => 'top',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
],
'pickers' => [
[
'title' => __( 'Active', 'blocksy-companion' ),
'id' => 'default',
'inherit' => 'var(--theme-palette-color-8)'
],
],
],
$prefix . '_overall_score_backgroud' => [
'label' => __( 'Overll Score Background', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'inline',
'setting' => [ 'transport' => 'postMessage' ],
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
],
'pickers' => [
[
'title' => __( 'Active', 'blocksy-companion' ),
'id' => 'default',
'inherit' => 'var(--theme-palette-color-4)'
],
],
],
],
],
]
];
return $options;
}, 10, 2);
add_action(
'blocksy:global-dynamic-css:enqueue',
'BlocksyExtensionProductReviews::add_global_styles',
10, 3
);
}
static public function add_global_styles($args) {
blocksy_theme_get_dynamic_styles(array_merge([
'path' => dirname(__FILE__) . '/global.php',
'chunk' => 'global',
], $args));
}
static public function onDeactivation() {
remove_action(
'blocksy:global-dynamic-css:enqueue',
'BlocksyExtensionProductReviews::add_global_styles',
10, 3
);
}
public function init_metabox() {
add_action('add_meta_boxes', [$this, 'setup_meta_box']);
add_action('save_post', [$this, 'save_meta_box']);
}
public function declare_cpt() {
$settings = $this->get_settings();
register_post_type('blc-product-review', [
'label' => __('Product Reviews', 'blocksy-companion'),
'description' => __( 'Product Reviews', 'blocksy-companion'),
'menu_icon' => 'dashicons-star-filled',
'labels' => [
'name' => __('Product Reviews', 'blocksy-companion'),
'singular_name' => __('Product Review', 'blocksy-companion'),
'menu_name' => __('Product Reviews', 'blocksy-companion'),
'parent_item_colon' => __('Parent Product Review', 'blocksy-companion'),
'all_items' => __('All Reviews', 'blocksy-companion'),
'view_item' => __('View Product Review', 'blocksy-companion'),
'add_new_item' => __('Add New Product Review', 'blocksy-companion'),
'add_new' => __('Add New Review', 'blocksy-companion'),
'edit_item' => __('Edit Product Review', 'blocksy-companion'),
'update_item' => __('Update Product Review', 'blocksy-companion'),
'search_items' => __('Search Product Review', 'blocksy-companion'),
'not_found' => __('Not Found', 'blocksy-companion'),
'not_found_in_trash' => __('Not found in Trash', 'blocksy-companion')
],
'supports' => [
'comments',
'title', 'editor', 'excerpt',
'author', 'thumbnail', 'revisions',
'custom-fields'
],
'show_in_rest' => true,
'public' => true,
'hierarchical' => false,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'has_archive' => true,
'can_export' => true,
'exclude_from_search' => false,
// 'taxonomies' => array('post_tag'),
'publicly_queryable' => true,
'capability_type' => 'page',
'rewrite' => [
'slug' => $settings['single_slug']
],
]);
register_taxonomy(
'blc-product-review-categories',
[
'blc-product-review'
],
[
'hierarchical' => true,
'labels' => [
'name' => __('Categories', 'blocksy-companion'),
'singular_name' => __('Category', 'blocksy-companion'),
'search_items' => __('Search Category', 'blocksy-companion'),
'all_items' => __('All Categories', 'blocksy-companion'),
'parent_item' => __('Parent Category', 'blocksy-companion'),
'parent_item_colon' => __('Parent Category:', 'blocksy-companion'),
'edit_item' => __('Edit Category', 'blocksy-companion'),
'update_item' => __('Update Category', 'blocksy-companion'),
'add_new_item' => __('Add New Category', 'blocksy-companion'),
'new_item_name' => __('New Category Name', 'blocksy-companion'),
'menu_name' => __('Categories', 'blocksy-companion'),
],
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'show_in_rest' => true,
'rewrite' => [
'slug' => $settings['category_slug']
],
]
);
}
public function setup_meta_box() {
add_meta_box(
'blocksy_settings_meta_box',
blc_safe_sprintf(
// Translators: %s is the theme name.
__( '%s Settings', 'blocksy-companion' ),
__( 'Blocksy', 'blocksy-companion' )
),
function ($post) {
$values = get_post_meta($post->ID, 'blocksy_product_review_options');
if (empty($values)) {
$values = [[]];
}
$options = blocksy_get_options(
dirname(__FILE__) . '/metabox.php',
[],
false
);
/**
* Note to code reviewers: This line doesn't need to be escaped.
* Function blocksy_output_options_panel() used here escapes the value properly.
*/
echo blocksy_output_options_panel(
[
'options' => $options,
'values' => $values[0],
'id_prefix' => 'ct-post-meta-options',
'name_prefix' => 'blocksy_product_review_options',
'attr' => [
'class' => 'ct-meta-box',
'data-disable-reverse-button' => 'yes'
]
]
);
wp_nonce_field(basename(__FILE__), 'blocksy_settings_meta_box');
},
'blc-product-review', 'normal', 'default'
);
}
public function save_meta_box($post_id) {
$is_autosave = wp_is_post_autosave($post_id);
$is_revision = wp_is_post_revision($post_id);
$is_valid_nonce = !! (
isset($_POST['blocksy_settings_meta_box']) && wp_verify_nonce(
sanitize_text_field(wp_unslash($_POST['blocksy_settings_meta_box'])),
basename(__FILE__)
)
);
if ($is_autosave || $is_revision || !$is_valid_nonce) {
return;
}
$values = [];
if (isset($_POST['blocksy_product_review_options'][blocksy_post_name()])) {
$values = json_decode(
wp_unslash($_POST['blocksy_product_review_options'][blocksy_post_name()]),
true
);
}
update_post_meta(
$post_id,
'blocksy_product_review_options',
$values
);
}
public function get_settings() {
if (wp_doing_ajax()) {
$maybe_input = json_decode(file_get_contents('php://input'), true);
if (
$maybe_input
&&
isset($maybe_input['extension'])
&&
$maybe_input['extension'] === 'product-reviews'
&&
isset($maybe_input['extAction'])
&&
$maybe_input['extAction']['type'] === 'persist'
) {
return $maybe_input['extAction']['settings'];
}
}
return get_option('blocksy_ext_product_reviews_settings', [
'single_slug' => 'product-review',
'category_slug' => 'product-review-category',
]);
}
public function set_settings($value) {
update_option('blocksy_ext_product_reviews_settings', $value);
}
}

View File

@ -0,0 +1,126 @@
<?php
$prefix = 'blc-product-review_single';
$product_scores_width = blocksy_get_theme_mod($prefix . '_product_scores_width', 800);
if ($product_scores_width !== 800) {
$css->put(
blocksy_prefix_selector('.ct-product-scores', $prefix),
'--product-scores-width: ' . $product_scores_width . 'px'
);
}
blocksy_output_colors([
'value' => blocksy_get_theme_mod(
$prefix . '_star_rating_color',
[]
),
'default' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT')
],
'inactive' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT')
],
],
'css' => $css,
'variables' => [
'default' => [
'selector' => blocksy_prefix_selector(
'.ct-product-scores',
$prefix
),
'variable' => 'star-rating-initial-color'
],
'inactive' => [
'selector' => blocksy_prefix_selector(
'.ct-product-scores',
$prefix
),
'variable' => 'star-rating-inactive-color'
],
],
]);
blocksy_output_colors([
'value' => blocksy_get_theme_mod(
$prefix . '_overall_score_text',
[]
),
'default' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT')
]
],
'css' => $css,
'variables' => [
'default' => [
'selector' => blocksy_prefix_selector(
'.ct-product-scores',
$prefix
),
'variable' => 'overall-score-text-color'
],
],
]);
blocksy_output_colors([
'value' => blocksy_get_theme_mod(
$prefix . '_overall_score_backgroud',
[]
),
'default' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT')
]
],
'css' => $css,
'variables' => [
'default' => [
'selector' => blocksy_prefix_selector(
'.ct-product-scores',
$prefix
),
'variable' => 'overall-score-box-background'
],
],
]);
$prefix = 'blc-product-review_archive';
blocksy_output_colors([
'value' => blocksy_get_theme_mod(
$prefix . '_star_rating_color',
[]
),
'default' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT')
],
'inactive' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT')
],
],
'css' => $css,
'variables' => [
'default' => [
'selector' => blocksy_prefix_selector(
'.star-rating',
$prefix
),
'variable' => 'star-rating-initial-color'
],
'inactive' => [
'selector' => blocksy_prefix_selector(
'.star-rating',
$prefix
),
'variable' => 'star-rating-inactive-color'
],
],
]);

View File

@ -0,0 +1,43 @@
<?php
function blocksy_get_product_review_overall_score($post_id = null) {
if (! $post_id) {
global $post;
$post_id = $post->ID;
}
$atts = blocksy_get_post_options($post_id, [
'meta_id' => 'blocksy_product_review_options'
]);
$scores = blocksy_akg('scores', $atts, []);
if (empty($scores)) {
return '';
}
$output = '<div class="ct-overall-score-layer">';
$avg_score = apply_filters(
'blocksy:ext:product-reviews:overall-score',
round(array_reduce($scores, function ($carry, $score) {
return $carry + floatval($score['score']);
}, 0) / count($scores) * 10) / 10,
$scores
);
$output .= '<span class="ct-score-label">';
$output .= __('Rating', 'blocksy-companion');
$output .= ':</span>';
$output .= '<span class="ct-average-score">' . $avg_score . '/5</span>';
$output .= '<div class="star-rating" role="img">';
$width = (($avg_score / 5) * 100);
$output .= '<span style="width: ' . $width . '%;"></span>';
$output .= '</div>';
$output .= '</div>';
return $output;
}

View File

@ -0,0 +1,295 @@
<?php
$options = [
blocksy_rand_md5() => [
'title' => __( 'General', 'blocksy-companion' ),
'type' => 'tab',
'options' => [
'product_review_entity' => [
'label' => __( 'Review Entity', 'blocksy-companion' ),
'type' => 'ct-select',
'value' => 'Thing',
'view' => 'text',
'design' => 'inline',
'choices' => blocksy_ordered_keys(
[
'Thing' => __( 'Default', 'blocksy-companion' ),
'Product' => __( 'Product', 'blocksy-companion' ),
'Book' => __( 'Book', 'blocksy-companion' ),
// 'Course' => __( 'Course', 'blocksy-companion' ),
'CreativeWorkSeason' => __( 'Creative Work Season', 'blocksy-companion' ),
'CreativeWorkSeries' => __( 'Creative Work Series', 'blocksy-companion' ),
'Episode' => __( 'Episode', 'blocksy-companion' ),
// 'Event' => __( 'Event', 'blocksy-companion' ),
'Game' => __( 'Game', 'blocksy-companion' ),
// 'HowTo' => __( 'How To', 'blocksy-companion' ),
'LocalBusiness' => __( 'Local Business', 'blocksy-companion' ),
'MediaObject' => __( 'Media Object', 'blocksy-companion' ),
'Movie' => __( 'Movie', 'blocksy-companion' ),
'MusicPlaylist' => __( 'Music Playlist', 'blocksy-companion' ),
'MusicRecording' => __( 'Music Recording', 'blocksy-companion' ),
'Organization' => __( 'Organization', 'blocksy-companion' ),
// 'Recipe' => __( 'Recipe', 'blocksy-companion' ),
// 'SoftwareApplication' => __( 'Software Application', 'blocksy-companion' ),
]
),
'desc' => blc_safe_sprintf(
__(
'More info about review entity and how to choose the right one can be found %shere%s.',
'blocksy-companion'
),
'<a href="https://developers.google.com/search/blog/2019/09/making-review-rich-results-more-helpful" target="_blank">',
'</a>'
),
],
blocksy_rand_md5() => [
'type' => 'ct-condition',
'condition' => ['product_review_entity' => 'Product'],
'options' => [
blocksy_rand_md5() => [
'type' => 'ct-group',
'label' => ' ',
'wrapperAttr' => ['data-design' => 'inline'],
'options' => [
blocksy_rand_md5() => [
'type' => 'ct-notification',
'text' => __( 'Please note that some of this information (price, sku, brand) won\'t be displayed on the front-end. It is solely used for Google\'s Schema.org markup.', 'blocksy-companion' ),
'attr' => ['data-type' => 'background:yellow']
],
],
],
'product_entity_price' => [
'type' => 'text',
'label' => __('Product Price', 'blocksy-companion'),
'design' => 'inline',
'value' => '',
],
'product_entity_sku' => [
'type' => 'text',
'label' => __('Product SKU', 'blocksy-companion'),
'design' => 'inline',
'value' => '',
],
'product_entity_brand' => [
'type' => 'text',
'label' => __('Product Brand', 'blocksy-companion'),
'design' => 'inline',
'value' => '',
],
]
],
blocksy_rand_md5() => [
'type' => 'ct-divider',
],
'gallery' => [
'type' => 'ct-multi-image-uploader',
'label' => __('Gallery', 'blocksy-companion'),
'design' => 'inline',
'value' => []
],
blocksy_rand_md5() => [
'type' => 'ct-divider',
],
'product_button_label' => [
'type' => 'text',
'label' => __('Affiliate Button Label', 'blocksy-companion'),
'design' => 'inline',
'value' => __('Buy Now', 'blocksy-companion')
],
'product_link' => [
'type' => 'text',
'label' => __('Affiliate Link', 'blocksy-companion'),
'design' => 'inline',
'value' => '#'
],
'product_link_target' => [
'label' => __( 'Open Link In New Tab', 'blocksy-companion' ),
'type' => 'ct-switch',
'value' => 'no',
],
'product_link_sponsored' => [
'label' => __( 'Sponsored Attribute', 'blocksy-companion' ),
'type' => 'ct-switch',
'value' => 'no',
],
/*
'product_button_icon' => [
'type' => 'icon-picker',
'label' => __('Button Icon', 'blocksy-companion'),
'design' => 'inline',
'value' => [
'icon' => 'fas fa-shopping-cart'
]
],
*/
blocksy_rand_md5() => [
'type' => 'ct-divider',
],
'product_read_content_button_label' => [
'type' => 'text',
'label' => __('Read More Button Label', 'blocksy-companion'),
'design' => 'inline',
'value' => __('Read More', 'blocksy-companion')
],
/*
'product_read_content_button_icon' => [
'type' => 'icon-picker',
'label' => __('Button Icon', 'blocksy-companion'),
'design' => 'inline',
'value' => [
'icon' => 'fas fa-arrow-down'
]
],
*/
blocksy_rand_md5() => [
'type' => 'ct-divider',
],
'product_description' => [
'type' => 'wp-editor',
'label' => __('Short Description', 'blocksy-companion'),
'value' => '',
'design' => 'inline',
],
],
],
blocksy_rand_md5() => [
'title' => __( 'Rating', 'blocksy-companion' ),
'type' => 'tab',
'options' => [
'scores' => [
'type' => 'ct-addable-box',
'label' => __('Scores', 'blocksy-companion'),
'design' => 'inline',
'preview-template' => '<%= label %> (<%= score === 1 ? "1 star" : score + " stars" %>)',
'inner-options' => [
'label' => [
'type' => 'text',
'value' => 'Default'
],
'score' => [
'type' => 'ct-number',
'value' => 5,
'step' => 0.1,
'min' => 1,
'max' => 5
]
],
'value' => [
/*
[
'label' => 'Features',
'score' => 5
],
[
'label' => 'Quality',
'score' => 5
]
*/
]
],
blocksy_rand_md5() => [
'type' => 'ct-divider',
],
'product_specs' => [
'type' => 'ct-addable-box',
'label' => __('Product specs', 'blocksy-companion'),
'design' => 'inline',
'preview-template' => '<%= label %>',
'inner-options' => [
'label' => [
'type' => 'text',
'value' => 'Default'
],
'value' => [
'type' => 'text',
'value' => ''
]
],
'value' => []
],
blocksy_rand_md5() => [
'type' => 'ct-divider',
],
'product_pros' => [
'type' => 'ct-addable-box',
'label' => __('Pros', 'blocksy-companion'),
'design' => 'inline',
'preview-template' => '<%= label %>',
'inner-options' => [
'label' => [
'type' => 'text',
'value' => 'Default'
],
],
'value' => []
],
blocksy_rand_md5() => [
'type' => 'ct-divider',
],
'product_cons' => [
'type' => 'ct-addable-box',
'label' => __('Cons', 'blocksy-companion'),
'design' => 'inline',
'preview-template' => '<%= label %>',
'inner-options' => [
'label' => [
'type' => 'text',
'value' => 'Default'
],
],
'value' => []
],
],
],
// blocksy_rand_md5() => [
// 'title' => __( 'Design', 'blocksy-companion' ),
// 'type' => 'tab',
// 'options' => [
// ],
// ],
];

View File

@ -0,0 +1,65 @@
<?php
class BlocksyExtensionProductReviewsPreBoot {
public function __construct() {
add_action('admin_enqueue_scripts', function () {
if (! function_exists('get_plugin_data')) {
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
$data = get_plugin_data(BLOCKSY__FILE__);
if (! function_exists('blocksy_is_dashboard_page')) return;
if (! blocksy_is_dashboard_page()) return;
wp_enqueue_script(
'blocksy-ext-product-reviews-admin-dashboard-scripts',
BLOCKSY_URL . 'framework/extensions/product-reviews/static/bundle/dashboard.js',
['ct-options-scripts', 'ct-dashboard-scripts'],
$data['Version']
);
wp_enqueue_style(
'blocksy-ext-product-reviews-admin-dashboard-styles',
BLOCKSY_URL . 'framework/extensions/product-reviews/static/bundle/main-admin.min.css',
[],
$data['Version']
);
});
}
public function ext_action($payload) {
$ext = \Blocksy\Plugin::instance()->extensions->get('product-reviews');
if (
! isset($payload['type'])
||
! isset($payload['settings'])
||
$payload['type'] !== 'persist'
||
! $ext
) {
return;
}
$ext->set_settings($payload['settings']);
global $wp_rewrite;
$wp_rewrite->flush_rules();
return $this->ext_data([
'settings' => $payload['settings']
]);
}
public function ext_data($args = []) {
return wp_parse_args($args, [
'settings' => get_option('blocksy_ext_product_reviews_settings', [
'single_slug' => 'product-review',
'category_slug' => 'product-review-category',
])
]);
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
/**
* - v2.0.37
*
* Copyright (c) 2024
* Licensed GPLv2+
*/
.ct-product-reviews-settings-modal .ct-controls-group{padding-top:30px;margin-top:5px;border-top:1px dashed #eee}

View File

@ -0,0 +1,8 @@
/**
* - v2.0.37
*
* Copyright (c) 2024
* Licensed GPLv2+
*/
.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-inline:var(--thumbs-spacing)}.ct-product-hero .flexy-pills li img{width:100%;border-radius:2px;border:3px solid #fff}.ct-product-hero .hero-section:not(:first-child){margin-top:var(--margin-bottom, 40px)}.ct-product-scores{display:grid;grid-column-gap:25px;grid-row-gap:25px;margin:0 auto;max-width:var(--product-scores-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;position:relative;padding:10px 20px}.ct-product-scores li:before{position:absolute;z-index:0;inset:0;content:"";border-radius:2px;opacity:.2;background:var(--theme-border-color)}.ct-product-scores li>span{font-size:15px;font-weight:500;position:relative}.ct-overall-score{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:20px;color:var(--overall-score-text-color, var(--theme-palette-color-8));border-radius:2px;background:var(--overall-score-box-background, var(--theme-palette-color-4))}.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:.02em;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;margin-inline-end:auto}.ct-overall-score-layer .star-rating{margin:3px 0}.ct-product-actions-group{display:flex;align-items:center;justify-content:center}.ct-product-actions-group:not(:last-child){margin-bottom:60px}.ct-product-actions-group .ct-button:not(:last-child){margin-inline-end:25px}.ct-product-actions-group .ct-icon-container{color:inherit;margin-inline-start: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 var(--theme-border-color);padding-top:var(--theme-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}}.ct-product-info li{position:relative;padding-inline-start:22px}.ct-product-info .ct-icon-container{position:absolute;inset-inline-start:0;top:.4em;opacity:.8;--theme-icon-size: 13px}@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(--theme-content-vertical-spacing, 60px)}.ct-product-hero .ct-container{padding-bottom:var(--theme-content-vertical-spacing, 60px);border-bottom:1px solid var(--theme-border-color)}.ct-product-hero ul li:not(:last-child){margin-bottom:.3em}

View File

@ -0,0 +1 @@
!function(){"use strict";var r={n:function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},d:function(e,t){for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},o:function(r,e){return Object.prototype.hasOwnProperty.call(r,e)}},e=window.blocksyCustomizerSync,t=window.ctEvents,o=r.n(t);function c(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,o)}return t}function n(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?c(Object(t),!0).forEach((function(e){a(r,e,t[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))}))}return r}function a(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var i="blc-product-review_single";o().on("ct:customizer:sync:collect-variable-descriptors",(function(r){var t;r.result=n(n({},r.result),{},(a(t={},"".concat(i,"_product_scores_width"),{selector:(0,e.applyPrefixFor)(".ct-product-scores",i),variable:"product-scores-width",unit:"px"}),a(t,"".concat(i,"_star_rating_color"),[{selector:(0,e.applyPrefixFor)(".ct-product-scores",i),variable:"star-rating-initial-color",type:"color:default"},{selector:(0,e.applyPrefixFor)(".ct-product-scores",i),variable:"star-rating-inactive-color",type:"color:inactive"}]),a(t,"".concat(i,"_overall_score_text"),[{selector:(0,e.applyPrefixFor)(".ct-product-scores",i),variable:"overall-score-text-color",type:"color:default"}]),a(t,"".concat(i,"_overall_score_backgroud"),[{selector:(0,e.applyPrefixFor)(".ct-product-scores",i),variable:"overall-score-box-background",type:"color:default"}]),t))}));var l="blc-product-review_archive";o().on("ct:customizer:sync:collect-variable-descriptors",(function(r){r.result=n(n({},r.result),{},a({},"".concat(l,"_star_rating_color"),[{selector:(0,e.applyPrefixFor)(".star-rating",l),variable:"star-rating-initial-color",type:"color:default"},{selector:(0,e.applyPrefixFor)(".star-rating",l),variable:"star-rating-inactive-color",type:"color:inactive"}]))}))}();

View File

@ -0,0 +1,101 @@
import {
createElement,
Component,
useEffect,
useState,
Fragment,
} from '@wordpress/element'
import ctEvents from 'ct-events'
import { OptionsPanel } from 'blocksy-options'
import nanoid from 'nanoid'
import classnames from 'classnames'
import { __, sprintf } from 'ct-i18n'
import Overlay from '../../../../../static/js/helpers/Overlay'
const ProductReviews = ({ setExtsStatus, extension, onExtsSync }) => {
const [settings, setSettings] = useState(null)
return (
<div className={classnames('ct-extension-options ct-product-reviews-options')}>
<h4>{__('Product Reviews Settings', 'blocksy-companion')}</h4>
<p className="ct-modal-description">
{__(
'Configure the slugs for single and category pages of the product review custom post type.',
'blocksy-companion'
)}
</p>
<form>
<OptionsPanel
onChange={(optionId, optionValue) =>
setSettings((settings) => ({
...settings,
[optionId]: optionValue,
}))
}
options={{
single_slug: {
type: 'text',
value: '',
label: __('Single Slug', 'blocksy-companion'),
},
category_slug: {
type: 'text',
value: '',
label: __('Category Slug', 'blocksy-companion'),
},
}}
value={{
...extension.data.settings,
...(settings || {}),
}}
hasRevertButton={false}
/>
<button
className="ct-button-primary"
disabled={!settings}
onClick={(e) => {
e.preventDefault()
if (!settings) {
return
}
const newSettings = {
...extension.data.settings,
...settings,
}
setExtsStatus((extStatus) => ({
...extStatus,
[extension.name]: {
...extStatus[extension.name],
data: {
...extStatus[extension.name].data,
settings: newSettings,
},
},
}))
onExtsSync({
extAction: {
type: 'persist',
settings: newSettings,
},
})
setSettings(null)
}}>
{__('Save Settings', 'blocksy-companion')}
</button>
</form>
</div>
)
}
export default ProductReviews

View File

@ -0,0 +1,25 @@
import { createElement } from '@wordpress/element'
import { addFilter } from '@wordpress/hooks'
import ProductReviews from './ProductReviews'
import ctEvents from 'ct-events'
addFilter(
'blocksy.extensions.current_extension_content',
'blocksy',
(contentDescriptor, { extension, onExtsSync, setExtsStatus }) => {
if (extension.name !== 'product-reviews') return contentDescriptor
return {
...contentDescriptor,
content: (
<ProductReviews
setExtsStatus={setExtsStatus}
extension={extension}
onExtsSync={onExtsSync}
/>
),
}
}
)

View File

@ -0,0 +1,73 @@
import { applyPrefixFor } from 'blocksy-customizer-sync'
import ctEvents from 'ct-events'
const prefix = 'blc-product-review_single'
ctEvents.on(
'ct:customizer:sync:collect-variable-descriptors',
(allVariables) => {
allVariables.result = {
...allVariables.result,
[`${prefix}_product_scores_width`]: {
selector: applyPrefixFor('.ct-product-scores', prefix),
variable: 'product-scores-width',
unit: 'px',
},
[`${prefix}_star_rating_color`]: [
{
selector: applyPrefixFor('.ct-product-scores', prefix),
variable: 'star-rating-initial-color',
type: 'color:default',
},
{
selector: applyPrefixFor('.ct-product-scores', prefix),
variable: 'star-rating-inactive-color',
type: 'color:inactive',
},
],
[`${prefix}_overall_score_text`]: [
{
selector: applyPrefixFor('.ct-product-scores', prefix),
variable: 'overall-score-text-color',
type: 'color:default',
},
],
[`${prefix}_overall_score_backgroud`]: [
{
selector: applyPrefixFor('.ct-product-scores', prefix),
variable: 'overall-score-box-background',
type: 'color:default',
},
],
}
}
)
const archivePrefix = 'blc-product-review_archive'
ctEvents.on(
'ct:customizer:sync:collect-variable-descriptors',
(allVariables) => {
allVariables.result = {
...allVariables.result,
[`${archivePrefix}_star_rating_color`]: [
{
selector: applyPrefixFor('.star-rating', archivePrefix),
variable: 'star-rating-initial-color',
type: 'color:default',
},
{
selector: applyPrefixFor('.star-rating', archivePrefix),
variable: 'star-rating-inactive-color',
type: 'color:inactive',
},
],
}
}
)

View File

@ -0,0 +1,18 @@
.ct-product-actions-group {
display: flex;
align-items: center;
justify-content: center;
&:not(:last-child) {
margin-bottom: 60px;
}
.ct-button:not(:last-child) {
margin-inline-end: 25px;
}
.ct-icon-container {
color: inherit;
margin-inline-start: 10px;
}
}

View File

@ -0,0 +1,5 @@
.ct-product-description {
&:not(:last-child) {
margin-bottom: 60px;
}
}

View File

@ -0,0 +1,8 @@
.ct-product-reviews-settings-modal {
.ct-controls-group {
padding-top: 30px;
margin-top: 5px;
border-top: 1px dashed #eee;
}
}

View File

@ -0,0 +1,25 @@
@import '../../../../../static/sass/frontend/common-frontend/functions';
@import '../../../../../static/sass/frontend/common-frontend/mixins';
@import 'slider';
@import 'title';
@import 'scores';
@import 'actions';
@import 'description';
@import 'quick-info';
.ct-product-hero {
padding-top: var(--theme-content-vertical-spacing, 60px);
.ct-container {
padding-bottom: var(--theme-content-vertical-spacing, 60px);
border-bottom: 1px solid var(--theme-border-color);
}
ul li {
&:not(:last-child) {
margin-bottom: 0.3em;
}
}
}

View File

@ -0,0 +1,45 @@
.ct-product-info {
display: grid;
grid-template-columns: var(--grid-template-columns);
grid-column-gap: 40px;
grid-row-gap: 40px;
border-top: 1px solid var(--theme-border-color);
padding-top: var(--theme-content-vertical-spacing, 60px);
@include media-breakpoint-up (lg) {
--grid-template-columns: 1.5fr 1fr 1fr;
}
@include media-breakpoint-only (md) {
--grid-template-columns: 1fr 1fr;
}
li {
position: relative;
padding-inline-start: 22px;
}
.ct-icon-container {
position: absolute;
inset-inline-start: 0;
top: 0.4em;
opacity: 0.8;
--theme-icon-size: 13px;
}
}
.ct-specs {
@include media-breakpoint-only (md) {
grid-column: 1/-1;
}
ul {
display: grid;
grid-column-gap: 40px;
@include media-breakpoint-up (md) {
grid-template-columns: repeat(2, 1fr);
}
}
}

View File

@ -0,0 +1,88 @@
.ct-product-scores {
display: grid;
grid-column-gap: 25px;
grid-row-gap: 25px;
margin: 0 auto;
max-width: var(--product-scores-width, 800px);
@include media-breakpoint-up (md) {
grid-template-columns: 2fr 1fr;
}
&:not(:last-child) {
margin-bottom: 60px;
}
li {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
position: relative;
padding: 10px 20px;
&:before {
position: absolute;
z-index: 0;
inset: 0;
content: '';
border-radius: 2px;
opacity: 0.2;
background: var(--theme-border-color);
}
> span {
font-size: 15px;
font-weight: 500;
position: relative;
}
}
}
.ct-overall-score {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 20px;
color: var(--overall-score-text-color, var(--theme-palette-color-8));
border-radius: 2px;
background: var(--overall-score-box-background, var(--theme-palette-color-4));
.ct-average-score {
font-size: 55px;
font-weight: 800;
line-height: normal;
margin-bottom: 10px;
}
.ct-score-label {
font-size: 15px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.02em;
margin: 15px 0 0 0;
}
}
// layer
.ct-overall-score-layer {
display: flex;
flex-wrap: wrap;
align-items: center;
.ct-score-label,
.ct-average-score {
font-size: 14px;
font-weight: 600;
}
.ct-average-score {
margin: 0 5px;
margin-inline-end: auto;
}
.star-rating {
margin: 3px 0;
}
}

View File

@ -0,0 +1,34 @@
.ct-product-hero {
.flexy-container {
overflow: hidden;
}
.flexy-pills {
@include media-breakpoint-down (md) {
--thumbs-spacing: 10px;
}
@include media-breakpoint-up (lg) {
max-width: 70%;
margin: -8% auto 0 auto;
--thumbs-spacing: 20px;
}
ol {
margin: 0 calc(var(--thumbs-spacing) * -1);
}
li {
padding-top: var(--thumbs-spacing);
padding-inline: var(--thumbs-spacing);
img {
width: 100%;
border-radius: 2px;
border: 3px solid #fff;
}
}
}
}

View File

@ -0,0 +1,6 @@
.ct-product-hero {
.hero-section:not(:first-child) {
margin-top: var(--margin-bottom, 40px);
}
}

View File

@ -0,0 +1,310 @@
<?php
$prefix = 'blc-product-review_single';
$atts = apply_filters(
'blocksy:ext:product-reviews:frontend:atts',
blocksy_get_post_options(null, [
'meta_id' => 'blocksy_product_review_options'
]),
get_the_ID()
);
$gallery_images = array_map(function ($item) {
return $item['attachment_id'];
}, blocksy_akg('gallery', $atts, []));
$thumb_id = get_post_thumbnail_id();
if ($thumb_id) {
array_unshift($gallery_images, intval($thumb_id));
} else {
$gallery_images = [];
}
$link_atts = [];
if (blocksy_akg('product_link_sponsored', $atts, 'no') === 'yes') {
$link_atts['rel'] = 'sponsored';
}
if (blocksy_akg('product_link_target', $atts, 'no') === 'yes') {
$link_atts['target'] = '_blank';
if (! isset($link_atts['rel'])) {
$link_atts['rel'] = '';
}
$link_atts['rel'] .= ' noopener noreferrer';
$link_atts['rel'] = trim($link_atts['rel']);
}
echo '<section class="ct-product-hero">';
echo '<div class="ct-container">';
if (count($gallery_images) === 1) {
$attachment_id = $gallery_images[0];
$image_href = wp_get_attachment_image_src(
$attachment_id,
'full'
);
$width = null;
$height = null;
if ($image_href) {
$width = $image_href[1];
$height = $image_href[2];
$image_href = $image_href[0];
}
echo blocksy_media([
'attachment_id' => $gallery_images[0],
'size' => 'full',
'ratio' => apply_filters('blocksy:ext:product-reviews:gallery:ratio', '2/1'),
'tag_name' => 'a',
'html_atts' => array_merge([
'href' => $image_href
], $width ? [
'data-width' => $width,
'data-height' => $height
] : []),
]);
}
if (count($gallery_images) > 1) {
$args = [
'images' => $gallery_images,
'size' => 'full',
'images_ratio' => apply_filters('blocksy:ext:product-reviews:gallery:ratio', '2/1')
];
$args['pills_images'] = $gallery_images;
if (count($gallery_images) <= 5) {
} else {
$args['pills_have_arrows'] = true;
$args['pills_container_attr'] = [
'data-flexy' => 'no'
];
}
echo blocksy_flexy($args);
}
echo blocksy_output_hero_section([
'type' => 'type-1'
]);
$scores = blocksy_akg('scores', $atts, []);
if (! empty($scores)) {
echo '<div class="ct-product-scores">';
echo '<ul>';
foreach ($scores as $single_score) {
echo '<li>';
echo '<span>' . $single_score['label'] . '</span>';
echo '<div class="star-rating" role="img">';
$width = ((floatval($single_score['score']) / 5) * 100);
echo '<span style="width: ' . $width . '%;">Rated <strong class="rating">3</strong> out of 5</span>';
echo '</div>';
echo '</li>';
}
echo '</ul>';
echo '<div class="ct-overall-score" ' . blocksy_schema_org_definitions('reviewRating') . '>';
$avg_score = apply_filters(
'blocksy:ext:product-reviews:overall-score',
round(array_reduce($scores, function ($carry, $score) {
return $carry + floatval($score['score']);
}, 0) / count($scores) * 10) / 10,
$scores
);
echo '<span class="ct-average-score" ' . blocksy_schema_org_definitions('ratingValue') . '>' . $avg_score . '/5</span>';
echo '<div class="star-rating" role="img">';
$width = ( ( $avg_score / 5 ) * 100 );
echo '<span style="width: ' . $width . '%;"></span>';
echo '</div>';
echo '<span class="ct-score-label">';
echo __('Overall Score', 'blocksy-companion');
echo '</span>';
echo '</div>';
echo '</div>';
}
$has_read_more = blocksy_get_theme_mod($prefix . '_has_read_more', 'yes') === 'yes';
$has_buy_now = blocksy_get_theme_mod($prefix . '_has_buy_now', 'yes') === 'yes';
if ($has_read_more || $has_buy_now) {
echo '<div class="ct-product-actions-group">';
$product_link = blocksy_akg('product_link', $atts, '#');
$product_button_label = blocksy_akg(
'product_button_label',
$atts,
__('Buy Now', 'blocksy-companion')
);
$product_read_content_button_label = blocksy_akg(
'product_read_content_button_label',
$atts,
__('Read More', 'blocksy-companion')
);
if (
! empty($product_button_label)
&&
$has_read_more
) {
echo '<a href="#post-' . get_the_ID() . '" class="ct-button">';
echo $product_read_content_button_label;
/*
echo blc_get_icon([
'icon_descriptor' => blocksy_akg('product_read_content_button_icon', $atts, [
'icon' => 'fas fa-arrow-down'
]),
]);
*/
echo '</a>';
}
if (
! empty($product_button_label)
&&
! empty($product_link)
&&
$has_buy_now
) {
echo blocksy_html_tag(
'a',
array_merge([
'href' => esc_url($product_link),
'class' => 'ct-button'
], $link_atts),
$product_button_label
);
/*
echo blc_get_icon([
'icon_descriptor' => blocksy_akg('product_button_icon', $atts, [
'icon' => 'fas fa-cart-arrow-down'
]),
]);
*/
}
echo '</div>';
}
$product_specs = blocksy_akg('product_specs', $atts, []);
$product_pros = blocksy_akg('product_pros', $atts, []);
$product_cons = blocksy_akg('product_cons', $atts, []);
$product_description = blocksy_akg('product_description', $atts, '');
if (! empty($product_description)) {
echo '<div class="ct-product-description" ' . blocksy_schema_org_definitions('reviewBody') . '>';
echo '<div class="entry-content">';
echo do_shortcode($product_description);
echo '</div>';
echo '</div>';
}
if (
! empty($product_specs)
||
! empty($product_pros)
||
! empty($product_cons)
) {
echo '<div class="ct-product-info">';
if (! empty($product_specs)) {
echo '<div class="ct-specs">';
echo '<h5>' . __('Specs', 'blocksy-companion') . '</h5>';
echo '<ul>';
foreach ($product_specs as $single_spec) {
echo '<li>';
echo blocksy_html_tag(
'span',
[
'class' => 'ct-icon-container'
],
"<svg width='13' height='13' viewBox='0 0 13 13'><path d='M5.3 0l-.2 1.7c-.8.2-1.5.7-2.1 1.2l-1.5-.7-1.2 2 1.4 1c-.1.5-.2.9-.2 1.3s.1.8.2 1.2l-1.4 1 1.2 2 1.5-.6c.6.6 1.3 1 2.1 1.2l.2 1.7h2.3l.2-1.7c.8-.2 1.5-.6 2.1-1.2l1.6.7 1.2-2-1.4-1c.1-.4.2-.8.2-1.2s-.1-.8-.2-1.2l1.4-1-1.2-2-1.5.5c-.6-.6-1.3-1-2.1-1.2L7.7 0H5.3zm1.2 4.5c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2z'/></svg>"
);
echo '<b>' . blocksy_akg('label', $single_spec, '') . ': </b>';
echo blocksy_akg('value', $single_spec, '');
echo '</li>';
}
echo '</ul>';
echo '</div>';
}
if (! empty($product_pros)) {
echo '<div class="ct-product-review-pros" ' . blocksy_schema_org_definitions('positiveNotes') . '>';
echo '<h5>' . __('Pros', 'blocksy-companion') . '</h5>';
echo '<ul>';
foreach ($product_pros as $single_pro) {
echo '<li>';
echo blocksy_html_tag(
'span',
[
'class' => 'ct-icon-container'
],
"<svg width='13' height='13' viewBox='0 0 13 13'><path d='M6.4.3c-.3 0-.5.3-.6.5l-.6 1.7-1.7 2c-.3.3-.4.5-.4.9v6c0 .7.6 1.3 1.3 1.3h5.2c.5 0 1-.3 1.1-.7l2-4.4c.2-.3.3-.6.3-.8v-.6c0-.7-.6-1.3-1.3-1.3H7.2s.7-1.6.7-2.7c0-1-.7-1.6-1.2-1.7-.2-.2-.2-.2-.3-.2zM1 4.8c-.5 0-1 .4-1 1v5.9c0 .6.4 1 1 1s1-.4 1-1V5.8c-.1-.5-.5-1-1-1z'/></svg>"
);
echo blocksy_akg('label', $single_pro, '');
echo '</li>';
}
echo '</ul>';
echo '</div>';
}
if (! empty($product_cons)) {
echo '<div class="ct-product-review-cons" ' . blocksy_schema_org_definitions('negativeNotes') . '>';
echo '<h5>' . __('Cons', 'blocksy-companion') . '</h5>';
echo '<ul>';
foreach ($product_cons as $single_cons) {
echo '<li>';
echo blocksy_html_tag(
'span',
[
'class' => 'ct-icon-container'
],
"<svg width='13' height='13' viewBox='0 0 13 13'><path d='M6.6 12.6c.5-.2 1.2-.7 1.2-1.7 0-1.1-.7-2.7-.7-2.7h4.5c.7 0 1.3-.6 1.3-1.3v-.7c0-.3-.1-.5-.2-.8l-2-4.4c-.2-.4-.6-.7-1.1-.7H4.4c-.7 0-1.3.6-1.3 1.3v6c0 .3.1.6.3.9l1.7 2 .5 1.7c.1.3.3.5.6.5s.3 0 .4-.1zM1.9 7.2V1.4c0-.5-.4-1-1-1s-1 .3-1 1v5.9c0 .5.4 1 1 1s1-.6 1-1.1z'/></svg>"
);
echo blocksy_akg('label', $single_cons, '');
echo '</li>';
}
echo '</ul>';
echo '</div>';
}
echo '</div>';
}
echo '</div>';
echo '</section>';

View File

@ -0,0 +1,13 @@
<?php
$config = [
// translators: This is a brand name. Preferably to not be translated
'name' => _x('Trending Posts', 'Extension Brand Name', 'blocksy-companion'),
'description' => __('Highlight your most popular posts or products based on the number of comments or reviews they have gotten in the specified period of time.', 'blocksy-companion'),
'documentation' => 'https://creativethemes.com/blocksy/docs/extensions/trending-posts/',
'video' => 'https://creativethemes.com/blocksy/video-tutorials/customization/exploring-the-trending-posts-extension/',
'customize' => admin_url('customize.php?ct_autofocus=trending_posts_ext'),
'icon' => '<svg width="16" height="16" viewBox="0 0 16 16"><path d="M13 4c-.9-1.5-2.2-2.8-3.2-3.9-.2-.1-.3-.1-.5-.1s-.4.2-.5.3L6.6 5 4.3 3.5c-.2-.1-.3-.2-.5-.1-.2 0-.3.1-.4.2-1.3 2.1-2.1 4.1-2.1 5.7a6.7 6.7 0 0 0 13.4 0c0-1.8-.6-3.5-1.7-5.3zm-.5 5.8c-.3 2.1-2 3.7-4 4h-.1c-.4 0-.6-.3-.6-.6s.2-.6.5-.6c1.5-.2 2.7-1.4 3-3 0-.4.4-.6.7-.6.3.1.6.4.5.8z"/></svg>',
];

View File

@ -0,0 +1,568 @@
<?php
$all_post_types = [
'post' => __('Posts', 'blocksy-companion')
];
if (class_exists('WooCommerce')) {
$all_post_types['product'] = __('Products', 'blocksy-companion');
}
if (function_exists('blocksy_manager')) {
$post_types = blocksy_manager()->post_types->get_supported_post_types();
foreach ($post_types as $single_post_type) {
$post_type_object = get_post_type_object($single_post_type);
if (! $post_type_object) {
continue;
}
$all_post_types[
$single_post_type
] = $post_type_object->labels->singular_name;
}
}
$cpt_options = [];
foreach ($all_post_types as $custom_post_type => $label) {
if ($custom_post_type === 'page') {
continue;
}
$opt_id = 'trending_block_category';
$label = __('Category', 'blocksy-companion');
$label_multiple = __('All categories', 'blocksy-companion');
$taxonomy = 'category';
if ($custom_post_type !== 'post') {
$opt_id = 'trending_block_' . $custom_post_type . '_taxonomy';
$label = __('Taxonomy', 'blocksy-companion');
$label_multiple = __('All taxonomies', 'blocksy-companion');
$taxonomies = get_object_taxonomies($custom_post_type);
if (count($taxonomies) > 0) {
$taxonomy = array_slice($taxonomies, 0, 20);
} else {
$taxonomy = 'nonexistent';
}
}
$categories = get_terms([
'taxonomy' => $taxonomy,
// 'post_type' => $custom_post_type,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => false
]);
$category_choices = [
'all_categories' => $label_multiple
];
if (! is_wp_error($categories)) {
foreach ($categories as $category) {
$category_choices[$category->term_id] = $category->name;
}
}
$cpt_options[blocksy_rand_md5()] = [
'type' => 'ct-condition',
'condition' => [
'trending_block_post_type' => $custom_post_type,
'trending_block_post_source' => '!custom'
],
'options' => [
$opt_id => [
'type' => 'ct-select',
'label' => $label,
'value' => 'all_categories',
'choices' => blocksy_ordered_keys($category_choices),
'design' => 'inline',
'sync' => [
'selector' => '.ct-trending-block',
'render' => function () {
echo blc_get_trending_block();
}
],
],
]
];
}
$options = [
// translators: This is a brand name. Preferably to not be translated
'title' => _x('Trending Posts', 'Extension Brand Name', 'blocksy-companion'),
'container' => [ 'priority' => 8 ],
'options' => [
'trending_posts_section_options' => [
'type' => 'ct-options',
'setting' => [ 'transport' => 'postMessage' ],
'inner-options' => [
blocksy_rand_md5() => [
'type' => 'ct-title',
'label' => __( 'Trending Posts', 'blocksy-companion' ),
],
blocksy_rand_md5() => [
'title' => __( 'General', 'blocksy-companion' ),
'type' => 'tab',
'options' => [
[
[
'trending_block_label' => [
'label' => __( 'Module Title', 'blocksy-companion' ),
'type' => 'text',
'design' => 'inline',
'value' => __( 'Trending now', 'blocksy-companion' ),
'sync' => 'live',
],
'trending_block_label_tag' => [
'label' => __( 'Module Title Tag', 'blocksy-companion' ),
'type' => 'ct-select',
'value' => 'h3',
'view' => 'text',
'design' => 'inline',
'choices' => blocksy_ordered_keys(
[
'h1' => 'H1',
'h2' => 'H2',
'h3' => 'H3',
'h4' => 'H4',
'h5' => 'H5',
'h6' => 'H6',
'p' => 'p',
'span' => 'span',
]
),
'sync' => [
'selector' => '.ct-trending-block',
'render' => function () {
echo blc_get_trending_block();
}
]
],
],
blc_site_has_feature()
? [
'trending_block_icon_source' => [
'label' => __(
'Module Title Icon Source',
'blocksy-companion'
),
'type' => 'ct-radio',
'value' => 'default',
'view' => 'text',
'design' => 'block',
'divider' => 'top',
'sync' => [
'selector' => '.ct-trending-block',
'render' => function () {
echo blc_get_trending_block();
}
],
'choices' => [
'default' => __(
'Default',
'blocksy-companion'
),
'custom' => __(
'Custom',
'blocksy-companion'
),
],
],
blocksy_rand_md5() => [
'type' => 'ct-condition',
'condition' => [
'trending_block_icon_source' => 'custom',
],
'options' => [
'trending_block_custom_icon' => [
'type' => 'icon-picker',
'label' => __(
'Icon',
'blocksy-companion'
),
'design' => 'inline',
'divider' => 'top',
'value' => [
'icon' => 'fas fa-fire',
],
'sync' => [
'selector' => '.ct-trending-block',
'render' => function () {
echo blc_get_trending_block();
}
]
],
],
],
]
: [],
'trending_block_post_type' => count($all_post_types) > 1 ? [
'label' => __( 'Post Type', 'blocksy-companion' ),
'type' => 'ct-select',
'value' => 'post',
'design' => 'inline',
'divider' => 'top:full',
'setting' => [ 'transport' => 'postMessage' ],
'choices' => blocksy_ordered_keys($all_post_types),
'sync' => [
'selector' => '.ct-trending-block',
'render' => function () {
echo blc_get_trending_block();
}
],
] : [
'label' => __('Post Type', 'blocksy-companion'),
'type' => 'hidden',
'value' => 'post',
'design' => 'none',
'setting' => ['transport' => 'postMessage'],
],
'trending_block_post_source' => [
'type' => 'ct-select',
'label' => __( 'Source', 'blocksy-companion' ),
'value' => 'categories',
'design' => 'inline',
'choices' => blocksy_ordered_keys(
[
'categories' => __('Taxonomies', 'blocksy-companion'),
'custom' => __( 'Custom Query', 'blocksy-companion' ),
]
),
'sync' => [
'selector' => '.ct-trending-block',
'render' => function () {
echo blc_get_trending_block();
}
],
],
],
$cpt_options,
[
blocksy_rand_md5() => [
'type' => 'ct-condition',
'condition' => [
'trending_block_post_source' => 'custom'
],
'options' => [
'trending_block_post_id' => [
'label' => __( 'Posts ID', 'blocksy-companion' ),
'type' => 'text',
'design' => 'inline',
'desc' => blc_safe_sprintf(
__('Separate posts ID by comma. How to find the %spost ID%s.', 'blocksy-companion'),
'<a href="https://www.wpbeginner.com/beginners-guide/how-to-find-post-category-tag-comments-or-user-id-in-wordpress/" target="_blank">',
'</a>'
),
'sync' => [
'selector' => '.ct-trending-block',
'render' => function () {
echo blc_get_trending_block();
}
],
],
],
],
'trending_block_filter' => [
'label' => __( 'Trending From', 'blocksy-companion' ),
'type' => 'ct-select',
'divider' => 'top',
'value' => 'all_time',
'view' => 'text',
'design' => 'inline',
'setting' => [ 'transport' => 'postMessage' ],
'choices' => blocksy_ordered_keys(
[
'all_time' => __( 'All Time', 'blocksy-companion' ),
'last_24_hours' => __( 'Last 24 Hours', 'blocksy-companion' ),
'last_7_days' => __( 'Last 7 Days', 'blocksy-companion' ),
'last_month' => __( 'Last Month', 'blocksy-companion' ),
]
),
'sync' => [
'selector' => '.ct-trending-block',
'render' => function () {
echo blc_get_trending_block();
}
],
],
'trending_block_thumbnails_size' => [
'label' => __('Image Size', 'blocksy-companion'),
'type' => 'ct-select',
'value' => 'thumbnail',
'view' => 'text',
'design' => 'inline',
'divider' => 'top',
'choices' => blocksy_ordered_keys(
blocksy_get_all_image_sizes()
),
'sync' => [
'selector' => '.ct-trending-block',
'render' => function () {
echo blc_get_trending_block();
}
],
],
blocksy_rand_md5() => [
'type' => 'ct-divider',
],
'trending_block_visibility' => [
'label' => __( 'Container Visibility', 'blocksy-companion' ),
'type' => 'ct-visibility',
'design' => 'block',
'sync' => 'live',
'value' => [
'desktop' => true,
'tablet' => true,
'mobile' => false,
],
'choices' => blocksy_ordered_keys([
'desktop' => __( 'Desktop', 'blocksy-companion' ),
'tablet' => __( 'Tablet', 'blocksy-companion' ),
'mobile' => __( 'Mobile', 'blocksy-companion' ),
]),
],
],
blc_site_has_feature() ? [
'trending_block_location' => [
'label' => __('Display Location', 'blocksy-companion'),
'type' => 'ct-select',
'design' => 'inline',
'divider' => 'top',
'value' => 'blocksy:content:bottom',
'choices' => [
[
'key' => 'blocksy:content:bottom',
'value' => __('Before Footer', 'blocksy-companion')
],
[
'key' => 'blocksy:footer:after',
'value' => __('After Footer', 'blocksy-companion')
],
[
'key' => 'blocksy:header:after',
'value' => __('After Header', 'blocksy-companion')
]
]
],
'trending_block_conditions' => [
'label' => __('Display Conditions', 'blocksy-companion'),
'type' => 'blocksy-display-condition',
'divider' => 'top',
'value' => [
[
'type' => 'include',
'rule' => 'everywhere',
]
],
'display' => 'modal',
'modalTitle' => __('Trending Block Display Conditions', 'blocksy-companion'),
'modalDescription' => __('Add one or more conditions to display the trending block.', 'blocksy-companion'),
'design' => 'block',
'sync' => 'live'
],
] : [],
],
],
blocksy_rand_md5() => [
'title' => __( 'Design', 'blocksy-companion' ),
'type' => 'tab',
'options' => [
'trendingBlockHeadingFont' => [
'type' => 'ct-typography',
'label' => __( 'Module Title Font', 'blocksy-companion' ),
'value' => blocksy_typography_default_values([
'size' => '15px',
]),
'setting' => [ 'transport' => 'postMessage' ],
],
'trendingBlockHeadingFontColor' => [
'label' => __( 'Module Title Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'block:right',
'responsive' => true,
'sync' => 'live',
'divider' => 'bottom',
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
'inherit' => [
'var(--theme-heading-1-color, var(--theme-headings-color))' => [
'trending_block_label_tag' => 'h1'
],
'var(--theme-heading-2-color, var(--theme-headings-color))' => [
'trending_block_label_tag' => 'h2'
],
'var(--theme-heading-3-color, var(--theme-headings-color))' => [
'trending_block_label_tag' => 'h3'
],
'var(--theme-heading-4-color, var(--theme-headings-color))' => [
'trending_block_label_tag' => 'h4'
],
'var(--theme-heading-5-color, var(--theme-headings-color))' => [
'trending_block_label_tag' => 'h5'
],
'var(--theme-heading-6-color, var(--theme-headings-color))' => [
'trending_block_label_tag' => 'h6'
],
'var(--theme-text-color)' => [
'trending_block_label_tag' => 'span|p'
],
]
],
],
],
'trendingBlockPostsFont' => [
'type' => 'ct-typography',
'label' => __( 'Posts Title Font', 'blocksy-companion' ),
'value' => blocksy_typography_default_values([
'size' => '15px',
'variation' => 'n5',
]),
'setting' => [ 'transport' => 'postMessage' ],
],
'trendingBlockFontColor' => [
'label' => __( 'Posts Title Font Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'block:right',
'responsive' => true,
'sync' => 'live',
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
'hover' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
'inherit' => 'var(--theme-text-color)'
],
[
'title' => __( 'Hover', 'blocksy-companion' ),
'id' => 'hover',
'inherit' => 'var(--theme-link-hover-color)'
],
],
],
'trendingBlockArrowsColor' => [
'label' => __( 'Arrows Color', 'blocksy-companion' ),
'type' => 'ct-color-picker',
'design' => 'block:right',
'responsive' => true,
'divider' => 'top',
'sync' => 'live',
'value' => [
'default' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
'hover' => [
'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT'),
],
],
'pickers' => [
[
'title' => __( 'Initial', 'blocksy-companion' ),
'id' => 'default',
'inherit' => 'var(--theme-text-color)'
],
[
'title' => __( 'Hover', 'blocksy-companion' ),
'id' => 'hover',
'inherit' => 'var(--theme-link-hover-color)'
],
],
],
'trending_block_background' => [
'label' => __( 'Container Background', 'blocksy-companion' ),
'type' => 'ct-background',
'design' => 'block:right',
'responsive' => true,
'divider' => 'top',
'sync' => 'live',
'value' => blocksy_background_default_value([
'backgroundColor' => [
'default' => [
'color' => 'var(--theme-palette-color-5)',
],
],
])
],
'trendingBlockContainerSpacing' => [
'label' => __( 'Container Inner Spacing', 'blocksy-companion' ),
'type' => 'ct-slider',
'divider' => 'top',
'value' => '30px',
'units' => blocksy_units_config([
[
'unit' => 'px',
'min' => 0,
'max' => 100,
],
]),
'responsive' => true,
'sync' => 'live',
],
],
],
]
]
]
];

View File

@ -0,0 +1,134 @@
<?php
require_once dirname(__FILE__) . '/helpers.php';
class BlocksyExtensionTrending {
private $result = null;
public function __construct() {
add_action('wp_enqueue_scripts', function () {
if (! function_exists('get_plugin_data')) {
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
$data = get_plugin_data(BLOCKSY__FILE__);
if (is_admin()) {
return;
}
wp_enqueue_style(
'blocksy-ext-trending-styles',
BLOCKSY_URL . 'framework/extensions/trending/static/bundle/main.min.css',
['ct-main-styles'],
$data['Version']
);
}, 50);
add_filter('blocksy:frontend:dynamic-js-chunks', function ($chunks) {
$chunks[] = [
'id' => 'blocksy_ext_trending',
'selector' => '.ct-trending-block [class*="ct-arrow"]',
'url' => blocksy_cdn_url(
BLOCKSY_URL . 'framework/extensions/trending/static/bundle/main.js'
),
'trigger' => 'click'
];
return $chunks;
});
add_filter(
'blocksy_extensions_customizer_options',
function ($opts) {
$opts['trending_posts_ext'] = blocksy_get_options(
dirname(__FILE__) . '/customizer.php',
[],
false
);
return $opts;
}
);
add_action('wp', function () {
$location = 'blocksy:template:after';
if (blc_site_has_feature()) {
$location = blocksy_get_theme_mod(
'trending_block_location',
'blocksy:content:bottom'
);
}
$this->result = blc_get_trending_posts_value();
add_action(
$location,
function () {
if (blc_site_has_feature()) {
$conditions = blocksy_get_theme_mod(
'trending_block_conditions',
[
[
'type' => 'include',
'rule' => 'everywhere',
]
]
);
$conditions_manager = new \Blocksy\ConditionsManager();
if (! $conditions_manager->condition_matches($conditions)) {
return;
}
}
echo blc_get_trending_block($this->result);
},
50
);
});
add_action(
'customize_preview_init',
function () {
if (! function_exists('get_plugin_data')) {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
}
$data = get_plugin_data(BLOCKSY__FILE__);
wp_enqueue_script(
'blocksy-trending-customizer-sync',
BLOCKSY_URL . 'framework/extensions/trending/static/bundle/sync.js',
['customize-preview', 'ct-scripts', 'ct-customizer'],
$data['Version'],
true
);
}
);
add_action(
'blocksy:global-dynamic-css:enqueue',
'BlocksyExtensionTrending::add_global_styles',
10, 3
);
}
static public function add_global_styles($args) {
blocksy_theme_get_dynamic_styles(array_merge([
'path' => dirname(__FILE__) . '/global.php',
'chunk' => 'global',
], $args));
}
static public function onDeactivation() {
remove_action(
'blocksy:global-dynamic-css:enqueue',
'BlocksyExtensionTrending::add_global_styles',
10, 3
);
}
}

View File

@ -0,0 +1,122 @@
<?php
blocksy_output_font_css([
'font_value' => blocksy_get_theme_mod( 'trendingBlockHeadingFont',
blocksy_typography_default_values([
'size' => '15px',
])
),
'css' => $css,
'tablet_css' => $tablet_css,
'mobile_css' => $mobile_css,
'selector' => '.ct-trending-block .ct-module-title',
]);
blocksy_output_colors([
'value' => blocksy_get_theme_mod('trendingBlockHeadingFontColor'),
'default' => [
'default' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
],
'css' => $css,
'tablet_css' => $tablet_css,
'mobile_css' => $mobile_css,
'variables' => [
'default' => [
'selector' => '.ct-trending-block .ct-module-title',
'variable' => 'theme-heading-color'
],
],
'responsive' => true,
]);
blocksy_output_font_css([
'font_value' => blocksy_get_theme_mod( 'trendingBlockPostsFont',
blocksy_typography_default_values([
'size' => '15px',
'variation' => 'n5',
])
),
'css' => $css,
'tablet_css' => $tablet_css,
'mobile_css' => $mobile_css,
'selector' => '.ct-trending-block .ct-post-title',
]);
blocksy_output_colors([
'value' => blocksy_get_theme_mod('trendingBlockFontColor'),
'default' => [
'default' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
'hover' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
],
'css' => $css,
'tablet_css' => $tablet_css,
'mobile_css' => $mobile_css,
'variables' => [
'default' => [
'selector' => '.ct-trending-block a',
'variable' => 'theme-text-color'
],
'hover' => [
'selector' => '.ct-trending-block a',
'variable' => 'theme-link-hover-color'
],
],
'responsive' => true,
]);
blocksy_output_colors([
'value' => blocksy_get_theme_mod('trendingBlockArrowsColor'),
'default' => [
'default' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
'hover' => [ 'color' => Blocksy_Css_Injector::get_skip_rule_keyword('DEFAULT') ],
],
'css' => $css,
'tablet_css' => $tablet_css,
'mobile_css' => $mobile_css,
'variables' => [
'default' => [
'selector' => '.ct-trending-block [class*="ct-arrow"]',
'variable' => 'theme-text-color'
],
'hover' => [
'selector' => '.ct-trending-block [class*="ct-arrow"]',
'variable' => 'theme-link-hover-color'
],
],
'responsive' => true,
]);
blocksy_output_background_css([
'selector' => '.ct-trending-block',
'css' => $css,
'tablet_css' => $tablet_css,
'mobile_css' => $mobile_css,
'value' => blocksy_get_theme_mod(
'trending_block_background',
blocksy_background_default_value([
'backgroundColor' => [
'default' => [
'color' => 'var(--theme-palette-color-5)'
],
],
])
),
'responsive' => true,
]);
$container_inner_spacing = blocksy_get_theme_mod( 'trendingBlockContainerSpacing', '30px' );
if ($container_inner_spacing !== '30px') {
blocksy_output_responsive([
'css' => $css,
'tablet_css' => $tablet_css,
'mobile_css' => $mobile_css,
'selector' => ".ct-trending-block",
'variableName' => 'padding',
'value' => $container_inner_spacing,
'unit' => ''
]);
}

View File

@ -0,0 +1,295 @@
<?php
add_action('wp_ajax_blocksy_get_trending_posts', 'blc_get_trending_posts');
add_action('wp_ajax_nopriv_blocksy_get_trending_posts', 'blc_get_trending_posts');
if (! function_exists('blc_get_trending_posts')) {
function blc_get_trending_posts() {
if (! isset($_REQUEST['page'])) {
wp_send_json_error();
}
$page = intval(sanitize_text_field($_REQUEST['page']));
if (! $page) {
wp_send_json_error();
}
wp_send_json_success([
'posts' => blc_get_trending_posts_value([
'paged' => $page
])
]);
}
}
if (! function_exists('blc_get_trending_posts_value')) {
function blc_get_trending_posts_value($args = []) {
$args = wp_parse_args(
$args,
[
'paged' => 1
]
);
$date_query = [];
$date_filter = blocksy_get_theme_mod('trending_block_filter', 'all_time');
if ($date_filter && 'all_time' !== $date_filter) {
$days = [
'last_24_hours' => 1,
'last_7_days' => 7,
'last_month' => 30
][$date_filter];
if (! $days) {
$days = 30;
}
$time = time() - (intval($days) * 24 * 60 * 60);
$date_query = array(
'after' => [
'year' => date('Y', $time),
'month' => date('n', $time),
'days' => date('j', $time),
],
'before' => [
'year' => date('Y'),
'month' => date('n'),
'days' => date('j'),
],
'inclusive' => true,
);
}
$post_type = blocksy_get_theme_mod('trending_block_post_type', 'post');
if ($post_type === 'product' && ! class_exists('WooCommerce')) {
$post_type = 'post';
}
$source = blocksy_get_theme_mod('trending_block_post_source', 'categories');
$query_args = [
'post_type' => $post_type,
'order' => 'DESC',
'posts_per_page' => 4,
'orderby' => 'comment_count',
'paged' => $args['paged'],
'ignore_sticky_posts' => true,
'post_status' => 'publish'
];
if ($source === 'categories') {
$query_args['date_query'] = $date_query;
$cat_option_id = 'trending_block_category';
if ($post_type !== 'post') {
$cat_option_id = 'trending_block_' . $post_type . '_taxonomy';
}
$cat_id = blocksy_get_theme_mod($cat_option_id, 'all_categories');
$cat_id = (empty($cat_id) || 'all_categories' === $cat_id) ? '' : $cat_id;
if (! empty($cat_id)) {
$terms = get_terms(['include' => $cat_id]);
if (! empty($terms)) {
$query_args['tax_query'] = [
[
'taxonomy' => $terms[0]->taxonomy,
'field' => 'term_id',
'terms' => [$cat_id]
]
];
}
}
}
if ($source === 'custom') {
$post_id = blocksy_get_theme_mod('trending_block_post_id', '');
$query_args['orderby'] = 'post__in';
$query_args['post__in'] = ['__INEXISTING__'];
if (! empty(trim($post_id))) {
$query_args['post__in'] = explode(',', str_replace(' ', '', trim(
$post_id
)));
}
}
$query = new WP_Query(apply_filters(
'blocksy:trending-posts:query-args',
$query_args
));
if (! $query->have_posts()) {
return [
'posts' => [],
'is_last_page' => false
];
}
$result = [];
while ($query->have_posts()) {
$query->the_post();
$individual_entry = [
'id' => get_the_ID(),
'attachment_id' => get_post_thumbnail_id(),
'title' => get_the_title(),
'url' => get_permalink(),
'image' => ''
];
if (get_post_thumbnail_id()) {
$individual_entry['image'] = blocksy_media(
[
'attachment_id' => get_post_thumbnail_id(),
'size' => blocksy_get_theme_mod(
'trending_block_thumbnails_size',
'thumbnail'
),
'ratio' => '1/1',
'tag_name' => 'div',
]
);
}
$result[] = $individual_entry;
}
$is_last = intval($query->max_num_pages) === intval($args['paged']);
wp_reset_postdata();
return [
'posts' => $result,
'is_last_page' => $is_last
];
}
}
if (! function_exists('blc_get_trending_block')) {
function blc_get_trending_block($result = null) {
if (! $result) {
$result = blc_get_trending_posts_value();
}
if (empty($result['posts'])) {
return '';
}
ob_start();
$data_page = 'data-page="1"';
if ($result['is_last_page']) {
$data_page = '';
}
$class = 'ct-trending-block';
$class .= ' ' . blocksy_visibility_classes(
blocksy_get_theme_mod('trending_block_visibility', [
'desktop' => true,
'tablet' => true,
'mobile' => false,
])
);
$attr = [
'class' => $class
];
if (is_customize_preview()) {
$attr['data-shortcut'] = 'border';
$attr['data-shortcut-location'] = 'trending_posts_ext';
}
$label_tag = blocksy_get_theme_mod('trending_block_label_tag', 'h3');
$trending_label = blocksy_get_theme_mod(
'trending_block_label',
__('Trending now', 'blocksy-companion')
);
$icon = '<svg width="13" height="13" viewBox="0 0 13 13" fill="currentColor"><path d="M13 5.8V9c0 .4-.2.6-.5.6s-.5-.2-.5-.5V7.2l-4.3 4.2c-.2.2-.6.2-.8 0L4.6 9.1.9 12.8c-.1.1-.2.2-.4.2s-.3-.1-.4-.2c-.2-.2-.2-.6 0-.8l4.1-4.1c.2-.2.6-.2.8 0l2.3 2.3 3.8-3.8H9.2c-.3 0-.5-.2-.5-.5s.2-.5.5-.5h3.4c.2 0 .3.1.4.2v.2z"/></svg>';
if (function_exists('blc_get_icon')) {
$icon_source = blocksy_get_theme_mod('trending_block_icon_source', 'default');
if ($icon_source === 'custom') {
$icon = blc_get_icon([
'icon_descriptor' => blocksy_get_theme_mod('trending_block_custom_icon', [
'icon' => 'fas fa-fire',
]),
'icon_container' => false,
'icon_html_atts' => [
'width' => '13',
'height' => '13',
'fill' => 'currentColor'
]
]);
}
}
?>
<section <?php echo blocksy_attr_to_html($attr) ?>>
<div class="ct-container" <?php echo $data_page ?>>
<<?php echo $label_tag ?> class="ct-module-title">
<?php
echo $trending_label;
/**
* Note to code reviewers: This line doesn't need to be escaped.
* The value used here escapes the value properly.
* It contains an inline SVG, which is safe.
*/
echo $icon;
?>
<?php if (! $result['is_last_page']) { ?>
<span class="ct-arrow-left">
</span>
<span class="ct-arrow-right">
</span>
<?php } ?>
</<?php echo $label_tag ?>>
<?php
foreach ($result['posts'] as $post) {
echo blocksy_html_tag(
'a',
[
'href' => $post['url'],
],
$post['image'] . blocksy_html_tag(
'span',
[
'class' => 'ct-post-title',
],
$post['title']
)
);
}
?>
</div>
</section>
<?php
return ob_get_clean();
}
}

View File

@ -0,0 +1 @@
!function(){"use strict";function t(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||n(t)||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 e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],r=!0,o=!1,a=void 0;try{for(var c,i=t[Symbol.iterator]();!(r=(c=i.next()).done)&&(n.push(c.value),!e||n.length!==e);r=!0);}catch(t){o=!0,a=t}finally{try{r||null==i.return||i.return()}finally{if(o)throw a}}return n}(t,e)||n(t,e)||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(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function o(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function a(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var c={},i=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(n=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?o(Object(n),!0).forEach((function(e){a(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({el:null,action:null},n),n.el&&n.action&&!n.el.classList.contains("ct-loading")){var r=parseInt(n.el.dataset.page,10);if(("prev"!==n.action||1!==r)&&!(n.el.querySelectorAll(".ct-container > a").length<4&&1===r||n.el.dataset.page.indexOf("last")>-1&&"next"===n.action)){n.el.classList.add("ct-loading");var i,l="prev"===n.action?r-1:r+1;Promise.all([new Promise((function(t){n.el.classList.add("ct-leave-active"),requestAnimationFrame((function(){n.el.classList.remove("ct-leave-active"),n.el.classList.add("ct-leave"),setTimeout((function(){return t()}),650)}))})),(i="".concat(ct_localizations.ajax_url,"?action=blocksy_get_trending_posts&page=").concat(l),c[i]?new Promise((function(t){t(c[i]),window.ct_customizer_localizations||(c[i]=c[i].clone())})):new Promise((function(t){return fetch(i).then((function(e){t(e),window.ct_customizer_localizations||(c[i]=e.clone())}))}))).then((function(t){return t.json()}))]).then((function(r){var o=e(r,2),a=(o[0],o[1]),c=a.success,i=a.data;if(c){var s=i.posts,u=s.is_last_page,f=s.posts;n.el.dataset.page="".concat(l).concat(u?":last":""),t(n.el.querySelectorAll("a")).map((function(t){return t.remove()})),f.map((function(t){return n.el.insertAdjacentHTML("beforeend",'<a href="'.concat(t.url,'">\n ').concat(t.image,'\n <span class="ct-post-title">\n ').concat(t.title,"\n </span>\n </a>"))})),setTimeout((function(){n.el.classList.remove("ct-leave"),n.el.classList.add("ct-enter-active"),requestAnimationFrame((function(){n.el.classList.remove("ct-enter-active"),n.el.classList.add("ct-active"),setTimeout((function(){n.el.classList.remove("ct-active"),n.el.classList.remove("ct-loading")}),650)}))}),50)}}))}}};(0,window.ctFrontend.registerDynamicChunk)("blocksy_ext_trending",{mount:function(t,e){e.event;var n=t.closest("[data-page]");t.classList.contains("ct-arrow-left")&&i({el:n,action:"prev"}),t.classList.contains("ct-arrow-right")&&i({el:n,action:"next"})}})}();

View File

@ -0,0 +1,8 @@
/**
* - v2.0.37
*
* Copyright (c) 2024
* Licensed GPLv2+
*/
.ct-trending-block{padding:var(--padding, 30px) 0}.ct-trending-block>div{display:grid;grid-template-columns:var(--grid-template-columns);grid-column-gap:30px;grid-row-gap:20px;margin-bottom:5px}@media(min-width: 690px)and (max-width: 999.98px){.ct-trending-block>div{--grid-template-columns: repeat(2, 1fr)}}@media(min-width: 1000px){.ct-trending-block>div{--grid-template-columns: repeat(4, 1fr)}}.ct-trending-block>div.ct-leave-active>a,.ct-trending-block>div.ct-leave>a{transition:opacity .3s ease,transform .3s ease}.ct-trending-block>div.ct-leave-active>a:nth-of-type(1),.ct-trending-block>div.ct-leave>a:nth-of-type(1){transition-delay:0s}.ct-trending-block>div.ct-leave-active>a:nth-of-type(2),.ct-trending-block>div.ct-leave>a:nth-of-type(2){transition-delay:.15s}.ct-trending-block>div.ct-leave-active>a:nth-of-type(3),.ct-trending-block>div.ct-leave>a:nth-of-type(3){transition-delay:.25s}.ct-trending-block>div.ct-leave-active>a:nth-of-type(4),.ct-trending-block>div.ct-leave>a:nth-of-type(4){transition-delay:.35s}.ct-trending-block>div.ct-leave-active>a{opacity:1;transform:translateY(0)}.ct-trending-block>div.ct-leave>a{opacity:0;transform:translateY(3px)}.ct-trending-block>div.ct-enter-active>a,.ct-trending-block>div.ct-active>a{transition:opacity .3s ease,transform .3s ease}.ct-trending-block>div.ct-enter-active>a:nth-of-type(1),.ct-trending-block>div.ct-active>a:nth-of-type(1){transition-delay:0s}.ct-trending-block>div.ct-enter-active>a:nth-of-type(2),.ct-trending-block>div.ct-active>a:nth-of-type(2){transition-delay:.15s}.ct-trending-block>div.ct-enter-active>a:nth-of-type(3),.ct-trending-block>div.ct-active>a:nth-of-type(3){transition-delay:.25s}.ct-trending-block>div.ct-enter-active>a:nth-of-type(4),.ct-trending-block>div.ct-active>a:nth-of-type(4){transition-delay:.35s}.ct-trending-block>div.ct-enter-active>a{opacity:0;transform:translateY(3px)}.ct-trending-block>div.ct-active>a{opacity:1;transform:translateY(0)}.ct-trending-block .ct-module-title{grid-column:1/-1;display:flex;align-items:center;margin-bottom:10px}.ct-trending-block .ct-module-title>svg{margin-inline-start:10px}.ct-trending-block a{display:flex;align-items:center;--theme-link-initial-color: var(--theme-text-color)}.ct-trending-block .ct-media-container{flex:0 0 60px;border-radius:100%;margin-inline-end:20px;-webkit-mask-image:-webkit-radial-gradient(white, black)}.ct-trending-block .ct-post-title{word-break:break-word}.ct-trending-block [class*=ct-arrow]{display:flex;align-items:center;justify-content:center;width:23px;height:23px;cursor:pointer;background:rgba(0,0,0,0);border-radius:2px;opacity:.5;color:var(--theme-text-color);border:1px solid currentColor;transition:var(--theme-transition)}.ct-trending-block [class*=ct-arrow]:before{content:"";width:5px;height:5px;border:1px solid currentColor;border-right:none;border-bottom:none}.ct-trending-block [class*=ct-arrow]:hover{opacity:1;color:#fff;border-color:var(--theme-link-hover-color);background:var(--theme-link-hover-color)}.ct-trending-block .ct-arrow-left{margin-inline-start:auto;margin-inline-end:8px;padding-inline-start:1px}.ct-trending-block .ct-arrow-left:before{transform:rotate(-45deg)}.ct-trending-block .ct-arrow-right{padding-inline-end:1px}.ct-trending-block .ct-arrow-right:before{transform:rotate(135deg)}.ct-trending-block [data-page="1"] .ct-arrow-left,.ct-trending-block [data-page*=last] .ct-arrow-right{opacity:.2;pointer-events:none}

View File

@ -0,0 +1 @@
!function(){"use strict";var e={n:function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,{a:r}),r},d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t=window.blocksyCustomizerSync,r=window.ctEvents;function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}e.n(r)().on("ct:customizer:sync:collect-variable-descriptors",(function(e){e.result=o(o(o(o(o({},(0,t.typographyOption)({id:"trendingBlockHeadingFont",selector:".ct-trending-block .ct-module-title"})),{},{trendingBlockHeadingFontColor:{selector:".ct-trending-block .ct-module-title",variable:"theme-heading-color",type:"color",responsive:!0}},(0,t.typographyOption)({id:"trendingBlockPostsFont",selector:".ct-trending-block .ct-post-title"})),{},{trendingBlockFontColor:[{selector:".ct-trending-block a",variable:"theme-text-color",type:"color:default",responsive:!0},{selector:".ct-trending-block a",variable:"theme-link-hover-color",type:"color:hover",responsive:!0}],trendingBlockArrowsColor:[{selector:'.ct-trending-block [class*="ct-arrow"]',variable:"theme-text-color",type:"color:default",responsive:!0},{selector:'.ct-trending-block [class*="ct-arrow"]',variable:"theme-link-hover-color",type:"color:hover",responsive:!0}]},(0,t.handleBackgroundOptionFor)({id:"trending_block_background",selector:".ct-trending-block",responsive:!0})),e.result),{},{trendingBlockContainerSpacing:{selector:".ct-trending-block",variable:"padding",responsive:!0,unit:""}})})),wp.customize("trending_block_visibility",(function(e){return e.bind((function(e){return(0,t.responsiveClassesFor)("trending_block_visibility",document.querySelector(".ct-trending-block"))}))})),wp.customize("trending_block_label",(function(e){return e.bind((function(e){var t=document.querySelector(".ct-trending-block .ct-module-title");if(t){var r=t.innerHTML.split("<svg");r[0]=e,t.innerHTML=r.join("<svg")}}))}))}();

View File

@ -0,0 +1,16 @@
import { loadPage } from './trending-block'
import { registerDynamicChunk } from 'blocksy-frontend'
registerDynamicChunk('blocksy_ext_trending', {
mount: (el, { event }) => {
const loadingEl = el.closest('[data-page]')
if (el.classList.contains('ct-arrow-left')) {
loadPage({ el: loadingEl, action: 'prev' })
}
if (el.classList.contains('ct-arrow-right')) {
loadPage({ el: loadingEl, action: 'next' })
}
},
})

Some files were not shown because too many files have changed in this diff Show More