Commit d97d3093 authored by Martin Lees's avatar Martin Lees
Browse files

Updated to use webpack for the admin pages

parent 7415b757
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
}
\ No newline at end of file
......@@ -80,41 +80,30 @@ class Steempress_sp_Admin {
}
function gb_block_01_basic_editor_assets() {
// Scripts.
wp_enqueue_script(
'gb-block-01-basic', // Handle.
plugin_dir_url( __FILE__ ) . 'js/steempress_sp_gutenberg.js', // Block.js: We register the block here.
array( 'wp-blocks', 'wp-i18n', 'wp-element' ) // Dependencies, defined above.
);
// Styles.
wp_enqueue_style(
'gb-block-01-basic-editor', // Handle.
plugin_dir_url( __FILE__ ) . 'css/steempress_sp-admin.css', // Block editor CSS.
array( 'wp-edit-blocks' ) // Dependency to include the CSS after it.
);
} // End function gb_block_01_basic_editor_assets().
/**
* Enqueue the block's assets for the frontend.
* Enqueue Gutenberg block assets for backend editor.
*
* `wp-blocks`: includes block type registration and related functions.
* `wp-element`: includes the WordPress Element abstraction for describing the structure of your blocks.
* `wp-i18n`: To internationalize the block's text.
*
* @since 1.0.0
*/
function gb_block_01_basic_block_assets() {
// Styles.
wp_enqueue_style(
'gb-block-01-basic-frontend', // Handle.
plugin_dir_url( __FILE__ ) . 'css/steempress_sp-admin.css', // Block frontend CSS.
array( 'wp-blocks' ) // Dependency to include the CSS after it.
function my_block_cgb_editor_assets() {
// Scripts.
wp_enqueue_script(
'my_block-cgb-block-js', // Handle.
plugin_dir_url( __FILE__ ) . 'js/steempress_sp-admin.js', // Block.build.js: We register the block here. Built with Webpack.
array( 'wp-blocks', 'wp-i18n', 'wp-element' ), // Dependencies, defined above.
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ), // Version: filemtime — Gets file modification time.
true // Enqueue the script in the footer.
);
} // End function gb_block_01_basic_block_assets().
function mdlr_block_static_jsx_example_backend_enqueue() {
} // End function my_block_cgb_editor_assets().
wp_enqueue_script( $this->plugin_name."steempress_sp_backend", plugin_dir_url( __FILE__ ) . 'js/steempress_sp_gutenberg.js', array('wp-i18n', 'wp-element','wp-hooks', 'wp-components', 'wp-compose', 'wp-editor' ));
}
/**
* Register the JavaScript for the admin area.
......
......@@ -32,11 +32,3 @@
.steempress_sp_active:after {
content: "\2796"; /* Unicode character for "minus" sign (-) */
}
.wp-block-gb-basic-01 {
color: #000000;
background: mistyrose;
border: 0.2rem solid red;
padding: 2rem;
}
(function( $ ) {
'use strict';
/**
* All of the code for your admin-facing JavaScript source
* should reside in this file.
......
......@@ -62,7 +62,7 @@ function isValidBlockType( name ) {
}// end isValidBlockType()
**
/**
* Filters registered block settings, extending attributes with our custom data.
*
* @param {Object} settings Original block settings.
......
......@@ -181,8 +181,7 @@ class Steempress_sp {
$this->loader->add_action('add_meta_boxes',$plugin_admin, 'steempress_sp_add_custom_box');
$this->loader->add_action('save_post', $plugin_admin, 'steempress_sp_save_post_data');
$this->loader->add_action( 'enqueue_block_editor_assets', $plugin_admin, 'gb_block_01_basic_editor_assets' );
$this->loader->add_action( 'enqueue_block_assets', $plugin_admin, 'gb_block_01_basic_block_assets' );
$this->loader->add_action( 'enqueue_block_editor_assets', $plugin_admin, 'my_block_cgb_editor_assets' );
}
......
{
"name": "steempress",
"version": "1.0.0",
"description": "- Contributors: howo,fredrikaa - Requires at least: 4.7 - Tested up to: 4.9.2 - License: GPLv2 or later - License URI: http://www.gnu.org/licenses/gpl-2.0.html",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --mode production ./admin/js/source/*.js --output ./admin/js/steempress_sp-admin.js --module-bind js=babel-loader",
"dev": "webpack --mode development ./admin/js/source/*.js --output ./admin/js/steempress_sp-admin.js --module-bind js=babel-loader"
},
"repository": {
"type": "git",
"url": "git+https://github.com/drov0/steempress.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/drov0/steempress/issues"
},
"homepage": "https://github.com/drov0/steempress#readme",
"dependencies": {
"@babel/core": "^7.1.6",
"@babel/preset-env": "^7.1.6",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.4",
"webpack": "^4.25.1",
"webpack-cli": "^3.1.2"
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment