Plugin Directory

Changeset 2126229


Ignore:
Timestamp:
07/21/2019 08:32:20 AM (6 years ago)
Author:
solarissmoke
Message:

Version 1.10.2

Location:
disable-comments/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • disable-comments/trunk/assets/disable-comments.js

    r2126089 r2126229  
    22
    33wp.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  }
    911});
    1012//# 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;AACjBD,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  
    44Plugin URI: https://wordpress.org/plugins/disable-comments/
    55Description: Allows administrators to globally disable comments on their site. Comments can be disabled according to post type.
    6 Version: 1.10.1
     6Version: 1.10.2
    77Author: Samir Shah
    88Author URI: http://www.rayofsolaris.net/
     
    137137
    138138        // 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') );
    140140    }
    141141
     
    259259     * Determines if scripts should be enqueued
    260260     */
    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 ) {
    270262        global $post;
    271263
    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 ) ) ) {
    273265            return $this->disable_comments_script();
    274266        }
     
    279271     */
    280272    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        );
    285281    }
    286282
  • disable-comments/trunk/src/disable-comments.js

    r2126089 r2126229  
    11wp.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    }
    79});
Note: See TracChangeset for help on using the changeset viewer.