Skip to content
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
5 changes: 5 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
.github
assets
node_modules
src
vendor
.distignore
.editorconfig
.eslintrc.js
.gitignore
.phpcs.xml.dist
.prettierrc.js
composer.json
composer.lock
package-lock.json
package.json
phpstan.neon.dist
webpack.config.js
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ The "Controls ID" entered in this panel must match the "HTML anchor" assigned to

## Changelog

### 0.4.0

* Add an attribute to toggle a toggle block-specific class on the body element.
* Allow the toggle block to be placed inside the `core/navigation` block.
* Add transform support from/to `core/navigation-link` blocks.
* Update to latest dependencies, build process, and code standards.

### 0.3.1

* Add persisting `toggle-block-has-been-toggled` class to toggled element when first toggled.
Expand Down
2 changes: 1 addition & 1 deletion build/toggle-block/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"file:view.js"
],
"style": [
"file:../src/view.css"
"file:view.css"
],
"attributes": {
"bodyClass": {
Expand Down
2 changes: 1 addition & 1 deletion build/toggle-block/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-hooks', 'wp-i18n'), 'version' => '1b8472592ef953dd9320');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-hooks', 'wp-i18n'), 'version' => 'bff6c727c01bcb9ce96f');
2 changes: 1 addition & 1 deletion build/toggle-block/index.js

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

7 changes: 7 additions & 0 deletions build/toggle-block/view.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.wp-site-blocks .toggle-block-hidden {
display: none;
}

.editor-styles-wrapper .wp-block-happyprime-toggle-block {
display: inline-block;
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "happyprime/toggle-block",
"description": "Add a toggle to show and hide another block.",
"version": "0.3.1",
"version": "0.4.0",
"type": "wordpress-plugin",
"minimum-stability": "stable",
"license": "GPLv2-or-later",
Expand Down
2 changes: 1 addition & 1 deletion 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 package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "toggle-block",
"version": "0.3.1",
"version": "0.4.0",
"description": "Add a toggle to show and hide another block",
"author": "Happy Prime",
"license": "GPL-2.0-or-later",
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
includes:
- %rootDir%/../../happyprime/coding-standards/phpstan.neon.dist

parameters:
level: 9
12 changes: 6 additions & 6 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Toggle Block
* Description: Add a toggle to show and hide another block.
* Version: 0.3.1
* Version: 0.4.0
* Plugin URI: https://github.com/happyprime/toggle-block/
* Author: Happy Prime
* Author URI: https://happyprime.co
Expand Down Expand Up @@ -31,21 +31,21 @@
/**
* Register the block.
*/
function register() {
function register(): void {
register_block_type_from_metadata( __DIR__ . '/build/toggle-block' );
}

/**
* Ensure the block's view script is output in document footer.
*/
function alter_view_script() {
$asset_data = require __DIR__ . '/build/toggle-block/view.asset.php';
function alter_view_script(): void {
wp_deregister_script( 'happyprime-toggle-block-view-script' );

wp_register_script(
'happyprime-toggle-block-view-script',
plugins_url( 'build/toggle-block/view.js', __FILE__ ),
$asset_data['dependencies'],
filemtime( __DIR__ . '/build/toggle-block/view.js' ),
[],
(string) filemtime( __DIR__ . '/build/toggle-block/view.js' ),
true
);
}
2 changes: 1 addition & 1 deletion src/toggle-block/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"file:view.js"
],
"style": [
"file:../src/view.css"
"file:view.css"
],
"attributes": {
"bodyClass": {
Expand Down
17 changes: 17 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ module.exports = {
);
},
},
{
from: 'src/**/*.css',
to({ context, absoluteFilename }) {
const srcDir = path.resolve(context, 'src');
const relativeToSrc = path.relative(
srcDir,
absoluteFilename
);
const dir = path.dirname(relativeToSrc);
return path.resolve(
context,
'build',
dir,
'[name][ext]'
);
},
},
],
}),
],
Expand Down