Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails
WCEmailTemplateDivergenceDetector::rest_meta_auth_read_only
REST auth gate for _wc_email_template_* meta.
- Read: allowed for users who can edit
woo_emailposts (matches the email-list capability). - Write: never allowed via REST. Meta is owned by server-side detection, apply, and reset flows.
Signature follows the auth_{$object_type}_meta_{$meta_key} filter contract.
Метод класса: WCEmailTemplateDivergenceDetector{}
Хуков нет.
Возвращает
bool.
Использование
$result = WCEmailTemplateDivergenceDetector::rest_meta_auth_read_only( $allowed, $meta_key, $object_id, $user_id, $cap, $caps ): bool;
- $allowed(true|false) (обязательный)
- Whether the request is allowed (current state).
- $meta_key(строка) (обязательный)
- The meta key in question.
- $object_id(int) (обязательный)
- The post ID.
- $user_id(int) (обязательный)
- The current user ID.
- $cap(строка) (обязательный)
- The capability being requested.
- $caps(массив) (обязательный)
- The full set of caps the user must have.
Список изменений
| С версии 10.9.0 | Введена. |
Код WCEmailTemplateDivergenceDetector::rest_meta_auth_read_only() WCEmailTemplateDivergenceDetector::rest meta auth read only WC 11.2.2
public static function rest_meta_auth_read_only( $allowed, $meta_key, $object_id, $user_id, $cap, $caps ): bool {
unset( $allowed, $meta_key, $caps );
// Block all writes regardless of caller.
if ( in_array( $cap, array( 'edit_post_meta', 'add_post_meta', 'delete_post_meta' ), true ) ) {
return false;
}
// For reads, defer to whether the user can edit the post.
return user_can( $user_id, 'edit_post', $object_id );
}