Changeset 12923 for trunk/wp-includes/post.php
- Timestamp:
- 02/01/2010 11:12:26 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r12898 r12923 17 17 function create_initial_post_types() { 18 18 register_post_type( 'post', array( 'label' => __('Posts'), 19 'publicly_queryable' => true, 19 20 'exclude_from_search' => false, 20 21 '_builtin' => true, … … 22 23 'capability_type' => 'post', 23 24 'hierarchical' => false, 25 'rewrite' => false, 26 'query_var' => false, 24 27 'supports' => array('post-thumbnails', 'excerpts', 'trackbacks', 'custom-fields', 'comments', 'revisions') 25 28 ) ); 26 29 27 30 register_post_type( 'page', array( 'label' => __('Pages'), 31 'publicly_queryable' => true, 28 32 'exclude_from_search' => false, 29 33 '_builtin' => true, … … 31 35 'capability_type' => 'page', 32 36 'hierarchical' => true, 37 'rewrite' => false, 38 'query_var' => false, 33 39 'supports' => array('post-thumbnails', 'page-attributes', 'custom-fields', 'comments', 'revisions') 34 40 ) ); … … 39 45 '_edit_link' => 'media.php?attachment_id=%d', 40 46 'capability_type' => 'post', 41 'hierarchical' => false 47 'hierarchical' => false, 48 'rewrite' => false, 49 'query_var' => false, 42 50 ) ); 43 51 … … 47 55 '_edit_link' => 'revision.php?revision=%d', 48 56 'capability_type' => 'post', 49 'hierarchical' => false 57 'hierarchical' => false, 58 'rewrite' => false, 59 'query_var' => false, 50 60 ) ); 51 61 … … 687 697 * label - A descriptive name for the post type marked for translation. Defaults to $post_type. 688 698 * public - Whether posts of this type should be shown in the admin UI. Defaults to false. 689 * exclude_from_search - Whether to exclude posts with this post type from search results. Defaults to true. 699 * exclude_from_search - Whether to exclude posts with this post type from search results. Defaults to true if the type is not public, false if the type is public. 700 * publicly_queryable - Whether post_type queries can be performed from the front page. Defaults to whatever public is set as. 690 701 * inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none. 691 702 * capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post". … … 702 713 */ 703 714 function register_post_type($post_type, $args = array()) { 704 global $wp_post_types ;705 706 if ( !is_array($wp_post_types))715 global $wp_post_types, $wp_rewrite, $wp; 716 717 if ( !is_array($wp_post_types) ) 707 718 $wp_post_types = array(); 708 719 709 720 // Args prefixed with an underscore are reserved for internal use. 710 $defaults = array('label' => false, ' exclude_from_search' => true, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false, 'supports' => array());721 $defaults = array('label' => false, 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array()); 711 722 $args = wp_parse_args($args, $defaults); 712 723 $args = (object) $args; … … 714 725 $post_type = sanitize_user($post_type, true); 715 726 $args->name = $post_type; 727 728 // If not set, default to the setting for public. 729 if ( null === $args->publicly_queryable ) 730 $args->publicly_queryable = $args->public; 731 732 // If not set, default to true if not public, false if public. 733 if ( null === $args->exclude_from_search ) 734 $args->exclude_from_search = !$args->public; 716 735 717 736 if ( false === $args->label ) … … 734 753 add_post_type_support($post_type, $args->supports); 735 754 unset($args->supports); 755 } 756 757 if ( false !== $args->query_var && !empty($wp) ) { 758 if ( true === $args->query_var ) 759 $args->query_var = $post_type; 760 $args->query_var = sanitize_title_with_dashes($args->query_var); 761 $wp->add_query_var($args->query_var); 762 } 763 764 if ( false !== $args->rewrite && '' != get_option('permalink_structure') ) { 765 if ( !is_array($args->rewrite) ) 766 $args->rewrite = array(); 767 if ( !isset($args->rewrite['slug']) ) 768 $args->rewrite['slug'] = $post_type; 769 if ( !isset($args->rewrite['with_front']) ) 770 $args->rewrite['with_front'] = true; 771 $wp_rewrite->add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name="); 772 $wp_rewrite->add_permastruct($post_type, "/{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front']); 736 773 } 737 774
Note: See TracChangeset
for help on using the changeset viewer.