samikeijonen/bem-nav-filters

Custom BEM classes for nav in WordPress.

1.1.0 2018-09-09 15:07 UTC

This package is auto-updated.

Last update: 2024-04-10 04:10:40 UTC


README

This is a standalone composer package for BEM classes in WordPress navigation.

The article Quick Tip: BEM Naming and WordPress Filters for Navigation explains more about the logic.

Requirements

  • PHP 5.6+ (preferably 7+).
  • Composer for managing PHP dependencies.

Installation

Open your command line tool and change directories to your WordPress theme folder.

cd path/to/wp-content/themes/<your-theme-name>

Then, use Composer to install the package.

composer require samikeijonen/bem-nav-filters

Usage

If you're not already including the Composer autoload file for your theme you'll want something like the following bit of code in your theme's functions.php to autoload this package (and any others).

The Composer autoload file will automatically load up filters file for you and make its code available for you to use.

if ( file_exists( get_parent_theme_file_path( 'vendor/autoload.php' ) ) ) {
	require_once( get_parent_theme_file_path( 'vendor/autoload.php' ) );
}

Then init filters by this code in functions.php:

// Init BEM nav filters.
$filters = new \Foxland\BemNav\Filters();
$filters->init();