Make WordPress Core

Changeset 31601


Ignore:
Timestamp:
03/02/2015 11:40:13 PM (12 years ago)
Author:
azaozz
Message:

Press This:

  • Remove classes from suggested HTML for the editor.
  • Improve the filter, pass an associative array as param.
  • Use <em> instead of <cite>.

Props Michael-Arestad, kraftbj. Fixes #31493.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

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

    r31597 r31601  
    3232         */
    3333        public function site_settings() {
    34                 $html = '<p class="press-this-suggested-source">' . _x( 'Source:', 'Used in Press This to indicate where the content comes from.' ) .
    35                         ' <cite><a href="%1$s">%2$s</a></cite></p>';
     34                $default_html = array(
     35                        'quote' => '<blockquote>%1$s</blockquote>',
     36                        'link' => '<p>' . _x( 'Source:', 'Used in Press This to indicate where the content comes from.' ) .
     37                                ' <em><a href="%1$s">%2$s</a></em></p>',
     38                );
    3639
    3740                return array(
    … …  
    5053
    5154                        /**
    52                          * Filter the HTML for the Press This source attribution.
     55                         * Filter the default HTML for the Press This editor.
    5356                         *
    5457                         * @since 4.2.0
    5558                         *
    56                          * @param string $html Default HTML, %1$s is link href, %2$s is link text.
     59                         * @param array $default_html Associative array with two keys: 'quote' where %1$s is replaced with the site description
     60                         *                            or the selected content, and 'link' there %1$s is link href, %2$s is link text.
    5761                         */
    58                         'suggestedHTML' => apply_filters( 'press_this_suggested_html', $html ),
     62                        'html' => apply_filters( 'press_this_suggested_html', $default_html ),
    5963                );
    6064        }
  • trunk/src/wp-admin/js/press-this.js

    r31596 r31601  
    201201                        }
    202202
    203                         if ( text ) {
    204                                 text = sanitizeText( text );
    205                                 // Wrap suggested content in blockquote tag.
    206                                 content = '<blockquote class="press-this-suggested-content">' + text + '</blockquote>';
     203                        if ( text && siteConfig.html.quote ) {
     204                                // Wrap suggested content in specified HTML.
     205                                content = siteConfig.html.quote.replace( /%1\$s/g, sanitizeText( text ) );
    207206                        }
    208207
    209208                        // Add a source attribution if there is one available.
    210                         if ( url && siteConfig.suggestedHTML && ( ( title && __( 'newPost' ) !== title ) || siteName ) ) {
    211                                 content += siteConfig.suggestedHTML.replace( /%1\$s/g, encodeURI( url ) ).replace( /%2\$s/g, ( title || siteName ) );
     209                        if ( url && siteConfig.html.link && ( ( title && __( 'newPost' ) !== title ) || siteName ) ) {
     210                                content += siteConfig.html.link.replace( /%1\$s/g, encodeURI( url ) ).replace( /%2\$s/g, ( title || siteName ) );
    212211                        }
    213212
Note: See TracChangeset for help on using the changeset viewer.