AnsPress_Admin::get_free_menu_position( integer $start, double $increment = 0.99 )

Description #

Get free unused menu position. This function helps prevent other plugin menu conflict when assigned to same position.

Parameters #

  • $start
    integer (Required) position.
  • $increment
    double (Optional) position. Default value: 0.99

Source #

File: admin/anspress-admin.php

	public static function get_free_menu_position( $start, $increment = 0.99 ) {
		$menus_positions = array_keys( $GLOBALS['menu'] );

		if ( ! in_array( $start, $menus_positions, true ) ) {
			return $start;
		}

		// This position is already reserved find the closet one.
		while ( in_array( $start, $menus_positions, true ) ) {
			$start += $increment;
		}
		return $start;
	}

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