-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
74 changed files
with
3,345 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
lib/compat/wordpress-6.4/class-gutenberg-rest-blocks-controller-6-4.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/** | ||
* Reusable blocks REST API: WP_REST_Blocks_Controller class | ||
* | ||
* @package WordPress | ||
* @subpackage REST_API | ||
* @since 5.0.0 | ||
*/ | ||
|
||
/** | ||
* Controller which provides a REST endpoint for the editor to read, create, | ||
* edit and delete reusable blocks. Blocks are stored as posts with the wp_block | ||
* post type. | ||
* | ||
* @since 5.0.0 | ||
* | ||
* @see WP_REST_Posts_Controller | ||
* @see WP_REST_Controller | ||
*/ | ||
class Gutenberg_REST_Blocks_Controller_6_4 extends Gutenberg_REST_Blocks_Controller { | ||
/** | ||
* Gets the link relations available for the post and current user. | ||
* | ||
* @since 6.4.0 Ensures that only users with `edit_terms` capability can add taxonomy terms. | ||
* | ||
* @param WP_Post $post Post object. | ||
* @param WP_REST_Request $request Request object. | ||
* @return array List of link relations. | ||
*/ | ||
protected function get_available_actions( $post, $request ) { | ||
if ( 'edit' !== $request['context'] ) { | ||
return array(); | ||
} | ||
|
||
$rels = array(); | ||
|
||
$post_type = get_post_type_object( $post->post_type ); | ||
|
||
if ( 'attachment' !== $this->post_type && current_user_can( $post_type->cap->publish_posts ) ) { | ||
$rels[] = 'https://api.w.org/action-publish'; | ||
} | ||
|
||
if ( current_user_can( 'unfiltered_html' ) ) { | ||
$rels[] = 'https://api.w.org/action-unfiltered-html'; | ||
} | ||
|
||
if ( 'post' === $post_type->name ) { | ||
if ( current_user_can( $post_type->cap->edit_others_posts ) && current_user_can( $post_type->cap->publish_posts ) ) { | ||
$rels[] = 'https://api.w.org/action-sticky'; | ||
} | ||
} | ||
|
||
if ( post_type_supports( $post_type->name, 'author' ) ) { | ||
if ( current_user_can( $post_type->cap->edit_others_posts ) ) { | ||
$rels[] = 'https://api.w.org/action-assign-author'; | ||
} | ||
} | ||
|
||
$taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) ); | ||
|
||
foreach ( $taxonomies as $tax ) { | ||
$tax_base = ! empty( $tax->rest_base ) ? $tax->rest_base : $tax->name; | ||
|
||
if ( current_user_can( $tax->cap->edit_terms ) ) { | ||
$rels[] = 'https://api.w.org/action-create-' . $tax_base; | ||
} | ||
|
||
if ( current_user_can( $tax->cap->assign_terms ) ) { | ||
$rels[] = 'https://api.w.org/action-assign-' . $tax_base; | ||
} | ||
} | ||
|
||
return $rels; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
lib/compat/wordpress-6.4/class-gutenberg-rest-pattern-categories-controller.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* Gutenberg_REST_Pattern_Categories_Controller class | ||
* | ||
* Extends the WP_REST_Terms_Controller to handle permissions of pattern categories. | ||
* | ||
* @package Gutenberg | ||
* @subpackage REST_API | ||
* @since 6.4.0 | ||
*/ | ||
|
||
/** | ||
* Extends the WP_REST_Terms_Controller to handle permissions of pattern categories. | ||
* | ||
* @access public | ||
*/ | ||
class Gutenberg_REST_Pattern_Categories_Controller extends WP_REST_Terms_Controller { | ||
/** | ||
* Make pattern categories behave more like a hierarchical taxonomy in terms of permissions. | ||
* Check the edit_terms cap to see whether term creation is possible. | ||
* | ||
* @since 6.4.0 | ||
* | ||
* @param WP_REST_Request $request Request object. | ||
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. | ||
*/ | ||
public function create_item_permissions_check( $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable | ||
if ( ! $this->check_is_taxonomy_allowed( $this->taxonomy ) ) { | ||
return false; | ||
} | ||
|
||
$taxonomy_obj = get_taxonomy( $this->taxonomy ); | ||
|
||
// Patterns categories are a flat hierarchy (like tags), but work more like post categories in terms of permissions. | ||
if ( ! current_user_can( $taxonomy_obj->cap->edit_terms ) ) { | ||
return new WP_Error( | ||
'rest_cannot_create', | ||
__( 'Sorry, you are not allowed to create terms in this taxonomy.' ), | ||
array( 'status' => rest_authorization_required_code() ) | ||
); | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* Dataviews custom post type and taxonomy. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Registers the `wp_dataviews` post type and the `wp_dataviews_type` taxonomy. | ||
*/ | ||
function _gutenberg_register_data_views_post_type() { | ||
register_post_type( | ||
'wp_dataviews', | ||
array( | ||
'label' => _x( 'Dataviews', 'post type general name', 'gutenberg' ), | ||
'description' => __( 'Post which stores the different data views configurations', 'gutenberg' ), | ||
'public' => false, | ||
'show_ui' => false, | ||
'show_in_rest' => true, | ||
'rewrite' => false, | ||
'capabilities' => array( | ||
'read' => 'edit_published_posts', | ||
// 'create_posts' => 'edit_published_posts', | ||
// 'edit_posts' => 'edit_published_posts', | ||
// 'edit_published_posts' => 'edit_published_posts', | ||
// 'delete_published_posts' => 'delete_published_posts', | ||
// 'edit_others_posts' => 'edit_others_posts', | ||
// 'delete_others_posts' => 'edit_theme_options', | ||
), | ||
'map_meta_cap' => true, | ||
'supports' => array( 'title', 'slug', 'editor' ), | ||
) | ||
); | ||
|
||
register_taxonomy( | ||
'wp_dataviews_type', | ||
array( 'wp_dataviews' ), | ||
array( | ||
'public' => true, | ||
'hierarchical' => false, | ||
'labels' => array( | ||
'name' => __( 'Dataview types', 'gutenberg' ), | ||
'singular_name' => __( 'Dataview type', 'gutenberg' ), | ||
), | ||
'rewrite' => false, | ||
'show_ui' => false, | ||
'show_in_nav_menus' => false, | ||
'show_in_rest' => true, | ||
) | ||
); | ||
} | ||
|
||
add_action( 'init', '_gutenberg_register_data_views_post_type' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.