JFIF $ d d 7 * Z qn )ZP 0 !1 A "#a$2Qr D8 a Ri [f \m I ykI w0 c u F c Rı?lO7 к _f˓ [C $殷WF< _W ԣ s Kc ëI zyQy /_LK ℂ ;C",p F A : /] =H ~ , l s / 9 ć: [=/#f ; ) x { ٛE Q )~ = 𘙲r*2~ a _V = ' ku m F D } KYYC )( { * g& f `툪 r y ` = ^ c J. I ]( * `wq 1dđ #̩ ͑ 0 ; H ] u 搂 @:~ ו K L N s h } O I R* 8 :2 ! lD JV o ( 3 = M ( z Ȱ+i *N A r6K n S l ) ! J J Ӂ* % ݉?|D } d5: eP0 R; {$X' x F @ .ÊB {,WJ uQ ɲRI ;9 Q E琯 6 2fT .DU J ;*c P A\IL Nj! J ۱+ O\ ͔ ] ޒ S J ȧ c%A N ol ՎprU L Zԛe r E2= X D Xg VQeӓ k y P7 U* o m Q I s ,K `) 6\G3t?pgjr m ۛجw luGt f h 9uyP 0D;Uڽ"OXl i f $ ) &|ML 0 Z rm1 [ H XP l P R0 'G=i 2N +0 e 2 ]] 9 VT P O 7 h(F * 癈 ' = Q VZD F,d ߬ ~ T X G[ `le 69C R(!S2! P < 0 x < !1AQ "Raq 02Br #S CTb ? Ζ "]mH5WR 7 k.ۛ ! } Q~ + yԏ z |@ T20 S~ K e k *zF f^2X *( @ 8 r ? C I uI|֓>^Ex LgNU Y+{.R Ѫ τV YT D I 6 2 '8Y2 7'\T P.6 d &˦ @V q i |8 -O Ε ] ʔ U= T L 8= ;6c | !qfF3 a ů& ~$ l} 'NW U s$U k^S V : U#6w + +s &r+n ڐ { @ 29gL u " T Ù M=6 (^ "7 r}=6Yݾ lC u hquymp Ǧ G jhs ǜNl ɻ} o 7 #S6 a w 4 ! OS r D 5 7 % | ?x> L | / nD 6?/8 w # [ ) L 7 +6〼T A T g ! %5 Mm Z /c -{1_Je "| ^$ 'O & ޱմ < H vNqϡQ$ < 6 &Nݛ ֨tǻN (9 n ru~'όN sMG& ,uH Kw *Ī 5@ u6 BԒ i YN * f 0 _ GhKW u lT <nj- 0{ M L~ | /a v\ E = ?1 \ɟuq Ђ Y O a K ޡP q $ H8o Q˼EV ~ k 0 h' L Pp M -M" m^ !6l nմ 쮝C U T . ! :vMǨb h ډ Vc r @~p # !1QAa q ? AL0L x LU 4 d ; x " 16ad0 7.\ߋ 0 = P l v/ " c A Ay A|2pO8"d MV #1] = \ " ˡ ] k v I9 d ۓ & q ) ǐq E ꞅ v "P )q X &Q З non]я u ג./ ; gZ$ M QР 2M ]h ni 0 P $ێ 3CɏGjώy : m c # S_ l@ '_ \m|C 2`K _ 1 cIvGc $? PCQ S+D ? K aײ k Fr b 8 ύ NEدg ĝ U 3 6 #Ik+ v { v i ( ވ ? a e) X xy/*@Q Ǽ Ծ ) $ IWO l c G; !i k{ gOŀ L ('x T rb $ w) R $ & N1E td U3Uȉ1p M"N* (DNy d96.(jQ) X 5 c QɎMy W ? Q *!R > 6=7)Xj 5`J ] e 8%t ! + ' ! 1Q 5 !1 AQaq ё #2 "0BRb ? G t^ ## .l lQ T $ v , ,m 㵜5u bV =sY+ @d { N ! dn O < .- B; _w J t 6;Q Jd. Q c%p{ 1 ,sND dF H I0 Гo X ш e黅X ۢ F :)[ F G X ƹ / w _c MeD ,ʡc c . W D tA $ j@ : ) - #u c1< @ۗ9F ) KJ- hpP] _ x [ q B lb p ʖ w q " LFGd ƶ * s +ډ_Zc " ? % t[I P 6 J ]# =ɺ V v v CGs Gh1 > )6 |e y ? L ӣ m,4 G W Ui ` ] uJVo VDG< SB 6ϏQ @ TiU l y O U 0 kfV ~ ~}S Z @ *WU Ui ## ; s /[ = ! 7}" W N ] ' (L ! ~ y5 g9T̅J kbM' +s :S +B) v @ M j e C f j E 0 Y\Qn z G 1 д~ W o{T 9?` Rm yhsy3 !HAD ] m c1 ~ 2 L S u7x T ;j$ `} 4-> L# vzŏ I L S ֭ T { r jGK C ; b pU= - ` Bs K. S F w4 M q] Z dH S 0 ) tLg
<?php
namespace Elementor\Core\Editor;
use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
use Elementor\Core\Common\Modules\Ajax\Module;
use Elementor\Core\Debug\Loading_Inspection_Manager;
use Elementor\Core\Editor\Loader\Editor_Loader_Factory;
use Elementor\Core\Editor\Loader\Editor_Loader_Interface;
use Elementor\Core\Settings\Manager as SettingsManager;
use Elementor\Plugin;
use Elementor\TemplateLibrary\Source_Local;
use Elementor\Utils;
use Elementor\Core\Editor\Data;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor editor.
*
* Elementor editor handler class is responsible for initializing Elementor
* editor and register all the actions needed to display the editor.
*
* @since 1.0.0
*/
class Editor {
/**
* User capability required to access Elementor editor.
*/
const EDITING_CAPABILITY = 'edit_posts';
/**
* Post ID.
*
* Holds the ID of the current post being edited.
*
* @since 1.0.0
* @access private
*
* @var int Post ID.
*/
private $post_id;
/**
* Whether the edit mode is active.
*
* Used to determine whether we are in edit mode.
*
* @since 1.0.0
* @access private
*
* @var bool Whether the edit mode is active.
*/
private $is_edit_mode;
/**
* @var Notice_Bar
*/
public $notice_bar;
/**
* @var Promotion
*/
public $promotion;
/**
* @var Editor_Loader_Interface
*/
private $loader;
/**
* Init.
*
* Initialize Elementor editor. Registers all needed actions to run Elementor,
* removes conflicting actions etc.
*
* Fired by `admin_action_elementor` action.
*
* @since 1.0.0
* @access public
*
* @param bool $to_die Optional. Whether to die at the end. Default is `true`.
*/
public function init( $to_die = true ) {
if ( empty( $_REQUEST['post'] ) ) {
return;
}
$this->set_post_id( absint( $_REQUEST['post'] ) );
if ( ! $this->is_edit_mode( $this->post_id ) ) {
return;
}
// BC: From 2.9.0, the editor shouldn't handle the global post / current document.
// Use requested id and not the global in order to avoid conflicts with plugins that changes the global post.
query_posts( [
'p' => $this->post_id,
'post_type' => get_post_type( $this->post_id ),
] );
Plugin::$instance->db->switch_to_post( $this->post_id );
$document = Plugin::$instance->documents->get( $this->post_id );
Plugin::$instance->documents->switch_to_document( $document );
// Change mode to Builder
$document->set_is_built_with_elementor( true );
// End BC.
Loading_Inspection_Manager::instance()->register_inspections();
// Send MIME Type header like WP admin-header.
@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
self::send_document_isolation_policy_header();
add_filter( 'show_admin_bar', '__return_false' );
// Remove all WordPress actions
remove_all_actions( 'wp_head' );
remove_all_actions( 'wp_print_styles' );
remove_all_actions( 'wp_print_head_scripts' );
remove_all_actions( 'wp_footer' );
// Handle `wp_head`
add_action( 'wp_head', 'wp_enqueue_scripts', 1 );
add_action( 'wp_head', 'wp_print_styles', 8 );
add_action( 'wp_head', 'wp_print_head_scripts', 9 );
add_action( 'wp_head', 'wp_site_icon' );
add_action( 'wp_head', [ $this, 'editor_head_trigger' ], 30 );
// Handle `wp_footer`
add_action( 'wp_footer', 'wp_print_footer_scripts', 20 );
add_action( 'wp_footer', 'wp_auth_check_html', 30 );
add_action( 'wp_footer', [ $this, 'wp_footer' ] );
// Handle `wp_enqueue_scripts`
remove_all_actions( 'wp_enqueue_scripts' );
// Also remove all scripts hooked into after_wp_tiny_mce.
remove_all_actions( 'after_wp_tiny_mce' );
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ], 999999 );
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_styles' ], 999999 );
// Setup default heartbeat options
add_filter( 'heartbeat_settings', function( $settings ) {
$settings['interval'] = 15;
return $settings;
} );
// Tell to WP Cache plugins do not cache this request.
Utils::do_not_cache();
do_action( 'elementor/editor/init' );
$this->get_loader()->print_root_template();
// From the action it's an empty string, from tests its `false`
if ( false !== $to_die ) {
die;
}
}
/**
* Retrieve post ID.
*
* Get the ID of the current post.
*
* @since 1.8.0
* @access public
*
* @return int Post ID.
*/
public function get_post_id() {
return $this->post_id;
}
/**
* Redirect to new URL.
*
* Used as a fallback function for the old URL structure of Elementor page
* edit URL.
*
* Fired by `template_redirect` action.
*
* @since 1.6.0
* @access public
*/
public function redirect_to_new_url() {
if ( ! isset( $_GET['elementor'] ) ) {
return;
}
$document = Plugin::$instance->documents->get( get_the_ID() );
if ( ! $document ) {
wp_die( esc_html__( 'Document not found.', 'elementor' ) );
}
if ( ! $document->is_editable_by_current_user() || ! $document->is_built_with_elementor() ) {
return;
}
wp_safe_redirect( $document->get_edit_url() );
die;
}
/**
* Whether the edit mode is active.
*
* Used to determine whether we are in the edit mode.
*
* @since 1.0.0
* @access public
*
* @param int $post_id Optional. Post ID. Default is `null`, the current
* post ID.
*
* @return bool Whether the edit mode is active.
*/
public function is_edit_mode( $post_id = null ) {
if ( null !== $this->is_edit_mode ) {
return $this->is_edit_mode;
}
if ( empty( $post_id ) ) {
$post_id = $this->post_id;
}
$document = Plugin::$instance->documents->get( $post_id );
if ( ! $document || ! $document->is_editable_by_current_user() ) {
return false;
}
/** @var Module ajax */
$ajax_data = Plugin::$instance->common->get_component( 'ajax' )->get_current_action_data();
if ( ! empty( $ajax_data ) && 'get_document_config' === $ajax_data['action'] ) {
return true;
}
// Ajax request as Editor mode
$actions = [
'elementor',
// Templates
'elementor_get_templates',
'elementor_save_template',
'elementor_get_template',
'elementor_delete_template',
'elementor_import_template',
'elementor_library_direct_actions',
];
if ( isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], $actions ) ) {
return true;
}
return false;
}
/**
* Lock post.
*
* Mark the post as currently being edited by the current user.
*
* @since 1.0.0
* @access public
*
* @param int $post_id The ID of the post being edited.
*/
public function lock_post( $post_id ) {
if ( ! function_exists( 'wp_set_post_lock' ) ) {
require_once ABSPATH . 'wp-admin/includes/post.php';
}
wp_set_post_lock( $post_id );
}
/**
* Get locked user.
*
* Check what user is currently editing the post.
*
* @since 1.0.0
* @access public
*
* @param int $post_id The ID of the post being edited.
*
* @return \WP_User|false User information or false if the post is not locked.
*/
public function get_locked_user( $post_id ) {
if ( ! function_exists( 'wp_check_post_lock' ) ) {
require_once ABSPATH . 'wp-admin/includes/post.php';
}
$locked_user = wp_check_post_lock( $post_id );
if ( ! $locked_user ) {
return false;
}
return get_user_by( 'id', $locked_user );
}
/**
* NOTICE: This method not in use, it's here for backward compatibility.
*
* Print Editor Template.
*
* Include the wrapper template of the editor.
*
* @since 2.2.0
* @access public
*/
public function print_editor_template() {
include ELEMENTOR_PATH . 'includes/editor-templates/editor-wrapper.php';
}
/**
* Enqueue scripts.
*
* Registers all the editor scripts and enqueues them.
*
* @since 1.0.0
* @access public
*/
public function enqueue_scripts() {
remove_action( 'wp_enqueue_scripts', [ $this, __FUNCTION__ ], 999999 );
global $wp_styles, $wp_scripts;
// Reset global variable
$wp_styles = new \WP_Styles(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$wp_scripts = new \WP_Scripts(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$this->get_loader()->register_scripts();
/**
* Before editor enqueue scripts.
*
* Fires before Elementor editor scripts are enqueued.
*
* @since 1.0.0
*/
do_action( 'elementor/editor/before_enqueue_scripts' );
// Tweak for WP Admin menu icons
wp_print_styles( 'editor-buttons' );
$this->get_loader()->enqueue_scripts();
Plugin::$instance->controls_manager->enqueue_control_scripts();
/**
* After editor enqueue scripts.
*
* Fires after Elementor editor scripts are enqueued.
*
* @since 1.0.0
*/
do_action( 'elementor/editor/after_enqueue_scripts' );
}
/**
* Enqueue styles.
*
* Registers all the editor styles and enqueues them.
*
* @since 1.0.0
* @access public
*/
public function enqueue_styles() {
/**
* Before editor enqueue styles.
*
* Fires before Elementor editor styles are enqueued.
*
* @since 1.0.0
*/
do_action( 'elementor/editor/before_enqueue_styles' );
$this->get_loader()->register_styles();
$this->get_loader()->enqueue_styles();
$this->enqueue_theme_ui_styles();
$breakpoints = Plugin::$instance->breakpoints->get_breakpoints();
// The two breakpoints under 'tablet' need to be checked for values.
if ( $breakpoints[ Breakpoints_Manager::BREAKPOINT_KEY_MOBILE ]->is_custom() || $breakpoints[ Breakpoints_Manager::BREAKPOINT_KEY_MOBILE_EXTRA ]->is_enabled() ) {
wp_add_inline_style(
'elementor-editor',
'.elementor-device-tablet #elementor-preview-responsive-wrapper { width: ' . Plugin::$instance->breakpoints->get_device_min_breakpoint( Breakpoints_Manager::BREAKPOINT_KEY_TABLET ) . 'px; }'
);
}
/**
* After editor enqueue styles.
*
* Fires after Elementor editor styles are enqueued.
*
* @since 1.0.0
*/
do_action( 'elementor/editor/after_enqueue_styles' );
}
private function enqueue_theme_ui_styles() {
$ui_theme_selected = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
$ui_themes = [
'light',
'dark',
];
if ( 'auto' === $ui_theme_selected || ! in_array( $ui_theme_selected, $ui_themes, true ) ) {
$ui_light_theme_media_queries = '(prefers-color-scheme: light)';
$ui_dark_theme_media_queries = '(prefers-color-scheme: dark)';
} else {
$ui_light_theme_media_queries = 'none';
$ui_dark_theme_media_queries = 'none';
if ( 'light' === $ui_theme_selected ) {
$ui_light_theme_media_queries = 'all';
} elseif ( 'dark' === $ui_theme_selected ) {
$ui_dark_theme_media_queries = 'all';
}
}
$this->enqueue_theme_ui( 'light', $ui_light_theme_media_queries );
$this->enqueue_theme_ui( 'dark', $ui_dark_theme_media_queries );
}
private function enqueue_theme_ui( $ui_theme, $ui_theme_media_queries = 'all' ) {
$suffix = Utils::is_script_debug() ? '' : '.min';
wp_enqueue_style(
'e-theme-ui-' . $ui_theme,
ELEMENTOR_ASSETS_URL . 'css/theme-' . $ui_theme . $suffix . '.css',
[],
ELEMENTOR_VERSION,
$ui_theme_media_queries
);
}
/**
* Editor head trigger.
*
* Fires the 'elementor/editor/wp_head' action in the head tag in Elementor
* editor.
*
* @since 1.0.0
* @access public
*/
public function editor_head_trigger() {
/**
* Elementor editor head.
*
* Fires on Elementor editor head tag.
*
* Used to prints scripts or any other data in the head tag.
*
* @since 1.0.0
*/
do_action( 'elementor/editor/wp_head' );
}
/**
* WP footer.
*
* Prints Elementor editor with all the editor templates, and render controls,
* widgets and content elements.
*
* Fired by `wp_footer` action.
*
* @since 1.0.0
* @access public
*/
public function wp_footer() {
$plugin = Plugin::$instance;
$plugin->controls_manager->render_controls();
$plugin->widgets_manager->render_widgets_content();
$plugin->elements_manager->render_elements_content();
$plugin->dynamic_tags->print_templates();
$this->get_loader()->register_additional_templates();
/**
* Elementor editor footer.
*
* Fires on Elementor editor before closing the body tag.
*
* Used to prints scripts or any other HTML before closing the body tag.
*
* @since 1.0.0
*/
do_action( 'elementor/editor/footer' );
}
/**
* Set edit mode.
*
* Used to update the edit mode.
*
* @since 1.0.0
* @access public
*
* @param bool $edit_mode Whether the edit mode is active.
*/
public function set_edit_mode( $edit_mode ) {
$this->is_edit_mode = $edit_mode;
}
/**
* Editor constructor.
*
* Initializing Elementor editor and redirect from old URL structure of
* Elementor editor.
*
* @since 1.0.0
* @access public
*/
public function __construct() {
Plugin::$instance->data_manager_v2->register_controller( new Data\Globals\Controller() );
$this->notice_bar = new Notice_Bar();
$this->promotion = new Promotion();
add_action( 'admin_action_elementor', [ $this, 'init' ] );
add_action( 'template_redirect', [ $this, 'redirect_to_new_url' ] );
// Handle autocomplete feature for URL control.
add_filter( 'wp_link_query_args', [ $this, 'filter_wp_link_query_args' ] );
add_filter( 'wp_link_query', [ $this, 'filter_wp_link_query' ] );
add_filter( 'replace_editor', [ $this, 'filter_replace_editor' ], 10, 2 );
}
/**
* Whether the Document-Isolation-Policy header should be sent on the
* Elementor editor screen and the editor preview iframe.
*
* DIP places the document in its own agent cluster, which is the prerequisite
* for cross-origin isolation features such as SharedArrayBuffer (required by
* WordPress core's client-side media processing introduced in WP 7.1).
*
* Both the editor parent document and the preview iframe must send the same
* DIP header so they join the same agent cluster and synchronous DOM access
* between them (e.g. `iframe.contentWindow.elementorFrontend`) keeps working.
*
* The header is only honored by browsers on a secure context (HTTPS or
* localhost) so the helper short-circuits on insecure origins to avoid
* sending a header that the browser will ignore.
*
* @since 4.1.0
*
* @return bool
*/
public static function should_use_document_isolation_policy() {
if ( ! is_ssl() ) {
$raw_host = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '';
$host = strtolower( (string) strtok( $raw_host, ':' ) );
if ( 'localhost' !== $host && ! str_ends_with( $host, '.localhost' ) ) {
return false;
}
}
/**
* Filters whether Elementor sends the Document-Isolation-Policy header
* on the editor screen and preview iframe.
*
* @since 4.1.0
*
* @param bool $enabled Whether DIP is enabled. Defaults to true on a secure context.
*/
return (bool) apply_filters( 'elementor/editor/use_document_isolation_policy', true );
}
/**
* Send the Document-Isolation-Policy header for the current response.
*
* Safe to call from both the Elementor editor screen handler and the
* preview iframe handler. No-op when {@see self::should_use_document_isolation_policy()}
* returns false.
*
* @since 4.1.0
*/
public static function send_document_isolation_policy_header() {
if ( ! self::should_use_document_isolation_policy() || headers_sent() ) {
return;
}
header( 'Document-Isolation-Policy: isolate-and-credentialless' );
}
/**
* Signals to WordPress that Elementor is replacing the block editor on its own editor page,
* so that block-editor-specific behaviour (e.g. WP 7.0 COOP/COEP isolation headers) is not
* applied when the Elementor editor is active.
*
* @param bool $replace Whether the editor is being replaced.
* @param \WP_Post $post The post being edited.
*
* @return bool
*/
public function filter_replace_editor( $replace, $post ) {
if ( isset( $_REQUEST['action'] ) && 'elementor' === $_REQUEST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return true;
}
return $replace;
}
/**
* @since 2.2.0
* @access public
*/
public function filter_wp_link_query_args( $query ) {
$library_cpt_key = array_search( Source_Local::CPT, $query['post_type'], true );
if ( false !== $library_cpt_key ) {
unset( $query['post_type'][ $library_cpt_key ] );
}
return $query;
}
/**
* @since 2.2.0
* @access public
*/
public function filter_wp_link_query( $results ) {
// PHPCS - The user data is not used.
if ( isset( $_POST['editor'] ) && 'elementor' === $_POST['editor'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
$post_type_object = get_post_type_object( 'post' );
$post_label = $post_type_object->labels->singular_name;
foreach ( $results as & $result ) {
if ( 'post' === get_post_type( $result['ID'] ) ) {
$result['info'] = $post_label;
}
}
}
return $results;
}
public function set_post_id( $post_id ) {
$this->post_id = $post_id;
}
/**
* Get loader.
*
* @return Editor_Loader_Interface
*/
private function get_loader() {
if ( ! $this->loader ) {
$this->loader = Editor_Loader_Factory::create();
$this->loader->init();
}
return $this->loader;
}
/**
* Get elements presets.
*
* @return array
*/
public function get_elements_presets() {
$element_types = Plugin::$instance->elements_manager->get_element_types();
$presets = [];
foreach ( $element_types as $el_type => $element ) {
$this->check_element_for_presets( $element, $el_type, $presets );
}
return $presets;
}
/**
* @return void
*/
private function check_element_for_presets( $element, $el_type, &$presets ) {
$element_presets = $element->get_panel_presets();
if ( empty( $element_presets ) ) {
return;
}
foreach ( $element_presets as $key => $preset ) {
$this->maybe_add_preset( $el_type, $preset, $key, $presets );
}
}
/**
* @return void
*/
private function maybe_add_preset( $el_type, $preset, $key, &$presets ) {
if ( $this->is_valid_preset( $el_type, $preset ) ) {
$presets[ $key ] = $preset;
}
}
/**
* @return boolean
*/
private function is_valid_preset( $el_type, $preset ) {
return isset( $preset['replacements']['custom']['originalWidget'] )
&& $el_type === $preset['replacements']['custom']['originalWidget'];
}
}