Automattic\WooCommerce\EmailEditor\Engine

Email_Editor::get_current_postpublicWC 1.0

Get the current post object

Method of the class: Email_Editor{}

No Hooks.

Returns

Array|Mixed|WP_Post|null.

Usage

$Email_Editor = new Email_Editor();
$Email_Editor->get_current_post();

Email_Editor::get_current_post() code WC 10.7.0

public function get_current_post() {
	if ( isset( $_GET['post'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
		$post_id = 0;
		if ( is_string( $_GET['post'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- data valid
			$post_id = intval( $_GET['post'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- data valid
		}
		$current_post = get_post( $post_id );
	} else {
		$current_post = $GLOBALS['post'];
	}
	return $current_post;
}