PluginProbe
Booking Calendar / 11.8.1
Booking Calendar v11.8.1
11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 10.11.3 All 202 releases
← All changes | core/form_parser.php +60 -8 10.1111.8.1 View file →
@@ -72,12 +72,11 @@
72 72
73 73 // Parse select shortcodes
74 74 $rx_shortcode_types = 'text[*]?|email[*]?|coupon[*]?|time[*]?|textarea[*]?|select[*]?|selectbox[*]?|checkbox[*]?|radio[*]?|acceptance|captchac|captchar|file[*]?|quiz';
75 75 // $rx_shortcode_types= 'select[*]?|selectbox[*]?|checkbox[*]?|radio[*]?';
76 - $rx_shortcode_name = '\s+[a-zA-Z][0-9a-zA-Z:._-]*';
77 - $rx_shortcode_options = '[-0-9a-zA-Z:#_/|\s]*';
78 - $rx_shortcode_values = '(?:\s*(?:"[^"]*"|\'[^\']*\'))*';
79 - $regex = '%\[\s*(' . $rx_shortcode_types . ')(' . $rx_shortcode_name . ')(' . $rx_shortcode_options . ')?(' . $rx_shortcode_values . ')?\s*\]%';
76 + $rx_shortcode_name = '\s+([a-zA-Z][0-9a-zA-Z:._-]*)';
77 + $rx_shortcode_content = '((?:[^\]"\']+|"[^"]*"|\'[^\']*\')*)';
78 + $regex = '%\[\s*(' . $rx_shortcode_types . ')(?=\s|\])' . $rx_shortcode_content . '\]%';
80 79 preg_match_all( $regex, $booking_form_configuration, $found_shortcodes, PREG_SET_ORDER );
81 80
82 81
83 82 /**
@@ -98,14 +97,20 @@
98 97 */
99 98 $form_shortcodes = array();
100 99 foreach ( $found_shortcodes as $found_shortcode ) {
101 100
101 + if ( ! preg_match( '%^' . $rx_shortcode_name . '(.*)$%s', $found_shortcode[2], $shortcode_parts ) ) {
102 + continue;
103 + }
104 +
105 + list( $shortcode_options, $shortcode_values ) = wpbc_parse_form_shortcode_options_values( $shortcode_parts[2] );
106 +
102 107 $shortcode_config = array();
103 108 $shortcode_config['full_shortcode'] = trim( $found_shortcode[0] );
104 109 $shortcode_config['type'] = trim( $found_shortcode[1] );
105 - $shortcode_config['name'] = trim( $found_shortcode[2] );
106 - $shortcode_config['options'] = trim( $found_shortcode[3] );
107 - $shortcode_config['values_str'] = trim( $found_shortcode[4] );
110 + $shortcode_config['name'] = trim( $shortcode_parts[1] );
111 + $shortcode_config['options'] = trim( $shortcode_options );
112 + $shortcode_config['values_str'] = trim( $shortcode_values );
108 113 $shortcode_config['values_arr'] = array();
109 114
110 115 if ( ! empty( $shortcode_config['values_str'] ) ) {
111 116 $shortcode_config['values_arr'] = wpbc_parse_form_shortcode_values( $shortcode_config['values_str'] );
@@ -117,8 +122,55 @@
117 122 return $form_shortcodes;
118 123 }
119 124
120 125
126 +if ( ! function_exists( 'wpbc_parse_form_shortcode_options_values' ) ) {
127 + function wpbc_parse_form_shortcode_options_values( $shortcode_tail ){
128 +
129 + $shortcode_options = trim( $shortcode_tail );
130 + $shortcode_values = '';
131 +
132 + $value_matches = array();
133 + preg_match_all( '%(?:"[^"]*"|\'[^\']*\')%', $shortcode_tail, $value_matches, PREG_OFFSET_CAPTURE );
134 +
135 + $standalone_values = array();
136 + foreach ( $value_matches[0] as $value_match ) {
137 + $value_offset = $value_match[1];
138 + $prev_offset = $value_offset - 1;
139 +
140 + if ( ( $prev_offset >= 0 ) && ! ctype_space( $shortcode_tail[ $prev_offset ] ) ) {
141 + continue;
142 + }
143 +
144 + while ( ( $prev_offset >= 0 ) && ctype_space( $shortcode_tail[ $prev_offset ] ) ) {
145 + $prev_offset--;
146 + }
147 +
148 + if ( ( $prev_offset >= 0 ) && in_array( $shortcode_tail[ $prev_offset ], array( '=', ':' ), true ) ) {
149 + continue;
150 + }
151 +
152 + $standalone_values[] = $value_match;
153 + }
154 +
155 + if ( ! empty( $standalone_values ) ) {
156 + $shortcode_options = trim( substr( $shortcode_tail, 0, $standalone_values[0][1] ) );
157 + $shortcode_values = implode(
158 + ' ',
159 + array_map(
160 + function ( $value_match ) {
161 + return $value_match[0];
162 + },
163 + $standalone_values
164 + )
165 + );
166 + }
167 +
168 + return array( $shortcode_options, $shortcode_values );
169 + }
170 +}
171 +
172 +
121 173 function wpbc_parse_form_shortcode_values( $shortcode_values ){
122 174
123 175 $values_arr = array();
124 176
@@ -263,5 +315,5 @@
263 315 }
264 316 }
265 317
266 318 return false;
267 -}
319 +}