• Resolved Jezze

    (@jezze)


    Hueman is without a doubt one of the best themes available for wordpress. And so, I like to contribute a little feature which I miss in the current version; the ability to change the background color of the content section.

    add to functions\theme-options.php

    // Styling: Content Color
    array(
    	'id'		=> 'color-content',
    	'label'		=> 'Content Color',
    	'std'		=> '#ffffff',
    	'type'		=> 'colorpicker',
    	'section'	=> 'styling',
    	'class'		=> ''
    ),

    add to functions\dynamic-styles.php in alx_dynamic_css() where dynamic-styles != ‘off’

    $color_content = ot_get_option('color-content');
    $color_content_rgb = alx_hex2rgb($color_content, true);
    
    if ( $color_content != '#ffffff' ) {
      // background color
      $styles .= '.main, .page-title { background-color: '.$color_content.' !important; }';
    
      $color_content_luminance = 0.299 * $color_content_rgb[0] + 0.587 * $color_content_rgb[1] + 0.114 * $color_content_rgb[2];
    
      if ($color_content_luminance > 128) {
        // separator color on bright background
        $styles .= '.page-title, .featured, .post-list .post-row { border-bottom-color: rgba(160, 160, 160, .25); }';
      }
      else {
        // separator color on dark background
        $styles .= '.page-title, .featured, .post-list .post-row { border-bottom-color: rgba(240, 240, 240, .25); }';
      }
    }

    Maybe something similar could be officially added in a future version of the theme.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thanks for the contribution, good stuff! Saved for future updates 🙂

    I really like the way you check lumiance – had no idea you could do it like that.

    Thanks a lot for this bit of code!

    I’ve added it to my child theme and it works great. I also suggest adding this to your next update!

    I used the above code in theme-options.php and dynamic-styles.php in my child theme. I made a directory “functions” with the theme-options.php and dynamic-styles.php file and the added code (like above) I don’t see any change in my admin 🙁 so I guess something has gone wrong. Is it wrong to add the directory functions with just the two files or did I add the code in dynamic-styles.php in the wrong place? I dom’t know. Could you give me the complete code of dynamic-styles.php so I’m sure that’s o.k.?
    Thanks for your time and help,
    Jeroen

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘OptionTree: change background color for content’ is closed to new replies.