Always attempt to embed URLs in content, removing the Auto-embeds (autoembed_urls) option.

Remove the UI for setting the default width and height for embeds. Width was confusing as it
was blank by default (inheriting the content width from the theme, or 500px). The height is
now calculated as 1.5x the content width, or 1000px, whichever is smaller.

The [embed] shortcode can still receive manual height and width attributes. This just removes
the global settings.

props wonderboymusic. see #21719.



git-svn-id: http://core.svn.wordpress.org/trunk@21998 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2012-09-25 07:10:09 +00:00
parent 70ae01e133
commit a6c93e2f65
7 changed files with 29 additions and 68 deletions

View File

@ -468,11 +468,6 @@ function populate_options() {
// 2.8
'timezone_string' => $timezone_string,
// 2.9
'embed_autourls' => 1,
'embed_size_w' => '',
'embed_size_h' => 600,
// 3.0
'page_for_posts' => 0,
'page_on_front' => 0,
@ -542,6 +537,7 @@ function populate_options() {
'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron',
'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page',
'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app',
'autoembed_urls',
);
foreach ( $unusedoptions as $option )
delete_option($option);

View File

@ -15,13 +15,7 @@ if ( ! current_user_can( 'manage_options' ) )
$title = __('Media Settings');
$parent_file = 'options-general.php';
$media_options_help = '<p>' . __('You can set maximum sizes for images inserted into your written content; you can also insert an image as Full Size.') . '</p>' .
'<p>' . __('The Embed option allows you embed a video, image, or other media content into your content automatically by typing the URL (of the web page where the file lives) on its own line when you create your content.');
if ( ! empty( $content_width ) )
$media_options_help .= ' ' . __( 'If you do not set the maximum embed size, it will be automatically sized to fit into your content area.' );
$media_options_help .= '</p>';
$media_options_help = '<p>' . __('You can set maximum sizes for images inserted into your written content; you can also insert an image as Full Size.') . '</p>';
if ( ! is_multisite() ) {
$media_options_help .= '<p>' . __('Uploading Files allows you to choose the folder and path for storing your uploaded files.') . '</p>';
@ -91,32 +85,12 @@ include('./admin-header.php');
<?php do_settings_fields('media', 'default'); ?>
</table>
<?php if ( isset( $GLOBALS['wp_settings']['media']['embeds'] ) ) : ?>
<h3><?php _e('Embeds') ?></h3>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Auto-embeds'); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e('When possible, embed the media content from a URL directly onto the page. For example: links to Flickr and YouTube.'); ?></span></legend>
<label for="embed_autourls"><input name="embed_autourls" type="checkbox" id="embed_autourls" value="1" <?php checked( '1', get_option('embed_autourls') ); ?>/> <?php _e('When possible, embed the media content from a URL directly onto the page. For example: links to Flickr and YouTube.'); ?></label>
</fieldset></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Maximum embed size') ?></th>
<td>
<label for="embed_size_w"><?php _e('Width'); ?></label>
<input name="embed_size_w" type="number" step="1" min="0" id="embed_size_w" value="<?php form_option('embed_size_w'); ?>" class="small-text" />
<label for="embed_size_h"><?php _e('Height'); ?></label>
<input name="embed_size_h" type="number" step="1" min="0" id="embed_size_h" value="<?php form_option('embed_size_h'); ?>" class="small-text" />
<?php if ( ! empty( $content_width ) )
echo '<p class="description">' . __( 'If the width value is left blank, embeds will default to the max width of your theme.' ) . '</p>';
?>
</td>
</tr>
<?php do_settings_fields('media', 'embeds'); ?>
<?php do_settings_fields( 'media', 'embeds' ); ?>
</table>
<?php endif; ?>
<?php if ( !is_multisite() ) : ?>
<h3><?php _e('Uploading Files'); ?></h3>

View File

@ -61,7 +61,7 @@ if ( is_multisite() && !is_super_admin() && 'update' != $action )
$whitelist_options = array(
'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ),
'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),
'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'embed_autourls', 'embed_size_w', 'embed_size_h' ),
'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ),
'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ),
'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format' )
);

View File

@ -284,4 +284,7 @@ add_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
// If the upgrade hasn't run yet, assume link manager is used.
add_filter( 'default_option_link_manager_enabled', '__return_true' );
// Automatically embed URLs
add_filter( 'default_option_autoembed_urls', '__return_true' );
unset($filter, $action);

View File

@ -2764,7 +2764,6 @@ function sanitize_option($option, $value) {
case 'medium_size_h':
case 'large_size_w':
case 'large_size_h':
case 'embed_size_h':
case 'default_post_edit_rows':
case 'mailserver_port':
case 'comment_max_links':
@ -2782,11 +2781,6 @@ function sanitize_option($option, $value) {
$value = absint( $value );
break;
case 'embed_size_w':
if ( '' !== $value )
$value = absint( $value );
break;
case 'posts_per_page':
case 'posts_per_rss':
$value = (int) $value;

View File

@ -1081,20 +1081,19 @@ class WP_Embed {
*/
function __construct() {
// Hack to get the [embed] shortcode to run before wpautop()
add_filter( 'the_content', array(&$this, 'run_shortcode'), 8 );
add_filter( 'the_content', array( $this, 'run_shortcode' ), 8 );
// Shortcode placeholder for strip_shortcodes()
add_shortcode( 'embed', '__return_false' );
// Attempts to embed all URLs in a post
if ( get_option('embed_autourls') )
add_filter( 'the_content', array(&$this, 'autoembed'), 8 );
add_filter( 'the_content', array( $this, 'autoembed' ), 8 );
// After a post is saved, invalidate the oEmbed cache
add_action( 'save_post', array(&$this, 'delete_oembed_caches') );
add_action( 'save_post', array( $this, 'delete_oembed_caches' ) );
// After a post is saved, cache oEmbed items via AJAX
add_action( 'edit_form_advanced', array(&$this, 'maybe_run_ajax_cache') );
add_action( 'edit_form_advanced', array( $this, 'maybe_run_ajax_cache' ) );
}
/**
@ -1119,7 +1118,7 @@ class WP_Embed {
$orig_shortcode_tags = $shortcode_tags;
remove_all_shortcodes();
add_shortcode( 'embed', array(&$this, 'shortcode') );
add_shortcode( 'embed', array( $this, 'shortcode' ) );
// Do the shortcode (only the [embed] one is registered)
$content = do_shortcode( $content );
@ -1293,8 +1292,7 @@ class WP_Embed {
$this->usecache = false;
$content = $this->run_shortcode( $post->post_content );
if ( get_option('embed_autourls') )
$this->autoembed( $content );
$this->autoembed( $content );
$this->usecache = true;
}
@ -1309,7 +1307,7 @@ class WP_Embed {
* @return string Potentially modified $content.
*/
function autoembed( $content ) {
return preg_replace_callback( '|^\s*(https?://[^\s"]+)\s*$|im', array(&$this, 'autoembed_callback'), $content );
return preg_replace_callback( '|^\s*(https?://[^\s"]+)\s*$|im', array( $this, 'autoembed_callback' ), $content );
}
/**
@ -1367,31 +1365,27 @@ function wp_embed_unregister_handler( $id, $priority = 10 ) {
/**
* Create default array of embed parameters.
*
* The width defaults to the content width as specified by the theme. If the
* theme does not specify a content width, then 500px is used.
*
* The default height is 1.5 times the width, or 1000px, whichever is smaller.
*
* The 'embed_defaults' filter can be used to adjust either of these values.
*
* @since 2.9.0
*
* @return array Default embed parameters.
*/
function wp_embed_defaults() {
if ( !empty($GLOBALS['content_width']) )
$theme_width = (int) $GLOBALS['content_width'];
if ( ! empty( $GLOBALS['content_width'] ) )
$width = (int) $GLOBALS['content_width'];
$width = get_option('embed_size_w');
if ( empty($width) && !empty($theme_width) )
$width = $theme_width;
if ( empty($width) )
if ( empty( $width ) )
$width = 500;
$height = get_option('embed_size_h');
$height = min( ceil( $width * 1.5 ), 1000 );
if ( empty($height) )
$height = 700;
return apply_filters( 'embed_defaults', array(
'width' => $width,
'height' => $height,
) );
return apply_filters( 'embed_defaults', compact( 'width', 'height' ) );
}
/**

View File

@ -11,7 +11,7 @@ $wp_version = '3.5-alpha-21989';
*
* @global int $wp_db_version
*/
$wp_db_version = 21823;
$wp_db_version = 21998;
/**
* Holds the TinyMCE version