Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_REST_Fields::register_fields_for_attachments()
Register fields for attachments.
Return Return
(void)
Source Source
File: includes/class-llms-rest-fields.php
private function register_fields_for_attachments() {
register_rest_field(
'attachment',
'_llms_media_protection_product_id',
array(
'get_callback' => function ( $object ) {
return get_post_meta( $object['id'], '_llms_media_protection_product_id', true );
},
'update_callback' => function ( $value, $object ) {
$settings = new LLMS_Admin_Media_Protection_Attachment_Settings();
$protector = new LLMS_Media_Protector();
if ( $protector->is_media_protected( $object->ID ) ) {
update_post_meta( $object->ID, '_llms_media_protection_product_id', absint( $value ) );
return;
}
if ( $settings->move_attachment_to_protected_dir( $object->ID ) ) {
update_post_meta( $object->ID, '_llms_media_protection_product_id', absint( $value ) );
}
},
'schema' => array(
'description' => __( 'The ID of the product that protects this media.', 'lifterlms' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
)
);
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 9.0.0 | Introduced. |