Changeset 4840
- Timestamp:
- 07/24/2011 10:22:55 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-template.php
r4839 r4840 471 471 } 472 472 473 /** 474 * Return the value of $bp->action_variables 475 * 476 * @package BuddyPress 477 * 478 * @param mixed $action_variables The action variables array, or false if the array is empty 479 */ 473 480 function bp_action_variables() { 474 481 global $bp; 475 482 $action_variables = !empty( $bp->action_variables ) ? $bp->action_variables : false; 476 483 return apply_filters( 'bp_action_variables', $action_variables ); 484 } 485 486 /** 487 * Return the value of a given action variable 488 * 489 * @package BuddyPress 490 * @since 1.3 491 * 492 * @param int $position The key of the action_variables array that you want 493 * @return str $action_variable The value of that position in the array 494 */ 495 function bp_action_variable( $position = 0 ) { 496 $action_variables = bp_action_variables(); 497 498 $action_variable = isset( $action_variables[$position] ) ? $action_variables[$position] : false; 499 500 return apply_filters( 'bp_action_variable', $action_variable, $position ); 477 501 } 478 502 … … 677 701 } 678 702 703 /** 704 * Check to see whether the current page matches a given action. 705 * 706 * Along with bp_is_current_component() and bp_is_action_variable(), this function is mostly used 707 * to help determine when to use a given screen function. 708 * 709 * In BP parlance, the current_action is the URL chunk that comes directly after the 710 * current item slug. E.g., in 711 * http://example.com/groups/my-group/members 712 * the current_action is 'members'. 713 * 714 * @package BuddyPress 715 * @since 1.3 716 * 717 * @param str $action The action being tested against 718 * @return bool True if the current action matches $action 719 */ 679 720 function bp_is_current_action( $action = '' ) { 680 721 global $bp; … … 684 725 685 726 return false; 727 } 728 729 /** 730 * Check to see whether the current page matches a given action_variable. 731 * 732 * Along with bp_is_current_component() and bp_is_current_action(), this function is mostly used 733 * to help determine when to use a given screen function. 734 * 735 * In BP parlance, action_variables are an array made up of the URL chunks appearing after the 736 * current_action in a URL. For example, 737 * http://example.com/groups/my-group/admin/group-settings 738 * $action_variables[0] is 'group-settings'. 739 * 740 * @package BuddyPress 741 * @since 1.3 742 * 743 * @param str $action_variable The action_variable being tested against 744 * @param int $position The array key you're testing against. If you don't provide a $position, 745 * the function will return true if the $action_variable is found *anywhere* in the action 746 * variables array. 747 * @return bool 748 */ 749 function bp_is_action_variable( $action_variable = '', $position = false ) { 750 $is_action_variable = false; 751 752 if ( false !== $position ) { 753 // When a $position is specified, check that slot in the action_variables array 754 if ( $action_variable ) { 755 $is_action_variable = $action_variable == bp_action_variable( $position ); 756 } else { 757 // If no $action_variable is provided, we are essentially checking to see 758 // whether the slot is empty 759 $is_action_variable = !bp_action_variable( $position ); 760 } 761 } else { 762 // When no $position is specified, check the entire array 763 $is_action_variable = in_array( $action_variable, bp_action_variables() ); 764 } 765 766 return apply_filters( 'bp_is_action_variable', $is_action_variable, $action_variable, $position ); 686 767 } 687 768 -
trunk/bp-xprofile/bp-xprofile-actions.php
r4827 r4840 23 23 function xprofile_action_delete_avatar() { 24 24 global $bp; 25 26 if ( $bp->profile->id != $bp->current_component || 'change-avatar' != $bp->current_action || !isset( $bp->action_variables[0] ) || 'delete-avatar' != $bp->action_variables[0])25 26 if ( !bp_is_current_component( 'profile' ) || !bp_is_current_action( 'change-avatar' ) || !bp_is_action_variable( 'delete-avatar', 0 ) ) 27 27 return false; 28 28 -
trunk/bp-xprofile/bp-xprofile-screens.php
r4827 r4840 37 37 38 38 // Make sure a group is set. 39 if ( empty( $bp->action_variables[1]) )40 bp_core_redirect( $bp->displayed_user->domain. $bp->profile->slug . '/edit/group/1' );39 if ( !bp_action_variable( 1 ) ) 40 bp_core_redirect( bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/1' ); 41 41 42 42 // Check the field group exists 43 if ( ( !empty( $bp->action_variables[0] ) && 'group' != $bp->action_variables[0] ) || !xprofile_get_field_group( $bp->action_variables[1]) ) {43 if ( !bp_is_action_variable( 'group' ) || !xprofile_get_field_group( bp_action_variable( 1 ) ) ) { 44 44 bp_do_404(); 45 45 return; … … 54 54 // Check we have field ID's 55 55 if ( empty( $_POST['field_ids'] ) ) 56 bp_core_redirect( trailingslashit( $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . $bp->action_variables[1]) );56 bp_core_redirect( trailingslashit( $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . bp_action_variable( 1 ) ) ); 57 57 58 58 // Explode the posted field IDs into an array so we know which … … 68 68 if ( !empty( $_POST['field_' . $field_id . '_day'] ) && is_numeric( $_POST['field_' . $field_id . '_day'] ) ) { 69 69 // Concatenate the values 70 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . 71 $_POST['field_' . $field_id . '_month'] . ' ' . 72 $_POST['field_' . $field_id . '_year']; 70 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year']; 73 71 74 72 // Turn the concatenated value into a timestamp … … 116 114 117 115 // Redirect back to the edit screen to display the updates and message 118 bp_core_redirect( trailingslashit( $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . $bp->action_variables[1]) );116 bp_core_redirect( trailingslashit( bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/' . bp_action_variable( 1 ) ) ); 119 117 } 120 118 } … … 137 135 return false; 138 136 139 if ( !empty( $bp->action_variables) ) {137 if ( bp_action_variables() ) { 140 138 bp_do_404(); 141 139 return; -
trunk/bp-xprofile/bp-xprofile-template.php
r4831 r4840 695 695 696 696 function bp_profile_group_name( $deprecated = true ) { 697 global $bp;698 699 $group_id = !empty( $bp->action_variables[1] ) ? $bp->action_variables[1] : 1;700 701 if ( !is_numeric( $group_id ) )702 $group_id = 1;703 704 if ( !$group = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) {705 $group = new BP_XProfile_Group($group_id);706 wp_cache_set( 'xprofile_group_' . $group_id, $group, 'bp' );707 }708 709 697 if ( !$deprecated ) { 710 698 return bp_get_profile_group_name(); … … 714 702 } 715 703 function bp_get_profile_group_name() { 716 global $bp; 717 718 $group_id = !empty( $bp->action_variables[1] ) ? $bp->action_variables[1] : 1; 719 704 if ( !$group_id = bp_action_variable( 1 ) ) 705 $group_id = 1; 706 720 707 if ( !is_numeric( $group_id ) ) 721 708 $group_id = 1; … … 764 751 } 765 752 function bp_get_current_profile_group_id() { 766 global $bp; 767 768 if ( empty( $bp->action_variables[1] ) || !$profile_group_id = $bp->action_variables[1] ) 753 if ( !$profile_group_id = bp_action_variable( 1 ) ) 769 754 $profile_group_id = 1; 770 755
Note: See TracChangeset
for help on using the changeset viewer.