OHIDUL951

WP Custom Post Type - Megamenu

May 1st, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.98 KB | None | 0 0
  1. <?php
  2.  
  3. // File Security Check
  4. if ( ! defined( 'ABSPATH' ) ) {
  5.     exit;
  6. }
  7.  
  8. class ShapeCustomPosts {
  9.  
  10.     function __construct()
  11.     {
  12.         add_action( 'init', array( $this, 'shape_mega_menu') );
  13.     }
  14.  
  15.  
  16.  
  17.     /**
  18.      *
  19.      * Shape Services Custom Post Type
  20.      *
  21.      */
  22.     public function shape_mega_menu()
  23.     {
  24.  
  25.         $labels = array(
  26.             'name'               => _x( 'MegaMenu' , 'post type general name', 'one' ),
  27.             'singular_name'      => _x( 'MegaMenu', 'post type singular name', 'one' ),
  28.             'menu_name'          => _x( 'MegaMenu' , 'admin menu', 'one' ),
  29.             'name_admin_bar'     => _x( 'MegaMenu', 'add new on admin bar', 'one' ),
  30.             'add_new'            => _x( 'Add New', 'MegaMenu', 'one' ),
  31.             'add_new_item'       => __( 'Add New ' . 'MegaMenu', 'one' ),
  32.             'new_item'           => __( 'New ' . 'MegaMenu', 'one' ),
  33.             'edit_item'          => __( 'Edit ' . 'MegaMenu', 'one' ),
  34.             'view_item'          => __( 'View ' . 'MegaMenu', 'one' ),
  35.             'all_items'          => __( 'MegaMenus', 'one' ),
  36.             'search_items'       => __( 'Search MegaMenus', 'one' ),
  37.             'parent_item_colon'  => __( 'Parent :', 'one' ),
  38.             'not_found'          => __( 'No Services found.', 'one' ),
  39.             'not_found_in_trash' => __( 'No Services found in Trash.', 'one' )
  40.         );
  41.  
  42.         $args = array(
  43.             'labels'             => $labels,
  44.             'description'        => __( 'Description.', 'one' ),
  45.             'public'             => true,
  46.             'publicly_queryable' => true,
  47.             'show_ui'            => true,
  48.             'show_in_menu'       => true,
  49.             'query_var'          => true,
  50.             'menu_icon'          => 'dashicons-businessman',
  51.             'rewrite'            => array( 'slug' => 'mega-menu', 'with_front' => true, 'pages' => true, 'feeds' => true ),
  52.             'capability_type'    => 'post',
  53.             'has_archive'        => true,
  54.             'hierarchical'       => false,
  55.             'menu_position'      => null,
  56.             'supports'           => array( 'title', 'editor' )
  57.         );
  58.  
  59.         register_post_type('mega_menu', $args);
  60.    
  61.     }
  62.  
  63.  
  64. }
  65.  
  66. $shapeCustomPostInstance = new ShapeCustomPosts;
Advertisement
Add Comment
Please, Sign In to add comment