Make WordPress Core

Ticket #19257: 19257.diff

File 19257.diff, 12.0 KB (added by valendesigns, 9 years ago)
  • src/wp-admin/edit-form-advanced.php

    diff --git src/wp-admin/edit-form-advanced.php src/wp-admin/edit-form-advanced.php
    index 451691a..346abcf 100644
    if ( post_type_supports($post_type, 'page-attributes') ) 
    208208        add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', null, 'side', 'core');
    209209
    210210if ( $thumbnail_support && current_user_can( 'upload_files' ) )
    211         add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', null, 'side', 'low');
     211        add_meta_box('postimagediv', $post_type_object->labels->featured_image, 'post_thumbnail_meta_box', null, 'side', 'low');
    212212
    213213if ( post_type_supports($post_type, 'excerpt') )
    214214        add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', null, 'normal', 'core');
    if ( 'post' == $post_type ) { 
    366366        }
    367367
    368368        if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
    369                 $publish_box .= '<li>' . __('<strong>Featured Image</strong> - This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the featured image as a post thumbnail on the home page, a custom header, etc.') . '</li>';
     369                $publish_box .= '<li>' . sprintf( __('<strong>%s</strong> - This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the featured image as a post thumbnail on the home page, a custom header, etc.'), $post_type_object->labels->featured_image ) . '</li>';
    370370        }
    371371
    372372        $publish_box .= '</ul>';
  • src/wp-admin/includes/media.php

    diff --git src/wp-admin/includes/media.php src/wp-admin/includes/media.php
    index e1b573d..ad919ad 100644
    function get_media_item( $attachment_id, $args = null ) { 
    14861486        }
    14871487        if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) )
    14881488                && post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) {
     1489               
     1490                $calling_post = get_post( $calling_post_id );
     1491                $calling_post_type_object = get_post_type_object( $calling_post->post_type );
     1492
    14891493                $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$calling_post_id" );
    1490                 $thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\", \"$ajax_nonce\");return false;'>" . esc_html__( "Use as featured image" ) . "</a>";
     1494                $thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\", \"$ajax_nonce\");return false;'>" . esc_html( $calling_post_type_object->labels->use_featured_image ) . "</a>";
    14911495        }
    14921496
    14931497        if ( ( $r['send'] || $thumbnail || $delete ) && !isset( $form_fields['buttons'] ) ) {
    function get_compat_media_markup( $attachment_id, $args = null ) { 
    17221726 * @since 2.5.0
    17231727 */
    17241728function media_upload_header() {
     1729
    17251730        $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0;
    1726         echo '<script type="text/javascript">post_id = ' . $post_id . ";</script>\n";
     1731
     1732        if ( ! empty( $post_id ) ) {
     1733                $post_type = get_post_type( $post_id );
     1734        } else {
     1735                $post_type = '';
     1736        }
     1737
     1738        echo '<script type="text/javascript">post_id = ' . $post_id . ';post_type = ' . $post_type . ';</script>';
    17271739        if ( empty( $_GET['chromeless'] ) ) {
    17281740                echo '<div id="media-upload-header">';
    17291741                the_media_upload_tabs();
  • src/wp-admin/includes/post.php

    diff --git src/wp-admin/includes/post.php src/wp-admin/includes/post.php
    index 9356ace..57e352c 100644
    function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { 
    13451345function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
    13461346        global $content_width, $_wp_additional_image_sizes;
    13471347
    1348         $post = get_post( $post );
    1349 
     1348        $post = get_post( $post );
     1349        $post_type_object = get_post_type_object( $post->post_type );
     1350        $set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr( $post_type_object->labels->set_featured_image ) . '" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>';
    13501351        $upload_iframe_src = esc_url( get_upload_iframe_src('image', $post->ID ) );
    1351         $set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__( 'Set featured image' ) . '" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>';
    1352         $content = sprintf( $set_thumbnail_link, $upload_iframe_src, esc_html__( 'Set featured image' ) );
     1352
     1353        $content = sprintf( $set_thumbnail_link, $upload_iframe_src, esc_html( $post_type_object->labels->set_featured_image ) );
    13531354
    13541355        if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
    13551356                $old_content_width = $content_width;
    function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { 
    13611362                if ( !empty( $thumbnail_html ) ) {
    13621363                        $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );
    13631364                        $content = sprintf( $set_thumbnail_link, $upload_iframe_src, $thumbnail_html );
    1364                         $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__( 'Remove featured image' ) . '</a></p>';
     1365                        $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html( $post_type_object->labels->remove_featured_image ) . '</a></p>';
    13651366                }
    13661367                $content_width = $old_content_width;
    13671368        }
  • src/wp-admin/js/set-post-thumbnail.js

    diff --git src/wp-admin/js/set-post-thumbnail.js src/wp-admin/js/set-post-thumbnail.js
    index 68abbcc..f27fdec 100644
    function WPSetAsThumbnail( id, nonce ) { 
    99                action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie )
    1010        }, function(str){
    1111                var win = window.dialogArguments || opener || parent || top;
    12                 $link.text( setPostThumbnailL10n.setThumbnail );
     12                setThumbnail = 'setThumbnail_' + post_type;
     13                $link.text( setPostThumbnailL10n[setThumbnail] );
    1314                if ( str == '0' ) {
    1415                        alert( setPostThumbnailL10n.error );
    1516                } else {
  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index b69b328..8e939fb 100644
    function wp_enqueue_media( $args = array() ) { 
    29912991
    29922992        $hier = $post && is_post_type_hierarchical( $post->post_type );
    29932993
     2994        $post_type_object = get_post_type_object( $post->post_type );
     2995
    29942996        $strings = array(
    29952997                // Generic
    29962998                'url'         => __( 'URL' ),
    function wp_enqueue_media( $args = array() ) { 
    30493051                'insertFromUrlTitle' => __( 'Insert from URL' ),
    30503052
    30513053                // Featured Images
    3052                 'setFeaturedImageTitle' => __( 'Set Featured Image' ),
    3053                 'setFeaturedImage'    => __( 'Set featured image' ),
     3054                'setFeaturedImageTitle' => $post_type_object->labels->featured_image,
     3055                'setFeaturedImage'      => $post_type_object->labels->set_featured_image,
    30543056
    30553057                // Gallery
    30563058                'createGalleryTitle' => __( 'Create Gallery' ),
  • src/wp-includes/post.php

    diff --git src/wp-includes/post.php src/wp-includes/post.php
    index 564d4ee..871be75 100644
    function _post_type_meta_capabilities( $capabilities = null ) { 
    16151615 * - parent_item_colon - This string isn't used on non-hierarchical types. In hierarchical
    16161616 *                       ones the default is 'Parent Page:'.
    16171617 * - all_items - String for the submenu. Default is All Posts/All Pages.
     1618 * - featured_image - Default is Featured Image.
     1619 * - set_featured_image - Default is Set featured Image.
     1620 * - remove_featured_image - Default is Remove featured Image.
     1621 * - use_featured_image - Default is Use as featured Image.
    16181622 * - menu_name - Default is the same as `name`.
    16191623 *
    16201624 * Above, the first default value is for non-hierarchical post types (like posts)
    function get_post_type_labels( $post_type_object ) { 
    16391643                'not_found' => array( __('No posts found.'), __('No pages found.') ),
    16401644                'not_found_in_trash' => array( __('No posts found in Trash.'), __('No pages found in Trash.') ),
    16411645                'parent_item_colon' => array( null, __('Parent Page:') ),
    1642                 'all_items' => array( __( 'All Posts' ), __( 'All Pages' ) )
     1646                'all_items' => array( __( 'All Posts' ), __( 'All Pages' ) ),
     1647                'featured_image' => array( __( 'Featured Image' ), __( 'Featured Image' ) ),
     1648                'set_featured_image' => array( __( 'Set featured image' ), __( 'Set featured image' ) ),
     1649                'remove_featured_image' => array( __( 'Remove featured image' ), __( 'Remove featured image' ) ),
     1650                'use_featured_image' => array( __( 'Use as featured image' ), __( 'Use as featured image' ) ),
    16431651        );
    16441652        $nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name'];
    16451653
  • src/wp-includes/script-loader.php

    diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
    index 81c158a..57d2cf3 100644
    function wp_default_scripts( &$scripts ) { 
    570570                        'error' => __( 'Could not load the preview image. Please reload the page and try again.' )
    571571                ));
    572572
    573                 $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 );
    574                 did_action( 'init' ) && $scripts->localize( 'set-post-thumbnail', 'setPostThumbnailL10n', array(
    575                         'setThumbnail' => __( 'Use as featured image' ),
     573                $setPostThumbnailL10n = array(
     574                        'setThumbnail' => __( 'Use as featured image' ), // Back compat
    576575                        'saving' => __( 'Saving...' ),
    577576                        'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ),
    578577                        'done' => __( 'Done' )
    579                 ) );
     578                );
     579
     580                foreach ( get_post_types( null, 'objects' ) as $post_type_object ) {
     581                        if ( isset( $post_type_object->labels->use_featured_image ) ) {
     582                                $setPostThumbnailL10n["setThumbnail_{$post_type_object->name}"] = $post_type_object->labels->use_featured_image;
     583                        }
     584                }
     585                $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 );
     586                did_action( 'init' ) && $scripts->localize( 'set-post-thumbnail', 'setPostThumbnailL10n', $setPostThumbnailL10n );
     587
    580588
    581589                // Navigation Menus
    582590                $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox' ) );
  • tests/phpunit/tests/post/types.php

    diff --git tests/phpunit/tests/post/types.php tests/phpunit/tests/post/types.php
    index 31be335..d2f9cf8 100644
    class Tests_Post_Types extends WP_UnitTestCase { 
    101101                update_option( 'permalink_structure', $old_permastruct );
    102102                _unregister_post_type( 'foo' );
    103103        }
     104
     105        /**
     106         * @ticket 19257
     107         */
     108        function test_post_type_featured_image_labels() {
     109               
     110                register_post_type( 'foo' );
     111
     112                $post_type_object = get_post_type_object( 'foo' );
     113
     114                $this->assertEquals( 'Featured Image', $post_type_object->labels->featured_image );
     115                $this->assertEquals( 'Set featured image', $post_type_object->labels->set_featured_image );
     116                $this->assertEquals( 'Use as featured image', $post_type_object->labels->use_featured_image );
     117                $this->assertEquals( 'Remove featured image', $post_type_object->labels->remove_featured_image );
     118
     119                _unregister_post_type( 'foo' );
     120
     121                register_post_type( 'foo', array( 'labels' => array(
     122                        'featured_image' => 'Cover Image',
     123                        'set_featured_image' => 'Set cover image',
     124                        'remove_featured_image' => 'Remove cover image',
     125                        'use_featured_image' => 'Use as cover image'
     126                ) ) );
     127
     128                $post_type_object = get_post_type_object( 'foo' );
     129
     130                $this->assertEquals( 'Cover Image', $post_type_object->labels->featured_image );
     131                $this->assertEquals( 'Set cover image', $post_type_object->labels->set_featured_image );
     132                $this->assertEquals( 'Use as cover image', $post_type_object->labels->use_featured_image );
     133                $this->assertEquals( 'Remove cover image', $post_type_object->labels->remove_featured_image );
     134
     135        }
    104136}