/** * Corrects the parent file for post type screens. * * @since 1.0.0 * @access public * @param string $parent_file * @return string */ function parent_file($parent_file) { if ("edit.php?post_type={$this->topic_type}" === $parent_file || "edit.php?post_type={$this->reply_type}" === $parent_file) { $parent_file = mb_get_admin_menu_page(); } return $parent_file; }
/** * Registers post types needed by the plugin. * * @since 1.0.0 * @access public * @return void */ function mb_register_post_types() { /* Get admin menu page. */ $menu_page = mb_get_admin_menu_page(); /* Get post type names. */ $forum_type = mb_get_forum_post_type(); $topic_type = mb_get_topic_post_type(); $reply_type = mb_get_reply_post_type(); /* Set up the arguments for the "forum" post type. */ $forum_args = array('description' => '', 'public' => true, 'publicly_queryable' => true, 'exclude_from_search' => true, 'show_in_nav_menus' => true, 'show_ui' => true, 'show_in_menu' => "edit.php?post_type={$forum_type}" === $menu_page ? true : false, 'show_in_admin_bar' => true, 'menu_position' => null, 'menu_icon' => 'dashicons-format-chat', 'can_export' => true, 'delete_with_user' => false, 'hierarchical' => true, 'has_archive' => 'forums' === mb_get_show_on_front() ? mb_get_root_slug() : mb_get_forum_slug(), 'query_var' => $forum_type, 'capability_type' => 'forum', 'map_meta_cap' => true, 'capabilities' => mb_get_forum_capabilities(), 'rewrite' => array('slug' => mb_get_forum_slug(), 'with_front' => false, 'pages' => false, 'feeds' => true, 'ep_mask' => EP_PERMALINK), 'supports' => array('title', 'editor', 'thumbnail'), 'labels' => array('name' => __('Forums', 'message-board'), 'singular_name' => __('Forum', 'message-board'), 'menu_name' => __('Message Board', 'message-board'), 'name_admin_bar' => __('Forum', 'message-board'), 'all_items' => __('Forums', 'message-board'), 'add_new' => __('Add Forum', 'message-board'), 'add_new_item' => __('Add New Forum', 'message-board'), 'edit_item' => __('Edit Forum', 'message-board'), 'new_item' => __('New Forum', 'message-board'), 'view_item' => __('View Forum', 'message-board'), 'search_items' => __('Search Forums', 'message-board'), 'not_found' => __('No forums found', 'message-board'), 'not_found_in_trash' => __('No forums found in trash', 'message-board'), 'parent_item_colon' => __('Parent Forum:', 'message-board'), 'archive_title' => __('Forums', 'message-board'), 'mb_dashboard_count' => _n_noop('%s Forum', '%s Forums', 'message-board'), 'mb_form_title' => __('Forum Title:', 'message-board'), 'mb_form_type' => __('Forum Type:', 'message-board'), 'mb_form_status' => __('Status:', 'message-board'), 'mb_form_order' => __('Order:', 'message-board'), 'mb_form_content' => __('Description:', 'message-board'), 'mb_form_edit_item' => __('Edit Forum: %s', 'message-board'), 'mb_form_title_placeholder' => __('Enter forum title', 'message-board'), 'mb_form_content_placeholder' => __('Enter forum description…', 'message-board'), 'mb_form_subscribe' => __('Notify me of topics and replies via email', 'message-board'))); /* Set up the arguments for the "topic" post type. */ $topic_args = array('description' => '', 'public' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'show_in_nav_menus' => false, 'show_ui' => true, 'show_in_menu' => "edit.php?post_type={$topic_type}" === $menu_page ? true : $menu_page, 'show_in_admin_bar' => true, 'menu_position' => null, 'menu_icon' => 'dashicons-format-chat', 'can_export' => true, 'delete_with_user' => false, 'hierarchical' => false, 'has_archive' => 'topics' === mb_get_show_on_front() ? mb_get_root_slug() : mb_get_topic_slug(), 'query_var' => mb_get_topic_post_type(), 'capability_type' => $topic_type, 'map_meta_cap' => true, 'capabilities' => mb_get_topic_capabilities(), 'rewrite' => array('slug' => mb_get_topic_slug(), 'with_front' => false, 'pages' => false, 'feeds' => true, 'ep_mask' => EP_PERMALINK), 'supports' => array('title', 'editor'), 'labels' => array('name' => __('Topics', 'message-board'), 'singular_name' => __('Topic', 'message-board'), 'menu_name' => __('Message Board', 'message-board'), 'name_admin_bar' => __('Topic', 'message-board'), 'all_items' => __('Topics', 'message-board'), 'add_new' => __('Add Topic', 'message-board'), 'add_new_item' => __('Add New Topic', 'message-board'), 'edit_item' => __('Edit Topic', 'message-board'), 'new_item' => __('New Topic', 'message-board'), 'view_item' => __('View Topic', 'message-board'), 'search_items' => __('Search Topics', 'message-board'), 'not_found' => __('No topics found', 'message-board'), 'not_found_in_trash' => __('No topics found in trash', 'message-board'), 'parent_item_colon' => __('Forum:', 'message-board'), 'archive_title' => __('Topics', 'message-board'), 'mb_dashboard_count' => _n_noop('%s Topic', '%s Topics', 'message-board'), 'mb_form_title' => __('Topic Title:', 'message-board'), 'mb_form_type' => __('Topic Type:', 'message-board'), 'mb_form_status' => __('Status:', 'message-board'), 'mb_form_content' => __('Message:', 'message-board'), 'mb_form_edit_item' => __('Edit Topic: %s', 'message-board'), 'mb_form_title_placeholder' => __('Enter topic title', 'message-board'), 'mb_form_content_placeholder' => __('Enter topic message…', 'message-board'), 'mb_form_subscribe' => __('Notify me of follow-up posts via email', 'message-board'))); /* Set up the arguments for the "reply" post type. */ $reply_args = array('description' => '', 'public' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'show_in_nav_menus' => false, 'show_ui' => true, 'show_in_menu' => "edit.php?post_type={$reply_type}" === $menu_page ? true : $menu_page, 'show_in_admin_bar' => false, 'menu_position' => null, 'menu_icon' => 'dashicons-format-chat', 'can_export' => true, 'delete_with_user' => false, 'hierarchical' => false, 'has_archive' => mb_get_reply_slug(), 'query_var' => $reply_type, 'capability_type' => 'forum_reply', 'map_meta_cap' => true, 'capabilities' => mb_get_reply_capabilities(), 'rewrite' => array('slug' => mb_get_reply_slug(), 'with_front' => false, 'pages' => false, 'feeds' => false, 'ep_mask' => EP_PERMALINK), 'supports' => array('editor'), 'labels' => array('name' => __('Replies', 'message-board'), 'singular_name' => __('Reply', 'message-board'), 'menu_name' => __('Message Board', 'message-board'), 'name_admin_bar' => __('Reply', 'message-board'), 'all_items' => __('Replies', 'message-board'), 'add_new' => __('Add Reply', 'message-board'), 'add_new_item' => __('Leave A Reply', 'message-board'), 'edit_item' => __('Edit Reply', 'message-board'), 'new_item' => __('New Reply', 'message-board'), 'view_item' => __('View Reply', 'message-board'), 'search_items' => __('Search Replies', 'message-board'), 'not_found' => __('No replies found', 'message-board'), 'not_found_in_trash' => __('No replies found in trash', 'message-board'), 'parent_item_colon' => __('Topic:', 'message-board'), 'archive_title' => __('Replies', 'message-board'), 'mb_dashboard_count' => _n_noop('%s Reply', '%s Replies', 'message-board'), 'mb_form_content' => __('Message:', 'message-board'), 'mb_form_edit_item' => __('Edit Reply: %s', 'message-board'), 'mb_form_content_placeholder' => __('Enter reply message…', 'message-board'), 'mb_form_subscribe' => __('Notify me of follow-up posts via email', 'message-board'))); /* Register post types. */ register_post_type($forum_type, apply_filters('mb_forum_post_type_args', $forum_args)); register_post_type($topic_type, apply_filters('mb_topic_post_type_args', $topic_args)); register_post_type($reply_type, apply_filters('mb_reply_post_type_args', $reply_args)); }