Remove UAG Templates Button From Posts/Pages

Ultimate Addons for Gutenberg offers an option to import ready to use templates directly from block editor.

The plugin displays the ‘UAG Templates’ button on the top of every page and post. This button opens up a window where you can import templates.

If you wish to remove this button and option to import templates, use following custom code.

Note: Add following code to your child theme’s functions.php

1) To disable ‘UAG Templates’ button from all post, pages and other post types.

add_filter( 'ast_block_templates_disable', '__return_true' );

2) To disable ‘UAG Templates’ button from pages only

add_filter( 'ast_block_templates_disable', function( $default = false ) {
	if (isset($_REQUEST['post_type']) && 'page' === $_REQUEST['post_type']) {
        return true;
    } elseif ('page' ===get_post_type($_GET['post'])) {
        return true;
	return $default;
} );