humanmade / wp-flags

Flags: WordPress admin-controlled user-based feature flags
MIT License
34 stars 3 forks source link

Flags::get( flag_name )->active not returning current status of flag. #15

Open abhishek-kaushik opened 4 years ago

abhishek-kaushik commented 4 years ago

When we are registering a site level flag. Flag status returns inactive even though flag is activated. wp_options table is updating correctly, might be something to do with how we are returning Flag Object.

stuartshields commented 4 years ago

I've come across the same issue as well. For more context, this is happening when trying to call get inside of add_action( 'after_setup_theme'

goldenapples commented 4 years ago

Flags (both user- and site-level) aren't bootstrapped until early on the init hook, so trying to check the flag status on after_setup_theme isn't going to work.

I'm not sure why the bootstrap functions are being delayed until init, other than that site flags code was copied from user flags, and users aren't authenticated until shortly before init...

I think it would make more sense for site flags to run the HumanMade\Flags\Site\handle() function when the flag is first registered. Thoughts?

stuartshields commented 4 years ago

@goldenapples Yep that's exactly what I saw when I first started looking into this. I think the solution makes sense.

svandragt commented 3 years ago

Stumbled across this too.