Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of hnla

If BP is enable conditional tag (11 posts)

Started 1 year, 6 months ago by: Puanthanh

  • Profile picture of Puanthanh Puanthanh said 1 year, 6 months ago:

    It want something like this
    if bp_is_enable
    buddypress code
    else
    Wordpress code

    I think this will really help and ease theme developer

    Can this be possible?

  • Profile picture of hnla hnla said 1 year, 6 months ago:

    I think you’ll find it does exist and is how plugins are meant to work by first checking that BP is loaded?

    It might be easier if you explained what you’re trying to achieve rather than the approach you would like to take to achieving it, then someone will be able to, possibly, provide an alternative method to achieving your requirement. It’s possibly a slightly confusing request as surely with BP not activated, no BP theme running why would any WP theme files need to be checking to see if BP is running?

  • Profile picture of Puanthanh Puanthanh said 1 year, 6 months ago:

    You are right, I should have explained.
    I am making theme both compatible for WP and BP by using something like this
    <?php if (get_option(‘gangmei_switch_platform’) == ‘buddypress’) { ?>
    <?php include(TEMPLATEPATH . ‘/_inc/member-search.php’); ?>
    <?php } else { include(TEMPLATEPATH . ‘/_inc/search-form.php’); } ?>

    This work 100%
    ( If buddypress is enable from theme option page, it will show the buddypress member search form
    else it will show the wordpress search form)

    But i want something like I said.

  • Profile picture of hnla hnla said 1 year, 6 months ago:

    Then do either of these not serve the purpose?

    defined( ‘BP_VERSION’ )

    did_action( ‘bp_init’ )

  • Profile picture of Puanthanh Puanthanh said 1 year, 6 months ago:

    Thanks for the info. I have not use defined( ‘BP_VERSION’ )

    Where will be the proper place to put this code?

  • Profile picture of Puanthanh Puanthanh said 1 year, 6 months ago:

    Won’t it load slower if we add defined( ‘BP_VERSION’ ) did_action( ‘bp_init’ ) function

  • Profile picture of r-a-y r-a-y said 1 year, 6 months ago:

    Use:

    if (defined(‘BP_VERSION’ ) { your code here;}
    else { your non-bp code here;}

  • Profile picture of Puanthanh Puanthanh said 1 year, 6 months ago:

    @r-a-y Thank a million for the tip. you saved my day

  • Profile picture of hnla hnla said 1 year, 6 months ago:

    No problem ;)

  • Profile picture of Puanthanh Puanthanh said 1 year, 6 months ago:

    I think my style is better. Even if buddypress is enabled, I can still control it from the theme option page- what to display

  • Profile picture of hnla hnla said 1 year, 6 months ago:

    ?