Skip to content

Commit

Permalink
9.4.0 (#30)
Browse files Browse the repository at this point in the history
- Added new custom styles for Core blocks
  • Loading branch information
hrsetyono authored Nov 22, 2022
1 parent 7925104 commit 60ca042
Show file tree
Hide file tree
Showing 10 changed files with 336 additions and 53 deletions.
2 changes: 1 addition & 1 deletion dist/h-gutenberg.asset.php
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');
2 changes: 1 addition & 1 deletion dist/h-gutenberg.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/h-gutenberg.js

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

4 changes: 2 additions & 2 deletions edje-wp-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
* License: MIT
* Author: Pixel Studio
* Author URI: https://pixelstudio.id
* Version: 9.3.6
* Version: 9.4.0
*/

if (!defined('WPINC')) { die; } // exit if accessed directly

// Constant
define('H_VERSION', '9.3.6');
define('H_VERSION', '9.4.0');
define('H_BASE', basename(dirname(__FILE__)).'/'.basename(__FILE__));

define('H_DIR', __DIR__); // for require
Expand Down
44 changes: 0 additions & 44 deletions helper/utilities-deprecated.php
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']
]
);
}

61 changes: 59 additions & 2 deletions module-gutenberg/block-styles.php
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;
}
3 changes: 3 additions & 0 deletions module-gutenberg/src/h-gutenberg.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import './h-gutenberg.sass';
const { wp } = window;

wp.domReady(() => {
wp.blocks.unregisterBlockStyle('core/quote', 'plain');
wp.blocks.unregisterBlockStyle('core/image', 'rounded');

window.localizeH.disallowedBlocks.forEach((name) => {
wp.blocks.unregisterBlockType(name);
});
Expand Down
Loading

0 comments on commit 60ca042

Please sign in to comment.