Make WordPress Core

Opened 10 months ago

Last modified 7 days ago

#59270 new defect (bug)

Excerpts Not Showing Bold Text ...

Reported by: hmnvtn's profile hmnvtn Owned by:
Milestone: 6.7 Priority: normal
Severity: normal Version: 6.3
Component: Editor Keywords: has-patch
Focuses: Cc:

Description

The text itself shows, but it does not show the bold attributes as it did up until 6.2.2.

Change History (21)

#1 @khokansardar
10 months ago

@hmnvtn yes, I have also checked, the issue is coming due to this line of code which actually filter excerpt based on excerpt length attributes applied in excerpt block.

<?php
$excerpt = wp_trim_words( $excerpt, $excerpt_length );

#2 @sabernhardt
10 months ago

  • Component changed from General to Editor
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 6.3.2
  • Version set to 6.3

Thanks for the report!

The tag removal in the Post Excerpt blocks was already mentioned in a comment on the pull request GB44964. However, I did not find a follow-up issue (or pull request) on the Gutenberg repository to fix it. If you would like, you could create a new issue there.

This ticket was mentioned in Slack in #core-editor by bph. View the logs.


10 months ago

#5 @frzsombor
9 months ago

Coming from similar: #59348

It looks like the "block_type_metadata" filter gives us ability to modify original Gutenberg block settings, and this way it is possible to completely remove the "excerptLength" key from the metadata attributes array. This way we can bypass wp_trim_words() and only get the untrimmed excerpt with HTML content.

function fzs_filter_metadata_registration( $metadata ) {
    if ($metadata['name'] === 'core/post-excerpt') {
        unset($metadata['attributes']['excerptLength']);
    }
    return $metadata;
};
add_filter( 'block_type_metadata', 'fzs_filter_metadata_registration' );
Last edited 9 months ago by frzsombor (previous) (diff)

This ticket was mentioned in Slack in #core-editor by fabiankaegy. View the logs.


9 months ago

This ticket was mentioned in Slack in #core by joemcgill. View the logs.


9 months ago

This ticket was mentioned in Slack in #core by isabelbrison. View the logs.


9 months ago

#9 @audrasjb
9 months ago

  • Milestone changed from 6.3.2 to 6.4

As we're getting close to the 6.3.2 release candidate, let's move this ticket to the next release.

#10 @nicolefurlan
9 months ago

Per this comment in Slack it looks like this is still being reproduced in the latest Gutenberg trunk, so this will need a patch.

#11 @nicolefurlan
8 months ago

  • Milestone changed from 6.4 to 6.5

Bumping this to 6.5 since this bug is yet to be patched.

#12 @swissspidy
4 months ago

  • Milestone changed from 6.5 to 6.6

This ticket was mentioned in Slack in #core by joemcgill. View the logs.


3 months ago

This ticket was mentioned in Slack in #core by nhrrob. View the logs.


13 days ago

#15 @nhrrob
13 days ago

  • Milestone changed from 6.6 to 6.7

It has no movement in the last few months (and releases).
Moving to the next milestone (then future release if still doesn't receive any movement).

Still requires patch.

This ticket was mentioned in PR #6798 on WordPress/wordpress-develop by @up1512001.


11 days ago
#16

  • Keywords has-patch added; needs-patch removed

Trac ticket:
https://core.trac.wordpress.org/ticket/59270
---

As wp_trim_words function strips all HTML tags this won't allow doing any formatting to excerpt. I have used wp_kses() here with specific allowed HTML tags.

### Allowed tag list

$allowed_tags = array(
                'a'      => array(
                        'class' => array(),
                        'style' => array(),
                        'href'  => array(),
                        'id'    => array(),
                ),
                'strong' => array(),
                'b'      => array(),
                'em'     => array(),
                'img'    => array(
                        'class'  => array(),
                        'style'  => array(),
                        'src'    => array(),
                        'alt'    => array(),
                        'width'  => array(),
                        'height' => array(),
                ),
                'mark'   => array(
                        'class' => array(),
                        'style' => array(),
                ),
                'code'   => array(
                        'class' => array(),
                        'style' => array(),
                ),
                'kbd'    => array(
                        'class' => array(),
                        'style' => array(),
                ),
                'bdo'    => array(
                        'class' => array(),
                        'style' => array(),
                        'dir'   => array(),
                        'lang'  => array(),

                ),
                'span'   => array(
                        'class' => array(),
                        'style' => array(),
                ),
                'sup'    => array(
                        'class' => array(),
                        'style' => array(),
                ),
                'sub'    => array(
                        'class' => array(),
                        'style' => array(),
                ),
                's'      => array(
                        'class' => array(),
                        'style' => array(),
                ),
        );

### Example output

https://github.com/WordPress/wordpress-develop/assets/75293077/da21500c-1176-4ae9-86d0-d6d636a499b3

@up1512001 commented on PR #6798:


11 days ago
#17

Hi @swissspidy can you please review this PR?

@audrasjb commented on PR #6798:


11 days ago
#18

Hi, thanks for the PR!

I think we should consider passing $allowed_tags as an argument of wp_trim_words() so we can 1) make it optional (and maybe disabled by default? 2) allow extenders to customize it their way.

What do you think?

@up1512001 commented on PR #6798:


11 days ago
#19

@audrasjb we can definitely do that.

This ticket was mentioned in Slack in #core by up1512001. View the logs.


11 days ago

@up1512001 commented on PR #6798:


7 days ago
#21

@mukeshpanchal27 @audrasjb any update for this PR?

Note: See TracTickets for help on using tickets.