Changeset 21948
- Timestamp:
- 09/21/2012 10:52:54 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/wp-admin.css
r21944 r21948 3760 3760 3761 3761 .upload-php .fixed .column-parent { 3762 width: 25%;3762 width: 15%; 3763 3763 } 3764 3764 … … 3939 3939 } 3940 3940 3941 .describe .imgedit-wrap table td { 3941 .describe .imgedit-wrap table td, 3942 .wp_attachment_holder .imgedit-wrap table td { 3942 3943 vertical-align: top; 3943 3944 padding-top: 0; -
trunk/wp-admin/edit-form-advanced.php
r21944 r21948 64 64 10 => sprintf( __('Page draft updated. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 65 65 ); 66 $messages['attachment'] = array_fill( 1, 10, __( 'Media attachment updated' ) ); // Hack, for now. 66 67 67 68 $messages = apply_filters( 'post_updated_messages', $messages ); … … 78 79 $notice = false; 79 80 $form_extra = ''; 80 if ( 'auto-draft' == $post->post_status) {81 if ( 'auto-draft' == get_post_status( $post ) ) { 81 82 if ( 'edit' == $action ) 82 83 $post->post_title = ''; … … 107 108 require_once('./includes/meta-boxes.php'); 108 109 109 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', null, 'side', 'core'); 110 if ( 'attachment' == $post_type ) { 111 wp_enqueue_script( 'image-edit' ); 112 wp_enqueue_style( 'imgareaselect' ); 113 add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' ); 114 add_meta_box( 'attachmentdata', __('Attachment Page Content'), 'attachment_data_meta_box', null, 'normal', 'core' ); 115 add_action( 'edit_form_after_title', 'edit_form_image_editor' ); 116 } else { 117 add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core' ); 118 } 110 119 111 120 if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) … … 113 122 114 123 // all taxonomies 115 foreach ( get_object_taxonomies( $post_type) as $tax_name ) {124 foreach ( get_object_taxonomies( $post ) as $tax_name ) { 116 125 $taxonomy = get_taxonomy($tax_name); 117 126 if ( ! $taxonomy->show_ui ) … … 145 154 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', null, 'normal', 'core'); 146 155 147 if ( ( 'publish' == $post->post_status || 'private' == $post->post_status) && post_type_supports($post_type, 'comments') )156 if ( ( 'publish' == get_post_status( $post ) || 'private' == get_post_status( $post ) ) && post_type_supports($post_type, 'comments') ) 148 157 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core'); 149 158 150 if ( ! ( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) )159 if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) 151 160 add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core'); 152 161 … … 270 279 <?php 271 280 } 272 if ( 'draft' != $post->post_status)281 if ( 'draft' != get_post_status( $post ) ) 273 282 wp_original_referer_field(true, 'previous'); 274 283 … … 297 306 $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>'; 298 307 299 if ( $post_type_object->public && ! ( 'pending' == $post->post_status&& !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?>308 if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?> 300 309 <div id="edit-slug-box"> 301 310 <?php 302 if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status)311 if ( $sample_permalink_html && 'auto-draft' != get_post_status( $post ) ) 303 312 echo $sample_permalink_html; 304 313 ?> … … 311 320 wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); 312 321 ?> 313 </div> 314 <?php } ?> 315 316 <?php if ( post_type_supports($post_type, 'editor') ) { ?> 322 </div><!-- /titlediv --> 323 <?php 324 } 325 326 do_action( 'edit_form_after_title' ); 327 328 if ( post_type_supports($post_type, 'editor') ) { 329 ?> 317 330 <div id="postdivrich" class="postarea"> 318 331 … … 324 337 <span class="autosave-message"> </span> 325 338 <?php 326 if ( 'auto-draft' != $post->post_status) {339 if ( 'auto-draft' != get_post_status( $post ) ) { 327 340 echo '<span id="last-edit">'; 328 341 if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) { -
trunk/wp-admin/edit-tags.php
r21365 r21948 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 ) { -
trunk/wp-admin/includes/class-wp-media-list-table.php
r21944 r21948 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 ( 'category' == $taxonomy ) 146 $column_key = 'categories'; 147 elseif ( 'post_tag' == $taxonomy ) 148 $column_key = 'tags'; 149 else 150 $column_key = 'taxonomy-' . $taxonomy; 151 152 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; 153 } 154 136 155 /* translators: column name */ 137 156 if ( !$this->detached ) { … … 249 268 ?> 250 269 <td <?php echo $attributes ?>><?php the_author() ?></td> 251 <?php252 break;253 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 270 <?php 269 271 break; … … 340 342 341 343 default: 344 if ( 'categories' == $column_name ) 345 $taxonomy = 'category'; 346 if ( 'tags' == $column_name ) 347 $taxonomy = 'post_tag'; 348 elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) 349 $taxonomy = substr( $column_name, 9 ); 350 else 351 $taxonomy = false; 352 353 if ( $taxonomy ) { 354 $taxonomy_object = get_taxonomy( $taxonomy ); 355 echo '<td ' . $attributes . '>'; 356 if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) { 357 $out = array(); 358 foreach ( $terms as $t ) { 359 $posts_in_term_qv = array(); 360 $posts_in_term_qv['taxonomy'] = $taxonomy; 361 $posts_in_term_qv['term'] = $t->slug; 362 363 $out[] = sprintf( '<a href="%s">%s</a>', 364 esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), 365 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) 366 ); 367 } 368 /* translators: used between list items, there is a space after the comma */ 369 echo join( __( ', ' ), $out ); 370 } else { 371 echo '—'; 372 } 373 echo '</td>'; 374 break; 375 } 342 376 ?> 343 377 <td <?php echo $attributes ?>> -
trunk/wp-admin/includes/class-wp-terms-list-table.php
r21914 r21948 299 299 if ( 'post' != $this->screen->post_type ) 300 300 $args['post_type'] = $this->screen->post_type; 301 302 if ( 'attachment' == $this->screen->post_type ) 303 return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>"; 301 304 302 305 return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; -
trunk/wp-admin/includes/media.php
r21944 r21948 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. 861 * 862 * Illustrates the use of the attachment_fields_to_save filter 860 * post_title from the file name if none supplied. 861 * 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 * … … 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 $thumb_url = false; 2107 if ( $attachment_id = intval( $post->ID ) ) 2108 $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 600 ), true ); 2109 2110 $filename = esc_html( basename( $post->guid ) ); 2111 $title = esc_attr( $post->post_title ); 2112 2113 $post_mime_types = get_post_mime_types(); 2114 $keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) ); 2115 $type = array_shift( $keys ); 2116 $type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />"; 2117 2118 $media_dims = ''; 2119 $meta = wp_get_attachment_metadata( $post->ID ); 2120 if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) ) 2121 $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> "; 2122 $media_dims = apply_filters( 'media_meta', $media_dims, $post ); 2123 2124 $att_url = wp_get_attachment_url( $post->ID ); 2125 2126 $image_edit_button = ''; 2127 if ( gd_edit_image_support( $post->post_mime_type ) ) { 2128 $nonce = wp_create_nonce( "image_editor-$post->ID" ); 2129 $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='' />"; 2130 } 2131 2132 ?> 2133 <div class="wp_attachment_holder"> 2134 <div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div> 2135 2136 <div class="wp_attachment_image" id="media-head-<?php echo $attachment_id; ?>"> 2137 <p><img class="thumbnail" src="<?php echo $thumb_url[0]; ?>" style="max-width:100%" width="<?php echo $thumb_url[1]; ?>" alt="" /></p> 2138 <p><?php echo $image_edit_button; ?></p> 2139 </div> 2140 <div style="display:none" class="image-editor" id="image-editor-<?php echo $attachment_id; ?>"></div> 2141 2142 <div class="wp_attachment_details"> 2143 <p> 2144 <label for="attachment_url"><strong><?php _e( 'File URL' ); ?></strong></label><br /> 2145 <input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" value="<?php echo esc_attr($att_url); ?>" /><br /> 2146 </p> 2147 <p><strong><?php _e( 'File name:' ); ?></strong> <?php echo $filename; ?><br /> 2148 <strong><?php _e( 'File type:' ); ?></strong> <?php echo $post->post_mime_type; ?> 2149 <?php 2150 if ( $media_dims ) 2151 echo '<br /><strong>' . __( 'Dimensions:' ) . '</strong> ' . $media_dims; 2152 ?> 2153 </p> 2154 </div> 2155 </div> 2156 <?php 2157 } 2158 2098 2159 add_filter( 'async_upload_image', 'get_media_item', 10, 2 ); 2099 2160 add_filter( 'async_upload_audio', 'get_media_item', 10, 2 ); -
trunk/wp-admin/includes/meta-boxes.php
r21944 r21948 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"> … … 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"> … … 149 149 <?php } ?> 150 150 151 </div>< ?php // /misc-pub-section ?>151 </div><!-- .misc-pub-section --> 152 152 153 153 <?php … … 227 227 </div> 228 228 229 <?php 230 } 231 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 <div class="misc-pub-section curtime"> 264 <span id="timestamp"><?php printf($stamp, $date); ?></span> 265 </div><!-- .misc-pub-section --> 266 267 <?php do_action('attachment_submitbox_misc_actions'); ?> 268 </div><!-- #misc-publishing-actions --> 269 <div class="clear"></div> 270 </div><!-- #minor-publishing --> 271 272 <div id="major-publishing-actions"> 273 <div id="delete-action"> 274 <?php 275 if ( current_user_can( 'delete_post', $post->ID ) ) 276 if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { 277 echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>"; 278 } else { 279 $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; 280 echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "''>" . __( 'Delete Permanently' ) . "</a>"; 281 } 282 ?> 283 </div> 284 285 <div id="publishing-action"> 286 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="ajax-loading" alt="" /> 287 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" /> 288 <input name="save" type="submit" class="button-primary button-large" id="publish" accesskey="p" value="<?php esc_attr_e('Update') ?>" /> 289 </div> 290 <div class="clear"></div> 291 </div><!-- #major-publishing-actions --> 292 293 </div> 294 295 <?php 296 } 297 298 /** 299 * Display attachment/media-specific information 300 * 301 * @since 3.5.0 302 * 303 * @param object $post 304 */ 305 function attachment_data_meta_box( $post ) { 306 $alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true ); 307 $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ); 308 $editor_args = array( 309 'textarea_name' => 'content', 310 'textarea_rows' => 5, 311 'media_buttons' => false, 312 'tinymce' => false, 313 'quicktags' => $quicktags_settings, 314 ); 315 ?> 316 <p> 317 <label class="screen-reader-text" for="content"><strong><?php _e( 'Attachment Page Content' ); ?></strong></label> 318 <?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?> 319 </p> 320 321 <p> 322 <label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br /> 323 <textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea> 324 </p> 325 <p> 326 <label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br /> 327 <input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php echo esc_attr( $alt_text ); ?>" /> 328 </p> 229 329 <?php 230 330 } -
trunk/wp-admin/includes/post.php
r21944 r21948 233 233 continue; 234 234 delete_meta( $key ); 235 } 236 } 237 238 // Attachment stuff 239 if ( 'attachment' == $post_data['post_type'] && 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 ) ); 235 245 } 236 246 } … … 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; -
trunk/wp-admin/includes/screen.php
r21687 r21948 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 -
trunk/wp-admin/menu.php
r21877 r21948 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; 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); 67 74 68 75 $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'none' ); -
trunk/wp-admin/post.php
r21651 r21948 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 ); … … 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 ) -
trunk/wp-includes/admin-bar.php
r21818 r21948 488 488 $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ); 489 489 490 if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->edit_posts ) ) {490 if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->edit_posts ) ) 491 491 $actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' ); 492 unset( $cpts['post'] ); 493 } 494 495 if ( current_user_can( 'upload_files' ) ) 496 $actions[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'new-media' ); 492 493 if ( isset( $cpts['attachment'] ) && current_user_can( 'upload_files' ) ) 494 $actions[ 'media-new.php' ] = array( $cpts['attachment']->labels->name_admin_bar, 'new-media' ); 497 495 498 496 if ( current_user_can( 'manage_links' ) ) 499 497 $actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' ); 500 498 501 if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->edit_posts ) ) {499 if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->edit_posts ) ) 502 500 $actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' ); 503 unset( $cpts['page'] ); 504 }501 502 unset( $cpts['post'], $cpts['page'], $cpts['attachment'] ); 505 503 506 504 // Add any additional custom post types. -
trunk/wp-includes/link-template.php
r21937 r21948 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); … … 293 293 * 294 294 * @param mixed $post Optional. Post ID or object. 295 * @return string 296 */ 297 function get_attachment_link( $post = null ) { 295 * @param bool $leavename Optional. Leave name. 296 * @return string 297 */ 298 function get_attachment_link( $post = null, $leavename = false ) { 298 299 global $wp_rewrite; 299 300 … … 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 -
trunk/wp-includes/media.php
r21909 r21948 987 987 988 988 /** 989 * Return all of the taxonomy names that are registered for attachments. 990 * 991 * Handles mime-type-specific taxonomies such as attachment:image and attachment:video. 992 * 993 * @since 3.5.0 994 * @see get_attachment_taxonomies() 995 * @uses get_taxonomies() 996 * 997 * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default. 998 * @return array The names of all taxonomy of $object_type. 999 */ 1000 function get_taxonomies_for_attachments( $output = 'names' ) { 1001 $taxonomies = array(); 1002 foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) { 1003 foreach ( $taxonomy->object_type as $object_type ) { 1004 if ( 'attachment' == $object_type || 0 === strpos( $object_type, 'attachment:' ) ) { 1005 if ( 'names' == $output ) 1006 $taxonomies[] = $taxonomy->name; 1007 else 1008 $taxonomies[ $taxonomy->name ] = $taxonomy; 1009 break; 1010 } 1011 } 1012 } 1013 1014 return $taxonomies; 1015 } 1016 1017 /** 989 1018 * Check if the installed version of GD supports particular image type 990 1019 * -
trunk/wp-includes/post.php
r21943 r21948 53 53 register_post_type( 'attachment', array( 54 54 'labels' => array( 55 'name' => __( 'Media' ), 56 'edit_item' => __( 'Edit Media' ), 55 'name' => _x('Media', 'post type general name'), 56 'name_admin_bar' => _x( 'Media', 'add new from admin bar' ), 57 'add_new' => _x( 'Add New', 'add new media' ), 58 'edit_item' => __( 'Edit Media' ), 59 'view_item' => __( 'View Attachment Page' ), 57 60 ), 58 61 'public' => true, 59 'show_ui' => false,62 'show_ui' => true, 60 63 '_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. */64 '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */ 62 65 'capability_type' => 'post', 63 66 'map_meta_cap' => true, … … 67 70 'show_in_nav_menus' => false, 68 71 'delete_with_user' => true, 69 'supports' => array( ' comments', 'author' ),72 'supports' => array( 'title', 'author', 'comments' ), 70 73 ) ); 71 74 … … 3769 3772 $post_status = 'inherit'; 3770 3773 3774 if ( !empty($post_category) ) 3775 $post_category = array_filter($post_category); // Filter out empty terms 3776 3771 3777 // Make sure we set a valid category. 3772 if ( !isset($post_category) || 0 == count($post_category) || !is_array($post_category) ) { 3773 // 'post' requires at least one category. 3774 if ( 'post' == $post_type ) 3775 $post_category = array( get_option('default_category') ); 3776 else 3777 $post_category = array(); 3778 if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) { 3779 $post_category = array(); 3778 3780 } 3779 3781 … … 3860 3862 } 3861 3863 3862 wp_set_post_categories($post_ID, $post_category); 3864 if ( is_object_in_taxonomy($post_type, 'category') ) 3865 wp_set_post_categories( $post_ID, $post_category ); 3866 3867 if ( isset( $tags_input ) && is_object_in_taxonomy($post_type, 'post_tag') ) 3868 wp_set_post_tags( $post_ID, $tags_input ); 3869 3870 // support for all custom taxonomies 3871 if ( !empty($tax_input) ) { 3872 foreach ( $tax_input as $taxonomy => $tags ) { 3873 $taxonomy_obj = get_taxonomy($taxonomy); 3874 if ( is_array($tags) ) // array = hierarchical, string = non-hierarchical. 3875 $tags = array_filter($tags); 3876 if ( current_user_can($taxonomy_obj->cap->assign_terms) ) 3877 wp_set_post_terms( $post_ID, $tags, $taxonomy ); 3878 } 3879 } 3863 3880 3864 3881 if ( $file )
Note: See TracChangeset
for help on using the changeset viewer.