et_requeue_child_theme_styles() (core/functions line 871) : fetches all registered styles in child theme directories
et_core_replace_enqueued_style() (core/functions line 967) : deregisters, dequeues and then enqueues these styles
So you cannot conditionally enqueue styles using wp_register_style() and later/somewhere else wp_enqueue_style()as they are forcibly enqueued by Divi whether you want them to be or not.
Divi does this with a huge and undocumented priority so users can't easily work around this unless they happen to try a priority higher than 99999999 which is highly unlikely.
add_action( 'wp_enqueue_scripts', 'et_requeue_child_theme_styles', 99999999 ); (core/functions line 493)
This will not work....
/**
* Enqueue scripts and styles for services post type
* Example only - the wp_enqueue_style() call could be in a shortcode or some other location
*
* @return void
*/
function dsl_services_enqueue_scripts() {
wp_register_style( 'services-css', get_stylesheet_directory_uri() . '/css/services-styles.css', array(), '1.00', 'all' );
if ( is_single() && 'service' == get_post_type() ) {
wp_enqueue_style('services-css');
}
}
add_action( 'wp_enqueue_scripts', 'dsl_services_enqueue_scripts' );
This process should be reworked.
Alternative approaches:
only look in the root directory of the child theme - and document that this happens
only dequeue/requeue styles that are already enqueued, not just registered styles - and document that this happens
reduce the priority of this method to something sensible - and document that this happens
et_requeue_child_theme_styles()
(core/functions line 871) : fetches all registered styles in child theme directorieset_core_replace_enqueued_style()
(core/functions line 967) : deregisters, dequeues and then enqueues these stylesSo you cannot conditionally enqueue styles using
wp_register_style()
and later/somewhere elsewp_enqueue_style()
as they are forcibly enqueued by Divi whether you want them to be or not.Divi does this with a huge and undocumented priority so users can't easily work around this unless they happen to try a priority higher than 99999999 which is highly unlikely.
add_action( 'wp_enqueue_scripts', 'et_requeue_child_theme_styles', 99999999 );
(core/functions line 493)This will not work....
This process should be reworked.
Alternative approaches: