@@ -19,7 +19,7 @@ class On_Off extends Text {
1919 *
2020 * @var string
2121 */
22- protected $ blueprint = 'wrap|span|label|title|/title|prefix/|/label|description_left/|control|false_value/|input/|slider/|/control|description/|/span|tooltip/|/wrap ' ;
22+ protected $ blueprint = 'wrap|span|label|title|/title|prefix/|/label|description_left/|control|false_value/|input/|shadow/| slider/|/control|description/|/span|tooltip/|/wrap ' ;
2323
2424 /**
2525 * Filter the false_value parts structure.
@@ -93,18 +93,27 @@ protected function input( $struct ) {
9393 }
9494
9595 if ( $ this ->is_readonly () || ( true === $ this ->setting ->has_param ( 'main_required ' , false ) && empty ( $ struct ['attributes ' ]['data-main ' ] ) ) ) {
96- $ clone = $ struct ;
97- $ struct = array ();
98-
99- // Add the shadow input.
100- $ struct ['children ' ]['shadow ' ] = $ clone ;
101- $ struct ['children ' ]['shadow ' ]['attributes ' ]['type ' ] = 'hidden ' ;
102-
103- // Add the toggle stub.
104- $ struct ['children ' ]['toggle ' ] = $ this ->get_part ( 'input ' );
105- $ struct ['children ' ]['toggle ' ]['attributes ' ]['disabled ' ] = 'disabled ' ;
106- $ struct ['children ' ]['toggle ' ]['attributes ' ]['checked ' ] = 'checked ' ;
107- $ struct ['children ' ]['toggle ' ]['attributes ' ]['type ' ] = 'checkbox ' ;
96+ $ struct ['attributes ' ]['type ' ] = 'hidden ' ;
97+ }
98+
99+ return $ struct ;
100+ }
101+
102+ /**
103+ * Filter the shadow parts structure.
104+ *
105+ * @param array $struct The array structure.
106+ *
107+ * @return array
108+ */
109+ protected function shadow ( $ struct ) {
110+ // Add the toggle stub.
111+ if ( $ this ->is_readonly () || ( true === $ this ->setting ->has_param ( 'main_required ' , false ) && empty ( $ struct ['attributes ' ]['data-main ' ] ) ) ) {
112+ $ struct = $ this ->get_part ( 'input ' );
113+ $ struct ['attributes ' ]['type ' ] = 'checkbox ' ;
114+ $ struct ['attributes ' ]['disabled ' ] = 'disabled ' ;
115+ $ struct ['attributes ' ]['checked ' ] = 'checked ' ;
116+ $ struct ['attributes ' ]['type ' ] = 'checkbox ' ;
108117 }
109118
110119 return $ struct ;
0 commit comments