LLMS_REST_Sections_Controller::get_item_schema()

Get the Section’s schema, conforming to JSON Schema.


Return Return

(array)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/server/class-llms-rest-sections-controller.php

234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
* @since 1.0.0-beta.27
 *
 * @return array
 */
public function get_item_schema_base() {
 
    $schema = parent::get_item_schema_base();
 
    // Section's title.
    $schema['properties']['title']['description'] = __( 'Section Title', 'lifterlms' );
 
    // Section's parent id.
    $schema['properties']['parent_id'] = array(
        'description' => __( 'WordPress post ID of the parent item. Must be a Course ID.', 'lifterlms' ),
        'type'        => 'integer',
        'context'     => array( 'view', 'edit' ),
        'arg_options' => array(
            'sanitize_callback' => 'absint',
        ),
        'required'    => true,
    );
 
    // Section order.
    $schema['properties']['order'] = array(
        'description' => __( 'Order of the section within the course.', 'lifterlms' ),
        'type'        => 'integer',
        'default'     => 1,
        'context'     => array( 'view', 'edit' ),
        'arg_options' => array(
            'sanitize_callback' => 'absint',
        ),
        'required'    => true,
    );
 
    // remove unnecessary properties.
    $unnecessary_properties = array(
        'permalink',
        'slug',
        'content',
        'menu_order',
        'excerpt',
        'featured_media',
        'status',
        'password',
        'featured_media',
        'comment_status',
        'ping_status',
    );
 
    foreach ( $unnecessary_properties as $unnecessary_property ) {
        unset( $schema['properties'][ $unnecessary_property ] );
    }


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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