Ticket #19257: 19257.diff
File 19257.diff, 12.0 KB (added by , 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') ) 208 208 add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', null, 'side', 'core'); 209 209 210 210 if ( $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'); 212 212 213 213 if ( post_type_supports($post_type, 'excerpt') ) 214 214 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', null, 'normal', 'core'); … … if ( 'post' == $post_type ) { 366 366 } 367 367 368 368 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>'; 370 370 } 371 371 372 372 $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 ) { 1486 1486 } 1487 1487 if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) 1488 1488 && 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 1489 1493 $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>"; 1491 1495 } 1492 1496 1493 1497 if ( ( $r['send'] || $thumbnail || $delete ) && !isset( $form_fields['buttons'] ) ) { … … function get_compat_media_markup( $attachment_id, $args = null ) { 1722 1726 * @since 2.5.0 1723 1727 */ 1724 1728 function media_upload_header() { 1729 1725 1730 $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>'; 1727 1739 if ( empty( $_GET['chromeless'] ) ) { 1728 1740 echo '<div id="media-upload-header">'; 1729 1741 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 ) { 1345 1345 function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { 1346 1346 global $content_width, $_wp_additional_image_sizes; 1347 1347 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>'; 1350 1351 $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 ) ); 1353 1354 1354 1355 if ( $thumbnail_id && get_post( $thumbnail_id ) ) { 1355 1356 $old_content_width = $content_width; … … function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { 1361 1362 if ( !empty( $thumbnail_html ) ) { 1362 1363 $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID ); 1363 1364 $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>'; 1365 1366 } 1366 1367 $content_width = $old_content_width; 1367 1368 } -
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 ) { 9 9 action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie ) 10 10 }, function(str){ 11 11 var win = window.dialogArguments || opener || parent || top; 12 $link.text( setPostThumbnailL10n.setThumbnail ); 12 setThumbnail = 'setThumbnail_' + post_type; 13 $link.text( setPostThumbnailL10n[setThumbnail] ); 13 14 if ( str == '0' ) { 14 15 alert( setPostThumbnailL10n.error ); 15 16 } 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() ) { 2991 2991 2992 2992 $hier = $post && is_post_type_hierarchical( $post->post_type ); 2993 2993 2994 $post_type_object = get_post_type_object( $post->post_type ); 2995 2994 2996 $strings = array( 2995 2997 // Generic 2996 2998 'url' => __( 'URL' ), … … function wp_enqueue_media( $args = array() ) { 3049 3051 'insertFromUrlTitle' => __( 'Insert from URL' ), 3050 3052 3051 3053 // 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, 3054 3056 3055 3057 // Gallery 3056 3058 '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 ) { 1615 1615 * - parent_item_colon - This string isn't used on non-hierarchical types. In hierarchical 1616 1616 * ones the default is 'Parent Page:'. 1617 1617 * - 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. 1618 1622 * - menu_name - Default is the same as `name`. 1619 1623 * 1620 1624 * Above, the first default value is for non-hierarchical post types (like posts) … … function get_post_type_labels( $post_type_object ) { 1639 1643 'not_found' => array( __('No posts found.'), __('No pages found.') ), 1640 1644 'not_found_in_trash' => array( __('No posts found in Trash.'), __('No pages found in Trash.') ), 1641 1645 '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' ) ), 1643 1651 ); 1644 1652 $nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name']; 1645 1653 -
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 ) { 570 570 'error' => __( 'Could not load the preview image. Please reload the page and try again.' ) 571 571 )); 572 572 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 576 575 'saving' => __( 'Saving...' ), 577 576 'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ), 578 577 '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 580 588 581 589 // Navigation Menus 582 590 $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 { 101 101 update_option( 'permalink_structure', $old_permastruct ); 102 102 _unregister_post_type( 'foo' ); 103 103 } 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 } 104 136 }