Skip to content

Commit 0fdd16e

Browse files
committed
Block reorg
1 parent f6ea12f commit 0fdd16e

File tree

12 files changed

+78
-32
lines changed

12 files changed

+78
-32
lines changed

build/exclude

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/bin/
55
/build/
66
/docs/
7+
/js/msls-widget-block/
78
/legacy-tests/
89
/release/
910
/multisite-language-switcher/

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"require-dev": {
1313
"phpunit/phpunit": "^9.6",
1414
"brain/monkey": "^2.6",
15-
"phpstan/phpstan": "^1.10",
15+
"phpstan/phpstan": "^1.11",
1616
"szepeviktor/phpstan-wordpress": "^1.3",
1717
"phpstan/extension-installer": "^1.3",
1818
"antecedent/patchwork": "^2.1",

dist/block/index.asset.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components'), 'version' => '68612a682314c0702bd7');

dist/block/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://schemas.wp.org/trunk/block.json",
3+
"apiVersion": 3,
4+
"title": "Multisite Language Switcher",
5+
"icon": "translation",
6+
"category": "widgets",
7+
"name": "lloc/msls-widget-block",
8+
"version": "2.6.4",
9+
"description": "This is the widget comes with the Multisite Language Switcher plugin as a Gutenberg block.",
10+
"example": {},
11+
"supports": {
12+
"html": false
13+
},
14+
"textdomain": "multisite-language-switcher",
15+
"editorScript": "file:./index.js"
16+
}

js/msls-widget-block.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

js/msls-widget-block/block.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://schemas.wp.org/trunk/block.json",
3+
"apiVersion": 3,
4+
"title": "Multisite Language Switcher",
5+
"icon": "translation",
6+
"category": "widgets",
7+
"name": "lloc/msls-widget-block",
8+
"version": "2.6.4",
9+
"description": "This is the widget comes with the Multisite Language Switcher plugin as a Gutenberg block.",
10+
"example": {},
11+
"supports": {
12+
"html": false
13+
},
14+
"textdomain": "multisite-language-switcher",
15+
"editorScript": "file:./index.js"
16+
}

js/msls-widget-block/edit.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { useBlockProps } from '@wordpress/block-editor';
2+
import { ServerSideRender, TextControl } from '@wordpress/components';
3+
4+
export default function edit() {
5+
const blockProps = useBlockProps();
6+
return (
7+
<>
8+
<ServerSideRender
9+
block="lloc/msls-widget-block"
10+
attributes={blockProps.attributes}
11+
/>
12+
<InspectorControls>
13+
<TextControl
14+
label="Title"
15+
value={blockProps.attributes.title}
16+
onChange={(value) => {
17+
blockProps.setAttributes({ title: value });
18+
}}
19+
/>
20+
</InspectorControls>
21+
</>
22+
);
23+
}

js/msls-widget-block/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { registerBlockType } from '@wordpress/blocks';
2+
3+
import Edit from './edit';
4+
import save from './save';
5+
import metadata from './block.json';
6+
7+
registerBlockType(metadata.name, {
8+
edit: Edit,
9+
save,
10+
} );

js/msls-widget-block/index.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
// Silence is golden.
3+

js/msls-widget-block/save.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function save() {
2+
return null;
3+
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"scripts": {
33
"uglify": "uglifyjs js/msls.js > js/msls.min.js",
44
"less": "lessc css/msls.less css/msls.css --clean-css=\"--s1 --advanced\"",
5-
"build": "npm run uglify && npm run less"
5+
"build-msls-block": "wp-scripts build js/msls-widget-block/index.js --webpack-src-dir=./js --output-path=./dist/block",
6+
"build": "npm run uglify && npm run less && npm run build-msls-block"
67
},
78
"dependencies": {
89
"less": "^4.2.0",
@@ -11,6 +12,7 @@
1112
},
1213
"devDependencies": {
1314
"@playwright/test": "^1.44.0",
15+
"@wordpress/scripts": "^27.9.0",
1416
"@types/node": "^20.12.11"
1517
}
1618
}

0 commit comments

Comments
 (0)