-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Will not work when including cmb2 in a theme #42
base: master
Are you sure you want to change the base?
Conversation
…etup_theme so those who include cmb2 in their theme can use it Add php storm files to gitignore
@jcchavezs Hey, I've never really used phpsniffer much sorry about all the commits. Just had to make a change to get this working in a theme so figured I'd send you a PR |
@@ -253,7 +253,7 @@ protected function filter_field_data_to_save( $data_to_save, $field_id, $conditi | |||
* check can be removed once the min version for this plugin has been upped to 4.4.}} | |||
*/ | |||
if ( ( function_exists( 'wp_installing' ) && wp_installing() === false ) || ( ! function_exists( 'wp_installing' ) && ( ! defined( 'WP_INSTALLING' ) || WP_INSTALLING === false ) ) ) { | |||
add_action( 'plugins_loaded', 'cmb2_conditionals_init' ); | |||
add_action( 'after_setup_theme', 'cmb2_conditionals_init' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about something like:
if ( did_action( 'plugins_loaded' ) === 0 ) {
add_action( 'plugins_loaded', 'cmb2_conditionals_init' );
} elseif ( did_action( 'after_setup_theme' ) === 0 ) {
add_action( 'after_setup_theme', 'cmb2_conditionals_init' );
} else {
cmb2_conditionals_init();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like that could work with the class check. You think all those checks are necessary though? Would there be a time when after_setup_theme would be too late to init that you can think of?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jrfnl K, gave it a shot but that doesn't work as it's still initializing before the theme loads CMB2 so the javascript never gets loaded. If you'll want this to be compatible with theme embeds you'll need to do something like this PR suggests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any feedback on this one @jrfnl?
Change the hook for init of the plugin from plugins_loaded to after_setup_theme so those who include cmb2 in their theme can use it
Add php storm files to gitignore