Advertisement
pedmands

Project Mgr Plugin

Oct 7th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.78 KB | None | 0 0
  1. <?php
  2. /**
  3. * Plugin Name: Project Manager
  4. * Description: A simple plugin to publish projects with the project name, client, agency, and role(s) performed.
  5. * Author: Preston Edmands
  6. * License: GPL2
  7. */
  8.  
  9. /*  Copyright 2016  Preston Edmands  (email : pedmands@gmail.com)
  10.  
  11.     This program is free software; you can redistribute it and/or modify
  12.     it under the terms of the GNU General Public License, version 2, as
  13.     published by the Free Software Foundation.
  14.  
  15.     This program is distributed in the hope that it will be useful,
  16.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.     GNU General Public License for more details.
  19.  
  20.     You should have received a copy of the GNU General Public License
  21.     along with this program; if not, write to the Free Software
  22.     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  23. */
  24.  
  25. function custom_posttypes() {
  26.     $labels = array(
  27.         'name'               => 'Projects',
  28.         'singular_name'      => 'Project',
  29.         'menu_name'          => 'Projects',
  30.         'name_admin_bar'     => 'Project',
  31.         'add_new'            => 'Add New',
  32.         'add_new_item'       => 'Add New Project',
  33.         'new_item'           => 'New Project',
  34.         'edit_item'          => 'Edit Project',
  35.         'view_item'          => 'View Project',
  36.         'all_items'          => 'All projects',
  37.         'search_items'       => 'Search projects',
  38.         'parent_item_colon'  => 'Parent projects:',
  39.         'not_found'          => 'No projects found.',
  40.         'not_found_in_trash' => 'No projects found in Trash.',
  41.     );
  42.    
  43.     $args = array(
  44.         'labels'             => $labels,
  45.         'public'             => true,
  46.         'publicly_queryable' => true,
  47.         'show_ui'            => true,
  48.         'show_in_menu'       => true,
  49.         'menu_icon'          => 'dashicons-video-alt',
  50.         'query_var'          => true,
  51.         'rewrite'            => array( 'slug' => 'project' ),
  52.         'capability_type'    => 'post',
  53.         'has_archive'        => true,
  54.         'hierarchical'       => false,
  55.         'menu_position'      => 5,
  56.         'supports'           => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
  57.         'taxonomies'              => array('client', 'agency', 'director', 'editor', 'year', 'length', 'studio')
  58.     );
  59.     register_post_type('project', $args );
  60. }
  61.  
  62. add_action( 'init', 'custom_posttypes' );
  63.  
  64. function my_rewrite_flush() {
  65.     // First, we "add" the custom post type via the above written function.
  66.     // Note: "add" is written with quotes, as CPTs don't get added to the DB,
  67.     // They are only referenced in the post_type column with a post entry,
  68.     // when you add a post of this CPT.
  69.     custom_posttypes();
  70.  
  71.     // ATTENTION: This is *only* done during plugin activation hook in this example!
  72.     // You should *NEVER EVER* do this on every page load!!
  73.     flush_rewrite_rules();
  74. }
  75. register_activation_hook( __FILE__, 'my_rewrite_flush' );
  76.  
  77. // Custom Taxonomies
  78.  
  79. function custom_taxonomies() {
  80.  
  81.     // Client
  82.     $labels = array(
  83.         'name'              => 'Client',
  84.         'singular_name'     => 'Client',
  85.         'search_items'      => 'Search Clients',
  86.         'all_items'         => 'All Clients',
  87.         'parent_item'       => null,
  88.         'parent_item_colon' => null,
  89.         'edit_item'         => 'Edit Client',
  90.         'update_item'       => 'Update Client',
  91.         'add_new_item'      => 'Add New Client',
  92.         'new_item_name'     => 'New Client',
  93.         'menu_name'         => 'Clients',
  94.     );
  95.  
  96.     $args = array(
  97.          'hierarchical'          => false,
  98.         'labels'                => $labels,
  99.         'show_ui'               => true,
  100.         'show_admin_column'     => true,
  101.         'update_count_callback' => '_update_post_term_count',
  102.         'query_var'             => true,
  103.         'rewrite'           => array( 'slug' => 'client' ),
  104.     );
  105.    
  106.     register_taxonomy('client', array('project'), $args);
  107.  
  108.     // Agency
  109.     $labels = array(
  110.         'name'              => 'Angecy',
  111.         'singular_name'     => 'Agency',
  112.         'search_items'      => 'Search Angecies',
  113.         'all_items'         => 'All Angecies',
  114.         'parent_item'       => null,
  115.         'parent_item_colon' => null,
  116.         'edit_item'         => 'Edit Agency',
  117.         'update_item'       => 'Update Agency',
  118.         'add_new_item'      => 'Add New Agency',
  119.         'new_item_name'     => 'New Agency',
  120.         'menu_name'         => 'Angecies',
  121.     );
  122.  
  123.     $args = array(
  124.          'hierarchical'          => false,
  125.         'labels'                => $labels,
  126.         'show_ui'               => true,
  127.         'show_admin_column'     => true,
  128.         'update_count_callback' => '_update_post_term_count',
  129.         'query_var'             => true,
  130.         'rewrite'           => array( 'slug' => 'agency' ),
  131.     );
  132.    
  133.     register_taxonomy('agency', array('project'), $args);
  134.  
  135.     // Director
  136.     $labels = array(
  137.         'name'              => 'Director',
  138.         'singular_name'     => 'Director',
  139.         'search_items'      => 'Search Directors',
  140.         'all_items'         => 'All Directors',
  141.         'parent_item'       => null,
  142.         'parent_item_colon' => null,
  143.         'edit_item'         => 'Edit Director',
  144.         'update_item'       => 'Update Director',
  145.         'add_new_item'      => 'Add New Director',
  146.         'new_item_name'     => 'New Director',
  147.         'menu_name'         => 'Directors',
  148.     );
  149.  
  150.     $args = array(
  151.          'hierarchical'          => false,
  152.         'labels'                => $labels,
  153.         'show_ui'               => true,
  154.         'show_admin_column'     => true,
  155.         'update_count_callback' => '_update_post_term_count',
  156.         'query_var'             => true,
  157.         'rewrite'           => array( 'slug' => 'director' ),
  158.     );
  159.    
  160.     register_taxonomy('director', array('project'), $args);
  161.  
  162.     // Editor
  163.     $labels = array(
  164.         'name'              => 'Editor',
  165.         'singular_name'     => 'Editor',
  166.         'search_items'      => 'Search Editors',
  167.         'all_items'         => 'All Editors',
  168.         'parent_item'       => null,
  169.         'parent_item_colon' => null,
  170.         'edit_item'         => 'Edit Editor',
  171.         'update_item'       => 'Update Editor',
  172.         'add_new_item'      => 'Add New Editor',
  173.         'new_item_name'     => 'New Editor',
  174.         'menu_name'         => 'Editors',
  175.     );
  176.  
  177.     $args = array(
  178.          'hierarchical'          => false,
  179.         'labels'                => $labels,
  180.         'show_ui'               => true,
  181.         'show_admin_column'     => true,
  182.         'update_count_callback' => '_update_post_term_count',
  183.         'query_var'             => true,
  184.         'rewrite'           => array( 'slug' => 'editor' ),
  185.     );
  186.    
  187.     register_taxonomy('editor', array('project'), $args);
  188.  
  189.     // Year
  190.     $labels = array(
  191.         'name'              => 'Year',
  192.         'singular_name'     => 'Year',
  193.         'search_items'      => 'Search Years',
  194.         'all_items'         => 'All Years',
  195.         'parent_item'       => null,
  196.         'parent_item_colon' => null,
  197.         'edit_item'         => 'Edit Year',
  198.         'update_item'       => 'Update Year',
  199.         'add_new_item'      => 'Add New Year',
  200.         'new_item_name'     => 'New Year',
  201.         'menu_name'         => 'Years',
  202.     );
  203.  
  204.     $args = array(
  205.          'hierarchical'          => false,
  206.         'labels'                => $labels,
  207.         'show_ui'               => true,
  208.         'show_admin_column'     => true,
  209.         'update_count_callback' => '_update_post_term_count',
  210.         'query_var'             => true,
  211.         'rewrite'           => array( 'slug' => 'year' ),
  212.     );
  213.    
  214.     register_taxonomy('year', array('project'), $args);
  215.  
  216.     // Length
  217.     $labels = array(
  218.         'name'              => 'Length',
  219.         'singular_name'     => 'Length',
  220.         'search_items'      => 'Search Lengths',
  221.         'all_items'         => 'All Lengths',
  222.         'parent_item'       => null,
  223.         'parent_item_colon' => null,
  224.         'edit_item'         => 'Edit Length',
  225.         'update_item'       => 'Update Length',
  226.         'add_new_item'      => 'Add New Length',
  227.         'new_item_name'     => 'New Length',
  228.         'menu_name'         => 'Lengths',
  229.     );
  230.  
  231.     $args = array(
  232.          'hierarchical'          => false,
  233.         'labels'                => $labels,
  234.         'show_ui'               => true,
  235.         'show_admin_column'     => true,
  236.         'update_count_callback' => '_update_post_term_count',
  237.         'query_var'             => true,
  238.         'rewrite'           => array( 'slug' => 'length' ),
  239.     );
  240.    
  241.     register_taxonomy('length', array('project'), $args);
  242.  
  243.     // Studio
  244.     $labels = array(
  245.         'name'              => 'Studio',
  246.         'singular_name'     => 'Studio',
  247.         'search_items'      => 'Search Studios',
  248.         'all_items'         => 'All Studios',
  249.         'parent_item'       => null,
  250.         'parent_item_colon' => null,
  251.         'edit_item'         => 'Edit Studio',
  252.         'update_item'       => 'Update Studio',
  253.         'add_new_item'      => 'Add New Studio',
  254.         'new_item_name'     => 'New Studio',
  255.         'menu_name'         => 'Studios',
  256.     );
  257.  
  258.     $args = array(
  259.          'hierarchical'          => false,
  260.         'labels'                => $labels,
  261.         'show_ui'               => true,
  262.         'show_admin_column'     => true,
  263.         'update_count_callback' => '_update_post_term_count',
  264.         'query_var'             => true,
  265.         'rewrite'           => array( 'slug' => 'studio' ),
  266.     );
  267.    
  268.     register_taxonomy('studio', array('project'), $args);
  269.  
  270. }
  271.  
  272. add_action('init', 'custom_taxonomies');
  273. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement