Changeset 10163 for trunk/src/bp-xprofile/bp-xprofile-template.php
- Timestamp:
- 10/01/2015 04:18:13 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/bp-xprofile-template.php
r10140 r10163 116 116 * @since 2.4.0 Introduced `$member_type` argument. 117 117 * 118 * @param array $args {118 * @param array|string $args { 119 119 * An array of arguments. All items are optional. 120 120 * … … 134 134 public function __construct( $args = '' ) { 135 135 136 // Backward compatibility with old method of passing arguments 136 // Backward compatibility with old method of passing arguments. 137 137 if ( ! is_array( $args ) || func_num_args() > 1 ) { 138 138 _deprecated_argument( __METHOD__, '2.3.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); … … 224 224 do_action( 'xprofile_template_loop_end' ); 225 225 226 // Do some cleaning up after the loop 226 // Do some cleaning up after the loop. 227 227 $this->rewind_groups(); 228 228 } … … 238 238 $group = $this->next_group(); 239 239 240 // loop has just started240 // Loop has just started. 241 241 if ( 0 === $this->current_group ) { 242 242 … … 285 285 return true; 286 286 } elseif ( $this->current_field + 1 == $this->field_count ) { 287 // Do some cleaning up after the loop 287 // Do some cleaning up after the loop. 288 288 $this->rewind_fields(); 289 289 } … … 297 297 $field = $this->next_field(); 298 298 299 // Valid field values of 0 or '0' get caught by empty(), so we have an extra check for these. See #BP5731 299 // Valid field values of 0 or '0' get caught by empty(), so we have an extra check for these. See #BP5731. 300 300 if ( ! empty( $field->data ) && ( ! empty( $field->data->value ) || ( '0' === $field->data->value ) ) ) { 301 301 $value = maybe_unserialize( $field->data->value ); … … 313 313 314 314 /** 315 * Query for XProfile groups and fields 315 * Query for XProfile groups and fields. 316 316 * 317 317 * @since 1.0.0 … … 320 320 * @see BP_XProfile_Group::get() for full description of `$args` array. 321 321 * 322 * @param array $args {322 * @param array|string $args { 323 323 * Array of arguments. See BP_XProfile_Group::get() for full description. Those arguments whose defaults differ 324 324 * from that method are described here: … … 339 339 340 340 // Only show empty fields if we're on the Dashboard, or we're on a user's 341 // profile edit page, or this is a registration page 341 // profile edit page, or this is a registration page. 342 342 $hide_empty_fields_default = ( ! is_network_admin() && ! is_admin() && ! bp_is_user_profile_edit() && ! bp_is_register_page() ); 343 343 344 // We only need to fetch visibility levels when viewing your own profile 344 // We only need to fetch visibility levels when viewing your own profile. 345 345 if ( bp_is_my_profile() || bp_current_user_can( 'bp_moderate' ) || bp_is_register_page() ) { 346 346 $fetch_visibility_level_default = true; … … 349 349 } 350 350 351 // Parse arguments 351 // Parse arguments. 352 352 $r = bp_parse_args( $args, array( 353 353 'user_id' => bp_displayed_user_id(), … … 359 359 'fetch_field_data' => true, 360 360 'fetch_visibility_level' => $fetch_visibility_level_default, 361 'exclude_groups' => false, // Comma-separated list of profile field group IDs to exclude 362 'exclude_fields' => false, // Comma-separated list of profile field IDs to exclude 361 'exclude_groups' => false, // Comma-separated list of profile field group IDs to exclude. 362 'exclude_fields' => false, // Comma-separated list of profile field IDs to exclude. 363 363 'update_meta_cache' => true, 364 364 ), 'has_profile' ); 365 365 366 // Populate the template loop global 366 // Populate the template loop global. 367 367 $profile_template = new BP_XProfile_Data_Template( $r ); 368 368 … … 405 405 } 406 406 407 // Set a class with the field ID 407 // Set a class with the field ID. 408 408 $css_classes[] = 'field_' . $profile_template->field->id; 409 409 410 // Set a class with the field name (sanitized) 410 // Set a class with the field name (sanitized). 411 411 $css_classes[] = 'field_' . sanitize_title( $profile_template->field->name ); 412 412 413 // Set a class indicating whether the field is required or optional 413 // Set a class indicating whether the field is required or optional. 414 414 if ( ! empty( $profile_template->field->is_required ) ) { 415 415 $css_classes[] = 'required-field'; … … 418 418 } 419 419 420 // Add the field visibility level 420 // Add the field visibility level. 421 421 $css_classes[] = 'visibility-' . esc_attr( bp_get_the_profile_field_visibility_level() ); 422 422 … … 531 531 global $group; 532 532 533 // Build the form action URL 533 // Build the form action URL. 534 534 $form_action = trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/' . $group->id ); 535 535 … … 750 750 751 751 /** 752 * Returns the action name for any signup errors related to this profile field 752 * Returns the action name for any signup errors related to this profile field. 753 753 * 754 754 * In the registration templates, signup errors are pulled from the global … … 759 759 * 760 760 * @since 1.8.0 761 * @return string The _errors action name corresponding to this profile field 761 * 762 * @return string The _errors action name corresponding to this profile field. 762 763 */ 763 764 function bp_get_the_profile_field_errors_action() { … … 767 768 768 769 /** 769 * bp_the_profile_field_options()770 *771 770 * Displays field options HTML for field types of 'selectbox', 'multiselectbox', 772 771 * 'radio', 'checkbox', and 'datebox'. 773 772 * 774 * @package BuddyPress Xprofile775 773 * @since 1.1.0 776 774 * … … 783 781 } 784 782 /** 785 * bp_get_the_profile_field_options()786 *787 783 * Retrieves field options HTML for field types of 'selectbox', 'multiselectbox', 'radio', 'checkbox', and 'datebox'. 788 784 * 789 * @package BuddyPress Xprofile790 785 * @since 1.1.0 791 786 * … … 795 790 * @param array $args { 796 791 * Array of optional arguments. 797 * @type string|bool $type Type of datebox. False if it's not a798 * datebox, otherwise 'day, 'month', or 'year'. Default: false.799 * @type int $user_id ID of the user whose profile values should be800 * used when rendering options. Default: displayed user.792 * @type string|bool $type Type of datebox. False if it's not a 793 * datebox, otherwise 'day, 'month', or 'year'. Default: false. 794 * @type int $user_id ID of the user whose profile values should be 795 * used when rendering options. Default: displayed user. 801 796 * } 797 * 798 * @return string $vaue Field options markup. 802 799 */ 803 800 function bp_get_the_profile_field_options( $args = array() ) { … … 839 836 global $field; 840 837 841 // Define locale variable(s) 838 // Define locale variable(s). 842 839 $retval = false; 843 840 844 // Super admins can skip required check 841 // Super admins can skip required check. 845 842 if ( bp_current_user_can( 'bp_moderate' ) && !is_admin() ) { 846 843 $retval = false; 847 844 848 // All other users will use the field's setting 845 // All other users will use the field's setting. 849 846 } elseif ( isset( $field->is_required ) ) { 850 847 $retval = $field->is_required; … … 862 859 863 860 /** 864 * Echo the visibility level of this field 861 * Echo the visibility level of this field. 865 862 */ 866 863 function bp_the_profile_field_visibility_level() { … … 868 865 } 869 866 /** 870 * Return the visibility level of this field 867 * Return the visibility level of this field. 871 868 */ 872 869 function bp_get_the_profile_field_visibility_level() { … … 875 872 // On the registration page, values stored in POST should take 876 873 // precedence over default visibility, so that submitted values 877 // are not lost on failure 874 // are not lost on failure. 878 875 if ( bp_is_register_page() && ! empty( $_POST['field_' . $field->id . '_visibility'] ) ) { 879 876 $retval = esc_attr( $_POST['field_' . $field->id . '_visibility'] ); … … 893 890 894 891 /** 895 * Echo the visibility level label of this field 892 * Echo the visibility level label of this field. 896 893 */ 897 894 function bp_the_profile_field_visibility_level_label() { … … 899 896 } 900 897 /** 901 * Return the visibility level label of this field 898 * Return the visibility level label of this field. 902 899 */ 903 900 function bp_get_the_profile_field_visibility_level_label() { … … 906 903 // On the registration page, values stored in POST should take 907 904 // precedence over default visibility, so that submitted values 908 // are not lost on failure 905 // are not lost on failure. 909 906 if ( bp_is_register_page() && ! empty( $_POST['field_' . $field->id . '_visibility'] ) ) { 910 907 $level = esc_html( $_POST['field_' . $field->id . '_visibility'] ); … … 959 956 * Get all profile field groups. 960 957 * 961 * @since 958 * @since 2.1.0 962 959 * 963 960 * @return object $groups … … 984 981 * Check if there is more than one group of fields for the profile being edited. 985 982 * 986 * @since 983 * @since 2.1.0 987 984 * 988 985 * @return bool True if there is more than one profile field group. … … 1005 1002 * 1006 1003 * @since 1.0.0 1007 *1008 * @return string Field group tabs markup.1009 1004 */ 1010 1005 function bp_profile_group_tabs() { … … 1021 1016 1022 1017 /** 1023 * Return the XProfile group tabs 1018 * Return the XProfile group tabs. 1024 1019 * 1025 1020 * @since 2.3.0 … … 1029 1024 function bp_get_profile_group_tabs() { 1030 1025 1031 // Get field group data 1026 // Get field group data. 1032 1027 $groups = bp_profile_get_field_groups(); 1033 1028 $group_name = bp_get_profile_group_name(); 1034 1029 $tabs = array(); 1035 1030 1036 // Loop through field groups and put a tab-lst together 1031 // Loop through field groups and put a tab-lst together. 1037 1032 for ( $i = 0, $count = count( $groups ); $i < $count; ++$i ) { 1038 1033 1039 // Setup the selected class 1034 // Setup the selected class. 1040 1035 $selected = ''; 1041 1036 if ( $group_name === $groups[ $i ]->name ) { … … 1043 1038 } 1044 1039 1045 // Skip if group has no fields 1040 // Skip if group has no fields. 1046 1041 if ( empty( $groups[ $i ]->fields ) ) { 1047 1042 continue; 1048 1043 } 1049 1044 1050 // Build the profile field group link 1045 // Build the profile field group link. 1051 1046 $link = trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/' . $groups[ $i ]->id ); 1052 1047 1053 // Add tab to end of tabs array 1048 // Add tab to end of tabs array. 1054 1049 $tabs[] = sprintf( 1055 1050 '<li %1$s><a href="%2$s">%3$s</a></li>', … … 1083 1078 function bp_get_profile_group_name() { 1084 1079 1085 // Check action variable 1080 // Check action variable. 1086 1081 $group_id = bp_action_variable( 1 ); 1087 1082 if ( empty( $group_id ) || ! is_numeric( $group_id ) ) { … … 1089 1084 } 1090 1085 1091 // Check for cached group 1086 // Check for cached group. 1092 1087 $group = new BP_XProfile_Group( $group_id ); 1093 1088 … … 1143 1138 * Filters the current profile group ID. 1144 1139 * 1145 * Possible values are admin/profile/edit/[group-id] 1140 * Possible values are admin/profile/edit/[group-id]. 1146 1141 * 1147 1142 * @since 1.1.0 … … 1183 1178 1184 1179 /** 1185 * Echo the field visibility radio buttons 1180 * Echo the field visibility radio buttons. 1181 * 1182 * @param array|string $args Args for the radio buttons. 1186 1183 */ 1187 1184 function bp_profile_visibility_radio_buttons( $args = '' ) { … … 1189 1186 } 1190 1187 /** 1191 * Return the field visibility radio buttons 1188 * Return the field visibility radio buttons. 1189 * 1190 * @param array|string $args Args for the radio buttons. 1191 * 1192 * @return string $retval 1192 1193 */ 1193 1194 function bp_profile_get_visibility_radio_buttons( $args = '' ) { 1194 1195 1195 // Parse optional arguments 1196 // Parse optional arguments. 1196 1197 $r = bp_parse_args( $args, array( 1197 1198 'field_id' => bp_get_the_profile_field_id(), … … 1203 1204 ), 'xprofile_visibility_radio_buttons' ); 1204 1205 1205 // Empty return value, filled in below if a valid field ID is found 1206 // Empty return value, filled in below if a valid field ID is found. 1206 1207 $retval = ''; 1207 1208 1208 // Only do-the-do if there's a valid field ID 1209 // Only do-the-do if there's a valid field ID. 1209 1210 if ( ! empty( $r['field_id'] ) ) : 1210 1211 1211 // Start the output buffer 1212 // Start the output buffer. 1212 1213 ob_start(); 1213 1214 1214 // Output anything before 1215 // Output anything before. 1215 1216 echo $r['before']; ?> 1216 1217 … … 1232 1233 <?php endif; 1233 1234 1234 // Output anything after 1235 // Output anything after. 1235 1236 echo $r['after']; 1236 1237 1237 // Get the output buffer and empty it 1238 // Get the output buffer and empty it. 1238 1239 $retval = ob_get_clean(); 1239 1240 endif; … … 1252 1253 1253 1254 /** 1254 * Output the XProfile field visibility select list for settings 1255 * Output the XProfile field visibility select list for settings. 1255 1256 * 1256 1257 * @since 2.0.0 1258 * 1259 * @param array|string $args Args for the select list. 1257 1260 */ 1258 1261 function bp_profile_settings_visibility_select( $args = '' ) { … … 1260 1263 } 1261 1264 /** 1262 * Return the XProfile field visibility select list for settings 1265 * Return the XProfile field visibility select list for settings. 1263 1266 * 1264 1267 * @since 2.0.0 1268 * 1269 * @param array|string $args Args for the select list. 1270 * 1271 * @return string $retval 1265 1272 */ 1266 1273 function bp_profile_get_settings_visibility_select( $args = '' ) { 1267 1274 1268 // Parse optional arguments 1275 // Parse optional arguments. 1269 1276 $r = bp_parse_args( $args, array( 1270 1277 'field_id' => bp_get_the_profile_field_id(), … … 1274 1281 ), 'xprofile_settings_visibility_select' ); 1275 1282 1276 // Empty return value, filled in below if a valid field ID is found 1283 // Empty return value, filled in below if a valid field ID is found. 1277 1284 $retval = ''; 1278 1285 1279 // Only do-the-do if there's a valid field ID 1286 // Only do-the-do if there's a valid field ID. 1280 1287 if ( ! empty( $r['field_id'] ) ) : 1281 1288 1282 // Start the output buffer 1289 // Start the output buffer. 1283 1290 ob_start(); 1284 1291 1285 // Output anything before 1292 // Output anything before. 1286 1293 echo $r['before']; ?> 1287 1294 … … 1305 1312 <?php endif; 1306 1313 1307 // Output anything after 1314 // Output anything after. 1308 1315 echo $r['after']; 1309 1316 1310 // Get the output buffer and empty it 1317 // Get the output buffer and empty it. 1311 1318 $retval = ob_get_clean(); 1312 1319 endif;
Note: See TracChangeset
for help on using the changeset viewer.