first commit

This commit is contained in:
2024-10-28 22:14:22 +01:00
commit b65352c452
40581 changed files with 5712079 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php
/**
* 2007-2022 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2022 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,457 @@
<?php
/**
* 2007-2022 Apollotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Apollotheme <apollotheme@gmail.com>
* @copyright 2007-2022 Apollotheme
* @license http://apollotheme.com - prestashop template provider
*/
namespace LeoElements\Core\Settings\Base;
use LeoElements\Core\Common\Modules\Ajax\Module as Ajax;
use LeoElements\Core\Files\CSS\Base;
use LeoElements\Plugin;
use LeoElements\Core\Settings\Manager as SettingsManager;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor settings base manager.
*
* Elementor settings base manager handler class is responsible for registering
* and managing Elementor settings base managers.
*
* @since 1.6.0
* @abstract
*/
abstract class Manager {
/**
* Models cache.
*
* Holds all the models.
*
* @since 1.6.0
* @access private
*
* @var Model[]
*/
private $models_cache = [];
/**
* Settings base manager constructor.
*
* Initializing Elementor settings base manager.
*
* @since 1.6.0
* @access public
*/
public function __construct() {
Leo_Helper::add_action( 'elementor/editor/init', [ $this, 'on_elementor_editor_init' ] );
Leo_Helper::add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] );
$name = $this->get_css_file_name();
Leo_Helper::add_action( "elementor/css-file/{$name}/parse", [ $this, 'add_settings_css_rules' ] );
Leo_Helper::add_action( 'elementor/css-file/post/parse', [ $this, 'add_page_settings_css' ] );
}
/**
* Register ajax actions.
*
* Add new actions to handle data after an ajax requests returned.
*
* Fired by `elementor/ajax/register_actions` action.
*
* @since 2.0.0
* @access public
*
* @param Ajax $ajax_manager
*/
public function register_ajax_actions( $ajax_manager ) {
$name = $this->get_name();
$ajax_manager->register_ajax_action( "save_{$name}_settings", [ $this, 'ajax_save_settings' ] );
}
/**
* Get model for config.
*
* Retrieve the model for settings configuration.
*
* @since 1.6.0
* @access public
* @abstract
*
* @return Model The model object.
*/
abstract public function get_model_for_config();
/**
* Get manager name.
*
* Retrieve settings manager name.
*
* @since 1.6.0
* @access public
* @abstract
*/
abstract public function get_name();
/**
* Get model.
*
* Retrieve the model for any given model ID.
*
* @since 1.6.0
* @access public
*
* @param int $id Optional. Model ID. Default is `0`.
*
* @return Model The model.
*/
final public function get_model( $id = 0 ) {
if ( ! isset( $this->models_cache[ $id ] ) ) {
$this->create_model( $id );
}
return $this->models_cache[ $id ];
}
/**
* Ajax request to save settings.
*
* Save settings using an ajax request.
*
* @since 1.6.0
* @access public
*
* @param array $request Ajax request.
*
* @return array Ajax response data.
*/
final public function ajax_save_settings( $request ) {
$data = $request['data'];
$id = 0;
if ( ! empty( $request['id'] ) ) {
$id = $request['id'];
}
//$this->ajax_before_save_settings( $data, $id ); ///xxxxx
$this->save_settings( $data, $id );
$settings_name = $this->get_name();
$success_response_data = [];
/**
* Settings success response data.
*
* Filters the success response data when saving settings using ajax.
*
* The dynamic portion of the hook name, `$settings_name`, refers to the settings name.
*
* @since 1.6.0
* @deprecated 2.0.0 Use `elementor/settings/{$settings_name}/success_response_data` filter.
*
* @param array $success_response_data Success response data.
* @param int $id Settings ID.
* @param array $data Settings data.
*/
///$success_response_data = apply_filters_deprecated( "elementor/{$settings_name}/settings/success_response_data", [ $success_response_data, $id, $data ], '2.0.0', "elementor/settings/{$settings_name}/success_response_data" );
/**
* Settings success response data.
*
* Filters the success response data when saving settings using ajax.
*
* The dynamic portion of the hook name, `$settings_name`, refers to the settings name.
*
* @since 2.0.0
*
* @param array $success_response_data Success response data.
* @param int $id Settings ID.
* @param array $data Settings data.
*/
$success_response_data = Leo_Helper::apply_filters( "elementor/settings/{$settings_name}/success_response_data", $success_response_data, $id, $data );
return $success_response_data;
}
/**
* Save settings.
*
* Save settings to the database and update the CSS file.
*
* @since 1.6.0
* @access public
*
* @param array $settings Settings.
* @param int $id Optional. Post ID. Default is `0`.
*/
final public function save_settings( array $settings, $id = 0 ) {
$special_settings = $this->get_special_settings_names();
$settings_to_save = $settings;
foreach ( $special_settings as $special_setting ) {
if ( isset( $settings_to_save[ $special_setting ] ) ) {
unset( $settings_to_save[ $special_setting ] );
}
}
$this->save_settings_to_db( $settings_to_save, $id );
// Clear cache after save.
if ( isset( $this->models_cache[ $id ] ) ) {
unset( $this->models_cache[ $id ] );
}
$css_file = $this->get_css_file_for_update( $id );
if ( $css_file ) {
$css_file->update();
}
}
/**
* Add settings CSS rules.
*
* Add new CSS rules to the settings manager.
*
* Fired by `elementor/css-file/{$name}/parse` action.
*
* @since 1.6.0
* @access public
*
* @param Base $css_file The requested CSS file.
*/
public function add_settings_css_rules( Base $css_file ) {
$model = $this->get_model_for_css_file( $css_file );
$css_file->add_controls_stack_style_rules(
$model,
$model->get_style_controls(),
$model->get_settings(),
[ '{{WRAPPER}}' ],
[ $model->get_css_wrapper_selector() ]
);
}
/**
* @param $post_css Post
*/
public function add_page_settings_css( $post_css ) {
$document = Plugin::$instance->documents->get( $post_css->get_post_id() );
$settings = SettingsManager::get_settings_managers( 'page' )->get_model( $post_css->get_post_id() )->get_data( 'settings' );
if( !isset( $settings['custom_css'] ) ){
return;
}
$custom_css = trim( $settings['custom_css'] );
if ( empty( $custom_css ) ) {
return;
}
$custom_css = str_replace( 'selector', $document->get_css_wrapper_selector(), $custom_css );
// Add a css comment
$custom_css = '/* Start custom CSS */' . $custom_css . '/* End custom CSS */';
$post_css->get_stylesheet()->add_raw_css( $custom_css );
}
/**
* On Elementor init.
*
* Add editor template for the settings
*
* Fired by `elementor/init` action.
*
* @since 1.0.0
* @access public
*/
public function on_elementor_editor_init() {
Plugin::$instance->common->add_template( $this->get_editor_template(), 'text' );
}
/**
* Get saved settings.
*
* Retrieve the saved settings from the database.
*
* @since 1.6.0
* @access protected
* @abstract
*
* @param int $id Post ID.
*/
abstract protected function get_saved_settings( $id );
/**
* Get CSS file name.
*
* Retrieve CSS file name for the settings base manager.
*
* @since 1.6.0
* @access protected
* @abstract
*/
abstract protected function get_css_file_name();
/**
* Save settings to DB.
*
* Save settings to the database.
*
* @since 1.6.0
* @access protected
* @abstract
*
* @param array $settings Settings.
* @param int $id Post ID.
*/
abstract protected function save_settings_to_db( array $settings, $id );
/**
* Get model for CSS file.
*
* Retrieve the model for the CSS file.
*
* @since 1.6.0
* @access protected
* @abstract
*
* @param Base $css_file The requested CSS file.
*/
abstract protected function get_model_for_css_file( Base $css_file );
/**
* Get CSS file for update.
*
* Retrieve the CSS file before updating it.
*
* @since 1.6.0
* @access protected
* @abstract
*
* @param int $id Post ID.
*/
abstract protected function get_css_file_for_update( $id );
/**
* Get special settings names.
*
* Retrieve the names of the special settings that are not saved as regular
* settings. Those settings have a separate saving process.
*
* @since 1.6.0
* @access protected
*
* @return array Special settings names.
*/
protected function get_special_settings_names() {
return [];
}
/**
* Ajax before saving settings.
*
* Validate the data before saving it and updating the data in the database.
*
* @since 1.6.0
* @access public
*
* @param array $data Post data.
* @param int $id Post ID.
*/
public function ajax_before_save_settings( array $data, $id ) {}
/**
* Print the setting template content in the editor.
*
* Used to generate the control HTML in the editor using Underscore JS
* template. The variables for the class are available using `data` JS
* object.
*
* @since 1.6.0
* @access protected
*
* @param string $name Settings panel name.
*/
protected function print_editor_template_content( $name ) {
?>
<div class="elementor-panel-navigation">
<# _.each( elementor.config.settings.<?php echo Leo_Helper::esc_html( $name ); ?>.tabs, function( tabTitle, tabSlug ) { #>
<div class="elementor-panel-navigation-tab elementor-tab-control-{{ tabSlug }}" data-tab="{{ tabSlug }}">
<a href="#">{{{ tabTitle }}}</a>
</div>
<# } ); #>
</div>
<div id="elementor-panel-<?php echo Leo_Helper::esc_attr( $name ); ?>-settings-controls"></div>
<?php
}
/**
* Create model.
*
* Create a new model object for any given model ID and store the object in
* models cache property for later use.
*
* @since 1.6.0
* @access private
*
* @param int $id Model ID.
*/
private function create_model( $id ) {
$class_parts = explode( '\\', get_called_class() );
array_splice( $class_parts, count( $class_parts ) - 1, 1, 'Model' );
$class_name = implode( '\\', $class_parts );
$this->models_cache[ $id ] = new $class_name( [
'id' => $id,
'settings' => $this->get_saved_settings( $id ),
] );
}
/**
* Get editor template.
*
* Retrieve the final HTML for the editor.
*
* @since 1.6.0
* @access private
*
* @return string Settings editor template.
*/
private function get_editor_template() {
$name = $this->get_name();
ob_start();
?>
<script type="text/template" id="tmpl-elementor-panel-<?php echo Leo_Helper::esc_attr( $name ); ?>-settings">
<?php $this->print_editor_template_content( $name ); ?>
</script>
<?php
return ob_get_clean();
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* 2007-2022 Apollotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Apollotheme <apollotheme@gmail.com>
* @copyright 2007-2022 Apollotheme
* @license http://apollotheme.com - prestashop template provider
*/
namespace LeoElements\Core\Settings\Base;
use LeoElements\Controls_Stack;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor settings base model.
*
* Elementor settings base model handler class is responsible for registering
* and managing Elementor settings base models.
*
* @since 1.6.0
* @abstract
*/
abstract class Model extends Controls_Stack {
/**
* Get CSS wrapper selector.
*
* Retrieve the wrapper selector for the current panel.
*
* @since 1.6.0
* @access public
* @abstract
*/
abstract public function get_css_wrapper_selector();
/**
* Get panel page settings.
*
* Retrieve the page setting for the current panel.
*
* @since 1.6.0
* @access public
* @abstract
*/
abstract public function get_panel_page_settings();
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* 2007-2022 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2022 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,225 @@
<?php
/**
* 2007-2022 Apollotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Apollotheme <apollotheme@gmail.com>
* @copyright 2007-2022 Apollotheme
* @license http://apollotheme.com - prestashop template provider
*/
namespace LeoElements\Core\Settings\General;
use LeoElements\Controls_Manager;
use LeoElements\Core\Files\CSS\Base;
use LeoElements\Core\Files\CSS\Global_CSS;
use LeoElements\Core\Settings\Base\Manager as BaseManager;
use LeoElements\Core\Settings\Base\Model as BaseModel;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor general settings manager.
*
* Elementor general settings manager handler class is responsible for registering
* and managing Elementor general settings managers.
*
* @since 1.6.0
*/
class Manager extends BaseManager {
/**
* Lightbox panel tab.
*/
const PANEL_TAB_LIGHTBOX = 'lightbox';
/**
* Meta key for the general settings.
*/
const META_KEY = '_elementor_general_settings';
/**
* General settings manager constructor.
*
* Initializing Elementor general settings manager.
*
* @since 1.6.0
* @access public
*/
public function __construct() {
parent::__construct();
$this->add_panel_tabs();
}
/**
* Get manager name.
*
* Retrieve general settings manager name.
*
* @since 1.6.0
* @access public
*
* @return string Manager name.
*/
public function get_name() {
return 'general';
}
/**
* Get model for config.
*
* Retrieve the model for settings configuration.
*
* @since 1.6.0
* @access public
*
* @return BaseModel The model object.
*/
public function get_model_for_config() {
return $this->get_model();
}
/**
* Get saved settings.
*
* Retrieve the saved settings from the site options.
*
* @since 1.6.0
* @access protected
*
* @param int $id Post ID.
*
* @return array Saved settings.
*/
protected function get_saved_settings( $id ) {
$model_controls = Model::get_controls_list();
$settings = [];
foreach ( $model_controls as $tab_name => $sections ) {
foreach ( $sections as $section_name => $section_data ) {
foreach ( $section_data['controls'] as $control_name => $control_data ) {
$saved_setting = Leo_Helper::get_option( $control_name, null );
if ( null !== $saved_setting ) {
$settings[ $control_name ] = Leo_Helper::get_option( $control_name );
}
}
}
}
return $settings;
}
/**
* Get CSS file name.
*
* Retrieve CSS file name for the general settings manager.
*
* @since 1.6.0
* @access protected
* @return string
*
* @return string CSS file name.
*/
protected function get_css_file_name() {
return 'global';
}
/**
* Save settings to DB.
*
* Save general settings to the database, as site options.
*
* @since 1.6.0
* @access protected
*
* @param array $settings Settings.
* @param int $id Post ID.
*/
protected function save_settings_to_db( array $settings, $id ) {
$model_controls = Model::get_controls_list();
$one_list_settings = [];
foreach ( $model_controls as $tab_name => $sections ) {
foreach ( $sections as $section_name => $section_data ) {
foreach ( $section_data['controls'] as $control_name => $control_data ) {
if ( isset( $settings[ $control_name ] ) ) {
$one_list_control_name = str_replace( 'elementor_', '', $control_name );
$one_list_settings[ $one_list_control_name ] = $settings[ $control_name ];
Leo_Helper::update_option( $control_name, $settings[ $control_name ] );
} else {
Leo_Helper::delete_option( $control_name );
}
}
}
}
// Save all settings in one list for a future usage
if ( ! empty( $one_list_settings ) ) {
Leo_Helper::update_option( self::META_KEY, $one_list_settings );
} else {
Leo_Helper::delete_option( self::META_KEY );
}
}
/**
* Get model for CSS file.
*
* Retrieve the model for the CSS file.
*
* @since 1.6.0
* @access protected
*
* @param Base $css_file The requested CSS file.
*
* @return BaseModel The model object.
*/
protected function get_model_for_css_file( Base $css_file ) {
return $this->get_model();
}
/**
* Get CSS file for update.
*
* Retrieve the CSS file before updating the it.
*
* @since 1.6.0
* @access protected
*
* @param int $id Post ID.
*
* @return Global_CSS The global CSS file object.
*/
protected function get_css_file_for_update( $id ) {
return Global_CSS::create( 'global.css' );
}
/**
* Add panel tabs.
*
* Register new panel tab for the lightbox settings.
*
* @since 1.6.0
* @access private
*/
private function add_panel_tabs() {
Controls_Manager::add_tab( self::PANEL_TAB_LIGHTBOX, Leo_Helper::__( 'Lightbox', 'elementor' ) );
}
}

View File

@@ -0,0 +1,225 @@
<?php
/**
* 2007-2022 Apollotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Apollotheme <apollotheme@gmail.com>
* @copyright 2007-2022 Apollotheme
* @license http://apollotheme.com - prestashop template provider
*/
namespace LeoElements\Core\Settings\General;
use LeoElements\Controls_Manager;
use LeoElements\Core\Settings\Base\Model as BaseModel;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor global settings model.
*
* Elementor global settings model handler class is responsible for registering
* and managing Elementor global settings models.
*
* @since 1.6.0
*/
class Model extends BaseModel {
/**
* Get model name.
*
* Retrieve global settings model name.
*
* @since 1.6.0
* @access public
*
* @return string Model name.
*/
public function get_name() {
return 'global-settings';
}
/**
* Get CSS wrapper selector.
*
* Retrieve the wrapper selector for the global settings model.
*
* @since 1.6.0
* @access public
*
* @return string CSS wrapper selector.
*/
public function get_css_wrapper_selector() {
return '';
}
/**
* Get panel page settings.
*
* Retrieve the panel setting for the global settings model.
*
* @since 1.6.0
* @access public
*
* @return array {
* Panel settings.
*
* @type string $title The panel title.
* @type array $menu The panel menu.
* }
*/
public function get_panel_page_settings() {
return [
'title' => Leo_Helper::__( 'Global Settings', 'elementor' ),
'menu' => [
'icon' => 'eicon-cogs',
'beforeItem' => 'elementor-settings',
],
];
}
/**
* Get controls list.
*
* Retrieve the global settings model controls list.
*
* @since 1.6.0
* @access public
* @static
*
* @return array Controls list.
*/
public static function get_controls_list() {
return [
Controls_Manager::TAB_STYLE => [
'style' => [
'label' => Leo_Helper::__( 'Style', 'elementor' ),
'controls' => [
'elementor_default_generic_fonts' => [
'label' => Leo_Helper::__( 'Default Generic Fonts', 'elementor' ),
'type' => Controls_Manager::TEXT,
'default' => 'Sans-serif',
'description' => Leo_Helper::__( 'The list of fonts used if the chosen font is not available.', 'elementor' ),
'label_block' => true,
],
'elementor_container_width' => [
'label' => Leo_Helper::__( 'Content Width', 'elementor' ) . ' (px)',
'type' => Controls_Manager::NUMBER,
'min' => 300,
'description' => Leo_Helper::__( 'Sets the default width of the content area (Default: 1140)', 'elementor' ),
'selectors' => [
'.elementor-section.elementor-section-boxed > .elementor-container' => 'max-width: {{VALUE}}px',
],
],
'elementor_space_between_widgets' => [
'label' => Leo_Helper::__( 'Widgets Space', 'elementor' ) . ' (px)',
'type' => Controls_Manager::NUMBER,
'min' => 0,
'placeholder' => '20',
'description' => Leo_Helper::__( 'Sets the default space between widgets (Default: 20)', 'elementor' ),
'selectors' => [
'.elementor-widget:not(:last-child)' => 'margin-bottom: {{VALUE}}px',
],
],
'elementor_stretched_section_container' => [
'label' => Leo_Helper::__( 'Stretched Section Fit To', 'elementor' ),
'type' => Controls_Manager::TEXT,
'placeholder' => 'body',
'description' => Leo_Helper::__( 'Enter parent element selector to which stretched sections will fit to (e.g. #primary / .wrapper / main etc). Leave blank to fit to page width.', 'elementor' ),
'label_block' => true,
'frontend_available' => true,
],
'elementor_page_title_selector' => [
'label' => Leo_Helper::__( 'Page Title Selector', 'elementor' ),
'type' => Controls_Manager::TEXT,
'placeholder' => 'h1.entry-title',
'description' => Leo_Helper::__( 'LeoElements lets you hide the page title. This works for themes that have "h1.entry-title" selector. If your theme\'s selector is different, please enter it above.', 'elementor' ),
'label_block' => true,
],
],
],
],
Manager::PANEL_TAB_LIGHTBOX => [
'lightbox' => [
'label' => Leo_Helper::__( 'Lightbox', 'elementor' ),
'controls' => [
'elementor_global_image_lightbox' => [
'label' => Leo_Helper::__( 'Image Lightbox', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'description' => Leo_Helper::__( 'Open all image links in a lightbox popup window. The lightbox will automatically work on any link that leads to an image file.', 'elementor' ),
'frontend_available' => true,
],
'elementor_enable_lightbox_in_editor' => [
'label' => Leo_Helper::__( 'Enable In Editor', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'frontend_available' => true,
],
'elementor_lightbox_color' => [
'label' => Leo_Helper::__( 'Background Color', 'elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.elementor-lightbox' => 'background-color: {{VALUE}}',
],
],
'elementor_lightbox_ui_color' => [
'label' => Leo_Helper::__( 'UI Color', 'elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.elementor-lightbox .dialog-lightbox-close-button, .elementor-lightbox .elementor-swiper-button' => 'color: {{VALUE}}',
],
],
'elementor_lightbox_ui_color_hover' => [
'label' => Leo_Helper::__( 'UI Hover Color', 'elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.elementor-lightbox .dialog-lightbox-close-button:hover, .elementor-lightbox .elementor-swiper-button:hover' => 'color: {{VALUE}}',
],
],
],
],
],
];
}
/**
* Register model controls.
*
* Used to add new controls to the global settings model.
*
* @since 1.6.0
* @access protected
*/
protected function _register_controls() {
$controls_list = self::get_controls_list();
foreach ( $controls_list as $tab_name => $sections ) {
foreach ( $sections as $section_name => $section_data ) {
$this->start_controls_section(
$section_name, [
'label' => $section_data['label'],
'tab' => $tab_name,
]
);
foreach ( $section_data['controls'] as $control_name => $control_data ) {
$this->add_control( $control_name, $control_data );
}
$this->end_controls_section();
}
}
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* 2007-2022 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2022 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,199 @@
<?php
/**
* 2007-2022 Apollotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Apollotheme <apollotheme@gmail.com>
* @copyright 2007-2022 Apollotheme
* @license http://apollotheme.com - prestashop template provider
*/
namespace LeoElements\Core\Settings;
use LeoElements\Plugin;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor settings manager.
*
* Elementor settings manager handler class is responsible for registering and
* managing Elementor settings managers.
*
* @since 1.6.0
*/
class Manager {
/**
* Settings managers.
*
* Holds all the registered settings managers.
*
* @since 1.6.0
* @access private
*
* @var Base\Manager[]
*/
private static $settings_managers = [];
/**
* Builtin settings managers names.
*
* Holds the names for builtin Elementor settings managers.
*
* @since 1.6.0
* @access private
*
* @var array
*/
private static $builtin_settings_managers_names = [ 'page', 'general' ];
/**
* Add settings manager.
*
* Register a single settings manager to the registered settings managers.
*
* @since 1.6.0
* @access public
* @static
*
* @param Base\Manager $manager Settings manager.
*/
public static function add_settings_manager( Base\Manager $manager ) {
self::$settings_managers[ $manager->get_name() ] = $manager;
}
/**
* Get settings managers.
*
* Retrieve registered settings manager(s).
*
* If no parameter passed, it will retrieve all the settings managers. For
* any given parameter it will retrieve a single settings manager if one
* exist, or `null` otherwise.
*
* @since 1.6.0
* @access public
* @static
*
* @param string $manager_name Optional. Settings manager name. Default is
* null.
*
* @return Base\Manager|Base\Manager[] Single settings manager, if it exists,
* null if it doesn't exists, or the all
* the settings managers if no parameter
* defined.
*/
public static function get_settings_managers( $manager_name = null ) {
if ( $manager_name ) {
if ( isset( self::$settings_managers[ $manager_name ] ) ) {
return self::$settings_managers[ $manager_name ];
}
return null;
}
return self::$settings_managers;
}
/**
* Register default settings managers.
*
* Register builtin Elementor settings managers.
*
* @since 1.6.0
* @access private
* @static
*/
private static function register_default_settings_managers() {
foreach ( self::$builtin_settings_managers_names as $manager_name ) {
$manager_class = __NAMESPACE__ . '\\' . ucfirst( $manager_name ) . '\Manager';
self::add_settings_manager( new $manager_class() );
}
}
/**
* Get settings managers config.
*
* Retrieve the settings managers configuration.
*
* @since 1.6.0
* @access public
* @static
*
* @return array The settings managers configuration.
*/
public static function get_settings_managers_config() {
$config = [];
$user_can = true;
foreach ( self::$settings_managers as $name => $manager ) {
$settings_model = $manager->get_model_for_config();
$tabs = $settings_model->get_tabs_controls();
if ( ! $user_can ) {
unset( $tabs['style'] );
}
$config[ $name ] = [
'name' => $manager->get_name(),
'panelPage' => $settings_model->get_panel_page_settings(),
'cssWrapperSelector' => $settings_model->get_css_wrapper_selector(),
'controls' => $settings_model->get_controls(),
'tabs' => $tabs,
'settings' => $settings_model->get_settings(),
];
}
return $config;
}
/**
* Get settings frontend config.
*
* Retrieve the settings managers frontend configuration.
*
* @since 1.6.0
* @access public
* @static
*
* @return array The settings managers frontend configuration.
*/
public static function get_settings_frontend_config() {
$config = [];
foreach ( self::$settings_managers as $name => $manager ) {
$settings_model = $manager->get_model_for_config();
if ( $settings_model ) {
$config[ $name ] = $settings_model->get_frontend_settings();
}
}
return $config;
}
/**
* Run settings managers.
*
* Register builtin Elementor settings managers.
*
* @since 1.6.0
* @access public
* @static
*/
public static function run() {
self::register_default_settings_managers();
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* 2007-2022 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2022 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,336 @@
<?php
/**
* 2007-2022 Apollotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Apollotheme <apollotheme@gmail.com>
* @copyright 2007-2022 Apollotheme
* @license http://apollotheme.com - prestashop template provider
*/
namespace LeoElements\Core\Settings\Page;
use LeoElements\Core\Files\CSS\Base;
use LeoElements\Core\Files\CSS\Post;
use LeoElements\Core\Files\CSS\Post_Preview;
use LeoElements\Core\Utils\Exceptions;
use LeoElements\Core\Settings\Manager as SettingsManager;
use LeoElements\Core\Settings\Base\Manager as BaseManager;
use LeoElements\Core\Settings\Base\Model as BaseModel;
use LeoElements\DB;
use LeoElements\Plugin;
use LeoElements\Utils;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor page settings manager.
*
* Elementor page settings manager handler class is responsible for registering
* and managing Elementor page settings managers.
*
* @since 1.6.0
*/
class Manager extends BaseManager {
/**
* Meta key for the page settings.
*/
const META_KEY = '_elementor_page_settings';
/**
* Is CPT supports custom templates.
*
* Whether the Custom Post Type supports templates.
*
* @since 1.6.0
* @deprecated 2.0.0 Use `Utils::is_cpt_custom_templates_supported()` method instead.
* @access public
* @static
*
* @return bool True is templates are supported, False otherwise.
*/
public static function is_cpt_custom_templates_supported() {
_deprecated_function( __METHOD__, '2.0.0', 'Utils::is_cpt_custom_templates_supported()' );
return Utils::is_cpt_custom_templates_supported();
}
/**
* Get manager name.
*
* Retrieve page settings manager name.
*
* @since 1.6.0
* @access public
*
* @return string Manager name.
*/
public function get_name() {
return 'page';
}
/**
* Get model for config.
*
* Retrieve the model for settings configuration.
*
* @since 1.6.0
* @access public
*
* @return BaseModel The model object.
*/
public function get_model_for_config() {
if( !Leo_Helper::$id_post ){
return null;
}
$model = $this->get_model( Leo_Helper::$id_post );
return $model;
}
/**
* Ajax before saving settings.
*
* Validate the data before saving it and updating the data in the database.
*
* @since 1.6.0
* @access public
*
* @param array $data Post data.
* @param int $id Post ID.
*
* @throws \Exception If invalid post returned using the `$id`.
* @throws \Exception If current user don't have permissions to edit the post.
*/
public function ajax_before_save_settings( array $data, $id ) {
$post = get_post( $id );
if ( empty( $post ) ) {
throw new \Exception( 'Invalid post.', Exceptions::NOT_FOUND );
}
if ( ! current_user_can( 'edit_post', $id ) ) {
throw new \Exception( 'Access denied.', Exceptions::FORBIDDEN );
}
// Avoid save empty post title.
if ( ! empty( $data['post_title'] ) ) {
$post->post_title = $data['post_title'];
}
if ( isset( $data['post_excerpt'] ) && post_type_supports( $post->post_type, 'excerpt' ) ) {
$post->post_excerpt = $data['post_excerpt'];
}
if ( isset( $data['post_status'] ) ) {
$this->save_post_status( $id, $data['post_status'] );
unset( $post->post_status );
}
wp_update_post( $post );
// Check updated status
if ( DB::STATUS_PUBLISH === get_post_status( $id ) ) {
$autosave = wp_get_post_autosave( $post->ID );
if ( $autosave ) {
wp_delete_post_revision( $autosave->ID );
}
}
if ( isset( $data['post_featured_image'] ) && post_type_supports( $post->post_type, 'thumbnail' ) ) {
if ( empty( $data['post_featured_image']['id'] ) ) {
delete_post_thumbnail( $post->ID );
} else {
set_post_thumbnail( $post->ID, $data['post_featured_image']['id'] );
}
}
if ( Utils::is_cpt_custom_templates_supported() ) {
$template = get_metadata( 'post', $post->ID, '_wp_page_template', true );
if ( isset( $data['template'] ) ) {
$template = $data['template'];
}
if ( empty( $template ) ) {
$template = 'default';
}
// Use `update_metadata` in order to save also for revisions.
update_metadata( 'post', $post->ID, '_wp_page_template', $template );
}
}
/**
* Save settings to DB.
*
* Save page settings to the database, as post meta data.
*
* @since 1.6.0
* @access protected
*
* @param array $settings Settings.
* @param int $id Post ID.
*/
protected function save_settings_to_db( array $settings, $id ) {
// Use update/delete_metadata in order to handle also revisions.
if ( ! empty( $settings ) ) {
// Use `wp_slash` in order to avoid the unslashing during the `update_post_meta`.
Leo_Helper::update_post_meta( $id, self::META_KEY . '_id_lang_' . Leo_Helper::$id_lang, json_encode( $settings ) );
} else {
Leo_Helper::delete_post_meta( $id, self::META_KEY . '_id_lang_' . Leo_Helper::$id_lang );
}
}
/**
* Get CSS file for update.
*
* Retrieve the CSS file before updating it.
*
* This method overrides the parent method to disallow updating CSS files for pages.
*
* @since 1.6.0
* @access protected
*
* @param int $id Post ID.
*
* @return false Disallow The updating CSS files for pages.
*/
protected function get_css_file_for_update( $id ) {
return false;
}
/**
* Get saved settings.
*
* Retrieve the saved settings from the post meta.
*
* @since 1.6.0
* @access protected
*
* @param int $id Post ID.
*
* @return array Saved settings.
*/
protected function get_saved_settings( $id ) {
$settings = Leo_Helper::get_post_meta( $id, self::META_KEY . '_id_lang_' . Leo_Helper::$id_lang, true );
if ( ! $settings ) {
$settings = [];
}
$saved_template = Leo_Helper::get_post_meta( $id, '_wp_page_template' . '_id_lang_' . Leo_Helper::$id_lang, true );
if ( $saved_template ) {
$settings['template'] = $saved_template;
}
return $settings;
}
/**
* Get CSS file name.
*
* Retrieve CSS file name for the page settings manager.
*
* @since 1.6.0
* @access protected
*
* @return string CSS file name.
*/
protected function get_css_file_name() {
return 'post';
}
/**
* Get model for CSS file.
*
* Retrieve the model for the CSS file.
*
* @since 1.6.0
* @access protected
*
* @param Base $css_file The requested CSS file.
*
* @return BaseModel The model object.
*/
protected function get_model_for_css_file( Base $css_file ) {
if ( ! $css_file instanceof Post ) {
return null;
}
$post_id = $css_file->get_post_id();
if ( $css_file instanceof Post_Preview ) {
$autosave = Utils::get_post_autosave( $post_id );
if ( $autosave ) {
$post_id = $autosave->ID;
}
}
return $this->get_model( $post_id );
}
/**
* Get special settings names.
*
* Retrieve the names of the special settings that are not saved as regular
* settings. Those settings have a separate saving process.
*
* @since 1.6.0
* @access protected
*
* @return array Special settings names.
*/
protected function get_special_settings_names() {
return [
'id',
'post_title',
'post_status',
'template',
'post_excerpt',
'post_featured_image',
];
}
/**
* @since 2.0.0
* @access public
*
* @param $post_id
* @param $status
*/
public function save_post_status( $post_id, $status ) {
$parent_id = wp_is_post_revision( $post_id );
if ( $parent_id ) {
// Don't update revisions post-status
return;
}
$parent_id = $post_id;
$post = get_post( $parent_id );
$allowed_post_statuses = get_post_statuses();
if ( isset( $allowed_post_statuses[ $status ] ) ) {
$post_type_object = get_post_type_object( $post->post_type );
if ( 'publish' !== $status || current_user_can( $post_type_object->cap->publish_posts ) ) {
$post->post_status = $status;
}
}
wp_update_post( $post );
}
}

View File

@@ -0,0 +1,183 @@
<?php
/**
* 2007-2022 Apollotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Apollotheme <apollotheme@gmail.com>
* @copyright 2007-2022 Apollotheme
* @license http://apollotheme.com - prestashop template provider
*/
namespace LeoElements\Core\Settings\Page;
use LeoElements\Core\Settings\Base\Model as BaseModel;
use LeoElements\Plugin;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor page settings model.
*
* Elementor page settings model handler class is responsible for registering
* and managing Elementor page settings models.
*
* @since 1.6.0
*/
class Model extends BaseModel {
/**
* WordPress post object.
*
* Holds an instance of `WP_Post` containing the post object.
*
* @since 1.6.0
* @access public
*
* @var \WP_Post
*/
private $post;
/**
* @var \WP_Post
*/
private $post_parent;
/**
* Model constructor.
*
* Initializing Elementor page settings model.
*
* @since 1.6.0
* @access public
*
* @param array $data Optional. Model data. Default is an empty array.
*/
public function __construct( array $data = [] ) {
parent::__construct( $data );
}
/**
* Get model name.
*
* Retrieve page settings model name.
*
* @since 1.6.0
* @access public
*
* @return string Model name.
*/
public function get_name() {
return 'page-settings';
}
/**
* Get model unique name.
*
* Retrieve page settings model unique name.
*
* @since 1.6.0
* @access public
*
* @return string Model unique name.
*/
public function get_unique_name() {
return $this->get_name() . '-' . Leo_Helper::$id_post;
}
/**
* Get CSS wrapper selector.
*
* Retrieve the wrapper selector for the page settings model.
*
* @since 1.6.0
* @access public
*
* @return string CSS wrapper selector.
*/
public function get_css_wrapper_selector() {
$document = Plugin::$instance->documents->get( Leo_Helper::$id_post );
return $document->get_css_wrapper_selector();
}
/**
* Get panel page settings.
*
* Retrieve the panel setting for the page settings model.
*
* @since 1.6.0
* @access public
*
* @return array {
* Panel settings.
*
* @type string $title The panel title.
* }
*/
public function get_panel_page_settings() {
return [
/* translators: %s: Document title */
'title' => sprintf( Leo_Helper::__( '%s Settings', 'elementor' ), Leo_Helper::$post_title ),
];
}
/**
* On export post meta.
*
* When exporting data, check if the post is not using page template and
* exclude it from the exported Elementor data.
*
* @since 1.6.0
* @access public
*
* @param array $element_data Element data.
*
* @return array Element data to be exported.
*/
public function on_export( $element_data ) {
if ( ! empty( $element_data['settings']['template'] ) ) {
/**
* @var \Elementor\Modules\PageTemplates\Module $page_templates_module
*/
$page_templates_module = Plugin::$instance->modules_manager->get_modules( 'page-templates' );
$is_elementor_template = ! ! $page_templates_module->get_template_path( $element_data['settings']['template'] );
if ( ! $is_elementor_template ) {
unset( $element_data['settings']['template'] );
}
}
return $element_data;
}
/**
* Register model controls.
*
* Used to add new controls to the page settings model.
*
* @since 1.6.0
* @access protected
*/
protected function _register_controls() {
// Check if it's a real model, or abstract (for example - on import )
if ( Leo_Helper::$id_post ) {
$document = Plugin::$instance->documents->get_doc_or_auto_save( Leo_Helper::$id_post );
if ( $document ) {
$controls = $document->get_controls();
foreach ( $controls as $control_id => $args ) {
$this->add_control( $control_id, $args );
}
}
}
}
}