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

PHPCS-specific improvements #2914

Merged
merged 5 commits into from
Oct 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions blocks/library/categories/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ function gutenberg_render_block_core_categories( $attributes ) {
);

if ( ! empty( $attributes['displayAsDropdown'] ) ) {
$id = 'wp-block-categories-' . $block_id;
$args['id'] = $id;
$id = 'wp-block-categories-' . $block_id;
$args['id'] = $id;
$args['show_option_none'] = __( 'Select Category', 'gutenberg' );
$wrapper_markup = '<div class="%1$s">%2$s</div>';
$items_markup = wp_dropdown_categories( $args );
$type = 'dropdown';
$wrapper_markup = '<div class="%1$s">%2$s</div>';
$items_markup = wp_dropdown_categories( $args );
$type = 'dropdown';

if ( ! is_admin() ) {
$wrapper_markup .= gutenberg_build_dropdown_script_block_core_categories( $id );
}
} else {
$wrapper_markup = '<div class="%1$s"><ul>%2$s</ul></div>';
$items_markup = wp_list_categories( $args );
$type = 'list';
$items_markup = wp_list_categories( $args );
$type = 'list';
}

$class = "wp-block-categories wp-block-categories-{$type} align{$align}";
Expand Down
21 changes: 10 additions & 11 deletions blocks/library/latest-posts/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,27 @@ function gutenberg_render_block_core_latest_posts( $attributes ) {
}

register_block_type( 'core/latest-posts', array(
'attributes' => array(
'postsToShow' => array(
'type' => 'number',
'attributes' => array(
'postsToShow' => array(
'type' => 'number',
'default' => 5,
),
'displayPostDate' => array(
'type' => 'boolean',
'type' => 'boolean',
'default' => false,
),
'layout' => array(
'type' => 'string',
'layout' => array(
'type' => 'string',
'default' => 'list',
),
'columns' => array(
'type' => 'number',
'columns' => array(
'type' => 'number',
'default' => 3,
),
'align' => array(
'type' => 'string',
'align' => array(
'type' => 'string',
'default' => 'center',
),
),

'render_callback' => 'gutenberg_render_block_core_latest_posts',
) );
38 changes: 20 additions & 18 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ function do_blocks( $content ) {
$content_after_blocks = '';

foreach ( $blocks as $block ) {
$block_name = isset( $block['blockName'] ) ? $block['blockName'] : null;
$attributes = is_array( $block['attrs'] ) ? $block['attrs'] : array();
$block_name = isset( $block['blockName'] ) ? $block['blockName'] : null;
$attributes = is_array( $block['attrs'] ) ? $block['attrs'] : array();
$raw_content = isset( $block['rawContent'] ) ? $block['rawContent'] : null;

if ( $block_name ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/class-wp-block-type-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function register( $name, $args = array() ) {
$block_type = null;
if ( is_a( $name, 'WP_Block_Type' ) ) {
$block_type = $name;
$name = $block_type->name;
$name = $block_type->name;
}

if ( ! is_string( $name ) ) {
Expand Down
48 changes: 24 additions & 24 deletions lib/class-wp-rest-reusable-blocks-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function get_items( $request ) {
$collection = array();

foreach ( $reusable_blocks as $reusable_block ) {
$response = $this->prepare_item_for_response( $reusable_block, $request );
$response = $this->prepare_item_for_response( $reusable_block, $request );
$collection[] = $this->prepare_response_for_collection( $response );
}

Expand Down Expand Up @@ -219,7 +219,7 @@ protected function prepare_item_for_database( $request ) {
$prepared_reusable_block->ID = $existing_reusable_block->ID;
}

$prepared_reusable_block->post_type = 'gb_reusable_block';
$prepared_reusable_block->post_type = 'gb_reusable_block';
$prepared_reusable_block->post_status = 'publish';

// ID. We already validated this in self::update_item().
Expand Down Expand Up @@ -258,8 +258,8 @@ protected function prepare_item_for_database( $request ) {
*/
public function prepare_item_for_response( $reusable_block, $request ) {
$data = array(
'id' => $reusable_block->post_name,
'name' => $reusable_block->post_title,
'id' => $reusable_block->post_name,
'name' => $reusable_block->post_title,
'content' => $reusable_block->post_content,
);

Expand Down Expand Up @@ -289,27 +289,27 @@ public function prepare_response_for_collection( $response ) {
*/
public function get_item_schema() {
return array(
'$schema' => 'http://json-schema.org/schema#',
'title' => 'reusable-block',
'type' => 'object',
'properties' => array(
'id' => array(
'description' => __( 'UUID that identifies this reusable block.', 'gutenberg' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
'$schema' => 'http://json-schema.org/schema#',
'title' => 'reusable-block',
'type' => 'object',
'properties' => array(
'id' => array(
'description' => __( 'UUID that identifies this reusable block.', 'gutenberg' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'name' => array(
'description' => __( 'Name that identifies this reusable block', 'gutenberg' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'required' => true,
'name' => array(
'description' => __( 'Name that identifies this reusable block', 'gutenberg' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'required' => true,
),
'content' => array(
'description' => __( 'The block\'s HTML content.', 'gutenberg' ),
'type' => 'object',
'context' => array( 'view', 'edit' ),
'required' => true,
'content' => array(
'description' => __( 'The block\'s HTML content.', 'gutenberg' ),
'type' => 'object',
'context' => array( 'view', 'edit' ),
'required' => true,
),
),
);
Expand All @@ -328,7 +328,7 @@ public function get_item_schema() {
private function get_reusable_block( $uuid ) {
$reusable_blocks = get_posts( array(
'post_type' => 'gb_reusable_block',
'name' => $uuid,
'name' => $uuid,
) );

return array_shift( $reusable_blocks );
Expand Down
Loading