diff --git a/.travis.yml b/.travis.yml index 45bea74..cadc534 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,40 @@ language: php - notifications: email: on_success: never on_failure: change - branches: only: - - master - - "/^v?[0-9\\.]+$/" - + - master + - "/^v?[0-9\\.]+$/" php: - '5.6' - '7.0' - '7.1' - '7.2' - '7.3' - before_script: - - composer install - +- composer install script: - - composer test +- composer test +before_deploy: + - echo 'Making deploy packages...' + - rm -rfv .git + - rm -rfv bin + - rm -rfv tests + - rm -rfv .gitignore + - rm -rfv .travis.yml + - rm -rfv vendor + - rm -rfv composer.lock + - rm -rfv phpunit.xml.dist + - zip -r wp-block-creator.zip ./ +deploy: + provider: releases + skip_cleanup: true + api_key: + secure: YY9TUHnSC4uxutv+qL1l5d7UqAEf/4goKfnKalMMV5KD8J0mlIRTXJubswFbuMYc6nlbpbI2niG+Cb0RZcnYSQldZ6ZTKuZb6c7ZQiSVZ/NAKmjxJU7pkmJ4mrjwYoXfIBie4fjcXkEjwszWaPxiXvIFs5AbGTG3mK0mVuIAga4urzWmcGwWxOu9tM0L2578HR+2Dglq7iQGR+VWqmfjjv6DAd7DZMye/1beYK6QboHVxiVl8et6uh2v2xyYRibiifZgSvmDq4L6W3gjc8HLl8s6XHoZEXu7Zgx3CBrzglRasljVf8e+/PkI70PUolY/LpX+q6zFltA1UXrZgcT6I9j/pDYj6QH5q5jIEBXOnJHzhUYHp7to5YPhYc6s3LpPkxYKfMZXIcy3vsQsvKS2yCwLivzaX446KghfEqQglrXM0D3MJi00RTs4XOys9gXG+0vPTt6faNgerKkPlGgbJbckZDWULUJAv+4M/x/033Qo1p/BQvoK8LskNPuX3kl4Isp3NOEi5vvOUbGG+KVv9KfHmLYK3Y7KMsWA2TlTdhdHtTG12LQTxwtX6XGEPkGHLzPuLB1uEqUx//l6/tPOYtJtwrmyQ/J4QTmkULcjb1elBSjj5jnCmI+LkXEB5s1F9QAweCJDmASitCBRlZrXmi3RxSkChO/zuDLlFN0WF/0= + file: wp-block-creator.zip + on: + repo: hametuha/wp-block-creator + tags: true + php: '7.0' diff --git a/README.md b/README.md index fbe05f6..08e99f1 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,11 @@ Now all block will be automatically included. You don't have to load 1 by 1. Add new block anytime you want. +Every JavaScripts and Stylesheets will be resgistered with the power of [wp-enqueue-manager](https://github.com/hametuha/wp-enqueue-manager). Write proper header like below: + + +For more details, see [README.md](https://github.com/hametuha/wp-enqueue-manager) of `wp-enqueue-manager`. + ## License GPL 3.0 or later. Compatible with WordPress. \ No newline at end of file diff --git a/composer.json b/composer.json index 130aacc..34979ff 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "require": { "php": "^5.6|^7.0", "hametuha/singleton-pattern": "^1.0", - "hametuha/string-utility": "^1.0", + "hametuha/string-utility": "^1.1", "hametuha/wp-enqueue-manager": "^1.0" }, "require-dev": { diff --git a/src/Hametuha/WpBlockCreator.php b/src/Hametuha/WpBlockCreator.php index b60976c..f1d6b7f 100644 --- a/src/Hametuha/WpBlockCreator.php +++ b/src/Hametuha/WpBlockCreator.php @@ -6,6 +6,11 @@ use Hametuha\WpBlockCreator\Pattern\AbstractBlock; use Symfony\Component\Finder\Finder; +/** + * Assets manager for WordPress. + * + * @package wp-block-creator + */ class WpBlockCreator { /** diff --git a/src/Hametuha/WpBlockCreator/Pattern/AbstractBlock.php b/src/Hametuha/WpBlockCreator/Pattern/AbstractBlock.php index d433f0b..0d1e45a 100644 --- a/src/Hametuha/WpBlockCreator/Pattern/AbstractBlock.php +++ b/src/Hametuha/WpBlockCreator/Pattern/AbstractBlock.php @@ -5,6 +5,7 @@ use Hametuha\SingletonPattern\Singleton; use Hametuha\StringUtility\NamingConventions; +use Hametuha\StringUtility\Path; /** * Abstract block. @@ -14,7 +15,7 @@ */ abstract class AbstractBlock extends Singleton { - use NamingConventions; + use NamingConventions, Path; protected $prefix = ''; @@ -32,6 +33,7 @@ protected function init() { if ( $this->disabled || ! function_exists( 'register_block_type' ) ) { return; } + add_action( 'init', [ $this, 'register_assets' ] ); add_action( 'init', [ $this, 'register_block' ] ); add_action( 'enqueue_block_assets', [ $this, 'enqueue_block_assets' ] ); add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_block_editor_assets' ] ); @@ -46,6 +48,15 @@ public function enqueue_block_assets() {} * Enqueue something only on editor. */ public function enqueue_block_editor_assets() {} + + /** + * Register scripts on init hook + * + * If registered scripts are required, override here. + */ + public function register_assets() { + do_action( 'hametuha_block_creator_register_assets', $this->get_block_base() ); + } /** * Register block. @@ -59,7 +70,7 @@ public function register_block() { if ( $style = $this->get_style() ) { $args['editor_style'] = $style; } - $args = $this->filter_attributes( $args ); + $args = apply_filters( 'hametuha_block_creator_attributes', $this->filter_attributes( $args ), $this->get_block_name() ); register_block_type( $this->get_block_name(), $args ); }