WordPress.org

Make WordPress Core

Opened 11 months ago

Closed 11 months ago

Last modified 8 months ago

#45396 closed defect (bug) (fixed)

Import from JSON button is missing on Manage All Reusable Blocks page

Reported by: noisysocks Owned by: noisysocks
Milestone: 5.0 Priority: normal
Severity: normal Version: 5.0
Component: Editor Keywords:
Focuses: Cc:
PR Number:

Description

The Import from JSON button is missing on the Manage All Reusable Blocks page and the Export as JSON link underneath each reusable block does not work.

Steps to reproduce

  1. Create a new post
  2. Create a new reusable block
  3. Click on the More button (top right) and select Manage All Reusable Blocks

Expected result

There should be a blue Import from JSON button at the top of the WP Admin page.

Attachments (3)

45396.diff (592 bytes) - added by noisysocks 11 months ago.
Manage All Reusable Blocks Page.png (89.9 KB) - added by mukesh27 11 months ago.
45396.2.diff (1.1 KB) - added by swissspidy 11 months ago.

Download all attachments as: .zip

Change History (22)

@noisysocks
11 months ago

#1 @noisysocks
11 months ago

  • Keywords has-patch added; needs-patch removed

I've fixed this in 45396.diff by moving wp-list-reusable-blocks to the edit.php page's footer.

#2 @mukesh27
11 months ago

  • Keywords reporter-feedback added

@noisysocks In WP version 5.0-beta5-43909 is already working without applying above patch. see attached screenshot.

I am missing anything?

Last edited 11 months ago by mukesh27 (previous) (diff)

#3 follow-up: @noisysocks
11 months ago

I think it's a very recent regression. To clarify, I encountered it while running r43933 in the 5.0 branch.

#4 in reply to: ↑ 3 @mukesh27
11 months ago

  • Keywords reporter-feedback removed

Ok. so if above issue fix already then can you please close this ticket or needs to wait?

Replying to noisysocks:

I think it's a very recent regression. To clarify, I encountered it while running r43933 in the 5.0 branch.

Last edited 11 months ago by mukesh27 (previous) (diff)

#5 @noisysocks
11 months ago

The issue hasn't been fixed. It exists in the 5.0 development branch. We can't close this ticket until it's fixed by e.g. committing the patch I've attached above.

#6 @pento
11 months ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 5.0

#7 @youknowriad
11 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 43936:

Block Editor: Fix loading the script handling the "Manage Reusable Blocks" page.

This ensures the "import from JSON" and "export JSON" buttons are shown properly.
The script is loaded in the footer because it relies on the DOM being already there.

Props noisysocks, mukesh27.
Fixes #45396.

#8 @youknowriad
11 months ago

  • Keywords fixed-5.0 added
  • Resolution fixed deleted
  • Status changed from closed to reopened

#9 follow-up: @swissspidy
11 months ago

Don't you lose the version number when enqueuing the script that way? Why not just set $scripts->add_data( 'wp-list-reusable-blocks', 'group', 1 ); in script-loader.php instead?

#10 in reply to: ↑ 9 @noisysocks
11 months ago

Replying to swissspidy:

Don't you lose the version number when enqueuing the script that way? Why not just set $scripts->add_data( 'wp-list-reusable-blocks', 'group', 1 ); in script-loader.php instead?

I wrote the patch the only way I know how—I'm not too familiar with these APIs 🙂

Looking at the source for wp_enqueue_script, it seems to me that calling wp_enqueue_script() with $src = '' and $in_footer = true will have the same effect as setting $script->add_data( 'wp-list-reusable-blocks', 'group', 1 ); in script-loader.php. Is there something I'm missing?

#11 @swissspidy
11 months ago

The problem with that approach is that for everyone who adds wp-list-reusable-blocks as a dependency or directly calls wp_enqueue_script( 'wp-list-reusable-blocks' ) the script would still load in the header.

That's why this ($script->add_data( 'wp-list-reusable-blocks', 'group', 1 ); should be added directly to the wp_default_packages_scripts function.

@swissspidy
11 months ago

#12 @pento
11 months ago

  • Keywords fixed-5.0 removed

Thanks for following up on this, and the patch, @swissspidy!

45396.2.diff is good to commit.

#13 @swissspidy
11 months ago

Please correct me if I'm mistaken, but I'd hold off commit until the action on #45402 has been decided as that one includes a revert for this.

#14 @pento
11 months ago

  • Keywords fixed-5.0 added

Yah, I just caught up. :) Re-closing this in favour of #45402.

#15 @youknowriad
11 months ago

In 43942:

Block Editor: Fix the WordPress packages and vendor script registration.

The version is set properly and the scripts are automatically loaded in the footer.
This patch also includes a revert for the reusable blocks enqueue script.

Props pento, swissspidy.
Fixes #45402.
See #45396.

#16 @ocean90
11 months ago

  • Keywords has-patch commit fixed-5.0 removed
  • Milestone 5.0 deleted
  • Resolution set to duplicate
  • Status changed from reopened to closed

Duplicate of #45402.

#17 @desrosj
10 months ago

  • Resolution changed from duplicate to fixed

In 44274:

Block Editor: Fix loading the script handling the "Manage Reusable Blocks" page.

This ensures the "import from JSON" and "export JSON" buttons are shown properly. The script is loaded in the footer because it relies on the DOM being already there.

Props noisysocks, mukesh27.

Merges [43936] into trunk.

Fixes #45396.

#18 @desrosj
10 months ago

In 44277:

Block Editor: Fix the WordPress packages and vendor script registration.

The version is set properly and the scripts are automatically loaded in the footer.

This patch also includes a revert for the reusable blocks enqueue script.

Props pento, swissspidy, youknowriad.

Merges [43942] into trunk.

Fixes #45402.
See #45396.

#19 @ocean90
8 months ago

  • Milestone set to 5.0
Note: See TracTickets for help on using tickets.