/** * Output HTML for a <select> dropdown menu of posts for a given post type * * @param string $post_type The post type for which we're displaying posts * @return null * @since 1.0.0 */ public static function select_post_for_type($post_type, $section = '') { $args = array('post_type' => $post_type, 'posts_per_page' => -1, 'orderby' => 'post_title', 'order' => 'ASC'); $posts = get_posts($args); $choices = array(array('value' => '', 'label' => '- Select -')); foreach ($posts as $post) { $choice = array('value' => $post->ID, 'label' => $post->post_title); $choices[] = $choice; } RO3_Options::do_settings_field(array('name' => 'post_id' . $section, 'type' => 'select', 'label' => '', 'data' => array('section' => $section), 'choices' => $choices, 'description' => '<b>Note:</b> Below, you have the option to alter the title, description, image, etc. for the post you choose. Changes to the post do not auto update here.')); ?> </div> <?php }
* Load settings for the main settings section (i.e. the settings that don't come in 4's) */ # Whether to use rule of three or rule of four RO3_Options::$settings[] = array('name' => 'num_blocks', 'type' => 'select', 'label' => 'Rule Of ...', 'section' => 'main', 'choices' => array(array('value' => '3', 'label' => 'Three'), array('value' => '4', 'label' => 'Four'))); # Which style to use for the rule of three RO3_Options::$settings[] = array('name' => 'style', 'type' => 'radio', 'label' => 'Style', 'section' => 'main', 'choices' => array(array('value' => 'none', 'label' => 'None'), array('value' => 'drop-shadow', 'label' => 'Drop Shadow'), array('value' => 'nested', 'label' => 'Nested'), array('value' => 'circle', 'label' => 'Circle'), array('value' => 'bar', 'label' => 'Bar'), array('value' => 'fa-icon', 'label' => 'Font Awesome'))); # Which hover state to use RO3_Options::$settings[] = array('name' => 'hover_effect', 'type' => 'select', 'choices' => array(array('value' => '', 'label' => 'None'), array('value' => 'hvr-grow', 'label' => 'Grow'), array('value' => 'hvr-float-shadow', 'label' => 'Float Shadow')), 'label' => 'Hover Effect', 'section' => 'main'); RO3_Options::$settings[] = array('name' => 'main_color', 'type' => 'text', 'class' => 'color-picker', 'label' => 'Main Color', 'section' => 'main'); RO3_Options::$settings[] = array('name' => 'read_more', 'type' => 'checkbox', 'label' => 'Show "Read More"', 'section' => 'main', 'choices' => 'Yes'); RO3_Options::$settings[] = array('name' => 'fa_icon_size', 'type' => 'text', 'label' => 'Font Awesome Icon Size', 'section' => 'main', 'description' => 'Please enter a valid CSS value like <code>24px</code> or <code>2em</code>.<br /> Note that <code>em\'s</code> may generate a different preview size here than on the front end.'); /** * Get saved options and define defaults */ RO3_Options::$options = get_option('ro3_options'); # make sure each setting has a key in the main options (even if empty) if (!empty(RO3_Options::$options)) { foreach (RO3_Options::$settings as $setting) { if (empty(RO3_Options::$options[$setting['name']])) { RO3_Options::$options[$setting['name']] = ''; } } } # if no options have been saved yet, make sure at least all keys are present in CPTD_Options::$options if (!RO3_Options::$options) { # loop through settings foreach (RO3_Options::$settings as $setting) { # add key to options RO3_Options::$options[$setting['name']] = ''; }
function ro3_do_settings_page() { RO3_Options::settings_page(); }