PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.0-dev3
Elementor Website Builder – more than just a page builder v3.32.0-dev3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | modules/cloud-library/render-mode-preview.php +21 -16 4.2.0-dev23.32.0-dev3 View file →
@@ -18,17 +18,8 @@
18 18
19 19 public function __construct( $template_id ) {
20 20 $this->template_id = $template_id;
21 21 $this->document = $this->create_document();
22 -
23 - Plugin::$instance->db->switch_to_post( $this->document->get_main_id() );
24 -
25 - Plugin::$instance->documents->switch_to_document( $this->document );
26 -
27 - add_filter( 'template_include', [ $this, 'filter_template' ] );
28 -
29 - add_action( 'wp_footer', [ $this, 'cleanup' ], 999 );
30 -
31 22 parent::__construct( $this->document->get_main_id() );
32 23 }
33 24
34 25 public static function get_name() {
@@ -37,8 +28,10 @@
37 28
38 29 public function prepare_render() {
39 30 parent::prepare_render();
40 31 show_admin_bar( false );
32 +
33 + add_filter( 'template_include', [ $this, 'filter_template' ] );
41 34 }
42 35
43 36 public function filter_template() {
44 37 return ELEMENTOR_PATH . 'modules/page-templates/templates/canvas.php';
@@ -43,21 +36,31 @@
43 36 public function filter_template() {
44 37 return ELEMENTOR_PATH . 'modules/page-templates/templates/canvas.php';
45 38 }
46 39
47 - public function cleanup() {
48 - if ( $this->document && $this->document->get_main_id() ) {
49 - wp_delete_post( $this->document->get_main_id(), true );
50 - }
51 - }
52 -
53 40 public function enqueue_scripts() {
54 41 $suffix = ( Utils::is_script_debug() || Utils::is_elementor_tests() ) ? '' : '.min';
55 42
56 43 wp_enqueue_script(
44 + 'dom-to-image',
45 + ELEMENTOR_ASSETS_URL . "/lib/dom-to-image/js/dom-to-image{$suffix}.js",
46 + [],
47 + '2.6.0',
48 + true
49 + );
50 +
51 + wp_enqueue_script(
52 + 'html2canvas',
53 + ELEMENTOR_ASSETS_URL . "/lib/html2canvas/js/html2canvas{$suffix}.js",
54 + [],
55 + '1.4.1',
56 + true
57 + );
58 +
59 + wp_enqueue_script(
57 60 'cloud-library-screenshot',
58 61 ELEMENTOR_ASSETS_URL . "/js/cloud-library-screenshot{$suffix}.js",
59 - [],
62 + [ 'dom-to-image', 'html2canvas' ],
60 63 ELEMENTOR_VERSION,
61 64 true
62 65 );
63 66
@@ -80,8 +83,10 @@
80 83
81 84 if ( is_wp_error( $document ) ) {
82 85 wp_die();
83 86 }
87 +
88 + Plugin::$instance->documents->switch_to_document( $document );
84 89
85 90 return $document;
86 91 }
87 92 }