PluginProbe
Elementor Website Builder – more than just a page builder / 3.29.0-dev4
Elementor Website Builder – more than just a page builder v3.29.0-dev4
4.3.0-beta3 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 All 452 releases
elementor / modules / atomic-opt-in / opt-in-page.php

opt-in-page.php in Elementor Website Builder – more than just a page builder 3.29.0-dev4, at modules/atomic-opt-in/opt-in-page.php

100 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\AtomicOptIn;
4
5 use Elementor\Plugin;
6 use Elementor\Settings;
7 use Elementor\User;
8 use Elementor\Utils;
9
10 class OptInPage {
11 private Module $module;
12
13 public function __construct( Module $module ) {
14 $this->module = $module;
15 }
16
17 public function init() {
18 if ( ! current_user_can( 'manage_options' ) ) {
19 return;
20 }
21
22 $this->register_assets();
23 $this->add_settings_tab();
24 }
25
26 private function register_assets() {
27 $page_id = Settings::PAGE_ID;
28
29 add_action( "elementor/admin/after_create_settings/{$page_id}", [ $this, 'enqueue_scripts' ] );
30 add_action( "elementor/admin/after_create_settings/{$page_id}", [ $this, 'enqueue_styles' ] );
31 }
32
33 public function enqueue_styles() {
34 wp_enqueue_style(
35 Module::MODULE_NAME,
36 $this->module->get_opt_in_css_assets_url( 'modules/editor-v4-opt-in/opt-in' ),
37 [],
38 ELEMENTOR_VERSION
39 );
40 }
41
42 public function enqueue_scripts() {
43 $min_suffix = Utils::is_script_debug() ? '' : '.min';
44
45 wp_enqueue_script(
46 Module::MODULE_NAME,
47 ELEMENTOR_ASSETS_URL . 'js/editor-v4-opt-in' . $min_suffix . '.js',
48 [
49 'react',
50 'react-dom',
51 'elementor-common',
52 'elementor-v2-ui',
53 ],
54 ELEMENTOR_VERSION,
55 true
56 );
57
58 wp_localize_script(
59 Module::MODULE_NAME,
60 'elementorSettingsEditor4OptIn',
61 $this->prepare_data()
62 );
63 }
64
65 private function prepare_data() {
66 $create_new_post_type = User::is_current_user_can_edit_post_type( 'page' ) ? 'page' : 'post';
67
68 return [
69 'features' => [
70 'editor_v4' => $this->module->is_atomic_experiment_active(),
71 ],
72 'urls' => [
73 'start_building' => esc_url( Plugin::$instance->documents->get_create_new_post_url( $create_new_post_type ) ),
74 ],
75 ];
76 }
77
78 private function add_settings_tab() {
79 $page_id = Settings::PAGE_ID;
80
81 add_action( "elementor/admin/after_create_settings/{$page_id}", function( Settings $settings ) {
82 $this->add_new_tab_to( $settings );
83 }, 11 );
84 }
85
86 private function add_new_tab_to( Settings $settings ) {
87 $settings->add_tab( Module::MODULE_NAME, [
88 'label' => esc_html__( 'Editor V4', 'elementor' ),
89 'sections' => [
90 'opt-in' => [
91 'callback' => function() {
92 echo '<div id="page-editor-v4-opt-in"></div>';
93 },
94 'fields' => [],
95 ],
96 ],
97 ] );
98 }
99 }
100