module) { return false; } $opts = []; $table = _DB_PREFIX_ . 'layerslider'; $sliders = \Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( "SELECT `id`, `name` FROM `$table` WHERE `flag_hidden` = 0 AND `flag_deleted` = 0 LIMIT 100" ); if (!empty($sliders)) { foreach ($sliders as &$slider) { $name = empty($slider['name']) ? 'Unnamed' : $slider['name']; $opts[$slider['id']] = "#{$slider['id']} - $name"; } } return $opts; } /** * Register Creative Slider widget controls. * * Adds different input fields to allow the user to change and customize the widget settings. * * @since 1.0.0 * @access protected */ protected function _registerControls() { $this->startControlsSection( 'section_layerslider', [ 'label' => __('Creative Slider'), ] ); if ($this->module) { $this->addControl( 'ls-new', [ 'type' => ControlsManager::BUTTON, 'text' => ' ' . __('Create New Slider'), 'label_block' => true, 'description' => __('or'), ] ); $this->addControl( 'slider', [ 'classes' => 'ls-selector', 'label' => __('Slider'), 'type' => ControlsManager::SELECT2, 'select2options' => [ 'placeholder' => __('Select...'), ], 'options' => $this->getSliderOptions(), 'separator' => 'before', ] ); $this->addControl( 'ls-edit', [ 'type' => ControlsManager::BUTTON, 'text' => ' ' . __('Edit Slider'), 'condition' => [ 'slider!' => '0', ], ] ); } else { $this->addControl( 'ls-alert', [ 'raw' => $this->getAlert(), 'type' => ControlsManager::RAW_HTML, ] ); $this->addControl( 'ls-promo', [ 'raw' => $this->getPromo(), 'type' => ControlsManager::RAW_HTML, ] ); $this->addControl('slider', ['type' => ControlsManager::HIDDEN]); } $this->endControlsSection(); } /** * Render Creative Slider widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @since 1.0.0 * @access protected */ protected function render() { if (!$this->module) { return; } $id = (int) $this->getSettings('slider'); if (!empty($id)) { $slider = $this->module->generateSlider($id); if (\Tools::getValue('render') === 'widget') { $this->patchInitScript($slider, $id); } echo $slider; } } protected function patchInitScript(&$slider, $id) { $suffix = '_' . time(); $slider = str_replace("layerslider_$id", "layerslider_$id$suffix", $slider); ob_start(); ?> module) { return; } echo "<\x69frame src=\"https://creativeslider.webshopworks.com/promo-slider.html\" " . "style=\"width: 100%; height: 66vh; border: none;\">"; } protected function getAlert() { return '

Do you need an awesome slider?

Creative Slider is the perfect choice for you. With this widget you can easily place Creative Slider anywhere.

'; } protected function getPromo() { ob_start(); $iso = get_locale(); $more = "https://addons.prestashop.com/$iso/sliders-galleries/19062-creative-slider-responsive-slideshow.html"; $demo = 'https://addons.prestashop.com/demo/FO11013.html'; ?> active)) { $this->module = $ls; $context = \Context::getContext(); empty($context->employee) or Helper::$body_scripts['ce-layerslider'] = [ 'hndl' => 'ce-layerslider', 'l10n' => [ 'ls' => [ 'url' => $context->link->getAdminLink('AdminLayerSlider'), 'NameYourSlider' => __('Name your new slider'), 'ChangesYouMadeMayNotBeSaved' => __('Changes you made may not be saved, are you sure you want to close?'), ], ], ]; if (is_admin()) { wp_enqueue_style('jquery-fancybox', _PS_JS_DIR_ . 'jquery/plugins/fancybox/jquery.fancybox.css'); wp_enqueue_script('jquery-fancybox', _PS_JS_DIR_ . 'jquery/plugins/fancybox/jquery.fancybox.js', ['jquery'], false, true); } } parent::__construct($data, $args); } }