-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added new custom styles for Core blocks
- Loading branch information
Showing
10 changed files
with
336 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array('wp-polyfill'), 'version' => 'c44c041231f027435c7c67afa5ab38c7'); | ||
<?php return array('dependencies' => array('wp-polyfill'), 'version' => 'e66069de82fc0e4383d4f247fb5c6c6b'); |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1 @@ | ||
<?php | ||
|
||
/** | ||
* Register GET route. Can only be used in `rest_api_init` action. | ||
* | ||
* `H::register_GET_route( '/sample/:id', 'callback' );` | ||
* | ||
* @deprecated - Just use the original register_rest_route() | ||
*/ | ||
function h_register_GET_route(string $path, $callback) { | ||
global $h_api_namespace; | ||
$path = preg_replace('/(:)(.+)/', '(?P<$2>.+)', $path); | ||
|
||
register_rest_route( | ||
$h_api_namespace, | ||
$path, | ||
[ | ||
'methods' => 'GET', | ||
'callback' => $args['callback'] | ||
] | ||
); | ||
} | ||
|
||
|
||
/** | ||
* Register POST route. Can only be used in `rest_api_init` action. | ||
* | ||
* `H::register_POST_route( '/sample/:id', 'callback' );` | ||
* | ||
* @deprecated - Just use the original register_rest_route() | ||
*/ | ||
function h_register_POST_route(string $path, $callback) { | ||
global $h_api_namespace; | ||
$path = preg_replace('/(:)(.+)/', '(?P<$2>.+)', $path); | ||
|
||
register_rest_route( | ||
$h_api_namespace, | ||
$path, | ||
[ | ||
'methods' => 'POST', | ||
'callback' => $args['callback'] | ||
] | ||
); | ||
} | ||
|
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 |
---|---|---|
@@ -1,8 +1,65 @@ | ||
<?php | ||
|
||
register_block_style('core/button', [ 'name' => 'h-transparent', 'label' => 'Transparent' ]); | ||
// TEXT | ||
register_block_style('core/paragraph', [ 'name' => 'h-no-spacing', 'label' => 'No Spacing' ]); | ||
|
||
register_block_style('core/heading', [ 'name' => 'h-no-spacing', 'label' => 'No Spacing' ]); | ||
|
||
register_block_style('core/table', [ 'name' => 'h-full-color', 'label' => 'Full Color' ]); | ||
|
||
register_block_style('core/quote', [ 'name' => 'h-timeline', 'label' => 'Timeline' ]); | ||
|
||
register_block_style('core/quote', [ 'name' => 'h-testimony', 'label' => 'Testimony' ]); | ||
|
||
// DESIGN | ||
register_block_style('core/button', [ 'name' => 'h-transparent', 'label' => 'Transparent' ]); | ||
|
||
register_block_style('core/columns', [ 'name' => 'h-wide-gap', 'label' => 'Wide Gap' ]); | ||
|
||
register_block_style('core/columns', [ 'name' => 'h-no-gap', 'label' => 'No Gap' ]); | ||
|
||
register_block_style('core/spacer', [ 'name' => 'h-negative', 'label' => 'Negative' ]); | ||
add_filter('render_block_core/spacer', '_h_block_spacer_negative', 10, 2); | ||
|
||
// MEDIA | ||
register_block_style('core/gallery', [ 'name' => 'h-thumbnails', 'label' => 'Thumbnails' ]); | ||
register_block_style('core/image', [ 'name' => 'h-thumbnail-wide', 'label' => 'Thumbnail Wide' ]); | ||
register_block_style('core/image', [ 'name' => 'h-thumbnail-tall', 'label' => 'Thumbnail Tall' ]); | ||
|
||
register_block_style('core/media-text', [ 'name' => 'h-larger-image', 'label' => 'Larger Image' ]); | ||
register_block_style('core/media-text', [ 'name' => 'h-smaller-image', 'label' => 'Smaller Image' ]); | ||
|
||
register_block_style('core/media-text', [ 'name' => 'h-smaller-image', 'label' => 'Smaller Image' ]); | ||
|
||
register_block_style('core/cover', [ 'name' => 'h-below-header', 'label' => 'Below Header' ]); | ||
add_filter('body_class', '_h_body_class_cover_below_header'); | ||
|
||
|
||
/** | ||
* Modify the height into margin-bottom | ||
* | ||
* @filter render_block_core/spacer | ||
*/ | ||
function _h_block_spacer_negative($content, $block) { | ||
$is_negative = isset($block['attrs']['className']) | ||
&& str_contains($block['attrs']['className'], 'is-style-h-negative'); | ||
|
||
if ($is_negative) { | ||
$content = preg_replace('/height:(\d+)/', 'margin-bottom:-$1', $content); | ||
} | ||
return $content; | ||
} | ||
|
||
/** | ||
* Add extra class if using Cover with Below Header style | ||
* | ||
* @filter body_class | ||
*/ | ||
function _h_body_class_cover_below_header($classes) { | ||
global $post; | ||
preg_match('/wp-block-cover.+is-style-h-below-header/', $post->post_content, $matches); | ||
|
||
if ($matches) { | ||
$classes[] = 'h-has-cover-below-header'; | ||
} | ||
return $classes; | ||
} |
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.