Make WordPress Core

Ticket #21719: remove-auto-embeds.diff

File remove-auto-embeds.diff, 8.9 KB (added by wonderboymusic, 12 years ago)
  • wp-includes/default-filters.php

     
    285285// If the upgrade hasn't run yet, assume link manager is used.
    286286add_filter( 'default_option_link_manager_enabled', '__return_true' );
    287287
     288// Automatically embed URLs
     289add_filter( 'default_option_autoembed_urls', '__return_true' );
     290add_filter( 'default_option_embed_size_w', 500 );
     291add_filter( 'default_option_embed_size_h', 700 );
     292
    288293unset($filter, $action);
  • wp-includes/media.php

     
    10541054         */
    10551055        function __construct() {
    10561056                // Hack to get the [embed] shortcode to run before wpautop()
    1057                 add_filter( 'the_content', array(&$this, 'run_shortcode'), 8 );
     1057                add_filter( 'the_content', array( $this, 'run_shortcode'), 8 );
    10581058
    10591059                // Shortcode placeholder for strip_shortcodes()
    10601060                add_shortcode( 'embed', '__return_false' );
    10611061
    10621062                // Attempts to embed all URLs in a post
    1063                 if ( get_option('embed_autourls') )
    1064                         add_filter( 'the_content', array(&$this, 'autoembed'), 8 );
     1063                add_filter( 'the_content', array( $this, 'autoembed'), 8 );
    10651064
    10661065                // After a post is saved, invalidate the oEmbed cache
    1067                 add_action( 'save_post', array(&$this, 'delete_oembed_caches') );
     1066                add_action( 'save_post', array( $this, 'delete_oembed_caches') );
    10681067
    10691068                // After a post is saved, cache oEmbed items via AJAX
    1070                 add_action( 'edit_form_advanced', array(&$this, 'maybe_run_ajax_cache') );
     1069                add_action( 'edit_form_advanced', array( $this, 'maybe_run_ajax_cache') );
    10711070        }
    10721071
    10731072        /**
     
    10921091                $orig_shortcode_tags = $shortcode_tags;
    10931092                remove_all_shortcodes();
    10941093
    1095                 add_shortcode( 'embed', array(&$this, 'shortcode') );
     1094                add_shortcode( 'embed', array( $this, 'shortcode') );
    10961095
    10971096                // Do the shortcode (only the [embed] one is registered)
    10981097                $content = do_shortcode( $content );
     
    12661265                        $this->usecache = false;
    12671266
    12681267                        $content = $this->run_shortcode( $post->post_content );
    1269                         if ( get_option('embed_autourls') )
    1270                                 $this->autoembed( $content );
     1268                        $this->autoembed( $content );
    12711269
    12721270                        $this->usecache = true;
    12731271                }
     
    12821280         * @return string Potentially modified $content.
    12831281         */
    12841282        function autoembed( $content ) {
    1285                 return preg_replace_callback( '|^\s*(https?://[^\s"]+)\s*$|im', array(&$this, 'autoembed_callback'), $content );
     1283                return preg_replace_callback( '|^\s*(https?://[^\s"]+)\s*$|im', array( $this, 'autoembed_callback'), $content );
    12861284        }
    12871285
    12881286        /**
     
    13451343 * @return array Default embed parameters.
    13461344 */
    13471345function wp_embed_defaults() {
    1348         if ( !empty($GLOBALS['content_width']) )
     1346        if ( ! empty( $GLOBALS['content_width'] ) )
    13491347                $theme_width = (int) $GLOBALS['content_width'];
    13501348
    1351         $width = get_option('embed_size_w');
    1352 
    1353         if ( empty($width) && !empty($theme_width) )
     1349        if ( ! empty( $theme_width ) )
    13541350                $width = $theme_width;
    13551351
    1356         if ( empty($width) )
     1352        if ( empty( $width ) )
    13571353                $width = 500;
    13581354
    1359         $height = get_option('embed_size_h');
     1355        $height = min( ceil( $width * 2.5 ), 1000 );
    13601356
    1361         if ( empty($height) )
    1362                 $height = 700;
    1363 
    13641357        return apply_filters( 'embed_defaults', array(
    13651358                'width'  => $width,
    13661359                'height' => $height,
  • wp-includes/formatting.php

     
    27372737                case 'medium_size_h':
    27382738                case 'large_size_w':
    27392739                case 'large_size_h':
    2740                 case 'embed_size_h':
    27412740                case 'default_post_edit_rows':
    27422741                case 'mailserver_port':
    27432742                case 'comment_max_links':
     
    27552754                        $value = absint( $value );
    27562755                        break;
    27572756
    2758                 case 'embed_size_w':
    2759                         if ( '' !== $value )
    2760                                 $value = absint( $value );
    2761                         break;
    2762 
    27632757                case 'posts_per_page':
    27642758                case 'posts_per_rss':
    27652759                        $value = (int) $value;
  • wp-admin/includes/schema.php

     
    468468        // 2.8
    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,
    478473        'page_on_front' => 0,
  • wp-admin/options-media.php

     
    1515$title = __('Media Settings');
    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.');
     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>';
    2019
    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>';
    25 
    2620if ( ! is_multisite() ) {
    2721        $media_options_help .= '<p>' . __('Uploading Files allows you to choose the folder and path for storing your uploaded files.') . '</p>';
    2822}
     
    9185<?php do_settings_fields('media', 'default'); ?>
    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() ) : ?>
    12296<h3><?php _e('Uploading Files'); ?></h3>
  • wp-admin/options.php

     
    6161$whitelist_options = array(
    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        'privacy' => array( 'blog_public' ),
    6666        'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'show_on_front', 'page_on_front', 'page_for_posts' ),
    6767        'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format' ),