| 1 |
<?php |
| 2 |
namespace Elementor\Core\Editor; |
| 3 |
|
| 4 |
use Elementor\Api; |
| 5 |
use Elementor\Core\Common\Modules\Ajax\Module; |
| 6 |
use Elementor\Core\Common\Modules\Ajax\Module as Ajax; |
| 7 |
use Elementor\Core\Debug\Loading_Inspection_Manager; |
| 8 |
use Elementor\Core\Files\Assets\Files_Upload_Handler; |
| 9 |
use Elementor\Core\Responsive\Responsive; |
| 10 |
use Elementor\Core\Schemes\Manager as Schemes_Manager; |
| 11 |
use Elementor\Core\Settings\Manager as SettingsManager; |
| 12 |
use Elementor\Icons_Manager; |
| 13 |
use Elementor\Plugin; |
| 14 |
use Elementor\Settings; |
| 15 |
use Elementor\Shapes; |
| 16 |
use Elementor\TemplateLibrary\Source_Local; |
| 17 |
use Elementor\Tools; |
| 18 |
use Elementor\User; |
| 19 |
use Elementor\Utils; |
| 20 |
use Elementor\Core\Editor\Data; |
| 21 |
|
| 22 |
if ( ! defined( 'ABSPATH' ) ) { |
| 23 |
exit; // Exit if accessed directly. |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Elementor editor. |
| 28 |
* |
| 29 |
* Elementor editor handler class is responsible for initializing Elementor |
| 30 |
* editor and register all the actions needed to display the editor. |
| 31 |
* |
| 32 |
* @since 1.0.0 |
| 33 |
*/ |
| 34 |
class Editor { |
| 35 |
|
| 36 |
/** |
| 37 |
* The nonce key for Elementor editor. |
| 38 |
* @deprecated 2.3.0 |
| 39 |
*/ |
| 40 |
const EDITING_NONCE_KEY = 'elementor-editing'; |
| 41 |
|
| 42 |
/** |
| 43 |
* User capability required to access Elementor editor. |
| 44 |
*/ |
| 45 |
const EDITING_CAPABILITY = 'edit_posts'; |
| 46 |
|
| 47 |
/** |
| 48 |
* Post ID. |
| 49 |
* |
| 50 |
* Holds the ID of the current post being edited. |
| 51 |
* |
| 52 |
* @since 1.0.0 |
| 53 |
* @access private |
| 54 |
* |
| 55 |
* @var int Post ID. |
| 56 |
*/ |
| 57 |
private $post_id; |
| 58 |
|
| 59 |
/** |
| 60 |
* Whether the edit mode is active. |
| 61 |
* |
| 62 |
* Used to determine whether we are in edit mode. |
| 63 |
* |
| 64 |
* @since 1.0.0 |
| 65 |
* @access private |
| 66 |
* |
| 67 |
* @var bool Whether the edit mode is active. |
| 68 |
*/ |
| 69 |
private $is_edit_mode; |
| 70 |
|
| 71 |
/** |
| 72 |
* @var Notice_Bar |
| 73 |
*/ |
| 74 |
public $notice_bar; |
| 75 |
|
| 76 |
/** |
| 77 |
* Init. |
| 78 |
* |
| 79 |
* Initialize Elementor editor. Registers all needed actions to run Elementor, |
| 80 |
* removes conflicting actions etc. |
| 81 |
* |
| 82 |
* Fired by `admin_action_elementor` action. |
| 83 |
* |
| 84 |
* @since 1.0.0 |
| 85 |
* @access public |
| 86 |
* |
| 87 |
* @param bool $die Optional. Whether to die at the end. Default is `true`. |
| 88 |
*/ |
| 89 |
public function init( $die = true ) { |
| 90 |
if ( empty( $_REQUEST['post'] ) ) { |
| 91 |
return; |
| 92 |
} |
| 93 |
|
| 94 |
$this->set_post_id( absint( $_REQUEST['post'] ) ); |
| 95 |
|
| 96 |
if ( ! $this->is_edit_mode( $this->post_id ) ) { |
| 97 |
return; |
| 98 |
} |
| 99 |
|
| 100 |
// BC: From 2.9.0, the editor shouldn't handle the global post / current document. |
| 101 |
// Use requested id and not the global in order to avoid conflicts with plugins that changes the global post. |
| 102 |
query_posts( [ |
| 103 |
'p' => $this->post_id, |
| 104 |
'post_type' => get_post_type( $this->post_id ), |
| 105 |
] ); |
| 106 |
|
| 107 |
Plugin::$instance->db->switch_to_post( $this->post_id ); |
| 108 |
|
| 109 |
$document = Plugin::$instance->documents->get( $this->post_id ); |
| 110 |
|
| 111 |
Plugin::$instance->documents->switch_to_document( $document ); |
| 112 |
|
| 113 |
// Change mode to Builder |
| 114 |
Plugin::$instance->db->set_is_elementor_page( $this->post_id ); |
| 115 |
|
| 116 |
// End BC. |
| 117 |
|
| 118 |
Loading_Inspection_Manager::instance()->register_inspections(); |
| 119 |
|
| 120 |
// Send MIME Type header like WP admin-header. |
| 121 |
@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); |
| 122 |
|
| 123 |
// Temp: Allow plugins to know that the editor route is ready. TODO: Remove on 2.7.3. |
| 124 |
define( 'ELEMENTOR_EDITOR_USE_ROUTER', true ); |
| 125 |
|
| 126 |
add_filter( 'show_admin_bar', '__return_false' ); |
| 127 |
|
| 128 |
// Remove all WordPress actions |
| 129 |
remove_all_actions( 'wp_head' ); |
| 130 |
remove_all_actions( 'wp_print_styles' ); |
| 131 |
remove_all_actions( 'wp_print_head_scripts' ); |
| 132 |
remove_all_actions( 'wp_footer' ); |
| 133 |
|
| 134 |
// Handle `wp_head` |
| 135 |
add_action( 'wp_head', 'wp_enqueue_scripts', 1 ); |
| 136 |
add_action( 'wp_head', 'wp_print_styles', 8 ); |
| 137 |
add_action( 'wp_head', 'wp_print_head_scripts', 9 ); |
| 138 |
add_action( 'wp_head', 'wp_site_icon' ); |
| 139 |
add_action( 'wp_head', [ $this, 'editor_head_trigger' ], 30 ); |
| 140 |
|
| 141 |
// Handle `wp_footer` |
| 142 |
add_action( 'wp_footer', 'wp_print_footer_scripts', 20 ); |
| 143 |
add_action( 'wp_footer', 'wp_auth_check_html', 30 ); |
| 144 |
add_action( 'wp_footer', [ $this, 'wp_footer' ] ); |
| 145 |
|
| 146 |
// Handle `wp_enqueue_scripts` |
| 147 |
remove_all_actions( 'wp_enqueue_scripts' ); |
| 148 |
|
| 149 |
// Also remove all scripts hooked into after_wp_tiny_mce. |
| 150 |
remove_all_actions( 'after_wp_tiny_mce' ); |
| 151 |
|
| 152 |
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ], 999999 ); |
| 153 |
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_styles' ], 999999 ); |
| 154 |
|
| 155 |
// Setup default heartbeat options |
| 156 |
add_filter( 'heartbeat_settings', function( $settings ) { |
| 157 |
$settings['interval'] = 15; |
| 158 |
return $settings; |
| 159 |
} ); |
| 160 |
|
| 161 |
// Tell to WP Cache plugins do not cache this request. |
| 162 |
Utils::do_not_cache(); |
| 163 |
|
| 164 |
do_action( 'elementor/editor/init' ); |
| 165 |
|
| 166 |
$this->print_editor_template(); |
| 167 |
|
| 168 |
// From the action it's an empty string, from tests its `false` |
| 169 |
if ( false !== $die ) { |
| 170 |
die; |
| 171 |
} |
| 172 |
} |
| 173 |
|
| 174 |
/** |
| 175 |
* Retrieve post ID. |
| 176 |
* |
| 177 |
* Get the ID of the current post. |
| 178 |
* |
| 179 |
* @since 1.8.0 |
| 180 |
* @access public |
| 181 |
* |
| 182 |
* @return int Post ID. |
| 183 |
*/ |
| 184 |
public function get_post_id() { |
| 185 |
return $this->post_id; |
| 186 |
} |
| 187 |
|
| 188 |
/** |
| 189 |
* Redirect to new URL. |
| 190 |
* |
| 191 |
* Used as a fallback function for the old URL structure of Elementor page |
| 192 |
* edit URL. |
| 193 |
* |
| 194 |
* Fired by `template_redirect` action. |
| 195 |
* |
| 196 |
* @since 1.6.0 |
| 197 |
* @access public |
| 198 |
*/ |
| 199 |
public function redirect_to_new_url() { |
| 200 |
if ( ! isset( $_GET['elementor'] ) ) { |
| 201 |
return; |
| 202 |
} |
| 203 |
|
| 204 |
$document = Plugin::$instance->documents->get( get_the_ID() ); |
| 205 |
|
| 206 |
if ( ! $document ) { |
| 207 |
wp_die( __( 'Document not found.', 'elementor' ) ); |
| 208 |
} |
| 209 |
|
| 210 |
if ( ! $document->is_editable_by_current_user() || ! $document->is_built_with_elementor() ) { |
| 211 |
return; |
| 212 |
} |
| 213 |
|
| 214 |
wp_safe_redirect( $document->get_edit_url() ); |
| 215 |
die; |
| 216 |
} |
| 217 |
|
| 218 |
/** |
| 219 |
* Whether the edit mode is active. |
| 220 |
* |
| 221 |
* Used to determine whether we are in the edit mode. |
| 222 |
* |
| 223 |
* @since 1.0.0 |
| 224 |
* @access public |
| 225 |
* |
| 226 |
* @param int $post_id Optional. Post ID. Default is `null`, the current |
| 227 |
* post ID. |
| 228 |
* |
| 229 |
* @return bool Whether the edit mode is active. |
| 230 |
*/ |
| 231 |
public function is_edit_mode( $post_id = null ) { |
| 232 |
if ( null !== $this->is_edit_mode ) { |
| 233 |
return $this->is_edit_mode; |
| 234 |
} |
| 235 |
|
| 236 |
if ( empty( $post_id ) ) { |
| 237 |
$post_id = $this->post_id; |
| 238 |
} |
| 239 |
|
| 240 |
$document = Plugin::$instance->documents->get( $post_id ); |
| 241 |
|
| 242 |
if ( ! $document || ! $document->is_editable_by_current_user() ) { |
| 243 |
return false; |
| 244 |
} |
| 245 |
|
| 246 |
/** @var Module ajax */ |
| 247 |
$ajax_data = Plugin::$instance->common->get_component( 'ajax' )->get_current_action_data(); |
| 248 |
|
| 249 |
if ( ! empty( $ajax_data ) && 'get_document_config' === $ajax_data['action'] ) { |
| 250 |
return true; |
| 251 |
} |
| 252 |
|
| 253 |
// Ajax request as Editor mode |
| 254 |
$actions = [ |
| 255 |
'elementor', |
| 256 |
|
| 257 |
// Templates |
| 258 |
'elementor_get_templates', |
| 259 |
'elementor_save_template', |
| 260 |
'elementor_get_template', |
| 261 |
'elementor_delete_template', |
| 262 |
'elementor_import_template', |
| 263 |
'elementor_library_direct_actions', |
| 264 |
]; |
| 265 |
|
| 266 |
if ( isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], $actions ) ) { |
| 267 |
return true; |
| 268 |
} |
| 269 |
|
| 270 |
return false; |
| 271 |
} |
| 272 |
|
| 273 |
/** |
| 274 |
* Lock post. |
| 275 |
* |
| 276 |
* Mark the post as currently being edited by the current user. |
| 277 |
* |
| 278 |
* @since 1.0.0 |
| 279 |
* @access public |
| 280 |
* |
| 281 |
* @param int $post_id The ID of the post being edited. |
| 282 |
*/ |
| 283 |
public function lock_post( $post_id ) { |
| 284 |
if ( ! function_exists( 'wp_set_post_lock' ) ) { |
| 285 |
require_once ABSPATH . 'wp-admin/includes/post.php'; |
| 286 |
} |
| 287 |
|
| 288 |
wp_set_post_lock( $post_id ); |
| 289 |
} |
| 290 |
|
| 291 |
/** |
| 292 |
* Get locked user. |
| 293 |
* |
| 294 |
* Check what user is currently editing the post. |
| 295 |
* |
| 296 |
* @since 1.0.0 |
| 297 |
* @access public |
| 298 |
* |
| 299 |
* @param int $post_id The ID of the post being edited. |
| 300 |
* |
| 301 |
* @return \WP_User|false User information or false if the post is not locked. |
| 302 |
*/ |
| 303 |
public function get_locked_user( $post_id ) { |
| 304 |
if ( ! function_exists( 'wp_check_post_lock' ) ) { |
| 305 |
require_once ABSPATH . 'wp-admin/includes/post.php'; |
| 306 |
} |
| 307 |
|
| 308 |
$locked_user = wp_check_post_lock( $post_id ); |
| 309 |
if ( ! $locked_user ) { |
| 310 |
return false; |
| 311 |
} |
| 312 |
|
| 313 |
return get_user_by( 'id', $locked_user ); |
| 314 |
} |
| 315 |
|
| 316 |
/** |
| 317 |
* Print Editor Template. |
| 318 |
* |
| 319 |
* Include the wrapper template of the editor. |
| 320 |
* |
| 321 |
* @since 2.2.0 |
| 322 |
* @access public |
| 323 |
*/ |
| 324 |
public function print_editor_template() { |
| 325 |
include ELEMENTOR_PATH . 'includes/editor-templates/editor-wrapper.php'; |
| 326 |
} |
| 327 |
|
| 328 |
/** |
| 329 |
* Enqueue scripts. |
| 330 |
* |
| 331 |
* Registers all the editor scripts and enqueues them. |
| 332 |
* |
| 333 |
* @since 1.0.0 |
| 334 |
* @access public |
| 335 |
*/ |
| 336 |
public function enqueue_scripts() { |
| 337 |
remove_action( 'wp_enqueue_scripts', [ $this, __FUNCTION__ ], 999999 ); |
| 338 |
|
| 339 |
global $wp_styles, $wp_scripts; |
| 340 |
|
| 341 |
$plugin = Plugin::$instance; |
| 342 |
|
| 343 |
// Reset global variable |
| 344 |
$wp_styles = new \WP_Styles(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 345 |
$wp_scripts = new \WP_Scripts(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 346 |
|
| 347 |
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'ELEMENTOR_TESTS' ) && ELEMENTOR_TESTS ) ? '' : '.min'; |
| 348 |
|
| 349 |
wp_register_script( |
| 350 |
'elementor-editor-modules', |
| 351 |
ELEMENTOR_ASSETS_URL . 'js/editor-modules' . $suffix . '.js', |
| 352 |
[ |
| 353 |
'elementor-common-modules', |
| 354 |
], |
| 355 |
ELEMENTOR_VERSION, |
| 356 |
true |
| 357 |
); |
| 358 |
|
| 359 |
wp_register_script( |
| 360 |
'elementor-editor-document', |
| 361 |
ELEMENTOR_ASSETS_URL . 'js/editor-document' . $suffix . '.js', |
| 362 |
[ |
| 363 |
'elementor-common-modules', |
| 364 |
], |
| 365 |
ELEMENTOR_VERSION, |
| 366 |
true |
| 367 |
); |
| 368 |
// Hack for waypoint with editor mode. |
| 369 |
wp_register_script( |
| 370 |
'elementor-waypoints', |
| 371 |
ELEMENTOR_ASSETS_URL . 'lib/waypoints/waypoints-for-editor.js', |
| 372 |
[ |
| 373 |
'jquery', |
| 374 |
], |
| 375 |
'4.0.2', |
| 376 |
true |
| 377 |
); |
| 378 |
|
| 379 |
wp_register_script( |
| 380 |
'perfect-scrollbar', |
| 381 |
ELEMENTOR_ASSETS_URL . 'lib/perfect-scrollbar/js/perfect-scrollbar' . $suffix . '.js', |
| 382 |
[], |
| 383 |
'1.4.0', |
| 384 |
true |
| 385 |
); |
| 386 |
|
| 387 |
wp_register_script( |
| 388 |
'jquery-easing', |
| 389 |
ELEMENTOR_ASSETS_URL . 'lib/jquery-easing/jquery-easing' . $suffix . '.js', |
| 390 |
[ |
| 391 |
'jquery', |
| 392 |
], |
| 393 |
'1.3.2', |
| 394 |
true |
| 395 |
); |
| 396 |
|
| 397 |
wp_register_script( |
| 398 |
'nprogress', |
| 399 |
ELEMENTOR_ASSETS_URL . 'lib/nprogress/nprogress' . $suffix . '.js', |
| 400 |
[], |
| 401 |
'0.2.0', |
| 402 |
true |
| 403 |
); |
| 404 |
|
| 405 |
wp_register_script( |
| 406 |
'tipsy', |
| 407 |
ELEMENTOR_ASSETS_URL . 'lib/tipsy/tipsy' . $suffix . '.js', |
| 408 |
[ |
| 409 |
'jquery', |
| 410 |
], |
| 411 |
'1.0.0', |
| 412 |
true |
| 413 |
); |
| 414 |
|
| 415 |
wp_register_script( |
| 416 |
'jquery-elementor-select2', |
| 417 |
ELEMENTOR_ASSETS_URL . 'lib/e-select2/js/e-select2.full' . $suffix . '.js', |
| 418 |
[ |
| 419 |
'jquery', |
| 420 |
], |
| 421 |
'4.0.6-rc.1', |
| 422 |
true |
| 423 |
); |
| 424 |
|
| 425 |
wp_register_script( |
| 426 |
'flatpickr', |
| 427 |
ELEMENTOR_ASSETS_URL . 'lib/flatpickr/flatpickr' . $suffix . '.js', |
| 428 |
[ |
| 429 |
'jquery', |
| 430 |
], |
| 431 |
'1.12.0', |
| 432 |
true |
| 433 |
); |
| 434 |
|
| 435 |
wp_register_script( |
| 436 |
'ace', |
| 437 |
'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.5/ace.js', |
| 438 |
[], |
| 439 |
'1.2.5', |
| 440 |
true |
| 441 |
); |
| 442 |
|
| 443 |
wp_register_script( |
| 444 |
'ace-language-tools', |
| 445 |
'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.5/ext-language_tools.js', |
| 446 |
[ |
| 447 |
'ace', |
| 448 |
], |
| 449 |
'1.2.5', |
| 450 |
true |
| 451 |
); |
| 452 |
|
| 453 |
wp_register_script( |
| 454 |
'jquery-hover-intent', |
| 455 |
ELEMENTOR_ASSETS_URL . 'lib/jquery-hover-intent/jquery-hover-intent' . $suffix . '.js', |
| 456 |
[], |
| 457 |
'1.0.0', |
| 458 |
true |
| 459 |
); |
| 460 |
|
| 461 |
wp_register_script( |
| 462 |
'nouislider', |
| 463 |
ELEMENTOR_ASSETS_URL . 'lib/nouislider/nouislider' . $suffix . '.js', |
| 464 |
[], |
| 465 |
'13.0.0', |
| 466 |
true |
| 467 |
); |
| 468 |
|
| 469 |
wp_register_script( |
| 470 |
'pickr', |
| 471 |
ELEMENTOR_ASSETS_URL . 'lib/pickr/pickr.min.js', |
| 472 |
[], |
| 473 |
'1.5.0', |
| 474 |
true |
| 475 |
); |
| 476 |
|
| 477 |
wp_register_script( |
| 478 |
'elementor-editor', |
| 479 |
ELEMENTOR_ASSETS_URL . 'js/editor' . $suffix . '.js', |
| 480 |
[ |
| 481 |
'elementor-common', |
| 482 |
'elementor-editor-modules', |
| 483 |
'elementor-editor-document', |
| 484 |
'wp-auth-check', |
| 485 |
'jquery-ui-sortable', |
| 486 |
'jquery-ui-resizable', |
| 487 |
'perfect-scrollbar', |
| 488 |
'nprogress', |
| 489 |
'tipsy', |
| 490 |
'imagesloaded', |
| 491 |
'heartbeat', |
| 492 |
'jquery-elementor-select2', |
| 493 |
'flatpickr', |
| 494 |
'ace', |
| 495 |
'ace-language-tools', |
| 496 |
'jquery-hover-intent', |
| 497 |
'nouislider', |
| 498 |
'pickr', |
| 499 |
'react', |
| 500 |
'react-dom', |
| 501 |
], |
| 502 |
ELEMENTOR_VERSION, |
| 503 |
true |
| 504 |
); |
| 505 |
|
| 506 |
/** |
| 507 |
* Before editor enqueue scripts. |
| 508 |
* |
| 509 |
* Fires before Elementor editor scripts are enqueued. |
| 510 |
* |
| 511 |
* @since 1.0.0 |
| 512 |
*/ |
| 513 |
do_action( 'elementor/editor/before_enqueue_scripts' ); |
| 514 |
|
| 515 |
// Tweak for WP Admin menu icons |
| 516 |
wp_print_styles( 'editor-buttons' ); |
| 517 |
|
| 518 |
$settings = SettingsManager::get_settings_managers_config(); |
| 519 |
// Moved to document since 2.9.0. |
| 520 |
unset( $settings['page'] ); |
| 521 |
|
| 522 |
$document = Plugin::$instance->documents->get_doc_or_auto_save( $this->post_id ); |
| 523 |
$kits_manager = Plugin::$instance->kits_manager; |
| 524 |
|
| 525 |
$page_title_selector = $kits_manager->get_current_settings( 'page_title_selector' ); |
| 526 |
|
| 527 |
$page_title_selector .= ', .elementor-page-title'; |
| 528 |
|
| 529 |
$config = [ |
| 530 |
'initial_document' => $document->get_config(), |
| 531 |
'version' => ELEMENTOR_VERSION, |
| 532 |
'home_url' => home_url(), |
| 533 |
'admin_settings_url' => admin_url( 'admin.php?page=' . Settings::PAGE_ID ), |
| 534 |
'autosave_interval' => AUTOSAVE_INTERVAL, |
| 535 |
'tabs' => $plugin->controls_manager->get_tabs(), |
| 536 |
'controls' => $plugin->controls_manager->get_controls_data(), |
| 537 |
'elements' => $plugin->elements_manager->get_element_types_config(), |
| 538 |
'schemes' => [ |
| 539 |
'items' => $plugin->schemes_manager->get_registered_schemes_data(), |
| 540 |
'enabled_schemes' => Schemes_Manager::get_enabled_schemes(), |
| 541 |
], |
| 542 |
'globals' => [ |
| 543 |
'defaults_enabled' => [ |
| 544 |
'colors' => $kits_manager->is_custom_colors_enabled(), |
| 545 |
'typography' => $kits_manager->is_custom_typography_enabled(), |
| 546 |
], |
| 547 |
], |
| 548 |
'icons' => [ |
| 549 |
'libraries' => Icons_Manager::get_icon_manager_tabs_config(), |
| 550 |
'goProURL' => Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=icon-library&utm_campaign=gopro&utm_medium=wp-dash' ), |
| 551 |
], |
| 552 |
'filesUpload' => [ |
| 553 |
'unfilteredFiles' => Files_Upload_Handler::is_enabled(), |
| 554 |
], |
| 555 |
'fa4_to_fa5_mapping_url' => ELEMENTOR_ASSETS_URL . 'lib/font-awesome/migration/mapping.js', |
| 556 |
'default_schemes' => $plugin->schemes_manager->get_schemes_defaults(), |
| 557 |
'settings' => $settings, |
| 558 |
'system_schemes' => $plugin->schemes_manager->get_system_schemes(), |
| 559 |
'wp_editor' => $this->get_wp_editor_config(), |
| 560 |
'settings_page_link' => Settings::get_url(), |
| 561 |
'tools_page_link' => Tools::get_url(), |
| 562 |
'elementor_site' => 'https://go.elementor.com/about-elementor/', |
| 563 |
'docs_elementor_site' => 'https://go.elementor.com/docs/', |
| 564 |
'help_the_content_url' => 'https://go.elementor.com/the-content-missing/', |
| 565 |
'help_right_click_url' => 'https://go.elementor.com/meet-right-click/', |
| 566 |
'help_flexbox_bc_url' => 'https://go.elementor.com/flexbox-layout-bc/', |
| 567 |
'elementPromotionURL' => 'https://go.elementor.com/go-pro-%s', |
| 568 |
'dynamicPromotionURL' => 'https://go.elementor.com/go-pro-dynamic-tag', |
| 569 |
'additional_shapes' => Shapes::get_additional_shapes_for_config(), |
| 570 |
'user' => [ |
| 571 |
'restrictions' => $plugin->role_manager->get_user_restrictions_array(), |
| 572 |
'is_administrator' => current_user_can( 'manage_options' ), |
| 573 |
'introduction' => User::get_introduction_meta(), |
| 574 |
], |
| 575 |
'preview' => [ |
| 576 |
'help_preview_error_url' => 'https://go.elementor.com/preview-not-loaded/', |
| 577 |
'help_preview_http_error_url' => 'https://go.elementor.com/preview-not-loaded/#permissions', |
| 578 |
'help_preview_http_error_500_url' => 'https://go.elementor.com/500-error/', |
| 579 |
'debug_data' => Loading_Inspection_Manager::instance()->run_inspections(), |
| 580 |
], |
| 581 |
'locale' => get_locale(), |
| 582 |
'rich_editing_enabled' => filter_var( get_user_meta( get_current_user_id(), 'rich_editing', true ), FILTER_VALIDATE_BOOLEAN ), |
| 583 |
'page_title_selector' => $page_title_selector, |
| 584 |
'tinymceHasCustomConfig' => class_exists( 'Tinymce_Advanced' ) || class_exists( 'Advanced_Editor_Tools' ), |
| 585 |
'inlineEditing' => Plugin::$instance->widgets_manager->get_inline_editing_config(), |
| 586 |
'dynamicTags' => Plugin::$instance->dynamic_tags->get_config(), |
| 587 |
'ui' => [ |
| 588 |
'darkModeStylesheetURL' => ELEMENTOR_ASSETS_URL . 'css/editor-dark-mode' . $suffix . '.css', |
| 589 |
'defaultGenericFonts' => $kits_manager->get_current_settings( 'default_generic_fonts' ), |
| 590 |
], |
| 591 |
// Legacy Mode - for backwards compatibility of older HTML markup. |
| 592 |
'legacyMode' => [ |
| 593 |
'elementWrappers' => Plugin::instance()->get_legacy_mode( 'elementWrappers' ), |
| 594 |
], |
| 595 |
'i18n' => [ |
| 596 |
'elementor' => __( 'Elementor', 'elementor' ), |
| 597 |
'edit' => __( 'Edit', 'elementor' ), |
| 598 |
'delete' => __( 'Delete', 'elementor' ), |
| 599 |
'cancel' => __( 'Cancel', 'elementor' ), |
| 600 |
'clear' => __( 'Clear', 'elementor' ), |
| 601 |
'done' => __( 'Done', 'elementor' ), |
| 602 |
'got_it' => __( 'Got It', 'elementor' ), |
| 603 |
/* translators: %s: Element type. */ |
| 604 |
'add_element' => __( 'Add %s', 'elementor' ), |
| 605 |
/* translators: %s: Element name. */ |
| 606 |
'edit_element' => __( 'Edit %s', 'elementor' ), |
| 607 |
/* translators: %s: Element type. */ |
| 608 |
'duplicate_element' => __( 'Duplicate %s', 'elementor' ), |
| 609 |
/* translators: %s: Element type. */ |
| 610 |
'delete_element' => __( 'Delete %s', 'elementor' ), |
| 611 |
'flexbox_attention_header' => __( 'Note: Flexbox Changes', 'elementor' ), |
| 612 |
'flexbox_attention_message' => __( 'Elementor 2.5 introduces key changes to the layout using CSS Flexbox. Your existing pages might have been affected, please review your page before publishing.', 'elementor' ), |
| 613 |
'color_picker' => __( 'Color Picker', 'elementor' ), |
| 614 |
|
| 615 |
// Global Styles |
| 616 |
'new_global_color' => __( 'New Global Color', 'elementor' ), |
| 617 |
'global_colors_title' => __( 'Global Colors', 'elementor' ), |
| 618 |
'manage_global_colors' => __( 'Manage Global Colors', 'elementor' ), |
| 619 |
'create_global_color' => __( 'Create New Global Color', 'elementor' ), |
| 620 |
'delete_global_color' => __( 'Delete Global Color', 'elementor' ), |
| 621 |
'delete_global_color_info' => __( 'You\'re about to delete a Global Color. Note that if it\'s being used anywhere on your site, it will inherit a default color.', 'elementor' ), |
| 622 |
'global_colors_info' => __( 'Global Colors help you work smarter. Save a color, and use it anywhere throughout your site. Access and edit your global colors by clicking the Manage button.', 'elementor' ), |
| 623 |
'typography' => __( 'Typography', 'elementor' ), |
| 624 |
'new_typography_setting' => __( 'New Typography Setting', 'elementor' ), |
| 625 |
'global_fonts_title' => __( 'Global Fonts', 'elementor' ), |
| 626 |
'manage_global_fonts' => __( 'Manage Global Fonts', 'elementor' ), |
| 627 |
'create_global_font' => __( 'Create New Global Font', 'elementor' ), |
| 628 |
'delete_global_font' => __( 'Delete Global Font', 'elementor' ), |
| 629 |
'delete_global_font_info' => __( 'You\'re about to delete a Global Font. Note that if it\'s being used anywhere on your site, it will inherit a default typography.', 'elementor' ), |
| 630 |
'global_fonts_info' => __( 'Global Fonts help you work smarter. Save a Typography, and use it anywhere throughout your site. Access and edit your Global Fonts by clicking the Manage button.', 'elementor' ), |
| 631 |
'default' => __( 'Default', 'elementor' ), |
| 632 |
'create' => __( 'Create', 'elementor' ), |
| 633 |
'global_color_confirm_text' => __( 'Are you sure you want to create a new Global Color?', 'elementor' ), |
| 634 |
'global_color_already_exists' => __( 'Please note that the same exact color already exists in your Global Colors list. Are you sure you want to create it?', 'elementor' ), |
| 635 |
'global_color_name_already_exists' => __( 'Please note that a color with the same exact name already exists in your Global Colors list. Are you sure you want to create it?', 'elementor' ), |
| 636 |
'global_fonts_confirm_text' => __( 'Are you sure you want to create a new Global Font setting?', 'elementor' ), |
| 637 |
'custom' => __( 'Custom', 'elementor' ), |
| 638 |
|
| 639 |
// Menu. |
| 640 |
'site_settings' => __( 'Site Settings', 'elementor' ), |
| 641 |
'theme_builder' => __( 'Theme Builder', 'elementor' ), |
| 642 |
'user_preferences' => __( 'User Preferences', 'elementor' ), |
| 643 |
'settings' => __( 'Settings', 'elementor' ), |
| 644 |
'more' => __( 'More', 'elementor' ), |
| 645 |
'navigate_from_page' => __( 'Navigate From Page', 'elementor' ), |
| 646 |
'view_page' => __( 'View Page', 'elementor' ), |
| 647 |
'exit_to_dashboard' => __( 'Exit To Dashboard', 'elementor' ), |
| 648 |
|
| 649 |
// Elements. |
| 650 |
'inner_section' => __( 'Inner Section', 'elementor' ), |
| 651 |
|
| 652 |
// Control Order. |
| 653 |
'asc' => __( 'Ascending order', 'elementor' ), |
| 654 |
'desc' => __( 'Descending order', 'elementor' ), |
| 655 |
|
| 656 |
// Clear Page. |
| 657 |
'clear_page' => __( 'Delete All Content', 'elementor' ), |
| 658 |
'dialog_confirm_clear_page' => __( 'Attention: We are going to DELETE ALL CONTENT from this page. Are you sure you want to do that?', 'elementor' ), |
| 659 |
|
| 660 |
// Enable unfiltered file uploads. |
| 661 |
'enable_unfiltered_files_upload' => __( 'Enable Unfiltered File Uploads', 'elementor' ), |
| 662 |
'dialog_confirm_enable_unfiltered_files_upload' => __( 'Before you enable unfiltered files upload, note that this kind of files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.', 'elementor' ), |
| 663 |
|
| 664 |
// Enable fontawesome 5 if needed. |
| 665 |
'enable_fa5' => __( 'Elementor\'s New Icon Library', 'elementor' ), |
| 666 |
'dialog_confirm_enable_fa5' => __( 'Elementor v2.6 includes an upgrade from Font Awesome 4 to 5. In order to continue using icons, be sure to click "Upgrade".', 'elementor' ) . ' <a href="https://go.elementor.com/fontawesome-migration/" target="_blank">' . __( 'Learn More', 'elementor' ) . '</a>', |
| 667 |
|
| 668 |
// Panel Preview Mode. |
| 669 |
'back_to_editor' => __( 'Show Panel', 'elementor' ), |
| 670 |
'preview' => __( 'Hide Panel', 'elementor' ), |
| 671 |
|
| 672 |
// Inline Editing. |
| 673 |
'type_here' => __( 'Type Here', 'elementor' ), |
| 674 |
|
| 675 |
// Library. |
| 676 |
'an_error_occurred' => __( 'An error occurred', 'elementor' ), |
| 677 |
'category' => __( 'Category', 'elementor' ), |
| 678 |
'delete_template' => __( 'Delete Template', 'elementor' ), |
| 679 |
'delete_template_confirm' => __( 'Are you sure you want to delete this template?', 'elementor' ), |
| 680 |
'import_template_dialog_header' => __( 'Import Document Settings', 'elementor' ), |
| 681 |
'import_template_dialog_message' => __( 'Do you want to also import the document settings of the template?', 'elementor' ), |
| 682 |
'import_template_dialog_message_attention' => __( 'Attention: Importing may override previous settings.', 'elementor' ), |
| 683 |
'library' => __( 'Library', 'elementor' ), |
| 684 |
'no' => __( 'No', 'elementor' ), |
| 685 |
'page' => __( 'Page', 'elementor' ), |
| 686 |
/* translators: %s: Template type. */ |
| 687 |
'save_your_template' => __( 'Save Your %s to Library', 'elementor' ), |
| 688 |
'save_your_template_description' => __( 'Your designs will be available for export and reuse on any page or website', 'elementor' ), |
| 689 |
'section' => __( 'Section', 'elementor' ), |
| 690 |
'templates_empty_message' => __( 'This is where your templates should be. Design it. Save it. Reuse it.', 'elementor' ), |
| 691 |
'templates_empty_title' => __( 'Haven’t Saved Templates Yet?', 'elementor' ), |
| 692 |
'templates_no_favorites_message' => __( 'You can mark any pre-designed template as a favorite.', 'elementor' ), |
| 693 |
'templates_no_favorites_title' => __( 'No Favorite Templates', 'elementor' ), |
| 694 |
'templates_no_results_message' => __( 'Please make sure your search is spelled correctly or try a different words.', 'elementor' ), |
| 695 |
'templates_no_results_title' => __( 'No Results Found', 'elementor' ), |
| 696 |
'templates_request_error' => __( 'The following error(s) occurred while processing the request:', 'elementor' ), |
| 697 |
'yes' => __( 'Yes', 'elementor' ), |
| 698 |
'blocks' => __( 'Blocks', 'elementor' ), |
| 699 |
'pages' => __( 'Pages', 'elementor' ), |
| 700 |
'my_templates' => __( 'My Templates', 'elementor' ), |
| 701 |
|
| 702 |
// Incompatible Device. |
| 703 |
'device_incompatible_header' => __( 'Your browser isn\'t compatible', 'elementor' ), |
| 704 |
'device_incompatible_message' => __( 'Your browser isn\'t compatible with all of Elementor\'s editing features. We recommend you switch to another browser like Chrome or Firefox.', 'elementor' ), |
| 705 |
'proceed_anyway' => __( 'Proceed Anyway', 'elementor' ), |
| 706 |
|
| 707 |
// Preview not loaded. |
| 708 |
'learn_more' => __( 'Learn More', 'elementor' ), |
| 709 |
'preview_el_not_found_header' => __( 'Sorry, the content area was not found in your page.', 'elementor' ), |
| 710 |
'preview_el_not_found_message' => __( 'You must call \'the_content\' function in the current template, in order for Elementor to work on this page.', 'elementor' ), |
| 711 |
|
| 712 |
// Gallery. |
| 713 |
'delete_gallery' => __( 'Reset Gallery', 'elementor' ), |
| 714 |
'dialog_confirm_gallery_delete' => __( 'Are you sure you want to reset this gallery?', 'elementor' ), |
| 715 |
/* translators: %s: The number of images. */ |
| 716 |
'gallery_images_selected' => __( '%s Images Selected', 'elementor' ), |
| 717 |
'gallery_no_images_selected' => __( 'No Images Selected', 'elementor' ), |
| 718 |
'insert_media' => __( 'Insert Media', 'elementor' ), |
| 719 |
|
| 720 |
// Take Over. |
| 721 |
/* translators: %s: User name. */ |
| 722 |
'dialog_user_taken_over' => __( '%s has taken over and is currently editing. Do you want to take over this page editing?', 'elementor' ), |
| 723 |
'go_back' => __( 'Go Back', 'elementor' ), |
| 724 |
'take_over' => __( 'Take Over', 'elementor' ), |
| 725 |
|
| 726 |
// Revisions. |
| 727 |
/* translators: %s: Template type. */ |
| 728 |
'dialog_confirm_delete' => __( 'Are you sure you want to remove this %s?', 'elementor' ), |
| 729 |
|
| 730 |
// Saver. |
| 731 |
'before_unload_alert' => __( 'Please note: All unsaved changes will be lost.', 'elementor' ), |
| 732 |
'published' => __( 'Published', 'elementor' ), |
| 733 |
'publish' => __( 'Publish', 'elementor' ), |
| 734 |
'save' => __( 'Save', 'elementor' ), |
| 735 |
'saved' => __( 'Saved', 'elementor' ), |
| 736 |
'update' => __( 'Update', 'elementor' ), |
| 737 |
'enable' => __( 'Enable', 'elementor' ), |
| 738 |
'submit' => __( 'Submit', 'elementor' ), |
| 739 |
'working_on_draft_notification' => __( 'This is just a draft. Play around and when you\'re done - click update.', 'elementor' ), |
| 740 |
'keep_editing' => __( 'Keep Editing', 'elementor' ), |
| 741 |
'have_a_look' => __( 'Have a look', 'elementor' ), |
| 742 |
'view_all_revisions' => __( 'View All Revisions', 'elementor' ), |
| 743 |
'dismiss' => __( 'Dismiss', 'elementor' ), |
| 744 |
'saving_disabled' => __( 'Saving has been disabled until you’re reconnected.', 'elementor' ), |
| 745 |
|
| 746 |
// Ajax |
| 747 |
'server_error' => __( 'Server Error', 'elementor' ), |
| 748 |
'server_connection_lost' => __( 'Connection Lost', 'elementor' ), |
| 749 |
'unknown_error' => __( 'Unknown Error', 'elementor' ), |
| 750 |
|
| 751 |
// Context Menu |
| 752 |
'duplicate' => __( 'Duplicate', 'elementor' ), |
| 753 |
'copy' => __( 'Copy', 'elementor' ), |
| 754 |
'paste' => __( 'Paste', 'elementor' ), |
| 755 |
'copy_style' => __( 'Copy Style', 'elementor' ), |
| 756 |
'paste_style' => __( 'Paste Style', 'elementor' ), |
| 757 |
'reset_style' => __( 'Reset Style', 'elementor' ), |
| 758 |
'save_as_global' => __( 'Save as a Global', 'elementor' ), |
| 759 |
'save_as_block' => __( 'Save as Template', 'elementor' ), |
| 760 |
'new_column' => __( 'Add New Column', 'elementor' ), |
| 761 |
'copy_all_content' => __( 'Copy All Content', 'elementor' ), |
| 762 |
'delete_all_content' => __( 'Delete All Content', 'elementor' ), |
| 763 |
'navigator' => __( 'Navigator', 'elementor' ), |
| 764 |
|
| 765 |
// Right Click Introduction |
| 766 |
'meet_right_click_header' => __( 'Meet Right Click', 'elementor' ), |
| 767 |
'meet_right_click_message' => __( 'Now you can access all editing actions using right click.', 'elementor' ), |
| 768 |
|
| 769 |
// Hotkeys screen |
| 770 |
'keyboard_shortcuts' => __( 'Keyboard Shortcuts', 'elementor' ), |
| 771 |
|
| 772 |
// Deprecated Control |
| 773 |
'deprecated_notice' => __( 'The <strong>%1$s</strong> widget has been deprecated since %2$s %3$s.', 'elementor' ), |
| 774 |
'deprecated_notice_replacement' => __( 'It has been replaced by <strong>%1$s</strong>.', 'elementor' ), |
| 775 |
'deprecated_notice_last' => __( 'Note that %1$s will be completely removed once %2$s %3$s is released.', 'elementor' ), |
| 776 |
|
| 777 |
//Preview Debug |
| 778 |
'preview_debug_link_text' => __( 'Click here for preview debug', 'elementor' ), |
| 779 |
|
| 780 |
'icon_library' => __( 'Icon Library', 'elementor' ), |
| 781 |
'my_libraries' => __( 'My Libraries', 'elementor' ), |
| 782 |
'upload' => __( 'Upload', 'elementor' ), |
| 783 |
'icons_promotion' => __( 'Become a Pro user to upload unlimited font icon folders to your website.', 'elementor' ), |
| 784 |
'go_pro' => __( 'Go Pro', 'elementor' ), |
| 785 |
'custom_positioning' => __( 'Custom Positioning', 'elementor' ), |
| 786 |
|
| 787 |
'element_promotion_dialog_header' => __( '%s Widget', 'elementor' ), |
| 788 |
'element_promotion_dialog_message' => __( 'Use %s widget and dozens more pro features to extend your toolbox and build sites faster and better.', 'elementor' ), |
| 789 |
'see_it_in_action' => __( 'See it in Action', 'elementor' ), |
| 790 |
'dynamic_content' => __( 'Dynamic Content', 'elementor' ), |
| 791 |
'dynamic_promotion_message' => __( 'Create more personalized and dynamic sites by populating data from various sources with dozens of dynamic tags to choose from.', 'elementor' ), |
| 792 |
|
| 793 |
// TODO: Remove. |
| 794 |
'autosave' => __( 'Autosave', 'elementor' ), |
| 795 |
'elementor_docs' => __( 'Documentation', 'elementor' ), |
| 796 |
'reload_page' => __( 'Reload Page', 'elementor' ), |
| 797 |
'session_expired_header' => __( 'Timeout', 'elementor' ), |
| 798 |
'session_expired_message' => __( 'Your session has expired. Please reload the page to continue editing.', 'elementor' ), |
| 799 |
'soon' => __( 'Soon', 'elementor' ), |
| 800 |
'unknown_value' => __( 'Unknown Value', 'elementor' ), |
| 801 |
], |
| 802 |
]; |
| 803 |
|
| 804 |
if ( ! Utils::has_pro() && current_user_can( 'manage_options' ) ) { |
| 805 |
$config['promotionWidgets'] = Api::get_promotion_widgets(); |
| 806 |
} |
| 807 |
|
| 808 |
$this->bc_move_document_filters(); |
| 809 |
|
| 810 |
/** |
| 811 |
* Localize editor settings. |
| 812 |
* |
| 813 |
* Filters the editor localized settings. |
| 814 |
* |
| 815 |
* @since 1.0.0 |
| 816 |
* |
| 817 |
* @param array $config Editor configuration. |
| 818 |
* @param int $post_id The ID of the current post being edited. |
| 819 |
*/ |
| 820 |
$config = apply_filters( 'elementor/editor/localize_settings', $config ); |
| 821 |
|
| 822 |
Utils::print_js_config( 'elementor-editor', 'ElementorConfig', $config ); |
| 823 |
|
| 824 |
wp_enqueue_script( 'elementor-editor' ); |
| 825 |
|
| 826 |
$plugin->controls_manager->enqueue_control_scripts(); |
| 827 |
|
| 828 |
/** |
| 829 |
* After editor enqueue scripts. |
| 830 |
* |
| 831 |
* Fires after Elementor editor scripts are enqueued. |
| 832 |
* |
| 833 |
* @since 1.0.0 |
| 834 |
*/ |
| 835 |
do_action( 'elementor/editor/after_enqueue_scripts' ); |
| 836 |
} |
| 837 |
|
| 838 |
/** |
| 839 |
* Enqueue styles. |
| 840 |
* |
| 841 |
* Registers all the editor styles and enqueues them. |
| 842 |
* |
| 843 |
* @since 1.0.0 |
| 844 |
* @access public |
| 845 |
*/ |
| 846 |
public function enqueue_styles() { |
| 847 |
/** |
| 848 |
* Before editor enqueue styles. |
| 849 |
* |
| 850 |
* Fires before Elementor editor styles are enqueued. |
| 851 |
* |
| 852 |
* @since 1.0.0 |
| 853 |
*/ |
| 854 |
do_action( 'elementor/editor/before_enqueue_styles' ); |
| 855 |
|
| 856 |
$suffix = Utils::is_script_debug() ? '' : '.min'; |
| 857 |
|
| 858 |
$direction_suffix = is_rtl() ? '-rtl' : ''; |
| 859 |
|
| 860 |
wp_register_style( |
| 861 |
'font-awesome', |
| 862 |
ELEMENTOR_ASSETS_URL . 'lib/font-awesome/css/font-awesome' . $suffix . '.css', |
| 863 |
[], |
| 864 |
'4.7.0' |
| 865 |
); |
| 866 |
|
| 867 |
wp_register_style( |
| 868 |
'elementor-select2', |
| 869 |
ELEMENTOR_ASSETS_URL . 'lib/e-select2/css/e-select2' . $suffix . '.css', |
| 870 |
[], |
| 871 |
'4.0.6-rc.1' |
| 872 |
); |
| 873 |
|
| 874 |
wp_register_style( |
| 875 |
'google-font-roboto', |
| 876 |
'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700', |
| 877 |
[], |
| 878 |
ELEMENTOR_VERSION |
| 879 |
); |
| 880 |
|
| 881 |
wp_register_style( |
| 882 |
'flatpickr', |
| 883 |
ELEMENTOR_ASSETS_URL . 'lib/flatpickr/flatpickr' . $suffix . '.css', |
| 884 |
[], |
| 885 |
'1.12.0' |
| 886 |
); |
| 887 |
|
| 888 |
wp_register_style( |
| 889 |
'pickr', |
| 890 |
ELEMENTOR_ASSETS_URL . 'lib/pickr/themes/monolith.min.css', |
| 891 |
[], |
| 892 |
'1.5.0' |
| 893 |
); |
| 894 |
|
| 895 |
wp_register_style( |
| 896 |
'elementor-editor', |
| 897 |
ELEMENTOR_ASSETS_URL . 'css/editor' . $direction_suffix . $suffix . '.css', |
| 898 |
[ |
| 899 |
'elementor-common', |
| 900 |
'elementor-select2', |
| 901 |
'elementor-icons', |
| 902 |
'wp-auth-check', |
| 903 |
'google-font-roboto', |
| 904 |
'flatpickr', |
| 905 |
'pickr', |
| 906 |
], |
| 907 |
ELEMENTOR_VERSION |
| 908 |
); |
| 909 |
|
| 910 |
wp_enqueue_style( 'elementor-editor' ); |
| 911 |
|
| 912 |
$ui_theme = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' ); |
| 913 |
|
| 914 |
if ( 'light' !== $ui_theme ) { |
| 915 |
$ui_theme_media_queries = 'all'; |
| 916 |
|
| 917 |
if ( 'auto' === $ui_theme ) { |
| 918 |
$ui_theme_media_queries = '(prefers-color-scheme: dark)'; |
| 919 |
} |
| 920 |
|
| 921 |
wp_enqueue_style( |
| 922 |
'elementor-editor-dark-mode', |
| 923 |
ELEMENTOR_ASSETS_URL . 'css/editor-dark-mode' . $suffix . '.css', |
| 924 |
[ |
| 925 |
'elementor-editor', |
| 926 |
], |
| 927 |
ELEMENTOR_VERSION, |
| 928 |
$ui_theme_media_queries |
| 929 |
); |
| 930 |
} |
| 931 |
|
| 932 |
if ( Responsive::has_custom_breakpoints() ) { |
| 933 |
$breakpoints = Responsive::get_breakpoints(); |
| 934 |
|
| 935 |
wp_add_inline_style( 'elementor-editor', '.elementor-device-tablet #elementor-preview-responsive-wrapper { width: ' . $breakpoints['md'] . 'px; }' ); |
| 936 |
} |
| 937 |
|
| 938 |
/** |
| 939 |
* After editor enqueue styles. |
| 940 |
* |
| 941 |
* Fires after Elementor editor styles are enqueued. |
| 942 |
* |
| 943 |
* @since 1.0.0 |
| 944 |
*/ |
| 945 |
do_action( 'elementor/editor/after_enqueue_styles' ); |
| 946 |
} |
| 947 |
|
| 948 |
/** |
| 949 |
* Get WordPress editor config. |
| 950 |
* |
| 951 |
* Config the default WordPress editor with custom settings for Elementor use. |
| 952 |
* |
| 953 |
* @since 1.9.0 |
| 954 |
* @access private |
| 955 |
*/ |
| 956 |
private function get_wp_editor_config() { |
| 957 |
// Remove all TinyMCE plugins. |
| 958 |
remove_all_filters( 'mce_buttons', 10 ); |
| 959 |
remove_all_filters( 'mce_external_plugins', 10 ); |
| 960 |
|
| 961 |
if ( ! class_exists( '\_WP_Editors', false ) ) { |
| 962 |
require ABSPATH . WPINC . '/class-wp-editor.php'; |
| 963 |
} |
| 964 |
|
| 965 |
// WordPress 4.8 and higher |
| 966 |
if ( method_exists( '\_WP_Editors', 'print_tinymce_scripts' ) ) { |
| 967 |
\_WP_Editors::print_default_editor_scripts(); |
| 968 |
\_WP_Editors::print_tinymce_scripts(); |
| 969 |
} |
| 970 |
ob_start(); |
| 971 |
|
| 972 |
wp_editor( |
| 973 |
'%%EDITORCONTENT%%', |
| 974 |
'elementorwpeditor', |
| 975 |
[ |
| 976 |
'editor_class' => 'elementor-wp-editor', |
| 977 |
'editor_height' => 250, |
| 978 |
'drag_drop_upload' => true, |
| 979 |
] |
| 980 |
); |
| 981 |
|
| 982 |
$config = ob_get_clean(); |
| 983 |
|
| 984 |
// Don't call \_WP_Editors methods again |
| 985 |
remove_action( 'admin_print_footer_scripts', [ '_WP_Editors', 'editor_js' ], 50 ); |
| 986 |
remove_action( 'admin_print_footer_scripts', [ '_WP_Editors', 'print_default_editor_scripts' ], 45 ); |
| 987 |
|
| 988 |
\_WP_Editors::editor_js(); |
| 989 |
|
| 990 |
return $config; |
| 991 |
} |
| 992 |
|
| 993 |
/** |
| 994 |
* Editor head trigger. |
| 995 |
* |
| 996 |
* Fires the 'elementor/editor/wp_head' action in the head tag in Elementor |
| 997 |
* editor. |
| 998 |
* |
| 999 |
* @since 1.0.0 |
| 1000 |
* @access public |
| 1001 |
*/ |
| 1002 |
public function editor_head_trigger() { |
| 1003 |
/** |
| 1004 |
* Elementor editor head. |
| 1005 |
* |
| 1006 |
* Fires on Elementor editor head tag. |
| 1007 |
* |
| 1008 |
* Used to prints scripts or any other data in the head tag. |
| 1009 |
* |
| 1010 |
* @since 1.0.0 |
| 1011 |
*/ |
| 1012 |
do_action( 'elementor/editor/wp_head' ); |
| 1013 |
} |
| 1014 |
|
| 1015 |
/** |
| 1016 |
* Add editor template. |
| 1017 |
* |
| 1018 |
* Registers new editor templates. |
| 1019 |
* |
| 1020 |
* @since 1.0.0 |
| 1021 |
* @deprecated 2.3.0 Use `Plugin::$instance->common->add_template()` |
| 1022 |
* @access public |
| 1023 |
* |
| 1024 |
* @param string $template Can be either a link to template file or template |
| 1025 |
* HTML content. |
| 1026 |
* @param string $type Optional. Whether to handle the template as path |
| 1027 |
* or text. Default is `path`. |
| 1028 |
*/ |
| 1029 |
public function add_editor_template( $template, $type = 'path' ) { |
| 1030 |
_deprecated_function( __METHOD__, '2.3.0', 'Plugin::$instance->common->add_template()' ); |
| 1031 |
|
| 1032 |
$common = Plugin::$instance->common; |
| 1033 |
|
| 1034 |
if ( $common ) { |
| 1035 |
Plugin::$instance->common->add_template( $template, $type ); |
| 1036 |
} |
| 1037 |
} |
| 1038 |
|
| 1039 |
/** |
| 1040 |
* WP footer. |
| 1041 |
* |
| 1042 |
* Prints Elementor editor with all the editor templates, and render controls, |
| 1043 |
* widgets and content elements. |
| 1044 |
* |
| 1045 |
* Fired by `wp_footer` action. |
| 1046 |
* |
| 1047 |
* @since 1.0.0 |
| 1048 |
* @access public |
| 1049 |
*/ |
| 1050 |
public function wp_footer() { |
| 1051 |
$plugin = Plugin::$instance; |
| 1052 |
|
| 1053 |
$plugin->controls_manager->render_controls(); |
| 1054 |
$plugin->widgets_manager->render_widgets_content(); |
| 1055 |
$plugin->elements_manager->render_elements_content(); |
| 1056 |
|
| 1057 |
$plugin->schemes_manager->print_schemes_templates(); |
| 1058 |
|
| 1059 |
$plugin->dynamic_tags->print_templates(); |
| 1060 |
|
| 1061 |
$this->init_editor_templates(); |
| 1062 |
|
| 1063 |
/** |
| 1064 |
* Elementor editor footer. |
| 1065 |
* |
| 1066 |
* Fires on Elementor editor before closing the body tag. |
| 1067 |
* |
| 1068 |
* Used to prints scripts or any other HTML before closing the body tag. |
| 1069 |
* |
| 1070 |
* @since 1.0.0 |
| 1071 |
*/ |
| 1072 |
do_action( 'elementor/editor/footer' ); |
| 1073 |
} |
| 1074 |
|
| 1075 |
/** |
| 1076 |
* Set edit mode. |
| 1077 |
* |
| 1078 |
* Used to update the edit mode. |
| 1079 |
* |
| 1080 |
* @since 1.0.0 |
| 1081 |
* @access public |
| 1082 |
* |
| 1083 |
* @param bool $edit_mode Whether the edit mode is active. |
| 1084 |
*/ |
| 1085 |
public function set_edit_mode( $edit_mode ) { |
| 1086 |
$this->is_edit_mode = $edit_mode; |
| 1087 |
} |
| 1088 |
|
| 1089 |
/** |
| 1090 |
* Editor constructor. |
| 1091 |
* |
| 1092 |
* Initializing Elementor editor and redirect from old URL structure of |
| 1093 |
* Elementor editor. |
| 1094 |
* |
| 1095 |
* @since 1.0.0 |
| 1096 |
* @access public |
| 1097 |
*/ |
| 1098 |
public function __construct() { |
| 1099 |
Plugin::$instance->data_manager->register_controller( Data\Globals\Controller::class ); |
| 1100 |
|
| 1101 |
$this->notice_bar = new Notice_Bar(); |
| 1102 |
|
| 1103 |
add_action( 'admin_action_elementor', [ $this, 'init' ] ); |
| 1104 |
add_action( 'template_redirect', [ $this, 'redirect_to_new_url' ] ); |
| 1105 |
|
| 1106 |
// Handle autocomplete feature for URL control. |
| 1107 |
add_filter( 'wp_link_query_args', [ $this, 'filter_wp_link_query_args' ] ); |
| 1108 |
add_filter( 'wp_link_query', [ $this, 'filter_wp_link_query' ] ); |
| 1109 |
} |
| 1110 |
|
| 1111 |
/** |
| 1112 |
* @since 2.2.0 |
| 1113 |
* @access public |
| 1114 |
*/ |
| 1115 |
public function filter_wp_link_query_args( $query ) { |
| 1116 |
$library_cpt_key = array_search( Source_Local::CPT, $query['post_type'], true ); |
| 1117 |
if ( false !== $library_cpt_key ) { |
| 1118 |
unset( $query['post_type'][ $library_cpt_key ] ); |
| 1119 |
} |
| 1120 |
|
| 1121 |
return $query; |
| 1122 |
} |
| 1123 |
|
| 1124 |
/** |
| 1125 |
* @since 2.2.0 |
| 1126 |
* @access public |
| 1127 |
*/ |
| 1128 |
public function filter_wp_link_query( $results ) { |
| 1129 |
if ( isset( $_POST['editor'] ) && 'elementor' === $_POST['editor'] ) { |
| 1130 |
$post_type_object = get_post_type_object( 'post' ); |
| 1131 |
$post_label = $post_type_object->labels->singular_name; |
| 1132 |
|
| 1133 |
foreach ( $results as & $result ) { |
| 1134 |
if ( 'post' === get_post_type( $result['ID'] ) ) { |
| 1135 |
$result['info'] = $post_label; |
| 1136 |
} |
| 1137 |
} |
| 1138 |
} |
| 1139 |
|
| 1140 |
return $results; |
| 1141 |
} |
| 1142 |
|
| 1143 |
/** |
| 1144 |
* Create nonce. |
| 1145 |
* |
| 1146 |
* If the user has edit capabilities, it creates a cryptographic token to |
| 1147 |
* give him access to Elementor editor. |
| 1148 |
* |
| 1149 |
* @since 1.8.1 |
| 1150 |
* @since 1.8.7 The `$post_type` parameter was introduces. |
| 1151 |
* @deprecated 2.3.0 Use `Plugin::$instance->common->get_component( 'ajax' )->create_nonce()` instead |
| 1152 |
* @access public |
| 1153 |
* |
| 1154 |
* @param string $post_type The post type to check capabilities. |
| 1155 |
* |
| 1156 |
* @return null|string The nonce token, or `null` if the user has no edit |
| 1157 |
* capabilities. |
| 1158 |
*/ |
| 1159 |
public function create_nonce( $post_type ) { |
| 1160 |
_deprecated_function( __METHOD__, '2.3.0', 'Plugin::$instance->common->get_component( \'ajax\' )->create_nonce()' ); |
| 1161 |
|
| 1162 |
/** @var Ajax $ajax */ |
| 1163 |
$ajax = Plugin::$instance->common->get_component( 'ajax' ); |
| 1164 |
|
| 1165 |
return $ajax->create_nonce(); |
| 1166 |
} |
| 1167 |
|
| 1168 |
/** |
| 1169 |
* Verify nonce. |
| 1170 |
* |
| 1171 |
* The user is given an amount of time to use the token, so therefore, since |
| 1172 |
* the user ID and `$action` remain the same, the independent variable is |
| 1173 |
* the time. |
| 1174 |
* |
| 1175 |
* @since 1.8.1 |
| 1176 |
* @deprecated 2.3.0 |
| 1177 |
* @access public |
| 1178 |
* |
| 1179 |
* @param string $nonce Nonce to verify. |
| 1180 |
* |
| 1181 |
* @return false|int If the nonce is invalid it returns `false`. If the |
| 1182 |
* nonce is valid and generated between 0-12 hours ago it |
| 1183 |
* returns `1`. If the nonce is valid and generated |
| 1184 |
* between 12-24 hours ago it returns `2`. |
| 1185 |
*/ |
| 1186 |
public function verify_nonce( $nonce ) { |
| 1187 |
_deprecated_function( __METHOD__, '2.3.0', 'wp_verify_nonce()' ); |
| 1188 |
|
| 1189 |
return wp_verify_nonce( $nonce ); |
| 1190 |
} |
| 1191 |
|
| 1192 |
/** |
| 1193 |
* Verify request nonce. |
| 1194 |
* |
| 1195 |
* Whether the request nonce verified or not. |
| 1196 |
* |
| 1197 |
* @since 1.8.1 |
| 1198 |
* @deprecated 2.3.0 Use `Plugin::$instance->common->get_component( 'ajax' )->verify_request_nonce()` instead |
| 1199 |
* @access public |
| 1200 |
* |
| 1201 |
* @return bool True if request nonce verified, False otherwise. |
| 1202 |
*/ |
| 1203 |
public function verify_request_nonce() { |
| 1204 |
_deprecated_function( __METHOD__, '2.3.0', 'Plugin::$instance->common->get_component( \'ajax\' )->verify_request_nonce()' ); |
| 1205 |
|
| 1206 |
/** @var Ajax $ajax */ |
| 1207 |
$ajax = Plugin::$instance->common->get_component( 'ajax' ); |
| 1208 |
|
| 1209 |
return $ajax->verify_request_nonce(); |
| 1210 |
} |
| 1211 |
|
| 1212 |
/** |
| 1213 |
* Verify ajax nonce. |
| 1214 |
* |
| 1215 |
* Verify request nonce and send a JSON request, if not verified returns an |
| 1216 |
* error. |
| 1217 |
* |
| 1218 |
* @since 1.9.0 |
| 1219 |
* @deprecated 2.3.0 |
| 1220 |
* @access public |
| 1221 |
*/ |
| 1222 |
public function verify_ajax_nonce() { |
| 1223 |
_deprecated_function( __METHOD__, '2.3.0' ); |
| 1224 |
|
| 1225 |
/** @var Ajax $ajax */ |
| 1226 |
$ajax = Plugin::$instance->common->get_component( 'ajax' ); |
| 1227 |
|
| 1228 |
if ( ! $ajax->verify_request_nonce() ) { |
| 1229 |
wp_send_json_error( new \WP_Error( 'token_expired', 'Nonce token expired.' ) ); |
| 1230 |
} |
| 1231 |
} |
| 1232 |
|
| 1233 |
/** |
| 1234 |
* Init editor templates. |
| 1235 |
* |
| 1236 |
* Initialize default elementor templates used in the editor panel. |
| 1237 |
* |
| 1238 |
* @since 1.7.0 |
| 1239 |
* @access private |
| 1240 |
*/ |
| 1241 |
private function init_editor_templates() { |
| 1242 |
$template_names = [ |
| 1243 |
'global', |
| 1244 |
'panel', |
| 1245 |
'panel-elements', |
| 1246 |
'repeater', |
| 1247 |
'templates', |
| 1248 |
'navigator', |
| 1249 |
'hotkeys', |
| 1250 |
]; |
| 1251 |
|
| 1252 |
foreach ( $template_names as $template_name ) { |
| 1253 |
Plugin::$instance->common->add_template( ELEMENTOR_PATH . "includes/editor-templates/$template_name.php" ); |
| 1254 |
} |
| 1255 |
} |
| 1256 |
|
| 1257 |
private function bc_move_document_filters() { |
| 1258 |
global $wp_filter; |
| 1259 |
|
| 1260 |
$old_tag = 'elementor/editor/localize_settings'; |
| 1261 |
$new_tag = 'elementor/document/config'; |
| 1262 |
|
| 1263 |
if ( ! has_filter( $old_tag ) ) { |
| 1264 |
return; |
| 1265 |
} |
| 1266 |
|
| 1267 |
foreach ( $wp_filter[ $old_tag ] as $priority => $filters ) { |
| 1268 |
foreach ( $filters as $filter_id => $filter_args ) { |
| 1269 |
if ( 2 === $filter_args['accepted_args'] ) { |
| 1270 |
remove_filter( $old_tag, $filter_id, $priority ); |
| 1271 |
|
| 1272 |
add_filter( $new_tag, $filter_args['function'], $priority, 2 ); |
| 1273 |
|
| 1274 |
// TODO: Hard deprecation |
| 1275 |
// _deprecated_hook( '`' . $old_tag . ` is no longer using post_id', '2.9.0', $new_tag' ); |
| 1276 |
} |
| 1277 |
} |
| 1278 |
} |
| 1279 |
} |
| 1280 |
|
| 1281 |
public function set_post_id( $post_id ) { |
| 1282 |
$this->post_id = $post_id; |
| 1283 |
} |
| 1284 |
} |
| 1285 |
|