PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
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 / mcp / utils / mcp-v4-gate.php

mcp-v4-gate.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at modules/mcp/utils/mcp-v4-gate.php

74 lines 2.0 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\Mcp\Utils;
4
5 use Elementor\Modules\AtomicWidgets\Module as Atomic_Widgets_Module;
6 use Elementor\Plugin;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 class Mcp_V4_Gate {
13
14 const GATED_IDS = [
15 'elementor/build-composition',
16 'elementor/create-preview-link',
17 'elementor/get-default-styles',
18 'elementor/get-widget-schema',
19 'elementor/global-classes-resource',
20 'elementor/global-variables-resource',
21 'elementor/interactions-schema-resource',
22 'elementor/list-components',
23 'elementor/list-dynamic-tags',
24 'elementor/list-widget-schemas',
25 'elementor/manage-classes',
26 'elementor/manage-component',
27 'elementor/manage-default-styles',
28 'elementor/manage-elements',
29 'elementor/manage-global-variable',
30 'elementor/manage-global-variable-guide',
31 'elementor/reorder-classes',
32 ];
33
34 public static function is_atomic_editor_active(): bool {
35 return Plugin::$instance->experiments->is_feature_active( Atomic_Widgets_Module::EXPERIMENT_NAME );
36 }
37
38 public static function is_gated( string $id ): bool {
39 return in_array( $id, self::gated_ids(), true );
40 }
41
42 /**
43 * @return true|\WP_Error true when the ability may run, or an error explaining why not.
44 */
45 public static function is_available( string $id ) {
46 if ( self::is_gated( $id ) && ! self::is_atomic_editor_active() ) {
47 return self::v4_required_error();
48 }
49
50 return true;
51 }
52
53 private static function v4_required_error(): \WP_Error {
54 return new \WP_Error(
55 'elementor_v4_required',
56 __( 'This site needs the Atomic Editor turned on before this can be built. Turn it on in WP Admin → Elementor → Settings → Atomic Editor, then try again.', 'elementor' ),
57 [
58 'status' => 403,
59 'description_notice' => __( 'Note: needs Atomic Editor (currently off for this site).', 'elementor' ),
60 ]
61 );
62 }
63
64 private static function gated_ids(): array {
65 $ids = apply_filters( 'elementor/mcp/gated_ability_ids', self::GATED_IDS );
66
67 if ( ! is_array( $ids ) ) {
68 return self::GATED_IDS;
69 }
70
71 return array_values( array_unique( array_filter( $ids, 'is_string' ) ) );
72 }
73 }
74