BUG: BP Daily Theme - hard codes link to child.css instead of calling wp_enqueue_style

The function bpdaily_themeoptions_output() (in functions.php) hard codes 2 stylesheets instead of following best practice.

This makes it impossible for child themes (or the BP Daily theme itself) to version the child.css file and force an update (without overriding the whole function).

It also means the browser will always request the child.css file, even if it isn't included / needed by a child theme.

if ( ! function_exists( 'bpdaily_themeoptions_output' ) ) :
function bpdaily_themeoptions_output(){
include (get_template_directory() . '/library/options/options.php');
	$get_current_scheme = get_option('dev_buddydaily_custom_style');
	if(($get_current_scheme == '') || ($get_current_scheme == 'default.css')) {
		print "<style type='text/css' media='screen'>";
		include (get_template_directory() . '/library/options/theme-options.php');
		print "</style>";
	} else { ?>
	<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/library/styles/<?php echo $get_current_scheme; ?>" type="text/css" media="all" />
	<?php }
	?>
		<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/_inc/css/child.css" type="text/css" media="all" />
		<?php
}
endif;
  • aecnu
    • WP Unicorn

    Greetings chriskeeble,

    Welcome to WPMU Dev!

    Thank you for bringing this significant issue to our attention.

    The lead theme developer for this particular theme is no longer with WPMU Dev in which I do know for a fact that we are working on adding at least a couple new theme developers and I am sure that they will not only be fixing the themes including this one that will be assigned to them, they will be bringing some new and innovating themes with them.

    Thank you for the heads up and I look forward to the new lead theme developer when assigned to be fixing this up asap.

    Cheers, Joe

  • chriskeeble
    • New Recruit

    Hi @PC

    In addition, when this is addressed, it would be ideal if the css could be enqueued using a file version based on file time (for css file cache control). Something like this (untested)...

    $child_css_file = get_stylesheet_directory() . '\_inc\css\child.css';
    
    	if (file_exists ($child_css_file) ) {
    		$css_version = filemtime($child_css_file);
    		$stylesheet = get_stylesheet_directory_uri() . '/_inc_css_child.css';
            wp_enqueue_style( 'bp-daily-child-css', apply_filters( 'bp_daily_child_css', $stylesheet ), false , $css_version );
    	}

    (When I originally posted this topic I forgot to tag as BuddyPress Daily Theme - are you able to update? If not I could post a new topic to link so it doesn't get missed?)

    Kind regards

    Chris

  • PC
    • WPMU DEV Initiate

    Hello Chris,

    Thanks for added info. I am sure that would be looked at carefully.

    I can see the tags are there as BP Daily and The Daily Theme. So it should not be a problem. I would pass on the information further.

    Cheers
    PC

  • PC
    • WPMU DEV Initiate

    Greetings Chris,

    Our Dev has got it fixed in the latest release. You may download it here

    I would once again like to thank you for being such a great member of the community and for standing by while we were looking into this :slight_smile:

    @Moha : Thanks a lot for such a quick response on this :slight_smile:

    Cheers
    PC

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.