Changeset 3360
- Timestamp:
- 06/14/2016 12:30:54 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-readme-parser.php
r3358 r3360 210 210 } 211 211 212 // Sanitize and trim the short_description to match requirements213 $this->short_description = $this->sanitize_text( $this->short_description );214 $this->short_description = $this->trim_length( $this->short_description, 150 );215 216 212 // Parse out the Upgrade Notice section into it's own data 217 213 if ( isset( $this->sections['upgrade_notice'] ) ) { … … 243 239 244 240 // Markdownify! 245 $this->short_description = $this->parse_markdown( $this->short_description );246 241 $this->sections = array_map( array( $this, 'parse_markdown' ), $this->sections ); 247 242 $this->upgrade_notice = array_map( array( $this, 'parse_markdown' ), $this->upgrade_notice ); 243 244 // Sanitize and trim the short_description to match requirements 245 $this->short_description = $this->sanitize_text( $this->short_description ); 246 $this->short_description = $this->trim_length( $this->short_description, 150 ); 247 $this->short_description = $this->parse_markdown( $this->short_description ); 248 $this->short_description = wp_strip_all_tags( $this->short_description ); 248 249 249 250 if ( isset( $this->sections['screenshots'] ) ) { … … 280 281 281 282 protected function trim_length( $desc, $length = 150 ) { 282 if ( function_exists( 'mb_strlen' ) && function_exists( 'mb_substr' ) ) { 283 if ( mb_strlen( $desc ) > $length ) { 284 $desc = mb_substr( $desc, 0, $length ); 285 } 286 } else { 287 if ( strlen( $desc ) > $length ) { 288 $desc = substr( $desc, 0, $length ); 283 if ( mb_strlen( $desc ) > $length ) { 284 $desc = mb_substr( $desc, 0, $length ) . ' …'; 285 286 // If not a full sentence, and one ends within 20% of the end, trim it to that. 287 if ( '.' !== mb_substr( $desc, -1 ) && ( $pos = mb_strrpos( $desc, '.' ) ) > ( 0.8 * $length ) ) { 288 $desc = mb_substr( $desc, 0, $pos + 1 ); 289 289 } 290 290 }
Note: See TracChangeset
for help on using the changeset viewer.