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.
BP_REST_XProfile_Fields_Endpoint::get_date_field_options_array( BP_XProfile_Field $field, string $type = '' )
Get datebox options
Description
Parameters
- $field
-
(Required) XProfile field object.
- $type
-
(Optional) Date type parameter.
Default value: ''
Return
(array)
Source
File: bp-xprofile/classes/class-bp-rest-xprofile-fields-endpoint.php
1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 | private function get_date_field_options_array( $field , $type = '' ) { $eng_months = array ( 'January' , 'February' , 'March' , 'April' , 'May' , 'June' , 'July' , 'August' , 'September' , 'October' , 'November' , 'December' , ); $options = array (); // $type will be passed by calling function when needed. switch ( $type ) { case 'day' : for ( $i = 1; $i < 32; ++ $i ) { $options [] = array ( 'type' => 'option' , 'name' => $i , ); } break ; case 'month' : for ( $i = 0; $i < 12; ++ $i ) { $options [] = array ( 'type' => 'option' , 'name' => $eng_months [ $i ], ); } break ; case 'year' : $settings = BP_XProfile_Field_Type_Datebox::get_field_settings( $field ->id ); if ( 'relative' === $settings [ 'range_type' ] ) { // phpcs:ignore $start = date ( 'Y' ) + $settings [ 'range_relative_start' ]; // phpcs:ignore $end = date ( 'Y' ) + $settings [ 'range_relative_end' ]; } else { $start = $settings [ 'range_absolute_start' ]; $end = $settings [ 'range_absolute_end' ]; } for ( $i = $end ; $i >= $start ; $i -- ) { $options [] = array ( 'type' => 'option' , 'name' => $i , ); } break ; } return $options ; } |
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.