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_certificate_templates()

Register rest fields used for certificate templates.


Return Return

(void)


Top ↑

Source Source

File: includes/class-llms-rest-fields.php

	private function register_fields_for_certificate_templates() {

		register_rest_field(
			'llms_certificate',
			'certificate_title',
			array(
				'schema'          => array(
					'description' => __( 'Certificate title.', 'lifterlms' ),
					'type'        => 'string',
				),
				'get_callback'    => function( $object ) {
					$cert = llms_get_certificate( $object['id'], true );
					return $cert ? $cert->get( 'certificate_title' ) : null;
				},
				'update_callback' => function( $value, $post ) {
					$cert = llms_get_certificate( $post->ID, true );
					return $cert ? $cert->set( 'certificate_title', $value ) : null;
				},
			)
		);

		register_rest_field(
			'llms_certificate',
			'certificate_sequential_id',
			array(
				'schema'          => array(
					'description' => __( 'Next sequential ID.', 'lifterlms' ),
					'type'        => 'integer',
					'arg_options' => array(
						'validate_callback' => function( $value, $request ) {
							return (int) $value >= llms_get_certificate_sequential_id( $request['id'] );
						},
					),
				),
				'get_callback'    => function( $object ) {
					return llms_get_certificate_sequential_id( $object['id'] );
				},
				'update_callback' => function( $value, $post ) {
					$cert = llms_get_certificate( $post->ID, true );
					return $cert ? $cert->set( 'sequential_id', $value ) : null;
				},
			)
		);

	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.