diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php
index e25389a..8108771 100644
|
|
|
function bp_core_get_table_prefix() { |
| 116 | 116 | * @return array $items The sorted array. |
| 117 | 117 | */ |
| 118 | 118 | function bp_sort_by_key( $items, $key, $type = 'alpha' ) { |
| 119 | | usort( $items, create_function( '$a, $b', ' |
| 120 | | $values = array( 0 => false, 1 => false, ); |
| 121 | | $func_args = func_get_args(); |
| 122 | | foreach ( $func_args as $indexi => $index ) { |
| 123 | | if ( isset( $index->' . $key . ' ) ) { |
| 124 | | $values[ $indexi ] = $index->' . $key . '; |
| 125 | | } elseif ( isset( $index["' . $key . '"] ) ) { |
| 126 | | $values[ $indexi ] = $index["' . $key . '"]; |
| 127 | | } |
| 128 | | } |
| | 119 | $bp = buddypress(); |
| 129 | 120 | |
| 130 | | if ( isset( $values[0], $values[1] ) ) { |
| 131 | | if ( "num" === "' . $type . '" ) { |
| 132 | | $cmp = $values[0] - $values[1]; |
| 133 | | } else { |
| 134 | | $cmp = strcmp( $values[0], $values[1] ); |
| 135 | | } |
| | 121 | $bp->sort_key = $key; |
| | 122 | $bp->sort_type = $type; |
| 136 | 123 | |
| 137 | | if ( 0 > $cmp ) { |
| 138 | | $retval = -1; |
| 139 | | } elseif ( 0 < $cmp ) { |
| 140 | | $retval = 1; |
| 141 | | } else { |
| 142 | | $retval = 0; |
| 143 | | } |
| 144 | | return $retval; |
| | 124 | usort( $items, '_bp_sort_by_key_cb' ); |
| | 125 | |
| | 126 | unset( $bp->sort_key ); |
| | 127 | unset( $bp->sort_type ); |
| | 128 | |
| | 129 | return $items; |
| | 130 | } |
| | 131 | |
| | 132 | /** |
| | 133 | * Sorting callback for bp_sort_by_key(). |
| | 134 | * |
| | 135 | * @since 2.5.0 |
| | 136 | * |
| | 137 | * @param object|array $a |
| | 138 | * @param object|array $b |
| | 139 | * @return int |
| | 140 | */ |
| | 141 | function _bp_sort_by_key_cb( $a, $b ) { |
| | 142 | $key = buddypress()->sort_key; |
| | 143 | $type = buddypress()->sort_type; |
| | 144 | |
| | 145 | $values = array( 0 => false, 1 => false, ); |
| | 146 | $func_args = func_get_args(); |
| | 147 | foreach ( $func_args as $indexi => $index ) { |
| | 148 | if ( isset( $index->{$key} ) ) { |
| | 149 | $values[ $indexi ] = $index->{$key}; |
| | 150 | } elseif ( isset( $index[ $key ] ) ) { |
| | 151 | $values[ $indexi ] = $index[ $key ]; |
| | 152 | } |
| | 153 | } |
| | 154 | |
| | 155 | if ( isset( $values[0], $values[1] ) ) { |
| | 156 | if ( 'num' === $type ) { |
| | 157 | $cmp = $values[0] - $values[1]; |
| 145 | 158 | } else { |
| 146 | | return 0; |
| | 159 | $cmp = strcmp( $values[0], $values[1] ); |
| 147 | 160 | } |
| 148 | | ') ); |
| 149 | 161 | |
| 150 | | return $items; |
| | 162 | if ( 0 > $cmp ) { |
| | 163 | $retval = -1; |
| | 164 | } elseif ( 0 < $cmp ) { |
| | 165 | $retval = 1; |
| | 166 | } else { |
| | 167 | $retval = 0; |
| | 168 | } |
| | 169 | return $retval; |
| | 170 | } else { |
| | 171 | return 0; |
| | 172 | } |
| 151 | 173 | } |
| 152 | 174 | |
| 153 | 175 | /** |
diff --git src/bp-loader.php src/bp-loader.php
index 05c6e88..60f31cc 100644
|
|
|
class BuddyPress { |
| 101 | 101 | */ |
| 102 | 102 | public $active_components = array(); |
| 103 | 103 | |
| | 104 | /** |
| | 105 | * Sort key for bp_sort_by_key(). |
| | 106 | * |
| | 107 | * @since 2.5.0 |
| | 108 | * @var mixed |
| | 109 | */ |
| | 110 | public $sort_key; |
| | 111 | |
| | 112 | /** |
| | 113 | * Sort type for bp_sort_by_key(). |
| | 114 | * |
| | 115 | * @since 2.5.0 |
| | 116 | * @var string |
| | 117 | */ |
| | 118 | public $sort_type; |
| | 119 | |
| 104 | 120 | /** Option Overload *******************************************************/ |
| 105 | 121 | |
| 106 | 122 | /** |