woocommerce_email_editor_send_preview_email_without_post_permission хук-фильтрWC 2.16.0

Filters whether a preview email may be sent for a request without a backing post.

Defaults to false: postless requests are rejected unless an integration that handles them (via the woocommerce_email_editor_send_preview_email explicitly authorizes the request.

Использование

add_filter( 'woocommerce_email_editor_send_preview_email_without_post_permission', 'wp_kama_woocommerce_email_editor_send_preview_without_post_permission_filter', 10, 2 );

/**
 * Function for `woocommerce_email_editor_send_preview_email_without_post_permission` filter-hook.
 * 
 * @param bool             $allowed Whether the postless request is authorized.
 * @param \WP_REST_Request $request The send-preview REST request.
 *
 * @return bool
 */
function wp_kama_woocommerce_email_editor_send_preview_without_post_permission_filter( $allowed, $request ){
	// filter...
	return $allowed;
}
$allowed(true|false)
Whether the postless request is authorized.
По умолчанию: false
$request(\WP_REST_Request)
The send-preview REST request.

Список изменений

С версии 2.16.0 Введена.

Где вызывается хук

Email_Editor::register_email_editor_api_routes()
woocommerce_email_editor_send_preview_email_without_post_permission
woocommerce/packages/email-editor/src/Engine/class-email-editor.php 288
return (bool) apply_filters( 'woocommerce_email_editor_send_preview_email_without_post_permission', false, $request );

Где используется хук в WooCommerce

woocommerce/src/Internal/EmailEditor/Integration.php 170
add_filter( 'woocommerce_email_editor_send_preview_email_without_post_permission', array( $this, 'authorize_postless_send_preview' ), 10, 2 );