Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Plugin Name: Project Manager
- * Description: A simple plugin to publish projects with the project name, client, agency, and role(s) performed.
- * Author: Preston Edmands
- * License: GPL2
- */
- /* Copyright 2016 Preston Edmands (email : pedmands@gmail.com)
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License, version 2, as
- published by the Free Software Foundation.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
- function custom_posttypes() {
- $labels = array(
- 'name' => 'Projects',
- 'singular_name' => 'Project',
- 'menu_name' => 'Projects',
- 'name_admin_bar' => 'Project',
- 'add_new' => 'Add New',
- 'add_new_item' => 'Add New Project',
- 'new_item' => 'New Project',
- 'edit_item' => 'Edit Project',
- 'view_item' => 'View Project',
- 'all_items' => 'All projects',
- 'search_items' => 'Search projects',
- 'parent_item_colon' => 'Parent projects:',
- 'not_found' => 'No projects found.',
- 'not_found_in_trash' => 'No projects found in Trash.',
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'show_in_menu' => true,
- 'menu_icon' => 'dashicons-video-alt',
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'project' ),
- 'capability_type' => 'post',
- 'has_archive' => true,
- 'hierarchical' => false,
- 'menu_position' => 5,
- 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
- 'taxonomies' => array('client', 'agency', 'director', 'editor', 'year', 'length', 'studio')
- );
- register_post_type('project', $args );
- }
- add_action( 'init', 'custom_posttypes' );
- function my_rewrite_flush() {
- // First, we "add" the custom post type via the above written function.
- // Note: "add" is written with quotes, as CPTs don't get added to the DB,
- // They are only referenced in the post_type column with a post entry,
- // when you add a post of this CPT.
- custom_posttypes();
- // ATTENTION: This is *only* done during plugin activation hook in this example!
- // You should *NEVER EVER* do this on every page load!!
- flush_rewrite_rules();
- }
- register_activation_hook( __FILE__, 'my_rewrite_flush' );
- // Custom Taxonomies
- function custom_taxonomies() {
- // Client
- $labels = array(
- 'name' => 'Client',
- 'singular_name' => 'Client',
- 'search_items' => 'Search Clients',
- 'all_items' => 'All Clients',
- 'parent_item' => null,
- 'parent_item_colon' => null,
- 'edit_item' => 'Edit Client',
- 'update_item' => 'Update Client',
- 'add_new_item' => 'Add New Client',
- 'new_item_name' => 'New Client',
- 'menu_name' => 'Clients',
- );
- $args = array(
- 'hierarchical' => false,
- 'labels' => $labels,
- 'show_ui' => true,
- 'show_admin_column' => true,
- 'update_count_callback' => '_update_post_term_count',
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'client' ),
- );
- register_taxonomy('client', array('project'), $args);
- // Agency
- $labels = array(
- 'name' => 'Angecy',
- 'singular_name' => 'Agency',
- 'search_items' => 'Search Angecies',
- 'all_items' => 'All Angecies',
- 'parent_item' => null,
- 'parent_item_colon' => null,
- 'edit_item' => 'Edit Agency',
- 'update_item' => 'Update Agency',
- 'add_new_item' => 'Add New Agency',
- 'new_item_name' => 'New Agency',
- 'menu_name' => 'Angecies',
- );
- $args = array(
- 'hierarchical' => false,
- 'labels' => $labels,
- 'show_ui' => true,
- 'show_admin_column' => true,
- 'update_count_callback' => '_update_post_term_count',
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'agency' ),
- );
- register_taxonomy('agency', array('project'), $args);
- // Director
- $labels = array(
- 'name' => 'Director',
- 'singular_name' => 'Director',
- 'search_items' => 'Search Directors',
- 'all_items' => 'All Directors',
- 'parent_item' => null,
- 'parent_item_colon' => null,
- 'edit_item' => 'Edit Director',
- 'update_item' => 'Update Director',
- 'add_new_item' => 'Add New Director',
- 'new_item_name' => 'New Director',
- 'menu_name' => 'Directors',
- );
- $args = array(
- 'hierarchical' => false,
- 'labels' => $labels,
- 'show_ui' => true,
- 'show_admin_column' => true,
- 'update_count_callback' => '_update_post_term_count',
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'director' ),
- );
- register_taxonomy('director', array('project'), $args);
- // Editor
- $labels = array(
- 'name' => 'Editor',
- 'singular_name' => 'Editor',
- 'search_items' => 'Search Editors',
- 'all_items' => 'All Editors',
- 'parent_item' => null,
- 'parent_item_colon' => null,
- 'edit_item' => 'Edit Editor',
- 'update_item' => 'Update Editor',
- 'add_new_item' => 'Add New Editor',
- 'new_item_name' => 'New Editor',
- 'menu_name' => 'Editors',
- );
- $args = array(
- 'hierarchical' => false,
- 'labels' => $labels,
- 'show_ui' => true,
- 'show_admin_column' => true,
- 'update_count_callback' => '_update_post_term_count',
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'editor' ),
- );
- register_taxonomy('editor', array('project'), $args);
- // Year
- $labels = array(
- 'name' => 'Year',
- 'singular_name' => 'Year',
- 'search_items' => 'Search Years',
- 'all_items' => 'All Years',
- 'parent_item' => null,
- 'parent_item_colon' => null,
- 'edit_item' => 'Edit Year',
- 'update_item' => 'Update Year',
- 'add_new_item' => 'Add New Year',
- 'new_item_name' => 'New Year',
- 'menu_name' => 'Years',
- );
- $args = array(
- 'hierarchical' => false,
- 'labels' => $labels,
- 'show_ui' => true,
- 'show_admin_column' => true,
- 'update_count_callback' => '_update_post_term_count',
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'year' ),
- );
- register_taxonomy('year', array('project'), $args);
- // Length
- $labels = array(
- 'name' => 'Length',
- 'singular_name' => 'Length',
- 'search_items' => 'Search Lengths',
- 'all_items' => 'All Lengths',
- 'parent_item' => null,
- 'parent_item_colon' => null,
- 'edit_item' => 'Edit Length',
- 'update_item' => 'Update Length',
- 'add_new_item' => 'Add New Length',
- 'new_item_name' => 'New Length',
- 'menu_name' => 'Lengths',
- );
- $args = array(
- 'hierarchical' => false,
- 'labels' => $labels,
- 'show_ui' => true,
- 'show_admin_column' => true,
- 'update_count_callback' => '_update_post_term_count',
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'length' ),
- );
- register_taxonomy('length', array('project'), $args);
- // Studio
- $labels = array(
- 'name' => 'Studio',
- 'singular_name' => 'Studio',
- 'search_items' => 'Search Studios',
- 'all_items' => 'All Studios',
- 'parent_item' => null,
- 'parent_item_colon' => null,
- 'edit_item' => 'Edit Studio',
- 'update_item' => 'Update Studio',
- 'add_new_item' => 'Add New Studio',
- 'new_item_name' => 'New Studio',
- 'menu_name' => 'Studios',
- );
- $args = array(
- 'hierarchical' => false,
- 'labels' => $labels,
- 'show_ui' => true,
- 'show_admin_column' => true,
- 'update_count_callback' => '_update_post_term_count',
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'studio' ),
- );
- register_taxonomy('studio', array('project'), $args);
- }
- add_action('init', 'custom_taxonomies');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement