getId( 'post' ); return $post_id ? Util::get_post_edit_url( $post_id ) : ''; } /** * List-table tab URL for the post type in ?post_type=, '' if it is not one of ours. */ public static function resolve_list_screen_url(): string { $slug = Util::get_entity_type_slug( Params::get()->getKey( 'post_type' ) ); return $slug ? admin_url( 'admin.php?page=adpresso-list-tables&tab=' . $slug ) : ''; } /** * Handler for load-post.php. */ public function redirect_edit_screen(): void { $this->redirect( self::resolve_edit_screen_url() ); } /** * Handler for load-post-new.php and load-edit.php. */ public function redirect_list_screen(): void { $this->redirect( self::resolve_list_screen_url() ); } /** * Redirects and exits, unless there is nowhere to go. * * @param string $url Target URL or ''. */ private function redirect( string $url ): void { if ( '' === $url ) { return; } wp_safe_redirect( $url ); exit; } }