Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: limit excerpt lengths even for custom excerpts #874

Merged
merged 2 commits into from
Sep 22, 2021

Conversation

obenland
Copy link
Member

Trims excerpts even if it's a custom excerpt for a uniform look.

All Submissions:

Changes proposed in this Pull Request:

Deprecated excerpt_length and excerpt_more methods in favor of a comprehensive excerpt callback.

Core only allows to control the length of generated excerpts, assuming that authors want to keep their custom excerpts as they're written. This PR will apply the excerpt length limit to both types of excerpts for a more uniform look.

Closes Automattic/wp-calypso#51415

How to test the changes in this Pull Request:

  1. Once you checked out the branch and built the block…
  2. Add a custom excerpt to a post, preferably a rather long one.
  3. In a different post, insert the Homepage Posts block and manipulate the excerpt length.
  4. Preview the post to make sure the front-end works as expected.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Trims excerpts even if it's a custom excerpt for a uniform look.

Fixes Automattic/wp-calypso#51415
@obenland obenland added [Status] Needs Review [Block] Homepage Posts User Report This issue was created following a WordPress customer report labels Sep 17, 2021
@dkoo dkoo requested a review from a team September 17, 2021 23:26
@mreishus
Copy link
Contributor

Once you checked out the branch and built the block…

@obenland I'm not sure how to do this. After I run npm start in this repository, I don't see any ports open up on my machine. Do I need to copy some of the built files to a calypso installation, or my sandbox to work with them?

@obenland
Copy link
Member Author

Heh, I was just thinking I should expand on the testing instructions :)

I have my newspack-blocks repo sym-linked into wp-content/plugins on a local WordPress install (I use MAMP) so I can use it as a regular plugin. Does that help?

@mreishus
Copy link
Contributor

Yup, I use wp-env, and I was able to get it working by adding the directory to the plugins list in .wp-env.json.
2021-09-20_10-20

@mreishus mreishus self-requested a review September 20, 2021 15:37
Copy link
Contributor

@mreishus mreishus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionality is working well:
2021-09-20_10-44

From a code standpoint, as someone not familiar with the code, I might wonder why both filter_excerpt and filter_excerpt_length exist, since they both seem to do the same thing. However the @deprecated tag might provide enough of an explanation.

Noted a small spelling error.

Copy link
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected, left one question.

includes/class-newspack-blocks.php Show resolved Hide resolved
@adekbadek adekbadek merged commit 85f5bf4 into master Sep 22, 2021
@adekbadek adekbadek deleted the add/filter-excerpt branch September 22, 2021 09:45
matticbot pushed a commit that referenced this pull request Sep 28, 2021
# [1.39.0-alpha.1](v1.38.0...v1.39.0-alpha.1) (2021-09-28)

### Bug Fixes

* limit excerpt lengths even for custom excerpts ([#874](#874)) ([85f5bf4](85f5bf4))

### Features

* **donate:** remove NRH metadata ([080430c](080430c))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.39.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Sep 28, 2021
# [1.39.0](v1.38.0...v1.39.0) (2021-09-28)

### Bug Fixes

* if a post has a custom excerpt, use it ([#880](#880)) ([57b5cdd](57b5cdd))
* limit excerpt lengths even for custom excerpts ([#874](#874)) ([85f5bf4](85f5bf4))

### Features

* **donate:** remove NRH metadata ([080430c](080430c))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.39.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blog Posts Block: Excerpt Word Limit Ignored for Posts with a Custom Excerpt
4 participants