| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Hybrid++ Schemas utilities: normalize/validate/merge/extract. |
| 4 | 4 | * |
| @@ -65,9 +65,9 @@ | ||
| 65 | 65 | |
| 66 | 66 | // Allow extra prop/control types used by the Inspector Factory. |
| 67 | 67 | $allowed_prop_types = array( 'string', 'number', 'boolean', 'array', 'int', 'float', 'enum', 'color' ); |
| 68 | 68 | // Expanded to support Factory extras and color control. |
| 69 | - $allowed_control_types = array( 'text', 'number', 'checkbox', 'textarea', 'select', 'range_number', 'len', 'color' ); | |
| 69 | + $allowed_control_types = array( 'text', 'number', 'checkbox', 'textarea', 'select', 'range_number', 'len', 'color', 'slot' ); | |
| 70 | 70 | |
| 71 | 71 | // Validate prop meta. |
| 72 | 72 | foreach ( $pack['schema']['props'] as $prop_key => $meta ) { |
| 73 | 73 | |
| @@ -102,13 +102,20 @@ | ||
| 102 | 102 | if ( ! is_array( $control ) ) { |
| 103 | 103 | unset( $group['controls'][ $c_i ] ); |
| 104 | 104 | continue; |
| 105 | 105 | } |
| 106 | - if ( empty( $control['key'] ) || empty( $control['type'] ) || ! in_array( $control['type'], $allowed_control_types, true ) ) { | |
| 107 | - unset( $group['controls'][ $c_i ] ); | |
| 108 | - continue; | |
| 109 | - } | |
| 110 | - // Remove objects in control meta. | |
| 106 | + if ( empty( $control['key'] ) || empty( $control['type'] ) || ! in_array( $control['type'], $allowed_control_types, true ) ) { | |
| 107 | + unset( $group['controls'][ $c_i ] ); | |
| 108 | + continue; | |
| 109 | + } | |
| 110 | + if ( 'slot' === $control['type'] ) { | |
| 111 | + $control['slot'] = isset( $control['slot'] ) ? sanitize_key( $control['slot'] ) : ''; | |
| 112 | + if ( '' === $control['slot'] ) { | |
| 113 | + unset( $group['controls'][ $c_i ] ); | |
| 114 | + continue; | |
| 115 | + } | |
| 116 | + } | |
| 117 | + // Remove objects in control meta. | |
| 111 | 118 | foreach ( $control as $k => $v ) { |
| 112 | 119 | if ( is_object( $v ) && ! ( $v instanceof JsonSerializable ) ) { |
| 113 | 120 | unset( $control[ $k ] ); |
| 114 | 121 | } |