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,289 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor settings controls.
*
* Elementor settings controls handler class responsible for creating the final
* HTML for various input field types used in Elementor settings pages.
*
* @since 1.0.0
*/
class Settings_Controls {
/**
* Render settings control.
*
* Generates the final HTML on the frontend for any given field based on
* the field type (text, select, checkbox, raw HTML, etc.).
*
* @since 1.0.0
* @access public
* @static
*
* @param array $field Optional. Field data. Default is an empty array.
*/
public static function render( $field = [] ) {
if ( empty( $field ) || empty( $field['id'] ) ) {
return;
}
$defaults = [
'type' => '',
'attributes' => [],
'std' => '',
'desc' => '',
];
$field = array_merge( $defaults, $field );
$method_name = $field['type'];
if ( ! method_exists( __CLASS__, $method_name ) ) {
$method_name = 'text';
}
self::$method_name( $field );
}
/**
* Render text control.
*
* Generates the final HTML for text controls.
*
* @since 2.0.0
* @access private
* @static
*
* @param array $field Field data.
*/
private static function text( array $field ) {
if ( empty( $field['attributes']['class'] ) ) {
$field['attributes']['class'] = 'regular-text';
}
$attributes = Utils::render_html_attributes( $field['attributes'] );
?>
<input type="<?php echo Leo_Helper::esc_attr( $field['type'] ); ?>" id="<?php echo Leo_Helper::esc_attr( $field['id'] ); ?>" name="<?php echo Leo_Helper::esc_attr( $field['id'] ); ?>" value="<?php echo Leo_Helper::esc_attr( Leo_Helper::get_option( $field['id'], $field['std'] ) ); ?>" <?php echo $attributes; ?>/>
<?php
if ( ! empty( $field['sub_desc'] ) ) :
echo $field['sub_desc'];
endif;
?>
<?php if ( ! empty( $field['desc'] ) ) : ?>
<p class="description"><?php echo $field['desc']; ?></p>
<?php
endif;
}
/**
* Render checkbox control.
*
* Generates the final HTML for checkbox controls.
*
* @since 2.0.0
* @access private
* @static
*
* @param array $field Field data.
*/
private static function checkbox( array $field ) {
?>
<label>
<input type="<?php echo Leo_Helper::esc_attr( $field['type'] ); ?>" id="<?php echo Leo_Helper::esc_attr( $field['id'] ); ?>" name="<?php echo Leo_Helper::esc_attr( $field['id'] ); ?>" value="<?php echo $field['value']; ?>"<?php checked( $field['value'], Leo_Helper::get_option( $field['id'], $field['std'] ) ); ?> />
<?php
if ( ! empty( $field['sub_desc'] ) ) :
echo $field['sub_desc'];
endif;
?>
</label>
<?php if ( ! empty( $field['desc'] ) ) : ?>
<p class="description"><?php echo $field['desc']; ?></p>
<?php
endif;
}
/**
* Render checkbox list control.
*
* Generates the final HTML for checkbox list controls.
*
* @since 2.0.0
* @access private
* @static
*
* @param array $field Field data.
*/
private static function checkbox_list( array $field ) {
$old_value = Leo_Helper::get_option( $field['id'], $field['std'] );
if ( ! is_array( $old_value ) ) {
$old_value = [];
}
foreach ( $field['options'] as $option_key => $option_value ) :
?>
<label>
<input type="checkbox" name="<?php echo $field['id']; ?>[]" value="<?php echo $option_key; ?>"<?php checked( in_array( $option_key, $old_value ), true ); ?> />
<?php echo $option_value; ?>
</label><br />
<?php endforeach; ?>
<?php if ( ! empty( $field['desc'] ) ) : ?>
<p class="description"><?php echo $field['desc']; ?></p>
<?php
endif;
}
/**
* Render select control.
*
* Generates the final HTML for select controls.
*
* @since 2.0.0
* @access private
* @static
*
* @param array $field Field data.
*/
private static function select( array $field ) {
$old_value = Leo_Helper::get_option( $field['id'], $field['std'] );
?>
<select name="<?php echo Leo_Helper::esc_attr( $field['id'] ); ?>">
<?php if ( ! empty( $field['show_select'] ) ) : ?>
<option value="">— <?php echo Leo_Helper::__( 'Select', 'elementor' ); ?> —</option>
<?php endif; ?>
<?php foreach ( $field['options'] as $value => $label ) : ?>
<option value="<?php echo Leo_Helper::esc_attr( $value ); ?>"<?php selected( $value, $old_value ); ?>><?php echo $label; ?></option>
<?php endforeach; ?>
</select>
<?php if ( ! empty( $field['desc'] ) ) : ?>
<p class="description"><?php echo $field['desc']; ?></p>
<?php
endif;
}
/**
* Render checkbox list control for CPT.
*
* Generates the final HTML for checkbox list controls populated with Custom Post Types.
*
* @since 2.0.0
* @access private
* @static
*
* @param array $field Field data.
*/
private static function checkbox_list_cpt( array $field ) {
$defaults = [
'exclude' => [],
];
$field = array_merge( $defaults, $field );
$post_types_objects = get_post_types(
[
'public' => true,
], 'objects'
);
$field['options'] = [];
foreach ( $post_types_objects as $cpt_slug => $post_type ) {
if ( in_array( $cpt_slug, $field['exclude'] ) ) {
continue;
}
$field['options'][ $cpt_slug ] = $post_type->labels->name;
}
self::checkbox_list( $field );
}
/**
* Render checkbox list control for user roles.
*
* Generates the final HTML for checkbox list controls populated with user roles.
*
* @since 2.0.0
* @access private
* @static
*
* @param array $field Field data.
*/
private static function checkbox_list_roles( array $field ) {
$defaults = [
'exclude' => [],
];
$field = array_merge( $defaults, $field );
$field['options'] = [];
$roles = get_editable_roles();
if ( is_multisite() ) {
$roles = [
'super_admin' => [
'name' => Leo_Helper::__( 'Super Admin', 'elementor' ),
],
] + $roles;
}
foreach ( $roles as $role_slug => $role_data ) {
if ( in_array( $role_slug, $field['exclude'] ) ) {
continue;
}
$field['options'][ $role_slug ] = $role_data['name'];
}
self::checkbox_list( $field );
}
/**
* Render raw HTML control.
*
* Generates the final HTML for raw HTML controls.
*
* @since 2.0.0
* @access private
* @static
*
* @param array $field Field data.
*/
private static function raw_html( array $field ) {
if ( empty( $field['html'] ) ) {
return;
}
?>
<div id="<?php echo $field['id']; ?>">
<div><?php echo $field['html']; ?></div>
<?php
if ( ! empty( $field['sub_desc'] ) ) :
echo $field['sub_desc'];
endif;
?>
<?php if ( ! empty( $field['desc'] ) ) : ?>
<p class="description"><?php echo $field['desc']; ?></p>
<?php endif; ?>
</div>
<?php
}
}

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,400 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor settings page.
*
* An abstract class that provides the needed properties and methods to handle
* WordPress dashboard settings pages in inheriting classes.
*
* @since 1.0.0
* @abstract
*/
abstract class Settings_Page {
/**
* Settings page ID.
*/
const PAGE_ID = '';
/**
* Tabs.
*
* Holds the settings page tabs, sections and fields.
*
* @access private
*
* @var array
*/
private $tabs;
/**
* Create tabs.
*
* Return the settings page tabs, sections and fields.
*
* @since 1.5.0
* @access protected
* @abstract
*/
abstract protected function create_tabs();
/**
* Get settings page title.
*
* Retrieve the title for the settings page.
*
* @since 1.5.0
* @access protected
* @abstract
*/
abstract protected function get_page_title();
/**
* Get settings page URL.
*
* Retrieve the URL of the settings page.
*
* @since 1.5.0
* @access public
* @static
*
* @return string Settings page URL.
*/
final public static function get_url() {
return Leo_Helper::admin_url( 'admin.php?page=' . static::PAGE_ID );
}
/**
* Settings page constructor.
*
* Initializing Elementor settings page.
*
* @since 1.5.0
* @access public
*/
public function __construct() {
$post = $GLOBALS['_POST'];
if ( ! empty( $post['option_page'] ) && static::PAGE_ID === $post['option_page'] ) {
Leo_Helper::add_action( 'admin_init', [ $this, 'register_settings_fields' ] );
}
}
/**
* Get tabs.
*
* Retrieve the settings page tabs, sections and fields.
*
* @since 1.5.0
* @access public
*
* @return array Settings page tabs, sections and fields.
*/
final public function get_tabs() {
$this->ensure_tabs();
return $this->tabs;
}
/**
* Add tab.
*
* Register a new tab to a settings page.
*
* @since 1.5.0
* @access public
*
* @param string $tab_id Tab ID.
* @param array $tab_args Optional. Tab arguments. Default is an empty array.
*/
final public function add_tab( $tab_id, array $tab_args = [] ) {
$this->ensure_tabs();
if ( isset( $this->tabs[ $tab_id ] ) ) {
// Don't override an existing tab
return;
}
if ( ! isset( $tab_args['sections'] ) ) {
$tab_args['sections'] = [];
}
$this->tabs[ $tab_id ] = $tab_args;
}
/**
* Add section.
*
* Register a new section to a tab.
*
* @since 1.5.0
* @access public
*
* @param string $tab_id Tab ID.
* @param string $section_id Section ID.
* @param array $section_args Optional. Section arguments. Default is an
* empty array.
*/
final public function add_section( $tab_id, $section_id, array $section_args = [] ) {
$this->ensure_tabs();
if ( ! isset( $this->tabs[ $tab_id ] ) ) {
// If the requested tab doesn't exists, use the first tab
$tab_id = key( $this->tabs );
}
if ( isset( $this->tabs[ $tab_id ]['sections'][ $section_id ] ) ) {
// Don't override an existing section
return;
}
if ( ! isset( $section_args['fields'] ) ) {
$section_args['fields'] = [];
}
$this->tabs[ $tab_id ]['sections'][ $section_id ] = $section_args;
}
/**
* Add field.
*
* Register a new field to a section.
*
* @since 1.5.0
* @access public
*
* @param string $tab_id Tab ID.
* @param string $section_id Section ID.
* @param string $field_id Field ID.
* @param array $field_args Field arguments.
*/
final public function add_field( $tab_id, $section_id, $field_id, array $field_args ) {
$this->ensure_tabs();
if ( ! isset( $this->tabs[ $tab_id ] ) ) {
// If the requested tab doesn't exists, use the first tab
$tab_id = key( $this->tabs );
}
if ( ! isset( $this->tabs[ $tab_id ]['sections'][ $section_id ] ) ) {
// If the requested section doesn't exists, use the first section
$section_id = key( $this->tabs[ $tab_id ]['sections'] );
}
if ( isset( $this->tabs[ $tab_id ]['sections'][ $section_id ]['fields'][ $field_id ] ) ) {
// Don't override an existing field
return;
}
$this->tabs[ $tab_id ]['sections'][ $section_id ]['fields'][ $field_id ] = $field_args;
}
/**
* Add fields.
*
* Register multiple fields to a section.
*
* @since 1.5.0
* @access public
*
* @param string $tab_id Tab ID.
* @param string $section_id Section ID.
* @param array $fields {
* An array of fields.
*
* @type string $field_id Field ID.
* @type array $field_args Field arguments.
* }
*/
final public function add_fields( $tab_id, $section_id, array $fields ) {
foreach ( $fields as $field_id => $field_args ) {
$this->add_field( $tab_id, $section_id, $field_id, $field_args );
}
}
/**
* Register settings fields.
*
* In each tab register his inner sections, and in each section register his
* inner fields.
*
* @since 1.5.0
* @access public
*/
final public function register_settings_fields() {
$controls_class_name = __NAMESPACE__ . '\Settings_Controls';
$tabs = $this->get_tabs();
foreach ( $tabs as $tab_id => $tab ) {
foreach ( $tab['sections'] as $section_id => $section ) {
$full_section_id = 'elementor_' . $section_id . '_section';
$label = isset( $section['label'] ) ? $section['label'] : '';
$section_callback = isset( $section['callback'] ) ? $section['callback'] : '__return_empty_string';
add_settings_section( $full_section_id, $label, $section_callback, static::PAGE_ID );
foreach ( $section['fields'] as $field_id => $field ) {
$full_field_id = ! empty( $field['full_field_id'] ) ? $field['full_field_id'] : 'elementor_' . $field_id;
$field['field_args']['id'] = $full_field_id;
$field_classes = [ $full_field_id ];
if ( ! empty( $field['class'] ) ) {
$field_classes[] = $field['field_args']['class'];
}
$field['field_args']['class'] = implode( ' ', $field_classes );
add_settings_field(
$full_field_id,
isset( $field['label'] ) ? $field['label'] : '',
[ $controls_class_name, 'render' ],
static::PAGE_ID,
$full_section_id,
$field['field_args']
);
$setting_args = [];
if ( ! empty( $field['setting_args'] ) ) {
$setting_args = $field['setting_args'];
}
register_setting( static::PAGE_ID, $full_field_id, $setting_args );
}
}
}
}
/**
* Display settings page.
*
* Output the content for the settings page.
*
* @since 1.5.0
* @access public
*/
public function display_settings_page() {
$this->register_settings_fields();
$tabs = $this->get_tabs();
?>
<div class="wrap">
<h1><?php echo $this->get_page_title(); ?></h1>
<div id="elementor-settings-tabs-wrapper" class="nav-tab-wrapper">
<?php
foreach ( $tabs as $tab_id => $tab ) {
if ( empty( $tab['sections'] ) ) {
continue;
}
$active_class = '';
if ( 'general' === $tab_id ) {
$active_class = ' nav-tab-active';
}
echo "<a id='elementor-settings-tab-{$tab_id}' class='nav-tab{$active_class}' href='#tab-{$tab_id}'>{$tab['label']}</a>";
}
?>
</div>
<form id="elementor-settings-form" method="post" action="options.php">
<?php
settings_fields( static::PAGE_ID );
foreach ( $tabs as $tab_id => $tab ) {
if ( empty( $tab['sections'] ) ) {
continue;
}
$active_class = '';
if ( 'general' === $tab_id ) {
$active_class = ' elementor-active';
}
echo "<div id='tab-{$tab_id}' class='elementor-settings-form-page{$active_class}'>";
foreach ( $tab['sections'] as $section_id => $section ) {
$full_section_id = 'elementor_' . $section_id . '_section';
if ( ! empty( $section['label'] ) ) {
echo "<h2>{$section['label']}</h2>";
}
if ( ! empty( $section['callback'] ) ) {
$section['callback']();
}
echo '<table class="form-table">';
do_settings_fields( static::PAGE_ID, $full_section_id );
echo '</table>';
}
echo '</div>';
}
submit_button();
?>
</form>
</div><!-- /.wrap -->
<?php
}
/**
* Ensure tabs.
*
* Make sure the settings page has tabs before inserting any new sections or
* fields.
*
* @since 1.5.0
* @access private
*/
private function ensure_tabs() {
if ( null === $this->tabs ) {
$this->tabs = $this->create_tabs();
$page_id = static::PAGE_ID;
/**
* After create settings.
*
* Fires after the settings are created in Elementor admin page.
*
* The dynamic portion of the hook name, `$page_id`, refers to the current page ID.
*
* @since 1.0.0
*
* @param Settings_Page $this The settings page.
*/
Leo_Helper::do_action( "elementor/admin/after_create_settings/{$page_id}", $this );
}
}
}

