BP_REST_Media_Endpoint::get_endpoint_args_for_item_schema( string $method = WP_REST_Server::CREATABLE )

Select the item schema arguments needed for the CREATABLE methods.

Description

Parameters

$method

(Optional) HTTP method of the request.

Default value: WP_REST_Server::CREATABLE

Return

(array) Endpoint arguments.

Source

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

1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) {
    $args = array();
    $key  = 'create';
 
    if ( WP_REST_Server::EDITABLE === $method ) {
        $args['id'] = array(
            'description'       => __( 'A unique numeric ID for the media.', 'buddyboss' ),
            'type'              => 'integer',
            'required'          => true,
            'sanitize_callback' => 'absint',
            'validate_callback' => 'rest_validate_request_arg',
        );
 
        $key = 'update';
    }
 
    if ( WP_REST_Server::CREATABLE === $method ) {
        $args['upload_ids'] = array(
            'description'       => __( 'Media specific IDs.', 'buddyboss' ),
            'default'           => array(),
            'type'              => 'array',
            'required'          => true,
            'items'             => array( 'type' => 'integer' ),
            'sanitize_callback' => 'wp_parse_id_list',
            'validate_callback' => 'rest_validate_request_arg',
        );
 
        $args['activity_id'] = array(
            'description'       => __( 'A unique numeric ID for the activity.', 'buddyboss' ),
            'type'              => 'integer',
            'sanitize_callback' => 'absint',
            'validate_callback' => 'rest_validate_request_arg',
        );
    }
 
    $args['group_id'] = array(
        'description'       => __( 'A unique numeric ID for the Group.', 'buddyboss' ),
        'type'              => 'integer',
        'sanitize_callback' => 'absint',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $args['album_id'] = array(
        'description'       => __( 'A unique numeric ID for the Media Album.', 'buddyboss' ),
        'type'              => 'integer',
        'sanitize_callback' => 'absint',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $args['privacy'] = array(
        'description'       => __( 'Privacy of the media.', 'buddyboss' ),
        'type'              => 'string',
        'enum'              => array( 'public', 'loggedin', 'onlyme', 'friends', 'grouponly', 'message' ),
        'default'           => 'public',
        'sanitize_callback' => 'sanitize_key',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    /**
     * Filters the method query arguments.
     *
     * @param array  $args   Query arguments.
     * @param string $method HTTP method of the request.
     *
     * @since 0.1.0
     */
    return apply_filters( "bp_rest_media_{$key}_query_arguments", $args, $method );
}

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.