Changeset 45505
- Timestamp:
- 06/08/2019 06:41:08 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/dashboard.php
r45450 r45505 585 585 echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>"; 586 586 587 588 589 587 590 $drafts = array_slice( $drafts, 0, 3 ); 588 591 foreach ( $drafts as $draft ) { … … 593 596 echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . esc_html( $title ) . '</a>'; 594 597 echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( __( 'F j, Y' ), $draft ) . '</time></div>'; 595 if ( $the_content = wp_trim_words( $draft->post_content, 10) ) {598 if ( $the_content = wp_trim_words( $draft->post_content, ) ) { 596 599 echo '<p>' . $the_content . '</p>'; 597 600 } -
trunk/src/wp-includes/comment-template.php
r45496 r45505 578 578 579 579 /** 580 * Retrieve the excerpt of the current comment. 581 * 582 * Will cut each word and only output the first 20 words with '…' at the end. 583 * If the word count is less than 20, then no truncating is done and no '…' 584 * will appear. 580 * Retrieves the excerpt of the given comment. 581 * 582 * Returns a maximum of 20 words with an ellipsis appended if necessary. 585 583 * 586 584 * @since 1.5.0 … … 589 587 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the excerpt. 590 588 * Default current comment. 591 * @return string The maybe truncated comment with 20 words or less.589 * @return string The . 592 590 */ 593 591 function get_comment_excerpt( $comment_ID = 0 ) { 594 592 $comment = get_comment( $comment_ID ); 595 593 $comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) ); 596 $words = explode( ' ', $comment_text ); 597 598 /** 599 * Filters the amount of words used in the comment excerpt. 594 595 /* translators: Maximum number of words used in a comment excerpt. */ 596 $comment_excerpt_length = intval( _x( '20', 'comment_excerpt_length' ) ); 597 598 /** 599 * Filters the maximum number of words used in the comment excerpt. 600 600 * 601 601 * @since 4.4.0 … … 603 603 * @param int $comment_excerpt_length The amount of words you want to display in the comment excerpt. 604 604 */ 605 $comment_excerpt_length = apply_filters( 'comment_excerpt_length', 20 ); 606 607 $use_ellipsis = count( $words ) > $comment_excerpt_length; 608 if ( $use_ellipsis ) { 609 $words = array_slice( $words, 0, $comment_excerpt_length ); 610 } 611 612 $excerpt = trim( join( ' ', $words ) ); 613 if ( $use_ellipsis ) { 614 $excerpt .= '…'; 615 } 605 $comment_excerpt_length = apply_filters( 'comment_excerpt_length', $comment_excerpt_length ); 606 607 $excerpt = wp_trim_words( $comment_text, $comment_excerpt_length, '…' ); 608 616 609 /** 617 610 * Filters the retrieved comment excerpt. -
trunk/src/wp-includes/formatting.php
r45445 r45505 3681 3681 * Generates an excerpt from the content, if needed. 3682 3682 * 3683 * The excerpt word amount will be 55 words and if the amount is greater than 3684 * that, then the string ' […]' will be appended to the excerpt. If the string 3685 * is less than 55 words, then the content will be returned as is. 3683 * Returns a maximum of 55 words with an ellipsis appended if necessary. 3686 3684 * 3687 3685 * The 55 word limit can be modified by plugins/themes using the {@see 'excerpt_length'} filter … … 3708 3706 $text = str_replace( ']]>', ']]>', $text ); 3709 3707 3708 3709 3710 3710 3711 /** 3711 * Filters the number of words in anexcerpt.3712 * Filters the excerpt. 3712 3713 * 3713 3714 * @since 2.7.0 3714 3715 * 3715 * @param int $number The number of words. Default 55.3716 * @param int $number The number of words. Default 55. 3716 3717 */ 3717 $excerpt_length = apply_filters( 'excerpt_length', 55 ); 3718 $excerpt_length = apply_filters( 'excerpt_length', $excerpt_length ); 3719 3718 3720 /** 3719 3721 * Filters the string in the "more" link displayed after a trimmed excerpt. … … 3726 3728 $text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); 3727 3729 } 3730 3728 3731 /** 3729 3732 * Filters the trimmed excerpt string. -
trunk/tests/phpunit/data/languages/ja_JP.po
r43359 r45505 41 41 msgid "Update %s now" 42 42 msgstr "今すぐ %s を更新" 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 -
trunk/tests/phpunit/tests/formatting/WPTrimWords.php
r42343 r45505 5 5 */ 6 6 class Tests_Formatting_WPTrimWords extends WP_UnitTestCase { 7 8 9 10 11 12 13 14 7 15 private $long_text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce varius lacinia vehicula. Etiam sapien risus, ultricies ac posuere eu, convallis sit amet augue. Pellentesque urna massa, lacinia vel iaculis eget, bibendum in mauris. Aenean eleifend pulvinar ligula, a convallis eros gravida non. Suspendisse potenti. Pellentesque et odio tortor. In vulputate pellentesque libero, sed dapibus velit mollis viverra. Pellentesque id urna euismod dolor cursus sagittis.'; 8 16 … … 43 51 $this->assertEquals( $text, wp_trim_words( $text ) ); 44 52 } 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 45 76 } -
trunk/tests/phpunit/tests/l10n.php
r44516 r45505 6 6 */ 7 7 class Tests_L10n extends WP_UnitTestCase { 8 9 10 11 12 13 14 15 16 8 17 9 18 /** … … 261 270 $this->assertNotEmpty( $array['X-Generator'] ); 262 271 } 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 263 519 }
Note: See TracChangeset
for help on using the changeset viewer.