View File

@@ -0,0 +1,724 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements;
use LeoElements\Core\Responsive\Responsive;
use LeoElements\Core\Settings\General\Manager as General_Settings_Manager;
use LeoElements\Core\Settings\Manager;
use LeoElements\TemplateLibrary\Source_Local;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor "Settings" page in WordPress Dashboard.
*
* Elementor settings page handler class responsible for creating and displaying
* Elementor "Settings" page in WordPress dashboard.
*
* @since 1.0.0
*/
class Settings extends Settings_Page {
/**
* Settings page ID for Elementor settings.
*/
const PAGE_ID = 'elementor';
/**
* Go Pro menu priority.
*/
const MENU_PRIORITY_GO_PRO = 502;
/**
* Settings page field for update time.
*/
const UPDATE_TIME_FIELD = '_elementor_settings_update_time';
/**
* Settings page general tab slug.
*/
const TAB_GENERAL = 'general';
/**
* Settings page style tab slug.
*/
const TAB_STYLE = 'style';
/**
* Settings page integrations tab slug.
*/
const TAB_INTEGRATIONS = 'integrations';
/**
* Settings page advanced tab slug.
*/
const TAB_ADVANCED = 'advanced';
/**
* Register admin menu.
*
* Add new Elementor Settings admin menu.
*
* Fired by `admin_menu` action.
*
* @since 1.0.0
* @access public
*/
public function register_admin_menu() {
$menu = &$GLOBALS['menu'];
$menu[] = [ '', 'read', 'separator-elementor', '', 'wp-menu-separator elementor' ]; // WPCS: override ok.
add_menu_page(
Leo_Helper::__( 'Elementor', 'elementor' ),
Leo_Helper::__( 'Elementor', 'elementor' ),
'manage_options',
self::PAGE_ID,
[ $this, 'display_settings_page' ],
'',
'58.5'
);
}
/**
* Reorder the Elementor menu items in admin.
* Based on WC.
*
* @since 1.0.0
*
* @param array $menu_order Menu order.
* @return array
*/
public function menu_order( $menu_order ) {
// Initialize our custom order array.
$elementor_menu_order = [];
// Get the index of our custom separator.
$elementor_separator = array_search( 'separator-elementor', $menu_order, true );
// Get index of library menu.
$elementor_library = array_search( Source_Local::ADMIN_MENU_SLUG, $menu_order, true );
// Loop through menu order and do some rearranging.
foreach ( $menu_order as $index => $item ) {
if ( 'elementor' === $item ) {
$elementor_menu_order[] = 'separator-elementor';
$elementor_menu_order[] = $item;
$elementor_menu_order[] = Source_Local::ADMIN_MENU_SLUG;
unset( $menu_order[ $elementor_separator ] );
unset( $menu_order[ $elementor_library ] );
} elseif ( ! in_array( $item, [ 'separator-elementor' ], true ) ) {
$elementor_menu_order[] = $item;
}
}
// Return order.
return $elementor_menu_order;
}
/**
* Register Elementor Pro sub-menu.
*
* Add new Elementor Pro sub-menu under the main Elementor menu.
*
* Fired by `admin_menu` action.
*
* @since 1.0.0
* @access public
*/
public function register_pro_menu() {
add_submenu_page(
self::PAGE_ID,
Leo_Helper::__( 'Custom Fonts', 'elementor' ),
Leo_Helper::__( 'Custom Fonts', 'elementor' ),
'manage_options',
'elementor_custom_fonts',
[ $this, 'elementor_custom_fonts' ]
);
add_submenu_page(
self::PAGE_ID,
'',
'<span class="dashicons dashicons-star-filled" style="font-size: 17px"></span> ' . Leo_Helper::__( 'Go Pro', 'elementor' ),
'manage_options',
'go_elementor_pro',
[ $this, 'handle_external_redirects' ]
);
add_submenu_page( Source_Local::ADMIN_MENU_SLUG, Leo_Helper::__( 'Theme Templates', 'elementor' ), Leo_Helper::__( 'Theme Builder', 'elementor' ), 'manage_options', 'theme_templates', [ $this, 'elementor_theme_templates' ] );
add_submenu_page( Source_Local::ADMIN_MENU_SLUG, Leo_Helper::__( 'Popups', 'elementor' ), Leo_Helper::__( 'Popups', 'elementor' ), 'manage_options', 'popup_templates', [ $this, 'elementor_popups' ] );
}
/**
* Register Elementor knowledge base sub-menu.
*
* Add new Elementor knowledge base sub-menu under the main Elementor menu.
*
* Fired by `admin_menu` action.
*
* @since 2.0.3
* @access public
*/
public function register_knowledge_base_menu() {
add_submenu_page(
self::PAGE_ID,
'',
Leo_Helper::__( 'Getting Started', 'elementor' ),
'manage_options',
'elementor-getting-started',
[ $this, 'elementor_getting_started' ]
);
add_submenu_page(
self::PAGE_ID,
'',
Leo_Helper::__( 'Get Help', 'elementor' ),
'manage_options',
'go_knowledge_base_site',
[ $this, 'handle_external_redirects' ]
);
}
/**
* Go Elementor Pro.
*
* Redirect the Elementor Pro page the clicking the Elementor Pro menu link.
*
* Fired by `admin_init` action.
*
* @since 2.0.3
* @access public
*/
public function handle_external_redirects() {
if ( empty( Tools::getValue('page') ) ) {
return;
}
}
/**
* Display settings page.
*
* Output the content for the getting started page.
*
* @since 1.0.0
* @access public
*/
public function elementor_getting_started() {
if ( User::is_current_user_can_edit_post_type( 'page' ) ) {
$create_new_label = Leo_Helper::__( 'Create Your First Page', 'elementor' );
$create_new_cpt = 'page';
} elseif ( User::is_current_user_can_edit_post_type( 'post' ) ) {
$create_new_label = Leo_Helper::__( 'Create Your First Post', 'elementor' );
$create_new_cpt = 'post';
}
?>
<div class="wrap">
<div class="e-getting-started">
<div class="e-getting-started__box postbox">
<div class="e-getting-started__header">
<div class="e-getting-started__title">
<div class="e-logo-wrapper"><i class="eicon-elementor"></i></div>
<?php echo Leo_Helper::__( 'Getting Started', 'elementor' ); ?>
</div>
<a class="e-getting-started__skip" href="<?php echo esc_url( Leo_Helper::admin_url() ); ?>">
<i class="eicon-close" aria-hidden="true" title="<?php Leo_Helper::esc_attr_e( 'Skip', 'elementor' ); ?>"></i>
<span class="elementor-screen-only"><?php echo Leo_Helper::__( 'Skip', 'elementor' ); ?></span>
</a>
</div>
<div class="e-getting-started__content">
<div class="e-getting-started__content--narrow">
<h2><?php echo Leo_Helper::__( 'Welcome to Elementor', 'elementor' ); ?></h2>
<p><?php echo Leo_Helper::__( 'We recommend you watch this 2 minute getting started video, and then try the editor yourself by dragging and dropping elements to create your first page.', 'elementor' ); ?></p>
</div>
<div class="e-getting-started__video">
<iframe width="620" height="350" src="https://www.youtube-nocookie.com/embed/nZlgNmbC-Cw?rel=0&amp;controls=1&amp;modestbranding=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<div class="e-getting-started__actions e-getting-started__content--narrow">
<?php if ( ! empty( $create_new_cpt ) ) : ?>
<a href="<?php echo esc_url( Utils::get_create_new_post_url( $create_new_cpt ) ); ?>" class="button button-primary button-hero"><?php echo Leo_Helper::esc_html( $create_new_label ); ?></a>
<?php endif; ?>
<a href="https://subdomain.leoelements.com/getting-started/" target="_blank" class="button button-secondary button-hero"><?php echo Leo_Helper::__( 'Get the Full Guide', 'elementor' ); ?></a>
</div>
</div>
</div>
</div>
</div><!-- /.wrap -->
<?php
}
/**
* Display settings page.
*
* Output the content for the custom fonts page.
*
* @since 2.0.0
* @access public
*/
public function elementor_custom_fonts() {
?>
<div class="wrap">
<div class="elementor-blank_state">
<i class="eicon-nerd-chuckle"></i>
<h2><?php echo Leo_Helper::__( 'Add Your Custom Fonts', 'elementor' ); ?></h2>
<p><?php echo Leo_Helper::__( 'Custom Fonts allows you to add your self-hosted fonts and use them on your Elementor projects to create a unique brand language.', 'elementor' ); ?></p>
<a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="<?php echo Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=wp-custom-fonts&utm_campaign=gopro&utm_medium=wp-dash' ); ?>"><?php echo Leo_Helper::__( 'Go Pro', 'elementor' ); ?></a>
</div>
</div><!-- /.wrap -->
<?php
}
/**
* Display settings page.
*
* Output the content for the Popups page.
*
* @since 1.0.0
* @access public
*/
public function elementor_popups() {
?>
<div class="wrap">
<div class="elementor-blank_state">
<i class="eicon-nerd-chuckle"></i>
<h2><?php echo Leo_Helper::__( 'Get Popup Builder', 'elementor' ); ?></h2>
<p><?php echo Leo_Helper::__( 'Popup Builder lets you take advantage of all the amazing features in Elementor, so you can build beautiful & highly converting popups. Go pro and start designing your popups today.', 'elementor' ); ?></p>
<a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="<?php echo Utils::get_pro_link( 'https://elementor.com/popup-builder/?utm_source=popup-templates&utm_campaign=gopro&utm_medium=wp-dash' ); ?>"><?php echo Leo_Helper::__( 'Go Pro', 'elementor' ); ?></a>
</div>
</div><!-- /.wrap -->
<?php
}
/**
* Display settings page.
*
* Output the content for the Theme Templates page.
*
* @since 1.0.0
* @access public
*/
public function elementor_theme_templates() {
?>
<div class="wrap">
<div class="elementor-blank_state">
<i class="eicon-nerd-chuckle"></i>
<h2><?php echo Leo_Helper::__( 'Get Theme Builder', 'elementor' ); ?></h2>
<p><?php echo Leo_Helper::__( 'Theme Builder is the industry leading all-in-one solution that lets you customize every part of your WordPress theme visually: Header, Footer, Single, Archive & WooCommerce.', 'elementor' ); ?></p>
<a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="<?php echo Utils::get_pro_link( 'https://elementor.com/theme-builder/?utm_source=theme-templates&utm_campaign=gopro&utm_medium=wp-dash' ); ?>"><?php echo Leo_Helper::__( 'Go Pro', 'elementor' ); ?></a>
</div>
</div><!-- /.wrap -->
<?php
}
/**
* On admin init.
*
* Preform actions on WordPress admin initialization.
*
* Fired by `admin_init` action.
*
* @since 2.0.0
* @access public
*/
public function on_admin_init() {
$this->handle_external_redirects();
// Save general settings in one list for a future usage
$this->handle_general_settings_update();
$this->maybe_remove_all_admin_notices();
}
/**
* Change "Settings" menu name.
*
* Update the name of the Settings admin menu from "Elementor" to "Settings".
*
* Fired by `admin_menu` action.
*
* @since 1.0.0
* @access public
*/
public function admin_menu_change_name() {
$submenu = &$GLOBALS['submenu'];
if ( isset( $submenu['elementor'] ) ) {
// @codingStandardsIgnoreStart
$submenu['elementor'][0][0] = Leo_Helper::__( 'Settings', 'elementor' );
// @codingStandardsIgnoreEnd
}
}
/**
* Update CSS print method.
*
* Clear post CSS cache.
*
* Fired by `add_option_elementor_css_print_method` and
* `update_option_elementor_css_print_method` actions.
*
* @since 1.7.5
* @access public
*/
public function update_css_print_method() {
Plugin::$instance->files_manager->clear_cache();
}
/**
* Create tabs.
*
* Return the settings page tabs, sections and fields.
*
* @since 1.5.0
* @access protected
*
* @return array An array with the settings page tabs, sections and fields.
*/
protected function create_tabs() {
$validations_class_name = __NAMESPACE__ . '\Settings_Validations';
$default_breakpoints = Responsive::get_default_breakpoints();
return [
self::TAB_GENERAL => [
'label' => Leo_Helper::__( 'General', 'elementor' ),
'sections' => [
'general' => [
'fields' => [
self::UPDATE_TIME_FIELD => [
'full_field_id' => self::UPDATE_TIME_FIELD,
'field_args' => [
'type' => 'hidden',
],
'setting_args' => [ $validations_class_name, 'current_time' ],
],
'cpt_support' => [
'label' => Leo_Helper::__( 'Post Types', 'elementor' ),
'field_args' => [
'type' => 'checkbox_list_cpt',
'std' => [ 'page', 'post' ],
'exclude' => [ 'attachment', 'elementor_library' ],
],
'setting_args' => [ $validations_class_name, 'checkbox_list' ],
],
'disable_color_schemes' => [
'label' => Leo_Helper::__( 'Disable Default Colors', 'elementor' ),
'field_args' => [
'type' => 'checkbox',
'value' => 'yes',
'sub_desc' => Leo_Helper::__( 'Checking this box will disable Elementor\'s Default Colors, and make Elementor inherit the colors from your theme.', 'elementor' ),
],
],
'disable_typography_schemes' => [
'label' => Leo_Helper::__( 'Disable Default Fonts', 'elementor' ),
'field_args' => [
'type' => 'checkbox',
'value' => 'yes',
'sub_desc' => Leo_Helper::__( 'Checking this box will disable Elementor\'s Default Fonts, and make Elementor inherit the fonts from your theme.', 'elementor' ),
],
],
],
],
'usage' => [
'label' => Leo_Helper::__( 'Improve Elementor', 'elementor' ),
'fields' => [
'allow_tracking' => [
'label' => Leo_Helper::__( 'Usage Data Tracking', 'elementor' ),
'field_args' => [
'type' => 'checkbox',
'value' => 'yes',
'default' => '',
'sub_desc' => Leo_Helper::__( 'Opt-in to our anonymous plugin data collection and to updates. We guarantee no sensitive data is collected.', 'elementor' ) . sprintf( ' <a href="%1$s" target="_blank">%2$s</a>', 'https://creator.axonvip.com/usage-data-tracking/', Leo_Helper::__( 'Learn more.', 'elementor' ) ),
],
'setting_args' => [ __NAMESPACE__ . '\Tracker', 'check_for_settings_optin' ],
],
],
],
],
],
self::TAB_STYLE => [
'label' => Leo_Helper::__( 'Style', 'elementor' ),
'sections' => [
'style' => [
'fields' => [
'default_generic_fonts' => [
'label' => Leo_Helper::__( 'Default Generic Fonts', 'elementor' ),
'field_args' => [
'type' => 'text',
'std' => 'Sans-serif',
'class' => 'medium-text',
'desc' => Leo_Helper::__( 'The list of fonts used if the chosen font is not available.', 'elementor' ),
],
],
'container_width' => [
'label' => Leo_Helper::__( 'Content Width', 'elementor' ),
'field_args' => [
'type' => 'number',
'attributes' => [
'min' => 300,
'placeholder' => '1140',
'class' => 'medium-text',
],
'sub_desc' => 'px',
'desc' => Leo_Helper::__( 'Sets the default width of the content area (Default: 1140)', 'elementor' ),
],
],
'space_between_widgets' => [
'label' => Leo_Helper::__( 'Space Between Widgets', 'elementor' ),
'field_args' => [
'type' => 'number',
'attributes' => [
'placeholder' => '20',
'class' => 'medium-text',
],
'sub_desc' => 'px',
'desc' => Leo_Helper::__( 'Sets the default space between widgets (Default: 20)', 'elementor' ),
],
],
'stretched_section_container' => [
'label' => Leo_Helper::__( 'Stretched Section Fit To', 'elementor' ),
'field_args' => [
'type' => 'text',
'attributes' => [
'placeholder' => 'body',
'class' => 'medium-text',
],
'desc' => 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' ),
],
],
'page_title_selector' => [
'label' => Leo_Helper::__( 'Page Title Selector', 'elementor' ),
'field_args' => [
'type' => 'text',
'attributes' => [
'placeholder' => 'h1.entry-title',
'class' => 'medium-text',
],
'desc' => Leo_Helper::__( 'Elementor 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' ),
],
],
'viewport_lg' => [
'label' => Leo_Helper::__( 'Tablet Breakpoint', 'elementor' ),
'field_args' => [
'type' => 'number',
'attributes' => [
'placeholder' => $default_breakpoints['lg'],
'min' => $default_breakpoints['md'] + 1,
'max' => $default_breakpoints['xl'] - 1,
'class' => 'medium-text',
],
'sub_desc' => 'px',
/* translators: %d: Breakpoint value */
'desc' => sprintf( Leo_Helper::__( 'Sets the breakpoint between desktop and tablet devices. Below this breakpoint tablet layout will appear (Default: %dpx).', 'elementor' ), $default_breakpoints['lg'] ),
],
],
'viewport_md' => [
'label' => Leo_Helper::__( 'Mobile Breakpoint', 'elementor' ),
'field_args' => [
'type' => 'number',
'attributes' => [
'placeholder' => $default_breakpoints['md'],
'min' => $default_breakpoints['sm'] + 1,
'max' => $default_breakpoints['lg'] - 1,
'class' => 'medium-text',
],
'sub_desc' => 'px',
/* translators: %d: Breakpoint value */
'desc' => sprintf( Leo_Helper::__( 'Sets the breakpoint between tablet and mobile devices. Below this breakpoint mobile layout will appear (Default: %dpx).', 'elementor' ), $default_breakpoints['md'] ),
],
],
'global_image_lightbox' => [
'label' => Leo_Helper::__( 'Image Lightbox', 'elementor' ),
'field_args' => [
'type' => 'checkbox',
'value' => 'yes',
'std' => 'yes',
'sub_desc' => 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' ),
'desc' => Leo_Helper::__( 'You can customize the lightbox design by going to: Top-left hamburger icon > Global Settings > Lightbox.', 'elementor' ),
],
],
],
],
],
],
self::TAB_INTEGRATIONS => [
'label' => Leo_Helper::__( 'Integrations', 'elementor' ),
'sections' => [],
],
self::TAB_ADVANCED => [
'label' => Leo_Helper::__( 'Advanced', 'elementor' ),
'sections' => [
'advanced' => [
'fields' => [
'css_print_method' => [
'label' => Leo_Helper::__( 'CSS Print Method', 'elementor' ),
'field_args' => [
'class' => 'elementor_css_print_method',
'type' => 'select',
'options' => [
'internal' => Leo_Helper::__( 'Internal Embedding', 'elementor' ),
'external' => Leo_Helper::__( 'External File', 'elementor' ),
],
'desc' => '</div><div class="elementor-css-print-method-description" data-value="internal" style="display: none">' . Leo_Helper::__( 'Use internal CSS that is embedded in the head of the page. For troubleshooting server configuration conflicts and managing development environments (recommended).', 'elementor' ) . '</div>' . '<div class="elementor-css-print-method-description" data-value="external" style="display: none">' . Leo_Helper::__( 'Use external CSS files for all generated stylesheets. Choose this setting for better performance.', 'elementor' ),
],
],
'editor_break_lines' => [
'label' => Leo_Helper::__( 'Switch Editor Loader Method', 'elementor' ),
'field_args' => [
'type' => 'select',
'options' => [
'' => Leo_Helper::__( 'Disable', 'elementor' ),
1 => Leo_Helper::__( 'Enable', 'elementor' ),
],
'desc' => Leo_Helper::__( 'For troubleshooting server configuration conflicts.', 'elementor' ),
],
],
'edit_buttons' => [
'label' => Leo_Helper::__( 'Editing Handles', 'elementor' ),
'field_args' => [
'type' => 'select',
'std' => '',
'options' => [
'' => Leo_Helper::__( 'Hide', 'elementor' ),
'on' => Leo_Helper::__( 'Show', 'elementor' ),
],
'desc' => Leo_Helper::__( 'Show editing handles when hovering over the element edit button', 'elementor' ),
],
],
'allow_svg' => [
'label' => Leo_Helper::__( 'Enable SVG Uploads', 'elementor' ),
'field_args' => [
'type' => 'select',
'std' => '',
'options' => [
'' => Leo_Helper::__( 'Disable', 'elementor' ),
1 => Leo_Helper::__( 'Enable', 'elementor' ),
],
'desc' => Leo_Helper::__( 'Please note! Allowing uploads of any files (SVG included) is a potential security risk.', 'elementor' ) . '<br>' . Leo_Helper::__( 'Elementor will try to sanitize the SVG files, removing potential malicious code and scripts.', 'elementor' ) . '<br>' . Leo_Helper::__( 'We recommend you only enable this feature if you understand the security risks involved.', 'elementor' ),
],
],
],
],
],
],
];
}
/**
* Get settings page title.
*
* Retrieve the title for the settings page.
*
* @since 1.5.0
* @access protected
*
* @return string Settings page title.
*/
protected function get_page_title() {
return Leo_Helper::__( 'Elementor', 'elementor' );
}
/**
* Handle general settings update.
*
* Save general settings in one list for a future usage.
*
* @since 2.0.0
* @access private
*/
private function handle_general_settings_update() {
$post = $GLOBALS['_POST'];
if ( ! empty( $post['option_page'] ) && self::PAGE_ID === $post['option_page'] && ! empty( $post['action'] ) && 'update' === $post['action'] ) {
check_admin_referer( 'elementor-options' );
$saved_general_settings = Leo_Helper::get_option( General_Settings_Manager::META_KEY );
if ( ! $saved_general_settings ) {
$saved_general_settings = [];
}
$general_settings = Manager::get_settings_managers( 'general' )->get_model()->get_settings();
foreach ( $general_settings as $setting_key => $setting ) {
if ( ! empty( $post[ $setting_key ] ) ) {
$pure_setting_key = str_replace( 'elementor_', '', $setting_key );
$saved_general_settings[ $pure_setting_key ] = $post[ $setting_key ];
}
}
Leo_Helper::update_option( General_Settings_Manager::META_KEY, $saved_general_settings );
}
}
/**
* @since 1.0.0
* @access private
*/
private function maybe_remove_all_admin_notices() {
$elementor_pages = [
'elementor-getting-started',
'elementor-role-manager',
'elementor_custom_fonts',
'elementor-license',
];
if ( empty( Tools::getValue('page') ) || ! in_array( Tools::getValue('page'), $elementor_pages, true ) ) {
return;
}
remove_all_actions( 'admin_notices' );
}
/**
* Settings page constructor.
*
* Initializing Elementor "Settings" page.
*
* @since 1.0.0
* @access public
*/
public function __construct() {
parent::__construct();
Leo_Helper::add_action( 'admin_init', [ $this, 'on_admin_init' ] );
Leo_Helper::add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 20 );
Leo_Helper::add_action( 'admin_menu', [ $this, 'admin_menu_change_name' ], 200 );
Leo_Helper::add_action( 'admin_menu', [ $this, 'register_pro_menu' ], self::MENU_PRIORITY_GO_PRO );
Leo_Helper::add_action( 'admin_menu', [ $this, 'register_knowledge_base_menu' ], 501 );
// Clear CSS Meta after change print method.
Leo_Helper::add_action( 'add_option_elementor_css_print_method', [ $this, 'update_css_print_method' ] );
Leo_Helper::add_action( 'update_option_elementor_css_print_method', [ $this, 'update_css_print_method' ] );
Leo_Helper::add_filter( 'custom_menu_order', '__return_true' );
Leo_Helper::add_filter( 'menu_order', [ $this, 'menu_order' ] );
foreach ( Responsive::get_editable_breakpoints() as $breakpoint_key => $breakpoint ) {
foreach ( [ 'add', 'update' ] as $action ) {
Leo_Helper::add_action( "{$action}_option_elementor_viewport_{$breakpoint_key}", [ 'LeoElements\Core\Responsive\Responsive', 'compile_stylesheet_templates' ] );
}
}
}
}

