How to overide the roots_main_class from custom.php

Hi,

I’m trying to build a set of options for the theme to allow the user to set various things from within WordPress by using Advanced Custom Fields. One of these options will be the column widths.

So I’m trying to start with set the widths from within custom.php like this (the small values are just so I can see it do something & I will change these later)…

add_filter('roots_main_class', 'roots_main_class_adjust');

function roots_main_class_adjust($class) {

  global $class;

  if (roots_display_sidebar()) {

    // Classes on pages with the sidebar
    $class = 'col-sm-1';

  } else {

    // Classes on full width pages
    $class = 'col-sm-1';
  }

  return $class;
}

I will call the custom fields values, if I just get this to work to sart with.

I expect I have missed something obvious here, but I can’t get it to do anything. Can someone help me?

The problem is that right now we don’t use apply_filters for the main and sidebar classes. Last night I added this commit to 7.0.0: https://github.com/roots/roots/commit/ea5699f2844e71c059dada259a0e5b9e2a330711

Roll that into your theme and use the roots/main_class filter.

Great stuff, thanks for this.