Пример #1
0
  public static function insert_builtin() {

    // add the appropriate built-in post types (page and post) if required
    // we'll ignore menu item, attachment, and revision since there's no MasterPress tweaks applicable to those  

    $post_type_post = MPM_PostType::find_by_name("post");

    if (!$post_type_post) {

      $post_type_post = new MPM_PostType();
    
      $post_type_post->set(      
        array( 
          "name" => "post",
          "plural_name" => "posts",
          "disabled" => false,
          "labels" => array(
            "name" => __("Posts", MASTERPRESS_DOMAIN),
            "singular_name" => __("Post", MASTERPRESS_DOMAIN),
            "add_new" => __("Add New", MASTERPRESS_DOMAIN),
            "add_new_item" => __("Add New Post", MASTERPRESS_DOMAIN),
            "edit" => __("Edit Post", MASTERPRESS_DOMAIN),
            "edit_item" => __("Edit Post", MASTERPRESS_DOMAIN),
            "new_item" => __("New Post", MASTERPRESS_DOMAIN),
            "view" => __("View Post", MASTERPRESS_DOMAIN),
            "view_item" => __("View Post", MASTERPRESS_DOMAIN),
            "search_items" => __("Search Posts", MASTERPRESS_DOMAIN),
            "not_found" => __("No posts found.", MASTERPRESS_DOMAIN),
            "not_found_in_trash" => __("No posts found in Trash.", MASTERPRESS_DOMAIN),
            "parent_item_colon" => "", 
            "menu_name" => __("Posts", MASTERPRESS_DOMAIN)
          ),
        
          "description" => "",
          "publicly_queryable" => true,
          "exclude_from_search" => false,
          "show_ui" => true,
          "show_in_menu" => true,
          "menu_position" => 5,
          "menu_sub_position" => 0,
          "menu_icon" => "menu-icon-posts.png",
          "manage_sort_order" => "post_date|desc",
          "capability_type" => "post",
          "capabilities" => array(),
          "map_meta_cap" => true,
          "hierarchical" => false,
          "supports" => "title,editor,author,thumbnail,excerpt,trackbacks,custom-fields,comments,revisions,page-attributes,post-formats",
          "permalink_epmask" => "EP_PERMALINK",
          "has_archive" => true,
          "rewrite" => array( "slug" => "", "with_front" => true, "feeds" => true, "pages" => false ),
          "query_var" => "post",
          "can_export" => true,
          "show_in_nav_menus" => true,
          "_builtin" => true,
          "_external" => false
        )
      );
    
      $post_type_post->insert();
    
    }
      
    $tax_post_tag = MPM_Taxonomy::find_by_name("post_tag");
    $tax_category = MPM_Taxonomy::find_by_name("category");
    
    if ( !$post_type_post->linked_to_taxonomy( $tax_post_tag ) ) {
      $post_type_post->link_taxonomy( $tax_post_tag );
    }

    if ( !$post_type_post->linked_to_taxonomy( $tax_category ) ) {
      $post_type_post->link_taxonomy( $tax_category );
    }

    
    $post_type_page = MPM_PostType::find_by_name("page");
    
    if (!$post_type_page) {

      $post_type_page = new MPM_PostType();
    
      $post_type_page->set(      
        array( 
          "name" => "page",
          "plural_name" => "pages",
          "disabled" => false,
          "labels" => array(
            "name" => __("Pages", MASTERPRESS_DOMAIN),
            "singular_name" => __("Page", MASTERPRESS_DOMAIN),
            "add_new" => __("Add New", MASTERPRESS_DOMAIN),
            "add_new_item" => __("Add New Page", MASTERPRESS_DOMAIN),
            "edit" => __("Edit Page", MASTERPRESS_DOMAIN),
            "edit_item" => __("Edit Page", MASTERPRESS_DOMAIN),
            "new_item" => __("New Page", MASTERPRESS_DOMAIN),
            "view" => __("View Page", MASTERPRESS_DOMAIN),
            "view_item" => __("View Page", MASTERPRESS_DOMAIN),
            "search_items" => __("Search Pages", MASTERPRESS_DOMAIN),
            "not_found" => __("No pages found.", MASTERPRESS_DOMAIN),
            "not_found_in_trash" => __("No pages found in Trash.", MASTERPRESS_DOMAIN),
            "parent_item_colon" => __("Parent Page", MASTERPRESS_DOMAIN), 
            "menu_name" => __("Pages", MASTERPRESS_DOMAIN)
          ),
        
          "description" => "",
          "publicly_queryable" => true,
          "exclude_from_search" => false,
          "show_ui" => true,
          "show_in_menu" => true,
          "menu_position" => 20,
          "menu_sub_position" => 0,
          "menu_icon" => "menu-icon-pages.png",
          "manage_sort_order" => "menu_order|asc",
          "capability_type" => "page",
          "capabilities" => array(),
          "map_meta_cap" => true,
          "hierarchical" => true,
          "supports" => "title,editor,author,thumbnail,excerpt,trackbacks,custom-fields,comments,revisions,page-attributes,post-formats",
          "permalink_epmask" => "1",
          "has_archive" => true,
          "rewrite" => array( "slug" => "", "with_front" => false, "feeds" => false, "pages" => true ),
          "query_var" => "page",
          "can_export" => true,
          "show_in_nav_menus" => true,
          "_builtin" => true,
          "_external" => false
        )
      );
      
      $post_type_page->insert();

    }
      

	$post_type_attachment = MPM_PostType::find_by_name("attachment");
    
    if (!$post_type_attachment) {

      $post_type_attachment = new MPM_PostType();
    
      $post_type_attachment->set(      
        array( 
          "name" => "attachment",
          "plural_name" => "attachments",
          "disabled" => false,
          "labels" => array(
            "name" => __("Media", MASTERPRESS_DOMAIN),
            "singular_name" => __("Media", MASTERPRESS_DOMAIN),
            "add_new" => __("Add New", MASTERPRESS_DOMAIN),
            "add_new_item" => __("Add New Post", MASTERPRESS_DOMAIN),
            "edit" => __("Edit Media", MASTERPRESS_DOMAIN),
            "edit_item" => __("Edit Media", MASTERPRESS_DOMAIN),
            "new_item" => __("New Post", MASTERPRESS_DOMAIN),
            "view" => __("View Media", MASTERPRESS_DOMAIN),
            "view_item" => __("View Media", MASTERPRESS_DOMAIN),
            "search_items" => __("Search Media", MASTERPRESS_DOMAIN),
            "not_found" => __("No media found.", MASTERPRESS_DOMAIN),
            "not_found_in_trash" => __("No media found in Trash.", MASTERPRESS_DOMAIN),
            "parent_item_colon" => __("Parent Post", MASTERPRESS_DOMAIN), 
            "menu_name" => __("Media", MASTERPRESS_DOMAIN)
          ),
        
          "description" => "",
          "publicly_queryable" => true,
          "exclude_from_search" => false,
          "show_ui" => true,
          "show_in_menu" => true,
          "menu_position" => 20,
          "menu_sub_position" => 0,
          "menu_icon" => "menu-icon-media.png",
          "manage_sort_order" => "menu_order|asc",
          "capability_type" => "post",
          "capabilities" => array(),
          "map_meta_cap" => true,
          "hierarchical" => true,
          "supports" => "title,editor,author,thumbnail,excerpt,trackbacks,custom-fields,comments,revisions,page-attributes,post-formats",
          "permalink_epmask" => "1",
          "has_archive" => true,
          "rewrite" => array( "slug" => "", "with_front" => false, "feeds" => false, "pages" => true ),
          "query_var" => "page",
          "can_export" => true,
          "show_in_nav_menus" => true,
          "_builtin" => true,
          "_external" => false
        )
      );
      
      $post_type_attachment->insert();

    }

	
  }