{"action":"created","comment":{"url":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments/210746003","pull_request_review_id":147028933,"id":210746003,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMDc0NjAwMw==","diff_hunk":"@@ -394,6 +394,33 @@ function gutenberg_content_has_blocks( $content ) {\n \treturn has_blocks( $content );\n }\n \n+/**\n+ * Determine whether a $post or a string contains a specific block type.\n+ * This test optimizes for performance rather than strict accuracy, detecting\n+ * the block type exists but not validating its structure.\n+ * For strict accuracy, you should use the block parser on post content.\n+ *\n+ * @since 3.6.0\n+ *\n+ * @param string                  $block_type Full Block type to look for.\n+ * @param int|string|WP_Post|null $post Optional. Post content, post ID, or post object. Defaults to global $post.\n+ * @return bool Whether the post content contains the specified block.\n+ */\n+function has_block( $block_type, $post = null ) {\n+\tif ( ! is_string( $post ) ) {\n+\t\t$wp_post = get_post( $post );\n+\t\tif ( $wp_post instanceof WP_Post ) {\n+\t\t\t$post = $wp_post->post_content;\n+\t\t}\n+\t}\n+\n+\tif ( ! has_blocks( $post ) ) {","path":"lib/register.php","position":42,"original_position":42,"commit_id":"5f5d6468aebcadd061060efbb260bcdae997dd77","original_commit_id":"5f5d6468aebcadd061060efbb260bcdae997dd77","user":{"login":"obenland","id":1398304,"node_id":"MDQ6VXNlcjEzOTgzMDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1398304?v=4","gravatar_id":"","url":"https://api.github.com/users/obenland","html_url":"https://github.com/obenland","followers_url":"https://api.github.com/users/obenland/followers","following_url":"https://api.github.com/users/obenland/following{/other_user}","gists_url":"https://api.github.com/users/obenland/gists{/gist_id}","starred_url":"https://api.github.com/users/obenland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obenland/subscriptions","organizations_url":"https://api.github.com/users/obenland/orgs","repos_url":"https://api.github.com/users/obenland/repos","events_url":"https://api.github.com/users/obenland/events{/privacy}","received_events_url":"https://api.github.com/users/obenland/received_events","type":"User","site_admin":false},"body":"This check could probably moved to the top of the function. If there are no blocks, getting the post before hand seems superfluous.","created_at":"2018-08-16T21:21:59Z","updated_at":"2018-08-16T21:26:02Z","html_url":"https://github.com/WordPress/gutenberg/pull/9058#discussion_r210746003","pull_request_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/9058","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments/210746003"},"html":{"href":"https://github.com/WordPress/gutenberg/pull/9058#discussion_r210746003"},"pull_request":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/9058"}}},"pull_request":{"url":"https://api.github.com/repos/WordPress/gutenberg/pulls/9058","id":208960108,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA4OTYwMTA4","html_url":"https://github.com/WordPress/gutenberg/pull/9058","diff_url":"https://github.com/WordPress/gutenberg/pull/9058.diff","patch_url":"https://github.com/WordPress/gutenberg/pull/9058.patch","issue_url":"https://api.github.com/repos/WordPress/gutenberg/issues/9058","number":9058,"state":"open","locked":false,"title":"Add has_block function and unit tests for it","user":{"login":"andreilupu","id":1893980,"node_id":"MDQ6VXNlcjE4OTM5ODA=","avatar_url":"https://avatars1.githubusercontent.com/u/1893980?v=4","gravatar_id":"","url":"https://api.github.com/users/andreilupu","html_url":"https://github.com/andreilupu","followers_url":"https://api.github.com/users/andreilupu/followers","following_url":"https://api.github.com/users/andreilupu/following{/other_user}","gists_url":"https://api.github.com/users/andreilupu/gists{/gist_id}","starred_url":"https://api.github.com/users/andreilupu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreilupu/subscriptions","organizations_url":"https://api.github.com/users/andreilupu/orgs","repos_url":"https://api.github.com/users/andreilupu/repos","events_url":"https://api.github.com/users/andreilupu/events{/privacy}","received_events_url":"https://api.github.com/users/andreilupu/received_events","type":"User","site_admin":false},"body":"## Description\r\nA refresh for #8340 \r\n\r\n## How has this been tested?\r\n<!-- Please describe in detail how you tested your changes. -->\r\n<!-- Include details of your testing environment, tests ran to see how -->\r\n<!-- your change affects other areas of the code, etc. -->\r\n\r\n## Screenshots <!-- if applicable -->\r\n\r\n## Types of changes\r\n<!-- What types of changes does your code introduce?  -->\r\n<!-- Bug fix (non-breaking change which fixes an issue) -->\r\n<!-- New feature (non-breaking change which adds functionality) -->\r\n<!-- Breaking change (fix or feature that would cause existing functionality to not work as expected) -->\r\n\r\n## Checklist:\r\n- [x] My code is tested.\r\n- [x] My code follows the WordPress code style. <!-- Check code: `npm run lint`, Guidelines: https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/ -->\r\n- [x] My code follows the accessibility standards. <!-- Guidelines: https://make.wordpress.org/core/handbook/best-practices/coding-standards/accessibility-coding-standards/ -->\r\n- [x] My code has proper inline documentation. <!-- Guidelines: https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/javascript/ -->\r\n","created_at":"2018-08-16T19:26:55Z","updated_at":"2018-08-16T21:26:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8123bc2c6f04565a3b22ad663c8d6f6c32647610","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/9058/commits","review_comments_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/9058/comments","review_comment_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/issues/9058/comments","statuses_url":"https://api.github.com/repos/WordPress/gutenberg/statuses/5f5d6468aebcadd061060efbb260bcdae997dd77","head":{"label":"andreilupu:3773-add-has-block-functions-rebase","ref":"3773-add-has-block-functions-rebase","sha":"5f5d6468aebcadd061060efbb260bcdae997dd77","user":{"login":"andreilupu","id":1893980,"node_id":"MDQ6VXNlcjE4OTM5ODA=","avatar_url":"https://avatars1.githubusercontent.com/u/1893980?v=4","gravatar_id":"","url":"https://api.github.com/users/andreilupu","html_url":"https://github.com/andreilupu","followers_url":"https://api.github.com/users/andreilupu/followers","following_url":"https://api.github.com/users/andreilupu/following{/other_user}","gists_url":"https://api.github.com/users/andreilupu/gists{/gist_id}","starred_url":"https://api.github.com/users/andreilupu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreilupu/subscriptions","organizations_url":"https://api.github.com/users/andreilupu/orgs","repos_url":"https://api.github.com/users/andreilupu/repos","events_url":"https://api.github.com/users/andreilupu/events{/privacy}","received_events_url":"https://api.github.com/users/andreilupu/received_events","type":"User","site_admin":false},"repo":{"id":118641225,"node_id":"MDEwOlJlcG9zaXRvcnkxMTg2NDEyMjU=","name":"gutenberg","full_name":"andreilupu/gutenberg","owner":{"login":"andreilupu","id":1893980,"node_id":"MDQ6VXNlcjE4OTM5ODA=","avatar_url":"https://avatars1.githubusercontent.com/u/1893980?v=4","gravatar_id":"","url":"https://api.github.com/users/andreilupu","html_url":"https://github.com/andreilupu","followers_url":"https://api.github.com/users/andreilupu/followers","following_url":"https://api.github.com/users/andreilupu/following{/other_user}","gists_url":"https://api.github.com/users/andreilupu/gists{/gist_id}","starred_url":"https://api.github.com/users/andreilupu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreilupu/subscriptions","organizations_url":"https://api.github.com/users/andreilupu/orgs","repos_url":"https://api.github.com/users/andreilupu/repos","events_url":"https://api.github.com/users/andreilupu/events{/privacy}","received_events_url":"https://api.github.com/users/andreilupu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andreilupu/gutenberg","description":"Printing since 1440. Development hub for the editor focus in core. Beta plugin is available from the official WordPress repository.","fork":true,"url":"https://api.github.com/repos/andreilupu/gutenberg","forks_url":"https://api.github.com/repos/andreilupu/gutenberg/forks","keys_url":"https://api.github.com/repos/andreilupu/gutenberg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andreilupu/gutenberg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andreilupu/gutenberg/teams","hooks_url":"https://api.github.com/repos/andreilupu/gutenberg/hooks","issue_events_url":"https://api.github.com/repos/andreilupu/gutenberg/issues/events{/number}","events_url":"https://api.github.com/repos/andreilupu/gutenberg/events","assignees_url":"https://api.github.com/repos/andreilupu/gutenberg/assignees{/user}","branches_url":"https://api.github.com/repos/andreilupu/gutenberg/branches{/branch}","tags_url":"https://api.github.com/repos/andreilupu/gutenberg/tags","blobs_url":"https://api.github.com/repos/andreilupu/gutenberg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andreilupu/gutenberg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andreilupu/gutenberg/git/refs{/sha}","trees_url":"https://api.github.com/repos/andreilupu/gutenberg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andreilupu/gutenberg/statuses/{sha}","languages_url":"https://api.github.com/repos/andreilupu/gutenberg/languages","stargazers_url":"https://api.github.com/repos/andreilupu/gutenberg/stargazers","contributors_url":"https://api.github.com/repos/andreilupu/gutenberg/contributors","subscribers_url":"https://api.github.com/repos/andreilupu/gutenberg/subscribers","subscription_url":"https://api.github.com/repos/andreilupu/gutenberg/subscription","commits_url":"https://api.github.com/repos/andreilupu/gutenberg/commits{/sha}","git_commits_url":"https://api.github.com/repos/andreilupu/gutenberg/git/commits{/sha}","comments_url":"https://api.github.com/repos/andreilupu/gutenberg/comments{/number}","issue_comment_url":"https://api.github.com/repos/andreilupu/gutenberg/issues/comments{/number}","contents_url":"https://api.github.com/repos/andreilupu/gutenberg/contents/{+path}","compare_url":"https://api.github.com/repos/andreilupu/gutenberg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andreilupu/gutenberg/merges","archive_url":"https://api.github.com/repos/andreilupu/gutenberg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andreilupu/gutenberg/downloads","issues_url":"https://api.github.com/repos/andreilupu/gutenberg/issues{/number}","pulls_url":"https://api.github.com/repos/andreilupu/gutenberg/pulls{/number}","milestones_url":"https://api.github.com/repos/andreilupu/gutenberg/milestones{/number}","notifications_url":"https://api.github.com/repos/andreilupu/gutenberg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andreilupu/gutenberg/labels{/name}","releases_url":"https://api.github.com/repos/andreilupu/gutenberg/releases{/id}","deployments_url":"https://api.github.com/repos/andreilupu/gutenberg/deployments","created_at":"2018-01-23T17:00:41Z","updated_at":"2018-07-31T20:29:55Z","pushed_at":"2018-08-16T18:58:06Z","git_url":"git://github.com/andreilupu/gutenberg.git","ssh_url":"git@github.com:andreilupu/gutenberg.git","clone_url":"https://github.com/andreilupu/gutenberg.git","svn_url":"https://github.com/andreilupu/gutenberg","homepage":"https://wordpress.org/plugins/gutenberg/ ","size":20371,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"WordPress:master","ref":"master","sha":"72da0cd7c358c5ffda63305e45183c0dcf3c21a7","user":{"login":"WordPress","id":276006,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI3NjAwNg==","avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"repo":{"id":80862584,"node_id":"MDEwOlJlcG9zaXRvcnk4MDg2MjU4NA==","name":"gutenberg","full_name":"WordPress/gutenberg","owner":{"login":"WordPress","id":276006,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI3NjAwNg==","avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WordPress/gutenberg","description":"Printing since 1440. Development hub for the editor focus in core. Beta plugin is available from the official WordPress repository.","fork":false,"url":"https://api.github.com/repos/WordPress/gutenberg","forks_url":"https://api.github.com/repos/WordPress/gutenberg/forks","keys_url":"https://api.github.com/repos/WordPress/gutenberg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WordPress/gutenberg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WordPress/gutenberg/teams","hooks_url":"https://api.github.com/repos/WordPress/gutenberg/hooks","issue_events_url":"https://api.github.com/repos/WordPress/gutenberg/issues/events{/number}","events_url":"https://api.github.com/repos/WordPress/gutenberg/events","assignees_url":"https://api.github.com/repos/WordPress/gutenberg/assignees{/user}","branches_url":"https://api.github.com/repos/WordPress/gutenberg/branches{/branch}","tags_url":"https://api.github.com/repos/WordPress/gutenberg/tags","blobs_url":"https://api.github.com/repos/WordPress/gutenberg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WordPress/gutenberg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WordPress/gutenberg/git/refs{/sha}","trees_url":"https://api.github.com/repos/WordPress/gutenberg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WordPress/gutenberg/statuses/{sha}","languages_url":"https://api.github.com/repos/WordPress/gutenberg/languages","stargazers_url":"https://api.github.com/repos/WordPress/gutenberg/stargazers","contributors_url":"https://api.github.com/repos/WordPress/gutenberg/contributors","subscribers_url":"https://api.github.com/repos/WordPress/gutenberg/subscribers","subscription_url":"https://api.github.com/repos/WordPress/gutenberg/subscription","commits_url":"https://api.github.com/repos/WordPress/gutenberg/commits{/sha}","git_commits_url":"https://api.github.com/repos/WordPress/gutenberg/git/commits{/sha}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/comments{/number}","issue_comment_url":"https://api.github.com/repos/WordPress/gutenberg/issues/comments{/number}","contents_url":"https://api.github.com/repos/WordPress/gutenberg/contents/{+path}","compare_url":"https://api.github.com/repos/WordPress/gutenberg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WordPress/gutenberg/merges","archive_url":"https://api.github.com/repos/WordPress/gutenberg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WordPress/gutenberg/downloads","issues_url":"https://api.github.com/repos/WordPress/gutenberg/issues{/number}","pulls_url":"https://api.github.com/repos/WordPress/gutenberg/pulls{/number}","milestones_url":"https://api.github.com/repos/WordPress/gutenberg/milestones{/number}","notifications_url":"https://api.github.com/repos/WordPress/gutenberg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WordPress/gutenberg/labels{/name}","releases_url":"https://api.github.com/repos/WordPress/gutenberg/releases{/id}","deployments_url":"https://api.github.com/repos/WordPress/gutenberg/deployments","created_at":"2017-02-03T19:34:19Z","updated_at":"2018-08-16T19:29:38Z","pushed_at":"2018-08-16T21:16:33Z","git_url":"git://github.com/WordPress/gutenberg.git","ssh_url":"git@github.com:WordPress/gutenberg.git","clone_url":"https://github.com/WordPress/gutenberg.git","svn_url":"https://github.com/WordPress/gutenberg","homepage":"https://wordpress.org/plugins/gutenberg/ ","size":20947,"stargazers_count":3039,"watchers_count":3039,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":791,"mirror_url":null,"archived":false,"open_issues_count":1226,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":791,"open_issues":1226,"watchers":3039,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/9058"},"html":{"href":"https://github.com/WordPress/gutenberg/pull/9058"},"issue":{"href":"https://api.github.com/repos/WordPress/gutenberg/issues/9058"},"comments":{"href":"https://api.github.com/repos/WordPress/gutenberg/issues/9058/comments"},"review_comments":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/9058/comments"},"review_comment":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/9058/commits"},"statuses":{"href":"https://api.github.com/repos/WordPress/gutenberg/statuses/5f5d6468aebcadd061060efbb260bcdae997dd77"}},"author_association":"NONE"}}
{"actor":{"display_login":"obenland"}}