PluginProbe
Elementor Website Builder – more than just a page builder / 3.30.0-dev3
Elementor Website Builder – more than just a page builder v3.30.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
elementor / core / common / modules / connect / admin.php

admin.php in Elementor Website Builder – more than just a page builder 3.30.0-dev3, at core/common/modules/connect/admin.php

96 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Common\Modules\Connect;
3
4 use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
5 use Elementor\Plugin;
6 use Elementor\Settings;
7 use Elementor\Utils;
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12
13 class Admin {
14
15 const PAGE_ID = 'elementor-connect';
16
17 public static $url = '';
18
19 /**
20 * @since 2.3.0
21 * @access public
22 */
23 public function register_admin_menu( Admin_Menu_Manager $admin_menu ) {
24 $admin_menu->register( static::PAGE_ID, new Connect_Menu_Item() );
25 }
26
27 /**
28 * @since 2.3.0
29 * @access public
30 */
31 public function on_load_page() {
32 if ( ! $this->user_has_enough_permissions() ) {
33 wp_die( 'You do not have sufficient permissions to access this page.', 'You do not have sufficient permissions to access this page.', [
34 'back_link' => true,
35 ] );
36 }
37
38 if ( isset( $_GET['action'], $_GET['app'] ) ) {
39 $manager = Plugin::$instance->common->get_component( 'connect' );
40
41 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
42 $app_slug = Utils::get_super_global_value( $_GET, 'app' );
43 $app = $manager->get_app( $app_slug );
44
45 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
46 $action = Utils::get_super_global_value( $_GET, 'action' );
47
48 $nonce_action = $app_slug . $action;
49
50 if ( ! $app ) {
51 wp_die( 'Unknown app: ' . esc_attr( $app_slug ) );
52 }
53
54 if ( ! wp_verify_nonce( Utils::get_super_global_value( $_GET, 'nonce' ), $nonce_action ) ) {
55 wp_die( 'Invalid Nonce', 'Invalid Nonce', [
56 'back_link' => true,
57 ] );
58 }
59
60 $method = 'action_' . $action;
61
62 if ( method_exists( $app, $method ) ) {
63 call_user_func( [ $app, $method ] );
64 }
65 }
66 }
67
68 private function user_has_enough_permissions() {
69 if ( current_user_can( 'manage_options' ) ) {
70 return true;
71 }
72
73 if ( 'library' === Utils::get_super_global_value( $_GET, 'app' ) ) {
74 return current_user_can( 'edit_posts' );
75 }
76
77 return false;
78 }
79
80 /**
81 * @since 2.3.0
82 * @access public
83 */
84 public function __construct() {
85 self::$url = admin_url( 'admin.php?page=' . self::PAGE_ID );
86
87 add_action( 'elementor/admin/menu/register', [ $this, 'register_admin_menu' ] );
88
89 add_action( 'elementor/admin/menu/after_register', function ( Admin_Menu_Manager $admin_menu, array $hooks ) {
90 if ( ! empty( $hooks[ static::PAGE_ID ] ) ) {
91 add_action( 'load-' . $hooks[ static::PAGE_ID ], [ $this, 'on_load_page' ] );
92 }
93 }, 10, 2 );
94 }
95 }
96