Changeset 46189 for trunk/src/wp-includes/blocks/latest-posts.php
- Timestamp:
- 09/19/2019 03:17:39 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/latest-posts.php
r44808 r46189 30 30 $list_items_markup = ''; 31 31 32 $excerpt_length = $attributes['excerptLength']; 33 32 34 foreach ( $recent_posts as $post ) { 33 35 $title = get_the_title( $post ); 34 36 if ( ! $title ) { 35 $title = __( '( Untitled)' );37 $title = __( '(no title)' ); 36 38 } 37 39 $list_items_markup .= sprintf( … … 49 51 } 50 52 53 if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent'] 54 && isset( $attributes['displayPostContentRadio'] ) && 'excerpt' === $attributes['displayPostContentRadio'] ) { 55 $post_excerpt = $post->post_excerpt; 56 if ( ! ( $post_excerpt ) ) { 57 $post_excerpt = $post->post_content; 58 } 59 $trimmed_excerpt = esc_html( wp_trim_words( $post_excerpt, $excerpt_length, ' … ' ) ); 60 61 $list_items_markup .= sprintf( 62 '<div class="wp-block-latest-posts__post-excerpt">%1$s', 63 $trimmed_excerpt 64 ); 65 66 if ( strpos( $trimmed_excerpt, ' … ' ) !== false ) { 67 $list_items_markup .= sprintf( 68 '<a href="%1$s">%2$s</a></div>', 69 esc_url( get_permalink( $post ) ), 70 __( 'Read more' ) 71 ); 72 } else { 73 $list_items_markup .= sprintf( 74 '</div>' 75 ); 76 } 77 } 78 79 if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent'] 80 && isset( $attributes['displayPostContentRadio'] ) && 'full_post' === $attributes['displayPostContentRadio'] ) { 81 $list_items_markup .= sprintf( 82 '<div class="wp-block-latest-posts__post-full-content">%1$s</div>', 83 wp_kses_post( html_entity_decode( $post->post_content, ENT_QUOTES, get_option( 'blog_charset' ) ) ) 84 ); 85 } 86 51 87 $list_items_markup .= "</li>\n"; 52 88 } 53 89 54 $class = 'wp-block-latest-posts ';90 $class = 'wp-block-latest-posts wp-block-latest-posts__list'; 55 91 if ( isset( $attributes['align'] ) ) { 56 92 $class .= ' align' . $attributes['align']; … … 73 109 } 74 110 75 $block_content =sprintf(111 return sprintf( 76 112 '<ul class="%1$s">%2$s</ul>', 77 113 esc_attr( $class ), 78 114 $list_items_markup 79 115 ); 80 81 return $block_content;82 116 } 83 117 … … 90 124 array( 91 125 'attributes' => array( 92 'categories' => array( 126 'align' => array( 127 'type' => 'string', 128 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), 129 ), 130 'className' => array( 93 131 'type' => 'string', 94 132 ), 95 'c lassName'=> array(133 'categories' => array( 96 134 'type' => 'string', 97 135 ), 98 'postsToShow' => array(136 'postsToShow' => array( 99 137 'type' => 'number', 100 138 'default' => 5, 101 139 ), 102 'displayPost Date'=> array(140 'displayPostContent' => array( 103 141 'type' => 'boolean', 104 142 'default' => false, 105 143 ), 106 'postLayout' => array( 144 'displayPostContentRadio' => array( 145 'type' => 'string', 146 'default' => 'excerpt', 147 ), 148 'excerptLength' => array( 149 'type' => 'number', 150 'default' => 55, 151 ), 152 'displayPostDate' => array( 153 'type' => 'boolean', 154 'default' => false, 155 ), 156 'postLayout' => array( 107 157 'type' => 'string', 108 158 'default' => 'list', 109 159 ), 110 'columns' => array(160 'columns' => array( 111 161 'type' => 'number', 112 162 'default' => 3, 113 163 ), 114 'align' => array( 115 'type' => 'string', 116 ), 117 'order' => array( 164 'order' => array( 118 165 'type' => 'string', 119 166 'default' => 'desc', 120 167 ), 121 'orderBy' => array(168 'orderBy' => array( 122 169 'type' => 'string', 123 170 'default' => 'date', … … 128 175 ); 129 176 } 130 131 177 add_action( 'init', 'register_block_core_latest_posts' );
Note: See TracChangeset
for help on using the changeset viewer.