Closed bonny closed 5 months ago
Hi @bonny
Thanks for your report, can you put the code into a PR so that I can merge it?
Hi @bonny
Thanks for your report, can you put the code into a PR so that I can merge it?
Sure, I will try to send a PR today.
If a plugin calls
switch_to_locale()
:then WP Statuses will crash
Reason:
Currently the function
wp_statuses_register
that converts the status objects to instances ofWP_Statuses_Core_Status
is called at init:add_action( 'init', 'wp_statuses_register', 1000 );
If a plugin then somewhere calles the WP function
switch_to_locale()
the status objects are recreated by WordPress, due to the functioncreate_initial_post_types
being called again from hookchange_locale
:add_action( 'change_locale', 'create_initial_post_types' );
Possible solution is to run
wp_status_register
also on thechange_locale
hook (just ascreate_initial_post_types
does):add_action( 'change_locale', 'wp_statuses_register', 10 );