Skip to content

Gutenberg – Functions & Filters

Henner R Setyono edited this page Jun 5, 2020 · 2 revisions

Set Disabled Blocks

apply_filters( 'h_disallowed_blocks', array $blocks )

$blocks (array) - List of disabled blocks.

default:

[
  'core/video',
  'core/nextpage',
  'core/social-links',

  // widget
  'core/calendar',
  'core/tag-cloud',
  'core/search',
  'core/latest-comments',
  'core/latest-posts',
  'core/rss',
  'core/legacy-widget',
  'core/archives',
  'core/categories',

  // embed
  'core-embed/amazon-kindle',
  'core-embed/soundcloud',
  'core-embed/spotify',
  'core-embed/flickr',
  'core-embed/vimeo',
  'core-embed/amazon-kindle',
  'core-embed/animoto',
  'core-embed/cloudup',
  'core-embed/collegehumor',
  'core-embed/crowdsignal',
  'core-embed/dailymotion',
  'core-embed/funnyordie',
  'core-embed/hulu',
  'core-embed/imgur',
  'core-embed/issuu',
  'core-embed/kickstarter',
  'core-embed/meetup-com',
  'core-embed/mixcloud',
  'core-embed/photobucket',
  'core-embed/polldaddy',
  'core-embed/reddit',
  'core-embed/reverbnation',
  'core-embed/screencast',
  'core-embed/scribd',
  'core-embed/slideshare',
  'core-embed/speaker-deck',
  'core-embed/smugmug',
  'core-embed/speaker',
  'core-embed/ted',
  'core-embed/tumblr',
  'core-embed/videopress',
  'core-embed/wordpress-tv',
  'core-embed/tiktok',

  // jetpack
  'jetpack/slideshow',
  'jetpack/contact-info',
  'jetpack/business-hours',
  'jetpack/calendly',
  'jetpack/eventbrite',
  'jetpack/gif',
  'jetpack/markdown',
  'jetpack/opentable',
  'jetpack/google-calendar',
  'jetpack/podcast-player',
  'jetpack/map',
  'jetpack/pinterest',
  'jetpack/revue',
  'jetpack/repeat-visitor',
  'jetpack/tiled-gallery',
]

EXAMPLE

We want to enable jetpack/slideshow, so we need to remove it from the array:

add_filter( 'h_disallowed_blocks', 'my_disallowed_blocks' );

function my_disallowed_blocks( $blocks ) {
  $i = array_search( 'jetpack/slideshow', $blocks );
  array_splice( $blocks, $i, 1 );
  return $blocks;
}

EXAMPLE 2

We want to disable jetpack/star-rating, simply add it to the array:

add_filter( 'h_disallowed_blocks', 'my_disallowed_blocks' );

function my_disallowed_blocks( $blocks ) {
  $blocks[] = 'jetpack/star-rating';
  return $blocks;
}

Modification to Core

Enabled wide alignment on these blocks:

  • core/paragraph
  • core/list
  • core/gallery
  • core/code
  • core/verse
  • core/preformatted
  • core/table
  • core/pullquote
  • core/heading

Removed float right/left on these blocks:

  • core/file
  • core/audio

Changed the default alignment of these blocks to wide:

  • core/columns

Changed the default alignment of these blocks to full:

  • core/group
  • core/cover

Clone this wiki locally