/bp-xprofile/bp-xprofile-template.php

  1. <?php 
  2. /** 
  3. * BuddyPress XProfile Template Tags. 
  4. * 
  5. * @package BuddyPress 
  6. * @subpackage XProfileTemplate 
  7. * @since 1.5.0 
  8. */ 
  9.  
  10. // Exit if accessed directly. 
  11. defined( 'ABSPATH' ) || exit; 
  12.  
  13. /** 
  14. * Query for XProfile groups and fields. 
  15. * 
  16. * @since 1.0.0 
  17. * 
  18. * @global object $profile_template 
  19. * @see BP_XProfile_Group::get() for full description of `$args` array. 
  20. * 
  21. * @param array|string $args { 
  22. * Array of arguments. See BP_XProfile_Group::get() for full description. Those arguments whose defaults differ 
  23. * from that method are described here: 
  24. * @type string|array $member_type Default: 'any'. 
  25. * @type bool $hide_empty_groups Default: true. 
  26. * @type bool $hide_empty_fields Defaults to true on the Dashboard, on a user's Edit Profile page,  
  27. * or during registration. Otherwise false. 
  28. * @type bool $fetch_visibility_level Defaults to true when an admin is viewing a profile, or when a user is 
  29. * viewing her own profile, or during registration. Otherwise false. 
  30. * @type bool $fetch_fields Default: true. 
  31. * @type bool $fetch_field_data Default: true. 
  32. * } 
  33. * 
  34. * @return bool 
  35. */ 
  36. function bp_has_profile( $args = '' ) { 
  37. global $profile_template; 
  38.  
  39. // Only show empty fields if we're on the Dashboard, or we're on a user's 
  40. // profile edit page, or this is a registration page. 
  41. $hide_empty_fields_default = ( ! is_network_admin() && ! is_admin() && ! bp_is_user_profile_edit() && ! bp_is_register_page() ); 
  42.  
  43. // We only need to fetch visibility levels when viewing your own profile. 
  44. if ( bp_is_my_profile() || bp_current_user_can( 'bp_moderate' ) || bp_is_register_page() ) { 
  45. $fetch_visibility_level_default = true; 
  46. } else { 
  47. $fetch_visibility_level_default = false; 
  48.  
  49. // Parse arguments. 
  50. $r = bp_parse_args( $args, array( 
  51. 'user_id' => bp_displayed_user_id(),  
  52. 'member_type' => 'any',  
  53. 'profile_group_id' => false,  
  54. 'hide_empty_groups' => true,  
  55. 'hide_empty_fields' => $hide_empty_fields_default,  
  56. 'fetch_fields' => true,  
  57. 'fetch_field_data' => true,  
  58. 'fetch_visibility_level' => $fetch_visibility_level_default,  
  59. 'exclude_groups' => false, // Comma-separated list of profile field group IDs to exclude. 
  60. 'exclude_fields' => false, // Comma-separated list of profile field IDs to exclude. 
  61. 'update_meta_cache' => true,  
  62. ), 'has_profile' ); 
  63.  
  64. // Populate the template loop global. 
  65. $profile_template = new BP_XProfile_Data_Template( $r ); 
  66.  
  67. /** 
  68. * Filters whether or not a group has a profile to display. 
  69. * 
  70. * @since 1.1.0 
  71. * @since 2.6.0 Added the `$r` parameter. 
  72. * 
  73. * @param bool $has_groups Whether or not there are group profiles to display. 
  74. * @param string $profile_template Current profile template being used. 
  75. * @param array $r Array of arguments passed into the BP_XProfile_Data_Template class. 
  76. */ 
  77. return apply_filters( 'bp_has_profile', $profile_template->has_groups(), $profile_template, $r ); 
  78.  
  79. /** 
  80. * Start off the profile groups. 
  81. * 
  82. * @since 1.0.0 
  83. * 
  84. * @return mixed 
  85. */ 
  86. function bp_profile_groups() { 
  87. global $profile_template; 
  88. return $profile_template->profile_groups(); 
  89.  
  90. /** 
  91. * Set up the profile groups. 
  92. * 
  93. * @since 1.0.0 
  94. * 
  95. * @return mixed 
  96. */ 
  97. function bp_the_profile_group() { 
  98. global $profile_template; 
  99. return $profile_template->the_profile_group(); 
  100.  
  101. /** 
  102. * Whether or not the group has fields to display. 
  103. * 
  104. * @since 1.0.0 
  105. * 
  106. * @return mixed 
  107. */ 
  108. function bp_profile_group_has_fields() { 
  109. global $profile_template; 
  110. return $profile_template->has_fields(); 
  111.  
  112. /** 
  113. * Output the class attribute for a field. 
  114. * 
  115. * @since 1.0.0 
  116. * 
  117. * @param mixed $class Extra classes to append to class attribute. 
  118. * Pass mutiple class names as an array or 
  119. * space-delimited string. 
  120. */ 
  121. function bp_field_css_class( $class = false ) { 
  122. echo bp_get_field_css_class( $class ); 
  123.  
  124. /** 
  125. * Return the class attribute for a field. 
  126. * 
  127. * @since 1.1.0 
  128. * 
  129. * @param string|bool $class Extra classes to append to class attribute. 
  130. * @return string 
  131. */ 
  132. function bp_get_field_css_class( $class = false ) { 
  133. global $profile_template; 
  134.  
  135. $css_classes = array(); 
  136.  
  137. if ( ! empty( $class ) ) { 
  138. if ( ! is_array( $class ) ) { 
  139. $class = preg_split( '#\s+#', $class ); 
  140. $css_classes = array_map( 'sanitize_html_class', $class ); 
  141.  
  142. // Set a class with the field ID. 
  143. $css_classes[] = 'field_' . $profile_template->field->id; 
  144.  
  145. // Set a class with the field name (sanitized). 
  146. $css_classes[] = 'field_' . sanitize_title( $profile_template->field->name ); 
  147.  
  148. // Set a class indicating whether the field is required or optional. 
  149. if ( ! empty( $profile_template->field->is_required ) ) { 
  150. $css_classes[] = 'required-field'; 
  151. } else { 
  152. $css_classes[] = 'optional-field'; 
  153.  
  154. // Add the field visibility level. 
  155. $css_classes[] = 'visibility-' . esc_attr( bp_get_the_profile_field_visibility_level() ); 
  156.  
  157. if ( $profile_template->current_field % 2 == 1 ) { 
  158. $css_classes[] = 'alt'; 
  159.  
  160. $css_classes[] = 'field_type_' . sanitize_title( $profile_template->field->type ); 
  161.  
  162. /** 
  163. * Filters the field classes to be applied to a field. 
  164. * 
  165. * @since 1.1.0 
  166. * 
  167. * @param array $css_classes Array of classes to be applied to field. Passed by reference. 
  168. */ 
  169. $css_classes = apply_filters_ref_array( 'bp_field_css_classes', array( &$css_classes ) ); 
  170.  
  171. /** 
  172. * Filters the class HTML attribute to be used on a field. 
  173. * 
  174. * @since 1.1.0 
  175. * 
  176. * @param string $value class HTML attribute with imploded classes. 
  177. */ 
  178. return apply_filters( 'bp_get_field_css_class', ' class="' . implode( ' ', $css_classes ) . '"' ); 
  179.  
  180. /** 
  181. * Whether or not the XProfile field has data to display. 
  182. * 
  183. * @since 1.0.0 
  184. * 
  185. * @global object $profile_template 
  186. * 
  187. * @return mixed 
  188. */ 
  189. function bp_field_has_data() { 
  190. global $profile_template; 
  191.  
  192. /** 
  193. * Filters whether or not the XProfile field has data to display. 
  194. * 
  195. * @since 2.8.0 
  196. * 
  197. * @param bool $value Whether or not there is data to display. 
  198. * @param object $profile_template Profile template object. 
  199. * @param string $value Profile field being displayed. 
  200. * @param string $value Profile field ID being displayed. 
  201. */ 
  202. return apply_filters( 'bp_field_has_data', $profile_template->field_has_data, $profile_template, $profile_template->field, $profile_template->field->id ); 
  203.  
  204. /** 
  205. * Whether or not the XProfile field has public data to display. 
  206. * 
  207. * @since 1.0.0 
  208. * 
  209. * @global object $profile_template 
  210. * 
  211. * @return bool 
  212. */ 
  213. function bp_field_has_public_data() { 
  214. global $profile_template; 
  215.  
  216. /** 
  217. * Filters whether or not the XProfile field has public data to display. 
  218. * 
  219. * @since 2.8.0 
  220. * 
  221. * @param bool $value Whether or not there is public data to display. 
  222. * @param object $profile_template Profile template object. 
  223. * @param string $value Profile field being displayed. 
  224. * @param string $value Profile field ID being displayed. 
  225. */ 
  226. return apply_filters( 'bp_field_has_public_data', ( ! empty( $profile_template->field_has_data ) ), $profile_template, $profile_template->field, $profile_template->field->id ); 
  227.  
  228. /** 
  229. * Output the XProfile group ID. 
  230. * 
  231. * @since 1.0.0 
  232. */ 
  233. function bp_the_profile_group_id() { 
  234. echo bp_get_the_profile_group_id(); 
  235.  
  236. /** 
  237. * Return the XProfile group ID. 
  238. * 
  239. * @since 1.1.0 
  240. * 
  241. * @return int 
  242. */ 
  243. function bp_get_the_profile_group_id() { 
  244. global $group; 
  245.  
  246. /** 
  247. * Filters the XProfile group ID. 
  248. * 
  249. * @since 1.1.0 
  250. * 
  251. * @param int $id ID for the profile group. 
  252. */ 
  253. return (int) apply_filters( 'bp_get_the_profile_group_id', $group->id ); 
  254.  
  255. /** 
  256. * Output the XProfile group name. 
  257. * 
  258. * @since 1.0.0 
  259. */ 
  260. function bp_the_profile_group_name() { 
  261. echo bp_get_the_profile_group_name(); 
  262.  
  263. /** 
  264. * Return the XProfile group name. 
  265. * 
  266. * @since 1.0.0 
  267. * 
  268. * @return string 
  269. */ 
  270. function bp_get_the_profile_group_name() { 
  271. global $group; 
  272.  
  273. /** 
  274. * Filters the XProfile group name. 
  275. * 
  276. * @since 1.0.0 
  277. * 
  278. * @param string $name Name for the profile group. 
  279. */ 
  280. return apply_filters( 'bp_get_the_profile_group_name', $group->name ); 
  281.  
  282. /** 
  283. * Output the XProfile group slug. 
  284. * 
  285. * @since 1.1.0 
  286. */ 
  287. function bp_the_profile_group_slug() { 
  288. echo bp_get_the_profile_group_slug(); 
  289.  
  290. /** 
  291. * Return the XProfile group slug. 
  292. * 
  293. * @since 1.1.0 
  294. * 
  295. * @return string 
  296. */ 
  297. function bp_get_the_profile_group_slug() { 
  298. global $group; 
  299.  
  300. /** 
  301. * Filters the XProfile group slug. 
  302. * 
  303. * @since 1.1.0 
  304. * 
  305. * @param string $value Slug for the profile group. 
  306. */ 
  307. return apply_filters( 'bp_get_the_profile_group_slug', sanitize_title( $group->name ) ); 
  308.  
  309. /** 
  310. * Output the XProfile group description. 
  311. * 
  312. * @since 1.0.0 
  313. */ 
  314. function bp_the_profile_group_description() { 
  315. echo bp_get_the_profile_group_description(); 
  316.  
  317. /** 
  318. * Return the XProfile group description. 
  319. * 
  320. * @since 1.0.0 
  321. * 
  322. * @return string 
  323. */ 
  324. function bp_get_the_profile_group_description() { 
  325. global $group; 
  326.  
  327. /** 
  328. * Filters the XProfile group description. 
  329. * 
  330. * @since 1.0.0 
  331. * 
  332. * @param string $description Description for the profile group. 
  333. */ 
  334. return apply_filters( 'bp_get_the_profile_group_description', $group->description ); 
  335.  
  336. /** 
  337. * Output the XProfile group edit form action. 
  338. * 
  339. * @since 1.1.0 
  340. */ 
  341. function bp_the_profile_group_edit_form_action() { 
  342. echo bp_get_the_profile_group_edit_form_action(); 
  343.  
  344. /** 
  345. * Return the XProfile group edit form action. 
  346. * 
  347. * @since 1.1.0 
  348. * 
  349. * @return string 
  350. */ 
  351. function bp_get_the_profile_group_edit_form_action() { 
  352. global $group; 
  353.  
  354. // Build the form action URL. 
  355. $form_action = trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/' . $group->id ); 
  356.  
  357. /** 
  358. * Filters the action for the XProfile group edit form. 
  359. * 
  360. * @since 1.1.0 
  361. * 
  362. * @param string $value URL for the action attribute on the 
  363. * profile group edit form. 
  364. */ 
  365. return apply_filters( 'bp_get_the_profile_group_edit_form_action', $form_action ); 
  366.  
  367. /** 
  368. * Output the XProfile group field IDs. 
  369. * 
  370. * @since 1.1.0 
  371. */ 
  372. function bp_the_profile_group_field_ids() { 
  373. echo bp_get_the_profile_group_field_ids(); 
  374.  
  375. /** 
  376. * Return the XProfile group field IDs. 
  377. * 
  378. * @since 1.1.0 
  379. * 
  380. * @return string 
  381. */ 
  382. function bp_get_the_profile_group_field_ids() { 
  383. global $group; 
  384.  
  385. $field_ids = ''; 
  386.  
  387. if ( !empty( $group->fields ) ) { 
  388. foreach ( (array) $group->fields as $field ) { 
  389. $field_ids .= $field->id . ', '; 
  390.  
  391. return substr( $field_ids, 0, -1 ); 
  392.  
  393. /** 
  394. * Output a comma-separated list of field IDs that are to be submitted on profile edit. 
  395. * 
  396. * @since 2.1.0 
  397. */ 
  398. function bp_the_profile_field_ids() { 
  399. echo bp_get_the_profile_field_ids(); 
  400. /** 
  401. * Generate a comma-separated list of field IDs that are to be submitted on profile edit. 
  402. * 
  403. * @since 2.1.0 
  404. * 
  405. * @return string 
  406. */ 
  407. function bp_get_the_profile_field_ids() { 
  408. global $profile_template; 
  409.  
  410. $field_ids = array(); 
  411. foreach ( $profile_template->groups as $group ) { 
  412. if ( ! empty( $group->fields ) ) { 
  413. $field_ids = array_merge( $field_ids, wp_list_pluck( $group->fields, 'id' ) ); 
  414.  
  415. $field_ids = implode( ', ', wp_parse_id_list( $field_ids ) ); 
  416.  
  417. /** 
  418. * Filters the comma-separated list of field IDs. 
  419. * 
  420. * @since 2.1.0 
  421. * 
  422. * @param string $field_ids Comma-separated field IDs. 
  423. */ 
  424. return apply_filters( 'bp_get_the_profile_field_ids', $field_ids ); 
  425.  
  426. /** 
  427. * Return the XProfile fields. 
  428. * 
  429. * @since 1.0.0 
  430. * 
  431. * @return mixed 
  432. */ 
  433. function bp_profile_fields() { 
  434. global $profile_template; 
  435. return $profile_template->profile_fields(); 
  436.  
  437. /** 
  438. * Sets up the XProfile field. 
  439. * 
  440. * @since 1.0.0 
  441. * 
  442. * @return mixed 
  443. */ 
  444. function bp_the_profile_field() { 
  445. global $profile_template; 
  446. return $profile_template->the_profile_field(); 
  447.  
  448. /** 
  449. * Output the XProfile field ID. 
  450. * 
  451. * @since 1.1.0 
  452. */ 
  453. function bp_the_profile_field_id() { 
  454. echo bp_get_the_profile_field_id(); 
  455.  
  456. /** 
  457. * Return the XProfile field ID. 
  458. * 
  459. * @since 1.1.0 
  460. * 
  461. * @return int 
  462. */ 
  463. function bp_get_the_profile_field_id() { 
  464. global $field; 
  465.  
  466. /** 
  467. * Filters the XProfile field ID. 
  468. * 
  469. * @since 1.1.0 
  470. * 
  471. * @param int $id ID for the profile field. 
  472. */ 
  473. return (int) apply_filters( 'bp_get_the_profile_field_id', $field->id ); 
  474.  
  475. /** 
  476. * Outputs the XProfile field name. 
  477. * 
  478. * @since 1.0.0 
  479. */ 
  480. function bp_the_profile_field_name() { 
  481. echo bp_get_the_profile_field_name(); 
  482.  
  483. /** 
  484. * Returns the XProfile field name. 
  485. * 
  486. * @since 1.0.0 
  487. * 
  488. * @return string 
  489. */ 
  490. function bp_get_the_profile_field_name() { 
  491. global $field; 
  492.  
  493. /** 
  494. * Filters the XProfile field name. 
  495. * 
  496. * @since 1.0.0 
  497. * 
  498. * @param string $name Name for the profile field. 
  499. */ 
  500. return apply_filters( 'bp_get_the_profile_field_name', $field->name ); 
  501.  
  502. /** 
  503. * Outputs the XProfile field value. 
  504. * 
  505. * @since 1.0.0 
  506. */ 
  507. function bp_the_profile_field_value() { 
  508. echo bp_get_the_profile_field_value(); 
  509.  
  510. /** 
  511. * Returns the XProfile field value. 
  512. * 
  513. * @since 1.0.0 
  514. * 
  515. * @return string 
  516. */ 
  517. function bp_get_the_profile_field_value() { 
  518. global $field; 
  519.  
  520. $field->data->value = bp_unserialize_profile_field( $field->data->value ); 
  521.  
  522. /** 
  523. * Filters the XProfile field value. 
  524. * 
  525. * @since 1.0.0 
  526. * 
  527. * @param string $value Value for the profile field. 
  528. * @param string $type Type for the profile field. 
  529. * @param int $id ID for the profile field. 
  530. */ 
  531. return apply_filters( 'bp_get_the_profile_field_value', $field->data->value, $field->type, $field->id ); 
  532.  
  533. /** 
  534. * Outputs the XProfile field edit value. 
  535. * 
  536. * @since 1.1.0 
  537. */ 
  538. function bp_the_profile_field_edit_value() { 
  539. echo bp_get_the_profile_field_edit_value(); 
  540.  
  541. /** 
  542. * Returns the XProfile field edit value. 
  543. * 
  544. * @since 1.1.0 
  545. * 
  546. * @return string 
  547. */ 
  548. function bp_get_the_profile_field_edit_value() { 
  549. global $field; 
  550.  
  551. /** 
  552. * Check to see if the posted value is different, if it is re-display this 
  553. * value as long as it's not empty and a required field. 
  554. */ 
  555. if ( ! isset( $field->data ) ) { 
  556. $field->data = new stdClass; 
  557.  
  558. if ( ! isset( $field->data->value ) ) { 
  559. $field->data->value = ''; 
  560.  
  561. if ( isset( $_POST['field_' . $field->id] ) && $field->data->value != $_POST['field_' . $field->id] ) { 
  562. if ( ! empty( $_POST['field_' . $field->id] ) ) { 
  563. $field->data->value = $_POST['field_' . $field->id]; 
  564. } else { 
  565. $field->data->value = ''; 
  566.  
  567. $field_value = isset( $field->data->value ) ? bp_unserialize_profile_field( $field->data->value ) : ''; 
  568.  
  569. /** 
  570. * Filters the XProfile field edit value. 
  571. * 
  572. * @since 1.1.0 
  573. * 
  574. * @param string $field_value Current field edit value. 
  575. * @param string $type Type for the profile field. 
  576. * @param int $id ID for the profile field. 
  577. */ 
  578. return apply_filters( 'bp_get_the_profile_field_edit_value', $field_value, $field->type, $field->id ); 
  579.  
  580. /** 
  581. * Outputs the XProfile field type. 
  582. * 
  583. * @since 1.1.0 
  584. */ 
  585. function bp_the_profile_field_type() { 
  586. echo bp_get_the_profile_field_type(); 
  587.  
  588. /** 
  589. * Returns the XProfile field type. 
  590. * 
  591. * @since 1.1.0 
  592. * 
  593. * @return string 
  594. */ 
  595. function bp_get_the_profile_field_type() { 
  596. global $field; 
  597.  
  598. /** 
  599. * Filters the XProfile field type. 
  600. * 
  601. * @since 1.1.0 
  602. * 
  603. * @param string $type Type for the profile field. 
  604. */ 
  605. return apply_filters( 'bp_the_profile_field_type', $field->type ); 
  606.  
  607. /** 
  608. * Outputs the XProfile field description. 
  609. * 
  610. * @since 1.1.0 
  611. */ 
  612. function bp_the_profile_field_description() { 
  613. echo bp_get_the_profile_field_description(); 
  614.  
  615. /** 
  616. * Returns the XProfile field description. 
  617. * 
  618. * @since 1.1.0 
  619. * 
  620. * @return string 
  621. */ 
  622. function bp_get_the_profile_field_description() { 
  623. global $field; 
  624.  
  625. /** 
  626. * Filters the XProfile field description. 
  627. * 
  628. * @since 1.1.0 
  629. * 
  630. * @param string $description Description for the profile field. 
  631. */ 
  632. return apply_filters( 'bp_get_the_profile_field_description', $field->description ); 
  633.  
  634. /** 
  635. * Outputs the XProfile field input name. 
  636. * 
  637. * @since 1.1.0 
  638. */ 
  639. function bp_the_profile_field_input_name() { 
  640. echo bp_get_the_profile_field_input_name(); 
  641.  
  642. /** 
  643. * Retursn the XProfile field input name. 
  644. * 
  645. * @since 1.1.0 
  646. * 
  647. * @return string 
  648. */ 
  649. function bp_get_the_profile_field_input_name() { 
  650. global $field; 
  651.  
  652. /** 
  653. * Filters the profile field input name. 
  654. * 
  655. * @since 1.1.0 
  656. * 
  657. * @param string $value Value used for the name attribute on an input. 
  658. */ 
  659. return apply_filters( 'bp_get_the_profile_field_input_name', 'field_' . $field->id ); 
  660.  
  661. /** 
  662. * Returns the action name for any signup errors related to this profile field. 
  663. * 
  664. * In the registration templates, signup errors are pulled from the global 
  665. * object and rendered at actions that look like 'bp_field_12_errors'. This 
  666. * function allows the action name to be easily concatenated and called in the 
  667. * following fashion: 
  668. * do_action( bp_get_the_profile_field_errors_action() ); 
  669. * 
  670. * @since 1.8.0 
  671. * 
  672. * @return string The _errors action name corresponding to this profile field. 
  673. */ 
  674. function bp_get_the_profile_field_errors_action() { 
  675. global $field; 
  676. return 'bp_field_' . $field->id . '_errors'; 
  677.  
  678. /** 
  679. * Displays field options HTML for field types of 'selectbox', 'multiselectbox',  
  680. * 'radio', 'checkbox', and 'datebox'. 
  681. * 
  682. * @since 1.1.0 
  683. * 
  684. * @param array $args Specify type for datebox. Allowed 'day', 'month', 'year'. 
  685. */ 
  686. function bp_the_profile_field_options( $args = array() ) { 
  687. echo bp_get_the_profile_field_options( $args ); 
  688. /** 
  689. * Retrieves field options HTML for field types of 'selectbox', 'multiselectbox', 'radio', 'checkbox', and 'datebox'. 
  690. * 
  691. * @since 1.1.0 
  692. * 
  693. * 
  694. * @param array $args { 
  695. * Array of optional arguments. 
  696. * @type string|bool $type Type of datebox. False if it's not a 
  697. * datebox, otherwise 'day, 'month', or 'year'. Default: false. 
  698. * @type int $user_id ID of the user whose profile values should be 
  699. * used when rendering options. Default: displayed user. 
  700. * } 
  701. * 
  702. * @return string $vaue Field options markup. 
  703. */ 
  704. function bp_get_the_profile_field_options( $args = array() ) { 
  705. global $field; 
  706.  
  707. $args = bp_parse_args( $args, array( 
  708. 'type' => false,  
  709. 'user_id' => bp_displayed_user_id(),  
  710. ), 'get_the_profile_field_options' ); 
  711.  
  712. /** 
  713. * In some cases, the $field global is not an instantiation of the BP_XProfile_Field class. 
  714. * However, we have to make sure that all data originally in $field gets merged back in, after reinstantiation. 
  715. */ 
  716. if ( ! method_exists( $field, 'get_children' ) ) { 
  717. $field_obj = xprofile_get_field( $field->id ); 
  718.  
  719. foreach ( $field as $field_prop => $field_prop_value ) { 
  720. if ( ! isset( $field_obj->{$field_prop} ) ) { 
  721. $field_obj->{$field_prop} = $field_prop_value; 
  722.  
  723. $field = $field_obj; 
  724.  
  725. ob_start(); 
  726. $field->type_obj->edit_field_options_html( $args ); 
  727. $html = ob_get_contents(); 
  728. ob_end_clean(); 
  729.  
  730. return $html; 
  731.  
  732. /** 
  733. * Render whether or not a profile field is required. 
  734. * 
  735. * @since 1.1.0 
  736. */ 
  737. function bp_the_profile_field_is_required() { 
  738. echo bp_get_the_profile_field_is_required(); 
  739.  
  740. /** 
  741. * Return whether or not a profile field is required. 
  742. * 
  743. * @since 1.1.0 
  744. * 
  745. * @return bool 
  746. */ 
  747. function bp_get_the_profile_field_is_required() { 
  748. global $field; 
  749.  
  750. $retval = false; 
  751.  
  752. if ( isset( $field->is_required ) ) { 
  753. $retval = $field->is_required; 
  754.  
  755. /** 
  756. * Filters whether or not a profile field is required. 
  757. * 
  758. * @since 1.1.0 
  759. * @since 2.8.0 Added field ID. 
  760. * 
  761. * @param bool $retval Whether or not the field is required. 
  762. * @param string $value Field ID that may be required. 
  763. */ 
  764. return (bool) apply_filters( 'bp_get_the_profile_field_is_required', $retval, $field->id ); 
  765.  
  766. /** 
  767. * Output the visibility level of this field. 
  768. * 
  769. * @since 1.6.0 
  770. */ 
  771. function bp_the_profile_field_visibility_level() { 
  772. echo bp_get_the_profile_field_visibility_level(); 
  773.  
  774. /** 
  775. * Return the visibility level of this field. 
  776. * 
  777. * @since 1.6.0 
  778. * 
  779. * @return string 
  780. */ 
  781. function bp_get_the_profile_field_visibility_level() { 
  782. global $field; 
  783.  
  784. // On the registration page, values stored in POST should take 
  785. // precedence over default visibility, so that submitted values 
  786. // are not lost on failure. 
  787. if ( bp_is_register_page() && ! empty( $_POST['field_' . $field->id . '_visibility'] ) ) { 
  788. $retval = esc_attr( $_POST['field_' . $field->id . '_visibility'] ); 
  789. } else { 
  790. $retval = ! empty( $field->visibility_level ) ? $field->visibility_level : 'public'; 
  791.  
  792. /** 
  793. * Filters the profile field visibility level. 
  794. * 
  795. * @since 1.6.0 
  796. * 
  797. * @param string $retval Field visibility level. 
  798. */ 
  799. return apply_filters( 'bp_get_the_profile_field_visibility_level', $retval ); 
  800.  
  801. /** 
  802. * Echo the visibility level label of this field. 
  803. * 
  804. * @since 1.6.0 
  805. */ 
  806. function bp_the_profile_field_visibility_level_label() { 
  807. echo bp_get_the_profile_field_visibility_level_label(); 
  808.  
  809. /** 
  810. * Return the visibility level label of this field. 
  811. * 
  812. * @since 1.6.0 
  813. * 
  814. * @return string 
  815. */ 
  816. function bp_get_the_profile_field_visibility_level_label() { 
  817. global $field; 
  818.  
  819. // On the registration page, values stored in POST should take 
  820. // precedence over default visibility, so that submitted values 
  821. // are not lost on failure. 
  822. if ( bp_is_register_page() && ! empty( $_POST['field_' . $field->id . '_visibility'] ) ) { 
  823. $level = esc_html( $_POST['field_' . $field->id . '_visibility'] ); 
  824. } else { 
  825. $level = ! empty( $field->visibility_level ) ? $field->visibility_level : 'public'; 
  826.  
  827. $fields = bp_xprofile_get_visibility_levels(); 
  828.  
  829. /** 
  830. * Filters the profile field visibility level label. 
  831. * 
  832. * @since 1.6.0 
  833. * @since 2.6.0 Added the `$level` parameter. 
  834. * 
  835. * @param string $retval Field visibility level label. 
  836. * @param string $level Field visibility level. 
  837. */ 
  838. return apply_filters( 'bp_get_the_profile_field_visibility_level_label', $fields[ $level ]['label'], $level ); 
  839.  
  840. /** 
  841. * Return unserialized profile field data. 
  842. * 
  843. * @since 1.0.0 
  844. * 
  845. * @param string $value Content to maybe unserialize. 
  846. * @return mixed|string 
  847. */ 
  848. function bp_unserialize_profile_field( $value ) { 
  849. if ( is_serialized($value) ) { 
  850. $field_value = maybe_unserialize($value); 
  851. $field_value = implode( ', ', $field_value ); 
  852. return $field_value; 
  853.  
  854. return $value; 
  855.  
  856. /** 
  857. * Output XProfile field data. 
  858. * 
  859. * @since 1.2.0 
  860. * 
  861. * @param string|array $args Array of arguments for field data. See {@link bp_get_profile_field_data} 
  862. */ 
  863. function bp_profile_field_data( $args = '' ) { 
  864. echo bp_get_profile_field_data( $args ); 
  865.  
  866. /** 
  867. * Return XProfile field data. 
  868. * 
  869. * @since 1.2.0 
  870. * 
  871. * @param string|array $args { 
  872. * Array of arguments for field data. 
  873. * 
  874. * @type string|int|bool $field Field identifier. 
  875. * @type int $user_id ID of the user to get field data for. 
  876. * } 
  877. * @return mixed 
  878. */ 
  879. function bp_get_profile_field_data( $args = '' ) { 
  880.  
  881. $r = wp_parse_args( $args, array( 
  882. 'field' => false, // Field name or ID. 
  883. 'user_id' => bp_displayed_user_id() 
  884. ) ); 
  885.  
  886. /** 
  887. * Filters the profile field data. 
  888. * 
  889. * @since 1.2.0 
  890. * @since 2.6.0 Added the `$r` parameter. 
  891. * 
  892. * @param mixed $value Profile data for a specific field for the user. 
  893. * @param array $r Array of parsed arguments. 
  894. */ 
  895. return apply_filters( 'bp_get_profile_field_data', xprofile_get_field_data( $r['field'], $r['user_id'] ), $r ); 
  896.  
  897. /** 
  898. * Get all profile field groups. 
  899. * 
  900. * @since 2.1.0 
  901. * 
  902. * @return array $groups 
  903. */ 
  904. function bp_profile_get_field_groups() { 
  905.  
  906. $groups = wp_cache_get( 'all', 'bp_xprofile_groups' ); 
  907. if ( false === $groups ) { 
  908. $groups = bp_xprofile_get_groups( array( 'fetch_fields' => true ) ); 
  909. wp_cache_set( 'all', $groups, 'bp_xprofile_groups' ); 
  910.  
  911. /** 
  912. * Filters all profile field groups. 
  913. * 
  914. * @since 2.1.0 
  915. * 
  916. * @param array $groups Array of available profile field groups. 
  917. */ 
  918. return apply_filters( 'bp_profile_get_field_groups', $groups ); 
  919.  
  920. /** 
  921. * Check if there is more than one group of fields for the profile being edited. 
  922. * 
  923. * @since 2.1.0 
  924. * 
  925. * @return bool True if there is more than one profile field group. 
  926. */ 
  927. function bp_profile_has_multiple_groups() { 
  928. $has_multiple_groups = count( (array) bp_profile_get_field_groups() ) > 1; 
  929.  
  930. /** 
  931. * Filters if there is more than one group of fields for the profile being edited. 
  932. * 
  933. * @since 2.1.0 
  934. * 
  935. * @param bool $has_multiple_groups Whether or not there are multiple groups. 
  936. */ 
  937. return (bool) apply_filters( 'bp_profile_has_multiple_groups', $has_multiple_groups ); 
  938.  
  939. /** 
  940. * Output the tabs to switch between profile field groups. 
  941. * 
  942. * @since 1.0.0 
  943. */ 
  944. function bp_profile_group_tabs() { 
  945. echo bp_get_profile_group_tabs(); 
  946.  
  947. /** 
  948. * Fires at the end of the tab output for switching between profile field 
  949. * groups. This action is in a strange place for legacy reasons. 
  950. * 
  951. * @since 1.0.0 
  952. */ 
  953. do_action( 'xprofile_profile_group_tabs' ); 
  954.  
  955. /** 
  956. * Return the XProfile group tabs. 
  957. * 
  958. * @since 2.3.0 
  959. * 
  960. * @return string 
  961. */ 
  962. function bp_get_profile_group_tabs() { 
  963.  
  964. // Get field group data. 
  965. $groups = bp_profile_get_field_groups(); 
  966. $group_name = bp_get_profile_group_name(); 
  967. $tabs = array(); 
  968.  
  969. // Loop through field groups and put a tab-lst together. 
  970. for ( $i = 0, $count = count( $groups ); $i < $count; ++$i ) { 
  971.  
  972. // Setup the selected class. 
  973. $selected = ''; 
  974. if ( $group_name === $groups[ $i ]->name ) { 
  975. $selected = ' class="current"'; 
  976.  
  977. // Skip if group has no fields. 
  978. if ( empty( $groups[ $i ]->fields ) ) { 
  979. continue; 
  980.  
  981. // Build the profile field group link. 
  982. $link = trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/' . $groups[ $i ]->id ); 
  983.  
  984. // Add tab to end of tabs array. 
  985. $tabs[] = sprintf( 
  986. '<li %1$s><a href="%2$s">%3$s</a></li>',  
  987. $selected,  
  988. esc_url( $link ),  
  989. esc_html( apply_filters( 'bp_get_the_profile_group_name', $groups[ $i ]->name ) ) 
  990. ); 
  991.  
  992. /** 
  993. * Filters the tabs to display for profile field groups. 
  994. * 
  995. * @since 1.5.0 
  996. * 
  997. * @param array $tabs Array of tabs to display. 
  998. * @param array $groups Array of profile groups. 
  999. * @param string $group_name Name of the current group displayed. 
  1000. */ 
  1001. $tabs = apply_filters( 'xprofile_filter_profile_group_tabs', $tabs, $groups, $group_name ); 
  1002.  
  1003. return join( '', $tabs ); 
  1004.  
  1005. /** 
  1006. * Output the XProfile group name. 
  1007. * 
  1008. * @since 1.0.0 
  1009. * 
  1010. * @param bool $deprecated Deprecated boolean parameter. 
  1011. * 
  1012. * @return string|mixed 
  1013. */ 
  1014. function bp_profile_group_name( $deprecated = true ) { 
  1015. if ( ! $deprecated ) { 
  1016. return bp_get_profile_group_name(); 
  1017. } else { 
  1018. echo bp_get_profile_group_name(); 
  1019.  
  1020. /** 
  1021. * Return the XProfile group name. 
  1022. * 
  1023. * @since 1.0.0 
  1024. * 
  1025. * @return string 
  1026. */ 
  1027. function bp_get_profile_group_name() { 
  1028.  
  1029. // Check action variable. 
  1030. $group_id = bp_action_variable( 1 ); 
  1031. if ( empty( $group_id ) || ! is_numeric( $group_id ) ) { 
  1032. $group_id = 1; 
  1033.  
  1034. // Check for cached group. 
  1035. $group = new BP_XProfile_Group( $group_id ); 
  1036.  
  1037. /** 
  1038. * Filters the profile group name. 
  1039. * 
  1040. * @since 1.0.0 
  1041. * @since 2.6.0 Added the `$group_id` parameter 
  1042. * 
  1043. * @param string $name Name of the profile group. 
  1044. * @param int $group_id ID of the profile group. 
  1045. */ 
  1046. return apply_filters( 'bp_get_profile_group_name', $group->name, $group_id ); 
  1047.  
  1048. /** 
  1049. * Render a formatted string displaying when a profile was last updated. 
  1050. * 
  1051. * @since 1.0.0 
  1052. */ 
  1053. function bp_profile_last_updated() { 
  1054.  
  1055. $last_updated = bp_get_profile_last_updated(); 
  1056.  
  1057. if ( empty( $last_updated ) ) { 
  1058. _e( 'Profile not recently updated.', 'buddypress' ); 
  1059. } else { 
  1060. echo $last_updated; 
  1061.  
  1062. /** 
  1063. * Return a formatted string displaying when a profile was last updated. 
  1064. * 
  1065. * @since 1.0.0 
  1066. * 
  1067. * @return bool|string 
  1068. */ 
  1069. function bp_get_profile_last_updated() { 
  1070.  
  1071. $last_updated = bp_get_user_meta( bp_displayed_user_id(), 'profile_last_updated', true ); 
  1072.  
  1073. if ( ! empty( $last_updated ) ) { 
  1074.  
  1075. /** 
  1076. * Filters the formatted string used to display when a profile was last updated. 
  1077. * 
  1078. * @since 1.0.0 
  1079. * 
  1080. * @param string $value Formatted last updated indicator string. 
  1081. */ 
  1082. return apply_filters( 'bp_get_profile_last_updated', sprintf( __( 'Profile updated %s', 'buddypress' ), bp_core_time_since( strtotime( $last_updated ) ) ) ); 
  1083.  
  1084. return false; 
  1085.  
  1086. /** 
  1087. * Display the current profile group ID. 
  1088. * 
  1089. * @since 1.1.0 
  1090. */ 
  1091. function bp_current_profile_group_id() { 
  1092. echo bp_get_current_profile_group_id(); 
  1093.  
  1094. /** 
  1095. * Return the current profile group ID. 
  1096. * 
  1097. * @since 1.1.0 
  1098. * 
  1099. * @return int 
  1100. */ 
  1101. function bp_get_current_profile_group_id() { 
  1102. $profile_group_id = bp_action_variable( 1 ); 
  1103. if ( empty( $profile_group_id ) ) { 
  1104. $profile_group_id = 1; 
  1105.  
  1106. /** 
  1107. * Filters the current profile group ID. 
  1108. * 
  1109. * Possible values are admin/profile/edit/[group-id]. 
  1110. * 
  1111. * @since 1.1.0 
  1112. * 
  1113. * @param int $profile_group_id Current profile group ID. 
  1114. */ 
  1115. return (int) apply_filters( 'bp_get_current_profile_group_id', $profile_group_id ); 
  1116.  
  1117. /** 
  1118. * Render an avatar delete link. 
  1119. * 
  1120. * @since 1.1.0 
  1121. */ 
  1122. function bp_avatar_delete_link() { 
  1123. echo bp_get_avatar_delete_link(); 
  1124.  
  1125. /** 
  1126. * Return an avatar delete link. 
  1127. * 
  1128. * @since 1.1.0 
  1129. * 
  1130. * @return string 
  1131. */ 
  1132. function bp_get_avatar_delete_link() { 
  1133.  
  1134. /** 
  1135. * Filters the link used for deleting an avatar. 
  1136. * 
  1137. * @since 1.1.0 
  1138. * 
  1139. * @param string $value Nonced URL used for deleting an avatar. 
  1140. */ 
  1141. return apply_filters( 'bp_get_avatar_delete_link', wp_nonce_url( bp_displayed_user_domain() . bp_get_profile_slug() . '/change-avatar/delete-avatar/', 'bp_delete_avatar_link' ) ); 
  1142.  
  1143. /** 
  1144. * Render an edit profile button. 
  1145. * 
  1146. * @since 1.0.0 
  1147. */ 
  1148. function bp_edit_profile_button() { 
  1149. bp_button( array( 
  1150. 'id' => 'edit_profile',  
  1151. 'component' => 'xprofile',  
  1152. 'must_be_logged_in' => true,  
  1153. 'block_self' => true,  
  1154. 'link_href' => trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit' ),  
  1155. 'link_class' => 'edit',  
  1156. 'link_text' => __( 'Edit Profile', 'buddypress' ),  
  1157. ) ); 
  1158.  
  1159. /** Visibility ****************************************************************/ 
  1160.  
  1161. /** 
  1162. * Echo the field visibility radio buttons. 
  1163. * 
  1164. * @since 1.6.0 
  1165. * 
  1166. * @param array|string $args Args for the radio buttons. See {@link bp_profile_get_visibility_radio_buttons} 
  1167. */ 
  1168. function bp_profile_visibility_radio_buttons( $args = '' ) { 
  1169. echo bp_profile_get_visibility_radio_buttons( $args ); 
  1170. /** 
  1171. * Return the field visibility radio buttons. 
  1172. * 
  1173. * @since 1.6.0 
  1174. * 
  1175. * @param array|string $args { 
  1176. * Args for the radio buttons. 
  1177. * 
  1178. * @type int $field_id ID of the field to render. 
  1179. * @type string $before Markup to render before the field. 
  1180. * @type string $after Markup to render after the field. 
  1181. * @type string $before_radio Markup to render before the radio button. 
  1182. * @type string $after_radio Markup to render after the radio button. 
  1183. * @type string $class Class to apply to the field markup. 
  1184. * } 
  1185. * @return string $retval 
  1186. */ 
  1187. function bp_profile_get_visibility_radio_buttons( $args = '' ) { 
  1188.  
  1189. // Parse optional arguments. 
  1190. $r = bp_parse_args( $args, array( 
  1191. 'field_id' => bp_get_the_profile_field_id(),  
  1192. 'before' => '<ul class="radio">',  
  1193. 'after' => '</ul>',  
  1194. 'before_radio' => '<li class="%s">',  
  1195. 'after_radio' => '</li>',  
  1196. 'class' => 'bp-xprofile-visibility' 
  1197. ), 'xprofile_visibility_radio_buttons' ); 
  1198.  
  1199. // Empty return value, filled in below if a valid field ID is found. 
  1200. $retval = ''; 
  1201.  
  1202. // Only do-the-do if there's a valid field ID. 
  1203. if ( ! empty( $r['field_id'] ) ) : 
  1204.  
  1205. // Start the output buffer. 
  1206. ob_start(); 
  1207.  
  1208. // Output anything before. 
  1209. echo $r['before']; ?> 
  1210.  
  1211. <?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?> 
  1212.  
  1213. <?php foreach( bp_xprofile_get_visibility_levels() as $level ) : ?> 
  1214.  
  1215. <?php printf( $r['before_radio'], esc_attr( $level['id'] ) ); ?> 
  1216.  
  1217. <label for="<?php echo esc_attr( 'see-field_' . $r['field_id'] . '_' . $level['id'] ); ?>"> 
  1218. <input type="radio" id="<?php echo esc_attr( 'see-field_' . $r['field_id'] . '_' . $level['id'] ); ?>" name="<?php echo esc_attr( 'field_' . $r['field_id'] . '_visibility' ); ?>" value="<?php echo esc_attr( $level['id'] ); ?>" <?php checked( $level['id'], bp_get_the_profile_field_visibility_level() ); ?> /> 
  1219. <span class="field-visibility-text"><?php echo esc_html( $level['label'] ); ?></span> 
  1220. </label> 
  1221.  
  1222. <?php echo $r['after_radio']; ?> 
  1223.  
  1224. <?php endforeach; ?> 
  1225.  
  1226. <?php endif; 
  1227.  
  1228. // Output anything after. 
  1229. echo $r['after']; 
  1230.  
  1231. // Get the output buffer and empty it. 
  1232. $retval = ob_get_clean(); 
  1233. endif; 
  1234.  
  1235. /** 
  1236. * Filters the radio buttons for setting visibility. 
  1237. * 
  1238. * @since 1.6.0 
  1239. * 
  1240. * @param string $retval HTML output for the visibility radio buttons. 
  1241. * @param array $r Parsed arguments to be used with display. 
  1242. * @param array $args Original passed in arguments to be used with display. 
  1243. */ 
  1244. return apply_filters( 'bp_profile_get_visibility_radio_buttons', $retval, $r, $args ); 
  1245.  
  1246. /** 
  1247. * Output the XProfile field visibility select list for settings. 
  1248. * 
  1249. * @since 2.0.0 
  1250. * 
  1251. * @param array|string $args Args for the select list. See {@link bp_profile_get_settings_visibility_select} 
  1252. */ 
  1253. function bp_profile_settings_visibility_select( $args = '' ) { 
  1254. echo bp_profile_get_settings_visibility_select( $args ); 
  1255. /** 
  1256. * Return the XProfile field visibility select list for settings. 
  1257. * 
  1258. * @since 2.0.0 
  1259. * 
  1260. * @param array|string $args { 
  1261. * Args for the select list. 
  1262. * 
  1263. * @type int $field_id ID of the field to render. 
  1264. * @type string $before Markup to render before the field. 
  1265. * @type string $before_controls markup before form controls. 
  1266. * @type string $after Markup to render after the field. 
  1267. * @type string $after_controls Markup after the form controls. 
  1268. * @type string $class Class to apply to the field markup. 
  1269. * @type string $label_class Class to apply for the label element. 
  1270. * @type string $notoggle_tag Markup element to use for notoggle tag. 
  1271. * @type string $notoggle_class Class to apply to the notoggle element. 
  1272. * } 
  1273. * @return string $retval 
  1274. */ 
  1275. function bp_profile_get_settings_visibility_select( $args = '' ) { 
  1276.  
  1277. // Parse optional arguments. 
  1278. $r = bp_parse_args( $args, array( 
  1279. 'field_id' => bp_get_the_profile_field_id(),  
  1280. 'before' => '',  
  1281. 'before_controls' => '',  
  1282. 'after' => '',  
  1283. 'after_controls' => '',  
  1284. 'class' => 'bp-xprofile-visibility',  
  1285. 'label_class' => 'bp-screen-reader-text',  
  1286. 'notoggle_tag' => 'span',  
  1287. 'notoggle_class' => 'field-visibility-settings-notoggle',  
  1288. ), 'xprofile_settings_visibility_select' ); 
  1289.  
  1290. // Empty return value, filled in below if a valid field ID is found. 
  1291. $retval = ''; 
  1292.  
  1293. // Only do-the-do if there's a valid field ID. 
  1294. if ( ! empty( $r['field_id'] ) ) : 
  1295.  
  1296. // Start the output buffer. 
  1297. ob_start(); 
  1298.  
  1299. // Output anything before. 
  1300. echo $r['before']; ?> 
  1301.  
  1302. <?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?> 
  1303.  
  1304. <?php echo $r['before_controls']; ?> 
  1305.  
  1306. <label for="<?php echo esc_attr( 'field_' . $r['field_id'] ) ; ?>_visibility" class="<?php echo esc_attr( $r['label_class'] ); ?>"><?php 
  1307. /** translators: accessibility text */ 
  1308. _e( 'Select visibility', 'buddypress' ); 
  1309. ?></label> 
  1310. <select class="<?php echo esc_attr( $r['class'] ); ?>" name="<?php echo esc_attr( 'field_' . $r['field_id'] ) ; ?>_visibility" id="<?php echo esc_attr( 'field_' . $r['field_id'] ) ; ?>_visibility"> 
  1311.  
  1312. <?php foreach ( bp_xprofile_get_visibility_levels() as $level ) : ?> 
  1313.  
  1314. <option value="<?php echo esc_attr( $level['id'] ); ?>" <?php selected( $level['id'], bp_get_the_profile_field_visibility_level() ); ?>><?php echo esc_html( $level['label'] ); ?></option> 
  1315.  
  1316. <?php endforeach; ?> 
  1317.  
  1318. </select> 
  1319.  
  1320. <?php echo $r['after_controls']; ?> 
  1321.  
  1322. <?php else : ?> 
  1323.  
  1324. <<?php echo esc_html( $r['notoggle_tag'] ); ?> class="<?php echo esc_attr( $r['notoggle_class'] ); ?>"><?php bp_the_profile_field_visibility_level_label(); ?></<?php echo esc_html( $r['notoggle_tag'] ); ?>> 
  1325.  
  1326. <?php endif; 
  1327.  
  1328. // Output anything after. 
  1329. echo $r['after']; 
  1330.  
  1331. // Get the output buffer and empty it. 
  1332. $retval = ob_get_clean(); 
  1333. endif; 
  1334.  
  1335. /** 
  1336. * Filters the dropdown list for setting visibility. 
  1337. * 
  1338. * @since 2.0.0 
  1339. * 
  1340. * @param string $retval HTML output for the visibility dropdown list. 
  1341. * @param array $r Parsed arguments to be used with display. 
  1342. * @param array $args Original passed in arguments to be used with display. 
  1343. */ 
  1344. return apply_filters( 'bp_profile_settings_visibility_select', $retval, $r, $args ); 
  1345.  
  1346. /** 
  1347. * Output the 'required' markup in extended profile field labels. 
  1348. * 
  1349. * @since 2.4.0 
  1350. */ 
  1351. function bp_the_profile_field_required_label() { 
  1352. echo bp_get_the_profile_field_required_label(); 
  1353.  
  1354. /** 
  1355. * Return the 'required' markup in extended profile field labels. 
  1356. * 
  1357. * @since 2.4.0 
  1358. * 
  1359. * @return string HTML for the required label. 
  1360. */ 
  1361. function bp_get_the_profile_field_required_label() { 
  1362. $retval = ''; 
  1363.  
  1364. if ( bp_get_the_profile_field_is_required() ) { 
  1365. $translated_string = __( '(required)', 'buddypress' ); 
  1366.  
  1367. $retval = ' <span class="bp-required-field-label">'; 
  1368. $retval .= apply_filters( 'bp_get_the_profile_field_required_label', $translated_string, bp_get_the_profile_field_id() ); 
  1369. $retval .= '</span>'; 
  1370.  
  1371.  
  1372. return $retval; 
.