WebDevStudios / WDS-Simple-Page-Builder

Uses existing template parts in the currently-active theme to build a customized page with rearrangeable elements.
GNU General Public License v2.0
136 stars 25 forks source link

Add wds_page_builder_load_template_part filter to for conditionally loading template parts #38

Closed jtsternberg closed 9 years ago

jtsternberg commented 9 years ago

Allows something like:

function wds_page_builder_load_template_part_maybe_load( $display, $part, $container, $class ) {

    if ( 'your-part' == $part['template_group'] && other_condition_to_check() ) {
        return false;
    }

    return $display;
}
add_filter( 'wds_page_builder_load_template_part', 'wds_page_builder_load_template_part_maybe_load', 10, 4 );
jazzsequence commented 9 years ago

@jtsternberg Could this be used instead of the ugly check to prevent multiple parts from loading? https://github.com/WebDevStudios/WDS-Simple-Page-Builder/blob/develop/inc/functions.php#L347