diff --git a/src/wp-admin/includes/class-wp-press-this.php b/src/wp-admin/includes/class-wp-press-this.php index 4f4bb4efd7..e85c13aa81 100644 --- a/src/wp-admin/includes/class-wp-press-this.php +++ b/src/wp-admin/includes/class-wp-press-this.php @@ -31,8 +31,11 @@ class WP_Press_This { * @return array Site settings. */ public function site_settings() { - $html = '

' . _x( 'Source:', 'Used in Press This to indicate where the content comes from.' ) . - ' %2$s

'; + $default_html = array( + 'quote' => '
%1$s
', + 'link' => '

' . _x( 'Source:', 'Used in Press This to indicate where the content comes from.' ) . + ' %2$s

', + ); return array( // Used to trigger the bookmarklet update notice. @@ -49,13 +52,14 @@ class WP_Press_This { 'redirInParent' => apply_filters( 'press_this_redirect_in_parent', false ), /** - * Filter the HTML for the Press This source attribution. + * Filter the default HTML for the Press This editor. * * @since 4.2.0 * - * @param string $html Default HTML, %1$s is link href, %2$s is link text. + * @param array $default_html Associative array with two keys: 'quote' where %1$s is replaced with the site description + * or the selected content, and 'link' there %1$s is link href, %2$s is link text. */ - 'suggestedHTML' => apply_filters( 'press_this_suggested_html', $html ), + 'html' => apply_filters( 'press_this_suggested_html', $default_html ), ); } diff --git a/src/wp-admin/js/press-this.js b/src/wp-admin/js/press-this.js index e2d63ea37d..e948056794 100644 --- a/src/wp-admin/js/press-this.js +++ b/src/wp-admin/js/press-this.js @@ -200,15 +200,14 @@ } } - if ( text ) { - text = sanitizeText( text ); - // Wrap suggested content in blockquote tag. - content = '
' + text + '
'; + if ( text && siteConfig.html.quote ) { + // Wrap suggested content in specified HTML. + content = siteConfig.html.quote.replace( /%1\$s/g, sanitizeText( text ) ); } // Add a source attribution if there is one available. - if ( url && siteConfig.suggestedHTML && ( ( title && __( 'newPost' ) !== title ) || siteName ) ) { - content += siteConfig.suggestedHTML.replace( /%1\$s/g, encodeURI( url ) ).replace( /%2\$s/g, ( title || siteName ) ); + if ( url && siteConfig.html.link && ( ( title && __( 'newPost' ) !== title ) || siteName ) ) { + content += siteConfig.html.link.replace( /%1\$s/g, encodeURI( url ) ).replace( /%2\$s/g, ( title || siteName ) ); } return content || '';