| @@ -23,23 +23,8 @@ | ||
| 23 | 23 | * @return array Blocks to Register |
| 24 | 24 | */ |
| 25 | 25 | public function register( $blocks ) { |
| 26 | 26 | |
| 27 | - // If the request is for the frontend, return the minimum block definition required | |
| 28 | - // to register and render the block on the frontend site using register_block_type(). | |
| 29 | - if ( ! $this->is_admin_frontend_editor_or_admin_rest_request() ) { | |
| 30 | - $blocks[ $this->get_name() ] = array( | |
| 31 | - 'title' => $this->get_title(), | |
| 32 | - 'icon' => $this->get_icon(), | |
| 33 | - 'attributes' => $this->get_attributes(), | |
| 34 | - 'render_callback' => array( $this, 'render' ), | |
| 35 | - ); | |
| 36 | - | |
| 37 | - return $blocks; | |
| 38 | - } | |
| 39 | - | |
| 40 | - // Request is for the WordPress Administration, frontend editor or REST API request. | |
| 41 | - // Register the full block definition, including fields, panels, default values and supports. | |
| 42 | 27 | $blocks[ $this->get_name() ] = array_merge( |
| 43 | 28 | $this->get_overview(), |
| 44 | 29 | array( |
| 45 | 30 | 'name' => $this->get_name(), |
| @@ -72,30 +57,8 @@ | ||
| 72 | 57 | |
| 73 | 58 | } |
| 74 | 59 | |
| 75 | 60 | /** |
| 76 | - * Returns this block's title. | |
| 77 | - * | |
| 78 | - * @since 3.1.1 | |
| 79 | - */ | |
| 80 | - public function get_title() { | |
| 81 | - | |
| 82 | - return ''; | |
| 83 | - | |
| 84 | - } | |
| 85 | - | |
| 86 | - /** | |
| 87 | - * Returns this block's icon. | |
| 88 | - * | |
| 89 | - * @since 3.1.1 | |
| 90 | - */ | |
| 91 | - public function get_icon() { | |
| 92 | - | |
| 93 | - return ''; | |
| 94 | - | |
| 95 | - } | |
| 96 | - | |
| 97 | - /** | |
| 98 | 61 | * Returns this block's Title, Icon, Categories, Keywords and properties. |
| 99 | 62 | * |
| 100 | 63 | * @since 1.9.6 |
| 101 | 64 | * |
| @@ -432,18 +395,17 @@ | ||
| 432 | 395 | |
| 433 | 396 | } |
| 434 | 397 | |
| 435 | 398 | /** |
| 436 | - * Determines if the request is a WordPress REST API request | |
| 437 | - * made by a logged in WordPress user who has the capability to edit posts. | |
| 399 | + * Determines if the request is a WordPress REST API request. | |
| 438 | 400 | * |
| 439 | 401 | * @since 3.1.0 |
| 440 | 402 | * |
| 441 | 403 | * @return bool |
| 442 | 404 | */ |
| 443 | - public function is_admin_rest_request() { | |
| 405 | + public function is_rest_request() { | |
| 444 | 406 | |
| 445 | - return defined( 'REST_REQUEST' ) && REST_REQUEST && current_user_can( 'edit_posts' ); | |
| 407 | + return defined( 'REST_REQUEST' ) && REST_REQUEST; | |
| 446 | 408 | |
| 447 | 409 | } |
| 448 | 410 | |
| 449 | 411 | /** |
| @@ -452,11 +414,11 @@ | ||
| 452 | 414 | * @since 3.1.0 |
| 453 | 415 | * |
| 454 | 416 | * @return bool |
| 455 | 417 | */ |
| 456 | - public function is_admin_frontend_editor_or_admin_rest_request() { | |
| 418 | + public function is_admin_frontend_editor_or_rest_request() { | |
| 457 | 419 | |
| 458 | - return WP_ConvertKit()->is_admin_or_frontend_editor() || $this->is_admin_rest_request(); | |
| 420 | + return WP_ConvertKit()->is_admin_or_frontend_editor() || $this->is_rest_request(); | |
| 459 | 421 | |
| 460 | 422 | } |
| 461 | 423 | |
| 462 | 424 | /** |
| @@ -468,9 +430,9 @@ | ||
| 468 | 430 | */ |
| 469 | 431 | public function is_block_editor_request() { |
| 470 | 432 | |
| 471 | 433 | // Return false if not a WordPress REST API request, which Gutenberg uses. |
| 472 | - if ( ! $this->is_admin_rest_request() ) { | |
| 434 | + if ( ! $this->is_rest_request() ) { | |
| 473 | 435 | return false; |
| 474 | 436 | } |
| 475 | 437 | |
| 476 | 438 | // Return false if the context parameter isn't edit. |