View File

@@ -0,0 +1,213 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements\System_Info\Classes\Abstracts;
use LeoElements\System_Info\Helpers\Model_Helper;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor base reporter.
*
* A base abstract class that provides the needed properties and methods to
* manage and handle reporter in inheriting classes.
*
* @since 1.0.0
* @abstract
*/
abstract class Base_Reporter {
/**
* Reporter properties.
*
* Holds the list of all the properties of the report.
*
* @access private
* @static
*
* @var array
*/
private $_properties;
/**
* Get report title.
*
* Retrieve the title of the report.
*
* @since 1.0.0
* @access public
* @abstract
*/
abstract public function get_title();
/**
* Get report fields.
*
* Retrieve the required fields for the report.
*
* @since 1.0.0
* @access public
* @abstract
*/
abstract public function get_fields();
/**
* Is report enabled.
*
* Whether the report is enabled.
*
* @since 1.0.0
* @access public
*
* @return bool Whether the report is enabled.
*/
public function is_enabled() {
return true;
}
/**
* Get report.
*
* Retrieve the report with all it's containing fields.
*
* @since 1.0.0
* @access public
*
* @return \WP_Error | array {
* Report fields.
*
* @type string $name Field name.
* @type string $label Field label.
* }
*/
final public function get_report( $format = '' ) {
$result = [];
$format = ( empty( $format ) ) ? '' : $format . '_';
foreach ( $this->get_fields() as $field_name => $field_label ) {
$method = 'get_' . $format . $field_name;
if ( ! method_exists( $this, $method ) ) {
$method = 'get_' . $field_name;
//fallback:
if ( ! method_exists( $this, $method ) ) {
return new \WP_Error( sprintf( "Getter method for the field '%s' wasn't found in %s.", $field_name, get_called_class() ) );
}
}
$reporter_field = [
'name' => $field_name,
'label' => $field_label,
];
$reporter_field = array_merge( $reporter_field, $this->$method() );
$result[ $field_name ] = $reporter_field;
}
return $result;
}
/**
* Get properties keys.
*
* Retrieve the keys of the properties.
*
* @since 1.0.0
* @access public
* @static
*
* @return array {
* Property keys.
*
* @type string $name Property name.
* @type string $fields Property fields.
* }
*/
public static function get_properties_keys() {
return [
'name',
'fields',
];
}
/**
* Filter possible properties.
*
* Retrieve possible properties filtered by property keys.
*
* @since 1.0.0
* @access public
* @static
*
* @param array $properties Properties to filter.
*
* @return array Possible properties filtered by property keys.
*/
final public static function filter_possible_properties( $properties ) {
return Model_Helper::filter_possible_properties( self::get_properties_keys(), $properties );
}
/**
* Set properties.
*
* Add/update properties to the report.
*
* @since 1.0.0
* @access public
*
* @param array $key Property key.
* @param array $value Optional. Property value. Default is `null`.
*/
final public function set_properties( $key, $value = null ) {
if ( is_array( $key ) ) {
$key = self::filter_possible_properties( $key );
foreach ( $key as $sub_key => $sub_value ) {
$this->set_properties( $sub_key, $sub_value );
}
return;
}
if ( ! in_array( $key, self::get_properties_keys(), true ) ) {
return;
}
$this->_properties[ $key ] = $value;
}
/**
* Reporter base constructor.
*
* Initializing the reporter base class.
*
* @since 1.0.0
* @access public
*
* @param array $properties Optional. Properties to filter. Default is `null`.
*/
public function __construct( $properties = null ) {
$this->_properties = array_fill_keys( self::get_properties_keys(), null );
if ( $properties ) {
$this->set_properties( $properties, null );
}
}
}

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,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,128 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements\System_Info\Classes;
use LeoElements\System_Info\Classes\Abstracts\Base_Reporter;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor must-use plugins report.
*
* Elementor system report handler class responsible for generating a report for
* must-use plugins.
*
* @since 1.0.0
*/
class MU_Plugins_Reporter extends Base_Reporter {
/**
* Must-Use plugins.
*
* Holds the sites must-use plugins list.
*
* @since 1.0.0
* @access private
*
* @var array
*/
private $plugins;
/**
* Get must-use plugins.
*
* Retrieve the must-use plugins.
*
* @since 2.0.0
* @access private
*
* @return array Must-Use plugins.
*/
private function get_mu_plugins() {
if ( ! $this->plugins ) {
$this->plugins = get_mu_plugins();
}
return $this->plugins;
}
/**
* Is enabled.
*
* Whether there are must-use plugins or not.
*
* @since 1.0.0
* @access public
*
* @return bool True if the site has must-use plugins, False otherwise.
*/
public function is_enabled() {
return ! ! $this->get_mu_plugins();
}
/**
* Get must-use plugins reporter title.
*
* Retrieve must-use plugins reporter title.
*
* @since 1.0.0
* @access public
*
* @return string Reporter title.
*/
public function get_title() {
return 'Must-Use Plugins';
}
/**
* Get must-use plugins report fields.
*
* Retrieve the required fields for the must-use plugins report.
*
* @since 1.0.0
* @access public
*
* @return array Required report fields with field ID and field label.
*/
public function get_fields() {
return [
'must_use_plugins' => 'Must-Use Plugins',
];
}
/**
* Get must-use plugins.
*
* Retrieve the sites must-use plugins.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value The must-use plugins list.
* }
*/
public function get_must_use_plugins() {
return [
'value' => $this->get_mu_plugins(),
];
}
}

