Automator_Helpers_Recipe::is_edit_page()

is_edit_page function to check if the current page is a post edit page


Return Return

(boolean)


Source Source

File: src/core/lib/helpers/class-automator-recipe-helpers.php

	public function is_edit_page() {
		global $pagenow;

		if ( null === $pagenow && isset( $_SERVER['SCRIPT_FILENAME'] ) ) {
			$pagenow = basename( $_SERVER['SCRIPT_FILENAME'] );
		}
		//make sure we are on the backend
		if ( ! is_admin() ) {
			return false;
		}
		if ( automator_filter_has_var( 'post' ) && ! empty( automator_filter_input( 'post' ) ) ) {
			$current_post = get_post( absint( automator_filter_input( 'post' ) ) );
			if (
				isset( $current_post->post_type )
				&& 'uo-recipe' === $current_post->post_type
				&& in_array(
					$pagenow,
					array(
						'post.php',
						'post-new.php',
					),
					true
				)
			) {
				return true;
			}

			return false;
		}

		return false;
	}