This commit is contained in:
2024-05-20 15:37:46 +03:00
commit 00b7dbd0b7
10404 changed files with 3285853 additions and 0 deletions

View File

@ -0,0 +1,33 @@
<?php
namespace Nextend\SmartSlider3\Platform;
use Nextend\Framework\Pattern\GetAssetsPathTrait;
use Nextend\Framework\Pattern\SingletonTrait;
abstract class AbstractSmartSlider3Platform {
use SingletonTrait, GetAssetsPathTrait;
public abstract function start();
/**
* @return string
*/
public abstract function getAdminUrl();
/**
* @return string
*/
public abstract function getAdminAjaxUrl();
/**
* @return string
*/
public function getNetworkAdminUrl() {
return $this->getAdminUrl();
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace Nextend\SmartSlider3\Platform;
use Nextend\Framework\Pattern\SingletonTrait;
class SmartSlider3Platform {
use SingletonTrait;
/**
* @var AbstractSmartSlider3Platform
*/
private static $platform;
public function __construct() {
self::$platform = WordPress\SmartSlider3PlatformWordPress::getInstance();
self::$platform->start();
}
public static function getAdminUrl() {
return self::$platform->getAdminUrl();
}
public static function getAdminAjaxUrl() {
return self::$platform->getAdminAjaxUrl();
}
public static function getNetworkAdminUrl() {
return self::$platform->getNetworkAdminUrl();
}
}

View File

@ -0,0 +1,308 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Admin;
use Nextend\Framework\PageFlow;
use Nextend\Framework\Sanitize;
use Nextend\SmartSlider3\Application\ApplicationSmartSlider3;
use Nextend\SmartSlider3\Application\Model\ModelSliders;
use Nextend\SmartSlider3\Platform\SmartSlider3Platform;
use Nextend\SmartSlider3\Platform\WordPress\HelperTinyMCE;
use Nextend\SmartSlider3\Settings;
use WP_Admin_Bar;
class AdminHelper {
public function __construct() {
add_action('admin_init', function () {
require_once dirname(__FILE__) . '/free/notice.php';
});
add_action('init', array(
$this,
'action_init'
));
add_action('admin_menu', array(
$this,
'action_admin_menu'
));
add_action('network_admin_menu', array(
$this,
'action_network_admin_menu'
));
add_action('wp_ajax_smart-slider3', array(
$this,
'display_admin_ajax'
));
add_filter('plugin_action_links', array(
$this,
'filter_plugin_action_links'
), 10, 2);
add_action('save_post', array(
$this,
'clearSliderCache'
));
add_action('wp_untrash_post', array(
$this,
'clearSliderCache'
));
global $wp_version;
if (version_compare($wp_version, '5.1', '<')) {
add_action('wpmu_new_blog', array(
$this,
'onInsertSite'
), -1000000);
} else {
add_action('wp_insert_site', array(
$this,
'onInsertSite'
), -1000000);
}
}
public function action_init() {
if (current_user_can('smartslider_edit') && intval(Settings::get('wp-adminbar', 1))) {
add_action('admin_bar_menu', array(
$this,
'action_admin_bar_menu'
), 81);
}
}
public function action_admin_menu() {
add_menu_page('Smart Slider', 'Smart Slider', 'smartslider', NEXTEND_SMARTSLIDER_3_URL_PATH, array(
$this,
'display_admin'
), 'dashicons-smart_slider__admin_menu');
add_submenu_page(NEXTEND_SMARTSLIDER_3_URL_PATH, 'Smart Slider', n2_('Dashboard'), 'smartslider', NEXTEND_SMARTSLIDER_3_URL_PATH, array(
$this,
'display_admin'
));
add_submenu_page(NEXTEND_SMARTSLIDER_3_URL_PATH, 'Help Center', n2_('Help center'), 'smartslider', NEXTEND_SMARTSLIDER_3_URL_PATH . '-help', array(
$this,
'display_help'
));
add_submenu_page(NEXTEND_SMARTSLIDER_3_URL_PATH, 'Go Pro', '<span class="smart_slider__admin_menu_go_pro"><span class="dashicons dashicons-unlock" style="font-size: 17px"></span>' . n2_('Go Pro') . '</span>', 'smartslider', NEXTEND_SMARTSLIDER_3_URL_PATH . '-go-pro', array(
$this,
'display_go_pro'
));
wp_enqueue_style('dashicons-smart-slider', HelperTinyMCE::getAssetsUri() . '/dist/wordpress-admin-menu.min.css', array('dashicons'));
}
public function display_controller($controller, $action = 'index', $ajax = false) {
$application = ApplicationSmartSlider3::getInstance();
$applicationType = $application->getApplicationTypeAdmin();
$applicationType->processRequest($controller, $action, $ajax);
PageFlow::markApplicationEnd();
}
private function checkForCap() {
if (!current_user_can('unfiltered_html')) {
if (is_multisite()) {
$documentationUrl = 'https://smartslider.helpscoutdocs.com/article/1983-how-to-give-access-to-smart-slider-for-non-admin-users#multisite';
} else {
$documentationUrl = 'https://smartslider.helpscoutdocs.com/article/1983-how-to-give-access-to-smart-slider-for-non-admin-users#wordpress';
}
wp_die(sprintf('<div class="error"><p>%s</p></div>', sprintf('Smart Slider allows you to place many things on your slider, so only users with the %s capability can have access to it. You do not have this capability and only %s.', '<i>unfiltered_html</i>', sprintf('<a href="%s" target="_blank">%s</a>', esc_url($documentationUrl), 'the administrator of your website can grant it to you'))));
}
}
public function display_admin() {
$this->checkForCap();
$this->display_controller('sliders', 'gettingstarted');
}
public function display_admin_index() {
$this->checkForCap();
$this->display_controller('sliders');
}
public function display_help() {
$this->checkForCap();
$this->display_controller('help');
}
public function display_go_pro() {
$this->checkForCap();
$this->display_controller('goPro');
}
public function display_admin_ajax() {
$this->display_controller('sliders', 'index', true);
}
public function action_network_admin_menu() {
add_action('admin_head', array(
$this,
'action_admin_head_network_update'
));
add_menu_page('Smart Slider Update', 'Smart Slider Update', 'smartslider', NEXTEND_SMARTSLIDER_3_URL_PATH, array(
$this,
'display_network_update'
), 'dashicons-smart_slider__admin_menu');
wp_enqueue_style('dashicons-smart-slider', HelperTinyMCE::getAssetsUri() . '/dist/wordpress-admin-menu.min.css', array('dashicons'));
}
public function action_admin_head_network_update() {
echo '<style type="text/css">#adminmenu .toplevel_page_' . esc_html(NEXTEND_SMARTSLIDER_3_URL_PATH) . '{display: none;}</style>';
}
public function display_network_update() {
$application = ApplicationSmartSlider3::getInstance();
$applicationType = $application->getApplicationTypeAdmin();
$applicationType->process('update', 'update');
PageFlow::markApplicationEnd();
}
/**
* @param WP_Admin_Bar $wp_admin_bar
*/
public function action_admin_bar_menu($wp_admin_bar) {
global $wpdb;
$adminUrl = SmartSlider3Platform::getAdminUrl();
$wp_admin_bar->add_node(array(
'id' => 'new_content_smart_slider',
'parent' => 'new-content',
'title' => 'Slider [Smart Slider 3]',
'href' => $adminUrl . '#createslider'
));
$wp_admin_bar->add_node(array(
'id' => 'smart_slider_3',
'title' => 'Smart Slider',
'href' => $adminUrl
));
$wp_admin_bar->add_node(array(
'id' => 'smart_slider_3_dashboard',
'parent' => 'smart_slider_3',
'title' => 'Dashboard',
'href' => $adminUrl
));
$wp_admin_bar->add_node(array(
'id' => 'smart_slider_3_create_slider',
'parent' => 'smart_slider_3',
'title' => 'Create slider',
'href' => $adminUrl . '#createslider'
));
$query = 'SELECT sliders.title, sliders.id
FROM ' . $wpdb->prefix . 'nextend2_smartslider3_sliders AS sliders
LEFT JOIN ' . $wpdb->prefix . 'nextend2_smartslider3_sliders_xref AS xref ON xref.slider_id = sliders.id
WHERE
(
xref.group_id IS NULL
OR xref.group_id = 0
OR (SELECT _sliders.slider_status FROM ' . $wpdb->prefix . 'nextend2_smartslider3_sliders AS _sliders WHERE _sliders.id = xref.group_id ) LIKE \'published\'
)
AND sliders.slider_status = \'published\'
ORDER BY time DESC LIMIT 10';
$sliders = $wpdb->get_results($query, ARRAY_A);
if (count($sliders)) {
$wp_admin_bar->add_node(array(
'id' => 'smart_slider_3_edit',
'parent' => 'smart_slider_3',
'title' => 'Edit slider',
'href' => $adminUrl
));
$applicationType = ApplicationSmartSlider3::getInstance()
->getApplicationTypeAdmin();
foreach ($sliders as $slider) {
$wp_admin_bar->add_node(array(
'id' => 'smart_slider_3_slider_' . $slider['id'],
'parent' => 'smart_slider_3_edit',
'title' => Sanitize::esc_html('#' . $slider['id'] . ' - ' . $slider['title']),
'href' => $applicationType->getUrlSliderEdit($slider['id'])
));
}
if (count($sliders) == 10) {
$wp_admin_bar->add_node(array(
'id' => 'smart_slider_3_slider_view_all',
'parent' => 'smart_slider_3_edit',
'title' => 'View all',
'href' => $adminUrl
));
}
}
}
public function filter_plugin_action_links($links, $file) {
if ($file === NEXTEND_SMARTSLIDER_3_BASENAME && current_user_can('manage_options')) {
if (!is_array($links)) {
$links = array();
}
$links[] = sprintf('<a href="%s">%s</a>', wp_nonce_url(add_query_arg(array('repairss3' => '1'), SmartSlider3Platform::getAdminUrl()), 'repairss3'), 'Analyze & Repair');
}
return $links;
}
public function clearSliderCache() {
$applicationTypeAdmin = ApplicationSmartSlider3::getInstance()
->getApplicationTypeAdmin();
$slidersModel = new ModelSliders($applicationTypeAdmin);
$slidersModel->invalidateCache();
}
public function onInsertSite() {
remove_action('save_post', array(
$this,
'clearSliderCache'
));
remove_action('wp_untrash_post', array(
$this,
'clearSliderCache'
));
}
}

View File

@ -0,0 +1,76 @@
<?php
use Nextend\Framework\ResourceTranslator\ResourceTranslator;
$current = time();
if (mktime(0, 0, 0, 11, 20, 2023) <= $current && $current < mktime(0, 0, 0, 11, 30, 2023)) {
if (get_option('ss3_bf_2023') != '1') {
add_action('admin_notices', function () {
?>
<div class="notice notice-info is-dismissible" data-ss3dismissable="ss3_bf_2023" style="display:grid;grid-template-columns: 100px auto;padding-top: 25px; padding-bottom: 22px;">
<img alt="Smart Slider 3" src="<?php echo esc_url(ResourceTranslator::toUrl('$ss3-admin$/images/notice.png')); ?>" width="74" height="74" style="grid-row: 1 / 4; align-self: center;justify-self: center">
<h3 style="margin:0;">Don't miss out on our biggest sale of the year!</h3>
<p style="margin:0 0 2px;">Get your <b>Smart Slider 3 Pro plan</b> with <b>UP TO 50% OFF</b>! This limited time offer expires on November 29.</p>
<p style="margin:0;">
<a class="button button-primary" href="https://smartslider3.com/pricing/?coupon=BF2023&utm_source=wpfree&utm_medium=wp&utm_campaign=bf23" target="_blank">
Buy Now</a>
<a class="button button-dismiss" href="#">Dismiss</a>
</p>
</div>
<?php
});
add_action('admin_footer', function () {
?>
<script>
(function () {
function ready(fn) {
if (document.readyState === "complete" || document.readyState === "interactive") {
fn();
} else {
document.addEventListener("DOMContentLoaded", fn);
}
}
function serialize(obj) {
return Object.keys(obj).reduce(function (a, k) {
a.push(k + '=' + encodeURIComponent(obj[k]));
return a;
}, []).join('&');
}
ready(function () {
setTimeout(function () {
const buttons = document.querySelectorAll("div[data-ss3dismissable] .notice-dismiss, div[data-ss3dismissable] .button-dismiss");
for (let i = 0; i < buttons.length; i++) {
buttons[i].addEventListener('click', function (e) {
e.preventDefault();
const http = new XMLHttpRequest();
http.open('POST', ajaxurl, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
http.send(serialize({
'action': 'ss3_dismiss_admin_notice',
'nonce': <?php echo json_encode(wp_create_nonce('ss3-dismissible-notice')); ?>
}));
e.target.closest('.is-dismissible').remove();
});
}
}, 1000);
});
})();
</script>
<?php
});
add_action('wp_ajax_ss3_dismiss_admin_notice', function () {
check_ajax_referer('ss3-dismissible-notice', 'nonce');
update_option('ss3_bf_2023', '1');
wp_die();
});
}
}

View File

@ -0,0 +1,112 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress;
use Nextend\Framework\Request\Request;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
use Nextend\SmartSlider3\Settings;
class Compatibility {
public function __construct() {
/**
* Fix for NextGenGallery and Divi live editor bug
*/
add_filter('run_ngg_resource_manager', function ($ret) {
if (Request::$GET->getInt('n2prerender') && Request::$GET->getCmd('n2app') !== '') {
$ret = false;
}
return $ret;
}, 1000000);
/**
* For ajax based page loaders
*
* HTTP_X_BARBA -> Rubenz theme
* swup -> Etc @see https://themeforest.net/item/etc-agency-freelance-portfolio-wordpress-theme/23832736
*/
$xRequestedWiths = array(
'XMLHttpRequest',
'swup'
);
if ((Request::$SERVER->getCmd('HTTP_X_REQUESTED_WITH') !== '' && in_array(Request::$SERVER->getCmd('HTTP_X_REQUESTED_WITH'), $xRequestedWiths)) || Request::$SERVER->getCmd('HTTP_X_BARBA') !== '') {
if (intval(Settings::get('wp-ajax-iframe-slider', 0))) {
Shortcode::forceIframe('ajax');
}
}
add_action('load-toplevel_page_' . NEXTEND_SMARTSLIDER_3_URL_PATH, array(
$this,
'removeEmoji'
));
/**
* Yoast SEO - Sitemap add images
*/
if (Settings::get('yoast-sitemap', 1)) {
add_filter('wpseo_xml_sitemap_post_url', array(
$this,
'filter_wpseo_xml_sitemap_post_url'
), 10, 2);
}
/**
* Not sure which page builder is it...
*/
if (Request::$GET->getInt('pswLoad')) {
Shortcode::forceIframe('psw');
}
if (defined('WC_ETRANSACTIONS_PLUGIN')) {
/**
* Plugin: https://wordpress.org/plugins/e-transactions-wc/
*
* @see SSDEV-2680
*/
remove_action('admin_notices', 'hmac_admin_notice');
}
/**
* Plugin: https://wordpress.org/plugins/weglot/
*
* @see SSDEV-3551
*/
if (defined('WEGLOT_NAME') && Request::$GET->getInt('n2prerender') && Request::$GET->getCmd('n2app') !== '') {
add_filter('weglot_button_html', function ($button_html) {
return '';
});
}
}
public function removeEmoji() {
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('admin_print_scripts', 'print_emoji_detection_script');
}
public static function filter_wpseo_xml_sitemap_post_url($permalink, $post) {
global $shortcode_tags;
$_shortcode_tags = $shortcode_tags;
$shortcode_tags = array(
"smartslider3" => array(
Shortcode::class,
"doShortcode"
)
);
$post->post_content = do_shortcode($post->post_content);
$shortcode_tags = $_shortcode_tags;
return $permalink;
}
}

View File

@ -0,0 +1,77 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress;
use Nextend\Framework\Request\Request;
use Nextend\SmartSlider3\Install\Install;
use Nextend\SmartSlider3\Install\Tables;
use Nextend\SmartSlider3\Platform\SmartSlider3Platform;
use Nextend\SmartSlider3\SmartSlider3Info;
class HelperInstall {
public function __construct() {
global $wp_version;
if (version_compare($wp_version, '5.1') >= 0) {
add_action('wp_delete_site', array(
$this,
'delete_site'
), 10);
} else {
add_action('delete_blog', array(
$this,
'action_delete_blog'
), 10, 2);
}
}
public function installOrUpgrade() {
if (get_option("n2_ss3_version") != SmartSlider3Info::$completeVersion) {
$this->install();
} else if (Request::$REQUEST->getInt('repairss3') && current_user_can('manage_options') && check_admin_referer('repairss3')) {
$this->install();
Tables::repair();
wp_redirect(SmartSlider3Platform::getAdminUrl());
exit;
}
}
private function install() {
if (Install::install()) {
update_option("n2_ss3_version", SmartSlider3Info::$completeVersion);
if (function_exists('opcache_reset')) {
opcache_reset();
}
return true;
}
return false;
}
public function delete_site($old_site) {
$this->action_delete_blog($old_site->blog_id, true);
}
public function action_delete_blog($blog_id, $drop) {
if ($drop) {
global $wpdb;
$prefix = $wpdb->get_blog_prefix($blog_id);
$wpdb->query('DROP TABLE IF EXISTS ' . $prefix . 'nextend2_image_storage, ' . $prefix . 'nextend2_section_storage;');
$wpdb->query('DROP TABLE IF EXISTS ' . $prefix . 'nextend2_smartslider3_generators, ' . $prefix . 'nextend2_smartslider3_sliders, ' . $prefix . 'nextend2_smartslider3_slides, ' . $prefix . 'nextend2_smartslider3_sliders_xref;');
}
}
}

View File

@ -0,0 +1,169 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress;
use Nextend\Framework\Asset\AssetManager;
use Nextend\Framework\Asset\Js\Js;
use Nextend\Framework\Asset\Predefined;
use Nextend\Framework\Pattern\GetAssetsPathTrait;
use Nextend\Framework\Pattern\SingletonTrait;
use Nextend\SmartSlider3\Application\ApplicationSmartSlider3;
use Nextend\SmartSlider3\Settings;
use Nextend\SmartSlider3\SmartSlider3Info;
use Nextend\Framework\Request\Request;
class HelperTinyMCE {
use SingletonTrait, GetAssetsPathTrait;
protected function init() {
add_action('admin_init', array(
$this,
'addButton'
));
}
public function addButton() {
if ((!current_user_can('edit_posts') && !current_user_can('edit_pages'))) {
return;
}
if (in_array(basename(Request::$SERVER->getVar('PHP_SELF')), array(
'post-new.php',
'page-new.php',
'post.php',
'page.php'
))) {
if (intval(Settings::get('editor-icon', 1))) {
$this->addForced();
if (get_user_option('rich_editing') == 'true') {
add_filter('mce_external_plugins', array(
$this,
'mceAddPlugin'
));
add_filter('mce_buttons', array(
$this,
'mceRegisterButton'
));
}
}
}
}
public function addForcedFrontend($action = 'wp_print_footer_scripts') {
$this->addForced('wp_print_footer_scripts');
}
public function addForced($action = 'admin_print_footer_scripts') {
static $added = false;
if (!$added) {
AssetManager::getInstance();
Js::addGlobalInline('window.N2DISABLESCHEDULER=1;');
Predefined::frontend();
Predefined::backend();
ApplicationSmartSlider3::getInstance()
->getApplicationTypeAdmin()
->enqueueAssets();
$this->initButtonDialog();
add_action($action, array(
$this,
'addButtonDialog'
));
$added = true;
}
}
public function mceAddPlugin($plugin_array) {
$plugin_array['smartslider3'] = self::getAssetsUri() . '/dist/wordpress-tinymce.min.js';
return $plugin_array;
}
public function mceRegisterButton($buttons) {
array_push($buttons, "|", "smartslider3");
return $buttons;
}
public function initButtonDialog() {
wp_register_style('smart-slider-editor', self::getAssetsUri() . '/dist/wordpress-editor.min.css', array(), SmartSlider3Info::$version, 'screen');
wp_enqueue_style('smart-slider-editor');
}
public function addButtonDialog() {
?>
<script>
window.NextendSmartSliderWPTinyMCEModal = function (ed) {
_N2.SelectSlider(n2_('Select Slider'), function (id, alias) {
if (alias) {
ed.execCommand('mceInsertContent', false, '<div>[smartslider3 alias="' + alias + '"]</div>');
} else if (id) {
ed.execCommand('mceInsertContent', false, '<div>[smartslider3 slider=' + id + ']</div>');
}
});
};
if (typeof QTags !== 'undefined') {
QTags.addButton('smart-slider-3', 'Smart Slider', function () {
_N2.SelectSlider(n2_('Select Slider'), function (id, alias) {
if (alias) {
QTags.insertContent("\n" + '<div>[smartslider3 alias="' + alias + '"]</div>');
} else if (id) {
QTags.insertContent("\n" + '<div>[smartslider3 slider=' + id + ']</div>');
}
});
});
}
window.NextendSmartSliderSelectModal = function ($input) {
_N2.SelectSlider(n2_('Select Slider'), function (id, alias) {
var idOrAlias = false;
if (alias) {
idOrAlias = alias;
} else if (id) {
idOrAlias = id;
}
if (idOrAlias) {
if (typeof $input === 'function') {
$input = $input();
}
$input.val(idOrAlias).trigger('input').trigger('change');
}
});
return false;
};
window.NextendSmartSliderSelectModalCallback = function (cb) {
_N2.SelectSlider(n2_('Select Slider'), function (id, alias) {
var idOrAlias = false;
if (alias) {
idOrAlias = alias;
} else if (id) {
idOrAlias = id;
}
if (idOrAlias) {
cb(idOrAlias);
}
});
return false;
}
</script>
<?php
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\ACF;
class ACF {
public function __construct() {
if (class_exists('acf', false)) {
add_action('acf/register_fields', array(
$this,
'registerFields'
));
add_action('acf/include_fields', array(
$this,
'registerFields'
));
}
}
public function registerFields() {
new AcfFieldSmartSlider3();
}
}

View File

@ -0,0 +1,154 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\ACF;
use acf_field;
use Nextend\SmartSlider3\Application\ApplicationSmartSlider3;
use Nextend\SmartSlider3\Application\Model\ModelSliders;
class AcfFieldSmartSlider3 extends acf_field {
public $label = 'Smart Slider 3';
function __construct() {
$this->name = 'acf_smartslider3';
parent::__construct();
}
function load_value($value, $post_id, $field) {
return $value;
}
function update_value($value, $field, $post_id) {
return $value;
}
public function format_value($value, $field) {
if (is_admin()) {
return $value;
}
if (!$value) {
return false;
}
if (!is_numeric($value)) {
return do_shortcode('[smartslider3 alias="' . $value . '"]');
}
return do_shortcode('[smartslider3 slider=' . $value . ']');
}
public function format_value_for_api($value, $field) {
if (is_admin()) {
return $value;
}
return $this->format_value($value, $field);
}
function load_field($field) {
return $field;
}
public function create_field($field) {
$this->render_field($field);
}
public function render_field($field) {
$applicationType = ApplicationSmartSlider3::getInstance()
->getApplicationTypeAdmin();
$slidersModel = new ModelSliders($applicationType);
$choices = array();
foreach ($slidersModel->getAll(0, 'published') as $slider) {
if ($slider['type'] == 'group') {
$subChoices = array();
if (!empty($slider['alias'])) {
$subChoices[$slider['alias']] = n2_('Whole group') . ' - ' . $slider['title'] . ' #Alias: ' . $slider['alias'];
}
$subChoices[$slider['id']] = n2_('Whole group') . ' - ' . $slider['title'] . ' #' . $slider['id'];
foreach ($slidersModel->getAll($slider['id'], 'published') as $_slider) {
if (!empty($_slider['alias'])) {
$subChoices[$_slider['alias']] = $_slider['title'] . ' #Alias: ' . $_slider['alias'];
}
$subChoices[$_slider['id']] = $_slider['title'] . ' #' . $_slider['id'];
}
$choices[$slider['id']] = array(
'label' => $slider['title'] . ' #' . $slider['id'],
'choices' => $subChoices
);
} else {
if (!empty($slider['alias'])) {
$choices[$slider['alias']] = $slider['title'] . ' #Alias: ' . $slider['alias'];
}
$choices[$slider['id']] = $slider['title'] . ' #' . $slider['id'];
}
}
?>
<table style="width:100%;border:0;">
<tr>
<td style="white-space: nowrap;">
<a href="#" onclick="<?php echo "NextendSmartSliderSelectModal(jQuery('#" . esc_js($field['id']) . "'));"; ?>return false;" class="button" title="<?php n2_e('Select Slider'); ?>"><?php n2_e('Select Slider'); ?></a>
<span style="line-height:2;padding:10px;"><?php n2_e('OR'); ?></span>
</td>
<td style="width:90%;">
<select id="<?php echo esc_attr($field['id']); ?>" class="<?php echo esc_attr($field['class']); ?>" name="<?php echo esc_attr($field['name']); ?>">
<?php if (!isset($field['required']) || !$field['required']): ?>
<option value=""><?php n2_e('None'); ?></option>
<?php endif; ?>
<?php
foreach ($choices as $id => $choice) {
if (is_array($choice)) {
?>
<optgroup label="<?php echo esc_attr($choice['label']); ?>">
<?php
foreach ($choice['choices'] as $_id => $_choice) {
?>
<option <?php if ($_id == $field['value']){ ?>selected <?php } ?>value="<?php echo esc_attr($_id); ?>"><?php echo esc_html($_choice); ?></option>
<?php
}
?>
</optgroup>
<?php
} else {
?>
<option <?php if ($id == $field['value']){ ?>selected <?php } ?>value="<?php echo esc_attr($id); ?>"><?php echo esc_html($choice); ?></option>
<?php
}
}
?>
</select>
</td>
</tr>
</table>
<?php
}
function create_options($field) {
}
function input_admin_enqueue_scripts() {
}
function input_admin_head() {
}
function field_group_admin_enqueue_scripts() {
}
function field_group_admin_head() {
}
}

View File

@ -0,0 +1,207 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\BeaverBuilder;
use FLBuilder;
use Nextend\Framework\WordPress\AssetInjector;
use Nextend\SmartSlider3\Application\ApplicationSmartSlider3;
use Nextend\SmartSlider3\Application\Model\ModelSliders;
use Nextend\SmartSlider3\Platform\WordPress\HelperTinyMCE;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class BeaverBuilder {
public function __construct() {
if (class_exists('\\FLBuilderModel', false)) {
$this->init();
}
}
public function init() {
add_action('fl_builder_editing_enabled', array(
$this,
'forceShortcodeIframe'
));
add_action('fl_builder_editing_enabled', array(
HelperTinyMCE::getInstance(),
"addForcedFrontend"
));
add_action('fl_ajax_before_render_new_module', array(
$this,
'forceShortcodeIframe'
));
add_action('fl_ajax_before_render_layout', array(
$this,
'forceShortcodeIframe'
));
add_action('fl_ajax_before_render_module_settings', array(
$this,
'forceShortcodeIframe'
));
add_action('fl_ajax_before_save_settings', array(
$this,
'forceShortcodeIframe'
));
add_action('fl_ajax_before_copy_module', array(
$this,
'forceShortcodeIframe'
));
add_action('fl_builder_before_render_ajax_layout', array(
$this,
'forceShortcodeIframe'
));
add_action('init', array(
$this,
'action_init'
));
add_action('fl_builder_control_smart-slider', array(
$this,
'fieldSmartSlider'
), 1, 3);
/**
* Fix for Beaver Builder 1.5
*/
add_action('fl_ajax_fl_builder_render_new_module_settings', array(
AssetInjector::getInstance(),
'removeInjectCSSComment'
), 0);
add_action('fl_ajax_fl_builder_save', array(
AssetInjector::getInstance(),
'removeInjectCSSComment'
), 0);
}
public function action_init() {
if (class_exists('\\FLBuilder')) {
FLBuilder::register_module(SmartSlider3::class, array(
'general' => array(
'title' => __('General', 'fl-builder'),
'sections' => array(
'general' => array(
'title' => "",
'fields' => array(
'sliderid' => array(
'type' => 'smart-slider',
'label' => 'Slider ID or Alias',
'default' => ''
),
)
)
)
)
));
/**
* Legacy
*/
FLBuilder::register_module(SmartSlider3Legacy::class, array(
'general' => array(
'title' => __('General', 'fl-builder'),
'sections' => array(
'general' => array(
'title' => "",
'fields' => array(
'sliderid' => array(
'type' => 'smart-slider',
'label' => 'Slider ID or Alias',
'default' => ''
),
)
)
)
)
));
}
}
public function forceShortcodeIframe() {
remove_action('wp_enqueue_scripts', array(
Shortcode::class,
'shortcodeModeToNoop'
), 1000000);
Shortcode::forceIframe('Beaver Builder', true);
}
public function fieldSmartSlider($name, $value, $field) {
$applicationType = ApplicationSmartSlider3::getInstance()
->getApplicationTypeAdmin();
$slidersModel = new ModelSliders($applicationType);
$choices = array();
foreach ($slidersModel->getAll(0, 'published') as $slider) {
if ($slider['type'] == 'group') {
$subChoices = array();
if (!empty($slider['alias'])) {
$subChoices[$slider['alias']] = n2_('Whole group') . ' - ' . $slider['title'] . ' #Alias: ' . $slider['alias'];
}
$subChoices[$slider['id']] = n2_('Whole group') . ' - ' . $slider['title'] . ' #' . $slider['id'];
foreach ($slidersModel->getAll($slider['id'], 'published') as $_slider) {
if (!empty($_slider['alias'])) {
$subChoices[$_slider['alias']] = $_slider['title'] . ' #Alias: ' . $_slider['alias'];
}
$subChoices[$_slider['id']] = $_slider['title'] . ' #' . $_slider['id'];
}
$choices[$slider['id']] = array(
'label' => $slider['title'] . ' #' . $slider['id'],
'choices' => $subChoices
);
} else {
if (!empty($slider['alias'])) {
$choices[$slider['alias']] = $slider['title'] . ' #Alias: ' . $slider['alias'];
}
$choices[$slider['id']] = $slider['title'] . ' #' . $slider['id'];
}
}
?>
<select name="<?php echo esc_attr($name); ?>">
<option value=""><?php n2_e('None'); ?></option>
<?php
foreach ($choices as $id => $choice) {
if (is_array($choice)) {
?>
<optgroup label="<?php echo esc_attr($choice['label']); ?>">
<?php
foreach ($choice['choices'] as $_id => $_choice) {
?>
<option <?php if ($_id == $value){ ?>selected <?php } ?>value="<?php echo esc_attr($_id); ?>"><?php echo esc_html($_choice); ?></option>
<?php
}
?>
</optgroup>
<?php
} else {
?>
<option <?php if ($id == $value){ ?>selected <?php } ?>value="<?php echo esc_attr($id); ?>"><?php echo esc_html($choice); ?></option>
<?php
}
}
?>
</select>
<div style="line-height:2;padding:10px;"><?php n2_e('OR'); ?></div>
<a href="#" onclick="NextendSmartSliderSelectModal(jQuery(this).siblings('select')) ;return false;" class="fl-builder-smart-slider-select fl-builder-button fl-builder-button-small fl-builder-button-primary" title="Select slider"><?php n2_e('Select Slider'); ?></a>
<script>
(function ($) {
var value = $('select[name="<?php echo esc_js($name); ?>"]').val();
if (value == '' || value == '0') {
$('.fl-builder-smart-slider-select').trigger('click');
}
})(jQuery);
</script>
<?php
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\BeaverBuilder;
use FLBuilderModule;
class SmartSlider3 extends FLBuilderModule {
public function __construct() {
parent::__construct(array(
'name' => 'Smart Slider',
'description' => 'Display the selected slider from Smart Slider plugin.',
'category' => __('Basic Modules', 'fl-builder'),
'dir' => plugin_dir_path(__FILE__),
'url' => plugins_url('/', __FILE__),
'editor_export' => true,
'enabled' => true
));
$this->slug = 'SmartSlider3';
}
public function get_icon($icon = '') {
return file_get_contents(dirname(__FILE__) . '/icon.svg');
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\BeaverBuilder;
use FLBuilderModule;
class SmartSlider3Legacy extends FLBuilderModule {
public function __construct() {
parent::__construct(array(
'name' => 'Smart Slider (Deprecated)',
'description' => 'Display the selected slider from Smart Slider plugin.',
'category' => __('Basic Modules', 'fl-builder'),
'dir' => plugin_dir_path(__FILE__),
'url' => plugins_url('/', __FILE__),
'editor_export' => true,
'enabled' => false,
));
$this->slug = 'beaver-builder-module';
}
}

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18">
<path d="M13.6 9.441a.522.522 0 0 1 .547.091.762.762 0 0 1 .253.583v3.567c0 .303-.161.572-.401.672l-3.601 1.513a3.582 3.582 0 0 1-2.795 0l-3.601-1.513c-.24-.1-.4-.37-.401-.672v-3.567c0-.232.094-.449.253-.583a.522.522 0 0 1 .546-.09l4.397 1.854a.51.51 0 0 0 .4 0zM8.78 1.92c.142-.06.3-.06.443 0l8.402 3.51c.228.096.38.335.375.599a.63.63 0 0 1-.402.584l-8.401 3.12a.546.546 0 0 1-.399 0L2.6 7.43a68.012 68.012 0 0 1-.8-.308v4.958c0 .523-.403.947-.9.947s-.9-.424-.9-.947V6.03a.633.633 0 0 1 .378-.6z"/>
</svg>

After

Width:  |  Height:  |  Size: 595 B

View File

@ -0,0 +1,9 @@
<?php
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly
}
if (is_numeric($settings->sliderid)) {
echo '[smartslider3 slider=' . esc_html($settings->sliderid) . ']';
} else {
echo '[smartslider3 alias="' . esc_html($settings->sliderid) . '"]';
}

View File

@ -0,0 +1,16 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\BoldGrid;
use Nextend\Framework\Request\Request;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class BoldGrid {
public function __construct() {
if (class_exists('Boldgrid_Editor') && (Request::$REQUEST->getCmd('action') == 'boldgrid_shortcode_smartslider3' || Request::$REQUEST->getCmd('action') == 'boldgrid_component_wp_smartslider3')) {
Shortcode::forceIframe('Boldgrid', true);
}
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Brizy;
use Brizy_Editor;
use Nextend\Framework\Request\Request;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class Brizy {
public function __construct() {
if (class_exists('Brizy_Editor') && Request::$REQUEST->getVar('action') == Brizy_Editor::prefix() . '_shortcode_content') {
Shortcode::forceIframe('Brizy', true);
}
}
}

View File

@ -0,0 +1,54 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Divi;
use Nextend\SmartSlider3\Platform\WordPress\Integration\Divi\V31ge\DiviExtensionSmartSlider3;
use Nextend\SmartSlider3\Platform\WordPress\Integration\Divi\V31lt\DiviV31lt;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class Divi {
public function __construct() {
add_action('et_builder_ready', array(
$this,
'action_et_builder_ready'
));
add_action('divi_extensions_init', array(
$this,
'action_divi_extensions_init'
));
add_action('et_fb_framework_loaded', array(
$this,
'forceShortcodeIframe'
));
}
public function action_et_builder_ready() {
if (version_compare(ET_CORE_VERSION, '3.1', '<')) {
new DiviV31lt();
}
if (is_et_pb_preview()) {
$this->forceShortcodeIframe();
}
}
public function action_divi_extensions_init() {
if (version_compare(ET_CORE_VERSION, '3.1', '>=')) {
new DiviExtensionSmartSlider3();
}
}
public function forceShortcodeIframe() {
Shortcode::forceIframe('Divi', true);
}
}

View File

@ -0,0 +1,78 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Divi\V31ge;
use DiviExtension;
class DiviExtensionSmartSlider3 extends DiviExtension {
public $gettext_domain = 'smart-slider-3';
public $name = 'smart-slider-3';
public $version = '1.0.0';
public function __construct($name = 'smart-slider-3', $args = array()) {
$this->plugin_dir = plugin_dir_path(__FILE__);
$this->plugin_dir_url = plugin_dir_url(__FILE__);
$this->_builder_js_data = array(
'iframeUrl' => site_url('/') . '?n2prerender=1&n2app=smartslider&n2controller=slider&n2action=iframe&h=' . sha1(NONCE_SALT . date('Y-m-d'))
);
parent::__construct($name, $args);
add_action('admin_enqueue_scripts', array(
$this,
'admin_enqueue_scripts'
));
add_action('smartslider3_slider_changed', array(
$this,
'clearDiviCache'
));
}
public function admin_enqueue_scripts() {
$styles_url = "{$this->plugin_dir_url}styles/admin/style.min.css";
wp_enqueue_style("{$this->name}-admin-styles", $styles_url, array(), $this->version);
?>
<script>
if (typeof localStorage !== 'undefined') {
localStorage.removeItem('et_pb_templates_et_pb_nextend_smart_slider_3');
localStorage.removeItem('et_pb_templates_et_pb_nextend_smart_slider_3_fullwidth');
}
</script>
<?php
}
public function clearDiviCache() {
if (function_exists('et_fb_delete_builder_assets')) {
/**
* We must delete the js files in wp-content/cache/et/ folder to refresh the slider list in Divi module
*/
et_fb_delete_builder_assets();
}
}
public function wp_hook_enqueue_scripts() {
parent::wp_hook_enqueue_scripts();
if (!et_core_is_fb_enabled()) {
wp_dequeue_style("{$this->name}-styles");
}
}
protected function _enqueue_bundles() {
parent::_enqueue_bundles();
if (!et_core_is_fb_enabled()) {
wp_dequeue_script("{$this->name}-frontend-bundle");
}
}
}

View File

@ -0,0 +1,5 @@
{
"builder.js": "/scripts/builder-bundle.min.js",
"frontend.css": "/styles/style.min.css",
"frontend.js": "/scripts/frontend-bundle.min.js"
}

View File

@ -0,0 +1,121 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Divi\V31ge;
use ET_Builder_Module;
use Nextend\Framework\Asset\Builder\BuilderJs;
use Nextend\SmartSlider3\Application\ApplicationSmartSlider3;
use Nextend\SmartSlider3\Application\Frontend\ApplicationTypeFrontend;
use Nextend\SmartSlider3\Application\Model\ModelSliders;
class ET_Builder_Module_SmartSlider3 extends ET_Builder_Module {
protected $module_credits = array(
'module_uri' => 'https://smartslider3.com',
'author' => 'Nextendweb',
'author_uri' => 'https://nextendweb.com',
);
public function init() {
$this->name = 'Smart Slider 3';
$this->slug = 'et_pb_nextend_smart_slider_3';
$this->vb_support = 'on';
$this->settings_modal_toggles = array(
'general' => array(
'toggles' => array(
'content' => esc_html__('Content', 'et_builder')
),
),
);
}
public function add_styles_scripts() {
?>
<script>
window.SmartSlider3IframeUrl = <?php echo json_encode(site_url('/') . '?n2prerender=1&n2app=smartslider&n2controller=slider&n2action=iframe&h=' . sha1(NONCE_SALT . date('Y-m-d'))); ?>;
<?php
$path = ApplicationTypeFrontend::getAssetsPath() . '/dist/iframe.min.js';
add_filter('js_escape', 'Nextend\Framework\Sanitize::esc_js_filter', 10, 2);
if (file_exists($path)) {
echo esc_js(file_get_contents($path));
} else {
}
remove_filter('js_escape', 'Nextend\Framework\Sanitize::esc_js_filter', 10);
?>
</script>
<?php
}
public function get_fields() {
if (et_core_is_fb_enabled()) {
add_action('wp_footer', array(
$this,
'add_styles_scripts'
));
}
$applicationType = ApplicationSmartSlider3::getInstance()
->getApplicationTypeAdmin();
$slidersModel = new ModelSliders($applicationType);
$options = array();
$options[-1] = 'None';
foreach ($slidersModel->getAll(0, 'published') as $slider) {
if ($slider['type'] == 'group') {
$subChoices = array();
if (!empty($slider['alias'])) {
$subChoices[$slider['alias']] = '-- ' . n2_('Whole group') . ' - ' . $slider['title'] . ' #Alias: ' . $slider['alias'];
}
$subChoices[$slider['id']] = '-- ' . n2_('Whole group') . ' - ' . $slider['title'] . ' #' . $slider['id'];
foreach ($slidersModel->getAll($slider['id'], 'published') as $_slider) {
if (!empty($_slider['alias'])) {
$subChoices[$_slider['alias']] = '-- ' . $_slider['title'] . ' #Alias: ' . $_slider['alias'];
}
$subChoices[$_slider['id']] = '-- ' . $_slider['title'] . ' #' . $_slider['id'];
}
$options[$slider['title'] . ' #' . $slider['id']] = $subChoices;
} else {
if (!empty($slider['alias'])) {
$options[$slider['alias']] = $slider['title'] . ' #Alias: ' . $slider['alias'];
}
$options[$slider['id']] = $slider['title'] . ' #' . $slider['id'];
}
}
return array(
'slider' => array(
'default' => -1,
'label' => 'Slider',
'option_category' => 'basic_option',
'type' => 'select',
'options' => $options,
'description' => esc_html__('Here you can create the content that will be used within the module.', 'et_builder'),
'is_fb_content' => true,
'toggle_slug' => 'main_content',
),
);
}
public function render($attrs, $content, $render_slug) {
if (is_numeric($this->props['slider'])) {
return do_shortcode('[smartslider3 slider=' . $this->props['slider'] . ']');
}
return do_shortcode('[smartslider3 alias="' . $this->props['slider'] . '"]');
}
public function get_advanced_fields_config() {
return false;
}
}
new ET_Builder_Module_SmartSlider3;

View File

@ -0,0 +1,15 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Divi\V31ge;
class ET_Builder_Module_SmartSlider3Fullwidth extends ET_Builder_Module_SmartSlider3 {
public function init() {
$this->name = 'Smart Slider 3';
$this->slug = 'et_pb_nextend_smart_slider_3_fullwidth';
$this->vb_support = 'on';
$this->fullwidth = true;
}
}
new ET_Builder_Module_SmartSlider3Fullwidth();

View File

@ -0,0 +1,8 @@
<?php
if (!class_exists('ET_Builder_Element')) {
return;
}
require_once dirname(__FILE__) . '/includes/modules/SmartSlider3/SmartSlider3.php';
require_once dirname(__FILE__) . '/includes/modules/SmartSlider3FullWidth/SmartSlider3FullWidth.php';

View File

@ -0,0 +1,33 @@
{
"name": "my-extension",
"version": "0.1.0",
"private": true,
"dependencies": {
"divi-scripts": "1.0.1",
"react": "^16.7.0",
"react-dom": "^16.7.0"
},
"scripts": {
"start": "divi-scripts start",
"build": "divi-scripts build",
"zip": "divi-scripts build && divi-scripts zip",
"eject": "divi-scripts eject"
},
"browserslist": {
"development": [
"last 2 chrome versions",
"last 2 firefox versions",
"last 2 edge versions"
],
"production": [
">1%",
"last 4 versions",
"Firefox ESR",
"not ie < 11"
]
},
"cde": {
"gettext": "aaa-my-extension",
"prefix": "aaa"
}
}

View File

@ -0,0 +1 @@
!function(n){var t={};function r(e){if(t[e])return t[e].exports;var o=t[e]={i:e,l:!1,exports:{}};return n[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=n,r.c=t,r.d=function(n,t,e){r.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:e})},r.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(t,"a",t),t},r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.p="/",r(r.s=8)}({10:function(n,t){},8:function(n,t,r){r(9),n.exports=r(10)},9:function(n,t){}});

View File

@ -0,0 +1,4 @@
.et-pb-all-modules .et_pb_nextend_smart_slider_3_fullwidth:before,
.et-pb-all-modules .et_pb_nextend_smart_slider_3:before {
content: '\53';
}

View File

@ -0,0 +1 @@
.et_divi_builder #et_builder_outer_content .et-db #et-boc .et-fb-modules-list .et_fb_nextend_smart_slider_3:before{content:"S"}.et_divi_builder #et_builder_outer_content .et-db #et-boc .et-fb-modules-list .et_fb_nextend_smart_slider_3_fullwidth:before{content:"S"}

View File

@ -0,0 +1 @@
.et-db #et-boc .et-fb-modules-list .et_fb_nextend_smart_slider_3:before{content:"S"}.et-db #et-boc .et-fb-modules-list .et_fb_nextend_smart_slider_3_fullwidth:before{content:"S"}

View File

@ -0,0 +1,91 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Divi\V31lt;
use ET_Builder_Element;
use ET_Builder_Module;
use Nextend\SmartSlider3\Platform\WordPress\HelperTinyMCE;
class DiviModuleSmartSlider extends ET_Builder_Module {
function init() {
$this->name = 'Smart Slider 3';
$this->slug = 'et_pb_nextend_smart_slider_3';
$this->whitelisted_fields = array(
'admin_label'
);
if (defined('EXTRA_LAYOUT_POST_TYPE')) {
$this->post_types = array(EXTRA_LAYOUT_POST_TYPE);
}
$this->whitelisted_fields = array(
'slider',
);
$this->fields_defaults = array();
$this->advanced_options = array();
add_action('admin_footer', array(
$this,
'add_admin_icon'
));
HelperTinyMCE::getInstance()
->addForced();
}
public function add_admin_icon() {
?>
<style type="text/css">
.et-pb-all-modules .et_pb_nextend_smart_slider_3::before,
.et-pb-all-modules .et_pb_nextend_smart_slider_3_fullwidth::before {
content: 'S';
}
</style>
<?php
}
function get_fields() {
$fields = array(
'slider' => array(
'label' => 'Slider',
'option_category' => 'basic_option',
'type' => 'text',
'renderer' => array(
$this,
'field_smart_slider_renderer'
),
'renderer_with_field' => true
),
'admin_label' => array(
'label' => esc_html__('Admin Label', 'et_builder'),
'type' => 'text',
'description' => esc_html__('This will change the label of the module in the builder for easy identification.', 'et_builder'),
'toggle_slug' => 'admin_label',
)
);
return $fields;
}
function shortcode_callback($atts, $content, $function_name) {
$sliderIdOrAlias = $this->shortcode_atts['slider'];
$module_class = '';
$module_class = ET_Builder_Element::add_module_order_class($module_class, $function_name);
if (!is_numeric($sliderIdOrAlias)) {
return '<div class="et_pb_module et-waypoint ' . $module_class . ' et_pb_animation_off">' . do_shortcode('[smartslider3 alias="' . $sliderIdOrAlias . '"]') . '</div>';
}
return '<div class="et_pb_module et-waypoint ' . $module_class . ' et_pb_animation_off">' . do_shortcode('[smartslider3 slider=' . $sliderIdOrAlias . ']') . '</div>';
}
public function field_smart_slider_renderer() {
$output = sprintf('<input type="button" class="button button-upload" value="%1$s" onclick="NextendSmartSliderSelectModal(jQuery(this).siblings(\'.regular-text\')); return false;">', n2_('Select Slider'));
return $output;
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Divi\V31lt;
class DiviModuleSmartSliderFullwidth extends DiviModuleSmartSlider {
function init() {
parent::init();
$this->fullwidth = true;
$this->slug = 'et_pb_nextend_smart_slider_3_fullwidth';
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Divi\V31lt;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class DiviV31lt {
public function __construct() {
add_filter('et_builder_get_child_modules', array(
$this,
'filter_et_builder_get_child_modules'
));
if (function_exists('et_fb_is_enabled') && et_fb_is_enabled()) {
$this->forceShortcodeIframe();
}
if (function_exists('is_et_pb_preview') && is_et_pb_preview()) {
$this->forceShortcodeIframe();
}
add_action('wp_ajax_et_fb_retrieve_builder_data', array(
$this,
'forceShortcodeIframe'
), 9);
new DiviModuleSmartSlider();
new DiviModuleSmartSliderFullwidth();
}
public function filter_et_builder_get_child_modules($child_modules) {
if ($child_modules === '') {
$child_modules = array();
}
return $child_modules;
}
public function forceShortcodeIframe() {
Shortcode::forceIframe('divi', true);
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Elementor;
use Elementor\Base_Data_Control;
use Elementor\Control_Base;
if (class_exists('\Elementor\Base_Data_Control')) {
abstract class AbstractControl extends Base_Data_Control {
}
} else {
abstract class AbstractControl extends Control_Base {
}
}
class_exists('\Elementor\Group_Control_Background');

View File

@ -0,0 +1,135 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Elementor;
use Elementor\Plugin;
use Nextend\SmartSlider3\Platform\WordPress\HelperTinyMCE;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
use Nextend\SmartSlider3\Platform\WordPress\Widget\WidgetSmartSlider3;
class Elementor {
public function __construct() {
add_action('elementor/init', array(
$this,
'init'
), 0);
}
public function init() {
if (!defined('SMART_SLIDER_ELEMENTOR_WIDGET_ALLOWED')) {
add_filter('elementor/widgets/black_list', function ($black_list) {
$black_list[] = 'N2SS3Widget';
$black_list[] = WidgetSmartSlider3::class;
return $black_list;
});
}
add_action('template_redirect', array(
$this,
'action_template_redirect'
), -1);
add_action('admin_action_elementor', array(
$this,
'forceShortcodeIframe'
), -10000);
add_action('wp_ajax_elementor_ajax', array(
$this,
'forceShortcodeIframe'
), -1);
add_action('wp_ajax_elementor_render_widget', array(
$this,
'forceShortcodeIframe'
), -1);
if ($this->elementor_version_compare('3.5.0')) {
add_action('elementor/widgets/register', array(
$this,
'action_widgets_registered'
), 100);
add_action('elementor/controls/register', array(
$this,
'action_controls_registered'
));
} else {
add_action('elementor/widgets/widgets_registered', array(
$this,
'action_widgets_registered'
), 100);
add_action('elementor/controls/controls_registered', array(
$this,
'action_controls_registered'
));
}
add_action('elementor/editor/before_enqueue_styles', array(
$this,
'action_editor_before_enqueue_styles'
));
add_action('elementor/editor/before_enqueue_scripts', array(
HelperTinyMCE::getInstance(),
'addForcedFrontend'
));
}
public function action_template_redirect() {
if (Plugin::instance()->editor->is_edit_mode() || Plugin::instance()->preview->is_preview_mode()) {
$this->forceShortcodeIframe();
}
}
public function action_widgets_registered() {
$widget_manager = Plugin::$instance->widgets_manager;
if ($this->elementor_version_compare('3.5.0')) {
$widget_manager->register(new ElementorWidgetSmartSlider());
} else if ($this->elementor_version_compare('2.9.0')) {
$widget_manager->register_widget_type(new ElementorWidgetSmartSlider350());
} else {
$widget_manager->register_widget_type(new ElementorWidgetSmartSlider290());
}
}
public function action_controls_registered($controls_manager) {
if ($this->elementor_version_compare('3.5.0')) {
$controls_manager->register(new ElementorControlSmartSlider());
} else {
$controls_manager->register_control('smartsliderfield', new ElementorControlSmartSlider());
}
}
public function forceShortcodeIframe() {
Shortcode::forceIframe('Elementor', true);
}
public function action_editor_before_enqueue_styles() {
HelperTinyMCE::getInstance()
->initButtonDialog();
}
public function elementor_version_compare($version, $compare = '>=') {
if (defined('ELEMENTOR_VERSION')) {
return version_compare(ELEMENTOR_VERSION, $version, $compare);
} else {
// ELEMENTOR_VERSION is only not defined in very old versions, what we don't support. So the real version number here doesn't matters.
return version_compare('1.0.0', $version, $compare);
}
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Elementor;
class_exists('\Elementor\Group_Control_Background');
class ElementorControlSmartSlider extends AbstractControl {
public function get_type() {
return 'smartsliderfield';
}
public function content_template() {
?>
<div class="elementor-control-field">
<label class="elementor-control-title">{{{ data.label }}}</label>
<div class="elementor-control-input-wrapper">
<a style="margin-bottom:10px;" href="#" onclick="NextendSmartSliderSelectModal(jQuery(this).siblings('input')); return false;" class="button button-primary elementor-button elementor-button-smartslider" title="Select slider">Select
slider</a>
<input type="{{ data.input_type }}" title="{{ data.title }}" data-setting="{{ data.name }}">
</div>
</div>
<# if(data.controlValue == ''){NextendSmartSliderSelectModal(function(){return jQuery('[data-setting="smartsliderid"]')})} #>
<?php
}
public function get_default_settings() {
return [
'input_type' => 'text',
];
}
}

View File

@ -0,0 +1,68 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Elementor;
use Elementor\Plugin;
use Elementor\Widget_Base;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class ElementorWidgetSmartSlider extends Widget_Base {
public function get_name() {
return 'smartslider';
}
public function get_title() {
return 'Smart Slider';
}
public function get_icon() {
return 'eicon-slider-3d';
}
protected function register_controls() {
$this->start_controls_section('section_smart_slider_elementor', [
'label' => esc_html('Smart Slider'),
]);
$this->add_control('smartsliderid', [
'label' => 'Slider ID or Alias',
'type' => 'smartsliderfield',
'default' => '',
'title' => 'Slider ID or Alias',
]);
$this->end_controls_section();
}
protected function render() {
if (Plugin::instance()->editor->is_edit_mode() || Plugin::instance()->preview->is_preview_mode()) {
// PHPCS - Content already escaped
echo Shortcode::renderIframe($this->get_settings('smartsliderid')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
$sliderIDorAlias = $this->get_settings('smartsliderid');
if (is_numeric($sliderIDorAlias)) {
echo do_shortcode('[smartslider3 slider=' . $sliderIDorAlias . ']');
} else {
echo do_shortcode('[smartslider3 alias="' . $sliderIDorAlias . '"]');
}
}
}
/**
* Must be declared as empty method to prevent issues with SEO plugins.
*/
public function render_plain_content() {
}
protected function content_template() {
// PHPCS - Content already escaped
echo Shortcode::renderIframe('{{{settings.smartsliderid}}}'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Elementor;
use Elementor\Plugin;
use Elementor\Widget_Base;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class ElementorWidgetSmartSlider290 extends Widget_Base {
public function get_name() {
return 'smartslider';
}
public function get_title() {
return 'Smart Slider';
}
public function get_icon() {
return 'eicon-slider-3d';
}
protected function _register_controls() {
$this->start_controls_section('section_smart_slider_elementor', [
'label' => esc_html('Smart Slider'),
]);
$this->add_control('smartsliderid', [
'label' => 'Slider ID or Alias',
'type' => 'smartsliderfield',
'default' => '',
'title' => 'Slider ID or Alias',
]);
$this->end_controls_section();
}
protected function render() {
if (Plugin::instance()->editor->is_edit_mode() || Plugin::instance()->preview->is_preview_mode()) {
// PHPCS - Content already escaped
echo Shortcode::renderIframe($this->get_settings('smartsliderid')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
$sliderIDorAlias = $this->get_settings('smartsliderid');
if (is_numeric($sliderIDorAlias)) {
echo do_shortcode('[smartslider3 slider=' . $sliderIDorAlias . ']');
} else {
echo do_shortcode('[smartslider3 alias="' . $sliderIDorAlias . '"]');
}
}
}
/**
* Must be declared as empty method to prevent issues with SEO plugins.
*/
public function render_plain_content() {
}
/**
* The Elementor deprecated this function in version 2.9.0 and it will be removed in 3.7.0
* @url https://developers.elementor.com/v2-9-0-planned-deprecations/
*/
protected function _content_template() {
// PHPCS - Content already escaped
echo Shortcode::renderIframe('{{{settings.smartsliderid}}}'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}

View File

@ -0,0 +1,68 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Elementor;
use Elementor\Plugin;
use Elementor\Widget_Base;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class ElementorWidgetSmartSlider350 extends Widget_Base {
public function get_name() {
return 'smartslider';
}
public function get_title() {
return 'Smart Slider';
}
public function get_icon() {
return 'eicon-slider-3d';
}
protected function _register_controls() {
$this->start_controls_section('section_smart_slider_elementor', [
'label' => esc_html('Smart Slider'),
]);
$this->add_control('smartsliderid', [
'label' => 'Slider ID or Alias',
'type' => 'smartsliderfield',
'default' => '',
'title' => 'Slider ID or Alias',
]);
$this->end_controls_section();
}
protected function render() {
if (Plugin::instance()->editor->is_edit_mode() || Plugin::instance()->preview->is_preview_mode()) {
// PHPCS - Content already escaped
echo Shortcode::renderIframe($this->get_settings('smartsliderid')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
$sliderIDorAlias = $this->get_settings('smartsliderid');
if (is_numeric($sliderIDorAlias)) {
echo do_shortcode('[smartslider3 slider=' . $sliderIDorAlias . ']');
} else {
echo do_shortcode('[smartslider3 alias="' . $sliderIDorAlias . '"]');
}
}
}
/**
* Must be declared as empty method to prevent issues with SEO plugins.
*/
public function render_plain_content() {
}
protected function content_template() {
// PHPCS - Content already escaped
echo Shortcode::renderIframe('{{{settings.smartsliderid}}}'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Fusion;
class Fusion {
public function __construct() {
add_action('fusion_builder_shortcodes_init', array(
$this,
'init'
));
}
public function init() {
new FusionElementSmartSlider3();
add_action('fusion_builder_before_init', array(
$this,
'action_fusion_builder_before_init'
));
add_filter('fusion_builder_fields', array(
$this,
'filter_fusion_builder_fields'
));
}
public function action_fusion_builder_before_init() {
fusion_builder_map(array(
'name' => 'Smart Slider 3',
'shortcode' => 'fusion_smartslider3',
'icon' => 'fusiona-uniF61C',
'allow_generator' => true,
'params' => array(
array(
'type' => 'smartslider3',
'heading' => 'Slider',
'param_name' => 'slider',
'value' => '',
)
),
));
}
public function filter_fusion_builder_fields($fields) {
$fields[] = array(
'smartslider3',
dirname(__FILE__) . '/field-smartslider3.php'
);
return $fields;
}
}

View File

@ -0,0 +1,38 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Fusion;
use Fusion_Element;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class FusionElementSmartSlider3 extends Fusion_Element {
public function __construct() {
parent::__construct();
add_action('fusion_load_module', array(
$this,
'force_iframe'
));
add_shortcode('fusion_smartslider3', array(
$this,
'render'
));
}
public function render($args, $content = '') {
if (!empty($args)) {
return do_shortcode('[smartslider3 slider="' . $args['slider'] . '"]');
} else {
return '<!-- Avada Builder empty Smart Slider element -->';
}
}
public function force_iframe() {
Shortcode::forceIframe('fusion', true);
}
}

View File

@ -0,0 +1,12 @@
<a style="margin-bottom:10px;" href="#" onclick="NextendSmartSliderSelectModal(jQuery(this).siblings('input')); return false;" class="button button-primary" title="Select slider">
Select slider
</a>
<input type="text" name="{{ param.param_name }}" id="{{ param.param_name }}" value="{{ option_value }}">
<?php
use Nextend\SmartSlider3\Platform\WordPress\HelperTinyMCE;
HelperTinyMCE::getInstance()
->addForcedFrontend();
?>

View File

@ -0,0 +1,63 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Gutenberg;
use Nextend\Framework\Pattern\GetAssetsPathTrait;
use Nextend\SmartSlider3\Application\ApplicationSmartSlider3;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class Gutenberg {
use GetAssetsPathTrait;
public function __construct() {
global $wp_version;
if (version_compare($wp_version, '5.0', '>=')) {
add_action('init', array(
$this,
'init'
));
}
}
public function init() {
global $wp_version;
$deps = array(
'wp-blocks',
'wp-element',
'wp-components'
);
if (version_compare($wp_version, '5.3', '<')) {
$deps[] = 'wp-editor';
} else {
$deps[] = 'wp-block-editor';
}
wp_register_script('gutenberg-smartslider3', self::getAssetsUri() . '/dist/gutenberg-block.min.js', $deps, null, true);
register_block_type('nextend/smartslider3', array(
'editor_script' => 'gutenberg-smartslider3',
));
add_action('enqueue_block_editor_assets', array(
$this,
'enqueue_block_editor_assets'
));
}
public function enqueue_block_editor_assets() {
wp_add_inline_script('gutenberg-smartslider3', 'window.gutenberg_smartslider3=' . json_encode(array(
'template' => Shortcode::renderIframe('{{{slider}}}'),
'slider_edit_url' => ApplicationSmartSlider3::getInstance()
->getApplicationTypeAdmin()
->createUrl('slider/edit') . '&slideraliasorid='
)) . ';');
Shortcode::forceIframe('gutenberg');
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Jetpack;
use Nextend\Framework\Asset\AssetManager;
use Nextend\Framework\Plugin;
class Jetpack {
public function __construct() {
if (defined('JETPACK__VERSION')) {
Plugin::addAction('n2_assets_manager_started', array(
$this,
'action_assets_manager_started'
));
add_filter('kses_allowed_protocols', array(
$this,
'kses_allowed_protocols'
), 10, 1);
}
}
public function action_assets_manager_started() {
add_filter('jetpack_photon_skip_image', array(
$this,
'filter_jetpack_photon_skip_image'
), 10, 3);
}
public function filter_jetpack_photon_skip_image($val, $src, $tag) {
if (AssetManager::$image->match($src)) {
return true;
}
return $val;
}
public function kses_allowed_protocols($protocols) {
$protocols[] = 'data';
return $protocols;
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\MotoPressCE;
use MPCEShortcode;
class MotoPressCE {
public function __construct() {
if (class_exists('MPCEShortcode', false)) {
$this->init();
}
}
public function init() {
if (MPCEShortcode::isContentEditor()) {
remove_shortcode('smartslider3');
}
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\NimbleBuilder;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class NimbleBuilder {
public function __construct() {
if (defined('NIMBLE_VERSION')) {
add_action('wp_ajax_sek_get_content', array(
$this,
'forceShortcodeIframe'
), -1);
}
}
public function forceShortcodeIframe() {
Shortcode::forceIframe('Nimble Builder', true);
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\OxygenBuilder;
use Nextend\Framework\Request\Request;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class OxygenBuilder {
public function __construct() {
if (defined('CT_VERSION') && (Request::$REQUEST->getCmd('action') == 'ct_render_shortcode' || Request::$REQUEST->getCmd('action') == 'ct_get_post_data')) {
self::forceShortcodeIframe();
}
}
public function forceShortcodeIframe() {
Shortcode::forceIframe('OxygenBuilder', true);
}
}

View File

@ -0,0 +1,95 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\RankMath;
use Nextend\Framework\Pattern\GetAssetsPathTrait;
use Nextend\Framework\Plugin;
use Nextend\Framework\Request\Request;
use Nextend\SmartSlider3\Application\Admin\Sliders\ControllerAjaxSliders;
use Nextend\SmartSlider3\Application\Admin\TraitAdminUrl;
use Nextend\SmartSlider3\Application\ApplicationSmartSlider3;
use Nextend\SmartSlider3\SmartSlider3Info;
class RankMath {
use GetAssetsPathTrait;
use TraitAdminUrl;
/** @var ControllerAjaxSliders */
protected $controller;
public function __construct() {
if (class_exists('RankMath', false)) {
add_action('admin_enqueue_scripts', array(
$this,
'admin_enqueue_scripts'
));
Plugin::addAction('PluggableController\Nextend\SmartSlider3\Application\Admin\Sliders\ControllerAjaxSliders', array(
$this,
'plugControllerAjaxSliders'
));
}
}
public function admin_enqueue_scripts($hook_suffix) {
if (in_array($hook_suffix, array(
'post.php',
'post-new.php'
), true) && wp_script_is('rank-math-analyzer')) {
$router = ApplicationSmartSlider3::getInstance()
->getApplicationTypeAdmin()
->getRouter();
wp_enqueue_script('smart-slider-3-rank-math-integration', self::getAssetsUri() . '/dist/rank-math-integration.min.js', array(
'wp-hooks',
'rank-math-analyzer'
), SmartSlider3Info::$version, true);
wp_localize_script('smart-slider-3-rank-math-integration', 'SmartSlider3RankMath', array(
'adminAjaxUrl' => $router->createAjaxUrl(array(
'sliders/RankMathContent'
))
));
}
}
/**
* @param ControllerAjaxSliders $controller
*/
public function plugControllerAjaxSliders($controller) {
$this->controller = $controller;
$this->controller->addExternalAction('rankmathcontent', array(
$this,
'actionRankMathContent'
));
}
public function actionRankMathContent() {
$this->controller->validateToken();
$sliderIDorAlias = Request::$POST->getInt('sliderID');
if (empty($sliderIDorAlias)) {
$sliderIDorAlias = Request::$POST->getVar('alias');
}
if (!empty($sliderIDorAlias)) {
$applicationTypeFrontend = ApplicationSmartSlider3::getInstance()
->getApplicationTypeFrontend();
$applicationTypeFrontend->process('slider', 'display', false, array(
'sliderID' => $sliderIDorAlias,
'usage' => 'RankMath ajax content'
));
}
exit;
}
}

View File

@ -0,0 +1,68 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\TablePress;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class TablePress {
private $level = 0;
public function __construct() {
if (defined('TABLEPRESS_ABSPATH')) {
$this->init();
}
}
public function init() {
add_filter('pre_do_shortcode_tag', array(
$this,
'before'
), 10, 2);
add_filter('do_shortcode_tag', array(
$this,
'after'
), 10, 2);
}
public function before($ret, $tag) {
if ($tag == 'table') {
$this->level++;
if ($this->level == 1) {
Shortcode::shortcodeModeToSkip();
}
}
return $ret;
}
public function after($output, $tag) {
if ($tag == 'table') {
$this->level--;
if ($this->level <= 0) {
Shortcode::shortcodeModeRestore();
global $shortcode_tags;
$tmp = $shortcode_tags;
$shortcode_tags = array(
'smartslider3' => array(
Shortcode::class,
'doShortcode'
)
);
$output = do_shortcode($output);
$shortcode_tags = $tmp;
}
}
return $output;
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\TatsuBuilder;
use Nextend\Framework\Request\Request;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class TatsuBuilder {
public function __construct() {
if (class_exists('Tatsu_Builder') && Request::$REQUEST->getCmd('action') == 'tatsu_module' && Request::$REQUEST->getVar('module') !== null) {
$tatsuModuleData = json_decode(Request::$REQUEST->getVar('module'));
if ($tatsuModuleData && is_object($tatsuModuleData) && isset($tatsuModuleData->name) && $tatsuModuleData->name === 'tatsu_text_with_shortcodes') {
Shortcode::forceIframe('TatsuBuilder', true);
}
}
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\ThemifyBuilder;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
use Themify_Builder_Model;
class ThemifyBuilder {
public function __construct() {
add_action('themify_builder_setup_modules', array(
$this,
'init'
));
}
//WORKING
public function init() {
/**
* Fix for slider shortcode appearance in Themmify Builder frontend editor
*/
add_action('wp_ajax_tb_render_element_shortcode', array(
$this,
'forceShortcodeIframe'
));
/**
* Fix for newly added slider widget appearance in Themmify Builder frontend editor
*/
add_action('wp_ajax_tb_load_module_partial', array(
$this,
'forceShortcodeIframe'
));
/**
* Fix for already added slider widget appearance in Themmify Builder frontend editor
*/
add_action('wp_ajax_tb_render_element', array(
$this,
'forceShortcodeIframe'
));
}
public function forceShortcodeIframe() {
Shortcode::forceIframe('Themify Builder', true);
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\Unyson;
class Unyson {
public function __construct() {
add_filter('fw_extensions_locations', array(
$this,
'filter_fw_extensions_locations'
));
}
public function filter_fw_extensions_locations($locations) {
if (version_compare(fw()->manifest->get_version(), '2.6.0', '>=')) {
$path = dirname(__FILE__);
$locations[$path] = plugin_dir_url(__FILE__);
}
return $locations;
}
}

View File

@ -0,0 +1,18 @@
<?php if (!defined('FW')) die('Forbidden');
class FW_Extension_SmartSlider extends FW_Extension {
/**
* @internal
*/
protected function _init() {
add_action('fw_option_types_init', array(
$this,
'_action_option_types_init'
));
}
public function _action_option_types_init() {
require_once dirname(__FILE__) . '/options/option-types.php';
}
}

View File

@ -0,0 +1,9 @@
<?php if (!defined('FW')) die('Forbidden');
$manifest = array();
$manifest['name'] = 'Smart Slider 3';
$manifest['version'] = '3.0.0';
$manifest['uri'] = 'https://smartslider3.com';
$manifest['author'] = 'Nextendweb';
$manifest['author_uri'] = 'https://smartslider3.com';
$manifest['standalone'] = true;

View File

@ -0,0 +1,76 @@
<?php
use Nextend\Framework\View\Html;
use Nextend\SmartSlider3\Application\ApplicationSmartSlider3;
use Nextend\SmartSlider3\Application\Model\ModelSliders;
use Nextend\SmartSlider3\Platform\WordPress\HelperTinyMCE;
class FW_Option_Type_SmartSliderChooser extends FW_Option_Type_Select {
protected function _enqueue_static($id, $option, $data) {
HelperTinyMCE::getInstance()
->addForced();
}
public function get_type() {
return 'smartsliderchooser';
}
protected function _render($id, $option, $data) {
$applicationType = ApplicationSmartSlider3::getInstance()
->getApplicationTypeAdmin();
$slidersModel = new ModelSliders($applicationType);
$choices = array();
foreach ($slidersModel->getAll(0, 'published') as $slider) {
if ($slider['type'] == 'group') {
$subChoices = array();
if (!empty($slider['alias'])) {
$subChoices[$slider['alias']] = n2_('Whole group') . ' - ' . $slider['title'] . ' #Alias: ' . $slider['alias'];
}
$subChoices[$slider['id']] = n2_('Whole group') . ' - ' . $slider['title'] . ' #' . $slider['id'];
foreach ($slidersModel->getAll($slider['id'], 'published') as $_slider) {
if (!empty($_slider['alias'])) {
$subChoices[$_slider['alias']] = $_slider['title'] . ' #Alias: ' . $_slider['alias'];
}
$subChoices[$_slider['id']] = $_slider['title'] . ' #' . $_slider['id'];
}
$choices[$slider['id']] = array(
'label' => $slider['title'] . ' #' . $slider['id'],
'choices' => $subChoices
);
} else {
if (!empty($slider['alias'])) {
$choices[$slider['alias']] = $slider['title'] . ' #Alias: ' . $slider['alias'];
}
$choices[$slider['id']] = $slider['title'] . ' #' . $slider['id'];
}
}
$option['choices'] = $choices;
$option['attr']['style'] = 'width:240px;vertical-align: middle';
return Html::tag('div', array(), Html::link(n2_('Select Slider'), '#', array(
'style' => 'vertical-align:middle;',
'class' => 'button button-primary',
'onclick' => "NextendSmartSliderSelectModal(jQuery('#fw-edit-options-modal-id')); return false;"
)) . '<span style="margin: 0 10px;vertical-align:middle;text-transform: uppercase;">' . n2_('OR') . '</span>' . parent::_render($id, $option, $data));
}
protected function _get_value_from_input($option, $input_value) {
if (is_null($input_value)) {
return $option['value'];
}
return (string)$input_value;
}
}
FW_Option_Type::register('FW_Option_Type_SmartSliderChooser');

View File

@ -0,0 +1,11 @@
<?php if (!defined('FW')) {
die('Forbidden');
}
$cfg = array();
$cfg['page_builder'] = array(
'title' => 'Smart Slider',
'description' => 'Adds Smart Slider into the page',
'tab' => __('Media Elements', 'fw'),
);

View File

@ -0,0 +1,11 @@
<?php if (!defined('FW')) {
die('Forbidden');
}
$options = array(
'id' => array(
'label' => 'Slider',
'type' => 'smartsliderchooser',
'value' => ''
),
);

View File

@ -0,0 +1,13 @@
<?php if (!defined('FW')) {
die('Forbidden');
}
/**
* @var array $atts
*/
if (is_numeric($atts['id'])) {
echo do_shortcode('[smartslider3 slider=' . $atts['id'] . ']');
} else {
echo do_shortcode('[smartslider3 alias="' . $atts['id'] . '"]');
}

View File

@ -0,0 +1,128 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\VisualComposer1;
use Nextend\SmartSlider3\Platform\WordPress\HelperTinyMCE;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
use function vc_add_shortcode_param;
use function vc_map;
class VisualComposer1 {
public function __construct() {
add_action('vc_after_set_mode', array(
$this,
'init'
));
}
public function init() {
$this->vc_add_element();
add_action('vc_frontend_editor_render', array(
$this,
'forceShortcodeIframe'
));
add_action('vc_front_load_page_', array(
$this,
'forceShortcodeIframe'
));
add_action('vc_load_shortcode', array(
Shortcode::class,
'shortcodeModeToNormal'
), -1000000);
add_action('vc_load_shortcode', array(
$this,
'forceShortcodeIframe'
));
add_action('vc_before_init_base', array(
$this,
'vc_before_init_base'
));
}
public function vc_before_init_base() {
add_filter('the_excerpt', array(
$this,
'filter_before_the_excerpt'
), -10000);
add_filter('the_excerpt', array(
$this,
'filter_after_the_excerpt'
), 10000);
}
public function filter_before_the_excerpt($output) {
Shortcode::shortcodeModeToNoop();
return $output;
}
public function filter_after_the_excerpt($output) {
Shortcode::shortcodeModeToNormal();
return $output;
}
private function vc_add_element() {
vc_add_shortcode_param('smartslider', array(
$this,
'field_smartslider'
));
vc_map(array(
"name" => "Smart Slider 3",
"base" => "smartslider3",
"category" => __('Content'),
"params" => array(
array(
'type' => 'smartslider',
'heading' => 'Slider ID or Alias',
'param_name' => 'slider',
'save_always' => true,
'description' => 'Select a slider to add it to your post or page.',
'admin_label' => true,
)
)
));
add_action('admin_footer', array(
$this,
'add_admin_icon'
));
}
public function add_admin_icon() {
?>
<style type="text/css">
.wpb_smartslider3 .vc_element-icon {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAYFBMVEUTr+8YnOQPxPkYnOQUsO8PxPkYnOQTr+5hp8Uoncg1kryMwtqh0ePT6PFvude83ers9vlFqc4Vi8EQo9kSls4Xo+j///8XoOcYm+QVp+oQwPcStPARuvQYneUUrewPxPkMc7TJAAAACHRSTlNt9G1uG8vNAnToTbkAAAFrSURBVHgBfZPr0qowDEXrBVB6b0KgUMv7v+UJ2MFy5tOVdIbuvXT0B6Lrumszr38wN1cuRXdv1q80dxa4/2F04srftc7zdtZqSrZeRTOfWc7XRqS5BtAj1E4SdZ3ROHLq5Ig5zem9Gbymjd1JJRXvBz7gLXdaKWXJWb+UQqTC4h3XVjurjEfIqXAICczTP7SUVlsDR8rCkpZ9wQD2ypG1RE++lxULkxYGDBoi+cTnLpR+Ewqoe0cSsnek4EhrwT6IQs7emhBrIZeB4IkMZED+fD5G5A9BE6kA+UQtwJMN5zF+E0YIiohkOAkx5n0jBO8BvSMyWLLtiFhAr0mHiD2RC/HgEMbebT8wxqD/E4a4D0rOETEYIhs4KcPCG9wKaeT2P/pp+CCGcdh2CJLe2B45OVaMhQnDQypp+jCNNeI1HoMYELl+VXMR7esnrbj9Fm6ia6fyPB3zod1e3nb6Sntnoetu7eWv9tLeuPwHrqBewxDhYIoAAAAASUVORK5CYII=);
}
</style>
<?php
}
public function field_smartslider($settings, $value) {
$value = htmlspecialchars($value);
HelperTinyMCE::getInstance()
->addForced();
return '<input name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-textinput ' . $settings['param_name'] . ' ' . $settings['type'] . '" type="text" value="' . $value . '" style="width:100px;vertical-align:middle;">
<a href="#" onclick="NextendSmartSliderSelectModal(jQuery(this).siblings(\'input\')); return false;" class="vc_general vc_ui-button vc_ui-button-default vc_ui-button-shape-rounded vc_ui-button-fw" title="Select slider">Select slider</a>';
}
public function forceShortcodeIframe() {
Shortcode::forceIframe('visualcomposer', true);
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\VisualComposer2;
use Nextend\Framework\Request\Request;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
class VisualComposer2 {
public function __construct() {
if (class_exists('VcvEnv') && Request::$REQUEST->getInt('vcv-ajax')) {
Shortcode::forceIframe('VisualComposer2', true);
}
}
}

View File

@ -0,0 +1,107 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Integration\WPRocket;
use Nextend\Framework\Plugin;
class WPRocket {
public function __construct() {
if (defined('WP_ROCKET_VERSION')) {
$this->init();
if (function_exists('get_rocket_cdn_url') && function_exists("get_rocket_option")) {
if (get_rocket_option('cdn', 0)) {
add_action('init', array(
$this,
'initCDN'
));
}
}
}
}
public function init() {
/**
* @see https://nextendweb.atlassian.net/browse/SSDEV-2335
*/
add_filter('rocket_excluded_inline_js_content', array(
$this,
'remove_rocket_excluded_inline_js_content'
));
/**
* @see https://nextendweb.atlassian.net/browse/SSDEV-2434
*/
add_filter('rocket_defer_inline_exclusions', array(
$this,
'rocket_defer_inline_exclusions'
));
/**
* @see https://nextendweb.atlassian.net/browse/SSDEV-3775
*/
add_filter('rocket_delay_js_exclusions', array(
$this,
'rocket_delay_js_exclusions'
));
}
public function remove_rocket_excluded_inline_js_content($excluded_inline) {
if (($index = array_search('SmartSliderSimple', $excluded_inline)) !== false) {
array_splice($excluded_inline, $index, 1);
}
return $excluded_inline;
}
public function rocket_defer_inline_exclusions($inline_exclusions) {
if (is_string($inline_exclusions)) {
// Only for WP Rocket 3.8.0
if (!empty($inline_exclusions)) {
$inline_exclusions .= '|';
}
$inline_exclusions .= 'N2R';
} else if (is_array($inline_exclusions)) {
/**
* Since WP Rocket 3.8.1 param is an array
*
* @see https://github.com/wp-media/wp-rocket/pull/3424
*/
$inline_exclusions[] = 'N2R';
}
return $inline_exclusions;
}
public function rocket_delay_js_exclusions($exclude_delay_js) {
$exclude_delay_js[] = '(.*)smart-slider(.*).js';
$exclude_delay_js[] = 'new _N2';
$exclude_delay_js[] = 'this._N2';
return $exclude_delay_js;
}
public function initCDN() {
Plugin::addFilter('n2_style_loader_src', array(
$this,
'filterSrcCDN'
));
Plugin::addFilter('n2_script_loader_src', array(
$this,
'filterSrcCDN'
));
}
public function filterSrcCDN($src) {
return get_rocket_cdn_url($src);
}
}

View File

@ -0,0 +1,455 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Shortcode;
use AMP_Options_Manager;
use AMP_Theme_Support;
use AmpProject\AmpWP\Option;
use Nextend\Framework\Asset\Builder\BuilderJs;
use Nextend\Framework\Localization\Localization;
use Nextend\Framework\Request\Request;
use Nextend\Framework\Sanitize;
use Nextend\Framework\View\Html;
use Nextend\SmartSlider3\Application\ApplicationSmartSlider3;
use Nextend\SmartSlider3\Application\Frontend\ApplicationTypeFrontend;
class Shortcode {
private static $cacheSliderOutput = array();
private static $iframe = false;
private static $iframeReason = '';
private static $disablePointer = false;
private static $shortcodeMode = 'shortcode';
public function __construct() {
self::addShortCode();
if (defined('DOING_AJAX') && DOING_AJAX) {
if (isset($_POST['action']) && ($_POST['action'] == 'stpb_preview_builder_item' || $_POST['action'] == 'stpb_load_builder_templates' || $_POST['action'] == 'stpb_load_template')) {
self::shortcodeModeToSkip();
}
}
/**
* There should not be sliders in the head
*/
add_action('wp_head', array(
self::class,
'headStart'
), -10000);
add_action('wp_head', array(
self::class,
'headEnd'
), 10000);
/**
* Thrive theme fix
*/
add_action('before_theme_builder_template_render', array(
self::class,
'headEnd'
));
add_action('woocommerce_shop_loop', array(
self::class,
'shortcodeModeToNoop'
), 9);
add_action('woocommerce_shop_loop', array(
self::class,
'shortcodeModeToNormal'
), 11);
add_action('woocommerce_single_product_summary', array(
self::class,
'shortcodeModeToNoop'
), 59);
add_action('woocommerce_single_product_summary', array(
self::class,
'shortcodeModeToNormal'
), 61);
/**
* Remove Smart Slider from feeds
*/
add_action('do_feed_rdf', array(
self::class,
'shortcodeModeToNoop'
), 0);
add_action('do_feed_rss', array(
self::class,
'shortcodeModeToNoop'
), 0);
add_action('do_feed_rss2', array(
self::class,
'shortcodeModeToNoop'
), 0);
add_action('do_feed_atom', array(
self::class,
'shortcodeModeToNoop'
), 0);
/**
* Remove sliders from the news feed of Yandex.News Feed by Teplitsa
* @url https://wordpress.org/plugins/yandexnews-feed-by-teplitsa/
*/
add_filter('layf_content_feed', function ($content) {
Shortcode::shortcodeModeToNoop();
return $content;
}, 1);
/**
* Sliders are not available over REST API! Fixes Gutenberg save problems.
*/
add_action('rest_api_init', array(
self::class,
'shortcodeModeToNoop'
), 0);
/**
* Sometimes rest api initialized on the frontend, so we have prepare for that
*/
add_action('wp', function () {
remove_action('rest_api_init', array(
self::class,
'shortcodeModeToNoop'
), 0);
});
/**
* Remove sliders from the AMP version of the site
* @url https://wordpress.org/plugins/amp/
*/
add_action('template_redirect', function () {
if (function_exists('amp_is_request') && amp_is_request()) {
add_action('wp_head', array(
self::class,
'shortcodeModeToNoop'
), 10001);
/**
* Fix for reader mode
*/
if (class_exists('AMP_Theme_Support', false) && class_exists('AMP_Options_Manager', false)) {
if (AMP_Options_Manager::get_option(Option::THEME_SUPPORT) === AMP_Theme_Support::READER_MODE_SLUG) {
Shortcode::shortcodeModeToNoop();
}
}
}
});
/**
* Remove sliders from the AMP version of the site
* @url https://wordpress.org/plugins/weeblramp/
*/
add_action('weeblramp_init', array(
self::class,
'shortcodeModeToNoop'
), 0);
/**
* Remove sliders from the Accelerated Mobile Pages version of the site
* @url https://wordpress.org/plugins/accelerated-mobile-pages/
* The other AMP plugin has a deprecated message for the "pre_amp_render_post" action, so we need to hook this function only for Accelerated Mobile Pages plugin.
*/
if (defined('AMPFORWP_VERSION')) {
add_action('pre_amp_render_post', array(
self::class,
'shortcodeModeToNoop'
));
}
add_action('after_setup_theme', function () {
if (function_exists('KTT_share_args_for_posts')) {
/**
* Theme: Narratium
* @url https://themeforest.net/item/narratium-simplicity-for-authors/20844434
*/
add_action('wp', array(
self::class,
'shortcodeModeToNoop'
), 0);
add_action('wp', array(
self::class,
'shortcodeModeToNormal'
), 11);
}
if (class_exists('Themeco\Theme\Theme')) {
/**
* @see SSDEV-3244
*/
remove_action('wp_head', array(
self::class,
'headStart'
), -10000);
}
});
/**
* @see SSDEV-3871
*/
add_filter('render_block_nextend/smartslider3', function ($block_content, $parsed_block) {
if (!empty($parsed_block['attrs']['slider'])) {
if (Request::$GET->getVar('customize_changeset_uuid') !== null) {
return self::renderIframe($parsed_block['attrs']['slider']);
} else {
return self::render(array('slider' => $parsed_block['attrs']['slider']));
}
}
return '';
}, 10, 2);
}
public static function forceIframe($reason, $disablePointer = false) {
self::$iframe = true;
self::$iframeReason = $reason;
self::$disablePointer = $disablePointer;
}
public static function doShortcode($parameters) {
if (self::$shortcodeMode == 'noop') {
return '';
}
if (Request::$isAjax) {
return '';
}
if (!empty($parameters['alias'])) {
$parameters['slider'] = $parameters['alias'];
}
if (isset($parameters['iframe'])) {
self::forceIframe($parameters['iframe']);
}
if (self::$iframe) {
if (isset($parameters['slider'])) {
return self::renderIframe($parameters['slider']);
}
return 'Smart Slider - Please select a slider!';
}
return self::render($parameters);
}
/**
* @param $sliderIDorAlias
*
* @return string contains escaped data
*/
public static function renderIframe($sliderIDorAlias) {
$path = ApplicationTypeFrontend::getAssetsPath() . '/dist/iframe.min.js';
if (file_exists($path)) {
$script = file_get_contents($path);
} else {
}
$attributes = array(
'class' => "n2-ss-slider-frame intrinsic-ignore",
'style' => 'width:100%;max-width:none;display:block;border:0;opacity:0;' . (self::$disablePointer ? 'pointer-events:none;' : ''),
'frameborder' => 0,
'src' => site_url('/') . '?n2prerender=1&n2app=smartslider&n2controller=slider&n2action=iframe&sliderid=' . $sliderIDorAlias . '&iseditor=' . (self::$iframeReason == 'ajax' ? 0 : 1) . '&hash=' . md5($sliderIDorAlias . NONCE_SALT)
);
$html = '';
switch (self::$iframeReason) {
case 'divi':
$attributes['onload'] = str_replace(array(
"\n",
"\r",
"\r\n",
'"',
), array(
"",
"",
"",
"'"
), $script) . 'n2SSIframeLoader(this);';
break;
case 'visualcomposer':
default:
$attributes['onload'] = str_replace(array(
"\n",
"\r",
"\r\n"
), "", $script) . 'n2SSIframeLoader(this);';
break;
}
return $html . '<div class="n2_ss_slider_frame_container">' . Html::tag('iframe', $attributes) . '</div>';
}
public static function render($parameters, $usage = 'WordPress Shortcode') {
$parameters = shortcode_atts(array(
'id' => md5(time()),
'slider' => '',
'logged_in' => null,
'role' => null,
'cap' => null,
'page' => null,
'lang' => null,
'slide' => null,
'get' => null
), $parameters);
if (empty($parameters['slider'])) {
return '';
}
if ($parameters['logged_in'] !== null) {
$logged_in = !!$parameters['logged_in'];
if (is_user_logged_in() !== $logged_in) {
return '';
}
}
if ($parameters['role'] !== null || $parameters['cap'] !== null) {
$current_user = wp_get_current_user();
if ($parameters['role'] !== null) {
$current_user_roles = $current_user->roles;
if (!in_array($parameters['role'], $current_user_roles)) {
return '';
}
}
if ($parameters['cap'] !== null) {
$current_user_caps = $current_user->allcaps;
if (!isset($current_user_caps[$parameters['cap']]) || !$current_user_caps[$parameters['cap']]) {
return '';
}
}
}
if ($parameters['page'] !== null) {
if ($parameters['page'] == 'home') {
$condition = (!is_home() && !is_front_page());
} else {
$condition = ((get_the_ID() != intval($parameters['page'])) || (is_home() || is_front_page()));
}
if ($condition) {
return '';
}
}
if ($parameters['lang'] !== null) {
if ($parameters['lang'] != Localization::getLocale()) {
return '';
}
}
if (!isset(self::$cacheSliderOutput[$parameters['slider']])) {
if ((is_numeric($parameters['slider']) && intval($parameters['slider']) > 0) || !is_numeric($parameters['slider'])) {
ob_start();
$slideTo = false;
if ($parameters['slide'] !== null) {
$slideTo = intval($parameters['slide']);
}
if ($parameters['get'] !== null) {
$slideTo = Request::$GET->getInt($parameters['get']);
}
if ($slideTo && is_numeric($parameters['slider']) && intval($parameters['slider']) > 0) {
echo wp_kses("<script>window['ss" . intval($parameters['slider']) . "'] = " . ($slideTo - 1) . ";</script>", Sanitize::$assetTags);
}
$applicationTypeFrontend = ApplicationSmartSlider3::getInstance()
->getApplicationTypeFrontend();
$applicationTypeFrontend->process('slider', 'display', false, array(
'sliderID' => $parameters['slider'],
'usage' => $usage
));
self::$cacheSliderOutput[$parameters['slider']] = ob_get_clean();
} else {
return '';
}
}
return self::$cacheSliderOutput[$parameters['slider']];
}
public static function changeShortcodeMode($mode) {
if (self::$shortcodeMode != $mode) {
self::$shortcodeMode = $mode;
}
}
public static function shortcodeModeToNormal() {
self::changeShortcodeMode('shortcode');
}
public static function shortcodeModeToNoop() {
self::changeShortcodeMode('noop');
}
public static function shortcodeModeToSkip() {
self::removeShortcode();
}
public static function shortcodeModeRestore() {
self::addShortCode();
}
public static function addShortCode() {
add_shortcode('smartslider3', array(
self::class,
'doShortcode'
));
}
private static function removeShortcode() {
remove_shortcode('smartslider3');
}
public static function headStart() {
self::shortcodeModeToNoop();
add_action('wp_enqueue_scripts', array(
self::class,
'shortcodeModeToNormal'
), -1000000);
add_action('wp_enqueue_scripts', array(
self::class,
'shortcodeModeToNoop'
), 1000000);
}
public static function headEnd() {
remove_action('wp_enqueue_scripts', array(
self::class,
'shortcodeModeToNormal'
), -1000000);
remove_action('wp_enqueue_scripts', array(
self::class,
'shortcodeModeToNoop'
), 1000000);
self::shortcodeModeToNormal();
}
}

View File

@ -0,0 +1,151 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress;
use Nextend\Framework\Asset\Predefined;
use Nextend\Framework\Sanitize;
use Nextend\Framework\WordPress\AssetInjector;
use Nextend\SmartSlider3\Application\ApplicationSmartSlider3;
use Nextend\SmartSlider3\Platform\AbstractSmartSlider3Platform;
use Nextend\SmartSlider3\Platform\WordPress\Admin\AdminHelper;
use Nextend\SmartSlider3\Platform\WordPress\Admin\Pro\WordPressUpdate;
use Nextend\SmartSlider3\Platform\WordPress\Integration\ACF\ACF;
use Nextend\SmartSlider3\Platform\WordPress\Integration\BeaverBuilder\BeaverBuilder;
use Nextend\SmartSlider3\Platform\WordPress\Integration\BoldGrid\BoldGrid;
use Nextend\SmartSlider3\Platform\WordPress\Integration\Brizy\Brizy;
use Nextend\SmartSlider3\Platform\WordPress\Integration\Divi\Divi;
use Nextend\SmartSlider3\Platform\WordPress\Integration\Elementor\Elementor;
use Nextend\SmartSlider3\Platform\WordPress\Integration\Fusion\Fusion;
use Nextend\SmartSlider3\Platform\WordPress\Integration\Gutenberg\Gutenberg;
use Nextend\SmartSlider3\Platform\WordPress\Integration\Jetpack\Jetpack;
use Nextend\SmartSlider3\Platform\WordPress\Integration\MotoPressCE\MotoPressCE;
use Nextend\SmartSlider3\Platform\WordPress\Integration\NimbleBuilder\NimbleBuilder;
use Nextend\SmartSlider3\Platform\WordPress\Integration\OxygenBuilder\OxygenBuilder;
use Nextend\SmartSlider3\Platform\WordPress\Integration\RankMath\RankMath;
use Nextend\SmartSlider3\Platform\WordPress\Integration\TablePress\TablePress;
use Nextend\SmartSlider3\Platform\WordPress\Integration\TatsuBuilder\TatsuBuilder;
use Nextend\SmartSlider3\Platform\WordPress\Integration\ThemifyBuilder\ThemifyBuilder;
use Nextend\SmartSlider3\Platform\WordPress\Integration\Unyson\Unyson;
use Nextend\SmartSlider3\Platform\WordPress\Integration\VisualComposer1\VisualComposer1;
use Nextend\SmartSlider3\Platform\WordPress\Integration\VisualComposer2\VisualComposer2;
use Nextend\SmartSlider3\Platform\WordPress\Integration\WPRocket\WPRocket;
use Nextend\SmartSlider3\Platform\WordPress\Shortcode\Shortcode;
use Nextend\SmartSlider3\Platform\WordPress\Widget\WidgetHelper;
use Nextend\SmartSlider3\PublicApi\Project;
class SmartSlider3PlatformWordPress extends AbstractSmartSlider3Platform {
public function start() {
require_once dirname(__FILE__) . '/compat.php';
$helperInstall = new HelperInstall();
$helperInstall->installOrUpgrade();
new WidgetHelper();
new Shortcode();
new AdminHelper();
add_action('admin_head', function () {
if (wp_script_is('gutenberg-smartslider3')) {
Predefined::frontend();
Predefined::backend();
ApplicationSmartSlider3::getInstance()
->getApplicationTypeAdmin()
->enqueueAssets();
}
});
new WordPressFrontend();
AssetInjector::getInstance();
$this->integrate();
$this->initSanitize();
}
public function getAdminUrl() {
return admin_url("admin.php?page=" . NEXTEND_SMARTSLIDER_3_URL_PATH);
}
public function getAdminAjaxUrl() {
return add_query_arg(array('action' => NEXTEND_SMARTSLIDER_3_URL_PATH), admin_url('admin-ajax.php'));
}
public function getNetworkAdminUrl() {
return network_admin_url("admin.php?page=" . NEXTEND_SMARTSLIDER_3_URL_PATH);
}
private function integrate() {
new Compatibility();
new TablePress();
new Gutenberg();
HelperTinyMCE::getInstance();
/**
* Advanced Custom Fields
*/
new ACF();
new Divi();
new VisualComposer1();
new VisualComposer2();
new Elementor();
new MotoPressCE();
new BeaverBuilder();
new Jetpack();
new Fusion();
new WPRocket();
new Unyson();
new OxygenBuilder();
new NimbleBuilder();
new Brizy();
new BoldGrid();
new RankMath();
new ThemifyBuilder();
new TatsuBuilder();
}
private function initSanitize() {
Sanitize::set_allowed_tags();
}
/**
* @param $file
*
* @return bool|int
*
* @deprecated
*/
public static function importSlider($file) {
return Project::import($file);
}
}

View File

@ -0,0 +1,75 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Widget;
use Nextend\SmartSlider3\Settings;
class WidgetHelper {
public function __construct() {
add_action('widgets_init', array(
$this,
'widgets_init'
), 11);
/**
* As fallback for the Classic Widgets
*/
if ($this->isOldEditor()) {
add_action('widgets_admin_page', array(
$this,
'widgets_admin_page'
));
}
}
public function widgets_init() {
/**
* Fix for Siteorigin and other plugins. They stored the class name...
*/
class_alias(WidgetSmartSlider3::class, 'N2SS3Widget');
register_widget('N2SS3Widget');
$widgetAreas = intval(Settings::get('wordpress-widget-areas', 1));
if ($widgetAreas > 0) {
for ($i = 1; $i <= $widgetAreas; $i++) {
$description = (!$this->isOldEditor()) ? 'Display this widget area in your theme: <strong>&lt;?php dynamic_sidebar( \'smartslider_area_' . $i . '\' ); ?&gt; </strong>' : '';
register_sidebar(array(
'name' => 'Custom Widget Area - #' . $i,
'description' => $description,
'id' => 'smartslider_area_' . $i,
'before_widget' => '',
'after_widget' => '',
'before_title' => '<div style="display:none;">',
'after_title' => '</div>',
));
}
}
}
public function widgets_admin_page() {
add_action('dynamic_sidebar_before', array(
$this,
'dynamic_sidebar_before'
));
}
public function dynamic_sidebar_before($index) {
if (substr($index, 0, strlen('smartslider_area_')) === 'smartslider_area_') {
echo '<div class="description">Display this widget area in your theme with: <pre style="white-space: pre-wrap;overflow:hidden;">&lt;?php dynamic_sidebar(\'' . esc_html($index) . '\'); ?&gt;</pre></div>';
}
}
private function isOldEditor() {
$blockEditor = function_exists('wp_use_widgets_block_editor');
return !$blockEditor || ($blockEditor && !wp_use_widgets_block_editor());
}
}

View File

@ -0,0 +1,207 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress\Widget;
use Nextend\Framework\Sanitize;
use Nextend\SmartSlider3\Application\ApplicationSmartSlider3;
use Nextend\SmartSlider3\Application\Model\ModelSliders;
use Nextend\SmartSlider3\Platform\WordPress\HelperTinyMCE;
use WP_Widget;
class WidgetSmartSlider3 extends WP_Widget {
private $preventRender = false;
function __construct() {
parent::__construct('smartslider3', 'Smart Slider', array(
'show_instance_in_rest' => true,
'description' => 'Displays a Smart Slider'
));
add_filter('widget_types_to_hide_from_legacy_widget_block', function ($widget_types) {
$widget_types[] = 'smartslider3';
return $widget_types;
});
// YOAST SEO fix
add_action('wpseo_head', array(
$this,
'preventRender'
), 0);
add_action('wpseo_head', array(
$this,
'notPreventRender'
), 10000000000);
}
public function preventRender() {
$this->preventRender = true;
}
public function notPreventRender() {
$this->preventRender = false;
}
function widget($args, $instance) {
global $wpdb;
if ($this->preventRender) {
return;
}
$instance = array_merge(array(
'id' => md5(time()),
'slider' => 0,
'title' => ''
), $instance);
if ($instance['slider'] === 0) {
$instance['slider'] = $wpdb->get_var('SELECT id FROM ' . $wpdb->prefix . 'nextend2_smartslider3_sliders WHERE slider_status = \'published\' LIMIT 0,1');
}
$slider = do_shortcode('[smartslider3 slider=' . $instance['slider'] . ']');
if ($slider != '') {
$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
echo wp_kses($args['before_widget'], Sanitize::$basicTags);
if (!empty($title)) echo wp_kses($args['before_title'] . $title . $args['after_title'], Sanitize::$basicTags);
// PHPCS - Content already escaped
echo $slider; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo wp_kses($args['after_widget'], Sanitize::$basicTags);
}
}
function form($instance) {
$instance = wp_parse_args((array)$instance, array(
'title' => '',
'slider' => 0
));
$title = $instance['title'];
HelperTinyMCE::getInstance()
->addForced();
?>
<p>
<?php
$applicationType = ApplicationSmartSlider3::getInstance()
->getApplicationTypeAdmin();
$slidersModel = new ModelSliders($applicationType);
$choices = array();
foreach ($slidersModel->getAll(0, 'published') as $slider) {
if ($slider['type'] == 'group') {
$subChoices = array();
if (!empty($slider['alias'])) {
$subChoices[$slider['alias']] = n2_('Whole group') . ' - ' . $slider['title'] . ' #Alias: ' . $slider['alias'];
}
$subChoices[$slider['id']] = n2_('Whole group') . ' - ' . $slider['title'] . ' #' . $slider['id'];
foreach ($slidersModel->getAll($slider['id'], 'published') as $_slider) {
if (!empty($_slider['alias'])) {
$subChoices[$_slider['alias']] = $_slider['title'] . ' #Alias: ' . $_slider['alias'];
}
$subChoices[$_slider['id']] = $_slider['title'] . ' #' . $_slider['id'];
}
$choices[$slider['id']] = array(
'label' => $slider['title'] . ' #' . $slider['id'],
'choices' => $subChoices
);
} else {
if (!empty($slider['alias'])) {
$choices[$slider['alias']] = $slider['title'] . ' #Alias: ' . $slider['alias'];
}
$choices[$slider['id']] = $slider['title'] . ' #' . $slider['id'];
}
}
$value = $instance['slider'];
$_title = '';
$sliderSelectID = esc_attr($this->get_field_id('slider'));
?>
<select id="<?php echo $sliderSelectID ?>" name="<?php echo esc_attr($this->get_field_name('slider')); ?>" class="widefat">
<?php if (empty($choices)): ?>
<option value=""><?php n2_e('None'); ?></option>
<?php else: ?>
<?php
if ($instance['slider'] === 0) {
global $wpdb;
$value = $wpdb->get_var('SELECT id FROM ' . $wpdb->prefix . 'nextend2_smartslider3_sliders WHERE slider_status = \'published\' LIMIT 0,1');
}
foreach ($choices as $id => $choice) {
if (is_array($choice)) {
?>
<optgroup label="<?php echo esc_attr($choice['label']); ?>">
<?php
foreach ($choice['choices'] as $_id => $_choice) {
?>
<option <?php if ($_id == $value){
$_title = $_choice; ?>selected <?php } ?>value="<?php echo esc_attr($_id); ?>"><?php echo esc_html($_choice); ?></option>
<?php
}
?>
</optgroup>
<?php
} else {
?>
<option <?php if ($id == $value){
$_title = $choice; ?>selected <?php } ?>value="<?php echo esc_attr($id); ?>"><?php echo esc_html($choice); ?></option>
<?php
}
}
?>
<?php endif; ?>
</select>
<?php
$sliderTempTitleID = esc_attr($this->get_field_id('temp-title'));
$sliderTempTitleName = esc_attr($this->get_field_name('temp-title'));
?>
<input id="<?php echo $sliderTempTitleID; ?>"
name="<?php echo $sliderTempTitleName; ?>" type="hidden"
value="<?php echo esc_attr($_title); ?>">
<script>
const ss3SliderSelectElement = document.getElementById("<?php echo $sliderSelectID ?>");
const ss3SliderTempTitleElement = document.getElementById("<?php echo $sliderTempTitleID; ?>");
if (ss3SliderSelectElement && ss3SliderTempTitleElement) {
ss3SliderSelectElement.addEventListener('change', (e) => {
ss3SliderTempTitleElement.value = ss3SliderSelectElement.options[ss3SliderSelectElement.selectedIndex].text;
});
}
</script>
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>">
Title:
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>"
name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text"
value="<?php echo esc_attr($title); ?>">
</label>
</p>
<?php
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = $new_instance['title'];
$instance['temp-title'] = $new_instance['temp-title'];
$instance['slider'] = $new_instance['slider'];
return $instance;
}
}

View File

@ -0,0 +1,52 @@
<?php
namespace Nextend\SmartSlider3\Platform\WordPress;
use Exception;
use Nextend\Framework\PageFlow;
use Nextend\Framework\Request\Request;
use Nextend\SmartSlider3\Application\ApplicationSmartSlider3;
class WordPressFrontend {
public function __construct() {
add_action('init', array(
$this,
'preRender'
), 1000000);
}
public function preRender() {
if (Request::$GET->getInt('n2prerender') && Request::$GET->getCmd('n2app') !== '') {
if (current_user_can('smartslider') || current_user_can('edit_posts') || current_user_can('edit_pages') || (Request::$GET->getCmd('h') === sha1(NONCE_SALT . date('Y-m-d') || Request::$GET->getCmd('h') === sha1(NONCE_SALT . date('Y-m-d', time() - 60 * 60 * 24))))) {
try {
$application = ApplicationSmartSlider3::getInstance();
$applicationType = $application->getApplicationTypeFrontend();
$applicationType->process('PreRender' . Request::$GET->getCmd('n2controller'), Request::$GET->getCmd('n2action'));
PageFlow::exitApplication();
} catch (Exception $e) {
exit;
}
} else if (Request::$GET->getInt('sliderid') !== 0 && Request::$GET->getCmd('hash') !== null && md5(Request::$GET->getInt('sliderid') . NONCE_SALT) == Request::$GET->getCmd('hash')) {
try {
$application = ApplicationSmartSlider3::getInstance();
$applicationType = $application->getApplicationTypeFrontend();
$applicationType->process('PreRenderSlider', 'iframe');
PageFlow::exitApplication();
} catch (Exception $e) {
exit;
}
}
}
}
}

View File

@ -0,0 +1,15 @@
<?php
use Nextend\SmartSlider3\Platform\WordPress\SmartSlider3PlatformWordPress;
if (!class_exists('SmartSlider3', false)) {
class SmartSlider3 {
public static function import($file) {
return SmartSlider3PlatformWordPress::importSlider($file);
}
}
}