Ticket #21391: attachment_editing_scratch.diff
File attachment_editing_scratch.diff, 12.3 KB (added by , 13 years ago) |
---|
-
wp-includes/post.php
53 53 register_post_type( 'attachment', array( 54 54 'labels' => array( 55 55 'name' => __( 'Media' ), 56 'name' => _x('Media', 'post type general name'), 57 'singular_name' => _x( 'Media Item', 'post type singular name' ), 58 'add_new' => _x( 'Add New', 'media item'), 59 'add_new_item' => __( 'Add New Media' ), 56 60 'edit_item' => __( 'Edit Media' ), 61 'new_item' => __( 'New Media Item' ), 62 'view_item' => __( 'View Attachment Page' ), 63 'search_items' => __( 'Search Media' ), 64 'not_found' => __( 'No media found.' ), 65 'not_found_in_trash' => __('No media found in Trash.'), 66 'parent_item_colon' => __('Parent:'), 67 'all_items' => __( 'All Media' ), 57 68 ), 58 69 'public' => true, 59 'show_ui' => false,70 'show_ui' => true, 60 71 '_builtin' => true, /* internal use only. don't use this when registering your own post type. */ 61 '_edit_link' => ' media.php?attachment_id=%d', /* internal use only. don't use this when registering your own post type. */72 '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */ 62 73 'capability_type' => 'post', 63 74 'map_meta_cap' => true, 64 75 'hierarchical' => false, … … 66 77 'query_var' => false, 67 78 'show_in_nav_menus' => false, 68 79 'delete_with_user' => true, 69 'supports' => array( 'comments', 'author' ), 80 'supports' => array( 'title', 'editor', 'author', 'excerpt', 'comments' ), 81 'disables' => array( 'save', 'preview', 'post_status', 'visibility' ) 70 82 ) ); 71 83 72 84 register_post_type( 'revision', array( … … 1075 1087 'capability_type' => 'post', 'capabilities' => array(), 'map_meta_cap' => null, 1076 1088 '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'hierarchical' => false, 1077 1089 'public' => false, 'rewrite' => true, 'has_archive' => false, 'query_var' => true, 1078 'supports' => array(), ' register_meta_box_cb' => null,1090 'supports' => array(), 'disables' => array(), 'register_meta_box_cb' => null, 1079 1091 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 1080 1092 'can_export' => true, 1081 1093 'show_in_nav_menus' => null, 'show_in_menu' => null, 'show_in_admin_bar' => null, … … 1135 1147 add_post_type_support($post_type, array('title', 'editor')); 1136 1148 } 1137 1149 1150 if ( ! empty($args->disables) ) { 1151 disable_for_post_type($post_type, $args->disables); 1152 unset($args->disables); 1153 } 1154 1138 1155 if ( false !== $args->query_var && !empty($wp) ) { 1139 1156 if ( true === $args->query_var ) 1140 1157 $args->query_var = $post_type; … … 1492 1509 } 1493 1510 1494 1511 /** 1512 * Disable long-existing features for a post type 1513 * 1514 * Can't later add post type support for certain things 1515 * 1516 * @since 3.5.0 1517 * @param string $post_type The post type for which to remove the feature 1518 * @param string|array $feature the feature being removed, can be an array of feature strings or a single string 1519 */ 1520 function disable_for_post_type( $post_type, $feature ) { 1521 global $_wp_post_type_disabled; 1522 1523 $features = (array) $feature; 1524 foreach ($features as $feature) { 1525 if ( func_num_args() == 2 ) 1526 $_wp_post_type_disabled[$post_type][$feature] = true; 1527 else 1528 $_wp_post_type_disabled[$post_type][$feature] = array_slice( func_get_args(), 2 ); 1529 } 1530 } 1531 1532 /** 1533 * Get all the disabled post type features 1534 * 1535 * @since 3.5.0 1536 * @param string $post_type The post type 1537 * @return array 1538 */ 1539 1540 function get_all_disabled_for_post_type( $post_type ) { 1541 global $_wp_post_type_disabled; 1542 1543 if ( isset( $_wp_post_type_disabled[$post_type] ) ) 1544 return $_wp_post_type_disabled[$post_type]; 1545 1546 return array(); 1547 } 1548 1549 /** 1550 * Checks whether a post type disables a given feature 1551 * 1552 * @since 3.5.0 1553 * @param string $post_type The post type being checked 1554 * @param string $feature the feature being checked 1555 * @return boolean 1556 */ 1557 1558 function post_type_disables( $post_type, $feature ) { 1559 global $_wp_post_type_disabled; 1560 1561 if ( !isset( $_wp_post_type_disabled[$post_type][$feature] ) ) 1562 return false; 1563 1564 // If no args passed then no extra checks need be performed 1565 if ( func_num_args() <= 2 ) 1566 return true; 1567 1568 return true; 1569 } 1570 1571 /** 1495 1572 * Updates the post type for the post ID. 1496 1573 * 1497 1574 * The page or post cache will be cleaned for the post ID. -
wp-admin/includes/post.php
1083 1083 1084 1084 list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); 1085 1085 1086 if ( 'publish' == $post->post_status) {1086 if ( 'publish' == get_post_status( $post ) ) { 1087 1087 $ptype = get_post_type_object($post->post_type); 1088 1088 $view_post = $ptype->labels->view_item; 1089 1089 $title = __('Click to edit this part of the permalink'); -
wp-admin/includes/meta-boxes.php
26 26 </div> 27 27 28 28 <div id="minor-publishing-actions"> 29 <?php if ( ! post_type_disables( $post->post_type, 'save' ) ) : ?> 29 30 <div id="save-action"> 30 31 <?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> 31 32 <input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" class="button button-highlighted" /> … … 34 35 <?php } ?> 35 36 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="draft-ajax-loading" alt="" /> 36 37 </div> 37 <?php if ( $post_type_object->public ) : ?> 38 <?php endif; // doesn't disable save button ?> 39 <?php if ( ! post_type_disables( $post->post_type, 'preview' ) && $post_type_object->public ) : ?> 38 40 <div id="preview-action"> 39 41 <?php 40 42 if ( 'publish' == $post->post_status ) { … … 57 59 58 60 <div id="misc-publishing-actions"> 59 61 62 <?php if ( ! post_type_disables( $post->post_type, 'post_status' ) ) : ?> 60 63 <div class="misc-pub-section"><label for="post_status"><?php _e('Status:') ?></label> 64 61 65 <span id="post-status-display"> 62 66 <?php 63 67 switch ( $post->post_status ) { … … 106 110 107 111 <?php } ?> 108 112 </div><?php // /misc-pub-section ?> 113 <?php endif; // doesn't disable post_status ?> 109 114 115 <?php if ( ! post_type_disables( $post->post_type, 'visibility' ) ) : ?> 110 116 <div class="misc-pub-section" id="visibility"> 111 117 <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php 112 118 … … 151 157 <?php } ?> 152 158 153 159 </div><?php // /misc-pub-section ?> 160 <?php endif; // doesn't disable visibility ?> 154 161 155 162 <?php 156 163 // translators: Publish box date format, see http://php.net/date … … 204 211 <div id="publishing-action"> 205 212 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="ajax-loading" alt="" /> 206 213 <?php 207 if ( !in_array( $post->post_status, a rray('publish', 'future', 'private') ) || 0 == $post->ID ) {214 if ( !in_array( $post->post_status, apply_filters( 'post_stati_published', array('publish', 'future', 'private', 'inherit') ) ) || 0 == $post->ID ) { 208 215 if ( $can_publish ) : 209 216 if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> 210 217 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" /> -
wp-admin/includes/screen.php
96 96 if ( $use_defaults ) { 97 97 $hidden = array(); 98 98 if ( 'post' == $screen->base ) { 99 if ( 'post' == $screen->post_type || 'page' == $screen->post_type )99 if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type ) 100 100 $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); 101 101 else 102 102 $hidden = array( 'slugdiv' ); -
wp-admin/post.php
31 31 if ( $post ) { 32 32 $post_type = $post->post_type; 33 33 $post_type_object = get_post_type_object( $post_type ); 34 $parent_file = 'upload.php'; 34 35 } 35 36 36 37 /** … … 148 149 $parent_file = "edit.php"; 149 150 $submenu_file = "edit.php"; 150 151 $post_new_file = "post-new.php"; 152 } elseif ( 'attachment' === $post_type ) { 153 $parent_file = 'upload.php'; 154 $submenu_file = 'upload.php'; 155 $post_new_file = 'media-new.php'; 151 156 } else { 152 157 if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) 153 158 $parent_file = $post_type_object->show_in_menu; -
wp-admin/edit-form-advanced.php
73 73 74 74 $notice = false; 75 75 $form_extra = ''; 76 if ( 'auto-draft' == $post->post_status) {76 if ( 'auto-draft' == get_post_status( $post ) ) { 77 77 if ( 'edit' == $action ) 78 78 $post->post_title = ''; 79 79 $autosave = false; … … 140 140 if ( post_type_supports($post_type, 'comments') ) 141 141 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', null, 'normal', 'core'); 142 142 143 if ( ('publish' == $post->post_status || 'private' == $post->post_status) && post_type_supports($post_type, 'comments') )143 if ( ('publish' == get_post_status( $post ) || 'private' == get_post_status( $post )) && post_type_supports($post_type, 'comments') ) 144 144 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core'); 145 145 146 if ( !( 'pending' == $post->post_status&& !current_user_can( $post_type_object->cap->publish_posts ) ) )146 if ( !( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) 147 147 add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core'); 148 148 149 149 if ( post_type_supports($post_type, 'author') ) { … … 259 259 <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ) ?>" /> 260 260 <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> 261 261 <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post_type ) ?>" /> 262 <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status ) ?>" />262 <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status ) ?>" /> 263 263 <input type="hidden" id="referredby" name="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" /> 264 264 <?php if ( ! empty( $active_post_lock ) ) { ?> 265 265 <input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" /> 266 266 <?php 267 267 } 268 if ( 'draft' != $post->post_status)268 if ( 'draft' != get_post_status( $post ) ) 269 269 wp_original_referer_field(true, 'previous'); 270 270 271 271 echo $form_extra; … … 292 292 if ( !empty($shortlink) ) 293 293 $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>'; 294 294 295 if ( $post_type_object->public && ! ( 'pending' == $post->post_status&& !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?>295 if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?> 296 296 <div id="edit-slug-box"> 297 297 <?php 298 if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status)298 if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != get_post_status( $post ) ) 299 299 echo $sample_permalink_html; 300 300 ?> 301 301 </div> … … 319 319 <td class="autosave-info"> 320 320 <span class="autosave-message"> </span> 321 321 <?php 322 if ( 'auto-draft' != $post->post_status) {322 if ( 'auto-draft' != get_post_status( $post ) ) { 323 323 echo '<span id="last-edit">'; 324 324 if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) { 325 325 $last_user = get_userdata($last_id);