- Michał Trykoszko Github
- Shelob9 Github
- Godaddy CoBlocks
- WP Data Reddit
- WP Data novo
- WP Data Best practices
- Gutenberg examples
- wait for script to load
- Creating WordPress Admin Pages
- How To Create WordPress Custom Admin Pages
- Gutenberg admin example
- Axios and WP
- CRUD custom db table
- CRUD custom table as class
- Block filters
- dynamic render_block filters
- plugin attributes for blocks
- change network and container name
docker run --name myadmin --network=79b2504362f0f4d8bc8006dd3b97b3aa_default -e PMA_PORT=49156 -d --link 79b2504362f0f4d8bc8006dd3b97b3aa_mysql_1:db -p 8080:80 phpmyadmin
- create a file
inseri-core.ts
import domReady from "@wordpress/dom-ready";
const main = {
foo: 43,
bar: (a: any) => "meow " + a,
};
domReady(() => {
// @ts-ignore
window.InseriCore = main;
});
- extend entrypoints
"build": "wp-scripts build ./src/index ./src/hydration ./src/inseri-core",
"start": "wp-scripts start ./src/index ./src/hydration ./src/inseri-core"
- extend init php and choose an unique script handle 'inseri-core'
function create_block_react_block_block_init() {
register_block_type( __DIR__ . '/build' );
$asset_file_inseri = include( plugin_dir_path( __FILE__ ) . 'build/inseri-core.asset.php');
wp_register_script(
'inseri-core',
plugins_url( 'build/inseri-core.js', __FILE__ ),
$asset_file_inseri['dependencies'],
$asset_file_inseri['version']
);
}
add_action( 'init', 'create_block_react_block_block_init' );
- now add inseri-core as dependency in other plugin's block.json
- script: will load in editor and view
- viewScript: loads only in front
- editorScript: loads only in editor
- there is no error, if the dependency is missing
"script": "inseri-core"
- now InseriCore is available