function recipress_insert_taxonomies($meta_fields) { $taxonomies = recipress_use_taxonomies(); if (!isset($taxonomies)) { $taxonomies = array('cuisine', 'course', 'skill_level'); } if ($taxonomies != '') { foreach ($taxonomies as $taxonomy) { $tax_name = ''; if ($taxonomy == 'cuisine') { $tax_name = __('Cuisine', 'recipress'); } if ($taxonomy == 'course') { $tax_name = __('Course', 'recipress'); } if ($taxonomy == 'skill_level') { $tax_name = __('Skill Level', 'recipress'); } $add_taxonomies[$taxonomy] = array('name' => $tax_name, 'id' => $taxonomy, 'type' => 'tax_select'); } } if ($add_taxonomies) { return recipress_array_insert($meta_fields, 'summary', $add_taxonomies); } else { return $meta_fields; } }
function recipress_add_page() { add_menu_page(__('ReciPress Options', 'recipress'), __('ReciPress', 'recipress'), 'edit_others_posts', 'recipress_options', 'recipress_do_page'); add_submenu_page('recipress_options', __('ReciPress Options', 'recipress'), __('ReciPress Options', 'recipress'), 'edit_others_posts', 'recipress_options', 'recipress_do_page'); add_submenu_page('recipress_options', __('Ingredients', 'recipress'), __('Ingredients', 'recipress'), 'edit_others_posts', 'edit-tags.php?taxonomy=ingredient'); $taxonomies = recipress_use_taxonomies(); if (!isset($taxonomies) || isset($taxonomies) && in_array('cuisine', $taxonomies)) { add_submenu_page('recipress_options', __('Cuisines', 'recipress'), __('Cuisines', 'recipress'), 'edit_others_posts', 'edit-tags.php?taxonomy=cuisine'); } if (!isset($taxonomies) || isset($taxonomies) && in_array('course', $taxonomies)) { add_submenu_page('recipress_options', __('Courses', 'recipress'), __('Courses', 'recipress'), 'edit_others_posts', 'edit-tags.php?taxonomy=course'); } if (!isset($taxonomies) || isset($taxonomies) && in_array('skill_level', $taxonomies)) { add_submenu_page('recipress_options', __('Skill Levels', 'recipress'), __('Skill Levels', 'recipress'), 'edit_others_posts', 'edit-tags.php?taxonomy=skill_level'); } }
/** @see WP_Widget::form */ function form($instance) { if ($instance) { $title = esc_attr($instance['title']); $taxonomy = $instance['taxonomy']; $type = $instance['type']; } else { $title = ''; $taxonomy = 'course'; $type = 'list'; } $taxonomies = recipress_use_taxonomies(); array_unshift($taxonomies, 'ingredient'); foreach ($taxonomies as $tax) { $tax = get_taxonomy($tax); $taxes[] = array('id' => $tax->query_var, 'name' => $tax->label); } ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'recipress'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo $title; ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('taxonomy'); ?> "><?php _e('Taxonomy:', 'recipress'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?> " name="<?php echo $this->get_field_name('taxonomy'); ?> "><?php foreach ($taxes as $tax) { echo '<option', $taxonomy == $tax['id'] ? ' selected="selected"' : '', ' value="' . $tax['id'] . '">' . $tax['name'] . '</option>'; } ?> </select> </p> <p> <label><?php _e('Output Type:', 'recipress'); ?> </label> <br /> <label><input id="<?php echo $this->get_field_id('type'); ?> _list" name="<?php echo $this->get_field_name('type'); ?> " type="radio"<?php if ($type == 'list') { echo ' checked="checked"'; } ?> value="list" /><?php _e('List', 'recipress'); ?> </label> <label><input id="<?php echo $this->get_field_id('type'); ?> _cloud" name="<?php echo $this->get_field_name('type'); ?> " type="radio"<?php if ($type == 'cloud') { echo ' checked="checked"'; } ?> value="cloud" /><?php _e('Cloud', 'recipress'); ?> </label> </p> <?php }