Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813

Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813

Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
PUM_Admin_Pages::reorder_submenu_array( $a,  $b )

Reorders the submenu by title.


Description Description

Forces $first_pages to load in order at the beginning of the menu and $last_pages to load in order at the end. All remaining menu items will go out in generic order.


Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813

Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813

Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Parameters Parameters

$a

(Required)

$b

(Required)


Top ↑

Return Return

(int)


Top ↑

Source Source

File: classes/Admin/Pages.php

	public static function reorder_submenu_array( $a, $b ) {
		$first_pages = apply_filters( 'pum_admin_submenu_first_pages', array(
			__( 'All Popups', 'popup-maker' ),
			__( 'Add New', 'popup-maker' ),
			__( 'All Themes', 'popup-maker' ),
			__( 'Categories', 'popup-maker' ),
			__( 'Tags', 'popup-maker' ),
		) );
		$last_pages  = apply_filters( 'pum_admin_submenu_last_pages', array(
			__( 'Extend', 'popup-maker' ),
			__( 'Settings', 'popup-maker' ),
			__( 'Tools', 'popup-maker' ),
			__( 'Support Forum', 'popup-maker' ),
			__( 'Account', 'popup-maker' ),
			__( 'Contact Us', 'popup-maker' ),
			__( 'Help & Support', 'popup-maker' ),
		) );

		$a_val = strip_tags( $a[0], false );
		$b_val = strip_tags( $b[0], false );

		// Sort First Page Keys.
		if ( in_array( $a_val, $first_pages ) && ! in_array( $b_val, $first_pages ) ) {
			return - 1;
		} elseif ( ! in_array( $a_val, $first_pages ) && in_array( $b_val, $first_pages ) ) {
			return 1;
		} elseif ( in_array( $a_val, $first_pages ) && in_array( $b_val, $first_pages ) ) {
			$a_key = array_search( $a_val, $first_pages );
			$b_key = array_search( $b_val, $first_pages );

			return ( $a_key < $b_key ) ? - 1 : 1;
		}

		// Sort Last Page Keys.
		if ( in_array( $a_val, $last_pages ) && ! in_array( $b_val, $last_pages ) ) {
			return 1;
		} elseif ( ! in_array( $a_val, $last_pages ) && in_array( $b_val, $last_pages ) ) {
			return - 1;
		} elseif ( in_array( $a_val, $last_pages ) && in_array( $b_val, $last_pages ) ) {
			$a_key = array_search( $a_val, $last_pages );
			$b_key = array_search( $b_val, $last_pages );

			return ( $a_key < $b_key ) ? - 1 : 1;
		}

		// Sort remaining keys
		return $a > $b ? 1 : - 1;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.4 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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