WordPress.org

Make WordPress Core

Ticket #26628: video-shortcode.diff

File video-shortcode.diff, 1.8 KB (added by wonderboymusic, 6 years ago)
  • src/wp-includes/formatting.php

     
    242242                $pee = preg_replace('|\s*<param([^>]*)>\s*|', "<param$1>", $pee); // no pee inside object/embed
    243243                $pee = preg_replace('|\s*</embed>\s*|', '</embed>', $pee);
    244244        }
     245        if ( preg_match( '|[\[<]video|', $pee ) ) {
     246                $pee = preg_replace( '#\s*<(track|source)([^>]*)>\s*#', '<$1$2>', $pee ); // no pee inside video tag/shortcode
     247        }
    245248        $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
    246249        // make paragraphs, including one at the end
    247250        $pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY);
     
    258261        $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
    259262        if ( $br ) {
    260263                $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee);
     264                $pee = preg_replace_callback('/[\[<]video.*?[\[<]\/video[\]>]/s', '_autop_newline_preservation_helper', $pee);
    261265                $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
    262266                $pee = str_replace('<WPPreserveNewline />', "\n", $pee);
    263267        }
  • src/wp-includes/media.php

     
    11441144                        $html .= sprintf( $source, $type['type'], esc_url( $$fallback ) );
    11451145                }
    11461146        }
     1147
     1148        if ( ! empty( $content ) ) {
     1149                if ( false !== strpos( $content, "\n" ) )
     1150                        $content = str_replace( array( "\r\n", "\n", "\t" ), '', $content );
     1151
     1152                $html .= trim( $content );
     1153        }
     1154
    11471155        if ( 'mediaelement' === $library )
    11481156                $html .= wp_mediaelement_fallback( $fileurl );
    11491157        $html .= '</video>';