Ticket #21391: 21391.7.1.patch
File 21391.7.1.patch, 30.0 KB (added by , 13 years ago) |
---|
-
wp-includes/media.php
986 986 } 987 987 988 988 /** 989 * Return all of the taxonomy names that are registered for attachments. 990 * 991 * @since 3.5.0 992 * 993 * @uses $wp_taxonomies 994 * 995 * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default. 996 * @return array The names of all taxonomy of $object_type. 997 */ 998 function get_taxonomies_for_attachments( $output = 'names' ) { 999 global $wp_taxonomies; 1000 1001 $taxonomies = array(); 1002 foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) { 1003 if ( in_array('attachment', (array) $tax_obj->object_type) || _is_attachment_type_taxonomy( $tax_obj->object_type ) ) { 1004 if ( 'names' == $output ) 1005 $taxonomies[] = $tax_name; 1006 else 1007 $taxonomies[ $tax_name ] = $tax_obj; 1008 } 1009 } 1010 1011 return $taxonomies; 1012 } 1013 1014 /** 1015 * Return all of the taxonomy names that are registered for specific attachment types. 1016 * Examples: attachment:image, attachment:video 1017 * 1018 * @since 3.5.0 1019 * 1020 * @param array|string $object_types The object types of the taxonomy. 1021 * @return bool True if it's an attachment tax, false if not. 1022 */ 1023 function _is_attachment_type_taxonomy( $object_types ) { 1024 if ( empty( $object_types ) ) 1025 return false; 1026 1027 $object_types = (array) $object_types; 1028 1029 foreach ( $object_types as $type ) { 1030 if ( 0 === strpos( $type, 'attachment:' ) ) 1031 return true; 1032 } 1033 } 1034 1035 /** 989 1036 * Check if the installed version of GD supports particular image type 990 1037 * 991 1038 * @since 2.9.0 -
wp-includes/link-template.php
106 106 if ( $post->post_type == 'page' ) 107 107 return get_page_link($post->ID, $leavename, $sample); 108 108 elseif ( $post->post_type == 'attachment' ) 109 return get_attachment_link( $post->ID);109 return get_attachment_link( $post->ID, $leavename ); 110 110 elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) ) 111 111 return get_post_permalink($post->ID, $leavename, $sample); 112 112 … … 292 292 * @since 2.0.0 293 293 * 294 294 * @param mixed $post Optional. Post ID or object. 295 * @param bool $leavename Optional. Leave name. 295 296 * @return string 296 297 */ 297 function get_attachment_link( $post = null ) {298 function get_attachment_link( $post = null, $leavename = false ) { 298 299 global $wp_rewrite; 299 300 300 301 $link = false; … … 314 315 $name = $post->post_name; 315 316 316 317 if ( strpos($parentlink, '?') === false ) 317 $link = user_trailingslashit( trailingslashit($parentlink) . $name ); 318 $link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' ); 319 320 if ( ! $leavename ) 321 $link = str_replace( '%postname%', $name, $link ); 318 322 } 319 323 320 324 if ( ! $link ) -
wp-includes/post.php
53 53 register_post_type( 'attachment', array( 54 54 'labels' => array( 55 55 'name' => __( 'Media' ), 56 'edit_item' => __( 'Edit 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' ), 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', 'comments', 'image-editor' ), 70 81 ) ); 71 82 72 83 register_post_type( 'revision', array( … … 3782 3793 if ( ! in_array( $post_status, array( 'inherit', 'private' ) ) ) 3783 3794 $post_status = 'inherit'; 3784 3795 3785 // Make sure we set a valid category. 3786 if ( !isset($post_category) || 0 == count($post_category) || !is_array($post_category) ) { 3787 // 'post' requires at least one category. 3788 if ( 'post' == $post_type ) 3789 $post_category = array( get_option('default_category') ); 3790 else 3791 $post_category = array(); 3796 3797 // Support for all taxonomies 3798 if ( ! empty( $tax_input ) ) { 3799 foreach ( $tax_input as $taxonomy => $tags ) { 3800 $taxonomy_obj = get_taxonomy( $taxonomy ); 3801 if ( is_array( $tags ) ) // array = hierarchical, string = non-hierarchical. 3802 $tags = array_filter( $tags ); 3803 if ( current_user_can( $taxonomy_obj->cap->assign_terms ) ) 3804 wp_set_post_terms( $post_ID, $tags, $taxonomy ); 3805 } 3792 3806 } 3793 3807 3794 3808 // Are we updating or creating? … … 3873 3887 $wpdb->update( $wpdb->posts, compact("post_name"), array( 'ID' => $post_ID ) ); 3874 3888 } 3875 3889 3876 wp_set_post_categories($post_ID, $post_category);3877 3878 3890 if ( $file ) 3879 3891 update_attached_file( $post_ID, $file ); 3880 3892 -
wp-includes/template.php
304 304 function get_attachment_template() { 305 305 global $posts; 306 306 $type = explode('/', $posts[0]->post_mime_type); 307 var_dump($posts[0]->post_mime_type); 307 308 if ( $template = get_query_template($type[0]) ) 308 309 return $template; 309 310 elseif ( $template = get_query_template($type[1]) ) … … 391 392 else 392 393 require( $_template_file ); 393 394 } 394 -
wp-admin/includes/class-wp-terms-list-table.php
299 299 if ( 'post' != $this->screen->post_type ) 300 300 $args['post_type'] = $this->screen->post_type; 301 301 302 return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; 302 $base = $this->screen->post_type == 'attachment' ? 'upload.php' : 'edit.php'; 303 304 return "<a href='" . esc_url ( add_query_arg( $args, $base ) ) . "'>$count</a>"; 303 305 } 304 306 305 307 function column_links( $tag ) { -
wp-admin/includes/post.php
235 235 } 236 236 } 237 237 238 // Attachment stuff 239 if ( isset( $post_data['_wp_attachment_image_alt'] ) ) { 240 $image_alt = get_post_meta( $post_ID, '_wp_attachment_image_alt', true ); 241 if ( $image_alt != stripslashes( $post_data['_wp_attachment_image_alt'] ) ) { 242 $image_alt = wp_strip_all_tags( stripslashes( $post_data['_wp_attachment_image_alt'] ), true ); 243 // update_meta expects slashed 244 update_post_meta( $post_ID, '_wp_attachment_image_alt', addslashes( $image_alt ) ); 245 } 246 } 247 238 248 add_meta( $post_ID ); 239 249 240 250 update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); … … 1064 1074 1065 1075 list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); 1066 1076 1067 if ( 'publish' == $post->post_status) {1077 if ( 'publish' == get_post_status( $post ) ) { 1068 1078 $ptype = get_post_type_object($post->post_type); 1069 1079 $view_post = $ptype->labels->view_item; 1070 1080 $title = __('Click to edit this part of the permalink'); -
wp-admin/includes/screen.php
98 98 if ( 'post' == $screen->base ) { 99 99 if ( 'post' == $screen->post_type || 'page' == $screen->post_type ) 100 100 $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); 101 elseif ( 'attachment' == $screen->post_type ) 102 $hidden = array( 'slugdiv', 'trackbacksdiv', 'postcustom', 'authordiv', 'revisionsdiv' ); 101 103 else 102 104 $hidden = array( 'slugdiv' ); 103 105 } -
wp-admin/includes/media.php
857 857 858 858 /** 859 859 * Filters input from media_upload_form_handler() and assigns a default 860 * post_title from the file name if none supplied. 860 * post_title from the file name if none supplied. 861 861 * 862 * Illustrates the use of the attachment_fields_to_save filter 862 * Illustrates the use of the attachment_fields_to_save filter 863 863 * which can be used to add default values to any field before saving to DB. 864 864 * 865 865 * @since 2.5.0 … … 2095 2095 echo '<p>' . sprintf( __( 'Sorry, you have used all of your storage quota of %s MB.' ), get_space_allowed() ) . '</p>'; 2096 2096 } 2097 2097 2098 /** 2099 * Displays the image and editor in the post editor 2100 * 2101 * @since 3.5.0 2102 */ 2103 function edit_form_image_editor() { 2104 $post = get_post(); 2105 2106 if ( ( $attachment_id = intval( $post->ID ) ) && $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ) ) 2107 $thumb_url = $thumb_url[0]; 2108 else 2109 $thumb_url = false; 2110 2111 $filename = esc_html( basename( $post->guid ) ); 2112 $title = esc_attr( $post->post_title ); 2113 2114 2115 $post_mime_types = get_post_mime_types(); 2116 $keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) ); 2117 $type = array_shift( $keys ); 2118 $type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />"; 2119 2120 2121 $media_dims = ''; 2122 $meta = wp_get_attachment_metadata( $post->ID ); 2123 if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) ) 2124 $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> "; 2125 $media_dims = apply_filters( 'media_meta', $media_dims, $post ); 2126 2127 $image_edit_button = ''; 2128 if ( gd_edit_image_support( $post->post_mime_type ) ) { 2129 $nonce = wp_create_nonce( "image_editor-$post->ID" ); 2130 $image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <img src='" . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . "' class='imgedit-wait-spin' alt='' />"; 2131 } 2132 2133 ?> 2134 <div class="wp_attachment_holder"> 2135 <div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div> 2136 2137 <div class="wp_attachment_image" id="media-head-<?php echo $attachment_id; ?>"> 2138 <p><img class="thumbnail" src="<?php echo $thumb_url; ?>" alt="" /></p> 2139 <p><?php echo $image_edit_button; ?></p> 2140 </div> 2141 <div style="display:none" class="image-editor" id="image-editor-<?php echo $attachment_id; ?>"></div> 2142 2143 <div class="wp_attachment_details"> 2144 <p><strong><?php _e( 'File name:' ); ?></strong> <?php echo $filename; ?></p> 2145 <p><strong><?php _e( 'File type:' ); ?></strong> <?php echo $post->post_mime_type; ?></p> 2146 <?php 2147 if ( !empty( $media_dims ) ) 2148 echo '<p><strong>' . __( 'Dimensions:' ) . "</strong> $media_dims</p>"; 2149 ?> 2150 </div> 2151 </div> 2152 <?php 2153 } 2154 2098 2155 add_filter( 'async_upload_image', 'get_media_item', 10, 2 ); 2099 2156 add_filter( 'async_upload_audio', 'get_media_item', 10, 2 ); 2100 2157 add_filter( 'async_upload_video', 'get_media_item', 10, 2 ); -
wp-admin/includes/class-wp-media-list-table.php
132 132 /* translators: column name */ 133 133 $posts_columns['title'] = _x( 'File', 'column name' ); 134 134 $posts_columns['author'] = __( 'Author' ); 135 //$posts_columns['tags'] = _x( 'Tags', 'column name' ); 135 136 $taxonomies = array(); 137 138 $taxonomies = get_taxonomies_for_attachments( 'objects' ); 139 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); 140 141 $taxonomies = apply_filters( "manage_taxonomies_for_attachment_columns", $taxonomies, 'attachment' ); 142 $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); 143 144 foreach ( $taxonomies as $taxonomy ) { 145 if ( 'post_tag' == $taxonomy ) 146 $column_key = 'tags'; 147 else 148 $column_key = 'taxonomy-' . $taxonomy; 149 150 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; 151 } 152 136 153 /* translators: column name */ 137 154 if ( !$this->detached ) { 138 155 $posts_columns['parent'] = _x( 'Attached to', 'column name' ); … … 251 268 <?php 252 269 break; 253 270 254 case 'tags':255 ?>256 <td <?php echo $attributes ?>><?php257 $tags = get_the_tags();258 if ( !empty( $tags ) ) {259 $out = array();260 foreach ( $tags as $c )261 $out[] = "<a href='edit.php?tag=$c->slug'> " . esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'post_tag', 'display' ) ) . "</a>";262 echo join( ', ', $out );263 } else {264 _e( 'No Tags' );265 }266 ?>267 </td>268 <?php269 break;270 271 271 case 'desc': 272 272 ?> 273 273 <td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td> … … 339 339 break; 340 340 341 341 default: 342 if ( 'tags' == $column_name ) 343 $taxonomy = 'post_tag'; 344 elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) 345 $taxonomy = substr( $column_name, 9 ); 346 347 if ( ! empty( $taxonomy ) ) { 348 $taxonomy_object = get_taxonomy( $taxonomy ); 349 echo '<td ' . $attributes . '>'; 350 if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) { 351 $out = array(); 352 foreach ( $terms as $t ) { 353 $posts_in_term_qv = array(); 354 $posts_in_term_qv['taxonomy'] = $taxonomy; 355 $posts_in_term_qv['term'] = $t->slug; 356 357 $out[] = sprintf( '<a href="%s">%s</a>', 358 esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), 359 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) 360 ); 361 } 362 /* translators: used between list items, there is a space after the comma */ 363 echo join( __( ', ' ), $out ); 364 } else { 365 echo '—'; 366 } 367 echo '</td>'; 368 break; 369 } 342 370 ?> 343 371 <td <?php echo $attributes ?>> 344 372 <?php do_action( 'manage_media_custom_column', $column_name, $id ); ?> -
wp-admin/includes/meta-boxes.php
51 51 </div> 52 52 <?php endif; // public post type ?> 53 53 <div class="clear"></div> 54 </div>< ?php // /minor-publishing-actions ?>54 </div><!-- /minor-publishing-actions --> 55 55 56 56 <div id="misc-publishing-actions"> 57 57 … … 103 103 </div> 104 104 105 105 <?php } ?> 106 </div>< ?php // /misc-pub-section ?>106 </div><!-- /misc-pub-section --> 107 107 108 108 <div class="misc-pub-section" id="visibility"> 109 109 <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php … … 148 148 </div> 149 149 <?php } ?> 150 150 151 </div>< ?php // /misc-pub-section ?>151 </div><!-- /misc-pub-section --> 152 152 153 153 <?php 154 154 // translators: Publish box date format, see http://php.net/date 155 155 $datef = __( 'M j, Y @ G:i' ); 156 156 if ( 0 != $post->ID ) { 157 if ( 'future' == $post->post_status) { // scheduled for publishing at a future date157 if ( 'future' == get_post_status() ) { // scheduled for publishing at a future date 158 158 $stamp = __('Scheduled for: <b>%1$s</b>'); 159 } else if ( 'publish' == $post->post_status || 'private' == $post->post_status) { // already published159 } else if ( 'publish' == get_post_status() || 'private' == get_post_status() ) { // already published 160 160 $stamp = __('Published on: <b>%1$s</b>'); 161 161 } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified 162 162 $stamp = __('Publish <b>immediately</b>'); … … 230 230 } 231 231 232 232 /** 233 * Display attachment submit form fields. 234 * 235 * @since 3.5.0 236 * 237 * @param object $post 238 */ 239 function attachment_submit_meta_box( $post ) { 240 global $action; 241 242 $post_type = $post->post_type; 243 $post_type_object = get_post_type_object($post_type); 244 $can_publish = current_user_can($post_type_object->cap->publish_posts); 245 ?> 246 <div class="submitbox" id="submitpost"> 247 248 <div id="minor-publishing"> 249 250 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?> 251 <div style="display:none;"> 252 <?php submit_button( __( 'Save' ), 'button', 'save' ); ?> 253 </div> 254 255 256 <div id="misc-publishing-actions"> 257 <?php 258 // translators: Publish box date format, see http://php.net/date 259 $datef = __( 'M j, Y @ G:i' ); 260 $stamp = __('Uploaded on: <b>%1$s</b>'); 261 $date = date_i18n( $datef, strtotime( $post->post_date ) ); 262 263 if ( $can_publish ) : // Contributors don't get to choose the date of publish ?> 264 <div class="misc-pub-section curtime"> 265 <span id="timestamp"> 266 <?php printf($stamp, $date); ?></span> 267 <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><?php _e('Edit') ?></a> 268 <div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'), 1); ?></div> 269 </div><?php // /misc-pub-section ?> 270 <?php endif; ?> 271 272 <?php do_action('attachment_submitbox_misc_actions'); ?> 273 </div><!-- / misc-publishing-actions --> 274 <div class="clear"></div> 275 </div><!-- / minor-publishing --> 276 277 <div id="major-publishing-actions"> 278 <div id="delete-action"> 279 <?php 280 if ( current_user_can( 'delete_post', $post->ID ) ) 281 if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { 282 echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>"; 283 } else { 284 $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; 285 echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "''>" . __( 'Delete Permanently' ) . "</a>"; 286 } 287 ?> 288 </div> 289 290 <div id="publishing-action"> 291 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="ajax-loading" alt="" /> 292 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" /> 293 <?php submit_button( __( 'Update' ), 'primary', 'publish', false, array( 'accesskey' => 'p' ) ); ?> 294 </div> 295 <div class="clear"></div> 296 </div><!-- /major-publishing-actions --> 297 298 </div> 299 300 <?php 301 } 302 303 /** 233 304 * Display post format form elements. 234 305 * 235 306 * @since 3.1.0 … … 982 1053 <a href="#" class="remove"><?php _e( 'Remove Featured Image' ); ?></a> 983 1054 </div> 984 1055 <?php 985 } 986 No newline at end of file 1056 } 1057 1058 /** 1059 * Display attachment/media-specific information 1060 * 1061 * @since 3.5.0 1062 * 1063 * @param object $post 1064 */ 1065 function attachment_data_meta_box( $post ) { 1066 $att_url = wp_get_attachment_url( $post->ID ); 1067 $alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true ); 1068 ?> 1069 <label for="_wp_attachment_image_alt"><strong>Alternative text</strong></label><br /> 1070 <input type="text" class="widefat" name="_wp_attachment_image_alt" value="<?php echo esc_attr( $alt_text ); ?>" /> 1071 </p> 1072 1073 <p> 1074 <label for="excerpt"><strong>Excerpt</strong></label><br /> 1075 <textarea class="widefat" name="excerpt"><?php echo $post->post_excerpt; ?></textarea> 1076 </p> 1077 1078 <p> 1079 <label for="attachment_url"><strong>File URL</strong></label><br /> 1080 <input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" value="<?php echo esc_attr($att_url); ?>" /><br /> 1081 <em><?php _e( 'Location of the uploaded file.' ); ?></em> 1082 </p> 1083 <?php 1084 } -
wp-admin/edit-tags.php
26 26 $title = $tax->labels->name; 27 27 28 28 if ( 'post' != $post_type ) { 29 $parent_file = "edit.php?post_type=$post_type";29 $parent_file = ( 'attachment' == $post_type ) ? 'upload.php' : "edit.php?post_type=$post_type"; 30 30 $submenu_file = "edit-tags.php?taxonomy=$taxonomy&post_type=$post_type"; 31 31 } else if ( 'link_category' == $tax->name ) { 32 32 $parent_file = 'link-manager.php'; -
wp-admin/css/wp-admin.css
3750 3750 } 3751 3751 3752 3752 .upload-php .fixed .column-parent { 3753 width: 25%;3753 width: 15%; 3754 3754 } 3755 3755 3756 3756 .js .html-uploader #plupload-upload-ui { … … 3929 3929 margin: 8px 0; 3930 3930 } 3931 3931 3932 .describe .imgedit-wrap table td { 3932 .describe .imgedit-wrap table td, 3933 .wp_attachment_holder .imgedit-wrap table td { 3933 3934 vertical-align: top; 3934 3935 padding-top: 0; 3935 3936 } -
wp-admin/post.php
85 85 if ( ! $sendback || 86 86 strpos( $sendback, 'post.php' ) !== false || 87 87 strpos( $sendback, 'post-new.php' ) !== false ) { 88 $sendback = admin_url( 'edit.php' ); 89 $sendback .= ( ! empty( $post_type ) ) ? '?post_type=' . $post_type : ''; 88 if ( 'attachment' == $post_type ) { 89 $sendback = admin_url( 'upload.php' ); 90 } else { 91 $sendback = admin_url( 'edit.php' ); 92 $sendback .= ( ! empty( $post_type ) ) ? '?post_type=' . $post_type : ''; 93 } 90 94 } else { 91 95 $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback ); 92 96 } … … 148 152 $parent_file = "edit.php"; 149 153 $submenu_file = "edit.php"; 150 154 $post_new_file = "post-new.php"; 155 } elseif ( 'attachment' == $post_type ) { 156 $parent_file = 'upload.php'; 157 $submenu_file = 'upload.php'; 158 $post_new_file = 'media-new.php'; 151 159 } else { 152 160 if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) 153 161 $parent_file = $post_type_object->show_in_menu; -
wp-admin/edit-form-advanced.php
24 24 add_action( 'admin_footer', 'wp_print_media_templates' ); 25 25 } 26 26 27 if ( post_type_supports( $post_type, 'image-editor' ) ) { 28 wp_enqueue_script( 'image-edit' ); 29 wp_enqueue_style( 'imgareaselect' ); 30 } 31 27 32 /** 28 33 * Post ID global 29 34 * @name $post_ID … … 77 82 78 83 $notice = false; 79 84 $form_extra = ''; 80 if ( 'auto-draft' == $post->post_status) {85 if ( 'auto-draft' == get_post_status( $post ) ) { 81 86 if ( 'edit' == $action ) 82 87 $post->post_title = ''; 83 88 $autosave = false; … … 106 111 // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). 107 112 require_once('./includes/meta-boxes.php'); 108 113 109 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', null, 'side', 'core'); 114 if ( 'attachment' == $post_type ) 115 add_meta_box('submitdiv', __('Publish'), 'attachment_submit_meta_box', null, 'side', 'core'); 116 else 117 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', null, 'side', 'core'); 110 118 111 119 if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) 112 120 add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core' ); 113 121 114 122 // all taxonomies 115 foreach ( get_object_taxonomies($post _type) as $tax_name ) {123 foreach ( get_object_taxonomies($post) as $tax_name ) { 116 124 $taxonomy = get_taxonomy($tax_name); 117 125 if ( ! $taxonomy->show_ui ) 118 126 continue; … … 125 133 add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', null, 'side', 'core', array( 'taxonomy' => $tax_name )); 126 134 } 127 135 136 if ( 'attachment' == $post_type ) 137 add_meta_box( 'attachmentdata', __('Attachment Data'), 'attachment_data_meta_box', null, 'normal', 'core' ); 138 128 139 if ( post_type_supports($post_type, 'page-attributes') ) 129 140 add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', null, 'side', 'core'); 130 141 … … 144 155 if ( post_type_supports($post_type, 'comments') ) 145 156 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', null, 'normal', 'core'); 146 157 147 if ( ( 'publish' == $post->post_status || 'private' == $post->post_status) && post_type_supports($post_type, 'comments') )158 if ( ( 'publish' == get_post_status( $post ) || 'private' == get_post_status( $post ) ) && post_type_supports($post_type, 'comments') ) 148 159 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core'); 149 160 150 if ( ! ( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) )161 if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) 151 162 add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core'); 152 163 153 164 if ( post_type_supports($post_type, 'author') ) { … … 158 169 if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) 159 170 add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core'); 160 171 172 if ( post_type_supports( $post_type, 'image-editor' ) ) 173 add_action( 'edit_form_advanced_before', 'edit_form_image_editor' ); 174 161 175 do_action('add_meta_boxes', $post_type, $post); 162 176 do_action('add_meta_boxes_' . $post_type, $post); 163 177 … … 269 283 <input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" /> 270 284 <?php 271 285 } 272 if ( 'draft' != $post->post_status)286 if ( 'draft' != get_post_status( $post ) ) 273 287 wp_original_referer_field(true, 'previous'); 274 288 275 289 echo $form_extra; … … 283 297 284 298 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> 285 299 <div id="post-body-content"> 286 <?php if ( post_type_supports($post_type, 'title') ) { ?> 300 <?php 301 do_action( 'edit_form_advanced_before' ); 302 303 if ( post_type_supports($post_type, 'title') ) { 304 ?> 287 305 <div id="titlediv"> 288 306 <div id="titlewrap"> 289 307 <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo apply_filters( 'enter_title_here', __( 'Enter title here' ), $post ); ?></label> 290 308 <input type="text" name="post_title" size="30" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" autocomplete="off" /> 291 309 </div> 292 310 <div class="inside"> 293 <?php294 $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : '';295 $shortlink = wp_get_shortlink($post->ID, 'post');296 if ( !empty($shortlink) )297 $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-tiny" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';311 <?php 312 $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : ''; 313 $shortlink = wp_get_shortlink($post->ID, 'post'); 314 if ( !empty($shortlink) ) 315 $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-tiny" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>'; 298 316 299 if ( $post_type_object->public && ! ( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?> 300 <div id="edit-slug-box"> 317 if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?> 318 <div id="edit-slug-box"> 319 <?php 320 if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != get_post_status( $post ) ) 321 echo $sample_permalink_html; 322 ?> 323 </div> 301 324 <?php 302 if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status ) 303 echo $sample_permalink_html; 304 ?> 305 </div> 306 <?php 307 } 325 } 308 326 ?> 309 327 </div> 310 328 <?php 311 329 wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); 312 330 ?> 313 </div> 314 <?php } ?> 331 </div><!-- /titlediv --> 332 <?php 333 } 315 334 316 <?php if ( post_type_supports($post_type, 'editor') ) { ?> 335 do_action( 'edit_form_after_title' ); 336 337 if ( post_type_supports($post_type, 'editor') ) { 338 ?> 317 339 <div id="postdivrich" class="postarea"> 318 340 319 341 <?php wp_editor($post->post_content, 'content', array('dfw' => true, 'tabfocus_elements' => 'sample-permalink,post-preview') ); ?> … … 323 345 <td class="autosave-info"> 324 346 <span class="autosave-message"> </span> 325 347 <?php 326 if ( 'auto-draft' != $post->post_status) {348 if ( 'auto-draft' != get_post_status( $post ) ) { 327 349 echo '<span id="last-edit">'; 328 350 if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) { 329 351 $last_user = get_userdata($last_id); … … 337 359 </tr></tbody></table> 338 360 339 361 </div> 340 <?php } ?> 362 <?php 363 } 364 365 do_action( 'edit_form_after_editor' ); 366 ?> 341 367 </div><!-- /post-body-content --> 342 368 343 369 <div id="postbox-container-1" class="postbox-container"> -
wp-admin/menu.php
64 64 $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php'); 65 65 /* translators: add new file */ 66 66 $submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php'); 67 foreach ( get_taxonomies_for_attachments( 'objects' ) as $tax ) { 68 if ( ! $tax->show_ui ) 69 continue; 67 70 71 $submenu['upload.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&post_type=attachment' ); 72 } 73 unset($tax); 74 68 75 $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'none' ); 69 76 $submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' ); 70 77 /* translators: add new links */