Make WordPress Core

Ticket #21391: 21391.7.1.patch

File 21391.7.1.patch, 30.0 KB (added by ocean90, 13 years ago)

s/image_editor/image-editor/g and s/get_attachments_taxonomies/get_taxonomies_for_attachments/

  • wp-includes/media.php

     
    986986}
    987987
    988988/**
     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 */
     998function 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 */
     1023function _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/**
    9891036 * Check if the installed version of GD supports particular image type
    9901037 *
    9911038 * @since 2.9.0
  • wp-includes/link-template.php

     
    106106        if ( $post->post_type == 'page' )
    107107                return get_page_link($post->ID, $leavename, $sample);
    108108        elseif ( $post->post_type == 'attachment' )
    109                 return get_attachment_link($post->ID);
     109                return get_attachment_link( $post->ID, $leavename );
    110110        elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) )
    111111                return get_post_permalink($post->ID, $leavename, $sample);
    112112
     
    292292 * @since 2.0.0
    293293 *
    294294 * @param mixed $post Optional. Post ID or object.
     295 * @param bool $leavename Optional. Leave name.
    295296 * @return string
    296297 */
    297 function get_attachment_link( $post = null ) {
     298function get_attachment_link( $post = null, $leavename = false ) {
    298299        global $wp_rewrite;
    299300
    300301        $link = false;
     
    314315                        $name = $post->post_name;
    315316
    316317                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 );
    318322        }
    319323
    320324        if ( ! $link )
  • wp-includes/post.php

     
    5353        register_post_type( 'attachment', array(
    5454                'labels' => array(
    5555                        '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' ),
    5768                ),
    5869                'public' => true,
    59                 'show_ui' => false,
     70                'show_ui' => true,
    6071                '_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. */
    6273                'capability_type' => 'post',
    6374                'map_meta_cap' => true,
    6475                'hierarchical' => false,
     
    6677                'query_var' => false,
    6778                'show_in_nav_menus' => false,
    6879                'delete_with_user' => true,
    69                 'supports' => array( 'comments', 'author' ),
     80                'supports' => array( 'title', 'editor', 'author', 'comments', 'image-editor' ),
    7081        ) );
    7182
    7283        register_post_type( 'revision', array(
     
    37823793        if ( ! in_array( $post_status, array( 'inherit', 'private' ) ) )
    37833794                $post_status = 'inherit';
    37843795
    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                }
    37923806        }
    37933807
    37943808        // Are we updating or creating?
     
    38733887                $wpdb->update( $wpdb->posts, compact("post_name"), array( 'ID' => $post_ID ) );
    38743888        }
    38753889
    3876         wp_set_post_categories($post_ID, $post_category);
    3877 
    38783890        if ( $file )
    38793891                update_attached_file( $post_ID, $file );
    38803892
  • wp-includes/template.php

     
    304304function get_attachment_template() {
    305305        global $posts;
    306306        $type = explode('/', $posts[0]->post_mime_type);
     307        var_dump($posts[0]->post_mime_type);
    307308        if ( $template = get_query_template($type[0]) )
    308309                return $template;
    309310        elseif ( $template = get_query_template($type[1]) )
     
    391392        else
    392393                require( $_template_file );
    393394}
    394 
  • wp-admin/includes/class-wp-terms-list-table.php

     
    299299                if ( 'post' != $this->screen->post_type )
    300300                        $args['post_type'] = $this->screen->post_type;
    301301
    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>";
    303305        }
    304306
    305307        function column_links( $tag ) {
  • wp-admin/includes/post.php

     
    235235                }
    236236        }
    237237
     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
    238248        add_meta( $post_ID );
    239249
    240250        update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
     
    10641074
    10651075        list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
    10661076
    1067         if ( 'publish' == $post->post_status ) {
     1077        if ( 'publish' == get_post_status( $post ) ) {
    10681078                $ptype = get_post_type_object($post->post_type);
    10691079                $view_post = $ptype->labels->view_item;
    10701080                $title = __('Click to edit this part of the permalink');
  • wp-admin/includes/screen.php

     
    9898                if ( 'post' == $screen->base ) {
    9999                        if ( 'post' == $screen->post_type || 'page' == $screen->post_type )
    100100                                $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv');
     101                        elseif ( 'attachment' == $screen->post_type )
     102                                $hidden = array( 'slugdiv', 'trackbacksdiv', 'postcustom', 'authordiv', 'revisionsdiv' );
    101103                        else
    102104                                $hidden = array( 'slugdiv' );
    103105                }
  • wp-admin/includes/media.php

     
    857857
    858858/**
    859859 * 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.
    861861 *
    862  * Illustrates the use of the attachment_fields_to_save filter 
     862 * Illustrates the use of the attachment_fields_to_save filter
    863863 * which can be used to add default values to any field before saving to DB.
    864864 *
    865865 * @since 2.5.0
     
    20952095        echo '<p>' . sprintf( __( 'Sorry, you have used all of your storage quota of %s MB.' ), get_space_allowed() ) . '</p>';
    20962096}
    20972097
     2098/**
     2099 * Displays the image and editor in the post editor
     2100 *
     2101 * @since 3.5.0
     2102 */
     2103function 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']}&nbsp;&times;&nbsp;{$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
    20982155add_filter( 'async_upload_image', 'get_media_item', 10, 2 );
    20992156add_filter( 'async_upload_audio', 'get_media_item', 10, 2 );
    21002157add_filter( 'async_upload_video', 'get_media_item', 10, 2 );
  • wp-admin/includes/class-wp-media-list-table.php

     
    132132                /* translators: column name */
    133133                $posts_columns['title'] = _x( 'File', 'column name' );
    134134                $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
    136153                /* translators: column name */
    137154                if ( !$this->detached ) {
    138155                        $posts_columns['parent'] = _x( 'Attached to', 'column name' );
     
    251268<?php
    252269                break;
    253270
    254         case 'tags':
    255 ?>
    256                 <td <?php echo $attributes ?>><?php
    257                 $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 <?php
    269                 break;
    270 
    271271        case 'desc':
    272272?>
    273273                <td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
     
    339339                break;
    340340
    341341        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 '&#8212;';
     366                        }
     367                        echo '</td>';
     368                        break;
     369                }
    342370?>
    343371                <td <?php echo $attributes ?>>
    344372                        <?php do_action( 'manage_media_custom_column', $column_name, $id ); ?>
  • wp-admin/includes/meta-boxes.php

     
    5151</div>
    5252<?php endif; // public post type ?>
    5353<div class="clear"></div>
    54 </div><?php // /minor-publishing-actions ?>
     54</div><!-- /minor-publishing-actions -->
    5555
    5656<div id="misc-publishing-actions">
    5757
     
    103103</div>
    104104
    105105<?php } ?>
    106 </div><?php // /misc-pub-section ?>
     106</div><!-- /misc-pub-section -->
    107107
    108108<div class="misc-pub-section" id="visibility">
    109109<?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php
     
    148148</div>
    149149<?php } ?>
    150150
    151 </div><?php // /misc-pub-section ?>
     151</div><!-- /misc-pub-section -->
    152152
    153153<?php
    154154// translators: Publish box date format, see http://php.net/date
    155155$datef = __( 'M j, Y @ G:i' );
    156156if ( 0 != $post->ID ) {
    157         if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
     157        if ( 'future' == get_post_status() ) { // scheduled for publishing at a future date
    158158                $stamp = __('Scheduled for: <b>%1$s</b>');
    159         } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
     159        } else if ( 'publish' == get_post_status() || 'private' == get_post_status() ) { // already published
    160160                $stamp = __('Published on: <b>%1$s</b>');
    161161        } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
    162162                $stamp = __('Publish <b>immediately</b>');
     
    230230}
    231231
    232232/**
     233 * Display attachment submit form fields.
     234 *
     235 * @since 3.5.0
     236 *
     237 * @param object $post
     238 */
     239function 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/**
    233304 * Display post format form elements.
    234305 *
    235306 * @since 3.1.0
     
    9821053                <a href="#" class="remove"><?php _e( 'Remove Featured Image' ); ?></a>
    9831054        </div>
    9841055        <?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 */
     1065function 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

     
    2626$title = $tax->labels->name;
    2727
    2828if ( '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";
    3030        $submenu_file = "edit-tags.php?taxonomy=$taxonomy&amp;post_type=$post_type";
    3131} else if ( 'link_category' == $tax->name ) {
    3232        $parent_file = 'link-manager.php';
  • wp-admin/css/wp-admin.css

     
    37503750}
    37513751
    37523752.upload-php .fixed .column-parent {
    3753         width: 25%;
     3753        width: 15%;
    37543754}
    37553755
    37563756.js .html-uploader #plupload-upload-ui {
     
    39293929        margin: 8px 0;
    39303930}
    39313931
    3932 .describe .imgedit-wrap table td {
     3932.describe .imgedit-wrap table td,
     3933.wp_attachment_holder .imgedit-wrap table td {
    39333934        vertical-align: top;
    39343935        padding-top: 0;
    39353936}
  • wp-admin/post.php

     
    8585if ( ! $sendback ||
    8686     strpos( $sendback, 'post.php' ) !== false ||
    8787     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        }
    9094} else {
    9195        $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback );
    9296}
     
    148152                $parent_file = "edit.php";
    149153                $submenu_file = "edit.php";
    150154                $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';
    151159        } else {
    152160                if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true )
    153161                        $parent_file = $post_type_object->show_in_menu;
  • wp-admin/edit-form-advanced.php

     
    2424        add_action( 'admin_footer', 'wp_print_media_templates' );
    2525}
    2626
     27if ( post_type_supports( $post_type, 'image-editor' ) ) {
     28        wp_enqueue_script( 'image-edit' );
     29        wp_enqueue_style( 'imgareaselect' );
     30}
     31
    2732/**
    2833 * Post ID global
    2934 * @name $post_ID
     
    7782
    7883$notice = false;
    7984$form_extra = '';
    80 if ( 'auto-draft' == $post->post_status ) {
     85if ( 'auto-draft' == get_post_status( $post ) ) {
    8186        if ( 'edit' == $action )
    8287                $post->post_title = '';
    8388        $autosave = false;
     
    106111// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
    107112require_once('./includes/meta-boxes.php');
    108113
    109 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', null, 'side', 'core');
     114if ( 'attachment' == $post_type )
     115        add_meta_box('submitdiv', __('Publish'), 'attachment_submit_meta_box', null, 'side', 'core');
     116else
     117        add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', null, 'side', 'core');
    110118
    111119if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) )
    112120        add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core' );
    113121
    114122// all taxonomies
    115 foreach ( get_object_taxonomies($post_type) as $tax_name ) {
     123foreach ( get_object_taxonomies($post) as $tax_name ) {
    116124        $taxonomy = get_taxonomy($tax_name);
    117125        if ( ! $taxonomy->show_ui )
    118126                continue;
     
    125133                add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', null, 'side', 'core', array( 'taxonomy' => $tax_name ));
    126134}
    127135
     136if ( 'attachment' == $post_type )
     137        add_meta_box( 'attachmentdata', __('Attachment Data'), 'attachment_data_meta_box', null, 'normal', 'core' );
     138
    128139if ( post_type_supports($post_type, 'page-attributes') )
    129140        add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', null, 'side', 'core');
    130141
     
    144155if ( post_type_supports($post_type, 'comments') )
    145156        add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', null, 'normal', 'core');
    146157
    147 if ( ('publish' == $post->post_status || 'private' == $post->post_status) && post_type_supports($post_type, 'comments') )
     158if ( ( 'publish' == get_post_status( $post ) || 'private' == get_post_status( $post ) ) && post_type_supports($post_type, 'comments') )
    148159        add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core');
    149160
    150 if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) )
     161if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) )
    151162        add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core');
    152163
    153164if ( post_type_supports($post_type, 'author') ) {
     
    158169if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) )
    159170        add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
    160171
     172if ( post_type_supports( $post_type, 'image-editor' ) )
     173        add_action( 'edit_form_advanced_before', 'edit_form_image_editor' );
     174
    161175do_action('add_meta_boxes', $post_type, $post);
    162176do_action('add_meta_boxes_' . $post_type, $post);
    163177
     
    269283<input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" />
    270284<?php
    271285}
    272 if ( 'draft' != $post->post_status )
     286if ( 'draft' != get_post_status( $post ) )
    273287        wp_original_referer_field(true, 'previous');
    274288
    275289echo $form_extra;
     
    283297
    284298<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
    285299<div id="post-body-content">
    286 <?php if ( post_type_supports($post_type, 'title') ) { ?>
     300<?php
     301do_action( 'edit_form_advanced_before' );
     302
     303if ( post_type_supports($post_type, 'title') ) {
     304?>
    287305<div id="titlediv">
    288306<div id="titlewrap">
    289307        <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo apply_filters( 'enter_title_here', __( 'Enter title here' ), $post ); ?></label>
    290308        <input type="text" name="post_title" size="30" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" autocomplete="off" />
    291309</div>
    292310<div class="inside">
    293 <?php
    294 $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(&#39;URL:&#39;, 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(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
    298316
    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>
    301324        <?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        }
    308326?>
    309327</div>
    310328<?php
    311329wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
    312330?>
    313 </div>
    314 <?php } ?>
     331</div><!-- /titlediv -->
     332<?php
     333}
    315334
    316 <?php if ( post_type_supports($post_type, 'editor') ) { ?>
     335do_action( 'edit_form_after_title' );
     336
     337if ( post_type_supports($post_type, 'editor') ) {
     338?>
    317339<div id="postdivrich" class="postarea">
    318340
    319341<?php wp_editor($post->post_content, 'content', array('dfw' => true, 'tabfocus_elements' => 'sample-permalink,post-preview') ); ?>
     
    323345        <td class="autosave-info">
    324346        <span class="autosave-message">&nbsp;</span>
    325347<?php
    326         if ( 'auto-draft' != $post->post_status ) {
     348        if ( 'auto-draft' != get_post_status( $post ) ) {
    327349                echo '<span id="last-edit">';
    328350                if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
    329351                        $last_user = get_userdata($last_id);
     
    337359</tr></tbody></table>
    338360
    339361</div>
    340 <?php } ?>
     362<?php
     363}
     364
     365do_action( 'edit_form_after_editor' );
     366?>
    341367</div><!-- /post-body-content -->
    342368
    343369<div id="postbox-container-1" class="postbox-container">
  • wp-admin/menu.php

     
    6464        $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
    6565        /* translators: add new file */
    6666        $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;
    6770
     71                $submenu['upload.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&amp;post_type=attachment' );
     72        }
     73        unset($tax);
     74
    6875$menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'none' );
    6976        $submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' );
    7077        /* translators: add new links */