Changeset 5993
- Timestamp:
- 04/17/2012 02:01:16 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-classes.php
r5953 r5993 101 101 102 102 // Static Functions 103 function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false, $exclude = false, $in = false, $spam = 'ham_only' ) { 104 global $wpdb, $bp; 103 104 /** 105 * Get activity items, as specified by parameters 106 * 107 * @param array $args See $defaults for explanation of arguments 108 * @return array 109 */ 110 function get( $args = array() ) { 111 global $wpdb, $bp; 112 113 // Backward compatibility with old method of passing arguments 114 if ( !is_array( $args ) || func_num_args() > 1 ) { 115 _deprecated_argument( __METHOD__, '1.6', 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__ ) ); 116 117 $old_args_keys = array( 118 0 => 'max', 119 1 => 'page', 120 2 => 'per_page', 121 3 => 'sort', 122 4 => 'search_terms', 123 5 => 'filter', 124 6 => 'display_comments', 125 7 => 'show_hidden', 126 8 => 'exclude', 127 9 => 'in', 128 10 => 'spam' 129 ); 130 131 $args = bp_core_parse_args_array( $old_args_keys, func_get_args() ); 132 } 133 134 $defaults = array( 135 'page' => 1, // The current page 136 'per_page' => 25, // Activity items per page 137 'max' => false, // Max number of items to return 138 'sort' => 'DESC', // ASC or DESC 139 'exclude' => false, // Array of ids to exclude 140 'in' => false, // Array of ids to limit query by (IN) 141 'filter' => false, // See self::get_filter_sql() 142 'search_terms' => false, // Terms to search by 143 'display_comments' => false, // Whether to include activity comments 144 'show_hidden' => false, // Show items marked hide_sitewide 145 'spam' => 'ham_only', // Spam status 146 ); 147 $r = wp_parse_args( $args, $defaults ); 148 extract( $r ); 105 149 106 150 // Select conditions … … 237 281 /** 238 282 * In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page). 239 * As of 1.5.x, use BP_Activity_Activity::get( ..., $in )instead.283 * As of 1.5.x, use BP_Activity_Activity::get() with an 'in' parameter instead. 240 284 * 241 285 * @deprecated 1.5 242 * @deprecated Use BP_Activity_Activity::get( ..., $in )instead.286 * @deprecated Use BP_Activity_Activity::get() with an 'in' parameter instead. 243 287 * @param mixed $activity_ids Array or comma-separated string of activity IDs to retrieve 244 288 * @param int $max Maximum number of results to return. (Optional; default is no maximum) … … 251 295 */ 252 296 function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) { 253 _deprecated_function( __FUNCTION__, '1.5', 'Use BP_Activity_Activity::get( ..., $in )instead.' );297 _deprecated_function( __FUNCTION__, '1.5', 'Use BP_Activity_Activity::get() with the "in" parameter instead.' ); 254 298 return BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids ); 255 299 } -
trunk/bp-activity/bp-activity-functions.php
r5938 r5993 821 821 if ( 1 == (int) $page && empty( $max ) && empty( $search_terms ) && empty( $filter ) && empty( $exclude ) && empty( $in ) && 'DESC' == $sort && empty( $exclude ) && 'ham_only' == $spam ) { 822 822 if ( !$activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' ) ) { 823 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden, false, false, $spam ); 823 $args = array( 824 'page' => $page, 825 'per_page' => $per_page, 826 'max' => $max, 827 'sort' => $sort, 828 'search_terms' => $search_terms, 829 'filter' => $filter, 830 'display_comments' => $display_comments, 831 'show_hidden' => $show_hidden, 832 'spam' => $spam 833 ); 834 $activity = BP_Activity_Activity::get( $args ); 824 835 wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' ); 825 836 } 826 837 827 838 } else { 828 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden, $exclude, $in, $spam ); 839 $args = array( 840 'page' => $page, 841 'per_page' => $per_page, 842 'max' => $max, 843 'sort' => $sort, 844 'search_terms' => $search_terms, 845 'filter' => $filter, 846 'display_comments' => $display_comments, 847 'show_hidden' => $show_hidden, 848 'exclude' => $exclude, 849 'in' => $in, 850 'spam' => $spam 851 ); 852 $activity = BP_Activity_Activity::get( $args ); 829 853 } 830 854 … … 859 883 extract( $r, EXTR_SKIP ); 860 884 861 return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, $show_hidden, false, $activity_ids, $spam ) ); 885 $get_args = array( 886 'page' => $page, 887 'per_page' => $per_page, 888 'max' => $max, 889 'sort' => $sort, 890 'display_comments' => $display_comments, 891 'show_hidden' => $show_hidden, 892 'in' => $activity_ids, 893 'spam' => $spam 894 ); 895 return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args ); 862 896 } 863 897 -
trunk/bp-activity/bp-activity-template.php
r5973 r5993 105 105 var $full_name; 106 106 107 function __construct( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude = false, $in = false, $spam = 'ham_only', $page_arg = 'acpage' ) { 107 /** 108 * Constructor method 109 * 110 * See definition of $defaults below, as well as $defaults in bp_has_activities(), for 111 * description of $args array 112 * 113 * @param array $args 114 */ 115 function __construct( $args ) { 108 116 global $bp; 109 117 118 // Backward compatibility with old method of passing arguments 119 if ( !is_array( $args ) || func_num_args() > 1 ) { 120 _deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %s should be in an associative array. See the inline documentation for more details.', 'buddypress' ), __METHOD__ ) ); 121 122 $old_args_keys = array( 123 0 => 'page', 124 1 => 'per_page', 125 2 => 'max', 126 3 => 'include', 127 4 => 'sort', 128 5 => 'filter', 129 6 => 'search_terms', 130 7 => 'display_comments', 131 8 => 'show_hidden', 132 9 => 'exclude', 133 10 => 'in', 134 11 => 'spam', 135 12 => 'page_arg' 136 ); 137 138 $args = bp_core_parse_args_array( $old_args_keys, func_get_args() ); 139 } 140 141 $defaults = array( 142 'page' => 1, 143 'per_page' => 20, 144 'page_arg' => 'acpage', 145 'max' => false, 146 'sort' => false, 147 'include' => false, 148 'exclude' => false, 149 'in' => false, 150 'filter' => false, 151 'search_terms' => false, 152 'display_comments' => 'threaded', 153 'show_hidden' => false, 154 'spam' => 'ham_only', 155 ); 156 $r = wp_parse_args( $args, $defaults ); 157 extract( $r ); 158 110 159 $this->pag_page = isset( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : $page; 111 160 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; … … 390 439 $spam = 'all'; 391 440 392 $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude, $in, $spam, $page_arg ); 393 394 return apply_filters( 'bp_has_activities', $activities_template->has_activities(), $activities_template ); 441 $template_args = array( 442 'page' => $page, 443 'per_page' => $per_page, 444 'page_arg' => $page_arg, 445 'max' => $max, 446 'sort' => $sort, 447 'include' => $include, 448 'exclude' => $exclude, 449 'in' => $in, 450 'filter' => $filter, 451 'search_terms' => $search_terms, 452 'display_comments' => $display_comments, 453 'show_hidden' => $show_hidden, 454 'spam' => $spam 455 ); 456 457 $activities_template = new BP_Activity_Template( $template_args ); 458 459 return apply_filters( 'bp_has_activities', $activities_template->has_activities(), $activities_template, $template_args ); 395 460 } 396 461 -
trunk/bp-core/bp-core-functions.php
r5992 r5993 952 952 953 953 return apply_filters( 'bp_use_wp_admin_bar', $use_admin_bar ); 954 } 955 956 /** 957 * A utility for parsing individual function arguments into an array. 958 * 959 * The purpose of this function is to help with backward compatibility in cases where 960 * 961 * function foo( $bar = 1, $baz = false, $barry = array(), $blip = false ) { // ... 962 * 963 * is deprecated in favor of 964 * 965 * function foo( $args = array() ) { 966 * $defaults = array( 967 * 'bar' => 1, 968 * 'arg2' => false, 969 * 'arg3' => array(), 970 * 'arg4' => false, 971 * ); 972 * $r = wp_parse_args( $args, $defaults ); // ... 973 * 974 * The first argument, $old_args_keys, is an array that matches the parameter positions (keys) to 975 * the new $args keys (values): 976 * 977 * $old_args_keys = array( 978 * 0 => 'bar', // because $bar was the 0th parameter for foo() 979 * 1 => 'baz', // because $baz was the 1st parameter for foo() 980 * 2 => 'barry', // etc 981 * 3 => 'blip' 982 * ); 983 * 984 * For the second argument, $func_args, you should just pass func_get_args(). 985 * 986 * @since BuddyPress (1.6) 987 * @param array $old_args_keys 988 * @param array $func_args 989 * @return array $new_args 990 */ 991 function bp_core_parse_args_array( $old_args_keys, $func_args ) { 992 $new_args = array(); 993 994 foreach( $old_args_keys as $arg_num => $arg_key ) { 995 if ( isset( $func_args[$arg_num] ) ) { 996 $new_args[$arg_key] = $func_args[$arg_num]; 997 } 998 } 999 1000 return $new_args; 954 1001 } 955 1002
Note: See TracChangeset
for help on using the changeset viewer.