Automattic\WooCommerce\Internal\EmailEditor
PageRenderer::get_edited_item
Check if the post can be edited in the email editor.
Метод класса: PageRenderer{}
Хуков нет.
Возвращает
\WP_Post|\WP_Block_Template|null. Edited item or null if the item is not found.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_edited_item( $id, $type );
- $id(int|строка) (обязательный)
- The post ID.
- $type(строка) (обязательный)
- The post type.
Код PageRenderer::get_edited_item() PageRenderer::get edited item WC 11.2.2
private function get_edited_item( $id, string $type ) {
// When we pass template we need to verify that the template is registered in the email template registry.
if ( 'wp_template' === $type ) {
$wp_template = get_block_template( $id );
if ( ! $wp_template ) {
return null;
}
$email_template = $this->template_registry->get_by_slug( $wp_template->slug );
return $email_template instanceof Template ? $wp_template : null;
}
// For post we need to verify that the post is of the email type.
$post = get_post( $id );
if ( $post instanceof \WP_Post && $type === $post->post_type ) {
return $post;
}
return null;
}