Changeset 31595
- Timestamp:
- 03/01/2015 10:43:36 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-press-this.php
r31589 r31595 32 32 */ 33 33 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>'; 36 34 37 return array( 35 38 // Used to trigger the bookmarklet update notice. … … 42 45 * @since 4.2.0 43 46 * 44 * @param bool $redir_in_parentWhether to redirect in parent window or not. Default false.47 * @param bool false Whether to redirect in parent window or not. Default false. 45 48 */ 46 'redir_in_parent' => apply_filters( 'press_this_redirect_in_parent', false ), 49 'redirInParent' => apply_filters( 'press_this_redirect_in_parent', false ), 50 51 /** 52 * Filter the HTML for the Press This source attribution. 53 * 54 * @since 4.2.0 55 * 56 * @param string $html Default HTML, %1$s is link href, %2$s is link text. 57 */ 58 'suggestedHTML' => apply_filters( 'press_this_suggested_html', $html ), 47 59 ); 48 60 } -
trunk/src/wp-admin/js/press-this.js
r31589 r31595 101 101 * Gets the source page's canonical link, based on passed location and meta data. 102 102 * 103 * @param data object Usually WpPressThis_App.data104 103 * @returns string Discovered canonical URL, or empty 105 104 */ 106 function getCanonicalLink( data ) { 107 if ( ! data || data.length ) { 108 return ''; 109 } 110 105 function getCanonicalLink() { 111 106 var link = ''; 112 107 … … 129 124 } 130 125 131 return decodeURI( link);126 return checkUrl( decodeURI( link ) ); 132 127 } 133 128 … … 135 130 * Gets the source page's site name, based on passed meta data. 136 131 * 137 * @param data object Usually WpPressThis_App.data138 132 * @returns string Discovered site name, or empty 139 133 */ 140 function getSourceSiteName( data ) { 141 if ( ! data || data.length ) { 142 return ''; 143 } 144 145 var name=''; 134 function getSourceSiteName() { 135 var name = ''; 146 136 147 137 if ( data._meta ) { … … 153 143 } 154 144 155 return name.replace( /\\/g, '');145 return sanitizeText( name ); 156 146 } 157 147 … … 159 149 * Gets the source page's title, based on passed title and meta data. 160 150 * 161 * @param data object Usually WpPressThis_App.data162 151 * @returns string Discovered page title, or empty 163 152 */ 164 function getSuggestedTitle( data ) { 165 if ( ! data || data.length ) { 166 return __( 'newPost' ); 167 } 168 153 function getSuggestedTitle() { 169 154 var title = ''; 170 155 … … 173 158 } 174 159 175 if ( ! title .length&& data._meta ) {160 if ( ! title && data._meta ) { 176 161 if ( data._meta['twitter:title'] && data._meta['twitter:title'].length ) { 177 162 title = data._meta['twitter:title']; … … 183 168 } 184 169 185 if ( ! title .length) {170 if ( ! title ) { 186 171 title = __( 'newPost' ); 187 172 hasEmptyTitleStr = true; 188 173 } 189 174 190 return title.replace( /\\/g, '');175 return sanitizeText( title ); 191 176 } 192 177 … … 195 180 * Features a blockquoted excerpt, as well as content attribution, if any. 196 181 * 197 * @param data object Usually WpPressThis_App.data198 182 * @returns string Discovered content, or empty 199 183 */ 200 function getSuggestedContent( data ) { 201 if ( ! data || data.length ) { 202 return ''; 203 } 204 205 var content = '', 206 title = getSuggestedTitle( data ), 207 url = getCanonicalLink( data ), 208 siteName = getSourceSiteName( data ); 184 function getSuggestedContent() { 185 var content = '', 186 text = '', 187 title = getSuggestedTitle(), 188 url = getCanonicalLink(), 189 siteName = getSourceSiteName(); 209 190 210 191 if ( data.s && data.s.length ) { 211 content = data.s;192 text = data.s; 212 193 } else if ( data._meta ) { 213 194 if ( data._meta['twitter:description'] && data._meta['twitter:description'].length ) { 214 content = data._meta['twitter:description'];195 text = data._meta['twitter:description']; 215 196 } else if ( data._meta['og:description'] && data._meta['og:description'].length ) { 216 content = data._meta['og:description'];197 text = data._meta['og:description']; 217 198 } else if ( data._meta.description && data._meta.description.length ) { 218 content = data._meta.description; 219 } 220 } 221 222 // Wrap suggested content in blockquote tag, if we have any. 223 content = ( content.length ? '<blockquote class="press-this-suggested-content">' + sanitizeText( content ) + '</blockquote>' : '' ); 199 text = data._meta.description; 200 } 201 } 202 203 if ( text ) { 204 text = sanitizeText( text ); 205 // Wrap suggested content in blockquote tag. 206 content = '<blockquote class="press-this-suggested-content">' + text + '</blockquote>'; 207 } 224 208 225 209 // Add a source attribution if there is one available. 226 if ( ( ( title.length && __( 'newPost' ) !== title ) || siteName.length ) && url.length ) { 227 content += '<p class="press-this-suggested-source">'; 228 content += __( 'source' ); 229 content += ' <cite>'; 230 content += __( 'sourceLink').replace( '%1$s', encodeURI( url ) ).replace( '%2$s', sanitizeText( title || siteName ) ); 231 content += '</cite></p>'; 232 } 233 234 if ( ! content ) { 235 content = ''; 236 } 237 238 return content.replace( /\\/g, '' ); 210 if ( url && siteConfig.suggestedHTML && ( ( title && __( 'newPost' ) !== title ) || siteName ) ) { 211 content += siteConfig.suggestedHTML.replace( '%1$s', encodeURI( url ) ).replace( '%2$s', ( title || siteName ) ); 212 } 213 214 return content || ''; 239 215 } 240 216 … … 473 449 hideSpinner(); 474 450 } else if ( response.data.redirect ) { 475 if ( window.opener && siteConfig.redir _in_parent ) {451 if ( window.opener && siteConfig.redirInParent ) { 476 452 try { 477 453 window.opener.location.href = response.data.redirect; … … 515 491 516 492 if ( ! hasSetFocus ) { 517 // Append to top of content on 1st media insert 518 editor.setContent( newContent + editor.getContent() ); 519 } else { 520 // Or add where the cursor was last positioned in TinyMCE 521 editor.execCommand( 'mceInsertContent', false, newContent ); 522 } 523 493 editor.focus(); 494 } 495 496 editor.execCommand( 'mceInsertContent', false, newContent ); 524 497 hasSetFocus = true; 525 498 } … … 674 647 } ); 675 648 } 676 677 649 } 678 650 -
trunk/src/wp-includes/script-loader.php
r31594 r31595 475 475 $scripts->add( 'press-this', "/wp-admin/js/press-this$suffix.js", array( 'jquery', 'tags-box' ), false, 1 ); 476 476 did_action( 'init' ) && $scripts->localize( 'press-this', 'pressThisL10n', array( 477 /**478 * Filter the string displayed before the source attribution string in Press This.479 *480 * @since 4.2.0481 *482 * @param string $string Internationalized source string.483 */484 'source' => apply_filters( 'press_this_source_string', __( 'Source:' ) ),485 486 /**487 * Filter the HTML link format for the Press This source attribution, can control target, class, etc.488 *489 * @since 4.2.0490 *491 * @param string $link_format Link format, %1$s is link href, %2$s is link text.492 */493 'sourceLink' => apply_filters( 'press_this_source_link', '<a href="%1$s">%2$s</a>' ),494 477 'newPost' => __( 'Title' ), 495 478 'unexpectedError' => __( 'Sorry, but an unexpected error occurred.' ),
Note: See TracChangeset
for help on using the changeset viewer.