| @@ -10,9 +10,8 @@ | ||
| 10 | 10 | * set at render time and used by the block itself. |
| 11 | 11 | * |
| 12 | 12 | * @var int |
| 13 | 13 | */ |
| 14 | -global $block_core_latest_posts_excerpt_length; | |
| 15 | 14 | $block_core_latest_posts_excerpt_length = 0; |
| 16 | 15 | |
| 17 | 16 | /** |
| 18 | 17 | * Callback for the excerpt_length filter used by |
| @@ -59,14 +58,9 @@ | ||
| 59 | 58 | $list_items_markup = ''; |
| 60 | 59 | |
| 61 | 60 | foreach ( $recent_posts as $post ) { |
| 62 | 61 | $post_link = esc_url( get_permalink( $post ) ); |
| 63 | - $title = get_the_title( $post ); | |
| 64 | 62 | |
| 65 | - if ( ! $title ) { | |
| 66 | - $title = __( '(no title)' ); | |
| 67 | - } | |
| 68 | - | |
| 69 | 63 | $list_items_markup .= '<li>'; |
| 70 | 64 | |
| 71 | 65 | if ( $attributes['displayFeaturedImage'] && has_post_thumbnail( $post ) ) { |
| 72 | 66 | $image_style = ''; |
| @@ -85,29 +79,32 @@ | ||
| 85 | 79 | $featured_image = get_the_post_thumbnail( |
| 86 | 80 | $post, |
| 87 | 81 | $attributes['featuredImageSizeSlug'], |
| 88 | 82 | array( |
| 89 | - 'style' => esc_attr( $image_style ), | |
| 83 | + 'style' => $image_style, | |
| 90 | 84 | ) |
| 91 | 85 | ); |
| 92 | 86 | if ( $attributes['addLinkToFeaturedImage'] ) { |
| 93 | 87 | $featured_image = sprintf( |
| 94 | - '<a href="%1$s" aria-label="%2$s">%3$s</a>', | |
| 95 | - esc_url( $post_link ), | |
| 96 | - esc_attr( $title ), | |
| 88 | + '<a href="%1$s">%2$s</a>', | |
| 89 | + $post_link, | |
| 97 | 90 | $featured_image |
| 98 | 91 | ); |
| 99 | 92 | } |
| 100 | 93 | $list_items_markup .= sprintf( |
| 101 | 94 | '<div class="%1$s">%2$s</div>', |
| 102 | - esc_attr( $image_classes ), | |
| 95 | + $image_classes, | |
| 103 | 96 | $featured_image |
| 104 | 97 | ); |
| 105 | 98 | } |
| 106 | 99 | |
| 100 | + $title = get_the_title( $post ); | |
| 101 | + if ( ! $title ) { | |
| 102 | + $title = __( '(no title)' ); | |
| 103 | + } | |
| 107 | 104 | $list_items_markup .= sprintf( |
| 108 | 105 | '<a href="%1$s">%2$s</a>', |
| 109 | - esc_url( $post_link ), | |
| 106 | + $post_link, | |
| 110 | 107 | $title |
| 111 | 108 | ); |
| 112 | 109 | |
| 113 | 110 | if ( isset( $attributes['displayAuthor'] ) && $attributes['displayAuthor'] ) { |
| @@ -118,9 +115,9 @@ | ||
| 118 | 115 | |
| 119 | 116 | if ( ! empty( $author_display_name ) ) { |
| 120 | 117 | $list_items_markup .= sprintf( |
| 121 | 118 | '<div class="wp-block-latest-posts__post-author">%1$s</div>', |
| 122 | - $byline | |
| 119 | + esc_html( $byline ) | |
| 123 | 120 | ); |
| 124 | 121 | } |
| 125 | 122 | } |
| 126 | 123 | |
| @@ -127,9 +124,9 @@ | ||
| 127 | 124 | if ( isset( $attributes['displayPostDate'] ) && $attributes['displayPostDate'] ) { |
| 128 | 125 | $list_items_markup .= sprintf( |
| 129 | 126 | '<time datetime="%1$s" class="wp-block-latest-posts__post-date">%2$s</time>', |
| 130 | 127 | esc_attr( get_the_date( 'c', $post ) ), |
| 131 | - get_the_date( '', $post ) | |
| 128 | + esc_html( get_the_date( '', $post ) ) | |
| 132 | 129 | ); |
| 133 | 130 | } |
| 134 | 131 | |
| 135 | 132 | if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent'] |
| @@ -136,12 +133,8 @@ | ||
| 136 | 133 | && isset( $attributes['displayPostContentRadio'] ) && 'excerpt' === $attributes['displayPostContentRadio'] ) { |
| 137 | 134 | |
| 138 | 135 | $trimmed_excerpt = get_the_excerpt( $post ); |
| 139 | 136 | |
| 140 | - if ( post_password_required( $post ) ) { | |
| 141 | - $trimmed_excerpt = __( 'This content is password protected.' ); | |
| 142 | - } | |
| 143 | - | |
| 144 | 137 | $list_items_markup .= sprintf( |
| 145 | 138 | '<div class="wp-block-latest-posts__post-excerpt">%1$s</div>', |
| 146 | 139 | $trimmed_excerpt |
| 147 | 140 | ); |
| @@ -148,18 +141,11 @@ | ||
| 148 | 141 | } |
| 149 | 142 | |
| 150 | 143 | if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent'] |
| 151 | 144 | && isset( $attributes['displayPostContentRadio'] ) && 'full_post' === $attributes['displayPostContentRadio'] ) { |
| 152 | - | |
| 153 | - $post_content = html_entity_decode( $post->post_content, ENT_QUOTES, get_option( 'blog_charset' ) ); | |
| 154 | - | |
| 155 | - if ( post_password_required( $post ) ) { | |
| 156 | - $post_content = __( 'This content is password protected.' ); | |
| 157 | - } | |
| 158 | - | |
| 159 | 145 | $list_items_markup .= sprintf( |
| 160 | 146 | '<div class="wp-block-latest-posts__post-full-content">%1$s</div>', |
| 161 | - wp_kses_post( $post_content ) | |
| 147 | + wp_kses_post( html_entity_decode( $post->post_content, ENT_QUOTES, get_option( 'blog_charset' ) ) ) | |
| 162 | 148 | ); |
| 163 | 149 | } |
| 164 | 150 | |
| 165 | 151 | $list_items_markup .= "</li>\n"; |