PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.0
Elementor Website Builder – more than just a page builder v3.35.0
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
elementor / modules / pro-install / module.php

module.php in Elementor Website Builder – more than just a page builder 3.35.0, at modules/pro-install/module.php

103 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Modules\ProInstall;
3
4 use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
5 use Elementor\Core\Common\Modules\Connect\Module as ConnectModule;
6 use Elementor\Core\Base\Module as BaseModule;
7 use Elementor\Plugin;
8 use Elementor\Utils;
9 use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 class Module extends BaseModule {
16
17 public function get_name() {
18 return 'pro-install';
19 }
20
21 public static function is_active() {
22 return ! Utils::has_pro() && current_user_can( 'manage_options' );
23 }
24
25 public function __construct() {
26 parent::__construct();
27
28 add_action( 'admin_post_elementor_do_pro_install', [ $this, 'admin_post_elementor_do_pro_install' ] );
29
30 add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) {
31 $connect_module->register_app( 'pro-install', Connect::get_class_name() );
32 } );
33
34 add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) {
35 if ( ! $this->is_editor_one_active() ) {
36 $admin_menu->register(
37 'elementor-connect-account',
38 new Pro_Install_Menu_Item(
39 $this->get_connect_app(),
40 $this->get_pro_install_page_assets(),
41 )
42 );
43 }
44 }, 116 );
45
46 add_action( 'elementor/editor-one/menu/excluded_level3_slugs', function ( array $excluded_slugs ): array {
47 $excluded_slugs[] = 'elementor-connect';
48 return $excluded_slugs;
49 } );
50
51 add_action( 'elementor/editor-one/menu/register', function( Menu_Data_Provider $menu_data_provider ) {
52 $menu_data_provider->register_menu(
53 new Editor_One_Connect_Account_Menu_Item(
54 $this->get_connect_app(),
55 $this->get_pro_install_page_assets()
56 )
57 );
58 } );
59 }
60
61 private function is_editor_one_active(): bool {
62 return (bool) Plugin::instance()->modules_manager->get_modules( 'editor-one' );
63 }
64
65 private function get_connect_app(): Connect {
66 return Plugin::$instance->common->get_component( 'connect' )->get_app( 'pro-install' );
67 }
68
69 public function admin_post_elementor_do_pro_install() {
70 if ( ! current_user_can( 'install_plugins' ) ) {
71 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'elementor' ) );
72 }
73
74 check_admin_referer( 'elementor_do_pro_install' );
75
76 $app = $this->get_connect_app();
77 $download_link = $app->get_download_link();
78
79 if ( empty( $download_link ) ) {
80 wp_die( esc_html__( 'There are no available subscriptions at the moment.', 'elementor' ) );
81 }
82
83 $plugin_installer = new Plugin_Installer( 'elementor-pro', $download_link );
84 $response = $plugin_installer->install();
85
86 if ( is_wp_error( $response ) ) {
87 wp_die( esc_html( $response->get_error_message() ) );
88 }
89
90 wp_safe_redirect( admin_url( 'admin.php?page=elementor-license' ) );
91 }
92
93 private function get_pro_install_page_assets(): array {
94 return [
95 'elementor-pro-install-events',
96 $this->get_js_assets_url( 'pro-install-events' ),
97 [ 'elementor-common' ],
98 ELEMENTOR_VERSION,
99 true,
100 ];
101 }
102 }
103