@@ -154,10 +154,15 @@ private function collect_attributes( array $block ): array {
154154 'toggle_text_color ' => $ this ->get_priority_attr ( $ block , 'priorityPlusToggleTextColor ' , '' ),
155155 'toggle_text_color_hover ' => $ this ->get_priority_attr ( $ block , 'priorityPlusToggleTextColorHover ' , '' ),
156156 'toggle_padding ' => $ this ->get_priority_attr ( $ block , 'priorityPlusTogglePadding ' , array () ),
157+ 'toggle_border ' => $ this ->get_priority_attr ( $ block , 'priorityPlusToggleBorder ' , array () ),
158+ 'toggle_border_radius ' => $ this ->get_priority_attr ( $ block , 'priorityPlusToggleBorderRadius ' , '' ),
157159
158160 // Core navigation attribute.
159161 'overlay_menu ' => $ this ->get_priority_attr ( $ block , 'overlayMenu ' , 'never ' ),
160162
163+ // Mobile collapse.
164+ 'mobile_collapse ' => $ this ->get_priority_attr ( $ block , 'priorityPlusMobileCollapse ' , true ),
165+
161166 // Menu style attributes.
162167 'menu_background_color ' => $ this ->get_priority_attr ( $ block , 'priorityPlusMenuBackgroundColor ' , '' ),
163168 'menu_border ' => $ this ->get_priority_attr ( $ block , 'priorityPlusMenuBorder ' , array () ),
@@ -198,10 +203,11 @@ private function inject_priority_attributes( string $block_content, array $attri
198203
199204 // Build data attributes string.
200205 $ data_attributes = sprintf (
201- '$1 data-more-label="%s" data-more-icon="%s" data-overlay-menu="%s" ' ,
206+ '$1 data-more-label="%s" data-more-icon="%s" data-overlay-menu="%s" data-mobile-collapse="%s" ' ,
202207 esc_attr ( $ attributes ['toggle_label ' ] ),
203208 esc_attr ( $ attributes ['toggle_icon ' ] ),
204- esc_attr ( $ attributes ['overlay_menu ' ] )
209+ esc_attr ( $ attributes ['overlay_menu ' ] ),
210+ $ attributes ['mobile_collapse ' ] ? 'true ' : 'false '
205211 );
206212
207213 // Add style attribute if we have any styles.
@@ -303,6 +309,92 @@ private function add_toggle_styles( array $attributes, array $style_parts ): arr
303309 }
304310 }
305311
312+ // Convert toggle border to CSS custom properties.
313+ if ( is_array ( $ attributes ['toggle_border ' ] ) && ! empty ( $ attributes ['toggle_border ' ] ) ) {
314+ $ style_parts = $ this ->add_toggle_border_styles ( $ attributes ['toggle_border ' ], $ style_parts );
315+ }
316+
317+ // Convert toggle border radius to CSS.
318+ if ( ! empty ( $ attributes ['toggle_border_radius ' ] ) ) {
319+ $ radius_css = $ this ->css_converter ->border_radius_to_css ( $ attributes ['toggle_border_radius ' ] );
320+ if ( '' !== $ radius_css ) {
321+ $ style_parts [] = sprintf (
322+ '--priority-plus-navigation--border-radius: %s ' ,
323+ esc_attr ( $ radius_css )
324+ );
325+ }
326+ }
327+
328+ return $ style_parts ;
329+ }
330+
331+ /**
332+ * Add toggle button border CSS custom properties.
333+ *
334+ * Handles both flat format (color, width, style at top level) and
335+ * per-side format (top, right, bottom, left objects).
336+ * Outputs unified --border-color, --border-width, --border-style vars.
337+ *
338+ * @param array $border Border attribute value.
339+ * @param array $style_parts Current style parts array.
340+ * @return array Updated style parts array.
341+ */
342+ private function add_toggle_border_styles ( array $ border , array $ style_parts ): array {
343+ // Flat format: { color, width, style }.
344+ if ( isset ( $ border ['color ' ] ) || isset ( $ border ['width ' ] ) || isset ( $ border ['style ' ] ) ) {
345+ if ( ! empty ( $ border ['color ' ] ) ) {
346+ $ style_parts [] = sprintf (
347+ '--priority-plus-navigation--border-color: %s ' ,
348+ esc_attr ( $ border ['color ' ] )
349+ );
350+ }
351+ if ( ! empty ( $ border ['width ' ] ) ) {
352+ $ style_parts [] = sprintf (
353+ '--priority-plus-navigation--border-width: %s ' ,
354+ esc_attr ( $ border ['width ' ] )
355+ );
356+ }
357+ if ( ! empty ( $ border ['style ' ] ) ) {
358+ $ style_parts [] = sprintf (
359+ '--priority-plus-navigation--border-style: %s ' ,
360+ esc_attr ( $ border ['style ' ] )
361+ );
362+ }
363+ return $ style_parts ;
364+ }
365+
366+ // Per-side format: { top: {...}, right: {...}, bottom: {...}, left: {...} }.
367+ $ sides = array ( 'top ' , 'right ' , 'bottom ' , 'left ' );
368+ $ colors = array ();
369+ $ widths = array ();
370+ $ styles = array ();
371+
372+ foreach ( $ sides as $ side ) {
373+ if ( isset ( $ border [ $ side ] ) && is_array ( $ border [ $ side ] ) ) {
374+ $ s = $ border [ $ side ];
375+ $ colors [] = isset ( $ s ['color ' ] ) ? $ s ['color ' ] : 'transparent ' ;
376+ $ widths [] = isset ( $ s ['width ' ] ) ? $ s ['width ' ] : '0 ' ;
377+ $ styles [] = isset ( $ s ['style ' ] ) ? $ s ['style ' ] : 'none ' ;
378+ } else {
379+ $ colors [] = 'transparent ' ;
380+ $ widths [] = '0 ' ;
381+ $ styles [] = 'none ' ;
382+ }
383+ }
384+
385+ $ style_parts [] = sprintf (
386+ '--priority-plus-navigation--border-color: %s ' ,
387+ esc_attr ( implode ( ' ' , $ colors ) )
388+ );
389+ $ style_parts [] = sprintf (
390+ '--priority-plus-navigation--border-width: %s ' ,
391+ esc_attr ( implode ( ' ' , $ widths ) )
392+ );
393+ $ style_parts [] = sprintf (
394+ '--priority-plus-navigation--border-style: %s ' ,
395+ esc_attr ( implode ( ' ' , $ styles ) )
396+ );
397+
306398 return $ style_parts ;
307399 }
308400
0 commit comments