Skip to content

Commit

Permalink
AbstractBlock now ready for single use.
Browse files Browse the repository at this point in the history
  • Loading branch information
fumikito committed Sep 25, 2019
1 parent 7eb990b commit 66ff6c6
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 12 deletions.
34 changes: 25 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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'
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 5 additions & 0 deletions src/Hametuha/WpBlockCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
use Hametuha\WpBlockCreator\Pattern\AbstractBlock;
use Symfony\Component\Finder\Finder;

/**
* Assets manager for WordPress.
*
* @package wp-block-creator
*/
class WpBlockCreator {

/**
Expand Down
15 changes: 13 additions & 2 deletions src/Hametuha/WpBlockCreator/Pattern/AbstractBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Hametuha\SingletonPattern\Singleton;
use Hametuha\StringUtility\NamingConventions;
use Hametuha\StringUtility\Path;

/**
* Abstract block.
Expand All @@ -14,7 +15,7 @@
*/
abstract class AbstractBlock extends Singleton {

use NamingConventions;
use NamingConventions, Path;

protected $prefix = '';

Expand All @@ -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' ] );
Expand All @@ -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.
Expand All @@ -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 );
}

Expand Down

0 comments on commit 66ff6c6

Please sign in to comment.