Example #1
0
 /**
  * Install Recipe Hero
  * @todo next DB updater, add to version compare: && null !== $current_db_version )
  */
 public function install()
 {
     $this->create_options();
     // Register post types
     include_once 'class-rh-post-types.php';
     RH_Post_types::register_post_types();
     RH_Post_types::register_taxonomies();
     // Queue upgrades
     $current_version = get_option('recipe_hero_version', null);
     $current_db_version = get_option('recipe_hero_db_version', null);
     if (version_compare($current_db_version, '1.0.0', '<')) {
         update_option('_rh_needs_update', 1);
     } else {
         update_option('recipe_hero_db_version', RecipeHero::$version);
     }
     // Update version
     update_option('recipe_hero_version', RecipeHero::$version);
     // Rating Reminder
     self::install_date();
     // Flush rules after install
     flush_rewrite_rules();
 }
Example #2
0
     * @since 	  1.0.8
     */
    public static function register_post_types()
    {
        if (post_type_exists('recipe')) {
            return;
        }
        $permalinks = get_option('recipe_hero_permalinks');
        $recipe_permalink = empty($permalinks['recipe_base']) ? _x('recipe', 'slug', 'recipe-hero') : $permalinks['recipe_base'];
        $labels = array('name' => _x('Recipes', 'post type general name'), 'singular_name' => _x('Recipe', 'post type singular name'), 'all_items' => __('All Recipes'), 'add_new' => __('Add New'), 'add_new_item' => __('Add New Recipe'), 'edit_item' => __('Edit Recipe'), 'new_item' => __('New Recipe'), 'view_item' => __('View Recipe'), 'search_items' => __('Search Recipes'), 'not_found' => __('No Recipes found'), 'not_found_in_trash' => __('No Recipes found in the trash'), 'parent_item_colon' => '', 'menu_name' => __('Recipe Hero'));
        $taxonomies = array();
        $supports = array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'custom-fields', 'publicize', 'page-attributes');
        $post_type_args = apply_filters('recipe_hero_recipe_post_type_args', array('labels' => $labels, 'singular_label' => __('Recipe'), 'public' => true, 'show_ui' => true, 'publicly_queryable' => true, 'query_var' => true, 'exclude_from_search' => false, 'show_in_nav_menus' => true, 'capability_type' => 'post', 'has_archive' => ($recipes_page_id = rh_get_page_id('recipes')) && get_post($recipes_page_id) ? get_page_uri($recipes_page_id) : 'recipes', 'hierarchical' => false, 'rewrite' => $recipe_permalink ? array('slug' => untrailingslashit($recipe_permalink), 'with_front' => false, 'feeds' => true) : false, 'supports' => $supports, 'menu_position' => 35, 'menu_icon' => 'dashicons-shield', 'taxonomies' => $taxonomies));
        register_post_type('recipe', $post_type_args);
    }
    /**
     * Filter post updated messages for the recipe post type
     *
     * @package   Recipe Hero
     * @author    Captain Theme <*****@*****.**>
     * @since 	  1.0.8
     */
    public static function recipe_updated_messages($messages)
    {
        global $post, $post_ID;
        $messages['recipe'] = array(0 => '', 1 => sprintf(__('Recipe updated. <a href="%s">View recipe</a>', 'recipe-hero'), esc_url(get_permalink($post_ID))), 2 => '', 3 => '', 4 => __('Recipe updated.', 'recipe-hero'), 5 => isset($_GET['revision']) ? sprintf(__('Recipe restored to revision from %s', 'recipe-hero'), wp_post_revision_title((int) $_GET['revision'], false)) : false, 6 => sprintf(__('Recipe published. <a href="%s">View recipe</a>', 'recipe-hero'), esc_url(get_permalink($post_ID))), 7 => __('Recipe saved.', 'recipe-hero'), 8 => sprintf(__('Recipe submitted. <a target="_blank" href="%s">Preview recipe</a>', 'recipe-hero'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))), 9 => sprintf(__('Recipe scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview recipe</a>', 'recipe-hero'), date_i18n(__('M j, Y @ G:i', 'recipe-hero'), strtotime($post->post_date)), esc_url(get_permalink($post_ID))), 10 => sprintf(__('Recipe draft updated. <a target="_blank" href="%s">Preview recipe</a>', 'recipe-hero'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))));
        return $messages;
    }
}
RH_Post_types::init();