LLMS_Admin_Menus::submenu_order( bool $flag )

Remove the default menu page from the submenu


Parameters Parameters

$flag

(bool) (Required) Flag from core filter (always false).


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/admin/class.llms.admin.menus.php

	 */
	public function submenu_order( $flag ) {

		global $submenu;

		if ( isset( $submenu['lifterlms'] ) ) {

			// Our desired order.
			$order = array( 'llms-dashboard', 'llms-settings', 'llms-reporting', 'edit.php?post_type=llms_form' );

			// Temporary array to hold our submenu items.
			$new_submenu = array();

			// Any items not defined in the $order array will be added at the end of the new array.
			$num_items = count( $submenu['lifterlms'] );

			foreach ( $submenu['lifterlms'] as $item ) {

				// Locate the desired order.
				$key = array_search( $item[2], $order, true );

				// Not found, increment the number of items to add it to the end of the array in its original order.
				if ( false === $key ) {
					$key = ++$num_items;
				}

				// Add the item to the new submenu.
				$new_submenu[ $key ] = $item;

			}

			// Sort.
			ksort( $new_submenu );

			// Remove the keys so the new array doesn't skip any numbers.
			$submenu['lifterlms'] = array_values( $new_submenu );

		}

		return $flag;


Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Adds custom sorting for LifterLMS submenu items.
3.2.0 Unknown.
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.