BP_REST_Groups_Endpoint::get_item_schema()
Get the group schema, conforming to JSON Schema.
Description
Return
(array)
Source
File: bp-groups/classes/class-bp-rest-groups-endpoint.php
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 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 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 | public function get_item_schema() { $schema = array ( 'title' => 'bp_groups' , 'type' => 'object' , 'properties' => array ( 'id' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'A unique numeric ID for the Group.' , 'buddyboss' ), 'readonly' => true, 'type' => 'integer' , ), 'creator_id' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'The ID of the user who created the Group.' , 'buddyboss' ), 'type' => 'integer' , 'default' => bp_loggedin_user_id(), ), 'name' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'The name of the Group.' , 'buddyboss' ), 'type' => 'string' , 'required' => true, 'arg_options' => array ( 'sanitize_callback' => 'sanitize_text_field' , ), ), 'slug' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'The URL-friendly slug for the Group.' , 'buddyboss' ), 'type' => 'string' , 'arg_options' => array ( 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database(). ), ), 'link' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'The permalink to the Group on the site.' , 'buddyboss' ), 'type' => 'string' , 'format' => 'uri' , 'readonly' => true, ), 'description' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'The description of the Group.' , 'buddyboss' ), 'type' => 'object' , 'required' => true, 'arg_options' => array ( 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database(). 'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database(). ), 'properties' => array ( 'raw' => array ( 'description' => __( 'Content for the description of the Group, as it exists in the database.' , 'buddyboss' ), 'type' => 'string' , 'context' => array ( 'embed' , 'view' , 'edit' ), ), 'rendered' => array ( 'description' => __( 'HTML content for the description of the Group, transformed for display.' , 'buddyboss' ), 'type' => 'string' , 'context' => array ( 'embed' , 'view' , 'edit' ), 'readonly' => true, ), ), ), 'status' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'The status of the Group.' , 'buddyboss' ), 'type' => 'string' , 'enum' => buddypress()->groups->valid_status, 'default' => 'public' , 'arg_options' => array ( 'sanitize_callback' => 'sanitize_key' , ), ), 'enable_forum' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'Whether the Group has a forum enabled or not.' , 'buddyboss' ), 'type' => 'boolean' , ), 'parent_id' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'ID of the parent Group.' , 'buddyboss' ), 'type' => 'integer' , ), 'date_created' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( "The date the Group was created, in the site's timezone." , 'buddyboss' ), 'readonly' => true, 'type' => 'string' , 'format' => 'date-time' , ), 'types' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'The type(s) of the Group.' , 'buddyboss' ), 'readonly' => true, 'enum' => bp_groups_get_group_types(), 'type' => 'array' , 'items' => array ( 'type' => 'string' , ), ), 'subgroups_id' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'Sub Groups id if having a sub groups.' , 'buddyboss' ), 'readonly' => true, 'type' => 'array' , 'items' => array ( 'type' => 'integer' , ), ), 'admins' => array ( 'context' => array ( 'edit' ), 'description' => __( 'Group administrators.' , 'buddyboss' ), 'readonly' => true, 'type' => 'array' , 'items' => array ( 'type' => 'object' , ), ), 'mods' => array ( 'context' => array ( 'edit' ), 'description' => __( 'Group moderators.' , 'buddyboss' ), 'readonly' => true, 'type' => 'array' , 'items' => array ( 'type' => 'object' , ), ), 'total_member_count' => array ( 'context' => array ( 'edit' ), 'description' => __( 'Count of all Group members.' , 'buddyboss' ), 'readonly' => true, 'type' => 'integer' , ), 'last_activity' => array ( 'context' => array ( 'edit' ), 'description' => __( "The date the Group was last active, in the site's timezone." , 'buddyboss' ), 'type' => 'string' , 'readonly' => true, 'format' => 'date-time' , ), // Adding additional schema. 'is_member' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'The current user is member of a group or not.' , 'buddyboss' ), 'type' => 'boolean' , 'readonly' => true, ), 'invite_id' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'Return\'s invite ID if current user is invited for a group or not.' , 'buddyboss' ), 'type' => 'integer' , 'readonly' => true, ), 'request_id' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'Return\'s request ID if invitation is pending for a group or not.' , 'buddyboss' ), 'type' => 'integer' , 'readonly' => true, ), 'is_admin' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'The current user is admin of a group or not.' , 'buddyboss' ), 'type' => 'boolean' , 'readonly' => true, ), 'is_mod' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'The current user is moderator of a group or not.' , 'buddyboss' ), 'type' => 'boolean' , 'readonly' => true, ), 'members_count' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'Members count of the group.' , 'buddyboss' ), 'type' => 'integer' , 'readonly' => true, ), 'role' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'Current member\'s role label in the group.' , 'buddyboss' ), 'type' => 'string' , 'readonly' => true, ), 'plural_role' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'Current member\'s role label in the plural form in the group' , 'buddyboss' ), 'type' => 'string' , 'readonly' => true, ), 'can_join' => array ( 'context' => array ( 'view' , 'edit' ), 'description' => __( 'Check current user can join or request access.' , 'buddyboss' ), 'type' => 'boolean' , 'readonly' => true, ), 'forum' => array ( 'context' => array ( 'embed' , 'view' , 'edit' ), 'description' => __( 'Forum id of the group.' , 'buddyboss' ), 'type' => 'integer' , 'readonly' => true, ), ), ); // Avatars. if ( ! bp_disable_group_avatar_uploads() ) { $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 group.' , 'buddyboss' ), 'type' => 'object' , 'context' => array ( 'embed' , 'view' , 'edit' ), 'readonly' => true, 'properties' => $avatar_properties , ); } if ( ! bp_disable_group_cover_image_uploads() ) { $schema [ 'properties' ][ 'cover_url' ] = array ( 'description' => __( 'Cover Image URLs for the group.' , 'buddyboss' ), 'type' => 'string' , 'format' => 'uri' , 'context' => array ( 'embed' , 'view' , 'edit' ), 'readonly' => true, ); } /** * Filters the group schema. * * @param array $schema The endpoint schema. */ return apply_filters( 'bp_rest_group_schema' , $this ->add_additional_fields_schema( $schema ) ); } |
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.