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

PLANET-5460 Disable Wordpress(wp5.5) Blocks Directory feature #1221

Merged
merged 1 commit into from
Nov 10, 2020

Conversation

sagarsdeshmukh
Copy link
Member

JIRA 5460

The branch is pin on planet-test-nix test instance for testing.

@sagarsdeshmukh sagarsdeshmukh requested a review from a team November 2, 2020 10:57
@sagarsdeshmukh sagarsdeshmukh self-assigned this Nov 2, 2020
@sagarsdeshmukh sagarsdeshmukh requested review from lithrel and mleray and removed request for a team November 2, 2020 10:57
src/MasterSite.php Outdated Show resolved Hide resolved
@sagarsdeshmukh sagarsdeshmukh changed the base branch from master to wp55 November 3, 2020 13:00
@comzeradd comzeradd changed the base branch from wp55 to master November 3, 2020 13:10
@comzeradd comzeradd changed the base branch from master to wp55 November 3, 2020 13:10
remove_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' );
remove_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_block_editor_assets_block_directory' );
}
);
Copy link
Contributor

@lithrel lithrel Nov 5, 2020

Choose a reason for hiding this comment

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

OK, I can't make the block directory work for some reason (it makes an OPTION request to its endpoint when I type in the box and that's all, no search after that); but I can see the script block-directory.js still loaded in the network tab.
From what I've read and tested, you don't need a hook to remove an action from a theme, and I can't see where the gutenberg_enqueue_block_editor_assets_block_directory is used, I can only assume it is specific to the Gutenberg repo and transformed at some point, but not included in the Wordpress install. In the end using only this one (without add_action()) seems to work:

remove_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' );

Which version are you on ? I just installed 5.5.3 so maybe we are on a different one (5.5.2 was just a few days before)

edit: We could also disable the endpoint, something like

  protected function hooks() {
    // ...
    $this->disable_block_directory();
  }

  public function disable_block_directory() {
    remove_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' );
    add_filter( 'rest_endpoints', [ $this, 'disable_block_directory_endpoint'] );
  }

  public function disable_block_directory_endpoint( $endpoints ) {
    unset( $endpoints['/wp/v2/block-directory/search'] );
    return $endpoints;
  }

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @lithrel - Thanks for the review :) . I am using the same WPv5.5.3 version. Could you try commenting the define('DISALLOW_FILE_MODS', true ); line in wp-config.php file.

I updated the PR with above changes. please have a look.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you try commenting the define('DISALLOW_FILE_MODS', true ); line in wp-config.php file.

That was it, thanks !

Copy link
Contributor

@lithrel lithrel left a comment

Choose a reason for hiding this comment

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

👍

@sagarsdeshmukh sagarsdeshmukh merged commit 6036580 into wp55 Nov 10, 2020
@sagarsdeshmukh sagarsdeshmukh deleted the planet-5460 branch November 10, 2020 10:28
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.

3 participants