Changeset 12887
- Timestamp:
- 04/16/2021 05:37:03 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
-
src/bp-templates/bp-legacy/buddypress/members/register.php (modified) (1 diff)
-
src/bp-templates/bp-nouveau/buddypress/members/register.php (modified) (2 diffs)
-
src/bp-templates/bp-nouveau/includes/template-tags.php (modified) (1 diff)
-
src/bp-templates/bp-nouveau/includes/xprofile/template-tags.php (modified) (2 diffs)
-
src/bp-xprofile/bp-xprofile-filters.php (modified) (1 diff)
-
tests/phpunit/testcases/xprofile/template.php (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-templates/bp-legacy/buddypress/members/register.php
r12595 r12887 166 166 167 167 <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?> 168 <?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => false) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>168 <?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( bp_xprofile_signup_args() ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?> 169 169 170 170 <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> -
trunk/src/bp-templates/bp-nouveau/buddypress/members/register.php
r12260 r12887 4 4 * 5 5 * @since 3.0.0 6 * @version 4.0.06 * @version 8.0.0 7 7 */ 8 8 … … 39 39 <?php /***** Extra Profile Details ******/ ?> 40 40 41 <?php if ( bp_is_active( 'xprofile' ) && bp_nouveau_ base_account_has_xprofile() ) : ?>41 <?php if ( bp_is_active( 'xprofile' ) && bp_nouveau_has_signup_xprofile_fields( true ) ) : ?> 42 42 43 43 <?php bp_nouveau_signup_hook( 'before', 'signup_profile' ); ?> -
trunk/src/bp-templates/bp-nouveau/includes/template-tags.php
r12836 r12887 1516 1516 1517 1517 // Provide a class token to acknowledge additional extended profile fields added to default account reg screen 1518 if ( 'register' === bp_current_component() && bp_is_active( 'xprofile' ) && bp_nouveau_ base_account_has_xprofile()) {1518 if ( 'register' === bp_current_component() && bp_is_active( 'xprofile' ) && bp_nouveau_has_signup_xprofile_fields()) { 1519 1519 $classes[] = 'extended-default-reg'; 1520 1520 } -
trunk/src/bp-templates/bp-nouveau/includes/xprofile/template-tags.php
r12082 r12887 4 4 * 5 5 * @since 3.0.0 6 * @version 3.0.06 * @version 8.0.0 7 7 */ 8 8 … … 63 63 * 64 64 * @since 3.0.0 65 * @deprecated 8.0.0 65 66 */ 66 67 function bp_nouveau_base_account_has_xprofile() { 67 return (bool) bp_has_profile( 68 array( 69 'profile_group_id' => 1, 70 'fetch_field_data' => false, 71 ) 72 ); 68 _deprecated_function( __FUNCTION__, '8.0.0', 'bp_nouveau_has_signup_xprofile_fields()' ); 69 return bp_nouveau_has_signup_xprofile_fields(); 73 70 } 71 72 /** 73 * Checks whether there are signup profile fields to display. 74 * 75 * @since 8.0.0 76 * 77 * @param bool Whether to init an xProfile loop. 78 * @return bool True if there are signup profile fields to display. False otherwise. 79 */ 80 function bp_nouveau_has_signup_xprofile_fields( $do_loop = false ) { 81 if ( ! $do_loop ) { 82 $signup_fields = (array) bp_xprofile_get_signup_field_ids(); 83 return 1 <= count( $signup_fields ); 84 } 85 86 return bp_has_profile( bp_xprofile_signup_args() ); 87 } -
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.