What does this php code found in my header.php template mean?

The following code is found in the header.php template in the buddypress social theme: <?php if (!strstr($_SERVER['REQUEST_URI'], '/wp-signup.php')) { ?>

<?php if($bp_existed == 'true') { ?>
<?php if ( !bp_is_register_page() && !bp_is_activation_page() ) { ?>
<?php if( !is_user_logged_in() || wpmudev_is_customize_preview() ) { locate_template( array('lib/templates/wp-template/top-header.php'), true ); } ?>
<?php } ?>
<?php } else { ?>
<?php if( ( !is_user_logged_in() || wpmudev_is_customize_preview() ) && is_home() ) { locate_template( array('lib/templates/wp-template/top-header.php'), true ); } ?>
<?php } ?>

<?php } ?>

What does this code mean, especially the part wpmu dev will customize preview?

  • Jack Kitterhing

    Hi there @ted_adj

    I hope you are well today and thank you for your question.

    wpmudev_is_customize_preview That part of the code, means it's checking if it's on the preview customizer page, we won't actually customize the preview :slight_smile:

    The rest of the code, basically will show the lib/templates/wp-template/top-header.php if:BuddyPress exists, we're not on BP register/activation page
    and the user isn't logged in, or we're in customizer preview. :slight_smile:

    Thank you!

    Kind Regards
    Jack.

  • ted_adj

    Thanks for the reply Jack, When that code: <?php if (!strstr($_SERVER['REQUEST_URI'], '/wp-signup.php')) { ?>

    <?php if($bp_existed == 'true') { ?>
    <?php if ( !bp_is_register_page() && !bp_is_activation_page() ) { ?>
    <?php if( !is_user_logged_in() || wpmudev_is_customize_preview() ) { locate_template( array('lib/templates/wp-template/top-header.php'), true ); } ?>
    <?php } ?>
    <?php } else { ?>
    <?php if( ( !is_user_logged_in() || wpmudev_is_customize_preview() ) && is_home() ) { locate_template( array('lib/templates/wp-template/top-header.php'), true ); } ?>
    <?php } ?>

    <?php } ?>
    is in the header.php section and the user is not logged in the [lib/templates/wp-template/top-header.php] section is wider than just when the code: <?php { locate_template( array('lib/templates/wp-template/top-header.php'), true ); } ?> is there. Why does that happen? Does it have to do with wpmudev_is_customize_preview() ) part of the code in the first part? Please help me out.

    Thanks

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.