/** * Initializes view. */ public function __initialize() { $icon = WP_Image_Util::get_instance()->generate_datauri(realpath(__DIR__ . '/../admin/images/data/recipes.svg')); $slug = WP_Recipe::get_instance()->get_slug(); $labels = array('add_new_item' => _x('Add New Recipe', 'recipe custom post type add new item', $slug), 'all_items' => _x('All Recipes', 'recipe custom post type all items', $slug), 'edit_item' => _x('Edit Recipe', 'recipe custom post type edit item', $slug), 'menu_name' => _x('Recipes', 'recipe custom post type menu name', $slug), 'name' => _x('Recipes', 'recipe custom post type name', $slug), 'new_item' => _x('New Recipe', 'recipe custom post type new item', $slug), 'not_found' => _x('No recipes found', 'recipe custom post type not found', $slug), 'not_found_in_trash' => _x('No recipes found in the trash', 'recipe custom post type not found in trash', $slug), 'search_items' => _x('Search Recipes', 'recipe custom post type search items', $slug), 'singular_name' => _x('Recipe', 'recipe custom post type singular name', $slug), 'view_item' => _x('View Recipe', 'recipe custom post type view item', $slug)); $args = array('description' => _x('A place to collect all your delicious recipes', 'recipe custom post type description', $slug), 'hierarchical' => false, 'labels' => $labels, 'menu_icon' => $icon, 'menu_position' => 5, 'public' => true, 'supports' => array('comments', 'editor', 'revisions', 'thumbnail', 'title')); register_post_type(WP_Recipe_Post_Type::get_instance()->get_post_type(), $args); }
/** * Gets post Pinterest meta and sets default values, if none are entered. * * @param WP_Post $post The post / page. * * @return array Pinterest meta. */ public function get_post_pinterest_meta($post) { $pinterest = maybe_unserialize(get_post_meta($post->ID, 'pinterest', true)); if (is_admin()) { if (empty($pinterest)) { $pinterest['hover'] = 'true'; $pinterest['description'] = ''; $pinterest['image'] = ''; $pinterest['url'] = ''; } return $pinterest; } if (!isset($pinterest['hover'])) { $pinterest['hover'] = 'true'; } if (empty($pinterest['description'])) { $pinterest['description'] = $post->post_title; } if (empty($pinterest['image'])) { $default_image = ''; $default_image = apply_filters('wp_pinterest_default_image', $default_image); $pinterest['image'] = WP_Image_Util::get_instance()->get_first_image($post->post_content, $default_image); } if (empty($pinterest['url'])) { $pinterest['url'] = get_permalink(); } return $pinterest; }