Changeset 12887 for trunk/src/bp-xprofile/bp-xprofile-filters.php
- Timestamp:
- 04/16/2021 05:37:03 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/bp-xprofile-filters.php
r12869 r12887 692 692 return $exporters; 693 693 } 694 695 /** 696 * Used to edit the field input name inside the xProfile Admin Screen 697 * 698 * @see bp_xprofile_admin_get_signup_field() 699 * 700 * @since 8.0.0 701 * 702 * @param string $field_selector The text to use as the input name/id attribute. 703 * @return string The text to use as the input name/id attribute. 704 */ 705 function bp_get_the_profile_signup_field_input_name( $field_selector = '' ) { 706 global $field; 707 708 if ( isset( $field->id ) && $field->id ) { 709 $field_selector = sprintf( 'signup_field_%d', $field->id ); 710 } 711 712 return $field_selector; 713 } 714 715 /** 716 * Provides Signup fields argument back compatibility for template overrides. 717 * 718 * @since 8.0.0 719 * @access private 720 * 721 * @param array $args The xProfile loop's signup arguments. 722 * @return array The xProfile loop's signup arguments. 723 */ 724 function _bp_xprofile_signup_do_backcompat( $args = array() ) { 725 $expected_args = bp_xprofile_signup_args(); 726 $needed_args = array_intersect_key( $args, $expected_args ); 727 728 if ( 1 === $args['profile_group_id'] || array_diff_key( $expected_args, $needed_args ) ) { 729 _doing_it_wrong( 'bp_has_profile()', __( 'The argument of this function into your custom `members/register.php` template should be bp_xprofile_signup_args()', 'buddypress' ), '8.0.0' ); 730 $args = $expected_args; 731 } 732 733 return $args; 734 } 735 736 /** 737 * Checks whether back compatibility is needed about xProfile loop's signup arguments. 738 * 739 * @since 8.0.0 740 * @access private 741 * 742 * @param string $template The located path for registration template. 743 * @param string $template_name The needed template name. 744 */ 745 function _bp_xprofile_signup_check_backcompat( $template = '', $template_name = '' ) { 746 if ( 'members/register.php' !== $template_name ) { 747 return; 748 } 749 750 if ( 0 !== strpos( $template, buddypress()->theme_compat->theme->dir ) ) { 751 add_filter( 'bp_after_has_profile_parse_args', '_bp_xprofile_signup_do_backcompat', 100 ); 752 } 753 } 754 755 /** 756 * Starts Signup fields back compatibility process only on the signup's page. 757 * 758 * @since 8.0.0 759 * @access private 760 */ 761 function _bp_xprofile_signup_start_backcompat() { 762 $signup_fields = (array) bp_xprofile_get_signup_field_ids(); 763 if ( ! $signup_fields ) { 764 return; 765 } 766 767 add_action( 'bp_locate_template', '_bp_xprofile_signup_check_backcompat', 10, 2 ); 768 } 769 add_action( 'bp_core_screen_signup', '_bp_xprofile_signup_start_backcompat' );
Note: See TracChangeset
for help on using the changeset viewer.