webzunft / edd-helpscout

Easy Digital Downloads integration for HelpScout. A WordPress Plugin.
GNU General Public License v2.0
59 stars 13 forks source link

New filters for default toggle state and toggle state persistency #81

Closed Spreeuw closed 2 years ago

Spreeuw commented 2 years ago

PR #78 introduced the is-persisted class to all sections, this PR adds a filter to disable that like so:

add_filter( 'edd_helpscout_persist_section_toggle', '__return_false' );

To allow for more fine-grained control, I've also added the section slug to the filter arguments, so that it can be disabled for a specific section. Here's an example that sets the subscriptions section to open by default, and makes sure it's not persisted (in other words, so that even if the user collapses it, it will be open again in the next window):

add_filter( 'edd_helpscout_default_section_toggle', function( $toggle, $section ){
    if ( $section == 'subscriptions' ) {
        $toggle = 'open';
    }
    return $toggle;
}, 10, 2 );
add_filter( 'edd_helpscout_persist_section_toggle', function( $persist, $section ){
    if ( $section == 'subscriptions' ) {
        $persist = false;
    }
    return $persist;
}, 10, 2 );
webzunft commented 2 years ago

@Spreeuw I merged #80 first which seems to conflict with the changes in your PR. Please try to resolve them so that I can continue merging. Thanks!

Spreeuw commented 2 years ago

@webzunft done!

webzunft commented 2 years ago

@Spreeuw thanks. Github is still showing me a warning that the rebase is not possible due to conflicts. Are you seeing it as well?

Spreeuw commented 2 years ago

You don't need to rebase, you should just be able to merge as-is (you can do a Squash & Merge if you want to condense history). There are no merge conflicts on my end: github-no-conflicts