View File

@@ -0,0 +1,133 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements\System_Info\Classes;
use LeoElements\System_Info\Classes\Abstracts\Base_Reporter;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor network plugins report.
*
* Elementor system report handler class responsible for generating a report for
* network plugins.
*
* @since 1.0.0
*/
class Network_Plugins_Reporter extends Base_Reporter {
/**
* Network plugins.
*
* Holds the sites network plugins list.
*
* @since 1.0.0
* @access private
*
* @var array
*/
private $plugins;
/**
* Get network plugins reporter title.
*
* Retrieve network plugins reporter title.
*
* @since 1.0.0
* @access public
*
* @return string Reporter title.
*/
public function get_title() {
return 'Network Plugins';
}
/**
* Get active network plugins.
*
* Retrieve the active network plugins from the list of active site-wide plugins.
*
* @since 2.0.0
* @access private
*
* @return array Active network plugins.
*/
private function get_network_plugins() {
if ( ! $this->plugins ) {
$active_plugins = get_site_option( 'active_sitewide_plugins' );
$this->plugins = array_intersect_key( get_plugins(), $active_plugins );
}
return $this->plugins;
}
/**
* Is enabled.
*
* Whether there are active network plugins or not.
*
* @since 1.0.0
* @access public
*
* @return bool True if the site has active network plugins, False otherwise.
*/
public function is_enabled() {
if ( ! is_multisite() ) {
return false;
};
return ! ! $this->get_network_plugins();
}
/**
* Get network plugins report fields.
*
* Retrieve the required fields for the network plugins report.
*
* @since 1.0.0
* @access public
*
* @return array Required report fields with field ID and field label.
*/
public function get_fields() {
return [
'network_active_plugins' => 'Network Plugins',
];
}
/**
* Get active network plugins.
*
* Retrieve the sites active network plugins.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value The active network plugins list.
* }
*/
public function get_network_active_plugins() {
return [
'value' => $this->get_network_plugins(),
];
}
}

