• Despite all my best efforts I’m unable to unregister only one section and that is the section ‘gpb_monochrome_section_title_and_text_columns_(dark)’. I’m pulling all the registered sections from the plugin using $sections = genesis_blocks_get_sections(); and this section is the only one that won’t unregister.

    I’m currently on version 1.2.1 of the Pro version of the plugin.
    * Plugin Name: Genesis Blocks Pro
    * Version: 1.2.1

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Jen Baumann

    (@dreamwhisper)

    Hi Justin.

    If it will work for what you need to accomplish, there is a filter you can use to whitelist only the sections & layouts desired. It’s a whitelist rather than a blacklist so you won’t need to update your code to remove new ones as we add them.

    add_filter(
    	'genesis_blocks_allowed_layout_components',
    	function( $layouts ) {
    		// Return an array of unique section/layout keys that are allowed.
    		return [ 'whitelisted_section_key_1', 'whitelisted_section_key_2' ];
    	}
    );
    Thread Starter Justin McGuire

    (@vijustin)

    This seems like it’ll work but I am running into an issue where I can seem to white list the custom layouts I’m loading.

    This is what I’ve got in my functions.php file. The custom layouts load fine until I add the filter then poof they get pulled out too.

    
    
    function vi_custom_layouts() {
    		// Ensure a proper version of Genesis Blocks is active before continuing.
    		if ( ! function_exists( 'genesis_blocks_register_layout_component' ) ) {
    			return;
    		}
    
    		// Tango
    		genesis_blocks_register_layout_component(
    			[
    				'type'       => 'layout',
    				'key'        => 'vi_tango_home_layout',
    				'name'       => 'Tango Homepage',
    				'content'    => "", //Some blocks here
    				'category'   => [
    					'business',
    				],
    				'keywords'   => [
    					'homepage',
    					'home',
    					'landing',
    				],
    				'image'      => '', // Image here
    				'collection' => [
    					'slug'  => 'tango-homepage',
    					'label' => 'Tango Homepage',
    				],
    			]
    		);
    
    	}
    	add_action( 'init', 'vi_custom_layouts', 12 );
    	
    	add_filter(
    		'genesis_blocks_allowed_layout_components',
    		function( $layouts ) {
    			return [ 'vi_tango_home_layout' ];
    		}
    	);

    Plugin Contributor Jen Baumann

    (@dreamwhisper)

    Hi Justin.

    Thanks for your patience. It appears that the filter is working only for sections at the moment. I will open an issue for the team to review.

    Thread Starter Justin McGuire

    (@vijustin)

    Ahh thank you for clarifying. Hopefully the team can either expand it to include layouts or provide us with another filter specifically for layouts. Thank you!

    Thread Starter Justin McGuire

    (@vijustin)

    While you’re bringing that issue to the team you might want to also bring their attention to the issue with the section Monochrome Title and Text Columns Dark not being removed using the genesis_blocks_unregister_layout_component() method. Below is the code I was using to find and unregister all the sections before adding in my custom ones but for some reason that one won’t unregister. The only thing I can notice that is unique about it is the key for that section has “(dark)” at the end and it’s the only section / layout that has parenthesis in the key.

    
    // Remove sections
    $sections = genesis_blocks_get_sections();
    foreach ($sections as $value) {
         genesis_blocks_unregister_layout_component( 'section', $value['key'] );
    }
    
    Plugin Contributor Jen Baumann

    (@dreamwhisper)

    Hi Justin.

    We released an update for Pro yesterday that removes the parenthesis from the gpb_monochrome_section_title_and_text_columns_(dark) section key.

    We’re planning a release to Genesis Blocks soon that will allow the filter I mentioned to allow for layouts.

    Plugin Contributor Jen Baumann

    (@dreamwhisper)

    @vijustin Version 1.2.4 included the fix for the genesis_blocks_allowed_layout_components filter so both issues you experienced should be resolved.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Unregister Section’ is closed to new replies.