Advertisements

user_can_access_admin_page

Definition:
function user_can_access_admin_page() {}

Source code

function user_can_access_admin_page() {

	global $pagenow;

	global $menu;

	global $submenu;

	global $_wp_menu_nopriv;

	global $_wp_submenu_nopriv;

	global $plugin_page;

	global $_registered_pages;



	$parent = get_admin_page_parent();



	if ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )

		return false;



	if ( isset( $plugin_page ) ) {

		if ( isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )

			return false;



		$hookname = get_plugin_page_hookname($plugin_page, $parent);



		if ( !isset($_registered_pages[$hookname]) )

			return false;

	}



	if ( empty( $parent) ) {

		if ( isset( $_wp_menu_nopriv[$pagenow] ) )

			return false;

		if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) )

			return false;

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

			return false;

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

			return false;

		foreach (array_keys( $_wp_submenu_nopriv ) as $key ) {

			if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) )

				return false;

			if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) )

			return false;

		}

		return true;

	}



	if ( isset( $plugin_page ) && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[$plugin_page] ) )

		return false;



	if ( isset( $submenu[$parent] ) ) {

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

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

				if ( current_user_can( $submenu_array[1] ))

					return true;

				else

					return false;

			} else if ( $submenu_array[2] == $pagenow ) {

				if ( current_user_can( $submenu_array[1] ))

					return true;

				else

					return false;

			}

		}

	}



	foreach ( $menu as $menu_array ) {

		if ( $menu_array[2] == $parent) {

			if ( current_user_can( $menu_array[1] ))

				return true;

			else

				return false;

		}

	}



	return true;

}

3277

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: