public function load_post_new() {
		$request_uri = $_SERVER['REQUEST_URI'];
		$post_types  = papi_get_post_types();

		if ( in_array( $this->post_type, $post_types, true ) && strpos( $request_uri, 'page_type=' ) === false ) {
			$parsed_url = parse_url( $request_uri );

			$only_page_type = papi_filter_settings_only_page_type( $this->post_type );
			$page_types     = papi_get_all_page_types( $this->post_type );
			$show_standard  = false;

			if ( count( $page_types ) === 1 && empty( $only_page_type ) ) {
				$show_standard  = $page_types[0]->standard_type;
				$show_standard  = $show_standard ? papi_filter_settings_show_standard_page_type( $this->post_type ) : $show_standard;
				$only_page_type = $show_standard ? '' : $page_types[0]->get_id();
			}

			// Check if we should show one post type or not and
			// create the right url for that.
			if ( ! empty( $only_page_type ) && ! $show_standard ) {
				$url = papi_get_page_new_url( $only_page_type, false );
			} else {
				$page = 'page=papi-add-new-page,' . $this->post_type;

				if ( $this->post_type !== 'post' ) {
					$page = '&' . $page;
				}

				$url = 'edit.php?' . $parsed_url['query'] . $page;
			}

			wp_safe_redirect( $url );
			papi_is_admin() && exit;
		}
	}
public function load_post_new() {
		$request_uri = $_SERVER['REQUEST_URI'];
		$post_types  = papi_get_post_types();

		if ( in_array( $this->post_type, $post_types, true ) && strpos( $request_uri, 'page_type=' ) === false ) {
			$parsed_url = parse_url( $request_uri );

			$only_page_type = papi_filter_settings_only_page_type( $this->post_type );
			$page_types     = papi_get_all_page_types( $this->post_type );
			$show_standard  = false;

			if ( count( $page_types ) === 1 && empty( $only_page_type ) ) {
				$show_standard  = $page_types[0]->standard_type;
				$show_standard  = $show_standard ? papi_filter_settings_show_standard_page_type( $this->post_type ) : $show_standard;
				$only_page_type = $show_standard ? '' : $page_types[0]->get_id();
			}

			// Check if we should show one post type or not and
			// create the right url for that.
			if ( ! empty( $only_page_type ) && ! $show_standard ) {
				$url = papi_get_page_new_url( $only_page_type, false );
			} else {
				$page = 'page=papi-add-new-page,' . $this->post_type;

				if ( $this->post_type !== 'post' ) {
					$page = '&' . $page;
				}

				$url = 'edit.php?' . $parsed_url['query'] . $page;
			}

			wp_safe_redirect( $url );
			papi_is_admin() && exit;
		}
	}
public function load_post_new ( ) { $ request_uri = $ _SERVER [ 'REQUEST_URI' ] ; $ post_types = papi_get_post_types ( ) ; if ( in_array ( $ this -> post_type , $ post_types , true ) && strpos ( $ request_uri , 'page_type=' ) === false ) { $ parsed_url = parse_url ( $ request_uri ) ; $ only_page_type = papi_filter_settings_only_page_type ( $ this -> post_type ) ; $ page_types = papi_get_all_page_types ( $ this -> post_type ) ; $ show_standard = false ; if ( count ( $ page_types ) === 1 && empty ( $ only_page_type ) ) { $ show_standard = $ page_types [ 0 ] -> standard_type ; $ show_standard = $ show_standard ? papi_filter_settings_show_standard_page_type ( $ this -> post_type ) : $ show_standard ; $ only_page_type = $ show_standard ? '' : $ page_types [ 0 ] -> get_id ( ) ; } // Check if we should show one post type or not and // create the right url for that. if ( ! empty ( $ only_page_type ) && ! $ show_standard ) { $ url = papi_get_page_new_url ( $ only_page_type , false ) ; } else { $ page = 'page=papi-add-new-page,' . $ this -> post_type ; if ( $ this -> post_type !== 'post' ) { $ page = '&' . $ page ; } $ url = 'edit.php?' . $ parsed_url [ 'query' ] . $ page ; } wp_safe_redirect ( $ url ) ; papi_is_admin ( ) && exit ; } }
Load post new action
Redirect to right url if no page type is set.
Load post new action Redirect to right url if no page type is set .