Skip to:
Content
Pages
Categories
Search
Top
Bottom

Correct way to setup BP_Theme_Compat class for custom theme

  • Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    What’s the correct procedure going forward (1.8+) to setup a theme that makes use of BP Theme Compatibility, but wants to significantly amend / remove some of the various filters / actions that BP_Legacy adds?

    I know I can do this by creating my own class named BP_Legacy in my theme and customising, but this doesn’t seem a correct approach.

    If I use a custom class name, e.g. class MY_Theme_Compat extends BP_Theme_Compat, how do I stop an instance of BP_Legacy also being created (and registering its actions that I don’t want)?

    Also, if I define a custom Theme_Compat class in my theme, can I still access ‘fallback’ templates from BP_Legacy – if so, is this built in default behaviour, or do I need to configure my class globals accordingly?

    Or if not, do I need to have all the template files in my theme?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    Maybe I’m just confused by the naming:

    I know I can do this by creating my own class named BP_Legacy in my theme and customising, but this doesn’t seem a correct approach.

    Is the BP_Legacy class supposed to behave like a pluggable function? i.e. you are expected to redeclare the class with the same name?

    On a separate but related matter — if I want to create a completely bespoke theme (not theme compat), how do I stop an instance of BP_Legacy being created and registering its actions?

    I’ve tried declaring add_theme_support(‘buddypress’) hooked on to ‘after_setup_theme’, but that doesn’t stop an instance of BP_Legacy being constructed and registering its actions.

    Looking at the BP_Theme_Compat constructor, it would appear that add_theme_support(‘buddypress’) should stop it — does it need to be hooked on to something earlier than ‘after_setup_theme’?

    Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    > if I want to create a completely bespoke theme (not theme compat), how do I stop an instance of BP_Legacy being created and registering its actions?

    Just guessing here, but perhaps by manipulating ‘register_theme_packages’ in bp-loader.php ?

    If you get this working, any info / hints you can share would be appreciated.

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    ‘register_theme_packages’ is probably the approach, but has to be looked into as will need some work doing to it, probably filters for bp_get_theme_package_id() and a lot of testing before it’s a viable there’s a fair bit of hardcoding going on that needs to be filterable?. Had a brief chat with Boone about this as need to prepare a overview best practise guide to all approaches one can take with custom themes/sites.

    For the moment I think one re-declares the class even if that might feel wrong – it works!

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.