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:
parent
42d51a4f89
commit
02192cb53f
|
@ -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 @@
|
|||
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))})}
|
|
@ -2313,6 +2313,7 @@ function wp_maybe_load_embeds() {
|
|||
}
|
||||
|
||||
wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube\.com/embed/([^/]+)#i', 'wp_embed_handler_youtube' );
|
||||
wp_embed_register_handler( 'youtube_v_url', '#https?://(www.)?youtube\.com/v/([^/]+)#i', 'wp_embed_handler_youtube' );
|
||||
|
||||
wp_embed_register_handler( 'googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo' );
|
||||
|
||||
|
@ -3008,6 +3009,8 @@ function wp_enqueue_media( $args = array() ) {
|
|||
|
||||
$hier = $post && is_post_type_hierarchical( $post->post_type );
|
||||
|
||||
$post_type_object = get_post_type_object( $post->post_type );
|
||||
|
||||
$strings = array(
|
||||
// Generic
|
||||
'url' => __( 'URL' ),
|
||||
|
@ -3066,8 +3069,8 @@ function wp_enqueue_media( $args = array() ) {
|
|||
'insertFromUrlTitle' => __( 'Insert from URL' ),
|
||||
|
||||
// Featured Images
|
||||
'setFeaturedImageTitle' => __( 'Set Featured Image' ),
|
||||
'setFeaturedImage' => __( 'Set featured image' ),
|
||||
'setFeaturedImageTitle' => $post_type_object->labels->featured_image,
|
||||
'setFeaturedImage' => $post_type_object->labels->set_featured_image,
|
||||
|
||||
// Gallery
|
||||
'createGalleryTitle' => __( 'Create Gallery' ),
|
||||
|
|
|
@ -1624,12 +1624,17 @@ function _post_type_meta_capabilities( $capabilities = null ) {
|
|||
* - parent_item_colon - This string isn't used on non-hierarchical types. In hierarchical
|
||||
* ones the default is 'Parent Page:'.
|
||||
* - all_items - String for the submenu. Default is All Posts/All Pages.
|
||||
* - featured_image - Default is Featured Image.
|
||||
* - set_featured_image - Default is Set featured image.
|
||||
* - remove_featured_image - Default is Remove featured image.
|
||||
* - use_featured_image - Default is Use as featured image.
|
||||
* - menu_name - Default is the same as `name`.
|
||||
*
|
||||
* Above, the first default value is for non-hierarchical post types (like posts)
|
||||
* and the second one is for hierarchical post types (like pages).
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @since 4.3.0 Added the `featured_image`, `set_featured_image`, `remove_featured_image`, and `use_featured_image` labels.
|
||||
* @access private
|
||||
*
|
||||
* @param object $post_type_object Post type object.
|
||||
|
@ -1648,7 +1653,11 @@ function get_post_type_labels( $post_type_object ) {
|
|||
'not_found' => array( __('No posts found.'), __('No pages found.') ),
|
||||
'not_found_in_trash' => array( __('No posts found in Trash.'), __('No pages found in Trash.') ),
|
||||
'parent_item_colon' => array( null, __('Parent Page:') ),
|
||||
'all_items' => array( __( 'All Posts' ), __( 'All Pages' ) )
|
||||
'all_items' => array( __( 'All Posts' ), __( 'All Pages' ) ),
|
||||
'featured_image' => array( __( 'Featured Image' ), __( 'Featured Image' ) ),
|
||||
'set_featured_image' => array( __( 'Set featured image' ), __( 'Set featured image' ) ),
|
||||
'remove_featured_image' => array( __( 'Remove featured image' ), __( 'Remove featured image' ) ),
|
||||
'use_featured_image' => array( __( 'Use as featured image' ), __( 'Use as featured image' ) ),
|
||||
);
|
||||
$nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name'];
|
||||
|
||||
|
|
|
@ -570,13 +570,20 @@ function wp_default_scripts( &$scripts ) {
|
|||
'error' => __( 'Could not load the preview image. Please reload the page and try again.' )
|
||||
));
|
||||
|
||||
$scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 );
|
||||
did_action( 'init' ) && $scripts->localize( 'set-post-thumbnail', 'setPostThumbnailL10n', array(
|
||||
'setThumbnail' => __( 'Use as featured image' ),
|
||||
$setPostThumbnailL10n = array(
|
||||
'setThumbnail' => __( 'Use as featured image' ), // Back compat
|
||||
'saving' => __( 'Saving...' ),
|
||||
'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ),
|
||||
'done' => __( 'Done' )
|
||||
) );
|
||||
);
|
||||
|
||||
foreach ( get_post_types( null, 'objects' ) as $post_type_object ) {
|
||||
if ( isset( $post_type_object->labels->use_featured_image ) ) {
|
||||
$setPostThumbnailL10n[ "setThumbnail_{$post_type_object->name}" ] = $post_type_object->labels->use_featured_image;
|
||||
}
|
||||
}
|
||||
$scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 );
|
||||
did_action( 'init' ) && $scripts->localize( 'set-post-thumbnail', 'setPostThumbnailL10n', $setPostThumbnailL10n );
|
||||
|
||||
// Navigation Menus
|
||||
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox' ) );
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.3-alpha-32672';
|
||||
$wp_version = '4.3-alpha-32673';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue