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 #
- $startinteger (Required) position.
- $incrementdouble (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; }
Expand full source code Collapse full source code View on GitHub: admin/anspress-admin.php:255
Add your comment