// Set default options foreach ($templates as $id => $template) { $mapping[$id] = $template['name']; update_option('wpurp_custom_template_' . intval($id), $template['template']); } $this->update_mapping($mapping); } } public function add_template($name, $template) { $mapping = $this->get_mapping(); $template_id = max(array_keys($mapping)) + 1; $mapping[$template_id] = $name; $this->update_mapping($mapping); update_option('wpurp_custom_template_' . $template_id, $template); return $template_id; } public function update_template($id, $template) { update_option('wpurp_custom_template_' . $id, $template); } public function delete_template($id) { $mapping = $this->get_mapping(); unset($mapping[$id]); $this->update_mapping($mapping); delete_option('wpurp_custom_template_' . $id); } } WPUltimateRecipe::loaded_addon('custom-templates', new WPURP_Custom_Templates());
$singular = $_POST['wpurp_custom_taxonomy_singular_name']; $slug = str_replace(' ', '-', strtolower($_POST['wpurp_custom_taxonomy_slug'])); $edit_tag_name = $_POST['wpurp_edit']; $editing = false; if (strlen($edit_tag_name) > 0) { $editing = true; } if (!$editing) { die('There was an unexpected error. Please try again.'); } if (!$editing && taxonomy_exists(strtolower($singular))) { die('This taxonomy already exists.'); } if (strlen($name) > 1 && strlen($singular) > 1) { $taxonomies = WPUltimateRecipe::get()->tags(); $name_lower = strtolower($name); // Cannot add tags in the basic version $tag_name = $edit_tag_name; // TODO Filter this to allow customizing $taxonomies[$tag_name] = array('labels' => array('name' => $name, 'singular_name' => $singular, 'search_items' => __('Search', 'wp-ultimate-recipe') . ' ' . $name, 'popular_items' => __('Popular', 'wp-ultimate-recipe') . ' ' . $name, 'all_items' => __('All', 'wp-ultimate-recipe') . ' ' . $name, 'edit_item' => __('Edit', 'wp-ultimate-recipe') . ' ' . $singular, 'update_item' => __('Update', 'wp-ultimate-recipe') . ' ' . $singular, 'add_new_item' => __('Add New', 'wp-ultimate-recipe') . ' ' . $singular, 'new_item_name' => __('New', 'wp-ultimate-recipe') . ' ' . $singular . ' ' . __('Name', 'wp-ultimate-recipe'), 'separate_items_with_commas' => __('Separate', 'wp-ultimate-recipe') . ' ' . $name_lower . ' ' . __('with commas', 'wp-ultimate-recipe'), 'add_or_remove_items' => __('Add or remove', 'wp-ultimate-recipe') . ' ' . $name_lower, 'choose_from_most_used' => __('Choose from the most used', 'wp-ultimate-recipe') . ' ' . $name_lower, 'not_found' => __('No', 'wp-ultimate-recipe') . ' ' . $name_lower . ' ' . __('found.', 'wp-ultimate-recipe'), 'menu_name' => $name), 'show_ui' => true, 'show_tagcloud' => true, 'hierarchical' => true, 'rewrite' => array('slug' => $slug, 'hierarchical' => true)); WPUltimateRecipe::get()->helper('taxonomies')->update($taxonomies); WPUltimateRecipe::get()->helper('taxonomies')->check_recipe_taxonomies(); WPUltimateRecipe::get()->helper('permalinks_flusher')->set_flush_needed(); } wp_redirect($_SERVER['HTTP_REFERER']); exit; } } WPUltimateRecipe::loaded_addon('basic-custom-taxonomies', new WPURP_Basic_Custom_Taxonomies()); } // !WPUltimateRecipe::is_premium_active()