Introduce featured_image, set_featured_image, remove_featured_image, and use_featured_image post type labels when registering a post type in order to override the 'Featured Image' text and its related phrases.
Props johnbillion, mordauk, valendesigns. Fixes #19257. Built from https://develop.svn.wordpress.org/trunk@32673 git-svn-id: http://core.svn.wordpress.org/trunk@32643 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -213,7 +213,7 @@ if ( post_type_supports($post_type, 'page-attributes') )
|
||||
add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', null, 'side', 'core');
|
||||
|
||||
if ( $thumbnail_support && current_user_can( 'upload_files' ) )
|
||||
add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', null, 'side', 'low');
|
||||
add_meta_box('postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low');
|
||||
|
||||
if ( post_type_supports($post_type, 'excerpt') )
|
||||
add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', null, 'normal', 'core');
|
||||
@@ -371,7 +371,8 @@ if ( 'post' == $post_type ) {
|
||||
}
|
||||
|
||||
if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
|
||||
$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>';
|
||||
/* translators: %s: Featured Image */
|
||||
$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 image as a post thumbnail on the home page, a custom header, etc.' ), esc_html( $post_type_object->labels->featured_image ) ) . '</li>';
|
||||
}
|
||||
|
||||
$publish_box .= '</ul>';
|
||||
|
||||
@@ -1493,8 +1493,12 @@ function get_media_item( $attachment_id, $args = null ) {
|
||||
}
|
||||
if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) )
|
||||
&& post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) {
|
||||
|
||||
$calling_post = get_post( $calling_post_id );
|
||||
$calling_post_type_object = get_post_type_object( $calling_post->post_type );
|
||||
|
||||
$ajax_nonce = wp_create_nonce( "set_post_thumbnail-$calling_post_id" );
|
||||
$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>";
|
||||
$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>";
|
||||
}
|
||||
|
||||
if ( ( $r['send'] || $thumbnail || $delete ) && !isset( $form_fields['buttons'] ) ) {
|
||||
@@ -1736,8 +1740,16 @@ function get_compat_media_markup( $attachment_id, $args = null ) {
|
||||
* @since 2.5.0
|
||||
*/
|
||||
function media_upload_header() {
|
||||
|
||||
$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0;
|
||||
echo '<script type="text/javascript">post_id = ' . $post_id . ";</script>\n";
|
||||
|
||||
if ( ! empty( $post_id ) ) {
|
||||
$post_type = get_post_type( $post_id );
|
||||
} else {
|
||||
$post_type = '';
|
||||
}
|
||||
|
||||
echo '<script type="text/javascript">post_id = ' . $post_id . ';post_type = ' . $post_type . ';</script>';
|
||||
if ( empty( $_GET['chromeless'] ) ) {
|
||||
echo '<div id="media-upload-header">';
|
||||
the_media_upload_tabs();
|
||||
|
||||
@@ -1362,11 +1362,16 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
|
||||
function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
|
||||
global $content_width, $_wp_additional_image_sizes;
|
||||
|
||||
$post = get_post( $post );
|
||||
$post = get_post( $post );
|
||||
$post_type_object = get_post_type_object( $post->post_type );
|
||||
$set_thumbnail_link = '<p class="hide-if-no-js"><a title="%s" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>';
|
||||
$upload_iframe_src = get_upload_iframe_src( 'image', $post->ID );
|
||||
|
||||
$upload_iframe_src = esc_url( get_upload_iframe_src('image', $post->ID ) );
|
||||
$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>';
|
||||
$content = sprintf( $set_thumbnail_link, $upload_iframe_src, esc_html__( 'Set featured image' ) );
|
||||
$content = sprintf( $set_thumbnail_link,
|
||||
esc_attr( $post_type_object->labels->set_featured_image ),
|
||||
esc_url( $upload_iframe_src ),
|
||||
esc_html( $post_type_object->labels->set_featured_image )
|
||||
);
|
||||
|
||||
if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
|
||||
$old_content_width = $content_width;
|
||||
@@ -1377,8 +1382,12 @@ function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
|
||||
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
|
||||
if ( !empty( $thumbnail_html ) ) {
|
||||
$ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );
|
||||
$content = sprintf( $set_thumbnail_link, $upload_iframe_src, $thumbnail_html );
|
||||
$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>';
|
||||
$content = sprintf( $set_thumbnail_link,
|
||||
esc_attr( $post_type_object->labels->set_featured_image ),
|
||||
esc_url( $upload_iframe_src ),
|
||||
$thumbnail_html
|
||||
);
|
||||
$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>';
|
||||
}
|
||||
$content_width = $old_content_width;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ function WPSetAsThumbnail( id, nonce ) {
|
||||
action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie )
|
||||
}, function(str){
|
||||
var win = window.dialogArguments || opener || parent || top;
|
||||
$link.text( setPostThumbnailL10n.setThumbnail );
|
||||
setThumbnail = 'setThumbnail_' + post_type;
|
||||
$link.text( setPostThumbnailL10n[ setThumbnail ] );
|
||||
if ( str == '0' ) {
|
||||
alert( setPostThumbnailL10n.error );
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
function WPSetAsThumbnail(a,b){var c=jQuery("a#wp-post-thumbnail-"+a);c.text(setPostThumbnailL10n.saving),jQuery.post(ajaxurl,{action:"set-post-thumbnail",post_id:post_id,thumbnail_id:a,_ajax_nonce:b,cookie:encodeURIComponent(document.cookie)},function(b){var d=window.dialogArguments||opener||parent||top;c.text(setPostThumbnailL10n.setThumbnail),"0"==b?alert(setPostThumbnailL10n.error):(jQuery("a.wp-post-thumbnail").show(),c.text(setPostThumbnailL10n.done),c.fadeOut(2e3),d.WPSetThumbnailID(a),d.WPSetThumbnailHTML(b))})}
|
||||
function WPSetAsThumbnail(a,b){var c=jQuery("a#wp-post-thumbnail-"+a);c.text(setPostThumbnailL10n.saving),jQuery.post(ajaxurl,{action:"set-post-thumbnail",post_id:post_id,thumbnail_id:a,_ajax_nonce:b,cookie:encodeURIComponent(document.cookie)},function(b){var d=window.dialogArguments||opener||parent||top;setThumbnail="setThumbnail_"+post_type,c.text(setPostThumbnailL10n[setThumbnail]),"0"==b?alert(setPostThumbnailL10n.error):(jQuery("a.wp-post-thumbnail").show(),c.text(setPostThumbnailL10n.done),c.fadeOut(2e3),d.WPSetThumbnailID(a),d.WPSetThumbnailHTML(b))})}
|
||||
Reference in New Issue
Block a user