Add initial files and structure for Essential Addons for Elementor Lite plugin

This commit is contained in:
2025-01-17 00:40:58 +01:00
parent ae5052c407
commit d2ed11bf1b
524 changed files with 258494 additions and 2310 deletions

View File

@@ -0,0 +1,702 @@
<?php
namespace Essential_Addons_Elementor\Traits;
if ( !defined( 'ABSPATH' ) ) {
exit();
}
// Exit if accessed directly
use Essential_Addons_Elementor\Classes\Helper as HelperClass;
use Essential_Addons_Elementor\Classes\WPDeveloper_Notice;
use PriyoMukul\WPNotice\Notices;
use PriyoMukul\WPNotice\Utils\CacheBank;
use PriyoMukul\WPNotice\Utils\NoticeRemover;
trait Admin {
private static $cache_bank = null;
/**
* Create an admin menu.
*
* @since 1.1.2
*/
public function admin_menu() {
$menu_notice = '';
$menu_notice = ( $this->menu_notice_should_show() ) ?'<span class="eael-menu-notice">1</span>':'';
add_menu_page(
__( 'Essential Addons a', 'essential-addons-for-elementor-lite' ),
sprintf(__( 'Essential Addons %s', 'essential-addons-for-elementor-lite' ), $menu_notice ),
'manage_options',
'eael-settings',
[$this, 'admin_settings_page'],
$this->safe_url( EAEL_PLUGIN_URL . 'assets/admin/images/ea-icon-white.svg' ),
'58.6'
);
}
/**
* Loading all essential scripts
*
* @since 1.1.2
*/
public function admin_enqueue_scripts( $hook ) {
wp_enqueue_style( 'essential_addons_elementor-notice-css', EAEL_PLUGIN_URL . 'assets/admin/css/notice.css', false, EAEL_PLUGIN_VERSION );
if ( $hook == 'essential-addons_page_template-cloud' ) {
wp_enqueue_style( 'essential_addons_elementor-template-cloud-css', EAEL_PLUGIN_URL . 'assets/admin/css/cloud.css', false, EAEL_PLUGIN_VERSION );
}
if ( isset( $hook ) && $hook == 'toplevel_page_eael-settings' ) {
wp_enqueue_style( 'essential_addons_elementor-admin-css', EAEL_PLUGIN_URL . 'assets/admin/css/admin.css', false, EAEL_PLUGIN_VERSION );
if ( $this->pro_enabled ) {
wp_enqueue_style( 'eael_pro-admin-css', EAEL_PRO_PLUGIN_URL . 'assets/admin/css/admin.css', false, EAEL_PRO_PLUGIN_VERSION );
}
wp_enqueue_style( 'sweetalert2-css', EAEL_PLUGIN_URL . 'assets/admin/vendor/sweetalert2/css/sweetalert2.min.css', false, EAEL_PLUGIN_VERSION );
wp_enqueue_script( 'sweetalert2-js', EAEL_PLUGIN_URL . 'assets/admin/vendor/sweetalert2/js/sweetalert2.min.js', array( 'jquery', 'sweetalert2-core-js' ), EAEL_PLUGIN_VERSION, true );
wp_enqueue_script( 'sweetalert2-core-js', EAEL_PLUGIN_URL . 'assets/admin/vendor/sweetalert2/js/core.js', array( 'jquery' ), EAEL_PLUGIN_VERSION, true );
wp_enqueue_script( 'essential_addons_elementor-admin-js', EAEL_PLUGIN_URL . 'assets/admin/js/admin.js', array( 'jquery' ), EAEL_PLUGIN_VERSION, true );
//Internationalizing JS string translation
$i18n = [
'login_register' => [
//m=modal, rm=response modal, r=reCAPTCHA, g= google, f=facebook, e=error
'm_title' => __( 'Login | Register Form Settings', 'essential-addons-for-elementor-lite' ),
'm_footer' => $this->pro_enabled ? __( 'To configure the API Keys, check out this doc', 'essential-addons-for-elementor-lite' ) : __( 'To retrieve your API Keys, click here', 'essential-addons-for-elementor-lite' ),
'save' => __( 'Save', 'essential-addons-for-elementor-lite' ),
'cancel' => __( 'Cancel', 'essential-addons-for-elementor-lite' ),
'rm_title' => __( 'Login | Register Form Settings Saved', 'essential-addons-for-elementor-lite' ),
'rm_footer' => __( 'Reload the page to see updated data', 'essential-addons-for-elementor-lite' ),
'e_title' => __( 'Oops...', 'essential-addons-for-elementor-lite' ),
'e_text' => __( 'Something went wrong!', 'essential-addons-for-elementor-lite' ),
'r_title' => __( 'reCAPTCHA v2', 'essential-addons-for-elementor-lite' ),
'r_sitekey' => __( 'Site Key', 'essential-addons-for-elementor-lite' ),
'r_sitesecret' => __( 'Site Secret', 'essential-addons-for-elementor-lite' ),
'r_language' => __( 'Language', 'essential-addons-for-elementor-lite' ),
'r_language_ph'=> __( 'reCAPTCHA Language Code', 'essential-addons-for-elementor-lite' ),
'g_title' => __( 'Google Login', 'essential-addons-for-elementor-lite' ),
'g_cid' => __( 'Google Client ID', 'essential-addons-for-elementor-lite' ),
'f_title' => __( 'Facebook Login', 'essential-addons-for-elementor-lite' ),
'f_app_id' => __( 'Facebook APP ID', 'essential-addons-for-elementor-lite' ),
'f_app_secret' => __( 'Facebook APP Secret', 'essential-addons-for-elementor-lite' ),
]
];
wp_localize_script( 'essential_addons_elementor-admin-js', 'localize', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'essential-addons-elementor' ),
'i18n' => $i18n,
'settings_save' => EAEL_PLUGIN_URL . 'assets/admin/images/settings-save.gif',
'assets_regenerated' => EAEL_PLUGIN_URL . 'assets/admin/images/assets-regenerated.gif',
) );
}
$this->eael_admin_inline_css();
}
/**
* Create settings page.
*
* @since 1.1.2
*/
public function admin_settings_page() {
?>
<form action="" method="POST" id="eael-settings" name="eael-settings">
<div class="template__wrapper background__greyBg px30 py50">
<div class="eael-container">
<div class="eael-main__tab mb45">
<ul class="ls-none tab__menu">
<li class="tab__list active"><a class="tab__item" href="#general"><i class="ea-admin-icon eael-icon-gear-alt"></i><?php echo __( 'General', 'essential-addons-for-elementor-lite' ); ?></a></li>
<li class="tab__list"><a class="tab__item" href="#elements"><i class="ea-admin-icon eael-icon-element"></i><?php echo __( 'Elements', 'essential-addons-for-elementor-lite' ); ?></a></li>
<li class="tab__list"><a class="tab__item" href="#extensions"><i class="ea-admin-icon eael-icon-extension"></i><?php echo __( 'Extensions', 'essential-addons-for-elementor-lite' ); ?></a></li>
<li class="tab__list"><a class="tab__item" href="#tools"><i class="ea-admin-icon eael-icon-tools"></i><?php echo __( 'Tools', 'essential-addons-for-elementor-lite' ); ?></a></li>
<li class="tab__list"><a class="tab__item" href="#integrations"><i class="ea-admin-icon eael-icon-plug"></i><?php echo __( 'Integrations', 'essential-addons-for-elementor-lite' ); ?></a></li>
<?php if ( !$this->pro_enabled ) { ?>
<li class="tab__list"><a class="tab__item" href="#go-pro"><i class="ea-admin-icon eael-icon-lock-alt"></i><?php echo __( 'Go Premium', 'essential-addons-for-elementor-lite' ); ?></a></li>
<?php } ?>
</ul>
</div>
</div>
<div class="eael-admin-setting-tabs">
<?php
include_once EAEL_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'includes/templates/admin/general.php';
include_once EAEL_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'includes/templates/admin/elements.php';
include_once EAEL_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'includes/templates/admin/extensions.php';
include_once EAEL_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'includes/templates/admin/tools.php';
if ( !$this->pro_enabled ) {
include_once EAEL_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'includes/templates/admin/go-pro.php';
}
include_once EAEL_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'includes/templates/admin/integrations.php';
include_once EAEL_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'includes/templates/admin/popup.php';
?>
</div>
</div>
</form>
<?php
do_action( 'eael_admin_page_setting' );
}
/**
* Saving data with ajax request
* @param
* @since 1.1.2
*/
public function admin_notice() {
require_once EAEL_PLUGIN_PATH . 'vendor/autoload.php';
self::$cache_bank = CacheBank::get_instance();
NoticeRemover::get_instance('1.0.0');
NoticeRemover::get_instance('1.0.0', '\WPDeveloper\BetterDocs\Dependencies\PriyoMukul\WPNotice\Notices');
$notices = new Notices( [
'id' => 'essential-addons-for-elementor',
'storage_key' => 'notices',
'lifetime' => 3,
'stylesheet_url' => esc_url_raw( EAEL_PLUGIN_URL . 'assets/admin/css/notice.css' ),
'styles' => esc_url_raw( EAEL_PLUGIN_URL . 'assets/admin/css/notice.css' ),
'priority' => 1
] );
$review_notice = __( 'We hope you\'re enjoying Essential Addons for Elementor! Could you please do us a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?', 'essential-addons-for-elementor-lite' );
$_review_notice = [
'thumbnail' => plugins_url( 'assets/admin/images/icon-ea-logo.svg', EAEL_PLUGIN_BASENAME ),
'html' => '<p>' . $review_notice . '</p>',
'links' => [
'later' => array(
'link' => 'https://wpdeveloper.com/review-essential-addons-elementor',
'target' => '_blank',
'label' => __( 'Ok, you deserve it!', 'essential-addons-for-elementor-lite' ),
'icon_class' => 'dashicons dashicons-external',
),
'allready' => array(
'label' => __( 'I already did', 'essential-addons-for-elementor-lite' ),
'icon_class' => 'dashicons dashicons-smiley',
'attributes' => [
'data-dismiss' => true
],
),
'maybe_later' => array(
'label' => __( 'Maybe Later', 'essential-addons-for-elementor-lite' ),
'icon_class' => 'dashicons dashicons-calendar-alt',
'attributes' => [
'data-later' => true
],
),
'support' => array(
'link' => 'https://wpdeveloper.com/support',
'label' => __( 'I need help', 'essential-addons-for-elementor-lite' ),
'icon_class' => 'dashicons dashicons-sos',
),
'never_show_again' => array(
'label' => __( 'Never show again', 'essential-addons-for-elementor-lite' ),
'icon_class' => 'dashicons dashicons-dismiss',
'attributes' => [
'data-dismiss' => true
],
)
]
];
$notices->add(
'review',
$_review_notice,
[
'start' => $notices->strtotime( '+7 day' ),
'recurrence' => 30,
'refresh' => EAEL_PLUGIN_VERSION,
'dismissible' => true,
]
);
$b_message = '<p>Black Friday Sale: Unlock access to <strong>90+ advanced Elementor widgets</strong> with up to 40% discounts <span class="gift-icon">🎁</span></p><p><a class="button button-primary" href="https://wpdeveloper.com/upgrade/ea-bfcm" target="_blank">Upgrade to pro</a> <button data-dismiss="true" class="dismiss-btn button button-link">I dont want to save money</button></p>';
$_black_friday_notice = [
'thumbnail' => plugins_url( 'assets/admin/images/full-logo.svg', EAEL_PLUGIN_BASENAME ),
'html' => $b_message,
];
$notices->add(
'black_friday_notice',
$_black_friday_notice,
[
'start' => $notices->time(),
'recurrence' => false,
'dismissible' => true,
'refresh' => EAEL_PLUGIN_VERSION,
"expire" => strtotime( '11:59:59pm 2nd December, 2023' ),
'display_if' => ! $this->pro_enabled,
]
);
self::$cache_bank->create_account( $notices );
self::$cache_bank->calculate_deposits( $notices );
}
/**
* eael_admin_inline_css
*
* Admin Menu highlighted
* @return false
* @since 5.1.0
*/
public function eael_admin_inline_css() {
$screen = get_current_screen();
if ( ! empty( $screen->id ) && $screen->id == 'toplevel_page_eael-settings' ) {
return false;
}
if ( $this->menu_notice_should_show() ) {
$custom_css = "
#toplevel_page_eael-settings a ,
#toplevel_page_eael-settings a:hover {
color:#f0f0f1 !important;
background: #7D55FF !important;
}
#toplevel_page_eael-settings .eael-menu-notice {
display:block !important;
}"
;
wp_add_inline_style( 'admin-bar', $custom_css );
}
}
/**
* menu_notice_should_show
*
* Check two flags status (eael_admin_menu_notice and eael_admin_promotion),
* if both true this display menu notice. it's prevent to display menu notice multiple time
*
* @return bool
* @since 5.1.0
*/
public function menu_notice_should_show() {
return ( get_option( 'eael_admin_menu_notice' ) < self::EAEL_PROMOTION_FLAG && get_option( 'eael_admin_promotion' ) < self::EAEL_ADMIN_MENU_FLAG );
}
public function essential_block_optin() {
if ( is_plugin_active( 'essential-blocks/essential-blocks.php' ) || get_option( 'eael_eb_optin_hide' ) ) {
return;
}
$screen = get_current_screen();
$is_exclude = ! empty( $_GET['post_type'] ) && in_array( $_GET['post_type'], [ 'elementor_library', 'product' ] );
$ajax_url = admin_url( 'admin-ajax.php' );
$nonce = wp_create_nonce( 'essential-addons-elementor' );
$eb_not_installed = HelperClass::get_local_plugin_data( 'essential-blocks/essential-blocks.php' ) === false;
$action = $eb_not_installed ? 'install' : 'activate';
$button_title = $eb_not_installed ? esc_html__( 'Install Essential Blocks', 'essential-addons-for-elementor-lite' ) : esc_html__( 'Activate', 'essential-addons-for-elementor-lite' );
if ( $screen->parent_base !== 'edit' || $is_exclude ) {
return;
}
?>
<div class="wpnotice-wrapper notice notice-info is-dismissible eael-eb-optin-notice">
<div class="wpnotice-content-wrapper">
<div class="eael-eb-optin">
<h3><?php esc_html_e( 'Using Gutenberg? Check out Essential Blocks!', 'essential-addons-for-elementor-lite' ); ?></h3>
<p><?php _e( 'Are you using the Gutenberg Editor for your website? Then try out Essential Blocks for Gutenberg, and explore 40+ unique blocks to make your web design experience in WordPress even more powerful. 🚀', 'essential-addons-for-elementor-lite' ); ?></p>
<p><?php _e( 'For more information, <a href="https://essential-blocks.com/demo/" target="_blank">check out the demo here</a>.', 'essential-addons-for-elementor-lite' ); ?></p>
<p>
<a href="#" class="button-primary wpdeveloper-eb-plugin-installer" data-action="<?php echo esc_attr( $action ); ?>"><?php echo esc_html( $button_title ); ?></a>
</p>
</div>
</div>
</div>
<script>
// install/activate plugin
(function ($) {
$(document).on("click", ".wpdeveloper-eb-plugin-installer", function (ev) {
ev.preventDefault();
var button = $(this),
action = button.data("action");
if ($.active && typeof action != "undefined") {
button.text("Waiting...").attr("disabled", true);
setInterval(function () {
if (!$.active) {
button.attr("disabled", false).trigger("click");
}
}, 1000);
}
if (action === "install" && !$.active) {
button.text("Installing...").attr("disabled", true);
$.ajax({
url: "<?php echo esc_html( $ajax_url ); ?>",
type: "POST",
data: {
action: "wpdeveloper_install_plugin",
security: "<?php echo esc_html( $nonce ); ?>",
slug: "essential-blocks",
},
success: function (response) {
if (response.success) {
button.text("Activated");
button.data("action", null);
setTimeout(function () {
location.reload();
}, 1000);
} else {
button.text("Install");
}
button.attr("disabled", false);
},
error: function (err) {
console.log(err.responseJSON);
},
});
} else if (action === "activate" && !$.active) {
button.text("Activating...").attr("disabled", true);
$.ajax({
url: "<?php echo esc_html( $ajax_url ); ?>",
type: "POST",
data: {
action: "wpdeveloper_activate_plugin",
security: "<?php echo esc_html( $nonce ); ?>",
basename: "essential-blocks/essential-blocks.php",
},
success: function (response) {
if (response.success) {
button.text("Activated");
button.data("action", null);
setTimeout(function () {
location.reload();
}, 1000);
} else {
button.text("Activate");
}
button.attr("disabled", false);
},
error: function (err) {
console.log(err.responseJSON);
},
});
}
}).on('click', '.eael-eb-optin-notice button.notice-dismiss', function (e) {
e.preventDefault();
var $notice_wrapper = $(this).closest('.eael-eb-optin-notice');
$.ajax({
url: "<?php echo esc_html( $ajax_url ); ?>",
type: "POST",
data: {
action: "eael_eb_optin_notice_dismiss",
security: "<?php echo esc_html( $nonce ); ?>",
},
success: function (response) {
if (response.success) {
$notice_wrapper.remove();
} else {
console.log(response.data);
}
},
error: function (err) {
console.log(err.responseText);
},
});
});
})(jQuery);
</script>
<?php
}
public function essential_block_special_optin() {
if ( is_plugin_active( 'essential-blocks/essential-blocks.php' ) || get_option( 'eael_eb_optin_hide' ) ) {
return;
}
$ajax_url = admin_url( 'admin-ajax.php' );
$nonce = wp_create_nonce( 'essential-addons-elementor' );
$eb_not_installed = HelperClass::get_local_plugin_data( 'essential-blocks/essential-blocks.php' ) === false;
$action = $eb_not_installed ? 'install' : 'activate';
$button_title = $eb_not_installed ? esc_html__( 'Install Essential Blocks', 'essential-addons-for-elementor-lite' ) : esc_html__( 'Activate', 'essential-addons-for-elementor-lite' );
?>
<style>
/* Essential Blocks Special Optin*/
.eael-eb-special-optin-notice {
border-left-color: #6200ee;
padding-top: 0;
padding-bottom: 0;
padding-left: 0;
}
.eael-eb-special-optin-notice h3,
.eael-eb-special-optin-notice p,
.eael-eb-special-optin-notice a {
font-family: -apple-system,BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
.eael-eb-special-optin-notice a {
color: #2271b1;
}
.eael-eb-special-optin-notice .wpnotice-content-wrapper {
display: flex;
}
.eael-eb-special-optin-notice .wpnotice-content-wrapper > div {
padding-top: 15px;
}
.eael-eb-special-optin-notice .eael-eb-optin-logo {
width: 50px;
text-align: center;
background: rgba(98, 0, 238, .1);
}
.eael-eb-special-optin-notice .eael-eb-optin-logo img {
width: 25px;
}
.eael-eb-special-optin-notice .eael-eb-optin {
padding-left: 10px;
}
.eael-eb-special-optin-notice .eael-eb-optin a.wpdeveloper-eb-plugin-installer {
background: #5E2EFF;
}
</style>
<div class="wpnotice-wrapper notice notice-info is-dismissible eael-eb-special-optin-notice">
<div class="wpnotice-content-wrapper">
<div class="eael-eb-optin-logo">
<img src="<?php echo esc_url( EAEL_PLUGIN_URL . 'assets/admin/images/eb-new.svg' ); ?>" alt="">
</div>
<div class="eael-eb-optin">
<h3><?php esc_html_e( 'Using Gutenberg? Check out Essential Blocks!', 'essential-addons-for-elementor-lite' ); ?></h3>
<p><?php _e( 'Are you using the Gutenberg Editor for your website? Then try out Essential Blocks for Gutenberg, and explore 40+ unique blocks to make your web design experience in WordPress even more powerful. 🚀', 'essential-addons-for-elementor-lite' ); ?></p>
<p><?php _e( 'For more information, <a href="https://essential-blocks.com/demo/" target="_blank">check out the demo here</a>.', 'essential-addons-for-elementor-lite' ); ?></p>
<p>
<a href="#" class="button-primary wpdeveloper-eb-plugin-installer" data-action="<?php echo esc_attr( $action ); ?>"><?php echo esc_html( $button_title ); ?></a>
</p>
</div>
</div>
</div>
<script>
// install/activate plugin
(function ($) {
$(document).on("click", ".wpdeveloper-eb-plugin-installer", function (ev) {
ev.preventDefault();
var button = $(this),
action = button.data("action");
if ($.active && typeof action != "undefined") {
button.text("Waiting...").attr("disabled", true);
setInterval(function () {
if (!$.active) {
button.attr("disabled", false).trigger("click");
}
}, 1000);
}
if (action === "install" && !$.active) {
button.text("Installing...").attr("disabled", true);
$.ajax({
url: "<?php echo esc_html( $ajax_url ); ?>",
type: "POST",
data: {
action: "wpdeveloper_install_plugin",
security: "<?php echo esc_html( $nonce ); ?>",
slug: "essential-blocks",
},
success: function (response) {
if (response.success) {
button.text("Activated");
button.data("action", null);
setTimeout(function () {
location.reload();
}, 1000);
} else {
button.text("Install");
}
button.attr("disabled", false);
},
error: function (err) {
console.log(err.responseJSON);
},
});
} else if (action === "activate" && !$.active) {
button.text("Activating...").attr("disabled", true);
$.ajax({
url: "<?php echo esc_html( $ajax_url ); ?>",
type: "POST",
data: {
action: "wpdeveloper_activate_plugin",
security: "<?php echo esc_html( $nonce ); ?>",
basename: "essential-blocks/essential-blocks.php",
},
success: function (response) {
if (response.success) {
button.text("Activated");
button.data("action", null);
setTimeout(function () {
location.reload();
}, 1000);
} else {
button.text("Activate");
}
button.attr("disabled", false);
},
error: function (err) {
console.log(err.responseJSON);
},
});
}
}).on('click', '.eael-eb-special-optin-notice button.notice-dismiss', function (e) {
e.preventDefault();
var $notice_wrapper = $(this).closest('.eael-eb-optin-notice');
$.ajax({
url: "<?php echo esc_html( $ajax_url ); ?>",
type: "POST",
data: {
action: "eael_eb_optin_notice_dismiss",
security: "<?php echo esc_html( $nonce ); ?>",
},
success: function (response) {
if (response.success) {
$notice_wrapper.remove();
} else {
console.log(response.data);
}
},
error: function (err) {
console.log(err.responseText);
},
});
});
})(jQuery);
</script>
<?php
}
public function eael_eb_optin_notice_dismiss() {
check_ajax_referer( 'essential-addons-elementor', 'security' );
if ( ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( __( 'You are not allowed to do this action', 'essential-addons-for-elementor-lite' ) );
}
update_option( 'eael_eb_optin_hide', true );
wp_send_json_success();
}
public function eael_gb_eb_popup_dismiss() {
check_ajax_referer( 'essential-addons-elementor', 'security' );
if ( ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( __( 'You are not allowed to do this action', 'essential-addons-for-elementor-lite' ) );
}
update_option( 'eael_gb_eb_popup_hide', true );
wp_send_json_success();
}
public function eael_black_friday_optin_dismiss() {
check_ajax_referer( 'essential-addons-elementor', 'security' );
update_option( 'eael_black_friday_optin_hide', true );
wp_send_json_success();
}
public function eael_black_friday_optin() {
$time = time();
$ajax_url = admin_url( 'admin-ajax.php' );
$nonce = wp_create_nonce( 'essential-addons-elementor' );
if ( $time > 1669852799 || get_option( 'eael_black_friday_optin_hide' ) || defined( 'EAEL_PRO_PLUGIN_VERSION' ) ) {
return;
}
?>
<style>
.eael-black-friday-notice,
.eael-black-friday-notice * {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
.eael-black-friday-notice {
padding: 0;
border-left-color: #6200ee;
}
.eael-black-friday-notice .wpnotice-content-wrapper {
display: flex;
}
.eael-black-friday-notice .wpnotice-content-wrapper .eael-black-friday-optin-logo {
width: 50px;
padding: 10px 0 0;
text-align: center;
background: rgba(98, 0, 238, .1);
}
.eael-black-friday-notice .wpnotice-content-wrapper .eael-black-friday-optin {
padding-left: 10px;
}
</style>
<div class="wpnotice-wrapper notice notice-info is-dismissible eael-black-friday-notice">
<div class="wpnotice-content-wrapper">
<div class="eael-black-friday-optin-logo">
<img src="<?php echo esc_url( EAEL_PLUGIN_URL . 'assets/admin/images/icon-ea-logo.svg' ); ?>" width="25" alt="">
</div>
<div class="eael-black-friday-optin">
<p><?php _e( '<strong>🎉 Black Friday Exclusive:</strong> SAVE up to 40% & access to Essential Addons Pro features.', 'essential-addons-for-elementor-lite' ); ?>
<a href="https://essential-addons.com/elementor/#pricing" target="_blank"
class="button-primary"><?php _e( 'Grab The Offer', 'essential-addons-for-elementor-lite' ); ?></a>
</p>
</div>
</div>
</div>
<script>
(function ($) {
$(document).on('click', '.eael-black-friday-notice button.notice-dismiss', function (e) {
e.preventDefault();
var $notice_wrapper = $(this).closest('.eael-black-friday-notice');
$.ajax({
url: "<?php echo esc_html( $ajax_url ); ?>",
type: "POST",
data: {
action: "eael_black_friday_optin_dismiss",
security: "<?php echo esc_html( $nonce ); ?>",
},
success: function (response) {
if (response.success) {
$notice_wrapper.remove();
} else {
console.log(response.data);
}
},
error: function (err) {
console.log(err.responseText);
},
});
});
})(jQuery);
</script>
<?php
}
}

View File

@@ -0,0 +1,409 @@
<?php
namespace Essential_Addons_Elementor\Traits;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
use \Elementor\Plugin;
use \Essential_Addons_Elementor\Classes\Plugin_Usage_Tracker;
trait Core
{
/**
* Extending plugin links
*
* @since 3.0.0
*/
public function i18n()
{
load_plugin_textdomain('essential-addons-for-elementor-lite');
}
/**
* Check if a plugin is active
*
* @since 3.0.0
*/
public function is_plugin_active($plugin)
{
include_once ABSPATH . 'wp-admin/includes/plugin.php';
return is_plugin_active($plugin);
}
/**
* Extending plugin links
*
* @since 3.0.0
*/
public function insert_plugin_links($links)
{
// settings
$links[] = sprintf('<a href="admin.php?page=eael-settings">' . __('Settings', 'essential-addons-for-elementor-lite') . '</a>');
// go pro
if (!$this->pro_enabled) {
$links[] = sprintf('<a href="https://wpdeveloper.com/in/upgrade-essential-addons-elementor" target="_blank" style="color: #524cff; font-weight: bold;">' . __('Go Pro', 'essential-addons-for-elementor-lite') . '</a>');
}
return $links;
}
/**
* Extending plugin row meta
*
* @since 3.0.0
*/
public function insert_plugin_row_meta($links, $file)
{
if (EAEL_PLUGIN_BASENAME == $file) {
// docs & faq
$links[] = sprintf('<a href="https://essential-addons.com/elementor/docs/?utm_medium=admin&utm_source=wp.org&utm_term=ea" target="_blank">' . __('Docs & FAQs', 'essential-addons-for-elementor-lite') . '</a>');
// video tutorials
$links[] = sprintf('<a href="https://www.youtube.com/channel/UCOjzLEdsnpnFVkm1JKFurPA?utm_medium=admin&utm_source=wp.org&utm_term=ea" target="_blank">' . __('Video Tutorials', 'essential-addons-for-elementor-lite') . '</a>');
}
return $links;
}
/**
* Redirect to options page
*
* @since v1.0.0
*/
public function redirect_on_activation()
{
if (get_transient('eael_do_activation_redirect')) {
delete_transient('eael_do_activation_redirect');
if (!isset($_GET['activate-multi'])) {
wp_redirect("admin.php?page=eael-settings");
}
}
}
/**
* Check if elementor plugin is activated
*
* @since v1.0.0
*/
public function elementor_not_loaded()
{
if (!current_user_can('activate_plugins')) {
return;
}
$elementor = 'elementor/elementor.php';
if ($this->is_plugin_installed($elementor)) {
$activation_url = wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $elementor . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $elementor);
$message = sprintf(__('%1$sEssential Addons for Elementor%2$s requires %1$sElementor%2$s plugin to be active. Please activate Elementor to continue.', 'essential-addons-for-elementor-lite'), "<strong>", "</strong>");
$button_text = __('Activate Elementor', 'essential-addons-for-elementor-lite');
} else {
$activation_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor');
$message = sprintf(__('%1$sEssential Addons for Elementor%2$s requires %1$sElementor%2$s plugin to be installed and activated. Please install Elementor to continue.', 'essential-addons-for-elementor-lite'), '<strong>', '</strong>');
$button_text = __('Install Elementor', 'essential-addons-for-elementor-lite');
}
$button = '<p><a href="' . esc_url( $activation_url ) . '" class="button-primary">' . esc_html( $button_text ) . '</a></p>';
printf('<div class="error"><p>%1$s</p>%2$s</div>', __($message), $button);
}
/**
* Optional usage tracker
*
* @since v1.0.0
*/
public function start_plugin_tracking()
{
$tracker = Plugin_Usage_Tracker::get_instance( EAEL_PLUGIN_FILE, [
'opt_in' => true,
'goodbye_form' => true,
'item_id' => '760e8569757fa16992d8'
] );
$tracker->set_notice_options(array(
'notice' => __( 'Want to help make <strong>Essential Addons for Elementor</strong> even more awesome? You can get a <strong>10% discount coupon</strong> for Pro upgrade if you allow.', 'essential-addons-for-elementor-lite' ),
'extra_notice' => __( 'We collect non-sensitive diagnostic data and plugin usage information.
Your site URL, WordPress & PHP version, plugins & themes and email address to send you the
discount coupon. This data lets us make sure this plugin always stays compatible with the most
popular plugins and themes. No spam, I promise.', 'essential-addons-for-elementor-lite' ),
));
$tracker->init();
}
/**
* Save default values to db
*
* @since v3.0.0
*/
public function set_default_values()
{
$defaults = array_fill_keys(array_keys(array_merge($GLOBALS['eael_config']['elements'], $GLOBALS['eael_config']['extensions'])), 1);
$values = get_option('eael_save_settings');
return update_option('eael_save_settings', wp_parse_args($values, $defaults));
}
/**
* Save setup wizard data
*
* @since v4.0.0
*/
public function enable_setup_wizard()
{
if ( !get_option( 'eael_version' ) && !get_option( 'eael_setup_wizard' ) ) {
update_option( 'eael_setup_wizard', 'redirect' );
}
}
/**
* Save default values to db
*
* @since v3.0.0
*/
public function save_global_values($post_id, $editor_data)
{
if (wp_doing_cron()) {
return;
}
$document = Plugin::$instance->documents->get($post_id, false);
$global_settings = get_option('eael_global_settings', []);
if ($document->get_settings('eael_ext_reading_progress_global') == 'yes' && $document->get_settings('eael_ext_reading_progress') == 'yes') {
$global_settings['reading_progress'] = [
'post_id' => $post_id,
'enabled' => true,
'eael_ext_reading_progress_global_display_condition' => $document->get_settings('eael_ext_reading_progress_global_display_condition'),
'eael_ext_reading_progress_position' => $document->get_settings('eael_ext_reading_progress_position'),
'eael_ext_reading_progress_height' => $document->get_settings('eael_ext_reading_progress_height'),
'eael_ext_reading_progress_bg_color' => $document->get_settings('eael_ext_reading_progress_bg_color'),
'eael_ext_reading_progress_fill_color' => $document->get_settings('eael_ext_reading_progress_fill_color'),
'eael_ext_reading_progress_animation_speed' => $document->get_settings('eael_ext_reading_progress_animation_speed'),
];
} else {
if (isset($global_settings['reading_progress']['post_id']) && $global_settings['reading_progress']['post_id'] == $post_id) {
$global_settings['reading_progress'] = [
'post_id' => null,
'enabled' => false,
];
}
}
//save table of contents global value
if ($document->get_settings('eael_ext_toc_global') == 'yes' && $document->get_settings('eael_ext_table_of_content') == 'yes') {
$typography_fields = [
'font_family',
'font_weight',
'text_transform',
'font_style',
'text_decoration',
'font_size',
'letter_spacing',
'line_height',
];
$global_settings['eael_ext_table_of_content'] = [
'post_id' => $post_id,
'enabled' => ($document->get_settings('eael_ext_toc_global') == 'yes'),
'eael_ext_toc_global_display_condition' => $document->get_settings('eael_ext_toc_global_display_condition'),
'eael_ext_toc_title' => $document->get_settings('eael_ext_toc_title'),
'eael_ext_toc_title_tag' => $document->get_settings('eael_ext_toc_title_tag'),
'eael_ext_toc_position' => $document->get_settings('eael_ext_toc_position'),
'eael_ext_toc_supported_heading_tag' => $document->get_settings('eael_ext_toc_supported_heading_tag'),
'eael_ext_toc_content_selector' => $document->get_settings('eael_ext_toc_content_selector'),
'eael_toc_exclude_selector' => $document->get_settings('eael_toc_exclude_selector'),
'eael_ext_toc_collapse_sub_heading' => $document->get_settings('eael_ext_toc_collapse_sub_heading'),
'eael_ext_toc_use_title_in_url' => $document->get_settings('eael_ext_toc_use_title_in_url'),
'eael_ext_toc_word_wrap' => $document->get_settings('eael_ext_toc_word_wrap'),
'eael_ext_toc_table_box_shadow_box_shadow' => $document->get_settings('eael_ext_toc_table_box_shadow_box_shadow'),
'eael_ext_toc_auto_collapse' => $document->get_settings('eael_ext_toc_auto_collapse'),
'eael_ext_toc_auto_highlight' => $document->get_settings('eael_ext_toc_auto_highlight'),
'eael_ext_toc_auto_highlight_single_item_only' => $document->get_settings('eael_ext_toc_auto_highlight_single_item_only'),
'eael_ext_toc_hide_in_mobile' => $document->get_settings('eael_ext_toc_hide_in_mobile'),
'eael_ext_toc_border_border' => $document->get_settings('eael_ext_toc_border_border'),
'eael_ext_toc_border_width' => $document->get_settings('eael_ext_toc_border_width'),
'eael_ext_toc_border_color' => $document->get_settings('eael_ext_toc_border_color'),
'eael_ext_toc_box_border_radius' => $document->get_settings('eael_ext_toc_box_border_radius'),
'eael_ext_toc_sticky_offset' => $document->get_settings('eael_ext_toc_sticky_offset'),
'eael_ext_toc_sticky_scroll' => $document->get_settings('eael_ext_toc_sticky_scroll'),
'eael_ext_toc_sticky_z_index' => $document->get_settings('eael_ext_toc_sticky_z_index'),
//toc header setting
'eael_ext_table_of_content_header_bg' => $document->get_settings('eael_ext_table_of_content_header_bg'),
'eael_ext_table_of_content_header_text_color' => $document->get_settings('eael_ext_table_of_content_header_text_color'),
'eael_ext_table_of_content_header_icon' => $document->get_settings('eael_ext_table_of_content_header_icon'),
'eael_ext_toc_header_padding' => $document->get_settings('eael_ext_toc_header_padding'),
'eael_ext_toc_width' => $document->get_settings('eael_ext_toc_width'),
//close button setting
'eael_ext_table_of_content_close_button_bg' => $document->get_settings('eael_ext_table_of_content_close_button_bg'),
'eael_ext_table_of_content_close_button_text_color' => $document->get_settings('eael_ext_table_of_content_close_button_text_color'),
'eael_ext_toc_close_button_text_style' => $document->get_settings('eael_ext_toc_close_button_text_style'),
'eael_ext_table_of_content_close_button_icon_size' => $document->get_settings('eael_ext_table_of_content_close_button_icon_size'),
'eael_ext_table_of_content_close_button_size' => $document->get_settings('eael_ext_table_of_content_close_button_size'),
'eael_ext_table_of_content_close_button_line_height' => $document->get_settings('eael_ext_table_of_content_close_button_line_height'),
'eael_ext_table_of_content_close_button_border_radius' => $document->get_settings('eael_ext_table_of_content_close_button_border_radius'),
'eael_ext_table_of_content_close_button_box_shadow' => $document->get_settings('eael_ext_table_of_content_close_button_box_shadow_box_shadow'),
//toc body setting
'eael_ext_table_of_content_body_bg' => $document->get_settings('eael_ext_table_of_content_body_bg'),
'eael_ext_toc_body_padding' => $document->get_settings('eael_ext_toc_body_padding'),
//list style setting
'eael_ext_table_of_content_list_style' => $document->get_settings('eael_ext_table_of_content_list_style'),
'eael_ext_toc_top_level_space' => $document->get_settings('eael_ext_toc_top_level_space'),
'eael_ext_toc_subitem_level_space' => $document->get_settings('eael_ext_toc_subitem_level_space'),
'eael_ext_toc_list_icon' => $document->get_settings('eael_ext_toc_list_icon'),
'eael_ext_table_of_content_list_text_color' => $document->get_settings('eael_ext_table_of_content_list_text_color'),
'eael_ext_table_of_content_list_text_color_active' => $document->get_settings('eael_ext_table_of_content_list_text_color_active'),
'eael_ext_table_of_list_hover_color' => $document->get_settings('eael_ext_table_of_list_hover_color'),
'eael_ext_table_of_content_list_separator_style' => $document->get_settings('eael_ext_table_of_content_list_separator_style'),
'eael_ext_table_of_content_list_separator_color' => $document->get_settings('eael_ext_table_of_content_list_separator_color'),
'eael_ext_toc_box_list_bullet_size' => $document->get_settings('eael_ext_toc_box_list_bullet_size'),
'eael_ext_toc_box_list_top_position' => $document->get_settings('eael_ext_toc_box_list_top_position'),
'eael_ext_toc_indicator_size' => $document->get_settings('eael_ext_toc_indicator_size'),
'eael_ext_toc_indicator_position' => $document->get_settings('eael_ext_toc_indicator_position'),
];
foreach ($typography_fields as $typography_field) {
$header_fields_attr = 'eael_ext_table_of_content_header_typography_' . $typography_field;
$list_fields_attr = 'eael_ext_table_of_content_list_typography_normal_' . $typography_field;
$global_settings['eael_ext_table_of_content'][$header_fields_attr] = $document->get_settings($header_fields_attr);
$global_settings['eael_ext_table_of_content'][$list_fields_attr] = $document->get_settings($list_fields_attr);
}
} else {
if (isset($global_settings['eael_ext_table_of_content']['post_id']) && $global_settings['eael_ext_table_of_content']['post_id'] == $post_id) {
$global_settings['eael_ext_table_of_content'] = [];
}
}
//Scroll to Top global settings : updated on elementor/editor/after_save action
$global_settings['eael_ext_scroll_to_top'] = $this->get_ext_scroll_to_top_global_settings($post_id, $document, $global_settings);
// set editor time
update_option('eael_editor_updated_at', strtotime('now'));
// update options
update_option('eael_global_settings', $global_settings);
}
/**
* Save default values to db while trashing a post
*
* @since 3.0.0
*/
public function save_global_values_trashed_post($post_id)
{
if (wp_doing_cron()) {
return;
}
if ( ! $this->is_activate_elementor() ) {
return false;
}
$document = Plugin::$instance->documents->get($post_id, false);
$global_settings = get_option('eael_global_settings');
// Reading Progress Bar
if ( isset($global_settings['reading_progress']['post_id']) && $global_settings['reading_progress']['post_id'] == $post_id ) {
$global_settings['reading_progress'] = [
'post_id' => null,
'enabled' => false,
];
}
// Table of Contents
if ( isset($global_settings['eael_ext_table_of_content']['post_id']) && $global_settings['eael_ext_table_of_content']['post_id'] == $post_id ) {
$global_settings['eael_ext_table_of_content'] = [];
}
// Scroll to Top
if ( isset($global_settings['eael_ext_scroll_to_top']['post_id']) && $global_settings['eael_ext_scroll_to_top']['post_id'] == $post_id ) {
$global_settings['eael_ext_scroll_to_top'] = [
'post_id' => null,
'enabled' => false,
];
}
// set editor time
update_option('eael_editor_updated_at', strtotime('now'));
// update options
update_option('eael_global_settings', $global_settings);
}
/**
* Get global settings of Scroll to Top extension
*
* @return array
* @since v5.0.0
*/
public function get_ext_scroll_to_top_global_settings($post_id, $document, $global_settings){
$global_settings_scroll_to_top = !empty($global_settings['eael_ext_scroll_to_top']) ? $global_settings['eael_ext_scroll_to_top'] : array();
$document_settings = $document->get_settings();
if ($document->get_settings('eael_ext_scroll_to_top_global') == 'yes' && $document->get_settings('eael_ext_scroll_to_top') == 'yes') {
$global_settings_scroll_to_top = [
'post_id' => $post_id,
'enabled' => true,
'eael_ext_scroll_to_top_global_display_condition' => $document->get_settings('eael_ext_scroll_to_top_global_display_condition'),
'eael_ext_scroll_to_top_position_text' => $document->get_settings('eael_ext_scroll_to_top_position_text'),
'eael_ext_scroll_to_top_position_bottom' => $document->get_settings('eael_ext_scroll_to_top_position_bottom'),
'eael_ext_scroll_to_top_position_left' => $document->get_settings('eael_ext_scroll_to_top_position_left'),
'eael_ext_scroll_to_top_position_right' => $document->get_settings('eael_ext_scroll_to_top_position_right'),
'eael_ext_scroll_to_top_button_width' => $document->get_settings('eael_ext_scroll_to_top_button_width'),
'eael_ext_scroll_to_top_button_height' => $document->get_settings('eael_ext_scroll_to_top_button_height'),
'eael_ext_scroll_to_top_z_index' => $document->get_settings('eael_ext_scroll_to_top_z_index'),
'eael_ext_scroll_to_top_button_opacity' => $document->get_settings('eael_ext_scroll_to_top_button_opacity'),
'eael_ext_scroll_to_top_button_icon_image' => $document->get_settings('eael_ext_scroll_to_top_button_icon_image'),
'eael_ext_scroll_to_top_button_icon_size' => $document->get_settings('eael_ext_scroll_to_top_button_icon_size'),
'eael_ext_scroll_to_top_button_icon_svg_size' => $document->get_settings('eael_ext_scroll_to_top_button_icon_svg_size'),
'eael_ext_scroll_to_top_button_icon_color' => $this->eael_ext_stt_fetch_color_or_global_color($document_settings, 'eael_ext_scroll_to_top_button_icon_color'),
'eael_ext_scroll_to_top_button_bg_color' => $this->eael_ext_stt_fetch_color_or_global_color($document_settings, 'eael_ext_scroll_to_top_button_bg_color'),
'eael_ext_scroll_to_top_button_border_radius' => $document->get_settings('eael_ext_scroll_to_top_button_border_radius'),
];
} else {
if (
( isset($global_settings['eael_ext_scroll_to_top']['post_id']) && $global_settings['eael_ext_scroll_to_top']['post_id'] == $post_id )
||
( isset($global_settings['eael_ext_scroll_to_top']['post_id']) && 'publish' !== get_post_status($global_settings['eael_ext_scroll_to_top']['post_id']) )
) {
$global_settings_scroll_to_top = [
'post_id' => null,
'enabled' => false,
];
}
}
return $global_settings_scroll_to_top;
}
public function eael_ext_stt_fetch_color_or_global_color($settings, $control_name=''){
if( !isset($settings[$control_name])) {
return '';
}
$color = $settings[$control_name];
if(!empty($settings['__globals__']) && !empty($settings['__globals__'][$control_name])){
$color = $settings['__globals__'][$control_name];
$color_arr = explode('?id=', $color); //E.x. 'globals/colors/?id=primary'
$color_name = count($color_arr) > 1 ? $color_arr[1] : '';
if( !empty($color_name) ) {
$color = "var( --e-global-color-$color_name )";
}
}
return $color;
}
}

View File

@@ -0,0 +1,984 @@
<?php
namespace Essential_Addons_Elementor\Traits;
if ( ! defined( 'ABSPATH' ) ) {
exit();
} // Exit if accessed directly
use Elementor\Icons_Manager;
use \Elementor\Plugin;
use Essential_Addons_Elementor\Classes\Helper;
trait Elements {
public $extensions_data = [];
/**
* Register custom controls
*
* @since v4.4.2
*/
public function register_controls( $controls_manager ) {
if ( version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) {
$controls_manager->register( new \Essential_Addons_Elementor\Controls\Select2() );
$controls_manager->add_group_control( 'eael-background', new \Essential_Addons_Elementor\Controls\EAEL_Background() );
} else {
$controls_manager->register_control( 'eael-select2', new \Essential_Addons_Elementor\Controls\Select2() );
}
}
/**
* Add elementor category
*
* @since v1.0.0
*/
public function register_widget_categories( $elements_manager ) {
$elements_manager->add_category(
'essential-addons-elementor',
[
'title' => __( 'Essential Addons', 'essential-addons-for-elementor-lite' ),
'icon' => 'font',
], 1 );
}
/**
* Register widgets
*
* @since v3.0.0
*/
public function register_elements( $widgets_manager ) {
$active_elements = (array) $this->get_settings();
if ( empty( $active_elements ) ) {
return;
}
asort( $active_elements );
foreach ( $active_elements as $active_element ) {
if ( ! isset( $this->registered_elements[ $active_element ] ) ) {
continue;
}
if ( isset( $this->registered_elements[ $active_element ]['condition'] ) ) {
$check = false;
if ( isset( $this->registered_elements[ $active_element ]['condition'][2] ) ) {
$check = $this->registered_elements[ $active_element ]['condition'][2];
}
if ( $this->registered_elements[ $active_element ]['condition'][0]( $this->registered_elements[ $active_element ]['condition'][1] ) == $check ) {
continue;
}
}
if ( $this->pro_enabled && \version_compare( EAEL_PRO_PLUGIN_VERSION, '3.3.0', '<' ) ) {
if ( in_array( $active_element, [
'content-timeline',
'dynamic-filter-gallery',
'post-block',
'post-carousel',
'post-list'
] ) ) {
continue;
}
}
if ( defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) {
$widgets_manager->register( new $this->registered_elements[ $active_element ]['class'] );
} else {
$widgets_manager->register_widget_type( new $this->registered_elements[ $active_element ]['class'] );
}
}
}
/**
* Register extensions
*
* @since v3.0.0
*/
public function register_extensions() {
$active_elements = (array) $this->get_settings();
// set promotion extension enabled
array_push( $active_elements, 'promotion' );
foreach ( $this->registered_extensions as $key => $extension ) {
if ( ! in_array( $key, $active_elements ) ) {
continue;
}
new $extension['class'];
}
}
/**
* List pro widgets
*
* @since v3.1.4
*/
public function promote_pro_elements( $config ) {
if ( $this->pro_enabled ) {
return $config;
}
$promotion_widgets = [];
if ( isset( $config['promotionWidgets'] ) ) {
$promotion_widgets = $config['promotionWidgets'];
}
$combine_array = array_merge( $promotion_widgets, [
[
'name' => 'eael-advanced-menu',
'title' => __( 'Advanced Menu', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-advanced-menu',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-content-timeline',
'title' => __( 'Content Timeline', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-content-timeline',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-counter',
'title' => __( 'Counter', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-counter',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-divider',
'title' => __( 'Divider', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-divider',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-dynamic-filterable-gallery',
'title' => __( 'Dynamic Gallery', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-dynamic-gallery',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-flip-carousel',
'title' => __( 'Flip Carousel', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-flip-carousel',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-google-map',
'title' => __( 'Google Map', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-advanced-google-maps',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-image-comparison',
'title' => __( 'Image Comparison', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-image-comparison',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-image-hotspots',
'title' => __( 'Image Hotspots', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-image-hotspots',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-image-scroller',
'title' => __( 'Image Scroller', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-image-scroller',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-instafeed',
'title' => __( 'Instagram Feed', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-instagram-feed',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-interactive-card',
'title' => __( 'Interactive Card', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-interactive-cards',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-interactive-promo',
'title' => __( 'Interactive Promo', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-interactive-promo',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-learn-dash-course-list',
'title' => __( 'LearnDash Course List', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-learndash',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-lightbox',
'title' => __( 'Lightbox & Modal', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-lightbox-modal',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-logo-carousel',
'title' => __( 'Logo Carousel', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-logo-carousel',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-mailchimp',
'title' => __( 'Mailchimp', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-mailchimp',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-offcanvas',
'title' => __( 'Offcanvas', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-offcanvas',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-one-page-nav',
'title' => __( 'One Page Navigation', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-one-page-navigaton',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-post-block',
'title' => __( 'Post Block', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-post-block',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-post-carousel',
'title' => __( 'Post Carousel', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-post-carousel',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-post-list',
'title' => __( 'Smart Post List', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-smart-post-list',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-price-menu',
'title' => __( 'Price Menu', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-price-menu',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-protected-content',
'title' => __( 'Protected Content', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-protected-content',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-static-product',
'title' => __( 'Static Product', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-static-product',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-team-member-carousel',
'title' => __( 'Team Member Carousel', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-team-member-carousel',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-testimonial-slider',
'title' => __( 'Testimonial Slider', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-testimonial-slider',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-toggle',
'title' => __( 'Toggle', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-content-toggle',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-twitter-feed-carousel',
'title' => __( 'Twitter Feed Carousel', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-twitter-feed-carousel',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-woo-collections',
'title' => __( 'Woo Product Collections', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-woo-product-collections',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-woo-product-slider',
'title' => __( 'Woo Product Slider', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-woo-product-collections',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eaicon-advanced-search',
'title' => __( 'Advanced Search', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-advanced-search',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-woo-thank-you',
'title' => __( 'Woo Thank You', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-thank-you',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-woo-cross-sells',
'title' => __( 'Woo Cross Sells', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-woo-cross-sells',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'eael-woo-account-dashboard',
'title' => __( 'Woo Account Dashboard', 'essential-addons-for-elementor-lite' ),
'icon' => 'eaicon-woo-account-dashboard',
'categories' => '["essential-addons-elementor"]',
],
[
'name' => 'fancy-chart',
'title' => __( 'Fancy Chart', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-elementor-circle',
'categories' => '["essential-addons-elementor"]',
],
] );
$config['promotionWidgets'] = $combine_array;
return $config;
}
public function eael_is_theme_builder_archive_template( $type = 'archive' ){
$is_archive_template = false;
if ( class_exists( 'ElementorPro\Modules\ThemeBuilder\Module' ) ) {
$conditions_manager = \ElementorPro\Plugin::instance()->modules_manager->get_modules( 'theme-builder' )->get_conditions_manager();
if( ! empty( $conditions_manager->get_documents_for_location( 'archive') ) || ! empty( $conditions_manager->get_documents_for_location( 'single') ) ) {
$is_archive_template = true;
}
}
return $is_archive_template;
}
public function eael_get_theme_builder_archive_template_id(){
$template_id = 0;
if ( class_exists( 'ElementorPro\Modules\ThemeBuilder\Module' ) ) {
if ( $this->eael_is_theme_builder_archive_template() ) {
$page_body_classes = get_body_class();
if( is_array( $page_body_classes ) && count( $page_body_classes ) ){
foreach( $page_body_classes as $page_body_class){
if ( strpos( $page_body_class, 'elementor-page-' ) !== FALSE ) {
$template_id = intval( str_replace('elementor-page-', '', $page_body_class) );
}
}
}
}
}
return $template_id;
}
/**
* Inject global extension html.
*
* @since v3.1.4
*/
public function render_global_html() {
if ( ! apply_filters( 'eael/is_plugin_active', 'elementor/elementor.php' ) ) {
return;
}
if ( ! is_singular() && ! is_archive() ) {
return;
}
$post_id = get_the_ID();
$html = '';
$global_settings = $settings_data = $document = [];
if ( $this->get_settings( 'reading-progress' ) || $this->get_settings( 'table-of-content' ) || $this->get_settings( 'scroll-to-top' ) ) {
$html = '';
$global_settings = get_option( 'eael_global_settings' );
$is_archive_template = $this->eael_is_theme_builder_archive_template();
if( ! empty ( $is_archive_template ) ){
$template_id = $this->eael_get_theme_builder_archive_template_id();
if ( ! empty( $template_id ) ) {
$post_id = $template_id;
}
}
$document = Plugin::$instance->documents->get( $post_id, false );
if ( is_object( $document ) ) {
$settings_data = $document->get_settings();
}
}
// Reading Progress Bar
if ( $this->get_settings( 'reading-progress' ) == true ) {
$reading_progress_status = $global_reading_progress = false;
if ( isset( $settings_data['eael_ext_reading_progress'] ) && $settings_data['eael_ext_reading_progress'] == 'yes' ) {
$reading_progress_status = true;
} elseif ( isset( $global_settings['reading_progress']['enabled'] ) && $global_settings['reading_progress']['enabled'] ) {
$reading_progress_status = true;
$global_reading_progress = true;
$settings_data = $global_settings['reading_progress'];
}
if ( $reading_progress_status ) {
if ( ! empty( $document ) && is_object( $document ) ) {
$this->progress_bar_local_css( $document->get_settings() );
}
$this->extensions_data = $settings_data;
$progress_height = ! empty( $settings_data['eael_ext_reading_progress_height']['size'] ) ? $settings_data['eael_ext_reading_progress_height']['size'] : '';
$animation_speed = ! empty( $settings_data['eael_ext_reading_progress_animation_speed']['size'] ) ? $settings_data['eael_ext_reading_progress_animation_speed']['size'] : '';
$reading_progress_html = '<div id="eael-reading-progress-'. get_the_ID() .'" class="eael-reading-progress-wrap eael-reading-progress-wrap-' . ( $this->get_extensions_value( 'eael_ext_reading_progress' ) == 'yes' ? 'local' : 'global' ) . '">';
if ( $global_reading_progress ) {
$reading_progress_html .= '<div class="eael-reading-progress eael-reading-progress-global eael-reading-progress-' . $this->get_extensions_value( 'eael_ext_reading_progress_position' ) . '" style="height: ' . $progress_height . 'px;background-color: ' . $this->get_extensions_value( 'eael_ext_reading_progress_bg_color' ) . ';">
<div class="eael-reading-progress-fill" style="height: ' . $progress_height . 'px;background-color: ' . $this->get_extensions_value( 'eael_ext_reading_progress_fill_color' ) . ';transition: width ' . $animation_speed . 'ms ease;"></div>
</div>';
} else {
$reading_progress_html .= '<div class="eael-reading-progress eael-reading-progress-local eael-reading-progress-' . $this->get_extensions_value( 'eael_ext_reading_progress_position' ) . '">
<div class="eael-reading-progress-fill"></div>
</div>';
}
$reading_progress_html .= '</div>';
if ( $this->get_extensions_value( 'eael_ext_reading_progress' ) != 'yes' ) {
$display_condition = $this->get_extensions_value( 'eael_ext_reading_progress_global_display_condition' );
if ( get_post_status( $this->get_extensions_value( 'post_id' ) ) != 'publish' ) {
$reading_progress_html = '';
} else if ( $display_condition == 'pages' && ! is_page() ) {
$reading_progress_html = '';
} else if ( $display_condition == 'posts' && ! is_single() ) {
$reading_progress_html = '';
}
}
if ( ! empty( $reading_progress_html ) ) {
wp_enqueue_script( 'eael-reading-progress' );
wp_enqueue_style( 'eael-reading-progress' );
$html .= $reading_progress_html;
}
}
}
// Table of Contents
if ( $this->get_settings( 'table-of-content' ) ) {
$toc_status = false;
$toc_status_global = false;
if ( is_object( $document ) ) {
$settings_data = $document->get_settings();
}
if ( isset( $settings_data['eael_ext_table_of_content'] ) && $settings_data['eael_ext_table_of_content'] == 'yes' ) {
$toc_status = true;
} elseif ( isset( $global_settings['eael_ext_table_of_content']['enabled'] ) && $global_settings['eael_ext_table_of_content']['enabled'] ) {
$toc_status = true;
$settings_data = $global_settings['eael_ext_table_of_content'];
}
$toc_status_global = isset( $global_settings['eael_ext_table_of_content']['enabled'] ) && $global_settings['eael_ext_table_of_content']['enabled'];
if ( $toc_status ) {
$this->extensions_data = $settings_data;
$el_class = 'eael-toc eael-toc-disable';
if ( $this->get_extensions_value( 'eael_ext_table_of_content' ) != 'yes' && ! empty( $settings_data['enabled'] ) ) {
$el_class .= ' eael-toc-global';
$this->toc_global_css( $global_settings );
}
$icon = 'fas fa-list';
$support_tag = (array) $settings_data['eael_ext_toc_supported_heading_tag'];
$support_tag = implode( ',', array_filter( $support_tag ) );
$position = $settings_data['eael_ext_toc_position'];
$page_offset = ! empty( $settings_data['eael_ext_toc_main_page_offset'] ) ? $settings_data['eael_ext_toc_main_page_offset']['size'] : 0;
$close_bt_text_style = $settings_data['eael_ext_toc_close_button_text_style'];
$auto_collapse = $settings_data['eael_ext_toc_auto_collapse'];
$auto_highlight = ! empty( $settings_data['eael_ext_toc_auto_highlight'] ) ? $settings_data['eael_ext_toc_auto_highlight'] : '';
$auto_highlight_single_item_only = ! empty( $settings_data['eael_ext_toc_auto_highlight_single_item_only'] ) ? $settings_data['eael_ext_toc_auto_highlight_single_item_only'] : '';
$title_to_url = $settings_data['eael_ext_toc_use_title_in_url'];
$toc_style = $settings_data['eael_ext_table_of_content_list_style'];
$toc_word_wrap = $settings_data['eael_ext_toc_word_wrap'];
$toc_collapse = $settings_data['eael_ext_toc_collapse_sub_heading'];
$list_icon = $settings_data['eael_ext_toc_list_icon'];
$toc_title = $settings_data['eael_ext_toc_title'];
$toc_title_tag = $settings_data['eael_ext_toc_title_tag'];
$icon_check = $settings_data['eael_ext_table_of_content_header_icon'];
$sticky_scroll = $settings_data['eael_ext_toc_sticky_scroll'];
$hide_mobile = $settings_data['eael_ext_toc_hide_in_mobile'];
$content_selector = $settings_data['eael_ext_toc_content_selector'];
$exclude_selector = $settings_data['eael_toc_exclude_selector'];
$el_class .= ( $position == 'right' ) ? ' eael-toc-right' : ' eael-toc-left';
$el_class .= ( $close_bt_text_style == 'bottom_to_top' ) ? ' eael-bottom-to-top' : ' ';
$el_class .= ( $auto_collapse == 'yes' ) ? ' eael-toc-auto-collapse collapsed' : ' ';
$el_class .= ( $hide_mobile == 'yes' ) ? ' eael-toc-mobile-hide' : ' ';
$toc_style_class = ' eael-toc-list-' . $toc_style;
$toc_style_class .= ( $toc_collapse == 'yes' ) ? ' eael-toc-collapse' : ' ';
$toc_style_class .= ( $list_icon == 'number' ) ? ' eael-toc-number' : ' eael-toc-bullet';
$toc_style_class .= ( $toc_word_wrap == 'yes' ) ? ' eael-toc-word-wrap' : ' ';
$toc_style_class .= ( $auto_highlight == 'yes' ) ? ' eael-toc-auto-highlight' : ' ';
$toc_style_class .= ( $auto_highlight == 'yes' && $auto_highlight_single_item_only == 'yes' ) ? ' eael-toc-highlight-single-item' : ' ';
$title_url = ( $title_to_url == 'yes' ) ? 'true' : 'false';
$icon_html = ! empty( $icon_check['value'] ) ? "<i class='" . esc_attr( $icon_check['value'] ) . "'></i>" : '';
$table_of_content_html = "<div data-eaelTocTag='" . esc_attr( $support_tag ) . "' data-contentSelector='" . esc_attr( $content_selector ) . "' data-excludeSelector='" . esc_attr( $exclude_selector ) . "' data-stickyScroll='" . esc_attr( $sticky_scroll['size'] ) . "' data-titleUrl='" . esc_attr( $title_url ) . "' data-page_offset='" . esc_attr( $page_offset ) . "' id='eael-toc' class='" . esc_attr( $el_class ) . " '>
<div class='eael-toc-header'>
<span class='eael-toc-close'>×</span>
<{$toc_title_tag} class='eael-toc-title'>{$toc_title}</{$toc_title_tag}>
</div>
<div class='eael-toc-body'>
<ul id='eael-toc-list' class='eael-toc-list " . esc_attr( $toc_style_class ) . "'></ul>
</div>
<button class='eael-toc-button'>" . wp_kses( $icon_html, [ 'i' => [ 'class' => [] ] ] ) . "<span>{$toc_title}</span></button>
</div>";
$is_toc_enabled = $this->get_extensions_value( 'eael_ext_table_of_content' );
$should_render_toc = 'yes' === $is_toc_enabled;
if ( 'yes' !== $is_toc_enabled ) {
$toc_global_display_condition = $this->get_extensions_value( 'eael_ext_toc_global_display_condition' );
if ( 'page' === $toc_global_display_condition ) {
$should_render_toc = is_page();
} else if ( 'post' === $toc_global_display_condition ) {
$should_render_toc = is_single();
} else if ( 'all' === $toc_global_display_condition ){
$should_render_toc = true;
} else if ( get_post_type() === $toc_global_display_condition ){
$should_render_toc = true;
}
if ( get_post_status( $this->get_extensions_value( 'post_id' ) ) !== 'publish' ) {
$should_render_toc = false;
}
}
// Exclude TOC configured page / post based on display condition
if ( $toc_status && $toc_status_global ) {
$toc_global_display_condition = $this->get_extensions_value( 'eael_ext_toc_global_display_condition' );
if ( 'page' === $toc_global_display_condition ) {
$should_render_toc = is_page();
} else if ( 'post' === $toc_global_display_condition ) {
$should_render_toc = is_single();
} else if ( 'all' === $toc_global_display_condition ){
$should_render_toc = true;
} else if ( get_post_type() === $toc_global_display_condition ){
$should_render_toc = true;
}
}
if( ! $should_render_toc ){
$table_of_content_html = '';
}
if ( ! empty( $table_of_content_html ) ) {
wp_enqueue_style( 'eael-table-of-content' );
wp_enqueue_script( 'eael-table-of-content' );
$html .= $table_of_content_html;
}
}
}
//Scroll to Top
if ( $this->get_settings( 'scroll-to-top' ) == true ) {
if ( isset( $document ) && is_object( $document ) ) {
$document_settings_data = $document->get_settings();
}
$scroll_to_top_status = $scroll_to_top_status_global = false;
if ( isset( $document_settings_data['eael_ext_scroll_to_top'] ) && $document_settings_data['eael_ext_scroll_to_top'] == 'yes' ) {
$scroll_to_top_status = true;
$settings_data_scroll_to_top = $document_settings_data;
} elseif ( isset( $global_settings['eael_ext_scroll_to_top']['enabled'] ) && $global_settings['eael_ext_scroll_to_top']['enabled'] ) {
$scroll_to_top_status = true;
$scroll_to_top_status_global = true;
$settings_data_scroll_to_top = $global_settings['eael_ext_scroll_to_top'];
}
if ( $scroll_to_top_status ) {
if ( $scroll_to_top_status_global ) {
//global status is true only when locally scroll to top is disabled.
$this->scroll_to_top_global_css( $global_settings );
}
$scroll_to_top_icon_image = ! empty( $settings_data_scroll_to_top['eael_ext_scroll_to_top_button_icon_image'] )
? $settings_data_scroll_to_top['eael_ext_scroll_to_top_button_icon_image']['value'] : '';
$scroll_to_top_icon_html = \Essential_Addons_Elementor\Classes\Helper::get_render_icon( $settings_data_scroll_to_top['eael_ext_scroll_to_top_button_icon_image'] ?? '' );
$scroll_to_top_html = "<div class='eael-ext-scroll-to-top-wrap scroll-to-top-hide'><span class='eael-ext-scroll-to-top-button'>$scroll_to_top_icon_html</span></div>";
$scroll_to_top_global_display_condition = isset( $settings_data_scroll_to_top['eael_ext_scroll_to_top_global_display_condition'] ) ? $settings_data_scroll_to_top['eael_ext_scroll_to_top_global_display_condition'] : 'all';
if ( isset( $settings_data_scroll_to_top['post_id'] ) && $settings_data_scroll_to_top['post_id'] != get_the_ID() ) {
if ( get_post_status( $settings_data_scroll_to_top['post_id'] ) != 'publish' ) {
$scroll_to_top_html = '';
} else if ( $scroll_to_top_global_display_condition == 'pages' && ! is_page() ) {
$scroll_to_top_html = '';
} else if ( $scroll_to_top_global_display_condition == 'posts' && ! is_single() ) {
$scroll_to_top_html = '';
}
}
if ( ! empty( $scroll_to_top_html ) ) {
wp_enqueue_script( 'eael-scroll-to-top' );
wp_enqueue_style( 'eael-scroll-to-top' );
$html .= $scroll_to_top_html;
}
}
}
printf( '%1$s', $html );
}
/**
* @param $post_css
* @param $elements
*
* @return string|void
*/
public function toc_global_css( $global_settings ) {
$eael_toc = $global_settings['eael_ext_table_of_content'];
$eael_toc_width = isset( $eael_toc['eael_ext_toc_width']['size'] ) ? $eael_toc['eael_ext_toc_width']['size'] : 300;
$toc_list_color_active = $eael_toc['eael_ext_table_of_content_list_text_color_active'];
$toc_list_separator_style = $eael_toc['eael_ext_table_of_content_list_separator_style'];
$header_padding = $eael_toc['eael_ext_toc_header_padding'];
$body_padding = $eael_toc['eael_ext_toc_body_padding'];
$header_typography = $this->get_typography_data( 'eael_ext_table_of_content_header_typography', $eael_toc );
$list_typography = $this->get_typography_data( 'eael_ext_table_of_content_list_typography_normal', $eael_toc );
$box_shadow = $eael_toc['eael_ext_toc_table_box_shadow_box_shadow'];
$border_radius = $eael_toc['eael_ext_toc_box_border_radius']['size'];
$bullet_size = $eael_toc['eael_ext_toc_box_list_bullet_size']['size'];
$top_position = $eael_toc['eael_ext_toc_box_list_top_position']['size'];
$indicator_size = $eael_toc['eael_ext_toc_indicator_size']['size'];
$indicator_position = $eael_toc['eael_ext_toc_indicator_position']['size'];
$close_bt_box_shadow = $eael_toc['eael_ext_table_of_content_close_button_box_shadow'];
$toc_global_css = "
.eael-toc-global .eael-toc-header,
.eael-toc-global.collapsed .eael-toc-button
{
background-color:{$eael_toc['eael_ext_table_of_content_header_bg']};
}
.eael-toc-global {
width:{$eael_toc_width}px;
z-index:{$eael_toc['eael_ext_toc_sticky_z_index']['size']};
}
.eael-toc-global.eael-sticky {
top:{$eael_toc['eael_ext_toc_sticky_offset']['size']};
}
.eael-toc-global .eael-toc-header .eael-toc-title,
.eael-toc-global.collapsed .eael-toc-button
{
color:{$eael_toc['eael_ext_table_of_content_header_text_color']};
$header_typography
}
.eael-toc-global .eael-toc-header {
padding:{$header_padding['top']}px {$header_padding['right']}px {$header_padding['bottom']}px {$header_padding['left']}px;
}
.eael-toc-global .eael-toc-body {
padding:{$body_padding['top']}px {$body_padding['right']}px {$body_padding['bottom']}px {$body_padding['left']}px;
}
.eael-toc-global .eael-toc-close
{
font-size: {$eael_toc['eael_ext_table_of_content_close_button_icon_size']['size']}px !important;
height: {$eael_toc['eael_ext_table_of_content_close_button_size']['size']}px !important;
width: {$eael_toc['eael_ext_table_of_content_close_button_size']['size']}px !important;
line-height: {$eael_toc['eael_ext_table_of_content_close_button_line_height']['size']}px !important;
color:{$eael_toc['eael_ext_table_of_content_close_button_text_color']} !important;
background-color:{$eael_toc['eael_ext_table_of_content_close_button_bg']} !important;
border-radius: {$eael_toc['eael_ext_table_of_content_close_button_border_radius']['size']}px !important;
box-shadow:{$close_bt_box_shadow['horizontal']}px {$close_bt_box_shadow['vertical']}px {$close_bt_box_shadow['blur']}px {$close_bt_box_shadow['spread']}px {$close_bt_box_shadow['color']} !important;
}
.eael-toc-global.eael-toc:not(.collapsed)
{
box-shadow:{$box_shadow['horizontal']}px {$box_shadow['vertical']}px {$box_shadow['blur']}px {$box_shadow['spread']}px {$box_shadow['color']};
}
.eael-toc-global .eael-toc-body
{
background-color:{$eael_toc['eael_ext_table_of_content_body_bg']};
}
.eael-toc-global .eael-toc-body ul.eael-toc-list.eael-toc-bullet li:before
{
width:{$bullet_size}px;
height:{$bullet_size}px;
top:{$top_position}px;
}
.eael-toc-global .eael-toc-body .eael-toc-list li,
.eael-toc-global .eael-toc-body .eael-toc-list.eael-toc-number li:before,
.eael-toc-global .eael-toc-body .eael-toc-list li a
{
color:{$eael_toc['eael_ext_table_of_content_list_text_color']} !important;
}
.eael-toc-global .eael-toc-body .eael-toc-list.eael-toc-bullet li:before {
background-color:{$eael_toc['eael_ext_table_of_content_list_text_color']} !important;
}
.eael-toc-global .eael-toc-body .eael-toc-list li:hover,
.eael-toc-global .eael-toc-body .eael-toc-list.eael-toc-number li:hover:before,
.eael-toc-global .eael-toc-body .eael-toc-list li:hover > a
{
color:{$eael_toc['eael_ext_table_of_list_hover_color']} !important;
}
.eael-toc-global .eael-toc-body .eael-toc-list li:hover > a:before {
border-bottom-color:{$eael_toc['eael_ext_table_of_list_hover_color']} !important;
}
.eael-toc-global .eael-toc-body .eael-toc-list.eael-toc-bullet li:hover:before,
.eael-toc-global .eael-toc-body .eael-toc-list li:hover > a:after {
background-color:{$eael_toc['eael_ext_table_of_list_hover_color']} !important;
}
.eael-toc-global .eael-toc-body .eael-toc-list li.eael-highlight-active,
.eael-toc-global .eael-toc-body .eael-toc-list.eael-toc-number li.eael-highlight-active:before,
.eael-toc-global .eael-toc-body .eael-toc-list li.eael-highlight-active > a,
.eael-toc-global .eael-toc-body .eael-toc-list li.eael-highlight-parent,
.eael-toc-global .eael-toc-body .eael-toc-list.eael-toc-number li.eael-highlight-parent:before,
.eael-toc-global .eael-toc-body .eael-toc-list li.eael-highlight-parent > a
{
color:$toc_list_color_active !important;
}
.eael-toc-global .eael-toc-body .eael-toc-list li.eael-highlight-active > a:before
{
border-bottom-color:$toc_list_color_active !important;
}
.eael-toc-global .eael-toc-body .eael-toc-list.eael-toc-bullet li.eael-highlight-active:before,
.eael-toc-global .eael-toc-body .eael-toc-list li.eael-highlight-active > a:after,
.eael-toc-global .eael-toc-body .eael-toc-list.eael-toc-bullet li.eael-highlight-parent:before
{
background-color:$toc_list_color_active !important;
}
.eael-toc-global ul.eael-toc-list > li
{
color:{$eael_toc['eael_ext_table_of_content_list_separator_color']} !important;
$list_typography
}
.eael-toc.eael-toc-global .eael-toc-body ul.eael-toc-list li:before {
$list_typography
}
.eael-toc-global .eael-toc-body .eael-toc-list.eael-toc-list-bar li.eael-highlight-active > a:after {
height:{$indicator_size}px;
}
.eael-toc-global .eael-toc-body .eael-toc-list.eael-toc-list-arrow li.eael-highlight-active > a:before,
.eael-toc-global .eael-toc-body .eael-toc-list.eael-toc-list-bar li.eael-highlight-active > a:after {
margin-top:{$indicator_position}px;
}
.eael-toc:not(.eael-toc-right)
{
border-top-right-radius:{$border_radius}px;
border-bottom-right-radius:{$border_radius}px;
}
.eael-toc:not(.eael-toc-right) .eael-toc-header
{
border-top-right-radius:{$border_radius}px;
}
.eael-toc:not(.eael-toc-right) .eael-toc-body {
border-bottom-right-radius:{$border_radius}px;
}
.eael-toc.eael-toc-right {
border-top-left-radius:{$border_radius}px;
border-bottom-left-radius:{$border_radius}px;
}
.eael-toc.eael-toc-right .eael-toc-header {
border-top-left-radius:{$border_radius}px;
}
.eael-toc.eael-toc-right .eael-toc-body {
border-bottom-left-radius:{$border_radius}px;
}
#eael-toc.eael-toc-global ul.eael-toc-list > li
{
padding-top:{$eael_toc['eael_ext_toc_top_level_space']['size']}px;
padding-bottom:{$eael_toc['eael_ext_toc_top_level_space']['size']}px;
}
#eael-toc.eael-toc-global ul.eael-toc-list>li ul li
{
padding-top:{$eael_toc['eael_ext_toc_subitem_level_space']['size']}px;
padding-bottom:{$eael_toc['eael_ext_toc_subitem_level_space']['size']}px;
}
";
if ( $toc_list_separator_style != 'none' ) {
$toc_global_css .= "
.eael-toc-global ul.eael-toc-list > li
{border-top: 0.5px $toc_list_separator_style !important;}
.eael-toc ul.eael-toc-list>li:first-child
{border: none !important;}";
}
if ( isset( $eael_toc['eael_ext_toc_border_border'] ) ) {
$border_width = $eael_toc['eael_ext_toc_border_width'];
$toc_global_css .= "
.eael-toc.eael-toc-global,.eael-toc-global button.eael-toc-button
{
border-style: {$eael_toc['eael_ext_toc_border_border']};
border-width: {$border_width['top']}px {$border_width['right']}px {$border_width['bottom']}px {$border_width['left']}px;
border-color: {$eael_toc['eael_ext_toc_border_color']};
}";
}
wp_add_inline_style( 'eael-table-of-content', $toc_global_css );
}
/**
* @param $document_settings
*
* @return string|void
*/
public function progress_bar_local_css( $document_settings ) {
$eael_reading_progress_fill_color = isset( $document_settings['eael_ext_reading_progress_fill_color'] ) ? $document_settings['eael_ext_reading_progress_fill_color'] : '';
$reading_progress_local_css = '';
$eael_reading_progress_id_selector = '#eael-reading-progress-' . get_the_ID();
if( ! empty( $eael_reading_progress_fill_color ) ){
$reading_progress_local_css .= "
{$eael_reading_progress_id_selector} .eael-reading-progress .eael-reading-progress-fill {
background-color: {$eael_reading_progress_fill_color};
}
";
}
wp_add_inline_style( 'eael-reading-progress', $reading_progress_local_css );
}
/**
* @return string|void
*/
public function scroll_to_top_global_css( $global_settings ) {
if ( ! is_array( $global_settings ) ) {
return false;
}
if ( empty( $global_settings['eael_ext_scroll_to_top'] ) ) {
return false;
}
$eael_scroll_to_top = $global_settings['eael_ext_scroll_to_top'];
$eael_stt_position = $eael_scroll_to_top['eael_ext_scroll_to_top_position_text'];
$eael_stt_position_bottom_size = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_position_bottom']['size'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_position_bottom']['size'] : 5;
$eael_stt_position_bottom_unit = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_position_bottom']['unit'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_position_bottom']['unit'] : 'px';
$eael_stt_position_left_size = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_position_left']['size'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_position_left']['size'] : 15;
$eael_stt_position_left_unit = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_position_left']['unit'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_position_left']['unit'] : 'px';
$eael_stt_position_right_size = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_position_right']['size'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_position_right']['size'] : 15;
$eael_stt_position_right_unit = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_position_right']['unit'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_position_right']['unit'] : 'px';
$eael_stt_button_width_size = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_button_width']['size'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_button_width']['size'] : 50;
$eael_stt_button_width_unit = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_button_width']['unit'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_button_width']['unit'] : 'px';
$eael_stt_button_height_size = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_button_height']['size'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_button_height']['size'] : 50;
$eael_stt_button_height_unit = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_button_height']['unit'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_button_height']['unit'] : 'px';
$eael_stt_z_index_size = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_z_index']['size'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_z_index']['size'] : 9999;
$eael_stt_z_index_unit = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_z_index']['unit'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_z_index']['unit'] : 'px';
$eael_stt_button_opacity_size = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_button_opacity']['size'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_button_opacity']['size'] : 0.7;
$eael_stt_button_opacity_unit = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_button_opacity']['unit'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_button_opacity']['unit'] : 'px';
$eael_stt_button_icon_size_size = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_button_icon_size']['size'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_button_icon_size']['size'] : 16;
$eael_stt_button_icon_size_unit = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_button_icon_size']['unit'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_button_icon_size']['unit'] : 'px';
$eael_stt_button_icon_svg_size_size = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_button_icon_svg_size']['size'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_button_icon_svg_size']['size'] : 32;
$eael_stt_button_icon_svg_size_unit = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_button_icon_svg_size']['unit'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_button_icon_svg_size']['unit'] : 'px';
$eael_stt_button_icon_color = $eael_scroll_to_top['eael_ext_scroll_to_top_button_icon_color'];
$eael_stt_button_bg_color = $eael_scroll_to_top['eael_ext_scroll_to_top_button_bg_color'];
$eael_stt_button_border_radius_size = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_button_border_radius']['size'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_button_border_radius']['size'] : 5;
$eael_stt_button_border_radius_unit = isset( $eael_scroll_to_top['eael_ext_scroll_to_top_button_border_radius']['unit'] ) ? $eael_scroll_to_top['eael_ext_scroll_to_top_button_border_radius']['unit'] : 'px';
$eael_stt_position_left_right_key = $eael_stt_position == 'bottom-left' ? 'left' : 'right';
$eael_stt_position_left_right_value = $eael_stt_position == 'bottom-left' ? $eael_stt_position_left_size . $eael_stt_position_left_unit : $eael_stt_position_right_size . $eael_stt_position_right_unit;
$scroll_to_top_global_css = "
.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button {
bottom: {$eael_stt_position_bottom_size}{$eael_stt_position_bottom_unit};
{$eael_stt_position_left_right_key}: {$eael_stt_position_left_right_value};
width: {$eael_stt_button_width_size}{$eael_stt_button_width_unit};
height: {$eael_stt_button_height_size}{$eael_stt_button_height_unit};
z-index: {$eael_stt_z_index_size};
opacity: {$eael_stt_button_opacity_size};
background-color: {$eael_stt_button_bg_color};
border-radius: {$eael_stt_button_border_radius_size}{$eael_stt_button_border_radius_unit};
}
.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button i {
color: {$eael_stt_button_icon_color};
font-size: {$eael_stt_button_icon_size_size}{$eael_stt_button_icon_size_unit};
}
.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button svg {
fill: {$eael_stt_button_icon_color};
width: {$eael_stt_button_icon_svg_size_size}{$eael_stt_button_icon_svg_size_unit};
height: {$eael_stt_button_icon_svg_size_size}{$eael_stt_button_icon_svg_size_unit};
}
";
wp_add_inline_style( 'eael-scroll-to-top', $scroll_to_top_global_css );
}
/**
* Register WC Hooks
*/
public function register_wc_hooks() {
if ( class_exists( 'WooCommerce' ) ) {
wc()->frontend_includes();
}
}
public function get_extensions_value( $key = '' ) {
return isset( $this->extensions_data[ $key ] ) ? $this->extensions_data[ $key ] : '';
}
/**
* Single instance for all advanced accordion faqs
*
* @return void
*/
public function render_advanced_accordion_global_faq(){
if( count( Helper::get_eael_advanced_accordion_faq() )) : ?>
<!-- EA FAQ Schema : Starts-->
<script type="application/ld+json">
<?php echo json_encode( Helper::get_eael_advanced_accordion_faq() ); ?>
</script>
<!-- EA FAQ Schema : Ends-->
<?php endif;
}
}

View File

@@ -0,0 +1,148 @@
<?php
namespace Essential_Addons_Elementor\Traits;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
use \Essential_Addons_Elementor\Classes\Helper as EnqueueHelper;
trait Enqueue
{
public function before_enqueue_styles( $widgets ) {
$widgets = (array) $widgets;
// Compatibility: Gravity forms
if ( in_array( 'gravity-form', $widgets ) && class_exists( 'GFCommon' ) ) {
foreach ( EnqueueHelper::get_gravity_form_list() as $form_id => $form_name ) {
if ( $form_id != '0' ) {
gravity_form_enqueue_scripts( $form_id );
}
}
}
// Compatibility: WPforms
if (in_array('wpforms', $widgets) && function_exists('wpforms')) {
wpforms()->frontend->assets_css();
}
// Compatibility: Caldera forms
if (in_array('caldera-form', $widgets) && class_exists('Caldera_Forms')) {
add_filter('caldera_forms_force_enqueue_styles_early', '__return_true');
}
// Compatibility: reCaptcha with login/register
if (in_array('login-register', $widgets) && $site_key = get_option('eael_recaptcha_sitekey')) {
$recaptcha_api_args['render'] = 'explicit';
if ( $recaptcha_language = get_option( 'eael_recaptcha_language' ) ) {
$recaptcha_api_args['hl'] = $recaptcha_language;
}
$recaptcha_api_args = apply_filters( 'eael_lr_recaptcha_api_args', $recaptcha_api_args );
$recaptcha_api_args = http_build_query( $recaptcha_api_args );
wp_register_script('eael-recaptcha', "https://www.recaptcha.net/recaptcha/api.js?{$recaptcha_api_args}", false, EAEL_PLUGIN_VERSION, false);
}
}
// editor styles
public function editor_enqueue_scripts()
{
// ea icon font
wp_enqueue_style(
'ea-icon',
$this->safe_url(EAEL_PLUGIN_URL . 'assets/admin/css/eaicon.css'),
false,
EAEL_PLUGIN_VERSION
);
// editor style
wp_enqueue_style(
'eael-editor',
$this->safe_url(EAEL_PLUGIN_URL . 'assets/admin/css/editor.css'),
false,
EAEL_PLUGIN_VERSION
);
}
// frontend styles
public function frontend_enqueue_scripts()
{
// ea icon font
wp_register_style(
'ea-icon-frontend',
$this->safe_url(EAEL_PLUGIN_URL . 'assets/admin/css/eaicon.css'),
false,
EAEL_PLUGIN_VERSION
);
}
// templately promo enqueue scripts
public function templately_promo_enqueue_scripts(){
// enqueue
wp_register_script(
'templately-promo',
EAEL_PLUGIN_URL . 'assets/admin/js/eael-templately-promo.js',
['jquery'],
EAEL_PLUGIN_VERSION
);
wp_localize_script('templately-promo','localize',[
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'essential-addons-elementor' ),
]);
wp_enqueue_script('templately-promo');
// enqueue
wp_enqueue_style(
'templately-promo',
EAEL_PLUGIN_URL . 'assets/admin/css/eael-templately-promo.css',
EAEL_PLUGIN_VERSION
);
}
public function templately_promo_enqueue_style(){
$src = EAEL_PLUGIN_URL . 'assets/admin/images/templately/logo-icon.svg';
$css = "
.elementor-add-new-section .elementor-add-templately-promo-button{
background-color: #5d4fff;
background-image: url({$src});
background-repeat: no-repeat;
background-position: center center;
position: relative;
}
.elementor-add-new-section .elementor-add-templately-promo-button > i{
height: 12px;
}
body .elementor-add-new-section .elementor-add-section-area-button {
margin-left: 0;
}";
wp_add_inline_style( 'elementor-icons', $css );
}
public function essential_blocks_promo_enqueue_scripts() {
if ( is_plugin_active( 'essential-blocks/essential-blocks.php' ) || get_option( 'eael_gb_eb_popup_hide' ) ) {
return;
}
add_action( 'admin_footer', [ $this, 'essential_blocks_promo_admin_js_template' ] );
wp_enqueue_script( 'eael-gutenberg', $this->safe_url( EAEL_PLUGIN_URL . 'assets/admin/js/eael-essential-blocks-promo.js' ), [ 'jquery' ], EAEL_PLUGIN_VERSION, true );
wp_enqueue_style( 'eael-gutenberg', $this->safe_url( EAEL_PLUGIN_URL . 'assets/admin/css/eael-essential-blocks-promo.css' ), [], EAEL_PLUGIN_VERSION );
}
// replace beehive theme's swiper slider lib file with elementor's swiper lib file
public function beehive_theme_swiper_slider_compatibility( $scripts ) {
unset( $scripts['swiper'] );
unset( $scripts['beehive-elements'] );
$scripts['beehive-elements'] = array(
'src' => EAEL_PLUGIN_URL . 'assets/front-end/js/view/beehive-elements.min.js',
'deps' => array( 'jquery' ),
'in_footer' => true,
'enqueue' => true,
);
return $scripts;
}
}

View File

@@ -0,0 +1,294 @@
<?php
namespace Essential_Addons_Elementor\Traits;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
use \Essential_Addons_Elementor\Classes\Helper as HelperClass;
trait Facebook_Feed {
/**
* Facebook Feed
*
* @param array $settings optional widget's settings
*
* @return false|string|void
* @since 3.4.0
*/
public function facebook_feed_render_items( $settings = [] ) {
// check if ajax request
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'facebook_feed_load_more' ) {
$ajax = wp_doing_ajax();
// check ajax referer
check_ajax_referer( 'essential-addons-elementor', 'security' );
// init vars
$page = isset( $_POST['page'] ) ? intval( $_REQUEST['page'], 10 ) : 0;
if ( ! empty( $_POST['post_id'] ) ) {
$post_id = intval( $_POST['post_id'], 10 );
} else {
$err_msg = __( 'Post ID is missing', 'essential-addons-for-elementor-lite' );
if ( $ajax ) {
wp_send_json_error( $err_msg );
}
return false;
}
if ( ! empty( $_POST['widget_id'] ) ) {
$widget_id = sanitize_text_field( $_POST['widget_id'] );
} else {
$err_msg = __( 'Widget ID is missing', 'essential-addons-for-elementor-lite' );
if ( $ajax ) {
wp_send_json_error( $err_msg );
}
return false;
}
$settings = HelperClass::eael_get_widget_settings( $post_id, $widget_id );
} else {
// init vars
$page = 0;
$settings = ! empty( $settings ) ? $settings : $this->get_settings_for_display();
}
$html = '';
$page_id = $settings['eael_facebook_feed_page_id'];
$token = $settings['eael_facebook_feed_access_token'];
$source = $settings['eael_facebook_feed_data_source'];
$display_comment = isset( $settings['eael_facebook_feed_comments'] ) ? $settings['eael_facebook_feed_comments'] : '';
if ( empty( $page_id ) || empty( $token ) ) {
return;
}
$key = 'eael_facebook_feed_' . md5( str_rot13( str_replace( '.', '', $source . $page_id . $token ) ) . $settings['eael_facebook_feed_cache_limit'] );
$facebook_data = get_transient( $key );
if ( $facebook_data == false ) {
$facebook_data = wp_remote_retrieve_body( wp_remote_get( $this->get_url($page_id, $token, $source, $display_comment), [
'timeout' => 70,
] ) );
$facebook_data = json_decode( $facebook_data, true );
if ( isset( $facebook_data['data'] ) ) {
set_transient( $key, $facebook_data, ( $settings['eael_facebook_feed_cache_limit'] * MINUTE_IN_SECONDS ) );
}
}
if ( ! isset( $facebook_data['data'] ) ) {
return;
}
$facebook_data = $facebook_data['data'];
switch ( $settings['eael_facebook_feed_sort_by'] ) {
case 'least-recent':
$facebook_data = array_reverse( $facebook_data );
break;
}
$items = array_splice( $facebook_data, ( $page * $settings['eael_facebook_feed_image_count']['size'] ), $settings['eael_facebook_feed_image_count']['size'] );
$bg_style = isset( $settings['eael_facebook_feed_image_render_type'] ) && $settings['eael_facebook_feed_image_render_type'] == 'cover' ? "background-size: cover;background-position: center;background-repeat: no-repeat;" : "background-size: 100% 100%;background-repeat: no-repeat;";
foreach ( $items as $item ) {
$t = 'eael_facebook_feed_message_max_length'; // short it
$limit = isset( $settings[ $t ] ) && isset( $settings[ $t ]['size'] ) ? $settings[ $t ]['size'] : null;
$message = wp_trim_words( ( isset( $item['message'] ) ? $item['message'] : ( isset( $item['story'] ) ? $item['story'] : '' ) ), $limit, '...' );
$photo = ( isset( $item['full_picture'] ) ? esc_url( $item['full_picture'] ) : '' );
$likes = ( isset( $item['reactions'] ) ? $item['reactions']['summary']['total_count'] : 0 );
$comments = ( isset( $item['comments'] ) ? $item['comments']['summary']['total_count'] : 0 );
if ( empty( $photo ) ) {
$photo = isset( $item['attachments']['data'][0]['media']['image']['src'] ) ? esc_url( $item['attachments']['data'][0]['media']['image']['src'] ) : $photo;
}
if ( $settings['eael_facebook_feed_layout'] == 'card' ) {
$item_form_name = ! empty( $item['from']['name'] ) ? $item['from']['name'] : '';
$current_page_id = ! empty( $item['from']['id'] ) ? $item['from']['id'] : $page_id;
$html .= '<div class="eael-facebook-feed-item">
<div class="eael-facebook-feed-item-inner">
<header class="eael-facebook-feed-item-header clearfix">
<div class="eael-facebook-feed-item-user clearfix">
<a href="https://www.facebook.com/' . $current_page_id . '" target="' . ( $settings['eael_facebook_feed_link_target'] == 'yes' ? '_blank' : '_self' ) . '"><img src="https://graph.facebook.com/v4.0/' . $current_page_id . '/picture" alt="' . esc_attr( $item_form_name ) . '" class="eael-facebook-feed-avatar"></a>
<a href="https://www.facebook.com/' . $current_page_id . '" target="' . ( $settings['eael_facebook_feed_link_target'] == 'yes' ? '_blank' : '_self' ) . '"><p class="eael-facebook-feed-username">' . esc_html( $item_form_name ) . '</p></a>
</div>';
if ( $settings['eael_facebook_feed_date'] ) {
$html .= '<a href="' . esc_url( $item['permalink_url'] ) . '" target="' . ( $settings['eael_facebook_feed_link_target'] ? '_blank' : '_self' ) . '" class="eael-facebook-feed-post-time"><i class="far fa-clock" aria-hidden="true"></i> ' . date_i18n( get_option('date_format'), strtotime( $item['created_time'] ) ) . '</a>';
}
$html .= '</header>';
if ( $settings['eael_facebook_feed_message'] && ! empty( $message ) ) {
$html .= '<div class="eael-facebook-feed-item-content">
<p class="eael-facebook-feed-message">' . $this->eael_str_check( $message ) . '</p>
</div>';
}
if ( ! empty( $photo ) || isset( $item['attachments']['data'] ) ) {
$html .= '<div class="eael-facebook-feed-preview-wrap">';
if ( $item['status_type'] == 'shared_story' ) {
if ( isset( $settings['eael_facebook_feed_is_show_preview_thumbnail'] ) && 'yes' == $settings['eael_facebook_feed_is_show_preview_thumbnail'] ) {
$html .= '<a href="' . esc_url( $item['permalink_url'] ) . '" target="' . ( $settings['eael_facebook_feed_link_target'] == 'yes' ? '_blank' : '_self' ) . '" class="eael-facebook-feed-preview-img">';
if ( !empty($item['attachments']['data'][0]['media_type']) && $item['attachments']['data'][0]['media_type'] == 'video' ) {
$html .= '<div class="eael-facebook-feed-img-container" style="background:url(' . esc_url( $photo ) . ');' . esc_attr( $bg_style ) . '">
<img class="eael-facebook-feed-img" src="' . esc_url( $photo ) . '"></div>
<div class="eael-facebook-feed-preview-overlay"><i class="far fa-play-circle" aria-hidden="true"></i></div>';
} else {
$html .= '<div class="eael-facebook-feed-img-container" style="background:url(' . esc_url( $photo ) . ');' . esc_attr( $bg_style ) . '">
<img class="eael-facebook-feed-img" src="' . esc_url( $photo ) . '"></div>';
}
$html .= '</a>';
}
$html .= '<div class="eael-facebook-feed-url-preview">';
if ( isset( $settings['eael_facebook_feed_is_show_preview_host'] ) && 'yes' == $settings['eael_facebook_feed_is_show_preview_host'] && !empty($item['attachments']['data'][0]['unshimmed_url']) ) {
$html .= '<p class="eael-facebook-feed-url-host">' . parse_url( $item['attachments']['data'][0]['unshimmed_url'] )['host'] . '</p>';
}
if ( isset( $settings['eael_facebook_feed_is_show_preview_title'] ) && 'yes' == $settings['eael_facebook_feed_is_show_preview_title'] ) {
$html .= '<h2 class="eael-facebook-feed-url-title">' . esc_html( $item['attachments']['data'][0]['title'] ) . '</h2>';
}
if ( isset( $settings['eael_facebook_feed_is_show_preview_description'] ) && 'yes' == $settings['eael_facebook_feed_is_show_preview_description'] ) {
$description = isset( $item['attachments']['data'][0]['description'] ) ? $item['attachments']['data'][0]['description'] : '';
$html .= '<p class="eael-facebook-feed-url-description">' . $description . '</p>';
}
$html .= '</div>';
} else if ( $item['status_type'] == 'added_video' ) {
if ( isset( $settings['eael_facebook_feed_is_show_preview_thumbnail'] ) && 'yes' == $settings['eael_facebook_feed_is_show_preview_thumbnail'] ) {
$html .= '<a href="' . esc_url( $item['permalink_url'] ) . '" target="' . ( $settings['eael_facebook_feed_link_target'] == 'yes' ? '_blank' : '_self' ) . '" class="eael-facebook-feed-preview-img">
<div class="eael-facebook-feed-img-container" style="background:url(' . esc_url( $photo ) . '); ' . esc_attr( $bg_style ) . '">
<img class="eael-facebook-feed-img" src="' . esc_url( $photo ) . '">
</div>
<div class="eael-facebook-feed-preview-overlay"><i class="far fa-play-circle" aria-hidden="true"></i></div>
</a>';
}
} else {
if ( isset( $settings['eael_facebook_feed_is_show_preview_thumbnail'] ) && 'yes' == $settings['eael_facebook_feed_is_show_preview_thumbnail'] ) {
$html .= '<a href="' . esc_url( $item['permalink_url'] ) . '" target="' . ( $settings['eael_facebook_feed_link_target'] == 'yes' ? '_blank' : '_self' ) . '" class="eael-facebook-feed-preview-img">
<div class="eael-facebook-feed-img-container" style="background:url(' . esc_url( $photo ) . '); ' . esc_attr( $bg_style ) . '">
<img class="eael-facebook-feed-img" src="' . esc_url( $photo ) . '">
</div>
</a>';
}
}
$html .= '</div>';
}
if ( $settings['eael_facebook_feed_likes'] || $settings['eael_facebook_feed_comments'] ) {
$html .= '<footer class="eael-facebook-feed-item-footer">
<div class="clearfix">';
if ( $settings['eael_facebook_feed_likes'] ) {
$html .= '<span class="eael-facebook-feed-post-likes"><i class="far fa-thumbs-up" aria-hidden="true"></i> ' . esc_html( $likes ) . '</span>';
}
if ( $settings['eael_facebook_feed_comments'] ) {
$html .= '<span class="eael-facebook-feed-post-comments"><i class="far fa-comments" aria-hidden="true"></i> ' . esc_html( $comments ) . '</span>';
}
$html .= '</div>
</footer>';
}
$html .= '</div>
</div>';
} else {
$html .= '<a href="' . esc_url( $item['permalink_url'] ) . '" target="' . ( $settings['eael_facebook_feed_link_target'] ? '_blank' : '_self' ) . '" class="eael-facebook-feed-item">
<div class="eael-facebook-feed-item-inner">
<div class="eael-facebook-feed-img-container" style="background:url(' . ( empty( $photo ) ? EAEL_PLUGIN_URL . 'assets/front-end/img/flexia-preview.jpg' : esc_url( $photo ) ) . '); ' . esc_attr( $bg_style ) . '">
<img class="eael-facebook-feed-img" src="' . ( empty( $photo ) ? EAEL_PLUGIN_URL . 'assets/front-end/img/flexia-preview.jpg' : esc_url( $photo ) ) . '">
</div>';
if ( $settings['eael_facebook_feed_likes'] || $settings['eael_facebook_feed_comments'] ) {
$html .= '<div class="eael-facebook-feed-item-overlay">
<div class="eael-facebook-feed-item-overlay-inner">
<div class="eael-facebook-feed-meta">';
if ( $settings['eael_facebook_feed_likes'] ) {
$html .= '<span class="eael-facebook-feed-post-likes"><i class="far fa-thumbs-up" aria-hidden="true"></i> ' . esc_html( $likes ) . '</span>';
}
if ( $settings['eael_facebook_feed_comments'] ) {
$html .= '<span class="eael-facebook-feed-post-comments"><i class="far fa-comments" aria-hidden="true"></i> ' . esc_html( $comments ) . '</span>';
}
$html .= '</div>
</div>
</div>';
}
$html .= '</div>
</a>';
}
}
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'facebook_feed_load_more' ) {
$data = [
'num_pages' => ceil( count( $facebook_data ) / $settings['eael_facebook_feed_image_count']['size'] ),
'html' => $html,
];
while ( ob_get_status() ) {
ob_end_clean();
}
if ( function_exists( 'gzencode' ) ) {
$response = gzencode( wp_json_encode( $data ) );
header( 'Content-Type: application/json; charset=utf-8' );
header( 'Content-Encoding: gzip' );
header( 'Content-Length: ' . strlen( $response ) );
printf( '%1$s', $response );
} else {
wp_send_json( $data );
}
wp_die();
}
return $html;
}
public function eael_str_check( $textData = '' ) {
$stringText = '';
if ( strlen( $textData ) > 5 ) {
$explodeText = explode( ' ', trim( $textData ) );
for ( $st = 0; $st < count( $explodeText ); $st ++ ) {
$pos = stripos( trim( $explodeText[ $st ] ), '#' );
$pos1 = stripos( trim( $explodeText[ $st ] ), '@' );
$poshttp = stripos( trim( $explodeText[ $st ] ), 'http' );
$poshttps = stripos( trim( $explodeText[ $st ] ), 'https' );
if ( $pos !== false ) {
$stringText .= '<a href="https://facebook.com/hashtag/' . str_replace( '#', '', $explodeText[ $st ] ) . '?source=feed_text" target="_blank"> ' . esc_html( $explodeText[ $st ] ) . ' </a>';
} elseif ( $pos1 !== false ) {
$stringText .= '<a href="https://facebook.com/' . $explodeText[ $st ] . '/" target="_blank"> ' . esc_html( $explodeText[ $st ] ) . ' </a>';
} elseif ( $poshttp !== false || $poshttps !== false ) {
$stringText .= '<a href="' . esc_url( $explodeText[ $st ] ) . '" target="_blank"> ' . esc_html( $explodeText[ $st ] ) . ' </a>';
} else {
$stringText .= ' ' . $explodeText[ $st ];
}
}
}
return $stringText;
}
/**
* get_url
* Build and return api endpoint based on source type
*
* @param string $page_id string
* @param string $token string
* @param string $source string
*
* @return string
*/
public function get_url( $page_id = '', $token = '', $source = 'posts', $display_comment = '' ) {
$comment_count = $display_comment == 'yes' ? ',comments.summary(total_count)' : '';
$post_limit = apply_filters( 'eael_facebook_feed_post_limit', 99 );
$post_url = "https://graph.facebook.com/v8.0/{$page_id}/posts?fields=status_type,created_time,from,message,story,full_picture,permalink_url,attachments.limit(1){type,media_type,title,description,unshimmed_url,media}{$comment_count},reactions.summary(total_count)&limit={$post_limit}&access_token={$token}";
$feed_url = "https://graph.facebook.com/v8.0/{$page_id}/feed?fields=id,message,full_picture,status_type,created_time,attachments{title,description,type,url,media},from,permalink_url,shares,call_to_action{$comment_count},reactions.summary(total_count),privacy&access_token={$token}&limit={$post_limit}&locale=en_US";
if ( 'posts' === $source ) {
return $post_url;
}
return $feed_url;
}
}

View File

@@ -0,0 +1,735 @@
<?php
namespace Essential_Addons_Elementor\Traits;
if ( !defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
use Elementor\Plugin;
use \Essential_Addons_Elementor\Classes\Helper as HelperClass;
use \Essential_Addons_Elementor\Elements\Woo_Checkout;
use function Crontrol\Event\get;
trait Helper
{
use Template_Query;
/**
* Woo Checkout
*/
/** Filter to add plugins to the TOC list.
*
* @param array TOC plugins.
*
* @return mixed
* @since 3.9.3
*/
public function toc_rank_math_support( $toc_plugins ) {
$toc_plugins[ 'essential-addons-for-elementor-lite/essential_adons_elementor.php' ] = __( 'Essential Addons for Elementor', 'essential-addons-for-elementor-lite' );
return $toc_plugins;
}
/**
* Save typeform access token
*
* @since 4.0.2
*/
public function typeform_auth_handle() {
if ( isset($_GET[ 'page' ]) && 'eael-settings' == $_GET[ 'page' ] ) {
if ( isset( $_GET[ 'typeform_tk' ] ) && isset( $_GET[ 'pr_code' ] ) ) {
if ( wp_hash( 'eael_typeform' ) === $_GET[ 'pr_code' ] ) {
update_option( 'eael_save_typeform_personal_token', sanitize_text_field( $_GET[ 'typeform_tk' ] ), false );
}
}
}
}
/*****************************
*
* Compatibility for Pro
*
* @since 4.2.4
*/
public function eael_get_page_templates( $type = null ) {
return HelperClass::get_elementor_templates( $type );
}
public function eael_query_controls() {
return do_action( 'eael/controls/query', $this );
}
public function eael_layout_controls() {
return do_action( 'eael/controls/layout', $this );
}
public function eael_load_more_button_style() {
return do_action( 'eael/controls/load_more_button_style', $this );
}
public function eael_read_more_button_style() {
return do_action( 'eael/controls/read_more_button_style', $this );
}
public function eael_controls_custom_positioning( $_1, $_2, $_3, $_4 ) {
return do_action( 'eael/controls/custom_positioning', $this, $_1, $_2, $_3, $_4 );
}
public function eael_get_all_types_post() {
return HelperClass::get_post_types();
}
public function eael_get_pages() {
return HelperClass::get_post_list( 'page' );
}
public function eael_woocommerce_product_categories_by_id() {
return HelperClass::get_terms_list( 'product_cat' );
}
public function fix_old_query( $settings ) {
return HelperClass::fix_old_query( $settings );
}
public function eael_get_query_args( $settings ) {
return HelperClass::get_query_args( $settings );
}
public function eael_get_tags( $args ) {
return HelperClass::get_tags_list( $args );
}
public function eael_get_taxonomies_by_post( $args ) {
return HelperClass::get_taxonomies_by_post( $args );
}
/**
* It returns the widget settings provided the page id and widget id
* @param int $page_id Page ID where the widget is used
* @param string $widget_id the id of the widget whose settings we want to fetch
*
* @return array
*/
public function eael_get_widget_settings( $page_id, $widget_id ) {
$document = Plugin::$instance->documents->get( $page_id );
$settings = [];
if ( $document ) {
$elements = Plugin::instance()->documents->get( $page_id )->get_elements_data();
$widget_data = $this->find_element_recursive( $elements, $widget_id );
if(!empty($widget_data)) {
$widget = Plugin::instance()->elements_manager->create_element_instance( $widget_data );
if ( $widget ) {
$settings = $widget->get_settings_for_display();
}
}
}
return $settings;
}
/**
* It store data temporarily for 5 mins by default
*
* @param $name
* @param $data
* @param int $time time in seconds. Default is 300s = 5 minutes
*
* @return bool it returns true if the data saved, otherwise, false returned.
*/
public function eael_set_transient( $name, $data, $time = 300 ) {
$time = !empty( $time ) ? (int) $time : ( 5 * MINUTE_IN_SECONDS );
return set_transient( $name, $data, $time );
}
public function print_load_more_button($settings, $args, $plugin_type = 'free')
{
//@TODO; not all widget's settings contain posts_per_page name exactly, so adjust the settings before passing here or run a migration and make all settings key generalize for load more feature.
if (!isset($this->page_id)) {
if ( Plugin::$instance->documents->get_current() ) {
$this->page_id = Plugin::$instance->documents->get_current()->get_main_id();
}else{
$this->page_id = null;
}
}
$max_page = empty( $args['max_page'] ) ? false : $args['max_page'];
unset( $args['max_page'] );
if ( isset( $args['found_posts'] ) && $args['found_posts'] <= $args['posts_per_page'] ){
$this->add_render_attribute( 'load-more', [ 'class' => 'hide-load-more' ] );
unset( $args['found_posts'] );
}
$this->add_render_attribute( 'load-more', [
'class' => "eael-load-more-button",
'id' => "eael-load-more-btn-" . $this->get_id(),
'data-widget-id' => $this->get_id(),
'data-widget' => $this->get_id(),
'data-page-id' => $this->page_id,
'data-template' => json_encode( [
'dir' => $plugin_type,
'file_name' => $settings['loadable_file_name'],
'name' => $this->process_directory_name()
],
1 ),
'data-class' => get_class( $this ),
'data-layout' => isset( $settings['layout_mode'] ) ? $settings['layout_mode'] : "",
'data-page' => 1,
'data-args' => http_build_query( $args ),
] );
if ( $max_page ) {
$this->add_render_attribute( 'load-more', [ 'data-max-page' => $max_page ] );
}
if ( $args['posts_per_page'] != '-1' ) {
$show_or_hide = ('true' == $settings['show_load_more'] || 1 == $settings['show_load_more'] || 'yes' == $settings['show_load_more']) ? '' : ' eael-force-hide';
do_action( 'eael/global/before-load-more-button', $settings, $args, $plugin_type );
?>
<div class="eael-load-more-button-wrap<?php echo "eael-dynamic-filterable-gallery" == $this->get_name() ? " dynamic-filter-gallery-loadmore" : ""; echo esc_attr( $show_or_hide ); ?>">
<button <?php $this->print_render_attribute_string( 'load-more' ); ?>>
<span class="eael-btn-loader button__loader"></span>
<span class="eael_load_more_text"><?php echo esc_html($settings['show_load_more_text']) ?></span>
</button>
</div>
<?php
do_action( 'eael/global/after-load-more-button', $settings, $args, $plugin_type );
}
}
public function eael_product_grid_script(){
if ( version_compare( WC()->version, '3.0.0', '>=' ) ) {
if ( current_theme_supports( 'wc-product-gallery-zoom' ) ) {
wp_enqueue_script( 'zoom' );
}
if ( current_theme_supports( 'wc-product-gallery-slider' ) ) {
wp_enqueue_script( 'flexslider' );
}
if ( current_theme_supports( 'wc-product-gallery-lightbox' ) ) {
wp_enqueue_script( 'photoswipe-ui-default' );
wp_enqueue_style( 'photoswipe-default-skin' );
if ( has_action( 'wp_footer', 'woocommerce_photoswipe' ) === false ) {
add_action( 'wp_footer', 'woocommerce_photoswipe', 15 );
}
}
wp_enqueue_script( 'wc-add-to-cart-variation' );
wp_enqueue_script( 'wc-single-product' );
}
}
/**
* Rating Markup
*/
public function eael_rating_markup( $html, $rating, $count ) {
if ( 0 == $rating ) {
$html = '<div class="eael-star-rating star-rating">';
$html .= wc_get_star_rating_html( $rating, $count );
$html .= '</div>';
}
return $html;
}
public function eael_product_wrapper_class( $classes, $product_id, $widget_name ) {
if ( ! is_plugin_active( 'woo-variation-swatches-pro/woo-variation-swatches-pro.php' ) ) {
return $classes;
}
$product = wc_get_product( $product_id );
if ( ! $product ) {
return $classes;
}
if ( $product->is_type( 'variable' ) ) {
$classes[] = 'wvs-archive-product-wrapper';
}
return $classes;
}
public function eael_woo_cart_empty_action() {
if ( ! function_exists( 'WC' ) ) {
return;
}
if ( isset( $_GET['empty_cart'] ) && 'yes' === esc_html( $_GET['empty_cart'] ) ) {
WC()->cart->empty_cart();
}
}
/**
* Customize checkout fields.
*/
public function eael_customize_woo_checkout_fields( $fields ) {
global $post;
if ( ! is_object( $post ) || is_null( $post ) ) {
return $fields;
}
$widgets = get_post_meta( $post->ID, '_elementor_controls_usage', true );
$widget_key = 'eael-woo-checkout';
if ( ! $widgets ) {
$widget_key = 'woo-checkout';
$widgets = get_post_meta( $post->ID, '_eael_widget_elements', true );
}
$eael_fields = get_post_meta( $post->ID, '_eael_checkout_fields_settings', true );
if ( ! isset( $widgets[ $widget_key ] ) || empty( $eael_fields ) ) {
return $fields;
}
$eael_fields = get_post_meta( $post->ID, '_eael_checkout_fields_settings', true );
foreach ( $fields as $type => $field_sets ) {
foreach ( $field_sets as $key => $field_set ) {
if ( isset( $eael_fields[ $type ][ $key ]['label'] ) ) {
$fields[ $type ][ $key ]['label'] = $eael_fields[ $type ][ $key ]['label'];
}
if ( isset( $eael_fields[ $type ][ $key ]['placeholder'] ) ) {
$fields[ $type ][ $key ]['placeholder'] = $eael_fields[ $type ][ $key ]['placeholder'];
}
}
}
return $fields;
}
/**
* Update Checkout Cart Quantity via ajax call.
*/
public function eael_checkout_cart_qty_update() {
if ( ! wp_verify_nonce( $_POST['nonce'], 'essential-addons-elementor' ) ) {
die( __('Permission Denied!') );
}
$cart_item_key = $_POST['cart_item_key'];
$cart_item = WC()->cart->get_cart_item( $cart_item_key );
$cart_item_quantity = apply_filters( 'woocommerce_stock_amount_cart_item', apply_filters( 'woocommerce_stock_amount', preg_replace( "/[^0-9\.]/", '', filter_var($_POST['quantity'], FILTER_SANITIZE_NUMBER_INT)) ), $cart_item_key );
$passed_validation = apply_filters( 'woocommerce_update_cart_validation', true, $cart_item_key, $cart_item, $cart_item_quantity );
if ( $passed_validation ) {
WC()->cart->set_quantity( $cart_item_key, $cart_item_quantity, true );
wp_send_json_success(
array(
'message' => __( 'Quantity updated successfully.', 'essential-addons-for-elementor-lite' ),
// 'cart_item_key' => $cart_item_key,
'cart_item_quantity' => $cart_item_quantity,
'cart_item_subtotal' => WC()->cart->get_product_subtotal( $cart_item['data'], $cart_item_quantity ),
'cart_subtotal' => WC()->cart->get_cart_subtotal(),
'cart_total' => WC()->cart->get_cart_total()
)
);
} else {
wp_send_json_error(
array(
'message' => __( 'Quantity update failed.', 'essential-addons-for-elementor-lite' ),
)
);
}
die();
}
public function change_add_woo_checkout_update_order_reviewto_cart_text( $add_to_cart_text ) {
add_filter( 'woocommerce_product_add_to_cart_text', function ( $default ) use ( $add_to_cart_text ) {
global $product;
switch ( $product->get_type() ) {
case 'external':
return $add_to_cart_text[ 'add_to_cart_external_product_button_text' ];
break;
case 'grouped':
return $add_to_cart_text[ 'add_to_cart_grouped_product_button_text' ];
break;
case 'simple':
return $add_to_cart_text[ 'add_to_cart_simple_product_button_text' ];
break;
case 'variable':
return $add_to_cart_text[ 'add_to_cart_variable_product_button_text' ];
break;
default:
return $default;
}
} );
}
public function print_template_views(){
$button_test = ( HelperClass::get_local_plugin_data( 'templately/templately.php' ) === false )?'Install Templately':'Activate Templately ';
?>
<div id="eael-promo-temp-wrap" class="eael-promo-temp-wrap" style="display: none">
<div class="eael-promo-temp-wrapper">
<div class="eael-promo-temp">
<a href="#" class="eael-promo-temp__times">
<i class="eicon-close" aria-hidden="true" title="Close"></i>
</a>
<div class="eael-promo-temp--left">
<div class="eael-promo-temp__logo">
<img src="<?php echo esc_url( EAEL_PLUGIN_URL . 'assets/admin/images/templately/logo.svg' ); ?>" alt="">
</div>
<ul class="eael-promo-temp__feature__list">
<li><?php _e('5,000+ Stunning Templates','essential-addons-for-elementor-lite'); ?></li>
<li><?php _e('Supports Elementor & Gutenberg','essential-addons-for-elementor-lite'); ?></li>
<li><?php _e('Powering up 300,000+ Websites','essential-addons-for-elementor-lite'); ?></li>
<li><?php _e('Cloud Collaboration with Team','essential-addons-for-elementor-lite'); ?></li>
</ul>
<form class="eael-promo-temp__form">
<label>
<input type="radio" value="install" class="eael-temp-promo-confirmation" name='eael-promo-temp__radio' checked>
<span><?php echo esc_html( $button_test ); ?></span>
</label>
<label>
<input type="radio" value="dnd" class="eael-temp-promo-confirmation" name='eael-promo-temp__radio'>
<span><?php _e('Dont Show This Again','essential-addons-for-elementor-lite'); ?></span>
</label>
</form>
<?php if ( HelperClass::get_local_plugin_data( 'templately/templately.php' ) === false ) { ?>
<button class="wpdeveloper-plugin-installer" data-action="install"
data-slug="<?php echo 'templately'; ?>"><?php _e( 'Install Templately', 'essential-addons-for-elementor-lite' ); ?></button>
<?php } else { ?>
<?php if ( is_plugin_active( 'templately/templately.php' ) ) { ?>
<button class="wpdeveloper-plugin-installer"><?php _e( 'Activated Templately', 'essential-addons-for-elementor-lite' ); ?></button>
<?php } else { ?>
<button class="wpdeveloper-plugin-installer" data-action="activate"
data-basename="<?php echo 'templately/templately.php'; ?>"><?php _e( 'Activate Templately', 'essential-addons-for-elementor-lite' ); ?></button>
<?php } ?>
<?php } ?>
<button class="eael-prmo-status-submit" style="display: none"><?php _e('Submit','essential-addons-for-elementor-lite') ?></button>
</div>
<div class="eael-promo-temp--right">
<img src="<?php echo esc_url( EAEL_PLUGIN_URL . 'assets/admin/images/templately/templates-edit.jpg' ); ?>" alt="">
</div>
</div>
</div>
</div>
<?php
}
public function templately_promo_status() {
check_ajax_referer( 'essential-addons-elementor', 'security' );
if(!current_user_can('manage_options')){
wp_send_json_error(__('you are not allowed to do this action', 'essential-addons-for-elementor-lite'));
}
$status = update_option( 'eael_templately_promo_hide', true );
if ( $status ) {
wp_send_json_success();
} else {
wp_send_json_error();
}
}
/**
* Retrieve product quick view data
*
* @return string
*/
/**
* return file path which are store in theme Template directory
* @param $file
*/
public function retrive_theme_path() {
$current_theme = wp_get_theme();
return sprintf(
'%s/%s',
$current_theme->theme_root,
$current_theme->stylesheet
);
}
/**
* @param string $tag
* @param string $function_to_remove
* @param int|string $priority
*/
public function eael_forcefully_remove_action( $tag, $function_to_remove, $priority ) {
global $wp_filter;
if ( isset( $wp_filter[ $tag ][ $priority ] ) && is_array( $wp_filter[ $tag ][ $priority ] ) ) {
foreach ( $wp_filter[ $tag ][ $priority ] as $callback_function => $registration ) {
if ( strlen( $callback_function ) > 32 && strpos( $callback_function, $function_to_remove, 32 ) !== false || $callback_function === $function_to_remove ) {
remove_action( $tag, $callback_function, $priority );
break;
}
}
}
}
/**
* eael_wpml_template_translation
* @param $id
* @return mixed|void
*/
public function eael_wpml_template_translation($id){
$postType = get_post_type( $id );
if ( 'elementor_library' === $postType ) {
return apply_filters( 'wpml_object_id', $id, $postType, true );
}
return $id;
}
/**
* eael_sanitize_template_param
* Removes special characters that are illegal in filenames
*
* @param array $template_info
*
* @access public
* @return array
* @since 5.0.4
*/
public function eael_sanitize_template_param( $template_info ){
$template_info = array_map( 'sanitize_text_field', $template_info );
return array_map( 'sanitize_file_name', $template_info );
}
/**
* sanitize_taxonomy_data
* Sanitize all value for tax query
*
* @param array $tax_list taxonomy param list
*
* @access protected
* @return array|array[]|string[]
* @since 5.0.4
*/
protected function sanitize_taxonomy_data( $tax_list ){
return array_map( function ( $param ) {
return is_array( $param ) ? array_map( 'sanitize_text_field', $param ) : sanitize_text_field( $param );
}, $tax_list );
}
/**
* eael_clear_widget_cache_data
* Remove cache from transient which contains widget data
*
* @access public
* @return array
* @since 5.0.7
*/
public function eael_clear_widget_cache_data() {
global $wpdb;
check_ajax_referer( 'essential-addons-elementor', 'security' );
$ac_name = sanitize_text_field( $_POST['ac_name'] );
$hastag = sanitize_text_field( $_POST['hastag'] );
$c_key = sanitize_text_field( $_POST['c_key'] );
$c_secret = sanitize_text_field( $_POST['c_secret'] );
$widget_id = sanitize_text_field( $_POST['widget_id'] );
$permalink = sanitize_text_field( $_POST['page_permalink'] );
$page_id = url_to_postid($permalink);
$settings = $this->eael_get_widget_settings($page_id, $widget_id);
$twitter_v2 = ! empty( $settings['eael_twitter_api_v2'] ) && 'yes' === $settings['eael_twitter_api_v2'] ? true : false;
$key_pattern = '_transient_' . $ac_name . '%' . md5( $hastag . $c_key . $c_secret ) . '_tf_cache';
if( $twitter_v2 ){
$bearer_token = $settings['eael_twitter_feed_bearer_token'];
$key_pattern = '_transient_' . $ac_name . '%' . md5( $hastag . $c_key . $c_secret . $bearer_token ) . '_tf_cache';
}
$sql = "SELECT `option_name` AS `name`
FROM $wpdb->options
WHERE `option_name` LIKE '$key_pattern'
ORDER BY `option_name`";
$results = $wpdb->get_results( $sql );
foreach ( $results as $transient ) {
$cache_key = substr( $transient->name, 11 );
delete_transient( $cache_key );
}
wp_send_json_success();
}
public function promotion_message_on_admin_screen() {
?>
<div id="eael-admin-promotion-message" class="eael-admin-promotion-message">
<i class="e-notice__dismiss eael-admin-promotion-close" role="button" aria-label="Dismiss" tabindex="0"></i>
<?php printf( __( "<p> <i>📣</i> NEW: Essential Addons 5.9 is here, with new '<a target='_blank' href='%s'>Woo Product List</a>' widget & more! Check out the <a target='_blank' href='%s'>Changelog</a> for more details 🎉</p>", "essential-addons-for-elementor-lite" ), esc_url( 'https://essential-addons.com/elementor/woo-product-list/' ), esc_url( 'https://essential-addons.com/elementor/changelog/' ) ); ?>
</div>
<?php
}
/**
* remove_admin_notice
*
*
* @return void
*/
public function remove_admin_notice() {
$current_screen = get_current_screen();
if ( $current_screen->id == 'toplevel_page_eael-settings' ) {
remove_all_actions( 'user_admin_notices' );
remove_all_actions( 'admin_notices' );
// To showing notice in EA settings page we have to use 'eael_admin_notices' action hook
add_action( 'admin_notices', function () {
do_action( 'eael_admin_notices' );
} );
/*Added admin notice which is basically uses for display new promotion message*/
if ( get_option( 'eael_admin_promotion' ) < self::EAEL_PROMOTION_FLAG ) {
add_action( 'eael_admin_notices', array( $this, 'promotion_message_on_admin_screen' ), 1 );
}
}
}
/**
* eael_show_admin_menu_notice
*
* Update flag if user visit Essential Addons setting page only first time
* @return void
* @since 5.1.0
*/
public function eael_show_admin_menu_notice() {
if ( get_option( 'eael_admin_menu_notice' ) < self::EAEL_ADMIN_MENU_FLAG ) {
update_option( 'eael_admin_menu_notice',self::EAEL_ADMIN_MENU_FLAG,'no' );
}
}
/**
* Checking that is actually elementor activated and works
*
* @return bool
*/
public function is_activate_elementor() {
return defined( 'ELEMENTOR_VERSION' ) && class_exists( 'Elementor\Plugin' );
}
public function essential_blocks_promo_admin_js_template() {
$eb_logo = EAEL_PLUGIN_URL . 'assets/admin/images/eb-new.svg';
$eb_promo_cross = EAEL_PLUGIN_URL . 'assets/admin/images/essential-blocks/cross.svg';
$eb_promo_img1 = EAEL_PLUGIN_URL . 'assets/admin/images/essential-blocks/eb-promo-img1.gif';
$eb_promo_img2 = EAEL_PLUGIN_URL . 'assets/admin/images/essential-blocks/eb-promo-img2.gif';
$eb_promo_img3 = EAEL_PLUGIN_URL . 'assets/admin/images/essential-blocks/eb-promo-img3.gif';
$eb_promo_img4 = EAEL_PLUGIN_URL . 'assets/admin/images/essential-blocks/eb-promo-img4.jpg';
$eb_promo_img5 = EAEL_PLUGIN_URL . 'assets/admin/images/essential-blocks/eb-promo-img5.png';
$eb_not_installed = HelperClass::get_local_plugin_data( 'essential-blocks/essential-blocks.php' ) === false;
$action = $eb_not_installed ? 'install' : 'activate';
$button_title = $eb_not_installed ? esc_html__( 'Try Essential Blocks', 'essential-addons-for-elementor-lite' ) : esc_html__( 'Activate', 'essential-addons-for-elementor-lite' );
$nonce = wp_create_nonce( 'essential-addons-elementor' );
?>
<script id="eael-gb-eb-button-template" type="text/html">
<button id="eael-eb-popup-button" type="button" class="components-button is-primary">
<img width="20" src="<?php echo esc_url( $eb_logo ); ?>" alt=""><?php esc_html_e( 'Essential Blocks', 'essential-addons-for-elementor-lite' ); ?>
</button>
</script>
<script id="eael-gb-eb-popup-template" type="text/html">
<div class="eael-gb-eb-popup">
<div class="eael-gb-eb-header">
<img src="<?php echo esc_url( $eb_promo_cross ); ?>" class="eael-gb-eb-dismiss" alt="">
<div class="eael-gb-eb-tooltip"><?php esc_html_e( 'Close dialog', 'essential-addons-for-elementor-lite' ); ?></div>
</div>
<div class="eael-gb-eb-popup-content --page-1">
<div class="eael-gb-eb-content">
<div class="eael-gb-eb-content-image">
<img src="<?php echo esc_url( $eb_promo_img1 ); ?>" alt="">
</div>
<div class="eael-gb-eb-content-pagination">
<span class="active" data-page="1"></span>
<span data-page="2"></span>
<span data-page="3"></span>
<span data-page="4"></span>
<span data-page="5"></span>
</div>
<div class="eael-gb-eb-content-info">
<h3><?php esc_html_e( 'Supercharge Your Gutenberg Experience With Essential Blocks', 'essential-addons-for-elementor-lite' ); ?></h3>
<p><?php esc_html_e( 'If you like Essential Addons for Elementor, check out Essential Blocks, the ultimate block library for Gutenberg that is trusted by more than 60,000+ web creators.', 'essential-addons-for-elementor-lite' ); ?></p>
<button class="eael-gb-eb-install components-button is-primary" data-action="<?php echo esc_attr( $action ); ?>" data-nonce="<?php echo esc_attr( $nonce ); ?>"><?php echo esc_html( $button_title ); ?></button>
</div>
</div>
<div class="eael-gb-eb-footer">
<button class="eael-gb-eb-never-show" data-nonce="<?php echo esc_attr( $nonce ); ?>"><?php esc_html_e( 'Never Show Again', 'essential-addons-for-elementor-lite' ); ?></button>
<button class="eael-gb-eb-prev"><?php esc_html_e( 'Previous', 'essential-addons-for-elementor-lite' ); ?></button>
<button class="eael-gb-eb-next"><?php esc_html_e( 'Next', 'essential-addons-for-elementor-lite' ); ?></button>
</div>
</div>
</div>
</script>
<script id="eael-gb-eb-button-template-page-1" type="text/html">
<div>
<div class="eael-gb-eb-content-image">
<img src="<?php echo esc_url( $eb_promo_img1 ); ?>" alt="">
</div>
<div class="eael-gb-eb-content-info">
<h3><?php esc_html_e( 'Supercharge Your Gutenberg Experience With Essential Blocks', 'essential-addons-for-elementor-lite' ); ?></h3>
<p><?php esc_html_e( 'If you like Essential Addons for Elementor, check out Essential Blocks, the ultimate block library for Gutenberg that is trusted by more than 60,000+ web creators.', 'essential-addons-for-elementor-lite' ) ?></p>
<button class="eael-gb-eb-install components-button is-primary" data-action="<?php echo esc_attr( $action ); ?>" data-nonce="<?php echo esc_attr( $nonce ); ?>"><?php echo esc_html( $button_title ); ?></button>
</div>
</div>
</script>
<script id="eael-gb-eb-button-template-page-2" type="text/html">
<div>
<div class="eael-gb-eb-content-image">
<img src="<?php echo esc_url( $eb_promo_img2 ); ?>" alt="">
</div>
<div class="eael-gb-eb-content-info">
<h3><?php esc_html_e( '40+ Amazing Gutenberg Blocks', 'essential-addons-for-elementor-lite' ); ?></h3>
<p><?php esc_html_e( 'Create & design your WordPress websites just the way you want with more than 40 amazing, ready blocks from Essential Blocks for Gutenberg.', 'essential-addons-for-elementor-lite' ) ?></p>
<button class="eael-gb-eb-install components-button is-primary" data-action="<?php echo esc_attr( $action ); ?>" data-nonce="<?php echo esc_attr( $nonce ); ?>"><?php echo esc_html( $button_title ); ?></button>
</div>
</div>
</script>
<script id="eael-gb-eb-button-template-page-3" type="text/html">
<div>
<div class="eael-gb-eb-content-image">
<img src="<?php echo esc_url( $eb_promo_img3 ); ?>" alt="">
</div>
<div class="eael-gb-eb-content-info">
<h3><?php esc_html_e( 'Useful Block Control Option', 'essential-addons-for-elementor-lite' ); ?></h3>
<p><?php esc_html_e( 'Get the fastest loading time and smoothest experience on your web page by enabling and disabling individual blocks as per your requirements.', 'essential-addons-for-elementor-lite' ) ?></p>
<button class="eael-gb-eb-install components-button is-primary" data-action="<?php echo esc_attr( $action ); ?>" data-nonce="<?php echo esc_attr( $nonce ); ?>"><?php echo esc_html( $button_title ); ?></button>
</div>
</div>
</script>
<script id="eael-gb-eb-button-template-page-4" type="text/html">
<div>
<div class="eael-gb-eb-content-image">
<img src="<?php echo esc_url( $eb_promo_img4 ); ?>" alt="">
</div>
<div class="eael-gb-eb-content-info">
<h3><?php esc_html_e( 'Access To Thousands Of Ready Gutenberg Templates', 'essential-addons-for-elementor-lite' ); ?></h3>
<p><?php esc_html_e( 'Design unique websites using ready Gutenberg templates from Templately with absolute ease and instantly grab attention.', 'essential-addons-for-elementor-lite' ) ?></p>
<button class="eael-gb-eb-install components-button is-primary" data-action="<?php echo esc_attr( $action ); ?>" data-nonce="<?php echo esc_attr( $nonce ); ?>"><?php echo esc_html( $button_title ); ?></button>
</div>
</div>
</script>
<script id="eael-gb-eb-button-template-page-5" type="text/html">
<div>
<div class="eael-gb-eb-content-image">
<img src="<?php echo esc_url( $eb_promo_img5 ); ?>" alt="">
</div>
<div class="eael-gb-eb-content-info">
<h3><?php esc_html_e( 'Try Essential Blocks Today!', 'essential-addons-for-elementor-lite' ); ?></h3>
<p><?php printf( __( 'Want to get started with Essential Blocks now? Check out %scomplete guides for each blocks%s to learn more about this ultimate block library for Gutenberg.', 'essential-addons-for-elementor-lite' ), '<a href="https://essential-blocks.com/demo" target="_blank">', '</a>' ) ?></p>
<button class="eael-gb-eb-install components-button is-primary" data-action="<?php echo esc_attr( $action ); ?>" data-nonce="<?php echo esc_attr( $nonce ); ?>"><?php echo esc_html( $button_title ); ?></button>
<button class="eael-gb-eb-never-show" data-nonce="<?php echo esc_attr( $nonce ); ?>"><?php esc_html_e( 'Never Show Again', 'essential-addons-for-elementor-lite' ); ?></button>
</div>
</div>
</script>
<?php
}
public function eael_post_view_count() {
if ( is_single() ) {
$post_id = get_the_ID();
$view_count = absint( get_post_meta( $post_id, '_eael_post_view_count', true ) );
update_post_meta( $post_id, '_eael_post_view_count', ++ $view_count );
}
}
}

View File

@@ -0,0 +1,320 @@
<?php
namespace Essential_Addons_Elementor\Traits;
use Elementor\Plugin;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
trait Library
{
public $a;
/**
* Return array of registered elements.
*
* @todo filter output
*/
public function get_registered_elements()
{
return array_keys($this->registered_elements);
}
/**
* Return saved settings
*
* @since 3.0.0
*/
public function get_settings($element = null)
{
$defaults = array_fill_keys(array_keys(array_merge($this->registered_elements, $this->registered_extensions)), true);
$elements = get_option('eael_save_settings', $defaults);
$elements = array_merge($defaults, $elements);
return (isset($element) ? (isset($elements[$element]) ? $elements[$element] : 0) : array_keys(array_filter($elements)));
}
/**
* @param $page_obj
* @param $key
* @return string
*/
public function get_extension_settings($page_settings = [], $global_settings = [], $extension = '', $key = '')
{
if (isset($page_settings) && $page_settings->get_settings($extension) == 'yes') {
return $page_settings->get_settings($key);
} else if (isset($global_settings[$extension]['enabled'])) {
return isset($global_settings[$extension][$key]) ? $global_settings[$extension][$key] : '';
}
return '';
}
/**
* @param $id
* @param $global_data
* @return string
*/
public function get_typography_data($id, $global_data)
{
$typo_data = '';
$fields_keys = [
'font_family',
'font_weight',
'text_transform',
'font_style',
'text_decoration',
'font_size',
'letter_spacing',
'line_height',
];
foreach ($fields_keys as $key => $field) {
$typo_attr = $global_data[$id . '_' . $field];
$attr = str_replace('_', '-', $field);
if (in_array($field, ['font_size', 'letter_spacing', 'line_height'])) {
if (!empty($typo_attr['size'])) {
$typo_data .= "{$attr}:{$typo_attr['size']}{$typo_attr['unit']} !important;";
}
} elseif (!empty($typo_attr)) {
$typo_data .= ($attr == 'font-family') ? "{$attr}:{$typo_attr}, sans-serif;" : "{$attr}:{$typo_attr};";
}
}
return $typo_data;
}
/**
* Check if assets files exists
*
* @since 3.0.0
*/
public function has_assets_files($uid = null, $ext = ['css', 'js'])
{
if (!is_array($ext)) {
$ext = (array) $ext;
}
foreach ($ext as $e) {
$path = EAEL_ASSET_PATH . DIRECTORY_SEPARATOR . ($uid ? $uid : 'eael') . '.min.' . $e;
if (!is_readable($this->safe_path($path))) {
return false;
}
}
return true;
}
/**
* Remove files
*
* @since 3.0.0
*/
public function remove_files( $post_id = null, $ext = [ 'css', 'js' ] ) {
foreach ( $ext as $e ) {
$path = EAEL_ASSET_PATH . DIRECTORY_SEPARATOR . 'eael' . ( $post_id ? '-' . $post_id : '' ) . '.' . $e;
if ( file_exists( $path ) ) {
unlink( $path );
}
}
do_action( 'eael_remove_assets', $post_id, $ext );
}
/**
* Remove files in dir
*
* @since 3.0.0
*/
public function empty_dir($path)
{
if (!is_dir($path) || !file_exists($path)) {
return;
}
foreach (scandir($path) as $item) {
if ($item == '.' || $item == '..') {
continue;
}
unlink($this->safe_path($path . DIRECTORY_SEPARATOR . $item));
}
}
/**
* Clear cache files
*
* @since 3.0.0
*/
/**
* Check if wp running in background
*
* @since 3.0.0
*/
public function is_running_background()
{
if (wp_doing_cron()) {
return true;
}
if (wp_doing_ajax()) {
return true;
}
if (!empty($_REQUEST['action']) && !$this->check_background_action( sanitize_text_field( $_REQUEST['action'] ) )) {
return true;
}
return false;
}
/**
* Check if elementor edit mode or not
*
* @since 3.0.0
*/
public function is_edit_mode()
{
if (isset($_REQUEST['elementor-preview'])) {
return true;
}
return false;
}
/**
* Check if elementor edit mode or not
*
* @since 3.0.0
*/
public function is_preview_mode()
{
if (isset($_REQUEST['elementor-preview'])) {
return false;
}
if (!empty($_REQUEST['action']) && !$this->check_background_action( sanitize_text_field( $_REQUEST['action'] ) )) {
return false;
}
return true;
}
/**
* Check if a plugin is installed
*
* @since v3.0.0
*/
public function is_plugin_installed($basename)
{
if (!function_exists('get_plugins')) {
include_once ABSPATH . '/wp-admin/includes/plugin.php';
}
$installed_plugins = get_plugins();
return isset($installed_plugins[$basename]);
}
/**
* Generate safe path
*
* @since v3.0.0
*/
public function safe_path($path)
{
$path = str_replace(['//', '\\\\'], ['/', '\\'], $path);
return str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path);
}
/**
* Generate safe url
*
* @since v3.0.0
*/
public function safe_url($url)
{
if (is_ssl()) {
$url = wp_parse_url($url);
if (!empty($url['host'])) {
$url['scheme'] = 'https';
}
return $this->unparse_url($url);
}
return $url;
}
public function unparse_url($parsed_url)
{
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
$host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
$port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
$user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
$pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
$pass = ($user || $pass) ? "$pass@" : '';
$path = isset($parsed_url['path']) ? $parsed_url['path'] : '';
$query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
$fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
return "$scheme$user$pass$host$port$path$query$fragment";
}
/**
* Allow to load asset for some pre defined action query param in elementor preview
* @return bool
*/
public function check_background_action($action_name){
$allow_action = [
'subscriptions',
'mepr_unauthorized',
'home',
'subscriptions',
'payments',
'newpassword',
'manage_sub_accounts',
'ppw_postpass',
];
if (in_array($action_name, $allow_action)){
return true;
}
return false;
}
/*
* Check some other cookie for solve asset loading issue
*/
public function check_third_party_cookie_status($id='') {
global $Password_Protected;
if ( is_object( $Password_Protected ) && method_exists( $Password_Protected, 'cookie_name' ) && isset( $_COOKIE[ $Password_Protected->cookie_name() ] ) ) {
return true;
}
return false;
}
/**
* check_protected_content_status
*
* check EaeL Protected content cookie set or not
*
* @return bool
*/
public function check_protected_content_status(){
if(!empty($_POST['eael_protected_content_id'])){
if(!empty($_POST['protection_password_'.$_POST['eael_protected_content_id']])){
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace Essential_Addons_Elementor\Traits;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
trait Shared
{
// Just for compatibility
}

View File

@@ -0,0 +1,292 @@
<?php
namespace Essential_Addons_Elementor\Traits;
if ( !defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
trait Template_Query {
public $current_widget_name = '';
public function set_widget_name( $name = '' ) {
$this->current_widget_name = $name;
}
/**
* Get only filename
* @param string
* @return string
*/
public function get_filename_only( $path ) {
$filename = \explode( '/', $path );
return \end( $filename );
}
/**
* Retrieves Template name from file header.
*
* @array
*/
private $template_headers = [
'Template Name' => 'Template Name',
];
/**
* Prepare the directory name from the following widget name.
*
* @access private
*
*
* @return string $widget_name
*/
private function process_directory_name()
{
if ( empty( $this->current_widget_name ) && \method_exists( $this, 'get_name' ) ) {
$this->current_widget_name = $this->get_name();
}
$widget_name = str_replace('eael-', '', $this->current_widget_name);
$widget_name = str_replace('-', ' ', $widget_name);
$widget_name = ucwords($widget_name);
$widget_name = str_replace(' ', '-', $widget_name);
return $widget_name;
}
/**
* Retrieve `Theme Template Directory`
*
* @return string templates directory from the active theme.
*/
private function theme_templates_dir() {
$current_theme = wp_get_theme();
$dir = sprintf(
'%s/%s/Template/%s',
$current_theme->theme_root,
$current_theme->stylesheet,
$this->process_directory_name()
);
if ( is_dir( $dir ) ) {
$file = scandir( $dir );
$file = array_pop( $file );
return pathinfo( $file, PATHINFO_EXTENSION ) === 'php' ? $dir : false;
}
return false;
}
/**
* Retrieves the lite plugin template directory path.
*
* @return string templates directory path of lite version.
*/
private function get_template_dir() {
return \sprintf(
'%sincludes/Template/%s',
EAEL_PLUGIN_PATH, $this->process_directory_name()
);
}
/**
* Retrieves the pro plugin template directory path.
*
* @return string templates directory path of pro version.
*/
private function get_pro_template_dir()
{
if (!apply_filters('eael/is_plugin_active', 'essential-addons-elementor/essential_adons_elementor.php')) {
return false;
}
return \sprintf(
'%sincludes/Template/%s',
EAEL_PRO_PLUGIN_PATH, $this->process_directory_name()
);
}
/**
* Collecting templates from different sources.
*
* @return array
*/
private function get_template_files() {
$templates = [];
if ( is_dir( $this->get_template_dir() ) ) {
$templates['lite'] = scandir( $this->get_template_dir(), 1 );
}
if ( is_dir( $this->get_pro_template_dir() ) ) {
$templates['pro'] = scandir( $this->get_pro_template_dir(), 1 );
}
if ( $this->theme_templates_dir() ) {
$templates['theme'] = scandir( $this->theme_templates_dir(), 1 );
}
return $templates;
}
/**
* Retrieves template list from template directory.
*
* @return array template list.
*/
protected function get_template_list() {
$files = [];
if ($this->get_template_files()) {
foreach ($this->get_template_files() as $key => $handler) {
foreach ($handler as $handle) {
if (strpos($handle, '.php') !== false) {
if ($key === 'lite') {
$path = sprintf('%s/%s', $this->get_template_dir(), $handle);
} else if ($key === 'pro') {
$path = sprintf('%s/%s', $this->get_pro_template_dir(), $handle);
} else if ($key === 'theme') {
$path = sprintf('%s/%s', $this->theme_templates_dir(), $handle);
}
$template_info = get_file_data( $path, $this->template_headers );
$template_name = $template_info[ 'Template Name' ];
if ( $template_name ) {
$files[ $template_name ] = $path;
}
}
}
}
}
return $files;
}
/**
*
* Retrieves template list from template directory.
*
* @param false $sort
* @return array
*/
public function get_template_list_for_dropdown($sort = false)
{
$files = [];
$templates = $this->get_template_files();
if (!empty( $templates)) {
foreach ($templates as $key => $handler) {
foreach ($handler as $handle) {
if (strpos($handle, '.php') !== false) {
$path = $this->_get_path($key, $handle);
$template_info = get_file_data($path, $this->template_headers);
$template_name = $template_info['Template Name'];
$template_key = str_replace( ' ', '-', strtolower( $template_name ) );
if ( $template_name ) {
$files[$template_key] = sprintf("%s (%s)", ucfirst($template_name), ucfirst($key));
}
}
}
}
}
if($sort){
ksort($files);
}
return $files;
}
public function _get_path($key, $handle)
{
$path = '';
if ($key === 'lite') {
$path = sprintf('%s/%s', $this->get_template_dir(), $handle);
} else if ($key === 'pro') {
$path = sprintf('%s/%s', $this->get_pro_template_dir(), $handle);
} else if ($key === 'theme') {
$path = sprintf('%s/%s', $this->theme_templates_dir(), $handle);
}
return $path;
}
/**
* Preparing template options for frontend select
*
* @return array teplate select options.
*/
private function get_template_options() {
$files = [];
if ( $this->get_template_list() ) {
foreach ( $this->get_template_list() as $filename => $path ) {
$filename = \str_replace( ' ', '-', $filename );
$files[ strtolower( $filename ) ] = $path;
}
}
return $files;
}
/**
* Adding key value pairs in template options.
*
* @return array
*/
private function template_options() {
$keys = array_keys( $this->get_template_options() );
$values = array_keys( $this->get_template_list() );
return array_combine( $keys, $values );
}
/**
* Retrieve template
*
* @param string $filename
*
* @return string include-able full template path.
*/
public function get_template( $filename ) {
if ( in_array( $filename, array_keys( $this->get_template_options() ) ) ) {
$file = $this->get_template_options()[ $filename ];
return $file;
}
return false;
}
/**
* Set default option in frontend select control.
*
* @return string first option.
*/
public function get_default() {
$dt = array_reverse( $this->template_options() );
return strtolower( array_pop( $dt ) );
}
/**
* Get directory name based on given file name
* @param $filename
* @return int|string
*/
protected function get_temp_dir_name($filename){
if(empty($filename)){
return 'free';
}
$template_files = array_reverse($this->get_template_files());
foreach ($template_files as $key => $handler) {
if(in_array($filename,$handler)){
return $key;
}
}
return 'free';
}
}

View File

@@ -0,0 +1,275 @@
<?php
namespace Essential_Addons_Elementor\Traits;
use function Better_Payment\Lite\Classes\better_payment_dd;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
trait Twitter_Feed
{
public static $twitter_feed_fetched_count = 0;
/**
* Twitter Feed
*
* @since 3.0.6
*/
public function twitter_feed_render_items($id, $settings, $class = '')
{
$token = get_option($id . '_' . $settings['eael_twitter_feed_ac_name'] . '_tf_token');
$user_object = get_option($id . '_' . $settings['eael_twitter_feed_ac_name'] . '_tf_user_object');
$user_object = ! empty( $user_object->data ) ? $user_object->data : '';
$expiration = ! empty( $settings['eael_auto_clear_cache'] ) && ! empty( $settings['eael_twitter_feed_cache_limit'] ) ? absint( $settings['eael_twitter_feed_cache_limit'] ) * MINUTE_IN_SECONDS : DAY_IN_SECONDS;
$cache_key = $settings['eael_twitter_feed_ac_name'] . '_' . $expiration . '_' . md5( $settings['eael_twitter_feed_hashtag_name'] . $settings['eael_twitter_feed_consumer_key'] . $settings['eael_twitter_feed_consumer_secret'] . ( empty( $settings['eael_twitter_feed_bearer_token'] ) ? '' : $settings['eael_twitter_feed_bearer_token'] ) ) . '_tf_cache';
$items = get_transient( $cache_key );
$html = '';
$twitter_v2 = ! empty( $settings['eael_twitter_api_v2'] ) && 'yes' === $settings['eael_twitter_api_v2'] ? true : false;
$account_name = sanitize_text_field( str_replace('@', '', $settings['eael_twitter_feed_ac_name']) );
if ( ! $twitter_v2 && ( empty($settings['eael_twitter_feed_consumer_key']) || empty($settings['eael_twitter_feed_consumer_secret']) ) ) {
return;
}
if ( $twitter_v2 && empty( $settings['eael_twitter_feed_bearer_token'] ) ) {
return;
}
if( $user_object ){
$user_id = ! empty( $user_object->id ) ? $user_object->id : '';
$user_profile_image_url = ! empty( $user_object->profile_image_url ) ? $user_object->profile_image_url : '';
$user_username = ! empty( $user_object->username ) ? $user_object->username : '';
$user_name = ! empty( $user_object->name ) ? $user_object->name : '';
}
if ($items === false) {
if ( ! $twitter_v2 && empty( $token ) ) {
$credentials = base64_encode($settings['eael_twitter_feed_consumer_key'] . ':' . $settings['eael_twitter_feed_consumer_secret']);
add_filter('https_ssl_verify', '__return_false');
$response = wp_remote_post('https://api.twitter.com/oauth2/token', [
'method' => 'POST',
'httpversion' => '1.1',
'blocking' => true,
'headers' => [
'Authorization' => 'Basic ' . $credentials,
'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8',
],
'body' => ['grant_type' => 'client_credentials'],
]);
$body = json_decode(wp_remote_retrieve_body($response));
if ($body) {
update_option($id . '_' . $settings['eael_twitter_feed_ac_name'] . '_tf_token', $body->access_token);
$token = $body->access_token;
}
}
add_filter('https_ssl_verify', '__return_false');
$api_endpoint = 'https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=' . $settings['eael_twitter_feed_ac_name'] . '&count=999&tweet_mode=extended';
if ( $twitter_v2 ){
$token = ! empty( $settings['eael_twitter_feed_bearer_token'] ) ? $settings['eael_twitter_feed_bearer_token'] : '';
$tweet_fields = [ 'entities', 'public_metrics', 'in_reply_to_user_id', 'attachments', 'created_at' ];
$tweet_fields_params = implode(',', $tweet_fields);
if ( empty( $user_object ) ){
$api_endpoint_user = "https://api.twitter.com/2/users/by/username/$account_name?user.fields=profile_image_url";
$response_user = wp_remote_get($api_endpoint_user, [
'blocking' => true,
'headers' => [
'Authorization' => "Bearer $token",
],
]);
$body_user = json_decode(wp_remote_retrieve_body($response_user));
if ($body_user) {
$user_object = $body_user;
update_option($id . '_' . $settings['eael_twitter_feed_ac_name'] . '_tf_user_object', $user_object);
$user_id = ! empty( $user_object->id ) ? $user_object->id : '';
$user_profile_image_url = ! empty( $user_object->profile_image_url ) ? $user_object->profile_image_url : '';
$user_username = ! empty( $user_object->username ) ? $user_object->username : '';
$user_name = ! empty( $user_object->name ) ? $user_object->name : '';
}
}
if ( empty( $user_id ) ){
return $html;
}
$api_endpoint = "https://api.twitter.com/2/users/$user_id/tweets?max_results=100&tweet.fields=$tweet_fields_params";
}
$response = wp_remote_get($api_endpoint, [
'blocking' => true,
'headers' => [
'Authorization' => "Bearer $token",
],
]);
if ( is_wp_error( $response ) ) {
return $html;
}
if ( ! empty( $response['response'] ) && $response['response']['code'] == 200 ) {
$items = json_decode( wp_remote_retrieve_body( $response ), true );
$items = $twitter_v2 && ! empty( $items['data'] ) ? $items['data'] : $items;
set_transient( $cache_key, $items, $expiration );
}
}
if ( empty( $items ) ) {
return $html;
}
if ( $settings['eael_twitter_feed_hashtag_name'] ) {
foreach ($items as $key => $item) {
$match = false;
if ( ! empty( $item['entities']['hashtags'] ) ) {
foreach ($item['entities']['hashtags'] as $tag) {
$tag['text'] = $twitter_v2 ? $tag['tag'] : $tag['text'];
if (strcasecmp($tag['text'], $settings['eael_twitter_feed_hashtag_name']) == 0) {
$match = true;
}
}
}
if ($match == false) {
unset($items[$key]);
}
}
}
$items = array_splice($items, 0, $settings['eael_twitter_feed_post_limit']);
$post_per_page = ! empty($settings['eael_twitter_feed_posts_per_page']) ? $settings['eael_twitter_feed_posts_per_page'] : 10;
$counter = 0;
$current_page = 1;
self::$twitter_feed_fetched_count = count($items);
foreach ($items as $item) {
$counter++;
if ($post_per_page > 0) {
$current_page = ceil($counter / $post_per_page);
}
$is_reply = ! empty($item['in_reply_to_status_id']) ? true : false;
if( $twitter_v2 ){
$is_reply = !empty($item['in_reply_to_user_id']) ? true : false;
}
$show_reply = ( !empty($settings['eael_twitter_feed_show_replies']) && 'true' === $settings['eael_twitter_feed_show_replies'] ) ? true : false;
if($is_reply && !$show_reply){
continue;
}
$item['full_text'] = $twitter_v2 ? $item['text'] : $item['full_text'];
$delimeter = strlen($item['full_text']) > $settings['eael_twitter_feed_content_length'] ? '...' : '';
$media = isset( $item['extended_entities']['media'] ) ? $item['extended_entities']['media'] :
( isset( $item['retweeted_status']['entities']['media'] ) ? $item['retweeted_status']['entities']['media'] :
( isset( $item['quoted_status']['entities']['media'] ) ? $item['quoted_status']['entities']['media'] :
[] ) );
$show_pagination = ! empty($settings['pagination']) && 'yes' === $settings['pagination'] ? true : false;
if($show_pagination){
$pagination_class = ' page-' . $current_page;
$pagination_class .= 1 === intval( $current_page ) ? ' eael-d-block' : ' eael-d-none';
} else {
$pagination_class = 'page-1 eael-d-block';
}
if ($counter == count($items)) {
$pagination_class .= ' eael-last-twitter-feed-item';
}
$user_name_full = '';
$html .= '<div class="eael-twitter-feed-item ' . esc_attr( $class ) . ' ' . esc_attr( $pagination_class ) . ' ">
<div class="eael-twitter-feed-item-inner">
<div class="eael-twitter-feed-item-header clearfix">';
$user_profile_image_url_https = ! empty( $item['user']['profile_image_url_https'] ) ? $item['user']['profile_image_url_https'] : '';
$$user_name_full = ! empty( $item['user']['name'] ) ? $item['user']['name'] : '';
$user_profile_image_url_https = $twitter_v2 && ! empty( $user_profile_image_url ) ? $user_profile_image_url : '';
$user_name_full = $twitter_v2 && ! empty( $user_name ) ? $user_name : '';
if ($settings['eael_twitter_feed_show_avatar'] == 'true' && ! empty( $user_profile_image_url_https ) ) {
$html .= '<a class="eael-twitter-feed-item-avatar avatar-' . $settings['eael_twitter_feed_avatar_style'] . '" href="//twitter.com/' . $settings['eael_twitter_feed_ac_name'] . '" target="_blank">
<img src="' . esc_url( $user_profile_image_url_https ) . '">
</a>';
}
$html .= '<a class="eael-twitter-feed-item-meta" href="//twitter.com/' . $settings['eael_twitter_feed_ac_name'] . '" target="_blank">';
if ( $settings['eael_twitter_feed_show_icon'] == 'true' && ! empty( $user_name_full ) ) {
$html .= '<i class="fab fa-twitter eael-twitter-feed-item-icon"></i>';
}
$html .= '<span class="eael-twitter-feed-item-author">' . $user_name_full . '</span>
</a>';
if ($settings['eael_twitter_feed_show_date'] == 'true') {
$html .= '<span class="eael-twitter-feed-item-date">' . sprintf(__('%s ago', 'essential-addons-for-elementor-lite'), human_time_diff(strtotime($item['created_at']))) . '</span>';
}
$html .= '</div>
<div class="eael-twitter-feed-item-content">';
$content = isset($item['entities']['urls'][0]['url'])?str_replace($item['entities']['urls'][0]['url'], '', $item['full_text']):$item['full_text'];
$content = substr( $content, 0, $settings['eael_twitter_feed_content_length']) . $delimeter;
if ( ! empty( $settings['eael_twitter_feed_hash_linked'] ) && $settings['eael_twitter_feed_hash_linked'] === 'yes' && ! empty( $item['entities']['hashtags'] ) ) {
$hashtags = [];
foreach ( $item['entities']['hashtags'] as $hashtag ){
$hashtag['text'] = $twitter_v2 ? $hashtag['tag'] : $hashtag['text'];
if ( $hashtag['text'] ){
$hashtags['#'.$hashtag['text']] = "<a href='https://twitter.com/hashtag/{$hashtag['text']}?src=hashtag_click' target='_blank'>#{$hashtag['text']}</a>";
}
}
$content = str_replace( array_keys($hashtags), $hashtags, $content );
}
if( $twitter_v2 ) {
$item['id_str'] = $item['id'];
$item['entities']['user_mentions'] = ! empty( $item['entities']['mentions'] ) ? $item['entities']['mentions'] : [];
}
if ( ! empty( $settings['eael_twitter_feed_mention_linked'] ) && $settings['eael_twitter_feed_mention_linked'] === 'yes' && $item['entities']['user_mentions'] ) {
$mentions = [];
foreach ( $item['entities']['user_mentions'] as $mention ){
$mention['screen_name'] = $twitter_v2 ? ( ! empty( $mention['tag'] ) ? $mention['tag'] : '' ) : $mention['screen_name'];
if ( $mention['screen_name'] ){
$mentions['@'.$mention['screen_name']] = "<a href='https://twitter.com/{$mention['screen_name']}' target='_blank'>@{$mention['screen_name']}</a>";
}
}
$content = str_replace( array_keys($mentions), $mentions, $content );
}
$html .= '<p>' . $content . '</p>';
$item_user_screen_name = ! empty( $item['user']['screen_name'] ) ? $item['user']['screen_name'] : '';
$item_user_screen_name = $twitter_v2 && ! empty( $user_username ) ? $user_username : '';
if ($settings['eael_twitter_feed_show_read_more'] == 'true' && ! empty( $item_user_screen_name ) ) {
$read_more = !empty( $settings[ 'eael_twitter_feed_show_read_more_text' ] ) ? $settings[ 'eael_twitter_feed_show_read_more_text' ] : __( 'Read More', 'essential-addons-for-elementor-lite' );
$html .= '<a href="//twitter.com/' . esc_attr( $item_user_screen_name ) . '/status/' . esc_attr( $item['id_str'] ) . '" target="_blank" class="read-more-link">'. esc_html( $read_more ).' <i class="fas fa-angle-double-right"></i></a>';
}
$html .= '</div>
' . ( isset( $media[0] ) && $settings['eael_twitter_feed_media'] == 'true' ? ( $media[0]['type'] == 'photo' ? '<img src="' . esc_url( $media[0]['media_url_https'] ) . '">' : '' ) : '' ) . '
</div>
</div>';
}
return $html;
}
}

View File

@@ -0,0 +1 @@
<?php // Silence is golden