Changeset 2126229
- Timestamp:
- 07/21/2019 08:32:20 AM (6 years ago)
- Location:
- disable-comments/trunk
- Files:
-
- 4 edited
-
assets/disable-comments.js (modified) (1 diff)
-
assets/disable-comments.js.map (modified) (1 diff)
-
disable-comments.php (modified) (4 diffs)
-
src/disable-comments.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
disable-comments/trunk/assets/disable-comments.js
r2126089 r2126229 2 2 3 3 wp.domReady(function () { 4 wp.blocks.getBlockTypes().forEach(function (block) { 5 if (disable_comments.disabled_blocks.includes(block.name)) { 6 wp.blocks.unregisterBlockType(block.name); 7 } 8 }); 4 if (wp.blocks) { 5 wp.blocks.getBlockTypes().forEach(function (block) { 6 if (disable_comments.disabled_blocks.includes(block.name)) { 7 wp.blocks.unregisterBlockType(block.name); 8 } 9 }); 10 } 9 11 }); 10 12 //# sourceMappingURL=disable-comments.js.map -
disable-comments/trunk/assets/disable-comments.js.map
r2126089 r2126229 1 {"version":3,"sources":["../src/disable-comments.js"],"names":["wp","domReady","blocks","getBlockTypes","forEach","block","disable_comments","disabled_blocks","includes","name","unregisterBlockType"],"mappings":";;AAAAA,EAAE,CAACC,QAAH,CAAY,YAAM;AACjB D,EAAAA,EAAE,CAACE,MAAH,CAAUC,aAAV,GAA0BC,OAA1B,CAAkC,UAACC,KAAD,EAAW;AAC5C,QAAIC,gBAAgB,CAACC,eAAjB,CAAiCC,QAAjC,CAA0CH,KAAK,CAACI,IAAhD,CAAJ,EAA2D;AAC1DT,MAAAA,EAAE,CAACE,MAAH,CAAUQ,mBAAV,CAA8BL,KAAK,CAACI,IAApC;AACA;AACD,GAJD;AAKA,CAND","sourcesContent":["wp.domReady(() => {\n\twp.blocks.getBlockTypes().forEach((block) => {\n\t\tif (disable_comments.disabled_blocks.includes(block.name)) {\n\t\t\twp.blocks.unregisterBlockType(block.name);\n\t\t}\n\t});\n});"],"file":"disable-comments.js"}1 {"version":3,"sources":["../src/disable-comments.js"],"names":["wp","domReady","blocks","getBlockTypes","forEach","block","disable_comments","disabled_blocks","includes","name","unregisterBlockType"],"mappings":";;AAAAA,EAAE,CAACC,QAAH,CAAY,YAAM;AACjB,MAAGD,EAAE,CAACE,MAAN,EAAc;AACbF,IAAAA,EAAE,CAACE,MAAH,CAAUC,aAAV,GAA0BC,OAA1B,CAAkC,UAACC,KAAD,EAAW;AAC5C,UAAIC,gBAAgB,CAACC,eAAjB,CAAiCC,QAAjC,CAA0CH,KAAK,CAACI,IAAhD,CAAJ,EAA2D;AAC1DT,QAAAA,EAAE,CAACE,MAAH,CAAUQ,mBAAV,CAA8BL,KAAK,CAACI,IAApC;AACA;AACD,KAJD;AAKA;AACD,CARD","sourcesContent":["wp.domReady(() => {\n\tif(wp.blocks) {\n\t\twp.blocks.getBlockTypes().forEach((block) => {\n\t\t\tif (disable_comments.disabled_blocks.includes(block.name)) {\n\t\t\t\twp.blocks.unregisterBlockType(block.name);\n\t\t\t}\n\t\t});\n\t}\n});\n"],"file":"disable-comments.js"} -
disable-comments/trunk/disable-comments.php
r2126089 r2126229 4 4 Plugin URI: https://wordpress.org/plugins/disable-comments/ 5 5 Description: Allows administrators to globally disable comments on their site. Comments can be disabled according to post type. 6 Version: 1.10. 16 Version: 1.10.2 7 7 Author: Samir Shah 8 8 Author URI: http://www.rayofsolaris.net/ … … 137 137 138 138 // Disable "Latest comments" block in Gutenberg 139 add_action( ' admin_enqueue_scripts', array( $this, 'filter_gutenberg_blocks') );139 add_action( 'enqueue_block_editor_assets', array( $this, 'filter_gutenberg_blocks') ); 140 140 } 141 141 … … 259 259 * Determines if scripts should be enqueued 260 260 */ 261 public function filter_gutenberg_blocks($hook) { 262 if (!in_array($hook, array('post-new.php', 'post.php'), true)) { 263 return; 264 } 265 266 if ($this->options['remove_everywhere']) { 267 return $this->disable_comments_script(); 268 } 269 261 public function filter_gutenberg_blocks( $hook ) { 270 262 global $post; 271 263 272 if ( isset($post->post_type) && in_array($post->post_type, $this->get_disabled_post_types(), true)) {264 if ( $this->options['remove_everywhere'] || ( isset( $post->post_type ) && in_array( $post->post_type, $this->get_disabled_post_types(), true ) ) ) { 273 265 return $this->disable_comments_script(); 274 266 } … … 279 271 */ 280 272 public function disable_comments_script() { 281 wp_enqueue_script('disable-comments-gutenberg', plugin_dir_url(__FILE__) . 'assets/disable-comments.js', array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post' )); 282 wp_localize_script('disable-comments-gutenberg', 'disable_comments', array( 283 'disabled_blocks' => array('core/latest-comments'), 284 )); 273 wp_enqueue_script( 'disable-comments-gutenberg', plugin_dir_url( __FILE__ ) . 'assets/disable-comments.js', array(), false, true ); 274 wp_localize_script( 275 'disable-comments-gutenberg', 276 'disable_comments', 277 array( 278 'disabled_blocks' => array( 'core/latest-comments' ), 279 ) 280 ); 285 281 } 286 282 -
disable-comments/trunk/src/disable-comments.js
r2126089 r2126229 1 1 wp.domReady(() => { 2 wp.blocks.getBlockTypes().forEach((block) => { 3 if (disable_comments.disabled_blocks.includes(block.name)) { 4 wp.blocks.unregisterBlockType(block.name); 5 } 6 }); 2 if(wp.blocks) { 3 wp.blocks.getBlockTypes().forEach((block) => { 4 if (disable_comments.disabled_blocks.includes(block.name)) { 5 wp.blocks.unregisterBlockType(block.name); 6 } 7 }); 8 } 7 9 });
Note: See TracChangeset
for help on using the changeset viewer.