AnsPress_Hooks::fix_nav_current_class( array $class, object $item )

Description #

Add current-menu-item class in AnsPress pages

Parameters #

  • $class
    array (Required) Menu class.
  • $item
    object (Required) Current menu item.

Changelog #

VersionDescription
2.1Introduced.

Source #

File: includes/hooks.php

	public static function fix_nav_current_class( $class, $item ) {
		// Return if empty or `$item` is not object.
		if ( empty( $item ) || ! is_object( $item ) ) {
			return $class;
		}

		if ( ap_current_page() === $item->object ) {
			$class[] = 'current-menu-item';
		}

		return $class;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment