| @@ -19,9 +19,13 @@ | ||
| 19 | 19 | */ |
| 20 | 20 | function propertyhive_wp_text_input( $field ) { |
| 21 | 21 | global $thepostid, $post, $propertyhive; |
| 22 | 22 | |
| 23 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared meta-box global contract; $thepostid is intentionally carried into the public Property Hive field-rendering helpers. | |
| 23 | 24 | $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
| 25 | + | |
| 26 | + $field = apply_filters( 'propertyhive_meta_box_wp_text_field', $field, $thepostid ); | |
| 27 | + | |
| 24 | 28 | $field['placeholder'] = isset( $field['placeholder'] ) ? $field['placeholder'] : ''; |
| 25 | 29 | $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short'; |
| 26 | 30 | $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
| 27 | 31 | $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); |
| @@ -49,9 +53,12 @@ | ||
| 49 | 53 | |
| 50 | 54 | echo ' |
| 51 | 55 | <p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"> |
| 52 | 56 | <label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label> |
| 53 | - <input type="' . esc_attr( $field['type'] ) . '" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['value'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" ' . implode( ' ', $custom_attributes ) . ' /> '; | |
| 57 | + <input type="' . esc_attr( $field['type'] ) . '" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['value'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" '; | |
| 58 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Custom attributes come from the PHP field definition/filter; every name and value is escaped above before assembling this attribute fragment. | |
| 59 | + echo implode( ' ', $custom_attributes ); | |
| 60 | + echo ' /> '; | |
| 54 | 61 | |
| 55 | 62 | if ( ! empty( $field['description'] ) ) { |
| 56 | 63 | |
| 57 | 64 | if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) { |
| @@ -64,9 +71,9 @@ | ||
| 64 | 71 | echo '</p>'; |
| 65 | 72 | } |
| 66 | 73 | |
| 67 | 74 | /** |
| 68 | - * Output a file input box. | |
| 75 | + * Output a photo input box. | |
| 69 | 76 | * |
| 70 | 77 | * @access public |
| 71 | 78 | * @param array $field |
| 72 | 79 | * @return void |
| @@ -73,9 +80,13 @@ | ||
| 73 | 80 | */ |
| 74 | 81 | function propertyhive_wp_photo_upload( $field ) { |
| 75 | 82 | global $thepostid, $post, $propertyhive; |
| 76 | 83 | |
| 84 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared meta-box global contract; $thepostid is intentionally carried into the public Property Hive field-rendering helpers. | |
| 77 | 85 | $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
| 86 | + | |
| 87 | + $field = apply_filters( 'propertyhive_meta_box_wp_photo_upload_field', $field, $thepostid ); | |
| 88 | + | |
| 78 | 89 | $field['id'] = isset( $field['id'] ) ? $field['id'] : ''; |
| 79 | 90 | $field['button_label'] = isset( $field['button_label'] ) ? $field['button_label'] : __('Select Photo', 'propertyhive'); |
| 80 | 91 | $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short'; |
| 81 | 92 | $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
| @@ -98,9 +109,9 @@ | ||
| 98 | 109 | { |
| 99 | 110 | echo ' style="display:none;"'; |
| 100 | 111 | } |
| 101 | 112 | echo '> |
| 102 | - <label for="' . esc_attr( $field['id'] ) . '">' . __( 'Uploaded', 'propertyhive' ) . ' ' . wp_kses_post( $field['label'] ) . '</label> | |
| 113 | + <label for="' . esc_attr( $field['id'] ) . '">' . esc_html(__( 'Uploaded', 'propertyhive' )) . ' ' . wp_kses_post( $field['label'] ) . '</label> | |
| 103 | 114 | <span>'; |
| 104 | 115 | if ( $field['value'] != '' ) |
| 105 | 116 | { |
| 106 | 117 | $image = wp_get_attachment_image_src( $field['value'], 'thumbnail' ); |
| @@ -105,9 +116,9 @@ | ||
| 105 | 116 | { |
| 106 | 117 | $image = wp_get_attachment_image_src( $field['value'], 'thumbnail' ); |
| 107 | 118 | if ($image !== FALSE) |
| 108 | 119 | { |
| 109 | - echo '<img src="' . $image[0] . '" width="150" alt="">'; | |
| 120 | + echo '<img src="' . esc_url($image[0]) . '" width="150" alt="">'; | |
| 110 | 121 | } |
| 111 | 122 | else |
| 112 | 123 | { |
| 113 | 124 | echo 'Image doesn\'t exist'; |
| @@ -118,9 +129,9 @@ | ||
| 118 | 129 | |
| 119 | 130 | echo ' |
| 120 | 131 | <p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"> |
| 121 | 132 | <label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label> |
| 122 | - <a href="" class="button button-primary ph_upload_photo_button' . $field['id'] . '">' . $field['button_label'] . '</a>'; | |
| 133 | + <a href="" class="button button-primary ph_upload_photo_button' . esc_attr($field['id']) . '">' . esc_html($field['button_label']) . '</a>'; | |
| 123 | 134 | |
| 124 | 135 | if ( ! empty( $field['description'] ) ) { |
| 125 | 136 | |
| 126 | 137 | if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) { |
| @@ -133,24 +144,24 @@ | ||
| 133 | 144 | echo '</p>'; |
| 134 | 145 | |
| 135 | 146 | echo '<script> |
| 136 | 147 | |
| 137 | - var file_frame' . $field['id'] . '; | |
| 148 | + var file_frame' . esc_js($field['id']) . '; | |
| 138 | 149 | |
| 139 | 150 | jQuery(document).ready(function() |
| 140 | 151 | { |
| 141 | - jQuery(\'.ph_upload_photo_button' . $field['id'] . '\').live(\'click\', function( event ){ | |
| 152 | + jQuery(\'body\').on(\'click\', \'.ph_upload_photo_button' . esc_js($field['id']) . '\', function( event ){ | |
| 142 | 153 | |
| 143 | 154 | event.preventDefault(); |
| 144 | 155 | |
| 145 | 156 | // If the media frame already exists, reopen it. |
| 146 | - if ( file_frame' . $field['id'] . ' ) { | |
| 147 | - file_frame' . $field['id'] . '.open(); | |
| 157 | + if ( file_frame' . esc_js($field['id']) . ' ) { | |
| 158 | + file_frame' . esc_js($field['id']) . '.open(); | |
| 148 | 159 | return; |
| 149 | 160 | } |
| 150 | 161 | |
| 151 | 162 | // Create the media frame. |
| 152 | - file_frame' . $field['id'] . ' = wp.media.frames.file_frame' . $field['id'] . ' = wp.media({ | |
| 163 | + file_frame' . esc_js($field['id']) . ' = wp.media.frames.file_frame' . esc_js($field['id']) . ' = wp.media({ | |
| 153 | 164 | title: jQuery( this ).data( \'uploader_title\' ), |
| 154 | 165 | button: { |
| 155 | 166 | text: jQuery( this ).data( \'uploader_button_text\' ), |
| 156 | 167 | }, |
| @@ -157,10 +168,10 @@ | ||
| 157 | 168 | multiple: false // Set to true to allow multiple files to be selected |
| 158 | 169 | }); |
| 159 | 170 | |
| 160 | 171 | // When an image is selected, run a callback. |
| 161 | - file_frame' . $field['id'] . '.on( \'select\', function() { | |
| 162 | - var selection = file_frame' . $field['id'] . '.state().get(\'selection\'); | |
| 172 | + file_frame' . esc_js($field['id']) . '.on( \'select\', function() { | |
| 173 | + var selection = file_frame' . esc_js($field['id']) . '.state().get(\'selection\'); | |
| 163 | 174 | |
| 164 | 175 | selection.map( function( attachment ) { |
| 165 | 176 | |
| 166 | 177 | attachment = attachment.toJSON(); |
| @@ -165,21 +176,141 @@ | ||
| 165 | 176 | |
| 166 | 177 | attachment = attachment.toJSON(); |
| 167 | 178 | |
| 168 | 179 | // Do something with attachment.id and/or attachment.url here |
| 169 | - console.log(attachment.url); | |
| 180 | + console.log(attachment); | |
| 170 | 181 | |
| 171 | - // Add selected image to page | |
| 172 | - //add_photo_attachment_to_grid(attachment); | |
| 182 | + jQuery(\'.form-field.' . esc_js( $field['id'] ) . '_field\').show(); | |
| 183 | + jQuery(\'.form-field.' . esc_js( $field['id'] ) . '_field span\').html(\'<img src="\' + attachment.url + \'" width="150" alt="">\'); | |
| 184 | + jQuery(\'#' . esc_js( $field['id'] ) . '\').val(attachment.id); | |
| 185 | + }); | |
| 186 | + }); | |
| 187 | + | |
| 188 | + // Finally, open the modal | |
| 189 | + file_frame' . esc_js($field['id']) . '.open(); | |
| 190 | + }); | |
| 191 | + }); | |
| 173 | 192 | |
| 174 | - jQuery(\'.form-field.' . esc_attr( $field['id'] ) . '_field\').show(); | |
| 175 | - jQuery(\'.form-field.' . esc_attr( $field['id'] ) . '_field span\').html(\'<img src="\' + attachment.url + \'" width="150" alt="">\'); | |
| 176 | - jQuery(\'#' . esc_attr( $field['id'] ) . '\').val(attachment.id); | |
| 193 | + </script>'; | |
| 194 | +} | |
| 195 | + | |
| 196 | +/** | |
| 197 | + * Output a file input box. | |
| 198 | + * | |
| 199 | + * @access public | |
| 200 | + * @param array $field | |
| 201 | + * @return void | |
| 202 | + */ | |
| 203 | +function propertyhive_wp_file_upload( $field ) { | |
| 204 | + global $thepostid, $post, $propertyhive; | |
| 205 | + | |
| 206 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared meta-box global contract; $thepostid is intentionally carried into the public Property Hive field-rendering helpers. | |
| 207 | + $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; | |
| 208 | + | |
| 209 | + $field = apply_filters( 'propertyhive_meta_box_wp_file_upload_field', $field, $thepostid ); | |
| 210 | + | |
| 211 | + $field['id'] = isset( $field['id'] ) ? $field['id'] : ''; | |
| 212 | + $field['button_label'] = isset( $field['button_label'] ) ? $field['button_label'] : __('Select Photo', 'propertyhive'); | |
| 213 | + $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short'; | |
| 214 | + $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; | |
| 215 | + $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); | |
| 216 | + $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; | |
| 217 | + $data_type = empty( $field['data_type'] ) ? '' : $field['data_type']; | |
| 218 | + | |
| 219 | + // Custom attribute handling | |
| 220 | + $custom_attributes = array(); | |
| 221 | + | |
| 222 | + if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) | |
| 223 | + foreach ( $field['custom_attributes'] as $attribute => $value ) | |
| 224 | + $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; | |
| 225 | + | |
| 226 | + propertyhive_wp_hidden_input( $field ); | |
| 227 | + | |
| 228 | + echo ' | |
| 229 | + <p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"'; | |
| 230 | + if ( $field['value'] == '' ) | |
| 231 | + { | |
| 232 | + echo ' style="display:none;"'; | |
| 233 | + } | |
| 234 | + echo '> | |
| 235 | + <label for="' . esc_attr( $field['id'] ) . '">' . esc_html(__( 'Uploaded', 'propertyhive' )) . ' ' . wp_kses_post( $field['label'] ) . '</label> | |
| 236 | + <span>'; | |
| 237 | + if ( $field['value'] != '' ) | |
| 238 | + { | |
| 239 | + $file = get_attached_file( $field['value'] ); | |
| 240 | + if ( $file !== FALSE ) | |
| 241 | + { | |
| 242 | + $filename = basename( $file ); | |
| 243 | + echo '<a href="' . esc_url(wp_get_attachment_url($field['value'])) . '" target="_blank">' . esc_html($filename) . '</a>'; | |
| 244 | + } | |
| 245 | + else | |
| 246 | + { | |
| 247 | + echo 'Image doesn\'t exist'; | |
| 248 | + } | |
| 249 | + } | |
| 250 | + echo '</span> | |
| 251 | + </p>'; | |
| 252 | + | |
| 253 | + echo ' | |
| 254 | + <p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"> | |
| 255 | + <label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label> | |
| 256 | + <a href="" class="button button-primary ph_upload_file_button' . esc_attr($field['id']) . '">' . esc_html($field['button_label']) . '</a>'; | |
| 257 | + | |
| 258 | + if ( ! empty( $field['description'] ) ) { | |
| 259 | + | |
| 260 | + if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) { | |
| 261 | + echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . esc_url( PH()->plugin_url() ) . '/assets/images/help.png" height="16" width="16" />'; | |
| 262 | + } else { | |
| 263 | + echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>'; | |
| 264 | + } | |
| 265 | + | |
| 266 | + } | |
| 267 | + echo '</p>'; | |
| 268 | + | |
| 269 | + echo '<script> | |
| 270 | + | |
| 271 | + var file_frame' . esc_js($field['id']) . '; | |
| 272 | + | |
| 273 | + jQuery(document).ready(function() | |
| 274 | + { | |
| 275 | + jQuery(\'body\').on(\'click\', \'.ph_upload_file_button' . esc_js($field['id']) . '\', function( event ){ | |
| 276 | + | |
| 277 | + event.preventDefault(); | |
| 278 | + | |
| 279 | + // If the media frame already exists, reopen it. | |
| 280 | + if ( file_frame' . esc_js($field['id']) . ' ) { | |
| 281 | + file_frame' . esc_js($field['id']) . '.open(); | |
| 282 | + return; | |
| 283 | + } | |
| 284 | + | |
| 285 | + // Create the media frame. | |
| 286 | + file_frame' . esc_js($field['id']) . ' = wp.media.frames.file_frame' . esc_js($field['id']) . ' = wp.media({ | |
| 287 | + title: jQuery( this ).data( \'uploader_title\' ), | |
| 288 | + button: { | |
| 289 | + text: jQuery( this ).data( \'uploader_button_text\' ), | |
| 290 | + }, | |
| 291 | + multiple: false // Set to true to allow multiple files to be selected | |
| 292 | + }); | |
| 293 | + | |
| 294 | + // When an image is selected, run a callback. | |
| 295 | + file_frame' . esc_js($field['id']) . '.on( \'select\', function() { | |
| 296 | + var selection = file_frame' . esc_js($field['id']) . '.state().get(\'selection\'); | |
| 297 | + | |
| 298 | + selection.map( function( attachment ) { | |
| 299 | + | |
| 300 | + attachment = attachment.toJSON(); | |
| 301 | + | |
| 302 | + // Do something with attachment.id and/or attachment.url here | |
| 303 | + console.log(attachment); | |
| 304 | + | |
| 305 | + jQuery(\'.form-field.' . esc_js($field['id']) . '_field\').show(); | |
| 306 | + jQuery(\'.form-field.' . esc_js($field['id']) . '_field span\').html(\'<a href="\' + attachment.url + \'" target="_blank">\' + attachment.filename + \'</a>\'); | |
| 307 | + jQuery(\'#' . esc_js($field['id']) . '\').val(attachment.id); | |
| 177 | 308 | }); |
| 178 | 309 | }); |
| 179 | 310 | |
| 180 | 311 | // Finally, open the modal |
| 181 | - file_frame' . $field['id'] . '.open(); | |
| 312 | + file_frame' . esc_js($field['id']) . '.open(); | |
| 182 | 313 | }); |
| 183 | 314 | }); |
| 184 | 315 | |
| 185 | 316 | </script>'; |
| @@ -194,9 +325,13 @@ | ||
| 194 | 325 | */ |
| 195 | 326 | function propertyhive_wp_hidden_input( $field ) { |
| 196 | 327 | global $thepostid, $post; |
| 197 | 328 | |
| 329 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared meta-box global contract; $thepostid is intentionally carried into the public Property Hive field-rendering helpers. | |
| 198 | 330 | $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
| 331 | + | |
| 332 | + $field = apply_filters( 'propertyhive_meta_box_wp_hidden_field', $field, $thepostid ); | |
| 333 | + | |
| 199 | 334 | $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); |
| 200 | 335 | |
| 201 | 336 | echo '<input type="hidden" name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['value'] ) . '" /> '; |
| 202 | 337 | } |
| @@ -210,9 +345,13 @@ | ||
| 210 | 345 | */ |
| 211 | 346 | function propertyhive_wp_textarea_input( $field ) { |
| 212 | 347 | global $thepostid, $post, $propertyhive; |
| 213 | 348 | |
| 349 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared meta-box global contract; $thepostid is intentionally carried into the public Property Hive field-rendering helpers. | |
| 214 | 350 | $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
| 351 | + | |
| 352 | + $field = apply_filters( 'propertyhive_meta_box_wp_textarea_field', $field, $thepostid ); | |
| 353 | + | |
| 215 | 354 | $field['placeholder'] = isset( $field['placeholder'] ) ? $field['placeholder'] : ''; |
| 216 | 355 | $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short'; |
| 217 | 356 | $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
| 218 | 357 | $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); |
| @@ -224,9 +363,12 @@ | ||
| 224 | 363 | if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) |
| 225 | 364 | foreach ( $field['custom_attributes'] as $attribute => $value ) |
| 226 | 365 | $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; |
| 227 | 366 | |
| 228 | - echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><textarea class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" rows="2" cols="20" ' . implode( ' ', $custom_attributes ) . '>' . esc_textarea( $field['value'] ) . '</textarea> '; | |
| 367 | + echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><textarea class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" rows="2" cols="20" '; | |
| 368 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Custom attributes come from the PHP field definition/filter; every name and value is escaped above before assembling this attribute fragment. | |
| 369 | + echo implode( ' ', $custom_attributes ); | |
| 370 | + echo '>' . esc_textarea( $field['value'] ) . '</textarea> '; | |
| 229 | 371 | |
| 230 | 372 | if ( ! empty( $field['description'] ) ) { |
| 231 | 373 | |
| 232 | 374 | if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) { |
| @@ -248,9 +390,13 @@ | ||
| 248 | 390 | */ |
| 249 | 391 | function propertyhive_wp_checkbox( $field ) { |
| 250 | 392 | global $thepostid, $post; |
| 251 | 393 | |
| 394 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared meta-box global contract; $thepostid is intentionally carried into the public Property Hive field-rendering helpers. | |
| 252 | 395 | $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
| 396 | + | |
| 397 | + $field = apply_filters( 'propertyhive_meta_box_wp_checkbox_field', $field, $thepostid ); | |
| 398 | + | |
| 253 | 399 | $field['class'] = isset( $field['class'] ) ? $field['class'] : 'checkbox'; |
| 254 | 400 | $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
| 255 | 401 | $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); |
| 256 | 402 | $field['cbvalue'] = isset( $field['cbvalue'] ) ? $field['cbvalue'] : 'yes'; |
| @@ -272,9 +418,13 @@ | ||
| 272 | 418 | */ |
| 273 | 419 | function propertyhive_wp_checkboxes( $field ) { |
| 274 | 420 | global $thepostid, $post; |
| 275 | 421 | |
| 422 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared meta-box global contract; $thepostid is intentionally carried into the public Property Hive field-rendering helpers. | |
| 276 | 423 | $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
| 424 | + | |
| 425 | + $field = apply_filters( 'propertyhive_meta_box_wp_checkboxes_field', $field, $thepostid ); | |
| 426 | + | |
| 277 | 427 | $field['class'] = isset( $field['class'] ) ? $field['class'] : 'checkbox'; |
| 278 | 428 | $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
| 279 | 429 | $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
| 280 | 430 | $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['name'], true ); |
| @@ -281,9 +431,9 @@ | ||
| 281 | 431 | |
| 282 | 432 | echo '<fieldset class="form-field ' . esc_attr( $field['wrapper_class'] ) . '"><legend>' . wp_kses_post( $field['label'] ) . '</legend><ul class="ph-radios">'; |
| 283 | 433 | |
| 284 | 434 | foreach ( $field['options'] as $key => $value ) { |
| 285 | - echo '<li><label><input type="checkbox" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '[]" id="' . esc_attr( $field['name'] ) . '_' . $key . '" value="' . esc_attr( $key ) . '" ' . ( ( !empty($field['value']) && in_array( $key, $field['value'] ) ) ? 'checked' : '' ) . ' /> ' . $value . '</label></li>'; | |
| 435 | + echo '<li><label><input type="checkbox" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '[]" id="' . esc_attr( $field['name'] . '_' . $key ) . '" value="' . esc_attr( $key ) . '" ' . ( ( !empty($field['value']) && in_array( $key, $field['value'] ) ) ? 'checked' : '' ) . ' /> ' . esc_html($value) . '</label></li>'; | |
| 286 | 436 | } |
| 287 | 437 | |
| 288 | 438 | echo '</ul>'; |
| 289 | 439 | |
| @@ -301,9 +451,13 @@ | ||
| 301 | 451 | */ |
| 302 | 452 | function propertyhive_wp_select( $field ) { |
| 303 | 453 | global $thepostid, $post, $propertyhive; |
| 304 | 454 | |
| 455 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared meta-box global contract; $thepostid is intentionally carried into the public Property Hive field-rendering helpers. | |
| 305 | 456 | $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
| 457 | + | |
| 458 | + $field = apply_filters( 'propertyhive_meta_box_wp_select_field', $field, $thepostid ); | |
| 459 | + | |
| 306 | 460 | $field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short'; |
| 307 | 461 | $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
| 308 | 462 | $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); |
| 309 | 463 | $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
| @@ -339,9 +493,13 @@ | ||
| 339 | 493 | */ |
| 340 | 494 | function propertyhive_wp_select_optgroups( $field ) { |
| 341 | 495 | global $thepostid, $post, $propertyhive; |
| 342 | 496 | |
| 497 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared meta-box global contract; $thepostid is intentionally carried into the public Property Hive field-rendering helpers. | |
| 343 | 498 | $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
| 499 | + | |
| 500 | + $field = apply_filters( 'propertyhive_meta_box_wp_select_optgroups_field', $field, $thepostid ); | |
| 501 | + | |
| 344 | 502 | $field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short'; |
| 345 | 503 | $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
| 346 | 504 | $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); |
| 347 | 505 | |
| @@ -386,9 +544,13 @@ | ||
| 386 | 544 | */ |
| 387 | 545 | function propertyhive_wp_radio( $field ) { |
| 388 | 546 | global $thepostid, $post, $propertyhive; |
| 389 | 547 | |
| 548 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared meta-box global contract; $thepostid is intentionally carried into the public Property Hive field-rendering helpers. | |
| 390 | 549 | $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
| 550 | + | |
| 551 | + $field = apply_filters( 'propertyhive_meta_box_wp_radio_field', $field, $thepostid ); | |
| 552 | + | |
| 391 | 553 | $field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short'; |
| 392 | 554 | $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
| 393 | 555 | $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); |
| 394 | 556 | $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |