static function get( $what = 'next', $return_post_id = false, $admin_mode = false ) {

		if ( 'first' === $what ) {
			return static::getFirst( $return_post_id, $admin_mode );
		}

		global $blog_id;

		global $post;

		$current_post_id = $post->ID;
		$book_structure = static::getBookStructure();
		$order = $book_structure['__order'];
		$pos = array_keys( $order );

		$what = ( 'next' === $what ? 'next' : 'prev' );

		// Move internal pointer to correct position
		reset( $pos );
		while ( $find_me = current( $pos ) ) {
			if ( (int) $find_me === (int) $current_post_id ) {
				break;
			} else {
				next( $pos );
			}
		}

		// Get next/previous
		$what( $pos );
		while ( $post_id = current( $pos ) ) {
			if ( $admin_mode ) {
				if ( current_user_can( 'edit_post', $post_id ) ) {
					break;
				} else {
					$what( $pos );
				}
			} else {
				if ( in_array( $order[ $post_id ]['post_status'], [ 'publish', 'web-only' ], true ) ) {
					break;
				} elseif ( current_user_can_for_blog( $blog_id, 'read_private_posts' ) ) {
					break;
				} elseif ( get_option( 'permissive_private_content' ) && current_user_can_for_blog( $blog_id, 'read' ) ) {
					break;
				} else {
					$what( $pos );
				}
			}
		}

		if ( $return_post_id ) {
			return (int) $post_id;
		} else {
			return ( empty( $post_id ) ) ? '/' : get_permalink( $post_id );
		}
	}
static function get( $what = 'next', $return_post_id = false, $admin_mode = false ) {

		if ( 'first' === $what ) {
			return static::getFirst( $return_post_id, $admin_mode );
		}

		global $blog_id;

		global $post;

		$current_post_id = $post->ID;
		$book_structure = static::getBookStructure();
		$order = $book_structure['__order'];
		$pos = array_keys( $order );

		$what = ( 'next' === $what ? 'next' : 'prev' );

		// Move internal pointer to correct position
		reset( $pos );
		while ( $find_me = current( $pos ) ) {
			if ( (int) $find_me === (int) $current_post_id ) {
				break;
			} else {
				next( $pos );
			}
		}

		// Get next/previous
		$what( $pos );
		while ( $post_id = current( $pos ) ) {
			if ( $admin_mode ) {
				if ( current_user_can( 'edit_post', $post_id ) ) {
					break;
				} else {
					$what( $pos );
				}
			} else {
				if ( in_array( $order[ $post_id ]['post_status'], [ 'publish', 'web-only' ], true ) ) {
					break;
				} elseif ( current_user_can_for_blog( $blog_id, 'read_private_posts' ) ) {
					break;
				} elseif ( get_option( 'permissive_private_content' ) && current_user_can_for_blog( $blog_id, 'read' ) ) {
					break;
				} else {
					$what( $pos );
				}
			}
		}

		if ( $return_post_id ) {
			return (int) $post_id;
		} else {
			return ( empty( $post_id ) ) ? '/' : get_permalink( $post_id );
		}
	}
static function get ( $ what = 'next' , $ return_post_id = false , $ admin_mode = false ) { if ( 'first' === $ what ) { return static :: getFirst ( $ return_post_id , $ admin_mode ) ; } global $ blog_id ; global $ post ; $ current_post_id = $ post -> ID ; $ book_structure = static :: getBookStructure ( ) ; $ order = $ book_structure [ '__order' ] ; $ pos = array_keys ( $ order ) ; $ what = ( 'next' === $ what ? 'next' : 'prev' ) ; // Move internal pointer to correct position reset ( $ pos ) ; while ( $ find_me = current ( $ pos ) ) { if ( ( int ) $ find_me === ( int ) $ current_post_id ) { break ; } else { next ( $ pos ) ; } } // Get next/previous $ what ( $ pos ) ; while ( $ post_id = current ( $ pos ) ) { if ( $ admin_mode ) { if ( current_user_can ( 'edit_post' , $ post_id ) ) { break ; } else { $ what ( $ pos ) ; } } else { if ( in_array ( $ order [ $ post_id ] [ 'post_status' ] , [ 'publish' , 'web-only' ] , true ) ) { break ; } elseif ( current_user_can_for_blog ( $ blog_id , 'read_private_posts' ) ) { break ; } elseif ( get_option ( 'permissive_private_content' ) && current_user_can_for_blog ( $ blog_id , 'read' ) ) { break ; } else { $ what ( $ pos ) ; } } } if ( $ return_post_id ) { return ( int ) $ post_id ; } else { return ( empty ( $ post_id ) ) ? '/' : get_permalink ( $ post_id ) ; } }
Fetch next, previous or first post

@param string $what prev, next or first
@param bool $return_post_id (optional)
@param bool $admin_mode (optional)

@return mixed URL of requested post, or Post ID if $return_post_id is set to true
Fetch next previous or first post