View File

@@ -0,0 +1,134 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements\System_Info\Classes;
use LeoElements\System_Info\Classes\Abstracts\Base_Reporter;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor active plugins report.
*
* Elementor system report handler class responsible for generating a report for
* active plugins.
*
* @since 1.0.0
*/
class Plugins_Reporter extends Base_Reporter {
/**
* Active plugins.
*
* Holds the sites active plugins list.
*
* @since 1.0.0
* @access private
*
* @var array
*/
private $plugins;
/**
* Get active plugins.
*
* Retrieve the active plugins from the list of all the installed plugins.
*
* @since 2.0.0
* @access private
*
* @return array Active plugins.
*/
private function get_plugins() {
if ( ! $this->plugins ) {
// Ensure get_plugins function is loaded
if ( ! function_exists( 'get_plugins' ) ) {
include ABSPATH . '/wp-admin/includes/plugin.php';
}
$active_plugins = Leo_Helper::get_option( 'active_plugins' );
$this->plugins = array_intersect_key( get_plugins(), array_flip( $active_plugins ) );
}
return $this->plugins;
}
/**
* Get active plugins reporter title.
*
* Retrieve active plugins reporter title.
*
* @since 1.0.0
* @access public
*
* @return string Reporter title.
*/
public function get_title() {
return 'Active Plugins';
}
/**
* Is enabled.
*
* Whether there are active plugins or not.
*
* @since 1.0.0
* @access public
*
* @return bool True if the site has active plugins, False otherwise.
*/
public function is_enabled() {
return ! ! $this->get_plugins();
}
/**
* Get active plugins report fields.
*
* Retrieve the required fields for the active plugins report.
*
* @since 1.0.0
* @access public
*
* @return array Required report fields with field ID and field label.
*/
public function get_fields() {
return [
'active_plugins' => 'Active Plugins',
];
}
/**
* Get active plugins.
*
* Retrieve the sites active plugins.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value The active plugins list.
* }
*/
public function get_active_plugins() {
return [
'value' => $this->get_plugins(),
];
}
}

View File

@@ -0,0 +1,378 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements\System_Info\Classes;
use LeoElements\Api;
use LeoElements\System_Info\Classes\Abstracts\Base_Reporter;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor server environment report.
*
* Elementor system report handler class responsible for generating a report for
* the server environment.
*
* @since 1.0.0
*/
class Server_Reporter extends Base_Reporter {
/**
* Get server environment reporter title.
*
* Retrieve server environment reporter title.
*
* @since 1.0.0
* @access public
*
* @return string Reporter title.
*/
public function get_title() {
return 'Server Environment';
}
/**
* Get server environment report fields.
*
* Retrieve the required fields for the server environment report.
*
* @since 1.0.0
* @access public
*
* @return array Required report fields with field ID and field label.
*/
public function get_fields() {
return [
'os' => 'Operating System',
'software' => 'Software',
'mysql_version' => 'MySQL version',
'php_version' => 'PHP Version',
'php_max_input_vars' => 'PHP Max Input Vars',
'php_max_post_size' => 'PHP Max Post Size',
'gd_installed' => 'GD Installed',
'zip_installed' => 'ZIP Installed',
'write_permissions' => 'Write Permissions',
'elementor_library' => 'Elementor Library',
];
}
/**
* Get server operating system.
*
* Retrieve the server operating system.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value Server operating system.
* }
*/
public function get_os() {
return [
'value' => PHP_OS,
];
}
/**
* Get server software.
*
* Retrieve the server software.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value Server software.
* }
*/
public function get_software() {
return [
'value' => $_SERVER['SERVER_SOFTWARE'],
];
}
/**
* Get PHP version.
*
* Retrieve the PHP version.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value PHP version.
* @type string $recommendation Minimum PHP version recommendation.
* @type bool $warning Whether to display a warning.
* }
*/
public function get_php_version() {
$result = [
'value' => PHP_VERSION,
];
if ( version_compare( $result['value'], '5.4', '<' ) ) {
$result['recommendation'] = Leo_Helper::_x( 'We recommend to use php 5.4 or higher', 'System Info', 'elementor' );
$result['warning'] = true;
}
return $result;
}
/**
* Get PHP `max_input_vars`.
*
* Retrieve the value of `max_input_vars` from `php.ini` configuration file.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value PHP `max_input_vars`.
* }
*/
public function get_php_max_input_vars() {
return [
'value' => ini_get( 'max_input_vars' ),
];
}
/**
* Get PHP `post_max_size`.
*
* Retrieve the value of `post_max_size` from `php.ini` configuration file.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value PHP `post_max_size`.
* }
*/
public function get_php_max_post_size() {
return [
'value' => ini_get( 'post_max_size' ),
];
}
/**
* Get GD installed.
*
* Whether the GD extension is installed.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value Yes if the GD extension is installed, No otherwise.
* @type bool $warning Whether to display a warning. True if the GD extension is installed, False otherwise.
* }
*/
public function get_gd_installed() {
$gd_installed = extension_loaded( 'gd' );
return [
'value' => $gd_installed ? 'Yes' : 'No',
'warning' => ! $gd_installed,
];
}
/**
* Get ZIP installed.
*
* Whether the ZIP extension is installed.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value Yes if the ZIP extension is installed, No otherwise.
* @type bool $warning Whether to display a warning. True if the ZIP extension is installed, False otherwise.
* }
*/
public function get_zip_installed() {
$zip_installed = extension_loaded( 'zip' );
return [
'value' => $zip_installed ? 'Yes' : 'No',
'warning' => ! $zip_installed,
];
}
/**
* Get MySQL version.
*
* Retrieve the MySQL version.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value MySQL version.
* }
*/
public function get_mysql_version() {
$wpdb = &$GLOBALS['wpdb'];
$db_server_version = $wpdb->get_results( "SHOW VARIABLES WHERE `Variable_name` IN ( 'version_comment', 'innodb_version' )", OBJECT_K );
return [
'value' => $db_server_version['version_comment']->Value . ' v' . $db_server_version['innodb_version']->Value,
];
}
/**
* Get write permissions.
*
* Check whether the required folders has writing permissions.
*
* @since 1.9.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value Writing permissions status.
* @type bool $warning Whether to display a warning. True if some required
* folders don't have writing permissions, False otherwise.
* }
*/
public function get_write_permissions() {
$paths_to_check = [
ABSPATH => 'WordPress root directory',
];
$write_problems = [];
$wp_upload_dir = wp_upload_dir();
if ( $wp_upload_dir['error'] ) {
$write_problems[] = 'WordPress root uploads directory';
}
$elementor_uploads_path = $wp_upload_dir['basedir'] . '/elementor';
if ( is_dir( $elementor_uploads_path ) ) {
$paths_to_check[ $elementor_uploads_path ] = 'Elementor uploads directory';
}
$htaccess_file = ABSPATH . '/.htaccess';
if ( file_exists( $htaccess_file ) ) {
$paths_to_check[ $htaccess_file ] = '.htaccess file';
}
foreach ( $paths_to_check as $dir => $description ) {
if ( ! is_writable( $dir ) ) {
$write_problems[] = $description;
}
}
if ( $write_problems ) {
$value = 'There are some writing permissions issues with the following directories/files:' . "\n\t\t - ";
$value .= implode( "\n\t\t - ", $write_problems );
} else {
$value = 'All right';
}
return [
'value' => $value,
'warning' => ! ! $write_problems,
];
}
/**
* Check for elementor library connectivity.
*
* Check whether the remote elementor library is reachable.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value The status of elementor library connectivity.
* @type bool $warning Whether to display a warning. True if elementor
* * library is not reachable, False otherwise.
* }
*/
public function get_elementor_library() {
$response = Leo_Helper::wp_remote_get(
Api::$api_info_url, [
'timeout' => 5,
'body' => [
// Which API version is used
'api_version' => LEOELEMENTS_VERSION,
// Which language to return
'site_lang' => get_bloginfo( 'language' ),
],
]
);
if ( Leo_Helper::is_wp_error( $response ) ) {
return [
'value' => 'Not connected (' . $response->get_error_message() . ')',
'warning' => true,
];
}
$http_response_code = wp_remote_retrieve_response_code( $response );
if ( 200 !== (int) $http_response_code ) {
$error_msg = 'HTTP Error (' . $http_response_code . ')';
return [
'value' => 'Not connected (' . $error_msg . ')',
'warning' => true,
];
}
$info_data = json_decode( wp_remote_retrieve_body( $response ), true );
if ( empty( $info_data ) ) {
return [
'value' => 'Not connected (Returns invalid JSON)',
'warning' => true,
];
}
return [
'value' => 'Connected',
];
}
}

View File

