From 84ca01187661ecef038184122a598310ffe77c8e Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 25 Sep 2012 07:10:09 +0000 Subject: [PATCH] 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: https://develop.svn.wordpress.org/trunk@21998 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/schema.php | 6 +---- wp-admin/options-media.php | 34 +++---------------------- wp-admin/options.php | 2 +- wp-includes/default-filters.php | 3 +++ wp-includes/formatting.php | 6 ----- wp-includes/media.php | 44 ++++++++++++++------------------- wp-includes/version.php | 2 +- 7 files changed, 29 insertions(+), 68 deletions(-) diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 676fd1951d..d3468f580b 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -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); diff --git a/wp-admin/options-media.php b/wp-admin/options-media.php index 3631971dfa..f307edd987 100644 --- a/wp-admin/options-media.php +++ b/wp-admin/options-media.php @@ -15,13 +15,7 @@ if ( ! current_user_can( 'manage_options' ) ) $title = __('Media Settings'); $parent_file = 'options-general.php'; -$media_options_help = '

' . __('You can set maximum sizes for images inserted into your written content; you can also insert an image as Full Size.') . '

' . - '

' . __('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 .= '

'; +$media_options_help = '

' . __('You can set maximum sizes for images inserted into your written content; you can also insert an image as Full Size.') . '

'; if ( ! is_multisite() ) { $media_options_help .= '

' . __('Uploading Files allows you to choose the folder and path for storing your uploaded files.') . '

'; @@ -91,32 +85,12 @@ include('./admin-header.php'); +

- - - - - - - - - - - - - +
- -
- - - - -' . __( 'If the width value is left blank, embeds will default to the max width of your theme.' ) . '

'; -?> -
+

diff --git a/wp-admin/options.php b/wp-admin/options.php index 20ebdcd7db..53f7e106c5 100644 --- a/wp-admin/options.php +++ b/wp-admin/options.php @@ -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' ) ); diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index f83964947c..6b283a2b5c 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -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); diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index d04cb10b5e..a73a8ada49 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -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; diff --git a/wp-includes/media.php b/wp-includes/media.php index 04d1475733..e10d19d468 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -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' ) ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index a905ef6f87..ce51b3ebc7 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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