PluginProbe
Flash Toolkit / trunk
Flash Toolkit vtrunk
trunk 1.0 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6
flash-toolkit / includes / class-flash-post-types.php

class-flash-post-types.php in Flash Toolkit trunk, at includes/class-flash-post-types.php

209 lines 8.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Post Types
4 *
5 * Registers post types and taxonomies.
6 *
7 * @class FT_Post_Types
8 * @version 1.0.0
9 * @package FlashToolkit/Classes/Portfolio
10 * @category Class
11 * @author ThemeGrill
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 /**
19 * FT_Post_Types Class
20 */
21 class FT_Post_Types {
22
23 /**
24 * Hook in methods.
25 */
26 public static function init() {
27 add_action( 'init', array( __CLASS__, 'register_taxonomies' ), 5 );
28 add_action( 'init', array( __CLASS__, 'register_post_types' ), 5 );
29 add_action( 'init', array( __CLASS__, 'support_jetpack_omnisearch' ) );
30 add_filter( 'rest_api_allowed_post_types', array( __CLASS__, 'rest_api_allowed_post_types' ) );
31 add_action( 'flash_toolkit_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
32 }
33
34 /**
35 * Register core taxonomies.
36 */
37 public static function register_taxonomies() {
38 if ( ! is_blog_installed() || taxonomy_exists( 'portfolio_cat' ) ) {
39 return;
40 }
41
42 do_action( 'flash_toolkit_register_taxonomy' );
43
44 $permalinks = flash_get_permalink_structure();
45
46 register_taxonomy( 'portfolio_cat',
47 apply_filters( 'flash_toolkit_taxonomy_objects_portfolio_cat', array( 'portfolio' ) ),
48 apply_filters( 'flash_toolkit_taxonomy_args_portfolio_cat', array(
49 'hierarchical' => true,
50 'label' => __( 'Categories', 'flash-toolkit' ),
51 'labels' => array(
52 'name' => __( 'Project Categories', 'flash-toolkit' ),
53 'singular_name' => __( 'Category', 'flash-toolkit' ),
54 'menu_name' => _x( 'Categories', 'Admin menu name', 'flash-toolkit' ),
55 'search_items' => __( 'Search Categories', 'flash-toolkit' ),
56 'all_items' => __( 'All Categories', 'flash-toolkit' ),
57 'parent_item' => __( 'Parent Category', 'flash-toolkit' ),
58 'parent_item_colon' => __( 'Parent Category:', 'flash-toolkit' ),
59 'edit_item' => __( 'Edit Category', 'flash-toolkit' ),
60 'update_item' => __( 'Update Category', 'flash-toolkit' ),
61 'add_new_item' => __( 'Add New Category', 'flash-toolkit' ),
62 'new_item_name' => __( 'New Category Name', 'flash-toolkit' ),
63 'not_found' => __( 'No categories found', 'flash-toolkit' ),
64 ),
65 'show_ui' => true,
66 'query_var' => true,
67 'capabilities' => array(
68 'manage_terms' => 'manage_portfolio_terms',
69 'edit_terms' => 'edit_portfolio_terms',
70 'delete_terms' => 'delete_portfolio_terms',
71 'assign_terms' => 'assign_portfolio_terms',
72 ),
73 'rewrite' => array(
74 'slug' => $permalinks['category_rewrite_slug'],
75 'with_front' => false,
76 'hierarchical' => true,
77 ),
78 ) )
79 );
80
81 register_taxonomy( 'portfolio_tag',
82 apply_filters( 'flash_toolkit_taxonomy_objects_portfolio_tag', array( 'portfolio' ) ),
83 apply_filters( 'flash_toolkit_taxonomy_args_portfolio_tag', array(
84 'hierarchical' => false,
85 'label' => __( 'Tags', 'flash-toolkit' ),
86 'labels' => array(
87 'name' => __( 'Project Tags', 'flash-toolkit' ),
88 'singular_name' => __( 'Tag', 'flash-toolkit' ),
89 'menu_name' => _x( 'Tags', 'Admin menu name', 'flash-toolkit' ),
90 'search_items' => __( 'Search Tags', 'flash-toolkit' ),
91 'all_items' => __( 'All Tags', 'flash-toolkit' ),
92 'edit_item' => __( 'Edit Tag', 'flash-toolkit' ),
93 'update_item' => __( 'Update Tag', 'flash-toolkit' ),
94 'add_new_item' => __( 'Add New Tag', 'flash-toolkit' ),
95 'new_item_name' => __( 'New Tag Name', 'flash-toolkit' ),
96 'popular_items' => __( 'Popular Tags', 'flash-toolkit' ),
97 'separate_items_with_commas' => __( 'Separate Tags with commas', 'flash-toolkit' ),
98 'add_or_remove_items' => __( 'Add or remove Tags', 'flash-toolkit' ),
99 'choose_from_most_used' => __( 'Choose from the most used tags', 'flash-toolkit' ),
100 'not_found' => __( 'No tags found', 'flash-toolkit' ),
101 ),
102 'show_ui' => true,
103 'query_var' => true,
104 'capabilities' => array(
105 'manage_terms' => 'manage_portfolio_terms',
106 'edit_terms' => 'edit_portfolio_terms',
107 'delete_terms' => 'delete_portfolio_terms',
108 'assign_terms' => 'assign_portfolio_terms',
109 ),
110 'rewrite' => array(
111 'slug' => $permalinks['tag_rewrite_slug'],
112 'with_front' => false
113 ),
114 ) )
115 );
116
117 do_action( 'flash_toolkit_after_register_taxonomy' );
118 }
119
120 /**
121 * Register core post types.
122 */
123 public static function register_post_types() {
124 if ( ! is_blog_installed() || post_type_exists( 'portfolio' ) ) {
125 return;
126 }
127
128 do_action( 'flash_toolkit_register_post_type' );
129
130 $permalinks = flash_get_permalink_structure();
131
132 register_post_type( 'portfolio',
133 apply_filters( 'flash_toolkit_register_post_type_portfolio',
134 array(
135 'labels' => array(
136 'name' => __( 'Projects', 'flash-toolkit' ),
137 'singular_name' => __( 'Project', 'flash-toolkit' ),
138 'menu_name' => _x( 'Portfolio', 'Admin menu name', 'flash-toolkit' ),
139 'all_items' => __( 'All Projects', 'flash-toolkit' ),
140 'add_new' => __( 'Add Project', 'flash-toolkit' ),
141 'add_new_item' => __( 'Add New Project', 'flash-toolkit' ),
142 'edit' => __( 'Edit', 'flash-toolkit' ),
143 'edit_item' => __( 'Edit Project', 'flash-toolkit' ),
144 'new_item' => __( 'New Project', 'flash-toolkit' ),
145 'view' => __( 'View Project', 'flash-toolkit' ),
146 'view_item' => __( 'View Project', 'flash-toolkit' ),
147 'search_items' => __( 'Search Projects', 'flash-toolkit' ),
148 'not_found' => __( 'No Projects found', 'flash-toolkit' ),
149 'not_found_in_trash' => __( 'No Projects found in trash', 'flash-toolkit' ),
150 'parent' => __( 'Parent Project', 'flash-toolkit' ),
151 'featured_image' => __( 'Project Image', 'flash-toolkit' ),
152 'set_featured_image' => __( 'Set project image', 'flash-toolkit' ),
153 'remove_featured_image' => __( 'Remove project image', 'flash-toolkit' ),
154 'use_featured_image' => __( 'Use as project image', 'flash-toolkit' ),
155 'insert_into_item' => __( 'Insert into project', 'flash-toolkit' ),
156 'uploaded_to_this_item' => __( 'Uploaded to this project', 'flash-toolkit' ),
157 'filter_items_list' => __( 'Filter Projects', 'flash-toolkit' ),
158 'items_list_navigation' => __( 'Projects navigation', 'flash-toolkit' ),
159 'items_list' => __( 'Projects list', 'flash-toolkit' ),
160 ),
161 'description' => __( 'This is where you can add new portfolio items to your project.', 'flash-toolkit' ),
162 'public' => true,
163 'show_ui' => true,
164 'capability_type' => 'portfolio',
165 'map_meta_cap' => true,
166 'publicly_queryable' => true,
167 'exclude_from_search' => false,
168 'hierarchical' => false,
169 'query_var' => true,
170 'menu_icon' => 'dashicons-portfolio',
171 'rewrite' => $permalinks['portfolio_rewrite_slug'] ? array( 'slug' => untrailingslashit( $permalinks['portfolio_rewrite_slug'] ), 'with_front' => false, 'feeds' => true ) : false,
172 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'author', 'custom-fields', 'page-attributes', 'publicize', 'wpcom-markdown' ),
173 'has_archive' => $permalinks['portfolio_has_archive'],
174 'show_in_nav_menus' => true
175 )
176 )
177 );
178 }
179
180 /**
181 * Add Portfolio Support to Jetpack Omnisearch.
182 */
183 public static function support_jetpack_omnisearch() {
184 if ( class_exists( 'Jetpack_Omnisearch_Posts' ) ) {
185 new Jetpack_Omnisearch_Posts( 'portfolio' );
186 }
187 }
188
189 /**
190 * Added portfolio for Jetpack related posts.
191 * @param array $post_types
192 * @return array
193 */
194 public static function rest_api_allowed_post_types( $post_types ) {
195 $post_types[] = 'portfolio';
196
197 return $post_types;
198 }
199
200 /**
201 * Flush rewrite rules.
202 */
203 public static function flush_rewrite_rules() {
204 flush_rewrite_rules();
205 }
206 }
207
208 FT_Post_Types::init();
209