@@ -0,0 +1,274 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements\System_Info\Classes;
use LeoElements\System_Info\Classes\Abstracts\Base_Reporter;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor theme report.
*
* Elementor system report handler class responsible for generating a report for
* the theme.
*
* @since 1.0.0
*/
class Theme_Reporter extends Base_Reporter {
/**
* Theme.
*
* Holds the sites theme object.
*
* @since 1.0.0
* @access private
*
* @var \WP_Theme WordPress theme object.
*/
private $theme = null;
/**
* Get theme reporter title.
*
* Retrieve theme reporter title.
*
* @since 1.0.0
* @access public
*
* @return string Reporter title.
*/
public function get_title() {
return 'Theme';
}
/**
* Get theme report fields.
*
* Retrieve the required fields for the theme report.
*
* @since 1.0.0
* @access public
*
* @return array Required report fields with field ID and field label.
*/
public function get_fields() {
$fields = [
'name' => 'Name',
'version' => 'Version',
'author' => 'Author',
'is_child_theme' => 'Child Theme',
];
if ( $this->get_parent_theme() ) {
$parent_fields = [
'parent_name' => 'Parent Theme Name',
'parent_version' => 'Parent Theme Version',
'parent_author' => 'Parent Theme Author',
];
$fields = array_merge( $fields, $parent_fields );
}
return $fields;
}
/**
* Get theme.
*
* Retrieve the theme.
*
* @since 1.0.0
* @access protected
*
* @return \WP_Theme WordPress theme object.
*/
protected function _get_theme() {
if ( is_null( $this->theme ) ) {
$this->theme = wp_get_theme();
}
return $this->theme;
}
/**
* Get parent theme.
*
* Retrieve the parent theme.
*
* @since 1.0.0
* @access protected
*
* @return \WP_Theme|false WordPress theme object, or false if the current theme is not a child theme.
*/
protected function get_parent_theme() {
return $this->_get_theme()->parent();
}
/**
* Get theme name.
*
* Retrieve the theme name.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value The theme name.
* }
*/
public function get_name() {
return [
'value' => $this->_get_theme()->get( 'Name' ),
];
}
/**
* Get theme author.
*
* Retrieve the theme author.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value The theme author.
* }
*/
public function get_author() {
return [
'value' => $this->_get_theme()->get( 'Author' ),
];
}
/**
* Get theme version.
*
* Retrieve the theme version.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value The theme version.
* }
*/
public function get_version() {
return [
'value' => $this->_get_theme()->get( 'Version' ),
];
}
/**
* Is the theme is a child theme.
*
* Whether the theme is a child theme.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value Yes if the theme is a child theme, No otherwise.
* @type string $recommendation Theme source code modification recommendation.
* }
*/
public function get_is_child_theme() {
$is_child_theme = is_child_theme();
$result = [
'value' => $is_child_theme ? 'Yes' : 'No',
];
if ( ! $is_child_theme ) {
$result['recommendation'] = sprintf(
/* translators: %s: Codex URL */
Leo_Helper::_x( 'If you want to modify the source code of your theme, we recommend using a <a href="%s">child theme</a>.', 'System Info', 'elementor' ),
'https://codex.wordpress.org/Child_Themes'
);
}
return $result;
}
/**
* Get parent theme version.
*
* Retrieve the parent theme version.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value The parent theme version.
* }
*/
public function get_parent_version() {
return [
'value' => $this->get_parent_theme()->get( 'Version' ),
];
}
/**
* Get parent theme author.
*
* Retrieve the parent theme author.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value The parent theme author.
* }
*/
public function get_parent_author() {
return [
'value' => $this->get_parent_theme()->get( 'Author' ),
];
}
/**
* Get parent theme name.
*
* Retrieve the parent theme name.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value The parent theme name.
* }
*/
public function get_parent_name() {
return [
'value' => $this->get_parent_theme()->get( 'Name' ),
];
}
}

View File

@@ -0,0 +1,133 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements\System_Info\Classes;
use LeoElements\System_Info\Classes\Abstracts\Base_Reporter;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor user report.
*
* Elementor system report handler class responsible for generating a report for
* the user.
*
* @since 1.0.0
*/
class User_Reporter extends Base_Reporter {
/**
* Get user reporter title.
*
* Retrieve user reporter title.
*
* @since 1.0.0
* @access public
*
* @return string Reporter title.
*/
public function get_title() {
return 'User';
}
/**
* Get user report fields.
*
* Retrieve the required fields for the user report.
*
* @since 1.0.0
* @access public
*
* @return array Required report fields with field ID and field label.
*/
public function get_fields() {
return [
'role' => 'Role',
'locale' => 'WP Profile lang',
'agent' => 'User Agent',
];
}
/**
* Get user role.
*
* Retrieve the user role.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value The user role.
* }
*/
public function get_role() {
$role = null;
$current_user = wp_get_current_user();
if ( ! empty( $current_user->roles ) ) {
$role = $current_user->roles[0];
}
return [
'value' => $role,
];
}
/**
* Get user profile language.
*
* Retrieve the user profile language.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value User profile language.
* }
*/
public function get_locale() {
return [
'value' => get_locale(),
];
}
/**
* Get user agent.
*
* Retrieve user agent.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value HTTP user agent.
* }
*/
public function get_agent() {
return [
'value' => Leo_Helper::esc_html( $_SERVER['HTTP_USER_AGENT'] ),
];
}
}

View File

