PHP Classes

File: todo/includes/todo-list-cpt.php

Recommend this page to a friend!
  Classes of Hillary Kollan   My WordPress Plugin List   todo/includes/todo-list-cpt.php   Download  
File: todo/includes/todo-list-cpt.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: My WordPress Plugin List
WordPress plugins for several purposes
Author: By
Last change:
Date: 1 year ago
Size: 1,426 bytes
 

Contents

Class file image Download
<?php

///create custom post types
//todo because its our custom post type

function td_register_todo(){
   
$singular = apply_filters('td_label_single', 'Todo');
   
$plural = apply_filters('td_label_plural', 'Todos');

   
$labels = [
       
'name' => $plural,
       
'singular_name' => $singular,
       
'add_new' => 'Add New',
       
'add_new_item' => 'Add New '. $singular,
       
'edit' => 'Edit '. $singular,
       
'new_item' => 'New '. $singular,
       
'view' => 'View',
       
'view_item' => 'View '. $singular,
       
'search_items' => 'Search '. $plural,
       
'not found' => 'No '.$plural. ' found',
       
'not_found_in_trash' => 'No '.$plural. ' found',
       
'menu_name' => $plural

   
];

   
$args = apply_filters('td_args', [
       
'labels' => $labels,
       
'description' => $plural.' by category',
       
'taxonomies' => ['category'],
       
'public' => true,
       
'show_in_menu' => true,
       
'menu_position' => 5,
       
'menu_icon' => 'dashicons-edit',
       
'show_in_nav_menus' => true,
       
'query_var' => true,
       
'can_export' => true,
       
'rewrite' => ['slug' => 'todo'],
       
'capability_type' => 'post',
       
'supports' => ['title']

    ]);

   
//register post type
   
register_post_type('todo', $args);

}

add_action('init', 'td_register_todo');