Ticket #9674: 9674.9.diff
File 9674.9.diff, 32.0 KB (added by , 15 years ago) |
---|
-
wp-includes/taxonomy.php
180 180 $wp->add_query_var($args['query_var']); 181 181 } 182 182 183 if ( false !== $args['rewrite'] && !empty($wp_rewrite) ) {183 if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') ) { 184 184 if ( !is_array($args['rewrite']) ) 185 185 $args['rewrite'] = array(); 186 186 if ( !isset($args['rewrite']['slug']) ) 187 187 $args['rewrite']['slug'] = sanitize_title_with_dashes($taxonomy); 188 188 $wp_rewrite->add_rewrite_tag("%$taxonomy%", '([^/]+)', $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=$term"); 189 $wp_rewrite->add_permastruct($taxonomy, " {$args['rewrite']['slug']}/%$taxonomy%");189 $wp_rewrite->add_permastruct($taxonomy, "/{$args['rewrite']['slug']}/%$taxonomy%"); 190 190 } 191 191 192 192 $args['name'] = $taxonomy; 193 $args['object_type'] = $object_type;193 $args['object_type'] = (array) $object_type; 194 194 $wp_taxonomies[$taxonomy] = (object) $args; 195 195 } 196 196 197 /** 198 * Add an already registered taxonomy to an object type. 199 * 200 * @package WordPress 201 * @subpackage Taxonomy 202 * @since 3.0 203 * @uses $wp_taxonomies Modifies taxonomy object 204 * 205 * @param string $taxonomy Name of taxonomy object 206 * @param array|string $object_type Name of the object type 207 * @return bool True if successful, false if not 208 */ 209 function register_taxonomy_for_object_type( $taxonomy, $object_type) { 210 global $wp_taxonomies; 211 212 if ( !isset($wp_taxonomies[$taxonomy]) ) 213 return false; 214 215 if ( ! get_post_type_object($object_type) ) 216 return false; 217 218 $wp_taxonomies[$taxonomy]->object_type[] = $object_type; 219 220 return true; 221 } 222 197 223 // 198 224 // Term API 199 225 // -
wp-includes/post.php
15 15 * Creates the initial post types when 'init' action is fired. 16 16 */ 17 17 function create_initial_post_types() { 18 register_post_type( 'post', array(' exclude_from_search' => false) );19 register_post_type( 'page', array(' exclude_from_search' => false) );20 register_post_type( 'attachment', array(' exclude_from_search' => false) );21 register_post_type( 'revision', array(' exclude_from_search' => true) );18 register_post_type( 'post', array('label' => __('Posts'), 'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false) ); 19 register_post_type( 'page', array('label' => __('Pages'),'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'page.php?post=%d', 'capability_type' => 'page', 'hierarchical' => true) ); 20 register_post_type( 'attachment', array('label' => __('Media'), 'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'media.php?attachment_id=%d', 'capability_type' => 'post', 'hierarchical' => false) ); 21 register_post_type( 'revision', array('label' => __('Revisions'),'exclude_from_search' => true, '_builtin' => true, '_edit_link' => 'revision.php?revision=%d', 'capability_type' => 'post', 'hierarchical' => false) ); 22 22 } 23 23 add_action( 'init', 'create_initial_post_types', 0 ); // highest priority 24 24 … … 442 442 } 443 443 444 444 /** 445 * Retrieve a post type object by name 446 * 447 * @package WordPress 448 * @subpackage Post 449 * @since 3.0 450 * @uses $wp_post_types 451 * @see register_post_type 452 * @see get_post_types 453 * 454 * @param string $post_type The name of a registered post type 455 * @return object A post type object 456 */ 457 function get_post_type_object( $post_type ) { 458 global $wp_post_types; 459 460 if ( empty($wp_post_types[$post_type]) ) 461 return null; 462 463 return $wp_post_types[$post_type]; 464 } 465 466 /** 445 467 * Get a list of all registered post type objects. 446 468 * 447 469 * @package WordPress … … 491 513 * 492 514 * Optional $args contents: 493 515 * 516 * label - A descriptive name for the post type marked for translation. Defaults to $post_type. 517 * public - Whether posts of this type should be shown in the admin UI. Defaults to true. 494 518 * exclude_from_search - Whether to exclude posts with this post type from search results. Defaults to true. 519 * inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none. 520 * capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post". 521 * hierarchical - Whether the post type is hierarchical. Defaults to false. 495 522 * 496 523 * @package WordPress 497 524 * @subpackage Post … … 507 534 if (!is_array($wp_post_types)) 508 535 $wp_post_types = array(); 509 536 510 $defaults = array('exclude_from_search' => true); 537 // Args prefixed with an underscore are reserved for internal use. 538 $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); 511 539 $args = wp_parse_args($args, $defaults); 540 $args = (object) $args; 512 541 513 542 $post_type = sanitize_user($post_type, true); 514 $args['name'] = $post_type; 515 $wp_post_types[$post_type] = (object) $args; 543 $args->name = $post_type; 544 545 if ( false === $args->label ) 546 $args->label = $post_type; 547 548 if ( empty($args->capability_type) ) { 549 $args->edit_cap = ''; 550 $args->read_cap = ''; 551 } else { 552 $args->edit_cap = 'edit_' . $args->capability_type; 553 $args->read_cap = 'read_' . $args->capability_type; 554 } 555 556 if ( !$args->_builtin && $args->public ) 557 $args->_show = true; 558 559 $wp_post_types[$post_type] = $args; 560 561 return $args; 516 562 } 517 563 518 564 /** … … 1018 1064 1019 1065 $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; 1020 1066 if ( 'readable' == $perm && is_user_logged_in() ) { 1021 if ( !current_user_can("read_private_{$type}s") ) { 1067 $post_type_object = get_post_type_object($type); 1068 if ( !current_user_can("read_private_{$post_type_object->capability_type}s") ) { 1022 1069 $cache_key .= '_' . $perm . '_' . $user->ID; 1023 1070 $query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))"; 1024 1071 } -
wp-includes/query.php
2062 2062 2063 2063 if ( is_array($post_type) ) 2064 2064 $post_type_cap = 'multiple_post_type'; 2065 else 2066 $post_type_cap = $post_type; 2065 else { 2066 $post_type_object = get_post_type_object ( $post_type ); 2067 if ( !empty($post_type_object) ) 2068 $post_type_cap = $post_type_object->capability_type; 2069 else 2070 $post_type_cap = $post_type; 2071 } 2067 2072 2068 2073 $exclude_post_types = ''; 2069 2074 foreach ( get_post_types( array('exclude_from_search' => true) ) as $_wp_post_type ) -
wp-includes/link-template.php
678 678 return; 679 679 680 680 if ( 'display' == $context ) 681 $action = ' action=edit&';681 $action = '&action=edit'; 682 682 else 683 $action = ' action=edit&';683 $action = '&action=edit'; 684 684 685 switch ( $post->post_type ) : 686 case 'page' : 687 if ( !current_user_can( 'edit_page', $post->ID ) ) 688 return; 689 $file = 'page'; 690 $var = 'post'; 691 break; 692 case 'attachment' : 693 if ( !current_user_can( 'edit_post', $post->ID ) ) 694 return; 695 $file = 'media'; 696 $var = 'attachment_id'; 697 break; 698 case 'revision' : 699 if ( !current_user_can( 'edit_post', $post->ID ) ) 700 return; 701 $file = 'revision'; 702 $var = 'revision'; 703 $action = ''; 704 break; 705 default : 706 if ( !current_user_can( 'edit_post', $post->ID ) ) 707 return apply_filters( 'get_edit_post_link', '', $post->ID, $context ); 708 $file = 'post'; 709 $var = 'post'; 710 break; 711 endswitch; 685 $post_type_object = get_post_type_object( $post->post_type ); 686 if ( !$post_type_object ) 687 return; 712 688 713 return apply_filters( 'get_edit_post_link', admin_url("$file.php?{$action}$var=$post->ID"), $post->ID, $context ); 689 if ( !current_user_can( $post_type_object->edit_cap, $post->ID ) ) 690 return; 691 692 return apply_filters( 'get_edit_post_link', admin_url( sprintf($post_type_object->_edit_link . $action, $post->ID) ), $post->ID, $context ); 714 693 } 715 694 716 695 /** -
wp-includes/capabilities.php
779 779 $author_data = get_userdata( $user_id ); 780 780 //echo "post ID: {$args[0]}<br />"; 781 781 $post = get_post( $args[0] ); 782 if ( 'page' == $post->post_type ) { 783 $args = array_merge( array( 'delete_page', $user_id ), $args ); 782 $post_type = get_post_type_object( $post->post_type ); 783 if ( $post_type && 'post' != $post_type->capability_type ) { 784 $args = array_merge( array( 'delete_' . $post_type->capability_type, $user_id ), $args ); 784 785 return call_user_func_array( 'map_meta_cap', $args ); 785 786 } 786 787 … … 855 856 $author_data = get_userdata( $user_id ); 856 857 //echo "post ID: {$args[0]}<br />"; 857 858 $post = get_post( $args[0] ); 858 if ( 'page' == $post->post_type ) { 859 $args = array_merge( array( 'edit_page', $user_id ), $args ); 859 $post_type = get_post_type_object( $post->post_type ); 860 if ( $post_type && 'post' != $post_type->capability_type ) { 861 $args = array_merge( array( 'edit_' . $post_type->capability_type, $user_id ), $args ); 860 862 return call_user_func_array( 'map_meta_cap', $args ); 861 863 } 862 864 $post_author_data = get_userdata( $post->post_author ); … … 913 915 break; 914 916 case 'read_post': 915 917 $post = get_post( $args[0] ); 916 if ( 'page' == $post->post_type ) { 917 $args = array_merge( array( 'read_page', $user_id ), $args ); 918 $post_type = get_post_type_object( $post->post_type ); 919 if ( $post_type && 'post' != $post_type->capability_type ) { 920 $args = array_merge( array( 'read_' . $post_type->capability_type, $user_id ), $args ); 918 921 return call_user_func_array( 'map_meta_cap', $args ); 919 922 } 920 923 -
wp-admin/menu-header.php
45 45 if ( !empty($submenu[$item[2]]) ) 46 46 $class[] = 'wp-has-submenu'; 47 47 48 if ( ( $parent_file && $item[2] == $parent_file ) || strcmp($self, $item[2]) == 0) {48 if ( ( $parent_file && $item[2] == $parent_file ) || ( false === strpos($parent_file, '?') && strcmp($self, $item[2]) == 0 ) ) { 49 49 if ( !empty($submenu[$item[2]]) ) 50 50 $class[] = 'wp-has-current-submenu wp-menu-open'; 51 51 else -
wp-admin/admin-ajax.php
1135 1135 if ( 'page' == $_POST['post_type'] ) { 1136 1136 $post[] = get_post($_POST['post_ID']); 1137 1137 page_rows($post); 1138 } elseif ( 'post' == $_POST['post_type'] ) {1138 } elseif ( 'post' == $_POST['post_type'] || in_array($_POST['post_type'], get_post_types( array('_show' => true) ) ) ) { 1139 1139 $mode = $_POST['post_view']; 1140 1140 $post[] = get_post($_POST['post_ID']); 1141 1141 post_rows($post); -
wp-admin/post-new.php
8 8 9 9 /** Load WordPress Administration Bootstrap */ 10 10 require_once('admin.php'); 11 $title = __('Add New Post'); 12 $parent_file = 'edit.php'; 11 12 if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) ) 13 $post_type = $_GET['post_type']; 14 else 15 $post_type = 'post'; 16 17 if ( 'post' != $post_type ) { 18 $parent_file = "edit.php?post_type=$post_type"; 19 $submenu_file = "post-new.php?post_type=$post_type"; 20 } else { 21 $parent_file = 'edit.php'; 22 $submenu_file = 'post-new.php'; 23 } 24 25 $post_type_object = get_post_type_object($post_type); 26 27 $title = sprintf(__('Add New %s'), $post_type_object->label); 28 13 29 $editing = true; 14 30 wp_enqueue_script('autosave'); 15 31 wp_enqueue_script('post'); … … 34 50 35 51 // Show post form. 36 52 $post = get_default_post_to_edit(); 53 $post->post_type = $post_type; 37 54 include('edit-form-advanced.php'); 38 55 39 56 include('admin-footer.php'); -
wp-admin/includes/plugin.php
745 745 $parent = $_wp_real_parent_file[$parent]; 746 746 return $parent; 747 747 } 748 /* 748 749 /* 749 750 if ( !empty ( $parent_file ) ) { 750 751 if ( isset( $_wp_real_parent_file[$parent_file] ) ) 751 752 $parent_file = $_wp_real_parent_file[$parent_file]; 752 753 753 754 return $parent_file; 754 755 } 755 */756 */ 756 757 757 758 if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) { 758 759 foreach ( (array)$menu as $parent_menu ) { … … 782 783 foreach ( $submenu[$parent] as $submenu_array ) { 783 784 if ( isset( $_wp_real_parent_file[$parent] ) ) 784 785 $parent = $_wp_real_parent_file[$parent]; 785 if ( $submenu_array[2] == $pagenow ) {786 if ( $submenu_array[2] == $pagenow && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) { 786 787 $parent_file = $parent; 787 788 return $parent; 788 789 } else -
wp-admin/includes/post.php
846 846 $orderby = 'date'; 847 847 } 848 848 849 $post_type_q = 'post_type=post'; 850 if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types( array('_show' => true) ) ) ) 851 $post_type_q = 'post_type=' . $q['post_type']; 852 853 849 854 $posts_per_page = (int) get_user_option( 'edit_per_page', 0, false ); 850 855 if ( empty( $posts_per_page ) || $posts_per_page < 1 ) 851 856 $posts_per_page = 15; 852 857 $posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page ); 853 858 854 wp(" post_type=post&$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby");859 wp("$post_type_q&$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby"); 855 860 856 861 return array($post_stati, $avail_post_stati); 857 862 } -
wp-admin/includes/meta-boxes.php
13 13 global $action; 14 14 15 15 $post_type = $post->post_type; 16 $can_publish = current_user_can("publish_${post_type}s"); 16 $post_type_object = get_post_type_object($post_type); 17 $type_cap = $post_type_object->capability_type; 18 $can_publish = current_user_can("publish_${type_cap}s"); 17 19 ?> 18 20 <div class="submitbox" id="submitpost"> 19 21 … … 184 186 <?php do_action('post_submitbox_start'); ?> 185 187 <div id="delete-action"> 186 188 <?php 187 if ( current_user_can( "delete_${ post_type}", $post->ID ) ) {189 if ( current_user_can( "delete_${type_cap}", $post->ID ) ) { 188 190 if ( !EMPTY_TRASH_DAYS ) { 189 191 $delete_url = wp_nonce_url( add_query_arg( array('action' => 'delete', 'post' => $post->ID) ), "delete-${post_type}_{$post->ID}" ); 190 192 $delete_text = __('Delete Permanently'); -
wp-admin/includes/template.php
3482 3482 } 3483 3483 3484 3484 function screen_meta($screen) { 3485 global $wp_meta_boxes, $_wp_contextual_help ;3485 global $wp_meta_boxes, $_wp_contextual_help, $typenow; 3486 3486 3487 3487 $screen = str_replace('.php', '', $screen); 3488 3488 $screen = str_replace('-new', '', $screen); … … 3492 3492 $column_screens = get_column_headers($screen); 3493 3493 $meta_screens = array('index' => 'dashboard'); 3494 3494 3495 // Give post_type pages their own screen 3496 if ( 'post' == $screen ) { 3497 if ( !empty($typenow) ) 3498 $screen = $typenow; 3499 } 3500 3495 3501 if ( isset($meta_screens[$screen]) ) 3496 3502 $screen = $meta_screens[$screen]; 3497 3503 $show_screen = false; … … 3675 3681 global $screen_layout_columns; 3676 3682 3677 3683 $columns = array('dashboard' => 4, 'post' => 2, 'page' => 2, 'link' => 2); 3684 3685 // Add custom post types 3686 foreach ( get_post_types( array('_show' => true) ) as $post_type ) 3687 $columns[$post_type] = 2; 3688 3678 3689 $columns = apply_filters('screen_layout_columns', $columns, $screen); 3679 3690 3680 3691 if ( !isset($columns[$screen]) ) { … … 3754 3765 global $parent_file, $hook_suffix; 3755 3766 3756 3767 if ( empty($name) ) { 3757 if ( isset($parent_file) && !empty($parent_file) ) 3758 $name = substr($parent_file, 0, -4); 3768 if ( isset($parent_file) && !empty($parent_file) ) { 3769 $name = $parent_file; 3770 if ( false !== $pos = strpos($name, '?post_type=') ) 3771 $name = substr($name, 0, $pos); 3772 $name = substr($name, 0, -4); 3773 } 3759 3774 else 3760 3775 $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix); 3761 3776 } -
wp-admin/post.php
126 126 } 127 127 $post_ID = $p = (int) $_GET['post']; 128 128 $post = get_post($post_ID); 129 $post_type_object = get_post_type_object($post->post_type); 129 130 130 131 if ( empty($post->ID) ) 131 132 wp_die( __('You attempted to edit a post that doesn’t exist. Perhaps it was deleted?') ); … … 136 137 if ( 'trash' == $post->post_status ) 137 138 wp_die( __('You can’t edit this post because it is in the Trash. Please restore it and try again.') ); 138 139 139 if ( 'post' != $post->post_type ) { 140 if ( null == $post_type_object ) 141 wp_die( __('Unknown post type.') ); 142 143 if ( 'post' != $post->post_type && $post_type_object->_builtin ) { 140 144 wp_redirect( get_edit_post_link( $post->ID, 'url' ) ); 141 145 exit(); 142 146 } 143 147 148 $post_type = $post->post_type; 149 if ( 'post' != $post_type ) { 150 $parent_file = "edit.php?post_type=$post_type"; 151 $submenu_file = "edit.php?post_type=$post_type"; 152 } 153 144 154 wp_enqueue_script('post'); 145 155 if ( user_can_richedit() ) 146 156 wp_enqueue_script('editor'); … … 157 167 wp_enqueue_script('autosave'); 158 168 } 159 169 160 $title = __('Edit Post');170 $title = sprintf(__('Edit %s'), $post_type_object->label); 161 171 $post = get_post_to_edit($post_ID); 162 172 163 173 include('edit-form-advanced.php'); -
wp-admin/js/post.dev.js
231 231 var catAddAfter, stamp, visibility, sticky = '', post = 'post' == pagenow || 'post-new' == pagenow, page = 'page' == pagenow || 'page-new' == pagenow; 232 232 233 233 // postboxes 234 if ( post ) 235 postboxes.add_postbox_toggles('post'); 236 else if ( page ) 234 if ( post ) { 235 type = 'post'; 236 if ( typenow ) 237 type = typenow; 238 postboxes.add_postbox_toggles(type); 239 } else if ( page ) { 237 240 postboxes.add_postbox_toggles('page'); 241 } 238 242 239 243 // multi-taxonomies 240 244 if ( $('#tagsdiv-post_tag').length ) { -
wp-admin/edit-form-advanced.php
85 85 // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). 86 86 require_once('includes/meta-boxes.php'); 87 87 88 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', 'post', 'side', 'core');88 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $post_type, 'side', 'core'); 89 89 90 90 // all tag-style post taxonomies 91 foreach ( get_object_taxonomies( 'post') as $tax_name ) {91 foreach ( get_object_taxonomies($post_type) as $tax_name ) { 92 92 if ( !is_taxonomy_hierarchical($tax_name) ) { 93 93 $taxonomy = get_taxonomy($tax_name); 94 94 $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name; 95 95 96 add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', 'post', 'side', 'core');96 add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', $post_type, 'side', 'core'); 97 97 } 98 98 } 99 99 100 add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core');101 if ( current_theme_supports( 'post-thumbnails', 'post') )102 add_meta_box('postimagediv', __('Post Thumbnail'), 'post_thumbnail_meta_box', 'post', 'side', 'low');103 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core');104 add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', 'post', 'normal', 'core');105 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'normal', 'core');100 add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', $post_type, 'side', 'core'); 101 if ( current_theme_supports( 'post-thumbnails', $post_type ) ) 102 add_meta_box('postimagediv', __('Post Thumbnail'), 'post_thumbnail_meta_box', $post_type, 'side', 'low'); 103 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $post_type, 'normal', 'core'); 104 add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', $post_type, 'normal', 'core'); 105 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', $post_type, 'normal', 'core'); 106 106 do_action('dbx_post_advanced'); 107 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'post', 'normal', 'core');107 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', $post_type, 'normal', 'core'); 108 108 109 109 if ( 'publish' == $post->post_status || 'private' == $post->post_status ) 110 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', 'post', 'normal', 'core');110 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core'); 111 111 112 112 if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) ) 113 add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'normal', 'core');113 add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core'); 114 114 115 115 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM 116 116 if ( $post->post_author && !in_array($post->post_author, $authors) ) 117 117 $authors[] = $post->post_author; 118 118 if ( $authors && count( $authors ) > 1 ) 119 add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'normal', 'core');119 add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', $post_type, 'normal', 'core'); 120 120 121 121 if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) 122 add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'normal', 'core');122 add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core'); 123 123 124 do_action('do_meta_boxes', 'post', 'normal', $post);125 do_action('do_meta_boxes', 'post', 'advanced', $post);126 do_action('do_meta_boxes', 'post', 'side', $post);124 do_action('do_meta_boxes', $post_type, 'normal', $post); 125 do_action('do_meta_boxes', $post_type, 'advanced', $post); 126 do_action('do_meta_boxes', $post_type, 'side', $post); 127 127 128 128 require_once('admin-header.php'); 129 129 … … 152 152 <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr($form_action) ?>" /> 153 153 <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr($form_action) ?>" /> 154 154 <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> 155 <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post ->post_type) ?>" />155 <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post_type) ?>" /> 156 156 <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr($post->post_status) ?>" /> 157 157 <input name="referredby" type="hidden" id="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" /> 158 158 <?php … … 166 166 167 167 <?php do_action('submitpost_box'); ?> 168 168 169 <?php $side_meta_boxes = do_meta_boxes( 'post', 'side', $post); ?>169 <?php $side_meta_boxes = do_meta_boxes($post_type, 'side', $post); ?> 170 170 </div> 171 171 172 172 <div id="post-body"> … … 223 223 224 224 <?php 225 225 226 do_meta_boxes( 'post', 'normal', $post);226 do_meta_boxes($post_type, 'normal', $post); 227 227 228 228 do_action('edit_form_advanced'); 229 229 230 do_meta_boxes( 'post', 'advanced', $post);230 do_meta_boxes($post_type, 'advanced', $post); 231 231 232 232 do_action('dbx_post_sidebar'); ?> 233 233 -
wp-admin/menu.php
65 65 66 66 $_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group 67 67 68 foreach ( (array) get_post_types( array('_show' => true) ) as $ptype ) { 69 $_wp_last_object_menu++; 70 $ptype_obj = get_post_type_object($ptype); 71 $menu[$_wp_last_object_menu] = array(esc_attr($ptype_obj->label), 'edit_' . $ptype_obj->capability_type . 's', "edit.php?post_type=$ptype", '', 'menu-top', 'menu-posts', 'div'); 72 $submenu["edit.php?post_type=$ptype"][5] = array( __('Edit'), 'edit_posts', "edit.php?post_type=$ptype"); 73 /* translators: add new custom post type */ 74 $submenu["edit.php?post_type=$ptype"][10] = array( _x('Add New', 'post'), 'edit_posts', "post-new.php?post_type=$ptype" ); 75 76 $i = 15; 77 foreach ( $wp_taxonomies as $tax ) { 78 if ( $tax->hierarchical || ! in_array($ptype, (array) $tax->object_type, true) ) 79 continue; 80 81 $submenu["edit.php?post_type=$ptype"][$i] = array( esc_attr($tax->label), 'manage_categories', "edit-tags.php?taxonomy=$tax->name&post_type=$ptype" ); 82 ++$i; 83 } 84 } 85 unset($ptype, $ptype_obj); 86 68 87 $menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' ); 69 88 70 89 $menu[60] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top', 'menu-appearance', 'div' ); -
wp-admin/admin-header.php
35 35 else if ( isset($pagenow) ) 36 36 $hook_suffix = $pagenow; 37 37 38 if ( isset($submenu_file) && (false !== $pos = strpos($submenu_file, 'post_type=')) ) 39 $typenow = substr($submenu_file, $pos + 10); 40 elseif ( isset($parent_file) && (false !== $pos = strpos($parent_file, 'post_type=')) ) 41 $typenow = substr($parent_file, $pos + 10); 42 else 43 $typenow = ''; 44 38 45 $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix); 39 46 ?> 40 47 <script type="text/javascript"> 41 48 //<![CDATA[ 42 49 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; 43 50 var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'}; 44 var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = '<?php echo substr($pagenow, 0, -4); ?>', adminpage = '<?php echo $admin_body_class; ?>', thousandsSeparator = '<?php echo $wp_locale->number_format['thousands_sep']; ?>', decimalPoint = '<?php echo $wp_locale->number_format['decimal_point']; ?>';51 var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = '<?php echo substr($pagenow, 0, -4); ?>', typenow = '<?php echo $typenow; ?>', adminpage = '<?php echo $admin_body_class; ?>', thousandsSeparator = '<?php echo $wp_locale->number_format['thousands_sep']; ?>', decimalPoint = '<?php echo $wp_locale->number_format['decimal_point']; ?>'; 45 52 //]]> 46 53 </script> 47 54 <?php -
wp-admin/edit.php
20 20 unset( $_redirect ); 21 21 } 22 22 23 if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) ) 24 $post_type = $_GET['post_type']; 25 else 26 $post_type = 'post'; 27 28 $post_type_object = get_post_type_object($post_type); 29 30 if ( 'post' != $post_type ) { 31 $parent_file = "edit.php?post_type=$post_type"; 32 $submenu_file = "edit.php?post_type=$post_type"; 33 $post_new_file = "post-new.php?post_type=$post_type"; 34 } else { 35 $parent_file = 'edit.php'; 36 $submenu_file = 'edit.php'; 37 $post_new_file = 'post-new.php'; 38 } 39 23 40 // Handle bulk actions 24 41 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) { 25 42 check_admin_referer('bulk-posts'); 26 43 $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() ); 27 44 28 45 if ( strpos($sendback, 'post.php') !== false ) 29 $sendback = admin_url( 'post-new.php');46 $sendback = admin_url($post_new_file); 30 47 31 48 if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) { 32 49 $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']); 33 $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type= 'post' AND post_status = %s", $post_status ) );50 $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) ); 34 51 $doaction = 'delete'; 35 52 } elseif ( ( $_GET['action'] != -1 || $_GET['action2'] != -1 ) && ( isset($_GET['post']) || isset($_GET['ids']) ) ) { 36 53 $post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']); … … 107 124 exit; 108 125 } 109 126 110 if ( empty($title) ) 111 $title = __('Edit Posts'); 112 $parent_file = 'edit.php'; 127 $title = sprintf(__('Edit %s'), $post_type_object->label); 128 113 129 wp_enqueue_script('inline-edit-post'); 114 130 115 131 $user_posts = false; 116 132 if ( !current_user_can('edit_others_posts') ) { 117 $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = ' post' AND post_status != 'trash' AND post_author = %d", $current_user->ID) );133 $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = '%s' AND post_status != 'trash' AND post_author = %d", $post_type, $current_user->ID) ); 118 134 $user_posts = true; 119 135 if ( $user_posts_count && empty($_GET['post_status']) && empty($_GET['all_posts']) && empty($_GET['author']) ) 120 136 $_GET['author'] = $current_user->ID; … … 134 150 135 151 <div class="wrap"> 136 152 <?php screen_icon(); ?> 137 <h2><?php echo esc_html( $title ); ?> <a href=" post-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'post'); ?></a> <?php153 <h2><?php echo esc_html( $title ); ?> <a href="<?php echo $post_new_file ?>" class="button add-new-h2"><?php echo esc_html_x('Add New', 'post'); ?></a> <?php 138 154 if ( isset($_GET['s']) && $_GET['s'] ) 139 155 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( get_search_query() ) ); ?> 140 156 </h2> … … 188 204 <?php 189 205 if ( empty($locked_post_status) ) : 190 206 $status_links = array(); 191 $num_posts = wp_count_posts( 'post', 'readable' );207 $num_posts = wp_count_posts( $post_type, 'readable' ); 192 208 $class = ''; 193 209 $allposts = ''; 194 210 … … 215 231 if ( isset($_GET['post_status']) && $status == $_GET['post_status'] ) 216 232 $class = ' class="current"'; 217 233 218 $status_links[] = "<li><a href='edit.php?post_status=$status '$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>';234 $status_links[] = "<li><a href='edit.php?post_status=$status&post_type=$post_type'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>'; 219 235 } 220 236 echo implode( " |</li>\n", $status_links ) . '</li>'; 221 237 unset( $status_links ); … … 230 246 </p> 231 247 232 248 <input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_GET['post_status']) ? esc_attr($_GET['post_status']) : 'all'; ?>" /> 249 <input type="hidden" name="post_type" class="post_type_page" value="<?php echo $post_type; ?>" /> 233 250 <input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" /> 234 251 235 252 <?php if ( have_posts() ) { ?> … … 267 284 268 285 <?php // view filters 269 286 if ( !is_singular() ) { 270 $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC";287 $arc_query = $wpdb->prepare("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = %s ORDER BY post_date DESC", $post_type); 271 288 272 289 $arc_result = $wpdb->get_results( $arc_query ); 273 290