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

[New Block] Add post time to read block #43403

Merged
merged 47 commits into from
Feb 27, 2023
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5e7d7b3
Add new "Post Time To Read" block
t-hamano Sep 18, 2022
ed2b796
Add fixture
t-hamano Sep 18, 2022
cc6493c
Update npm dependencies
t-hamano Sep 18, 2022
f07c8c7
Disallow multiple insert
t-hamano Sep 18, 2022
49bff6f
Fix php lint error
t-hamano Sep 18, 2022
7e9f093
Fix npm dependencies path
t-hamano Sep 18, 2022
56a8e31
Remove unused context
t-hamano Sep 18, 2022
805a6bb
Add a missing word in translate string
t-hamano Sep 22, 2022
06eb280
Don't use @wordpress/editor package
t-hamano Oct 3, 2022
d22901f
Don't store attribute
t-hamano Oct 3, 2022
b2c90d6
Fix npm dependencies
t-hamano Oct 3, 2022
efb3580
Fix: The block is broken in the post editor
t-hamano Oct 3, 2022
094db1d
Update the block icon
t-hamano Oct 3, 2022
9c1e8d6
Add prefix and suffix
t-hamano Oct 3, 2022
088b96e
Server-side rendering implemented using dummy function
t-hamano Oct 3, 2022
9862171
Update fixtures
t-hamano Oct 3, 2022
87ed8b7
Fix phpcs lint error
t-hamano Oct 3, 2022
fa55d92
Implement word_count function
t-hamano Oct 4, 2022
2197d61
Remove some new lines on php
t-hamano Oct 4, 2022
4b6e097
Fix regexp escape
t-hamano Oct 4, 2022
72f6947
convert float zero to int zero
t-hamano Oct 4, 2022
757aa2a
Fix PHP lint error
t-hamano Oct 4, 2022
912e454
Cursor isn't displayed in prefix and suffix input area
t-hamano Oct 5, 2022
6cbca51
Calculate time only when content is changed
t-hamano Oct 5, 2022
8e065cc
Capitalize when there is no prefix
t-hamano Oct 5, 2022
46fb033
Apply inline block style to editor only
t-hamano Oct 5, 2022
faaaf9e
Add Unit Test
t-hamano Oct 11, 2022
fa9566a
Fix PHP Lint
t-hamano Oct 12, 2022
9785f99
Revert prefix/suffix
t-hamano Oct 12, 2022
4bd3ab3
Change block title and description
t-hamano Oct 12, 2022
e3f6b6e
Fix some unit tests
t-hamano Oct 12, 2022
1fa5255
Show message when there is no content
t-hamano Oct 12, 2022
b986d3a
Pass all PHP unit tests
t-hamano Oct 12, 2022
a0612ad
Add @covers to Unit Test class
t-hamano Oct 12, 2022
3909d6e
Changed prefix from gutenberg_ to wp_
t-hamano Oct 12, 2022
907945f
Use dataProvider
t-hamano Oct 12, 2022
7dc6e19
Add render_callback function unit tests
t-hamano Oct 13, 2022
c00d014
Add function existence check
t-hamano Oct 13, 2022
ca36549
Show time only
t-hamano Oct 19, 2022
a8e2884
Update PHP unit test
t-hamano Oct 19, 2022
e3417d8
Mark as experimental
t-hamano Feb 1, 2023
a27741f
Move `wp_word_count()` function to `experimental` directory
t-hamano Feb 1, 2023
39a840b
Use new function `wp_get_word_count_type()`
t-hamano Feb 11, 2023
e673723
fix lint error
t-hamano Feb 17, 2023
a0547c9
Merge branch 'trunk' into add/block-post-time-to-read
t-hamano Feb 21, 2023
b5a361a
Merge branch 'trunk' into add/block-post-time-to-read
t-hamano Feb 27, 2023
ebc1d03
Change namespace from `formatting` to `l10n`
t-hamano Feb 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Show message when there is no content
  • Loading branch information
t-hamano committed Feb 17, 2023
commit 1fa525513600e2d6ab1cb3488a2bb72418937cac
4 changes: 0 additions & 4 deletions packages/block-library/src/post-time-to-read/edit.js
Original file line number Diff line number Diff line change
@@ -67,10 +67,6 @@ function PostTimeToReadEdit( { attributes, setAttributes, context } ) {
wordCount( content, wordCountType ) / AVERAGE_READING_RATE
);

if ( minutesToRead === undefined ) {
return __( 'There is no content.' );
}

if ( minutesToRead !== 0 ) {
return sprintf(
/* translators: %d is the number of minutes the post will take to read. */
6 changes: 3 additions & 3 deletions packages/block-library/src/post-time-to-read/index.php
Original file line number Diff line number Diff line change
@@ -14,12 +14,12 @@
* @return string Returns the rendered post author name block.
*/
function render_block_core_post_time_to_read( $attributes, $content, $block ) {
$content = get_the_content();

if ( ! isset( $block->context['postId'] ) || ! $content ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
}

$content = get_the_content();

/*
* Average reading rate - based on average taken from
* https://irisreading.com/average-reading-speed-in-various-languages/