BP_REST_Blogs_Endpoint::get_item_schema()

Get the blogs schema, conforming to JSON Schema.

Description

Return

(array)

Source

File: bp-blogs/classes/class-bp-rest-blogs-endpoint.php

412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
public function get_item_schema() {
    $schema = array(
        '$schema'    => 'http://json-schema.org/draft-04/schema#',
        'title'      => 'bp_blogs',
        'type'       => 'object',
        'properties' => array(
            'id'            => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'A unique numeric ID for the blog.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'integer',
            ),
            'user_id'       => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'A unique numeric ID for the blog admin.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'integer',
            ),
            'name'          => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The name of the blog.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'string',
                'arg_options' => array(
                    'sanitize_callback' => 'sanitize_text_field',
                ),
            ),
            'permalink'     => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The permalink of the blog.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'string',
                'format'      => 'uri',
            ),
            'description'   => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The description of the blog.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'string',
            ),
            'path'          => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The path of the blog.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'string',
            ),
            'domain'        => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'the domain of the blog.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'string',
            ),
            'last_activity' => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( "The last activity date from the blog, in the site's timezone.", 'buddyboss' ),
                'type'        => 'string',
                'format'      => 'date-time',
            ),
        ),
    );
 
    // Blog Avatars.
    if ( true === buddypress()->avatar->show_avatars ) {
        $avatar_properties = array();
 
        $avatar_properties['full'] = array(
            /* translators: 1: Full avatar width in pixels. 2: Full avatar height in pixels */
            'description' => sprintf( __( 'Avatar URL with full image size (%1$d x %2$d pixels).', 'buddyboss' ), number_format_i18n( bp_core_avatar_full_width() ), number_format_i18n( bp_core_avatar_full_height() ) ),
            'type'        => 'string',
            'format'      => 'uri',
            'context'     => array( 'embed', 'view', 'edit' ),
        );
 
        $avatar_properties['thumb'] = array(
            /* translators: 1: Thumb avatar width in pixels. 2: Thumb avatar height in pixels */
            'description' => sprintf( __( 'Avatar URL with thumb image size (%1$d x %2$d pixels).', 'buddyboss' ), number_format_i18n( bp_core_avatar_thumb_width() ), number_format_i18n( bp_core_avatar_thumb_height() ) ),
            'type'        => 'string',
            'format'      => 'uri',
            'context'     => array( 'embed', 'view', 'edit' ),
        );
 
        $schema['properties']['avatar_urls'] = array(
            'description' => __( 'Avatar URLs for the blog.', 'buddyboss' ),
            'type'        => 'object',
            'context'     => array( 'embed', 'view', 'edit' ),
            'readonly'    => true,
            'properties'  => $avatar_properties,
        );
    }
 
    /**
     * Filter the blogs schema.
     *
     * @param array $schema The endpoint schema.
     *
     * @since 0.1.0
     */
    return apply_filters( 'bp_rest_blogs_schema', $this->add_additional_fields_schema( $schema ) );
}

Changelog

Changelog
Version Description
0.1.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.