PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.5
Elementor Website Builder – more than just a page builder v3.32.5
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.32.5, at modules/pro-install/module.php

83 lines 2.3 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\Settings;
9 use Elementor\Utils;
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 $admin_menu->register(
36 'elementor-connect-account',
37 new Pro_Install_Menu_Item(
38 $this->get_connect_app(),
39 $this->get_pro_install_page_assets(),
40 )
41 );
42 }, 116 );
43 }
44
45 private function get_connect_app(): Connect {
46 return Plugin::$instance->common->get_component( 'connect' )->get_app( 'pro-install' );
47 }
48
49 public function admin_post_elementor_do_pro_install() {
50 if ( ! current_user_can( 'install_plugins' ) ) {
51 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'elementor' ) );
52 }
53
54 check_admin_referer( 'elementor_do_pro_install' );
55
56 $app = $this->get_connect_app();
57 $download_link = $app->get_download_link();
58
59 if ( empty( $download_link ) ) {
60 wp_die( esc_html__( 'There are no available subscriptions at the moment.', 'elementor' ) );
61 }
62
63 $plugin_installer = new Plugin_Installer( 'elementor-pro', $download_link );
64 $response = $plugin_installer->install();
65
66 if ( is_wp_error( $response ) ) {
67 wp_die( esc_html( $response->get_error_message() ) );
68 }
69
70 wp_safe_redirect( admin_url( 'admin.php?page=elementor-license' ) );
71 }
72
73 private function get_pro_install_page_assets(): array {
74 return [
75 'elementor-pro-install-events',
76 $this->get_js_assets_url( 'pro-install-events' ),
77 [ 'elementor-common' ],
78 ELEMENTOR_VERSION,
79 true,
80 ];
81 }
82 }
83