| @@ -39,9 +39,9 @@ | ||
| 39 | 39 | * |
| 40 | 40 | * @return string Widget title. |
| 41 | 41 | */ |
| 42 | 42 | public function get_title() { |
| 43 | - return esc_html__( 'Menu Anchor', 'elementor' ); | |
| 43 | + return __( 'Menu Anchor', 'elementor' ); | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * Get widget icon. |
| @@ -70,31 +70,9 @@ | ||
| 70 | 70 | public function get_keywords() { |
| 71 | 71 | return [ 'menu', 'anchor', 'link' ]; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - protected function is_dynamic_content(): bool { | |
| 75 | - return false; | |
| 76 | - } | |
| 77 | - | |
| 78 | 74 | /** |
| 79 | - * Get style dependencies. | |
| 80 | - * | |
| 81 | - * Retrieve the list of style dependencies the widget requires. | |
| 82 | - * | |
| 83 | - * @since 3.24.0 | |
| 84 | - * @access public | |
| 85 | - * | |
| 86 | - * @return array Widget style dependencies. | |
| 87 | - */ | |
| 88 | - public function get_style_depends(): array { | |
| 89 | - return [ 'widget-menu-anchor' ]; | |
| 90 | - } | |
| 91 | - | |
| 92 | - public function has_widget_inner_wrapper(): bool { | |
| 93 | - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); | |
| 94 | - } | |
| 95 | - | |
| 96 | - /** | |
| 97 | 75 | * Register menu anchor widget controls. |
| 98 | 76 | * |
| 99 | 77 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 100 | 78 | * |
| @@ -104,9 +82,9 @@ | ||
| 104 | 82 | protected function register_controls() { |
| 105 | 83 | $this->start_controls_section( |
| 106 | 84 | 'section_anchor', |
| 107 | 85 | [ |
| 108 | - 'label' => esc_html__( 'Menu Anchor', 'elementor' ), | |
| 86 | + 'label' => __( 'Anchor', 'elementor' ), | |
| 109 | 87 | ] |
| 110 | 88 | ); |
| 111 | 89 | |
| 112 | 90 | $this->add_control( |
| @@ -111,19 +89,13 @@ | ||
| 111 | 89 | |
| 112 | 90 | $this->add_control( |
| 113 | 91 | 'anchor', |
| 114 | 92 | [ |
| 115 | - 'label' => esc_html__( 'The ID of Menu Anchor.', 'elementor' ), | |
| 93 | + 'label' => __( 'The ID of Menu Anchor.', 'elementor' ), | |
| 116 | 94 | 'type' => Controls_Manager::TEXT, |
| 117 | - 'ai' => [ | |
| 118 | - 'active' => false, | |
| 119 | - ], | |
| 120 | - 'placeholder' => esc_html__( 'For Example: About', 'elementor' ), | |
| 121 | - 'description' => esc_html__( 'This ID will be the CSS ID you will have to use in your own page, Without #.', 'elementor' ), | |
| 95 | + 'placeholder' => __( 'For Example: About', 'elementor' ), | |
| 96 | + 'description' => __( 'This ID will be the CSS ID you will have to use in your own page, Without #.', 'elementor' ), | |
| 122 | 97 | 'label_block' => true, |
| 123 | - 'dynamic' => [ | |
| 124 | - 'active' => true, | |
| 125 | - ], | |
| 126 | 98 | ] |
| 127 | 99 | ); |
| 128 | 100 | |
| 129 | 101 | $this->add_control( |
| @@ -128,15 +100,11 @@ | ||
| 128 | 100 | |
| 129 | 101 | $this->add_control( |
| 130 | 102 | 'anchor_note', |
| 131 | 103 | [ |
| 132 | - 'type' => Controls_Manager::ALERT, | |
| 133 | - 'alert_type' => 'warning', | |
| 134 | - 'content' => sprintf( | |
| 135 | - /* translators: %s: Accepted chars. */ | |
| 136 | - esc_html__( 'Note: The ID link ONLY accepts these chars: %s', 'elementor' ), | |
| 137 | - '`A-Z, a-z, 0-9, _ , -`' | |
| 138 | - ), | |
| 104 | + 'type' => Controls_Manager::RAW_HTML, | |
| 105 | + 'raw' => sprintf( __( 'Note: The ID link ONLY accepts these chars: %s', 'elementor' ), '`A-Z, a-z, 0-9, _ , -`' ), | |
| 106 | + 'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning', | |
| 139 | 107 | ] |
| 140 | 108 | ); |
| 141 | 109 | |
| 142 | 110 | $this->end_controls_section(); |
| @@ -152,21 +120,15 @@ | ||
| 152 | 120 | */ |
| 153 | 121 | protected function render() { |
| 154 | 122 | $anchor = $this->get_settings_for_display( 'anchor' ); |
| 155 | 123 | |
| 156 | - if ( empty( $anchor ) ) { | |
| 157 | - return; | |
| 124 | + if ( ! empty( $anchor ) ) { | |
| 125 | + $this->add_render_attribute( 'inner', 'id', sanitize_html_class( $anchor ) ); | |
| 158 | 126 | } |
| 159 | 127 | |
| 160 | - $this->add_render_attribute( | |
| 161 | - 'inner', | |
| 162 | - [ | |
| 163 | - 'class' => 'elementor-menu-anchor', | |
| 164 | - 'id' => sanitize_html_class( $anchor ), | |
| 165 | - ] | |
| 166 | - ); | |
| 128 | + $this->add_render_attribute( 'inner', 'class', 'elementor-menu-anchor' ); | |
| 167 | 129 | ?> |
| 168 | - <div <?php $this->print_render_attribute_string( 'inner' ); ?>></div> | |
| 130 | + <div <?php echo $this->get_render_attribute_string( 'inner' ); ?>></div> | |
| 169 | 131 | <?php |
| 170 | 132 | } |
| 171 | 133 | |
| 172 | 134 | /** |
| @@ -178,31 +140,8 @@ | ||
| 178 | 140 | * @access protected |
| 179 | 141 | */ |
| 180 | 142 | protected function content_template() { |
| 181 | 143 | ?> |
| 182 | - <# | |
| 183 | - if ( '' === settings.anchor ) { | |
| 184 | - return; | |
| 185 | - } | |
| 186 | - | |
| 187 | - view.addRenderAttribute( | |
| 188 | - 'inner', | |
| 189 | - { | |
| 190 | - 'class': 'elementor-menu-anchor', | |
| 191 | - 'id': settings.anchor, | |
| 192 | - } | |
| 193 | - ); | |
| 194 | - #> | |
| 195 | - <div {{{ view.getRenderAttributeString( 'inner' ) }}}></div> | |
| 144 | + <div class="elementor-menu-anchor"{{{ settings.anchor ? ' id="' + settings.anchor + '"' : '' }}}></div> | |
| 196 | 145 | <?php |
| 197 | - } | |
| 198 | - | |
| 199 | - public function render_markdown(): string { | |
| 200 | - return ''; | |
| 201 | - } | |
| 202 | - | |
| 203 | - protected function on_save( array $settings ) { | |
| 204 | - $settings['anchor'] = sanitize_html_class( $settings['anchor'] ); | |
| 205 | - | |
| 206 | - return $settings; | |
| 207 | 146 | } |
| 208 | 147 | } |