Acorn in Sage 10 & Body Classes

Running Sage 10 with Tailwind in a basic setup which you can see at https://github.com/wpvillain/ventus . Managed to get Tailwind CSS up and running, added some basic layouts. Also added the Sage filter to add some classes to several selectors. Did one setup with View Composer , but decided I like the add_action in web/app/themes/ventus/app/filters.php better for now.

Then I wanted to add some Tailwind needed classes to the body class. Realized the basic Sage 8-9 setup was no longer used… and that body_class was moved / added to Acorn at acorn/src/Acorn/Sage/SageServiceProvider.php . So I installed Acorn as must-use plugin , did composer install to make it not die on me. Just to see.

Now I am trying to figure out…

  • is it useful to have Acorn just for certain filters besides using it to build plugins?
  • if I do not use Acorn… is there still a Sage way to add body classes in Sage 10?
1 Like

This

add_filter('body_class', __NAMESPACE__ . '\\body_class');

function body_class($classes) {
    
    // Add page template class to body tag
  if (is_page_template('template-sidebar-left.blade.php')) {

      $classes[] = 'archive';

  }

  return $classes;
}

does still work.

Will see for next plugin what I can come up with using Acorn.

This topic was automatically closed after 42 days. New replies are no longer allowed.