PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.12
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.12
1.1.12 1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 All 36 releases
← All changes | includes/recycle-bin/store.php +22 -5 1.1.10 → 1.1.12 View file →
@@ -474,9 +474,9 @@
474 474 $parent_text
475 475 )
476 476 : $author;
477 477
478 - $subtitle = wp_trim_words( openstation_recycle_bin_plain_text( (string) $comment->comment_content ), 18, '…' );
478 + $subtitle = openstation_recycle_bin_excerpt( (string) $comment->comment_content );
479 479
480 480 $user = $user_id ? get_userdata( $user_id ) : false;
481 481 $user_name = $user ? $user->display_name : '';
482 482
@@ -520,9 +520,9 @@
520 520 * @return string
521 521 */
522 522 function openstation_recycle_bin_plain_text( $text ) {
523 523 return html_entity_decode(
524 - wp_strip_all_tags( (string) $text ),
524 + openstation_strip_all_tags( $text ),
525 525 ENT_QUOTES,
526 526 get_bloginfo( 'charset' )
527 527 );
528 528 }
@@ -527,8 +527,25 @@
527 527 );
528 528 }
529 529
530 530 /**
531 + * The first words of a body, as the plain text of a row's subtitle.
532 + *
533 + * @param string $text Raw excerpt or content.
534 + * @return string
535 + */
536 +function openstation_recycle_bin_excerpt( $text ) {
537 + // `wp_trim_words()` strips tags itself, and in plain text that cuts
538 + // at a `<`. Trimming before the decode would avoid it, but where
539 + // WordPress counts characters instead of words an `&amp;` would
540 + // count as five and could be cut in half. So each `<` sits out the
541 + // trim as a control character, one for one.
542 + $text = str_replace( '<', "\x1A", openstation_recycle_bin_plain_text( $text ) );
543 +
544 + return str_replace( "\x1A", '<', wp_trim_words( $text, 18, '…' ) );
545 +}
546 +
547 +/**
531 548 * Shape one WP_Post into the JSON the JS table consumes.
532 549 *
533 550 * @param WP_Post $post Trashed post.
534 551 * @return array
@@ -562,12 +579,12 @@
562 579 $subtitle = $mime;
563 580 } elseif ( 'post' === $type ) {
564 581 $icon = 'dashicons-admin-post';
565 582 $excerpt = (string) $post->post_excerpt;
566 - $subtitle = wp_trim_words( openstation_recycle_bin_plain_text( $excerpt ? $excerpt : (string) $post->post_content ), 18, '…' );
583 + $subtitle = openstation_recycle_bin_excerpt( $excerpt ? $excerpt : (string) $post->post_content );
567 584 } elseif ( 'page' === $type ) {
568 585 $icon = 'dashicons-admin-page';
569 - $subtitle = wp_trim_words( openstation_recycle_bin_plain_text( (string) $post->post_content ), 18, '…' );
586 + $subtitle = openstation_recycle_bin_excerpt( (string) $post->post_content );
570 587 } else {
571 588 // Custom post types: reuse the type's own menu Dashicon when it
572 589 // registered one, so a trashed product row reads as a product
573 590 // instead of a generic file. Content excerpt as the subtitle,
@@ -581,9 +598,9 @@
581 598 ) {
582 599 $icon = $post_type_obj->menu_icon;
583 600 }
584 601 $excerpt = (string) $post->post_excerpt;
585 - $subtitle = wp_trim_words( openstation_recycle_bin_plain_text( $excerpt ? $excerpt : (string) $post->post_content ), 18, '…' );
602 + $subtitle = openstation_recycle_bin_excerpt( $excerpt ? $excerpt : (string) $post->post_content );
586 603 }
587 604
588 605 $user = $user_id ? get_userdata( $user_id ) : false;
589 606 $user_name = $user ? $user->display_name : '';