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

Block Directory: Return deactivated plugins in search results. #23570

Closed
StevenDufresne opened this issue Jun 30, 2020 · 4 comments · Fixed by #23688
Closed

Block Directory: Return deactivated plugins in search results. #23570

StevenDufresne opened this issue Jun 30, 2020 · 4 comments · Fixed by #23688
Assignees
Labels
[Feature] Block Directory Related to the Block Directory, a repository of block plugins [Feature] Plugins API Extending the Gutenberg project with plugins via the Plugins API REST API Interaction Related to REST API [Status] In Progress Tracking issues with work in progress

Comments

@StevenDufresne
Copy link
Contributor

Describe the bug
Inactive block directory blocks should return as installable in the search results. The block should be activated if the user decides to click Add Block again.

This functionality was removed in the transition to using the WP_REST_Plugins_Controller in #22454.

This feature was initially introduce in #22286.

To reproduce
Steps to reproduce the behavior:

  1. Install a block from the directory (Boxer)
  2. Disable plugin via wp-admin/plugins.php
  3. Reload page
  4. Search for the same block
  5. Notice the result is not returned.

Expected behavior
See description.

Editor version (please complete the following information):

  • WordPress version: current master
@StevenDufresne StevenDufresne added [Feature] Plugins API Extending the Gutenberg project with plugins via the Plugins API [Feature] Block Directory Related to the Block Directory, a repository of block plugins labels Jun 30, 2020
@StevenDufresne
Copy link
Contributor Author

@TimothyBJacobs What do you think the best approach would be?

@TimothyBJacobs
Copy link
Member

I think we can just remove the find_plugin_for_slug from the block directory controller. There is already a wp:plugin link generated. So we could follow that link an do a PUT { status: active }.

@TimothyBJacobs TimothyBJacobs added the REST API Interaction Related to REST API label Jul 1, 2020
@TimothyBJacobs
Copy link
Member

I've implemented that for trunk here, WordPress/wordpress-develop@7946dc6

When the block is already installed, you get a response like this.

{
    "name": "cgb\/block-p5js",
    "title": "p5.js Block",
    "description": "p5.js + WordPress. Want to share some generative art on your own WordPress site? This is the plugin to make it happen. Add your custom p5.js code, and preview it...",
    "id": "wp-p5js-block",
    "rating": 5,
    "rating_count": 3,
    "active_installs": 100,
    "author_block_rating": 5,
    "author_block_count": 1,
    "author": "Mark Uraine",
    "icon": "https:\/\/ps.w.org\/wp-p5js-block\/assets\/icon-128x128.png?rev=2026902",
    "assets": [
      "https:\/\/ps.w.org\/wp-p5js-block\/trunk\/dist\/blocks.build.js?v=1590645660",
      "https:\/\/ps.w.org\/wp-p5js-block\/trunk\/dist\/blocks.style.build.css?v=1590645660",
      "https:\/\/ps.w.org\/wp-p5js-block\/trunk\/dist\/blocks.editor.build.css?v=1590645660"
    ],
    "last_updated": "2020-05-28T06:01:00",
    "humanized_updated": "1 month ago",
    "_links": {
      "wp:install-plugin": [
        {
          "href": "http:\/\/trunk.test\/wp-json\/wp\/v2\/plugins?slug=wp-p5js-block"
        }
      ],
      "wp:plugin": [
        {
          "embeddable": true,
          "href": "http:\/\/trunk.test\/wp-json\/wp\/v2\/plugins\/wp-p5js-block\/plugin"
        }
      ],
      "curies": [
        {
          "name": "wp",
          "href": "https:\/\/api.w.org\/{rel}",
          "templated": true
        }
      ]
    }
  }

@TimothyBJacobs
Copy link
Member

It would probably make sense to add an _embed=wp:plugin to the search request. That way you get the plugin details embedded.

{
    "name": "cgb\/block-p5js",
    "title": "p5.js Block",
    "description": "p5.js + WordPress. Want to share some generative art on your own WordPress site? This is the plugin to make it happen. Add your custom p5.js code, and preview it...",
    "id": "wp-p5js-block",
    "rating": 5,
    "rating_count": 3,
    "active_installs": 100,
    "author_block_rating": 5,
    "author_block_count": 1,
    "author": "Mark Uraine",
    "icon": "https:\/\/ps.w.org\/wp-p5js-block\/assets\/icon-128x128.png?rev=2026902",
    "assets": [
      "https:\/\/ps.w.org\/wp-p5js-block\/trunk\/dist\/blocks.build.js?v=1590645660",
      "https:\/\/ps.w.org\/wp-p5js-block\/trunk\/dist\/blocks.style.build.css?v=1590645660",
      "https:\/\/ps.w.org\/wp-p5js-block\/trunk\/dist\/blocks.editor.build.css?v=1590645660"
    ],
    "last_updated": "2020-05-28T06:01:00",
    "humanized_updated": "1 month ago",
    "_links": {
      "wp:install-plugin": [
        {
          "href": "http:\/\/trunk.test\/wp-json\/wp\/v2\/plugins?slug=wp-p5js-block"
        }
      ],
      "wp:plugin": [
        {
          "embeddable": true,
          "href": "http:\/\/trunk.test\/wp-json\/wp\/v2\/plugins\/wp-p5js-block\/plugin"
        }
      ],
      "curies": [
        {
          "name": "wp",
          "href": "https:\/\/api.w.org\/{rel}",
          "templated": true
        }
      ]
    },
    "_embedded": {
      "wp:plugin": [
        {
          "plugin": "wp-p5js-block\/plugin",
          "status": "active",
          "name": "p5.js Block",
          "plugin_uri": "https:\/\/github.com\/mapk\/p5js-block",
          "author": "Mark Uraine",
          "author_uri": "https:\/\/markuraine.com",
          "description": {
            "raw": "Add custom p5.js code into this Gutenberg block and preview it as you edit.",
            "rendered": "Add custom p5.js code into this Gutenberg block and preview it as you edit. <cite>By <a href=\"https:\/\/markuraine.com\">Mark Uraine<\/a>.<\/cite>"
          },
          "version": "1.1.0",
          "network_only": false,
          "requires_wp": "",
          "requires_php": "",
          "text_domain": "wp-p5js-block",
          "_links": {
            "self": [
              {
                "href": "http:\/\/trunk.test\/wp-json\/wp\/v2\/plugins\/wp-p5js-block\/plugin"
              }
            ]
          }
        }
      ]
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Directory Related to the Block Directory, a repository of block plugins [Feature] Plugins API Extending the Gutenberg project with plugins via the Plugins API REST API Interaction Related to REST API [Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants