Advertisements

get_admin_page_parent

Definition:
function get_admin_page_parent( $parent = '' ) {}

Parameters

  • $parent

Source code

function get_admin_page_parent( $parent = '' ) {

	global $parent_file;

	global $menu;

	global $submenu;

	global $pagenow;

	global $typenow;

	global $plugin_page;

	global $_wp_real_parent_file;

	global $_wp_menu_nopriv;

	global $_wp_submenu_nopriv;



	if ( !empty ( $parent ) && 'admin.php' != $parent ) {

		if ( isset( $_wp_real_parent_file[$parent] ) )

			$parent = $_wp_real_parent_file[$parent];

		return $parent;

	}



	/*

	if ( !empty ( $parent_file ) ) {

		if ( isset( $_wp_real_parent_file[$parent_file] ) )

			$parent_file = $_wp_real_parent_file[$parent_file];



		return $parent_file;

	}

	*/



	if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) {

		foreach ( (array)$menu as $parent_menu ) {

			if ( $parent_menu[2] == $plugin_page ) {

				$parent_file = $plugin_page;

				if ( isset( $_wp_real_parent_file[$parent_file] ) )

					$parent_file = $_wp_real_parent_file[$parent_file];

				return $parent_file;

			}

		}

		if ( isset( $_wp_menu_nopriv[$plugin_page] ) ) {

			$parent_file = $plugin_page;

			if ( isset( $_wp_real_parent_file[$parent_file] ) )

					$parent_file = $_wp_real_parent_file[$parent_file];

			return $parent_file;

		}

	}



	if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) {

		$parent_file = $pagenow;

		if ( isset( $_wp_real_parent_file[$parent_file] ) )

			$parent_file = $_wp_real_parent_file[$parent_file];

		return $parent_file;

	}



	foreach (array_keys( (array)$submenu ) as $parent) {

		foreach ( $submenu[$parent] as $submenu_array ) {

			if ( isset( $_wp_real_parent_file[$parent] ) )

				$parent = $_wp_real_parent_file[$parent];

			if ( !empty($typenow) && ($submenu_array[2] == "$pagenow?post_type=$typenow") ) {

				$parent_file = $parent;

				return $parent;

			} elseif ( $submenu_array[2] == $pagenow && empty($typenow) && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) {

				$parent_file = $parent;

				return $parent;

			} else

				if ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) {

					$parent_file = $parent;

					return $parent;

				}

		}

	}



	if ( empty($parent_file) )

		$parent_file = '';

	return '';

}

1120

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: