HEX
Server: LiteSpeed
System: Linux baciro.idweb.host 4.18.0-553.5.1.lve.1.el8.x86_64 #1 SMP Fri Jun 14 15:38:45 UTC 2024 x86_64
User: yastidua (1245)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/yastidua/httpdocs/wp-content/plugins/jetformbuilder/includes/classes/post/post-tools.php
<?php


namespace Jet_Form_Builder\Classes\Post;


class Post_Tools {

	/**
	 * @param $post_id
	 *
	 * @return \WP_Post
	 * @throws Not_Found_Post_Exception
	 */
	public static function get_post( $post_id ): \WP_Post {
		$post_id = (int) $post_id;

		if ( ! $post_id ) {
			throw new Not_Found_Post_Exception( 'Empty post_id' );
		}

		$post = \get_post( $post_id );

		if ( is_null( $post ) ) {
			throw new Not_Found_Post_Exception( 'Not found post row' );
		}

		return $post;
	}

	public static function get_title( $post ): string {
		$title = get_the_title( $post );

		return empty( $title ) ? __( '(no title)', 'jet-form-builder' ) : $title;
	}

}