@@ -0,0 +1,329 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements\System_Info\Classes;
use LeoElements\System_Info\Classes\Abstracts\Base_Reporter;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor WordPress environment report.
*
* Elementor system report handler class responsible for generating a report for
* the WordPress environment.
*
* @since 1.0.0
*/
class WordPress_Reporter extends Base_Reporter {
/**
* Get WordPress environment reporter title.
*
* Retrieve WordPress environment reporter title.
*
* @since 1.0.0
* @access public
*
* @return string Reporter title.
*/
public function get_title() {
return 'WordPress Environment';
}
/**
* Get WordPress environment report fields.
*
* Retrieve the required fields for the WordPress environment report.
*
* @since 1.0.0
* @access public
*
* @return array Required report fields with field ID and field label.
*/
public function get_fields() {
return [
'version' => 'Version',
'site_url' => 'Site URL',
'home_url' => 'Home URL',
'is_multisite' => 'WP Multisite',
'max_upload_size' => 'Max Upload Size',
'memory_limit' => 'Memory limit',
'permalink_structure' => 'Permalink Structure',
'language' => 'Language',
'timezone' => 'Timezone',
'admin_email' => 'Admin Email',
'debug_mode' => 'Debug Mode',
];
}
/**
* Get WordPress memory limit.
*
* Retrieve the WordPress memory limit.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value WordPress memory limit.
* @type string $recommendation Recommendation memory limit.
* @type bool $warning Whether to display a warning. True if the limit
* is below the recommended 64M, False otherwise.
* }
*/
public function get_memory_limit() {
$result = [
'value' => ini_get( 'memory_limit' ),
];
$min_recommended_memory = '64M';
$memory_limit_bytes = wp_convert_hr_to_bytes( $result['value'] );
$min_recommended_bytes = wp_convert_hr_to_bytes( $min_recommended_memory );
if ( $memory_limit_bytes < $min_recommended_bytes ) {
$result['recommendation'] = sprintf(
/* translators: 1: Minimum recommended_memory, 2: Codex URL */
Leo_Helper::_x( 'We recommend setting memory to at least %1$s. For more information, read about <a href="%2$s">how to Increase memory allocated to PHP</a>.', 'System Info', 'elementor' ),
$min_recommended_memory,
'https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP'
);
$result['warning'] = true;
}
return $result;
}
/**
* Get WordPress version.
*
* Retrieve the WordPress version.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value WordPress version.
* }
*/
public function get_version() {
return [
'value' => get_bloginfo( 'version' ),
];
}
/**
* Is multisite.
*
* Whether multisite is enabled or not.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value Yes if multisite is enabled, No otherwise.
* }
*/
public function get_is_multisite() {
return [
'value' => is_multisite() ? 'Yes' : 'No',
];
}
/**
* Get site URL.
*
* Retrieve WordPress site URL.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value WordPress site URL.
* }
*/
public function get_site_url() {
return [
'value' => get_site_url(),
];
}
/**
* Get home URL.
*
* Retrieve WordPress home URL.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value WordPress home URL.
* }
*/
public function get_home_url() {
return [
'value' => get_home_url(),
];
}
/**
* Get permalink structure.
*
* Retrieve the permalink structure
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value WordPress permalink structure.
* }
*/
public function get_permalink_structure() {
$wp_rewrite = &$GLOBALS['wp_rewrite'];
$structure = $wp_rewrite->permalink_structure;
if ( ! $structure ) {
$structure = 'Plain';
}
return [
'value' => $structure,
];
}
/**
* Get site language.
*
* Retrieve the site language.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value WordPress site language.
* }
*/
public function get_language() {
return [
'value' => get_bloginfo( 'language' ),
];
}
/**
* Get PHP `max_upload_size`.
*
* Retrieve the value of maximum upload file size defined in `php.ini` configuration file.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value Maximum upload file size allowed.
* }
*/
public function get_max_upload_size() {
return [
'value' => size_format( wp_max_upload_size() ),
];
}
/**
* Get WordPress timezone.
*
* Retrieve WordPress timezone.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value WordPress timezone.
* }
*/
public function get_timezone() {
$timezone = Leo_Helper::get_option( 'timezone_string' );
if ( ! $timezone ) {
$timezone = Leo_Helper::get_option( 'gmt_offset' );
}
return [
'value' => $timezone,
];
}
/**
* Get WordPress administrator email.
*
* Retrieve WordPress administrator email.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value WordPress administrator email.
* }
*/
public function get_admin_email() {
return [
'value' => Leo_Helper::get_option( 'admin_email' ),
];
}
/**
* Get debug mode.
*
* Whether WordPress debug mode is enabled or not.
*
* @since 1.0.0
* @access public
*
* @return array {
* Report data.
*
* @type string $value Active if debug mode is enabled, Inactive otherwise.
* }
*/
public function get_debug_mode() {
return [
'value' => WP_DEBUG ? 'Active' : 'Inactive',
];
}
}

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,84 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements\System_Info\Helpers;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor model helper.
*
* Elementor model helper handler class is responsible for filtering properties.
*
* @since 1.0.0
*/
final class Model_Helper {
/**
* Model helper constructor.
*
* Initializing the model helper class.
*
* @since 1.0.0
* @access private
*/
private function __construct() {}
/**
* Filter possible properties.
*
* Retrieve possible properties filtered by property intersect key.
*
* @since 1.0.0
* @access public
* @static
*
* @param array $possible_properties All the possible properties.
* @param array $properties Properties to filter.
*
* @return array Possible properties filtered by property intersect key.
*/
public static function filter_possible_properties( $possible_properties, $properties ) {
$properties_keys = array_flip( $possible_properties );
return array_intersect_key( $properties, $properties_keys );
}
/**
* Prepare properties.
*
* Combine the possible properties with the user properties and filter them.
*
* @since 1.0.0
* @access public
* @static
*
* @param array $possible_properties All the possible properties.
* @param array $user_properties User properties.
*
* @return array Possible properties and user properties filtered by property intersect key.
*/
public static function prepare_properties( $possible_properties, $user_properties ) {
$properties = array_fill_keys( $possible_properties, null );
$properties = array_merge( $properties, $user_properties );
return self::filter_possible_properties( $possible_properties, $properties );
}
}

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,458 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements\System_Info;
use LeoElements\System_Info\Classes\Abstracts\Base_Reporter;
use LeoElements\System_Info\Helpers\Model_Helper;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor main system info page.
*
* Elementor main system info page handler class responsible for creating system info
* reports and displaying them on WordPress dashboard under Elementor setting.
*
* @since 1.0.0
*/
class Main {
/**
* Required user capabilities.
*
* Holds the user capabilities required to manage Elementor menus.
*
* @since 1.0.0
* @access private
*
* @var string
*/
private $capability = 'manage_options';
/**
* System info settings.
*
* Holds the settings required for Elementor system info page.
*
* @since 1.0.0
* @access private
*
* @var array
*/
private $settings = [];
/**
* Elementor system info reports.
*
* Holds an array of available reports in Elementor system info page.
*
* @since 1.0.0
* @access private
*
* @var array
*/
private static $reports = [
'server' => [],
'wordpress' => [],
'theme' => [],
'user' => [],
'plugins' => [],
'network_plugins' => [],
'mu_plugins' => [],
];
/**
* Main system info page constructor.
*
* Initializing Elementor system info page.
*
* @since 1.0.0
* @access public
*/
public function __construct() {
$this->require_files();
$this->init_settings();
$this->add_actions();
}
/**
* Require files.
*
* Require the needed files for Elementor system info page.
*
* @since 1.0.0
* @access private
*/
private function require_files() {
require __DIR__ . '/classes/abstracts/base-reporter.php';
require __DIR__ . '/helpers/model-helper.php';
}
/**
* Create a report.
*
* Register a new report that will be displayed in Elementor system info page.
*
* @since 1.0.0
* @access public
*
* @param array $properties Report properties.
*
* @return \WP_Error|false|Base_Reporter Base_Reporter instance if the report was created,
* False or WP_Error otherwise.
*/
public function create_reporter( array $properties ) {
$properties = Model_Helper::prepare_properties( $this->get_settings( 'reporter_properties' ), $properties );
$reporter_class = $properties['class_name'] ? $properties['class_name'] : $this->get_reporter_class( $properties['name'] );
$reporter = new $reporter_class( $properties );
if ( ! ( $reporter instanceof Base_Reporter ) ) {
return new \WP_Error( 'Each reporter must to be an instance or sub-instance of `Base_Reporter` class.' );
}
if ( ! $reporter->is_enabled() ) {
return false;
}
return $reporter;
}
/**
* Add actions.
*
* Register filters and actions for the main system info page.
*
* @since 1.0.0
* @access private
*/
private function add_actions() {
Leo_Helper::add_action( 'admin_menu', [ $this, 'register_menu' ], 500 );
Leo_Helper::add_action( 'wp_ajax_elementor_system_info_download_file', [ $this, 'download_file' ] );
}
/**
* Display page.
*
* Output the content for the main system info page.
*
* @since 1.0.0
* @access public
*/
public function display_page() {
$reports_info = self::get_allowed_reports();
$reports = $this->load_reports( $reports_info );
$raw_reports = $this->load_reports( $reports_info, 'raw' );
?>
<div id="elementor-system-info">
<h3><?php echo Leo_Helper::__( 'System Info', 'elementor' ); ?></h3>
<div><?php $this->print_report( $reports, 'html' ); ?></div>
<h3><?php echo Leo_Helper::__( 'Copy & Paste Info', 'elementor' ); ?></h3>
<div id="elementor-system-info-raw">
<label id="elementor-system-info-raw-code-label" for="elementor-system-info-raw-code"><?php echo Leo_Helper::__( 'You can copy the below info as simple text with Ctrl+C / Ctrl+V:', 'elementor' ); ?></label>
<textarea id="elementor-system-info-raw-code" readonly>
<?php
unset( $raw_reports['wordpress']['report']['admin_email'] );
$this->print_report( $raw_reports, 'raw' );
?>
</textarea>
<script>
var textarea = document.getElementById( 'elementor-system-info-raw-code' );
var selectRange = function() {
textarea.setSelectionRange( 0, textarea.value.length );
};
textarea.onfocus = textarea.onblur = textarea.onclick = selectRange;
textarea.onfocus();
</script>
</div>
<hr>
<form action="<?php echo Leo_Helper::admin_url( 'admin-ajax.php' ); ?>" method="post">
<input type="hidden" name="action" value="elementor_system_info_download_file">
<input type="submit" class="button button-primary" value="<?php echo Leo_Helper::__( 'Download System Info', 'elementor' ); ?>">
</form>
</div>
<?php
}
/**
* Download file.
*
* Download the reports files.
*
* Fired by `wp_ajax_elementor_system_info_download_file` action.
*
* @since 1.0.0
* @access public
*/
public function download_file() {
if ( ! current_user_can( $this->capability ) ) {
wp_die( Leo_Helper::__( 'You don\'t have permissions to download this file', 'elementor' ) );
}
$reports_info = self::get_allowed_reports();
$reports = $this->load_reports( $reports_info );
$domain = parse_url( site_url(), PHP_URL_HOST );
header( 'Content-Type: text/plain' );
header( 'Content-Disposition:attachment; filename=system-info-' . $domain . '-' . date( 'd-m-Y' ) . '.txt' );
$this->print_report( $reports );
die;
}
/**
* Get report class.
*
* Retrieve the class of the report for any given report type.
*
* @since 1.0.0
* @access public
*
* @param string $reporter_type The type of the report.
*
* @return string The class of the report.
*/
public function get_reporter_class( $reporter_type ) {
return $this->get_settings( 'namespaces.classes_namespace' ) . '\\' . ucfirst( $reporter_type ) . '_Reporter';
}
/**
* Load reports.
*
* Retrieve the system info reports.
*
* @since 1.0.0
* @access public
*
* @param array $reports An array of system info reports.
* @param string $format - possible values: 'raw' or empty string, meaning 'html'
*
* @return array An array of system info reports.
*/
public function load_reports( $reports, $format = '' ) {
$result = [];
$settings = $this->get_settings();
foreach ( $reports as $report_name => $report_info ) {
if ( ! empty( $report_info['file_name'] ) ) {
$file_name = $report_info['file_name'];
} else {
$file_name = $settings['dirs']['classes'] . $settings['reportFilePrefix'] . str_replace( '_', '-', $report_name ) . '.php';
}
require_once $file_name;
$reporter_params = [
'name' => $report_name,
];
$reporter_params = array_merge( $reporter_params, $report_info );
$reporter = $this->create_reporter( $reporter_params );
if ( ! $reporter instanceof Base_Reporter ) {
continue;
}
$result[ $report_name ] = [
'report' => $reporter->get_report( $format ),
'label' => $reporter->get_title(),
];
if ( ! empty( $report_info['sub'] ) ) {
$result[ $report_name ]['sub'] = $this->load_reports( $report_info['sub'] );
}
}
return $result;
}
/**
* Print report.
*
* Output the system info page reports using an output template.
*
* @since 1.0.0
* @access public
*
* @param array $reports An array of system info reports.
* @param string $template Output type from the templates folder. Available
* templates are `raw` and `html`. Default is `raw`.
*/
public function print_report( $reports, $template = 'raw' ) {
static $tabs_count = 0;
static $required_plugins_properties = [
'Name',
'Version',
'URL',
'Author',
];
$template_path = $this->get_settings( 'dirs.templates' ) . $template . '.php';
require $template_path;
}
/**
* Register admin menu.
*
* Add new Elementor system info admin menu.
*
* Fired by `admin_menu` action.
*
* @since 1.0.0
* @access public
*/
public function register_menu() {
$system_info_text = Leo_Helper::__( 'System Info', 'elementor' );
add_submenu_page(
'elementor',
$system_info_text,
$system_info_text,
$this->capability,
'elementor-system-info',
[ $this, 'display_page' ]
);
}
/**
* Get default settings.
*
* Retrieve the default settings. Used to reset the report settings on
* initialization.
*
* @since 1.0.0
* @access protected
*
* @return array Default settings.
*/
protected function get_default_settings() {
$settings = [];
$reporter_properties = Base_Reporter::get_properties_keys();
array_push( $reporter_properties, 'category', 'name', 'class_name' );
$settings['reporter_properties'] = $reporter_properties;
$base_lib_dir = LEOELEMENTS_PATH . 'includes/settings/system-info/';
$settings['dirs'] = [
'lib' => $base_lib_dir,
'templates' => $base_lib_dir . 'templates/',
'classes' => $base_lib_dir . 'classes/',
'helpers' => $base_lib_dir . 'helpers/',
];
$settings['namespaces'] = [
'namespace' => __NAMESPACE__,
'classes_namespace' => __NAMESPACE__ . '\Classes',
];
$settings['reportFilePrefix'] = '';
return $settings;
}
/**
* Init settings.
*
* Initialize Elementor system info page by setting default settings.
*
* @since 1.0.0
* @access private
*/
private function init_settings() {
$this->settings = $this->get_default_settings();
}
/**
* Get settings.
*
* Retrieve the settings from any given container.
*
* @since 1.0.0
* @access public
*
* @param array $setting Optional. Settings required for Elementor system
* info page. Default is null.
* @param array $container Optional. Container. Default is null.
*
* @return mixed
*/
final public function get_settings( $setting = null, array $container = null ) {
if ( ! $container ) {
$container = $this->settings;
}
if ( $setting ) {
$setting_thread = explode( '.', $setting );
$parent_thread = array_shift( $setting_thread );
if ( $setting_thread ) {
return $this->get_settings( implode( '.', $setting_thread ), $container[ $parent_thread ] );
}
return $container[ $parent_thread ];
}
return $container;
}
/**
* Get allowed reports.
*
* Retrieve the available reports in Elementor system info page.
*
* @since 1.0.0
* @access public
* @static
*
* @return array Available reports in Elementor system info page.
*/
public static function get_allowed_reports() {
return self::$reports;
}
/**
* Add report.
*
* Register a new report to Elementor system info page.
*
* @since 1.4.0
* @access public
* @static
*
* @param string $report_name The name of the report.
* @param array $report_info Report info.
*/
public static function add_report( $report_name, $report_info ) {
self::$reports[ $report_name ] = $report_info;
}
}

View File

@@ -0,0 +1,96 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* @var array $reports
*/
foreach ( $reports as $report_name => $report ) : ?>
<div class="elementor-system-info-section elementor-system-info-<?php echo Leo_Helper::esc_attr( $report_name ); ?>">
<table class="widefat">
<thead>
<tr>
<th><?php echo $report['label']; ?></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
foreach ( $report['report'] as $field_name => $field ) :
if ( in_array( $report_name, [ 'plugins', 'network_plugins', 'mu_plugins' ], true ) ) {
foreach ( $field['value'] as $plugin ) :
?>
<tr>
<td>
<?php
if ( $plugin['PluginURI'] ) :
$plugin_name = "<a href='{$plugin['PluginURI']}'>{$plugin['Name']}</a>";
else :
$plugin_name = $plugin['Name'];
endif;
if ( $plugin['Version'] ) :
$plugin_name .= ' - ' . $plugin['Version'];
endif;
echo $plugin_name;
?>
</td>
<td>
<?php
if ( $plugin['Author'] ) :
if ( $plugin['AuthorURI'] ) :
$author = "<a href='{$plugin['AuthorURI']}'>{$plugin['Author']}</a>";
else :
$author = $plugin['Author'];
endif;
echo "By $author";
endif;
?>
</td>
<td></td>
</tr>
<?php
endforeach;
} else {
$warning_class = ! empty( $field['warning'] ) ? ' class="elementor-warning"' : '';
$log_label = ! empty( $field['label'] ) ? $field['label'] . ':' : '';
?>
<tr<?php echo $warning_class; ?>>
<td><?php echo $log_label; ?></td>
<td><?php echo $field['value']; ?></td>
<td><?php
if ( ! empty( $field['recommendation'] ) ) :
echo $field['recommendation'];
endif;
?>
</td>
</tr>
<?php
}
endforeach;
?>
</tbody>
</table>
</div>
<?php
endforeach;

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,76 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* @var array $reports
* @var array $required_plugins_properties
* @var int $tabs_count
*/
$tabs_count++;
$required_plugins_properties = array_flip( $required_plugins_properties );
unset( $required_plugins_properties['Name'] );
foreach ( $reports as $report_name => $report ) :
$indent = str_repeat( "\t", $tabs_count - 1 );
$is_plugins = in_array( $report_name, [
'plugins',
'network_plugins',
'mu_plugins',
] );
if ( ! $is_plugins ) :
echo PHP_EOL . $indent . '== ' . $report['label'] . ' ==';
endif;
echo PHP_EOL;
foreach ( $report['report'] as $field_name => $field ) :
$sub_indent = str_repeat( "\t", $tabs_count );
if ( $is_plugins ) {
echo "== {$field['label']} ==" . PHP_EOL;
foreach ( $field['value'] as $plugin ) :
$plugin_properties = array_intersect_key( $plugin, $required_plugins_properties );
echo $sub_indent . $plugin['Name'];
foreach ( $plugin_properties as $property_name => $property ) :
echo PHP_EOL . "{$sub_indent}\t{$property_name}: {$property}";
endforeach;
echo PHP_EOL . PHP_EOL;
endforeach;
} else {
echo "{$sub_indent}{$field['label']}: {$field['value']}" . PHP_EOL;
}
endforeach;
if ( ! empty( $report['sub'] ) ) :
$this->print_report( $report['sub'], $template, true );
endif;
endforeach;
$tabs_count--;

