| @@ -1,8 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\Modules\ElementManager; |
| 3 | 3 | |
| 4 | -use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager; | |
| 5 | 4 | use Elementor\Modules\Usage\Module as Usage_Module; |
| 6 | 5 | use Elementor\Api; |
| 7 | 6 | use Elementor\Plugin; |
| 8 | 7 | use Elementor\User; |
| @@ -63,9 +62,8 @@ | ||
| 63 | 62 | 'plugins' => $plugins, |
| 64 | 63 | 'notice_data' => [ |
| 65 | 64 | 'notice_id' => $notice_id, |
| 66 | 65 | 'is_viewed' => User::is_user_notice_viewed( $notice_id ), |
| 67 | - 'nonce' => wp_create_nonce( 'elementor_set_admin_notice_viewed' ), | |
| 68 | 66 | ], |
| 69 | 67 | 'promotion_data' => [ |
| 70 | 68 | 'manager_permissions' => [ |
| 71 | 69 | 'pro' => $this->get_element_manager_promotion( |
| @@ -103,11 +101,25 @@ | ||
| 103 | 101 | } |
| 104 | 102 | |
| 105 | 103 | private function get_element_manager_promotion( $promotion_data, $filter_id ): array { |
| 106 | 104 | |
| 107 | - return Filtered_Promotions_Manager::get_filtered_promotion_data( $promotion_data, 'elementor/element_manager/admin_app_data/promotion_data/' . $filter_id, 'url' ); | |
| 105 | + $filtered_data = apply_filters( 'elementor/element_manager/admin_app_data/promotion_data/' . $filter_id . '/', $promotion_data ); | |
| 106 | + | |
| 107 | + return $this->validate_promotion_data( $promotion_data, $filtered_data ); | |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | + private function validate_promotion_data( $promotion_data, $filtered_data ): array { | |
| 111 | + $filtered_data = array_intersect_key( $filtered_data, array_flip( array_keys( $promotion_data ) ) ); | |
| 112 | + | |
| 113 | + if ( ! Validate_Promotion::domain_is_on_elementor_dot_com( $filtered_data['url'] ) ) { | |
| 114 | + unset( $filtered_data['url'] ); | |
| 115 | + } | |
| 116 | + | |
| 117 | + $filtered_data['text'] = $filtered_data['text'] ?? $promotion_data['text']; | |
| 118 | + | |
| 119 | + return array_replace( $promotion_data, $filtered_data ); | |
| 120 | + } | |
| 121 | + | |
| 110 | 122 | private function verify_permission() { |
| 111 | 123 | if ( ! current_user_can( 'manage_options' ) ) { |
| 112 | 124 | wp_send_json_error( esc_html__( 'You do not have permission to edit these settings.', 'elementor' ) ); |
| 113 | 125 | } |
| @@ -122,9 +134,9 @@ | ||
| 122 | 134 | remove_all_filters( 'elementor/widgets/is_widget_enabled' ); |
| 123 | 135 | } |
| 124 | 136 | |
| 125 | 137 | private function get_plugin_name_from_widget_instance( $widget ) { |
| 126 | - if ( in_array( 'wordpress', $widget->get_categories() ) ) { // phpcs:ignore WordPress.WP.CapitalPDangit.MisspelledInText | |
| 138 | + if ( in_array( 'wordpress', $widget->get_categories() ) ) { | |
| 127 | 139 | return esc_html__( 'WordPress Widgets', 'elementor' ); |
| 128 | 140 | } |
| 129 | 141 | |
| 130 | 142 | $class_reflection = new \ReflectionClass( $widget ); |