/** * Display a group of radio buttons * * @param array $setting See `do_settings_field()`. Has been filtered through `RO3::get_field_array()` * @return null * @since 1.0.0 */ public static function radio_field($setting) { extract($setting); $choices = RO3::get_choice_array($setting); foreach ($choices as $choice) { $label = $choice['label']; $value = $choice['value']; ?> <label class='radio' for="<?php echo $choice['id']; ?> "> <input type="radio" id="<?php echo $choice['id']; ?> " name="ro3_options[<?php echo $name; ?> ]" value="<?php echo $value; ?> " class="<?php if (array_key_exists('class', $setting)) { echo $setting['class']; } ?> " <?php # add data attributes if (array_key_exists('data', $choice)) { foreach ($choice['data'] as $k => $v) { echo " data-{$k}='{$v}'"; } } # add checked property if we need to if (isset(self::$options[$name])) { checked($value, self::$options[$name]); } ?> autocomplete='off' /> <?php echo $label; ?> </label> <?php } }
$out = array(); if (!is_array($choices)) { $out[] = array('id' => $name . '_' . self::clean_str_for_field($choices), 'label' => $choices, 'value' => self::clean_str_for_field($choices)); } else { foreach ($choices as $choice) { if (!is_array($choice)) { $out[] = array('label' => $choice, 'id' => $name . '_' . self::clean_str_for_field($choice), 'value' => self::clean_str_for_field($choice)); } else { # if choice is already an array, we need to check for missing data if (!array_key_exists('id', $choice)) { $choice['id'] = $name . '_' . self::clean_str_for_field($choice['label']); } if (!array_key_exists('value', $choice)) { $choice['value'] = $name . '_' . self::clean_str_for_field($choice['label']); } $out[] = $choice; } } } return $out; } } # end class RO3 # require files for plugin foreach (RO3::$classes as $class) { RO3::req_file(ro3_dir("lib/class-{$class}.php")); } # load static variables for RO3 class RO3::$style = RO3_Options::$options['style']; RO3::$color = RO3_Options::$options['main_color'];
function ro3_get_posts_for_type() { RO3::select_post_for_type($_POST['post_type'], $_POST['section']); die; }