Make WordPress Core


Ignore:
Timestamp:
03/11/2015 11:36:23 PM (12 years ago)
Author:
azaozz
Message:

PressThis: add inline comments and some cleanup for the images and embeds regex.
Props stephdau. Fixes #31373.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-press-this.php

    r31737 r31739  
    383383                        // See mathtag.com and https://www.quantcast.com/how-we-do-it/iab-standard-measurement/how-we-collect-data/
    384384                        return '';
    385                 } else if ( false !== strpos( $src, '/g.gif' ) ) {
     385                } else if ( preg_match( '/\/[gb]\.gif(\?.+)?$/', $src ) ) {
    386386                        // Classic WP stats gif
    387387                        return '';
    … …  
    394394                $src = $this->_limit_url( $src );
    395395
    396                 if ( preg_match( '/\/\/www\.youtube\.com\/(embed|v)\/([^\?]+)\?.+$/', $src, $src_matches ) ) {
    397                         $src = 'https://www.youtube.com/watch?v=' . $src_matches[2];
     396                if ( preg_match( '/\/\/(m|www)\.youtube\.com\/(embed|v)\/([^\?]+)\?.+$/', $src, $src_matches ) ) {
     397                        // Embedded Youtube videos (www or mobile)
     398                        $src = 'https://www.youtube.com/watch?v=' . $src_matches[3];
    398399                } else if ( preg_match( '/\/\/player\.vimeo\.com\/video\/([\d]+)([\?\/]{1}.*)?$/', $src, $src_matches ) ) {
     400                        // Embedded Vimeo iframe videos
    399401                        $src = 'https://vimeo.com/' . (int) $src_matches[1];
    400402                } else if ( preg_match( '/\/\/vimeo\.com\/moogaloop\.swf\?clip_id=([\d]+)$/', $src, $src_matches ) ) {
     403                        // Embedded Vimeo Flash videos
    401404                        $src = 'https://vimeo.com/' . (int) $src_matches[1];
    402405                } else if ( preg_match( '/\/\/vine\.co\/v\/([^\/]+)\/embed/', $src, $src_matches ) ) {
     406                        // Embedded Vine videos
    403407                        $src = 'https://vine.co/v/' . $src_matches[1];
    404408                } else if ( preg_match( '/\/\/(www\.)?dailymotion\.com\/embed\/video\/([^\/\?]+)([\/\?]{1}.+)?/', $src, $src_matches ) ) {
     409                        // Embedded Daily Motion videos
    405410                        $src = 'https://www.dailymotion.com/video/' . $src_matches[2];
    406                 } else if ( ! preg_match( '/\/\/(m\.|www\.)?youtube\.com\/watch\?/', $src )
    407                             && ! preg_match( '/\/youtu\.be\/.+$/', $src )
    408                             && ! preg_match( '/\/\/vimeo\.com\/[\d]+$/', $src )
    409                             && ! preg_match( '/\/\/(www\.)?dailymotion\.com\/video\/.+$/', $src )
    410                             && ! preg_match( '/\/\/soundcloud\.com\/.+$/', $src )
    411                             && ! preg_match( '/\/\/twitter\.com\/[^\/]+\/status\/[\d]+$/', $src )
    412                             && ! preg_match( '/\/\/vine\.co\/v\/[^\/]+/', $src ) ) {
     411                } else if ( ! preg_match( '/\/\/(m|www)\.youtube\.com\/watch\?/', $src )          // Youtube video page (www or mobile)
     412                            && ! preg_match( '/\/youtu\.be\/.+$/', $src )                         // Youtu.be video page
     413                            && ! preg_match( '/\/\/vimeo\.com\/[\d]+$/', $src )                   // Vimeo video page
     414                            && ! preg_match( '/\/\/(www\.)?dailymotion\.com\/video\/.+$/', $src ) // Daily Motion video page
     415                            && ! preg_match( '/\/\/soundcloud\.com\/.+$/', $src )                 // SoundCloud audio page
     416                            && ! preg_match( '/\/\/twitter\.com\/[^\/]+\/status\/[\d]+$/', $src ) // Twitter status page
     417                            && ! preg_match( '/\/\/vine\.co\/v\/[^\/]+/', $src ) ) {              // Vine video page
    413418                        $src = '';
    414419                }
Note: See TracChangeset for help on using the changeset viewer.