Documentation

wp-hide/module_load_component

Posted in: Getting Started (4) How To (20) Plugin Options Explained (42) Actions / Filters (36)      Code Example (22)  

Name: wp-hide/module_load_component
Type: Filter
Arguments:
(bool) $load
(string) $component_id
(string) $component_class
(object) $module

This filter controls whether an individual WP Hide component should be loaded. Returning false prevents the component from being included and instantiated, while returning true allows the normal loading process to continue.

This is particularly useful when you need to conditionally disable specific components based on the current URL, request type, user role, environment, module, or other custom criteria.


    add_filter( 'wp-hide/module_load_component', 'custom_wp_hide_component_loading', 10, 4 );
    function custom_wp_hide_component_loading( $load, $component_id, $component_class, $module )
        {
            $disabled_components = array(
                'general-feed',
                'general-oembed',
                'general-emulate'
            );

            if ( in_array( $component_id, $disabled_components, TRUE ) )
                return FALSE;

            return $load;
        }
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Scroll to top