SHARE
TWEET

Untitled

a guest Feb 19th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. register_post_type( 'connector',
  2.     array(
  3.         'labels' => array(
  4.             'name' => __( 'Connectors' ),
  5.             'singular_name' => __( 'Connector' ),
  6.             'all_items' => __( 'All Connectors' ),
  7.             'add_new' => __( 'Add Connector' ),
  8.             'add_new_item' => __( 'Add New Connector' ),
  9.             'edit' => __( 'Edit'),
  10.             'edit_item' => __( 'Edit Connector' ),
  11.             'new_item' => __( 'New Connector'),
  12.             'view' => __( 'View Connector'),
  13.             'view_item' => __( 'View Connector'),
  14.             'search_items' => __( 'Search Connectors'),
  15.             'not_found' => __( 'No Connectors found' ),
  16.             'not_found_in_trash' => __( 'No Connectors found in trash' ),
  17.             'parent' => __( 'Parent Connector')
  18.         ),      
  19.  
  20.     'description' => __( 'This is where you can add new Connectors' ),
  21.     'public' => true,
  22.     'show_ui' => true,
  23.     'capability_type' => 'page',        
  24.     'publicly_queryable' => true,
  25.     'exclude_from_search' => false,
  26.     'hierarchical' => true,
  27.     'rewrite' => array( 'slug' => 'connector', 'with_front' => false ),
  28.     'query_var' => true,
  29.     'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'excerpt','author',/*, 'page-attributes'*/ ),
  30.     'taxonomies' => array('post_tag'), // this is IMPORTANT for adding tags
  31.     'has_archive' => true,
  32.     'show_in_nav_menus' => true,
  33.     'show_in_menu'=>false
  34.     )
  35. );
  36.      
  37. function modify_connectors() {
  38.     if ( post_type_exists( 'connector' ) ) {
  39.  
  40.  
  41. $capabilities = array(
  42.         'publish_posts' => 'publish_connectors',
  43.         'edit_posts' => 'edit_connectors',
  44.         'edit_others_posts' => 'edit_others_connectors',
  45.         'delete_posts' => 'delete_connectors',
  46.         'delete_others_posts' => 'delete_others_connectors',
  47.         'read_private_posts' => 'read_private_connectors',
  48.         'edit_post' => 'edit_connector',
  49.         'delete_post' => 'delete_connector',
  50.         'read_post' => 'read_connector',
  51.     );
  52.  
  53.  
  54.     global $wp_post_types, $wp_rewrite;
  55.     $wp_post_types['connector']->hierarchical = true;
  56.     $wp_post_types['connector']->capability_type = 'connector';
  57.     $wp_post_types['connector']->capabilities = $capabilities;
  58.     //I am not sure from nowonwards am I doing right or wrong
  59.     $args = $wp_post_types['connector'];
  60.     $wp_rewrite->add_rewrite_tag("%connector%", '(.+?)', $args->query_var ? "{$args->query_var}=" : "post_type=connector&name=");
  61.     add_post_type_support('connector','page-attributes');
  62.     }
  63. }
  64. add_action( 'init', 'modify_connectors', 1 );
  65.      
  66. 'description' => __( 'This is where you can add new Connectors' ),
  67. 'public' => true,
  68. 'show_ui' => true,
  69. 'capability_type' => 'page',        
  70. 'publicly_queryable' => true,
  71. 'exclude_from_search' => false,
  72. 'hierarchical' => true,
  73. 'capabilities'        => array(
  74. 'publish_posts'       => 'update_core',
  75. 'edit_others_posts'   => 'update_core',
  76. 'delete_posts'        => 'update_core',
  77. 'delete_others_posts' => 'update_core',
  78. 'read_private_posts'  => 'update_core',
  79. 'edit_post'           => 'edit_posts',
  80. 'delete_post'         => 'update_core',
  81. 'read_post'           => 'edit_posts',
  82. ),
  83. 'rewrite' => array( 'slug' => 'connector', 'with_front' => false ),
  84. 'query_var' => true,
  85. 'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'excerpt','author',/*, 'page-attributes'*/ ),
  86. 'taxonomies' => array('post_tag'), // this is IMPORTANT for adding tags
  87. 'has_archive' => true,
  88. 'show_in_nav_menus' => true,
  89. 'show_in_menu'=>false
  90. ));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top