Ticket #3403: blocks.diff
File blocks.diff, 7.7 KB (added by , 4 years ago) |
---|
-
package.json
27 27 "grunt-wp-i18n": "~1.0.3", 28 28 "matchdep": "~2.0.0", 29 29 "node-sass": "~4.14.1", 30 "parcel-bundler": "^1.10.1", 30 31 "postcss-scss": "~1.0.2", 31 32 "stylelint": "~13.6.1", 32 33 "stylelint-config-wordpress": "~15.0.0" … … 35 36 "node": ">=12.0.0", 36 37 "npm": ">=6.9.0" 37 38 }, 39 "scripts": { 40 "blocks": "parcel build src/includes/admin/assets/js/blocks.jsx --out-dir src/includes/admin/assets/js --public-url ." 41 }, 38 42 "keywords": [ 39 43 "community", 40 44 "forums", -
src/bbpress.php
340 340 require $this->includes_dir . 'common/template.php'; 341 341 require $this->includes_dir . 'common/widgets.php'; 342 342 require $this->includes_dir . 'common/shortcodes.php'; 343 require $this->includes_dir . 'common/blocks.php'; 343 344 344 345 // Forums 345 346 require $this->includes_dir . 'forums/capabilities.php'; … … 734 735 } 735 736 736 737 /** 737 * Register the bbPress shortcodes 738 * Register the bbPress shortcodes and blocks 738 739 * 739 740 * @since 2.0.0 bbPress (r3031) 740 741 */ 741 742 public function register_shortcodes() { 742 743 $this->shortcodes = new BBP_Shortcodes(); 744 $this->blocks = new BBP_Blocks( $this->shortcodes ); 743 745 } 744 746 745 747 /** -
src/includes/admin/assets/css/blocks.css
1 2 .bbpress-block { 3 background: #fff; 4 border: 1px solid #888; 5 padding: 1em 2em; 6 } 7 8 .bbpress-block h3 { 9 color: #444; 10 cursor: default; 11 } -
src/includes/admin/assets/js/blocks.js
Property changes on: src/includes/admin/assets/css/blocks.css ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"aE2q":[function(require,module,exports) { 2 function e(e){if(null==e)throw new TypeError("Cannot destructure undefined")}var n=wp.blocks.registerBlockType;e(wp.components),n("bbpress/forum-index",{title:"BBPress Forum Index",icon:"buddicons-bbpress-logo",category:"common",attributes:{},edit:function(){return React.createElement("div",{class:"bbpress-block"},React.createElement("h3",null,"BBPress Forum Index"))},save:function(){return null}}); 3 },{}]},{},["aE2q"], null) 4 //# sourceMappingURL=blocks.js.map 5 No newline at end of file -
src/includes/admin/assets/js/blocks.js.map
Property changes on: src/includes/admin/assets/js/blocks.js ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 {"version":3,"sources":["blocks.jsx"],"names":["registerBlockType","wp","blocks","components","title","icon","category","attributes","edit","save"],"mappings":";AAQA,SAAA,EAAA,GAAA,GAAA,MAAA,EAAA,MAAA,IAAA,UAAA,gCAPCA,IAAAA,EACGC,GAAGC,OADNF,kBAKGC,EAAAA,GAAGE,YAEPH,EAAmB,sBAAuB,CACzCI,MAAO,sBACPC,KAAM,yBACNC,SAAU,SAEVC,WAAY,GAEZC,KAAM,WAEJ,OAAA,MAAA,cAAA,MAAA,CAAK,MAAM,iBACV,MADD,cAAA,KAAA,KAAA,yBAMFC,KAAM,WACE,OAAA","file":"blocks.js","sourceRoot":"","sourcesContent":["const {\n\tregisterBlockType\n} = wp.blocks;\n\nconst {\n//\tTextControl\n} = wp.components;\n\nregisterBlockType( 'bbpress/forum-index', {\n\ttitle: 'BBPress Forum Index',\n\ticon: 'buddicons-bbpress-logo',\n\tcategory: 'common',\n\n\tattributes: {},\n\n\tedit: function() {\n\t\treturn (\n\t\t\t<div class=\"bbpress-block\">\n\t\t\t\t<h3>BBPress Forum Index</h3>\n\t\t\t</div>\n\t\t);\n\t},\n\n\tsave: function() {\n\t\treturn null;\n\t}\n} );"]} 2 No newline at end of file -
src/includes/admin/assets/js/blocks.jsx
1 const { 2 registerBlockType 3 } = wp.blocks; 4 5 const { 6 // TextControl 7 } = wp.components; 8 9 registerBlockType( 'bbpress/forum-index', { 10 title: 'BBPress Forum Index', 11 icon: 'buddicons-bbpress-logo', 12 category: 'common', 13 14 attributes: {}, 15 16 edit: function() { 17 return ( 18 <div class="bbpress-block"> 19 <h3>BBPress Forum Index</h3> 20 </div> 21 ); 22 }, 23 24 save: function() { 25 return null; 26 } 27 } ); 28 No newline at end of file -
src/includes/common/blocks.php
1 <?php 2 3 /** 4 * bbPress Blocks 5 * 6 * @package bbPress 7 * @subpackage Blocks 8 */ 9 10 // Exit if accessed directly 11 defined( 'ABSPATH' ) || exit; 12 13 if ( ! class_exists( 'BBP_Blocks' ) ) : 14 /** 15 * bbPress Shortcode Class 16 * 17 * @since 2.0.0 bbPress (r3031) 18 */ 19 class BBP_Blocks { 20 21 /** Vars ******************************************************************/ 22 23 /** 24 * @var BBP_Shortcodes Most of our blocks are just visual representations of existing shortcodes. 25 */ 26 public $shortcodes; 27 28 /** Functions *************************************************************/ 29 30 /** 31 * Set up the blocks for the Block Editor. 32 */ 33 public function __construct( BBP_Shortcodes $shortcodes = NULL ) { 34 $this->shortcodes = $shortcodes; 35 $this->register_blocks(); 36 } 37 38 public function register_blocks() { 39 if ( ! function_exists( 'register_block_type' ) ) { 40 return; 41 } 42 43 wp_register_script( 'bbp-blocks', plugins_url( '../admin/assets/js/blocks.js', __FILE__ ), [ 'wp-blocks', 'wp-components' ] ); 44 wp_register_style( 'bbp-blocks', plugins_url( '../admin/assets/css/blocks.css', __FILE__ ) ); 45 46 register_block_type( 'bbpress/forum-index', array( 47 'render_callback' => array( $this, 'display_forum_index' ), 48 'editor_script' => 'bbp-blocks', 49 'editor_style' => 'bbp-blocks', 50 ) ); 51 } 52 53 public function display_forum_index() { 54 $this->shortcodes->display_forum_index(); 55 } 56 57 } 58 endif; 59 No newline at end of file