View File

@@ -0,0 +1,301 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor "Tools" page in WordPress Dashboard.
*
* Elementor settings page handler class responsible for creating and displaying
* Elementor "Tools" page in WordPress dashboard.
*
* @since 1.0.0
*/
class Tools extends Settings_Page {
/**
* Settings page ID for Elementor tools.
*/
const PAGE_ID = 'elementor-tools';
/**
* Register admin menu.
*
* Add new Elementor Tools admin menu.
*
* Fired by `admin_menu` action.
*
* @since 1.0.0
* @access public
*/
public function register_admin_menu() {
add_submenu_page(
Settings::PAGE_ID,
Leo_Helper::__( 'Tools', 'elementor' ),
Leo_Helper::__( 'Tools', 'elementor' ),
'manage_options',
self::PAGE_ID,
[ $this, 'display_settings_page' ]
);
}
/**
* Clear cache.
*
* Delete post meta containing the post CSS file data. And delete the actual
* CSS files from the upload directory.
*
* Fired by `wp_ajax_elementor_clear_cache` action.
*
* @since 1.0.0
* @access public
*/
public function ajax_elementor_clear_cache() {
check_ajax_referer( 'elementor_clear_cache', '_nonce' );
Plugin::$instance->files_manager->clear_cache();
wp_send_json_success();
}
/**
* Replace URLs.
*
* Sends an ajax request to replace old URLs to new URLs. This method also
* updates all the Elementor data.
*
* Fired by `wp_ajax_elementor_replace_url` action.
*
* @since 1.1.0
* @access public
*/
public function ajax_elementor_replace_url() {
$post = $GLOBALS['_POST'];
check_ajax_referer( 'elementor_replace_url', '_nonce' );
$from = ! empty( $post['from'] ) ? $post['from'] : '';
$to = ! empty( $post['to'] ) ? $post['to'] : '';
try {
$results = Utils::replace_urls( $from, $to );
wp_send_json_success( $results );
} catch ( \Exception $e ) {
wp_send_json_error( $e->getMessage() );
}
}
/**
* Elementor version rollback.
*
* Rollback to previous Elementor version.
*
* Fired by `admin_post_elementor_rollback` action.
*
* @since 1.5.0
* @access public
*/
public function post_elementor_rollback() {
check_admin_referer( 'elementor_rollback' );
$plugin_slug = basename( LEOELEMENTS__FILE__, '.php' );
$rollback = new Rollback(
[
'version' => LEOELEMENTS_PREVIOUS_STABLE_VERSION,
'plugin_name' => LEOELEMENTS_PLUGIN_BASE,
'plugin_slug' => $plugin_slug,
'package_url' => sprintf( 'https://downloads.wordpress.org/plugin/%s.%s.zip', $plugin_slug, LEOELEMENTS_PREVIOUS_STABLE_VERSION ),
]
);
$rollback->run();
wp_die(
'', Leo_Helper::__( 'Rollback to Previous Version', 'elementor' ), [
'response' => 200,
]
);
}
/**
* Tools page constructor.
*
* Initializing Elementor "Tools" page.
*
* @since 1.0.0
* @access public
*/
public function __construct() {
parent::__construct();
Leo_Helper::add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 205 );
$post = $GLOBALS['_POST'];
if ( ! empty( $post ) ) {
Leo_Helper::add_action( 'wp_ajax_elementor_clear_cache', [ $this, 'ajax_elementor_clear_cache' ] );
Leo_Helper::add_action( 'wp_ajax_elementor_replace_url', [ $this, 'ajax_elementor_replace_url' ] );
}
Leo_Helper::add_action( 'admin_post_elementor_rollback', [ $this, 'post_elementor_rollback' ] );
}
/**
* Create tabs.
*
* Return the tools page tabs, sections and fields.
*
* @since 1.5.0
* @access protected
*
* @return array An array with the page tabs, sections and fields.
*/
protected function create_tabs() {
return [
'general' => [
'label' => Leo_Helper::__( 'General', 'elementor' ),
'sections' => [
'tools' => [
'fields' => [
'clear_cache' => [
'label' => Leo_Helper::__( 'Regenerate CSS', 'elementor' ),
'field_args' => [
'type' => 'raw_html',
'html' => sprintf( '<button data-nonce="%s" class="button elementor-button-spinner" id="elementor-clear-cache-button">%s</button>', wp_create_nonce( 'elementor_clear_cache' ), Leo_Helper::__( 'Regenerate Files', 'elementor' ) ),
'desc' => Leo_Helper::__( 'Styles set in Elementor are saved in CSS files in the uploads folder. Recreate those files, according to the most recent settings.', 'elementor' ),
],
],
'reset_api_data' => [
'label' => Leo_Helper::__( 'Sync Library', 'elementor' ),
'field_args' => [
'type' => 'raw_html',
'html' => sprintf( '<button data-nonce="%s" class="button elementor-button-spinner" id="elementor-library-sync-button">%s</button>', wp_create_nonce( 'elementor_reset_library' ), Leo_Helper::__( 'Sync Library', 'elementor' ) ),
'desc' => Leo_Helper::__( 'Elementor Library automatically updates on a daily basis. You can also manually update it by clicking on the sync button.', 'elementor' ),
],
],
],
],
],
],
'replace_url' => [
'label' => Leo_Helper::__( 'Replace URL', 'elementor' ),
'sections' => [
'replace_url' => [
'callback' => function() {
$intro_text = sprintf(
/* translators: %s: Codex URL */
Leo_Helper::__( '<strong>Important:</strong> It is strongly recommended that you <a target="_blank" href="%s">backup your database</a> before using Replace URL.', 'elementor' ),
'https://codex.wordpress.org/WordPress_Backups'
);
$intro_text = '<div>' . $intro_text . '</div>';
echo '<h2>' . Leo_Helper::esc_html__( 'Replace URL', 'elementor' ) . '</h2>';
echo $intro_text;
},
'fields' => [
'replace_url' => [
'label' => Leo_Helper::__( 'Update Site Address (URL)', 'elementor' ),
'field_args' => [
'type' => 'raw_html',
'html' => sprintf( '<input type="text" name="from" placeholder="http://old-url.com" class="medium-text"><input type="text" name="to" placeholder="http://new-url.com" class="medium-text"><button data-nonce="%s" class="button elementor-button-spinner" id="elementor-replace-url-button">%s</button>', wp_create_nonce( 'elementor_replace_url' ), Leo_Helper::__( 'Replace URL', 'elementor' ) ),
'desc' => Leo_Helper::__( 'Enter your old and new URLs for your WordPress installation, to update all Elementor data (Relevant for domain transfers or move to \'HTTPS\').', 'elementor' ),
],
],
],
],
],
],
'versions' => [
'label' => Leo_Helper::__( 'Version Control', 'elementor' ),
'sections' => [
'rollback' => [
'label' => Leo_Helper::__( 'Rollback to Previous Version', 'elementor' ),
'callback' => function() {
$intro_text = sprintf(
/* translators: %s: Elementor version */
Leo_Helper::__( 'Experiencing an issue with Elementor version %s? Rollback to a previous version before the issue appeared.', 'elementor' ),
LEOELEMENTS_VERSION
);
$intro_text = '<p>' . $intro_text . '</p>';
echo $intro_text;
},
'fields' => [
'rollback' => [
'label' => Leo_Helper::__( 'Rollback Version', 'elementor' ),
'field_args' => [
'type' => 'raw_html',
'html' => sprintf(
'<a href="%s" class="button elementor-button-spinner elementor-rollback-button">%s</a>',
wp_nonce_url( Leo_Helper::admin_url( 'admin-post.php?action=elementor_rollback' ), 'elementor_rollback' ),
sprintf(
/* translators: %s: Elementor previous stable version */
Leo_Helper::__( 'Reinstall v%s', 'elementor' ),
LEOELEMENTS_PREVIOUS_STABLE_VERSION
)
),
'desc' => '<span style="color: red;">' . Leo_Helper::__( 'Warning: Please backup your database before making the rollback.', 'elementor' ) . '</span>',
],
],
],
],
'beta' => [
'label' => Leo_Helper::__( 'Become a Beta Tester', 'elementor' ),
'callback' => function() {
$intro_text = Leo_Helper::__( 'Turn-on Beta Tester, to get notified when a new beta version of Elementor or E-Pro is available. The Beta version will not install automatically. You always have the option to ignore it.', 'elementor' );
$intro_text = '<p>' . $intro_text . '</p>';
$newsletter_opt_in_text = sprintf( Leo_Helper::__( 'Click <a id="beta-tester-first-to-know" href="%s">here</a> to join our First-To-Know email updates', 'elementor' ), '#' );
echo $intro_text;
echo $newsletter_opt_in_text;
},
'fields' => [
'beta' => [
'label' => Leo_Helper::__( 'Beta Tester', 'elementor' ),
'field_args' => [
'type' => 'select',
'default' => 'no',
'options' => [
'no' => Leo_Helper::__( 'Disable', 'elementor' ),
'yes' => Leo_Helper::__( 'Enable', 'elementor' ),
],
'desc' => '<span style="color: red;">' . Leo_Helper::__( 'Please Note: We do not recommend updating to a beta version on production sites.', 'elementor' ) . '</span>',
],
],
],
],
],
],
];
}
/**
* Get tools page title.
*
* Retrieve the title for the tools page.
*
* @since 1.5.0
* @access protected
*
* @return string Tools page title.
*/
protected function get_page_title() {
return Leo_Helper::__( 'Tools', 'elementor' );
}
}

View File

@@ -0,0 +1,108 @@
<?php
/**
* 2007-2022 Leotheme
*
* NOTICE OF LICENSE
*
* LeoElements is module help you can build content for your shop
*
* DISCLAIMER
*
* @author Leotheme <leotheme@gmail.com>
* @copyright 2007-2022 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
namespace LeoElements;
use LeoElements\Leo_Helper;
if ( ! defined( '_PS_VERSION_' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor settings validations.
*
* Elementor settings validations handler class is responsible for validating settings
* fields.
*
* @since 1.0.0
*/
class Settings_Validations {
/**
* Validate HTML field.
*
* Sanitize content for allowed HTML tags and remove backslashes before quotes.
*
* @since 1.0.0
* @access public
* @static
*
* @param string $input Input field.
*
* @return string Input field.
*/
public static function html( $input ) {
return stripslashes( wp_filter_post_kses( addslashes( $input ) ) );
}
/**
* Validate checkbox list.
*
* Make sure that an empty checkbox list field will return an array.
*
* @since 1.0.0
* @access public
* @static
*
* @param mixed $input Input field.
*
* @return mixed Input field.
*/
public static function checkbox_list( $input ) {
if ( empty( $input ) ) {
$input = [];
}
return $input;
}
/**
* Current Time
*
* Used to return current time
*
* @since 1.0.0
* @access public
* @static
*
* @param mixed $input Input field.
*
* @return int
*/
public static function current_time( $input ) {
return time();
}
/**
* Clear cache.
*
* Delete post meta containing the post CSS file data. And delete the actual
* CSS files from the upload directory.
*
* @since 1.4.8
* @access public
* @static
*
* @param mixed $input Input field.
*
* @return mixed Input field.
*/
public static function clear_cache( $input ) {
Plugin::$instance->files_manager->clear_cache();
return $input;
}
}