Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
PUM_Fields::select_callback( array $args, $value = null )
Select Callback
Description Description
Renders select fields.
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Parameters Parameters
- $args
-
(Required) Arguments passed by the setting
- $value
-
(Optional)
Default value: null
Source Source
File: includes/class-pum-fields.php
public function select_callback( $args, $value = null ) { if ( isset ( $args['select2'] ) ) { $args['class'] .= ' pum-field-select2'; } if ( ! $value ) { $value = isset( $args['std'] ) ? $args['std'] : ''; } $multiple = null; if ( $args['multiple'] ) { $multiple = 'multiple'; $args['class'] .= ' pum-field-select--multiple'; $args['name'] .= $args['as_array'] ? '[]' : ''; $value = ! is_array( $value ) ? array( $value ) : $value; } $this->field_before( $args ); $this->field_label( $args ); ?> <select id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" data-placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" data-allow-clear="true" <?php echo $multiple; ?> <?php if ( $args['required'] ) { echo 'required'; } ?>> <?php if ( ! empty( $args['options'] ) ) { foreach ( $args['options'] as $label => $option ) { $selected = ( ! $multiple && $option == $value ) || ( $multiple && in_array( $option, $value ) ); ?> <option value="<?php echo esc_attr( $option ); ?>" <?php selected( 1, $selected ); ?>><?php echo esc_html( $label ); ?></option><?php } } ?> </select><?php $this->field_description( $args ); $this->field_after(); }
Expand full source code Collapse full source code View on Trac