Add Creative Elements templates and update index files
- Introduced new templates for catalog, checkout, contact, and error pages. - Implemented caching headers and redirection in index.php files across various directories. - Enhanced product and layout templates for better integration with Creative Elements. - Added backoffice header styles and scripts for improved UI/UX in the admin panel.
This commit is contained in:
8
modules/creativeelements/core/settings/page/index.php
Normal file
8
modules/creativeelements/core/settings/page/index.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
header('Expires: Thu, 28 Feb 2019 00:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
header('Location: ../../../../../');
|
||||
die;
|
||||
310
modules/creativeelements/core/settings/page/manager.php
Normal file
310
modules/creativeelements/core/settings/page/manager.php
Normal file
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
/**
|
||||
* Creative Elements - live Theme & Page Builder
|
||||
*
|
||||
* @author WebshopWorks, Elementor
|
||||
* @copyright 2019-2022 WebshopWorks.com & Elementor.com
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
namespace CE;
|
||||
|
||||
defined('_PS_VERSION_') or die;
|
||||
|
||||
use CE\CoreXFilesXCSSXBase as Base;
|
||||
use CE\CoreXFilesXCSSXPost as Post;
|
||||
use CE\CoreXFilesXCSSXPostPreview as PostPreview;
|
||||
use CE\CoreXSettingsXBaseXManager as BaseManager;
|
||||
use CE\CoreXSettingsXBaseXModel as BaseModel;
|
||||
use CE\CoreXSettingsXManager as SettingsManager;
|
||||
use CE\CoreXUtilsXExceptions as Exceptions;
|
||||
|
||||
/**
|
||||
* 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 CoreXSettingsXPageXManager extends BaseManager
|
||||
{
|
||||
/**
|
||||
* Meta key for the page settings.
|
||||
*/
|
||||
const META_KEY = '_elementor_page_settings';
|
||||
|
||||
/**
|
||||
* Get manager name.
|
||||
*
|
||||
* Retrieve page settings manager name.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @access public
|
||||
*
|
||||
* @return string Manager name.
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
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 getModelForConfig()
|
||||
{
|
||||
if (!is_singular() && !Plugin::$instance->editor->isEditMode()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Plugin::$instance->editor->isEditMode()) {
|
||||
$post_id = Plugin::$instance->editor->getPostId();
|
||||
$document = Plugin::$instance->documents->getDocOrAutoSave($post_id);
|
||||
} else {
|
||||
$post_id = get_the_ID();
|
||||
$document = Plugin::$instance->documents->getDocForFrontend($post_id);
|
||||
}
|
||||
|
||||
if (!$document) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$model = $this->getModel($document->getPost()->ID);
|
||||
|
||||
if ($document->isAutosave()) {
|
||||
$model->setSettings('post_status', $document->getMainPost()->post_status);
|
||||
}
|
||||
|
||||
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 ajaxBeforeSaveSettings(array $data, $id)
|
||||
{
|
||||
$post = get_post($id);
|
||||
|
||||
if (empty($post)) {
|
||||
throw new \Exception('Invalid post.', Exceptions::NOT_FOUND);
|
||||
}
|
||||
|
||||
if (!current_user_can('edit', $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->savePostStatus($id, $data['post_status']);
|
||||
// unset($post->post_status);
|
||||
$post->post_status = $data['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'])) {
|
||||
if (empty($data['post_featured_image']['url'])) {
|
||||
delete_post_meta($post->ID, '_og_image');
|
||||
} else {
|
||||
update_post_meta($post->ID, '_og_image', $data['post_featured_image']['url']);
|
||||
}
|
||||
}
|
||||
|
||||
if (Utils::isCptCustomTemplatesSupported($post)) {
|
||||
$template = get_post_meta($post->ID, '_wp_page_template', true);
|
||||
|
||||
if (isset($data['template'])) {
|
||||
$template = $data['template'];
|
||||
}
|
||||
|
||||
if (empty($template)) {
|
||||
$template = 'default';
|
||||
}
|
||||
|
||||
update_post_meta($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 saveSettingsToDb(array $settings, $id)
|
||||
{
|
||||
if (!empty($settings)) {
|
||||
update_post_meta($id, self::META_KEY, $settings);
|
||||
} else {
|
||||
delete_post_meta($id, self::META_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 getCssFileForUpdate($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 getSavedSettings($id)
|
||||
{
|
||||
$settings = get_post_meta($id, self::META_KEY, true);
|
||||
|
||||
if (!$settings) {
|
||||
$settings = [];
|
||||
}
|
||||
|
||||
if (Utils::isCptCustomTemplatesSupported(get_post($id))) {
|
||||
$saved_template = get_post_meta($id, '_wp_page_template', 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 getCssFileName()
|
||||
{
|
||||
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 getModelForCssFile(Base $css_file)
|
||||
{
|
||||
if (!$css_file instanceof Post) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$post_id = $css_file->getPostId();
|
||||
|
||||
if ($css_file instanceof PostPreview) {
|
||||
$autosave = Utils::getPostAutosave($post_id);
|
||||
if ($autosave) {
|
||||
$post_id = $autosave->ID;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->getModel($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 getSpecialSettingsNames()
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'post_title',
|
||||
'post_status',
|
||||
'template',
|
||||
'post_excerpt',
|
||||
'post_featured_image',
|
||||
// Do not save:
|
||||
'action',
|
||||
'_nonce',
|
||||
'section_page_settings',
|
||||
'section_page_style',
|
||||
'section_custom_css',
|
||||
'template_default_description',
|
||||
'template_canvas_description',
|
||||
];
|
||||
}
|
||||
|
||||
// public function savePostStatus($post_id, $status)
|
||||
}
|
||||
193
modules/creativeelements/core/settings/page/model.php
Normal file
193
modules/creativeelements/core/settings/page/model.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
/**
|
||||
* Creative Elements - live Theme & Page Builder
|
||||
*
|
||||
* @author WebshopWorks, Elementor
|
||||
* @copyright 2019-2022 WebshopWorks.com & Elementor.com
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
namespace CE;
|
||||
|
||||
defined('_PS_VERSION_') or die;
|
||||
|
||||
use CE\CoreXSettingsXBaseXModel as BaseModel;
|
||||
|
||||
/**
|
||||
* 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 CoreXSettingsXPageXModel extends BaseModel
|
||||
{
|
||||
/**
|
||||
* Wrapper post object.
|
||||
*
|
||||
* Holds an instance of `WPPost` containing the post object.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @access public
|
||||
*
|
||||
* @var WPPost
|
||||
*/
|
||||
private $post;
|
||||
|
||||
/**
|
||||
* @var WPPost
|
||||
*/
|
||||
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 = [])
|
||||
{
|
||||
$this->post = get_post($data['id']);
|
||||
|
||||
if (!$this->post) {
|
||||
$this->post = new WPPost((object) []);
|
||||
}
|
||||
|
||||
if (wp_is_post_revision($this->post->ID)) {
|
||||
$this->post_parent = get_post($this->post->post_parent);
|
||||
} else {
|
||||
$this->post_parent = $this->post;
|
||||
}
|
||||
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get model name.
|
||||
*
|
||||
* Retrieve page settings model name.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @access public
|
||||
*
|
||||
* @return string Model name.
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
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 getUniqueName()
|
||||
{
|
||||
return $this->getName() . '-' . $this->post->ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 getCssWrapperSelector()
|
||||
{
|
||||
$document = Plugin::$instance->documents->get($this->post_parent->ID);
|
||||
return $document->getCssWrapperSelector();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 getPanelPageSettings()
|
||||
{
|
||||
$document = Plugin::$instance->documents->get($this->post->ID);
|
||||
|
||||
return [
|
||||
/* translators: %s: Document title */
|
||||
'title' => sprintf(__('%s Settings'), $document::getTitle()),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 onExport($element_data)
|
||||
{
|
||||
if (!empty($element_data['settings']['template'])) {
|
||||
/**
|
||||
* @var \Elementor\Modules\PageTemplates\Module $page_templates_module
|
||||
*/
|
||||
$page_templates_module = Plugin::$instance->modules_manager->getModules('page-templates');
|
||||
$is_elementor_template = !!$page_templates_module->getTemplatePath($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 _registerControls()
|
||||
{
|
||||
// Check if it's a real model, or abstract (for example - on import )
|
||||
if ($this->post->ID) {
|
||||
$document = Plugin::$instance->documents->getDocOrAutoSave($this->post->ID);
|
||||
|
||||
if ($document) {
|
||||
$controls = $document->getControls();
|
||||
|
||||
foreach ($controls as $control_id => $args) {
|
||||
$this->addControl($control_id, $args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user