Make WordPress Core

Changeset 21998


Ignore:
Timestamp:
09/25/2012 07:10:09 AM (14 years ago)
Author:
nacin
Message:

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.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/schema.php

    r21827 r21998  
    469469        'timezone_string' => $timezone_string,
    470470
    471         // 2.9
    472         'embed_autourls' => 1,
    473         'embed_size_w' => '',
    474         'embed_size_h' => 600,
    475 
    476471        // 3.0
    477472        'page_for_posts' => 0,
     
    543538                'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page',
    544539                'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app',
     540                'autoembed_urls',
    545541        );
    546542        foreach ( $unusedoptions as $option )
  • trunk/wp-admin/options-media.php

    r21852 r21998  
    1616$parent_file = 'options-general.php';
    1717
    18 $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>' .
    19         '<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.');
    20 
    21 if ( ! empty( $content_width ) )
    22         $media_options_help .= ' ' . __( 'If you do not set the maximum embed size, it will be automatically sized to fit into your content area.' );
    23 
    24 $media_options_help .= '</p>';
     18$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>';
    2519
    2620if ( ! is_multisite() ) {
     
    9286</table>
    9387
     88<?php if ( isset( $GLOBALS['wp_settings']['media']['embeds'] ) ) : ?>
    9489<h3><?php _e('Embeds') ?></h3>
    95 
    9690<table class="form-table">
    97 
    98 <tr valign="top">
    99 <th scope="row"><?php _e('Auto-embeds'); ?></th>
    100 <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>
    101 <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>
    102 </fieldset></td>
    103 </tr>
    104 
    105 <tr valign="top">
    106 <th scope="row"><?php _e('Maximum embed size') ?></th>
    107 <td>
    108 <label for="embed_size_w"><?php _e('Width'); ?></label>
    109 <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" />
    110 <label for="embed_size_h"><?php _e('Height'); ?></label>
    111 <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" />
    112 <?php if ( ! empty( $content_width ) )
    113         echo '<p class="description">' . __( 'If the width value is left blank, embeds will default to the max width of your theme.' ) . '</p>';
    114 ?>
    115 </td>
    116 </tr>
    117 
    118 <?php do_settings_fields('media', 'embeds'); ?>
     91<?php do_settings_fields( 'media', 'embeds' ); ?>
    11992</table>
     93<?php endif; ?>
    12094
    12195<?php if ( !is_multisite() ) : ?>
  • trunk/wp-admin/options.php

    r21852 r21998  
    6262        'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ),
    6363        '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' ),
    64         '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' ),
     64        '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' ),
    6565        'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ),
    6666        'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format' )
  • trunk/wp-includes/default-filters.php

    r21943 r21998  
    285285add_filter( 'default_option_link_manager_enabled', '__return_true' );
    286286
     287// Automatically embed URLs
     288add_filter( 'default_option_autoembed_urls', '__return_true' );
     289
    287290unset($filter, $action);
  • trunk/wp-includes/formatting.php

    r21996 r21998  
    27652765                case 'large_size_w':
    27662766                case 'large_size_h':
    2767                 case 'embed_size_h':
    27682767                case 'default_post_edit_rows':
    27692768                case 'mailserver_port':
     
    27832782                        break;
    27842783
    2785                 case 'embed_size_w':
    2786                         if ( '' !== $value )
    2787                                 $value = absint( $value );
    2788                         break;
    2789 
    27902784                case 'posts_per_page':
    27912785                case 'posts_per_rss':
  • trunk/wp-includes/media.php

    r21948 r21998  
    10821082        function __construct() {
    10831083                // Hack to get the [embed] shortcode to run before wpautop()
    1084                 add_filter( 'the_content', array(&$this, 'run_shortcode'), 8 );
     1084                add_filter( 'the_content', array( $this, 'run_shortcode' ), 8 );
    10851085
    10861086                // Shortcode placeholder for strip_shortcodes()
     
    10881088
    10891089                // Attempts to embed all URLs in a post
    1090                 if ( get_option('embed_autourls') )
    1091                         add_filter( 'the_content', array(&$this, 'autoembed'), 8 );
     1090                add_filter( 'the_content', array( $this, 'autoembed' ), 8 );
    10921091
    10931092                // After a post is saved, invalidate the oEmbed cache
    1094                 add_action( 'save_post', array(&$this, 'delete_oembed_caches') );
     1093                add_action( 'save_post', array( $this, 'delete_oembed_caches' ) );
    10951094
    10961095                // After a post is saved, cache oEmbed items via AJAX
    1097                 add_action( 'edit_form_advanced', array(&$this, 'maybe_run_ajax_cache') );
     1096                add_action( 'edit_form_advanced', array( $this, 'maybe_run_ajax_cache' ) );
    10981097        }
    10991098
     
    11201119                remove_all_shortcodes();
    11211120
    1122                 add_shortcode( 'embed', array(&$this, 'shortcode') );
     1121                add_shortcode( 'embed', array( $this, 'shortcode' ) );
    11231122
    11241123                // Do the shortcode (only the [embed] one is registered)
     
    12941293
    12951294                        $content = $this->run_shortcode( $post->post_content );
    1296                         if ( get_option('embed_autourls') )
    1297                                 $this->autoembed( $content );
     1295                        $this->autoembed( $content );
    12981296
    12991297                        $this->usecache = true;
     
    13101308         */
    13111309        function autoembed( $content ) {
    1312                 return preg_replace_callback( '|^\s*(https?://[^\s"]+)\s*$|im', array(&$this, 'autoembed_callback'), $content );
     1310                return preg_replace_callback( '|^\s*(https?://[^\s"]+)\s*$|im', array( $this, 'autoembed_callback' ), $content );
    13131311        }
    13141312
     
    13681366 * Create default array of embed parameters.
    13691367 *
     1368 * The width defaults to the content width as specified by the theme. If the
     1369 * theme does not specify a content width, then 500px is used.
     1370 *
     1371 * The default height is 1.5 times the width, or 1000px, whichever is smaller.
     1372 *
     1373 * The 'embed_defaults' filter can be used to adjust either of these values.
     1374 *
    13701375 * @since 2.9.0
    13711376 *
     
    13731378 */
    13741379function wp_embed_defaults() {
    1375         if ( !empty($GLOBALS['content_width']) )
    1376                 $theme_width = (int) $GLOBALS['content_width'];
    1377 
    1378         $width = get_option('embed_size_w');
    1379 
    1380         if ( empty($width) && !empty($theme_width) )
    1381                 $width = $theme_width;
    1382 
    1383         if ( empty($width) )
     1380        if ( ! empty( $GLOBALS['content_width'] ) )
     1381                $width = (int) $GLOBALS['content_width'];
     1382
     1383        if ( empty( $width ) )
    13841384                $width = 500;
    13851385
    1386         $height = get_option('embed_size_h');
    1387 
    1388         if ( empty($height) )
    1389                 $height = 700;
    1390 
    1391         return apply_filters( 'embed_defaults', array(
    1392                 'width'  => $width,
    1393                 'height' => $height,
    1394         ) );
     1386        $height = min( ceil( $width * 1.5 ), 1000 );
     1387
     1388        return apply_filters( 'embed_defaults', compact( 'width', 'height' ) );
    13951389}
    13961390
  • trunk/wp-includes/version.php

    r21989 r21998  
    1212 * @global int $wp_db_version
    1313 */
    14 $wp_db_version = 21823;
     14$wp_db_version = 21998;
    1515
    1616/**
Note: See TracChangeset for help on using the changeset viewer.