Changeset 6680 for trunk/src/includes/core/abstraction.php
- Timestamp:
- 09/07/2017 05:40:59 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/core/abstraction.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/core/abstraction.php
r6601 r6680 190 190 191 191 /** 192 * Remove the first-page from a pagination links result set, ensuring that it 193 * points to the canonical first page URL. 194 * 195 * This is a bit of an SEO hack, to guarantee that the first page in a loop will 196 * never have pagination appended to the end of it, regardless of what the other 197 * functions have decided for us. 198 * 199 * @since 2.6.0 bbPress (r6678) 200 * 201 * @param string $pagination_links The HTML links used for pagination 202 * 203 * @return string 204 */ 205 function bbp_make_first_page_canonical( $pagination_links = '' ) { 206 207 // Default value 208 $retval = $pagination_links; 209 210 // Remove first page from pagination 211 if ( ! empty( $pagination_links ) ) { 212 $retval = bbp_use_pretty_urls() 213 ? str_replace( bbp_get_paged_slug() . '/1/', '', $pagination_links ) 214 : preg_replace( '/&paged=1(?=[^0-9])/m', '', $pagination_links ); 215 } 216 217 // Filter & return 218 return apply_filters( 'bbp_make_first_page_canonical', $retval, $pagination_links ); 219 } 220 221 /** 222 * A convenient wrapper for common calls to paginate_links(), complete with 223 * support for parameters that aren't used internally by bbPress. 224 * 225 * @since 2.6.0 bbPress (r6679) 226 * 227 * @param array $args 228 * 229 * @return string 230 */ 231 function bbp_paginate_links( $args = array() ) { 232 233 // Maybe add view-all args 234 $add_args = empty( $args['add_args'] ) && bbp_get_view_all() 235 ? array( 'view' => 'all' ) 236 : false; 237 238 // Pagination settings with filter 239 $r = bbp_parse_args( $args, array( 240 241 // Used by callers 242 'base' => '', 243 'total' => 1, 244 'current' => bbp_get_paged(), 245 'prev_next' => true, 246 'prev_text' => is_rtl() ? '→' : '←', 247 'next_text' => is_rtl() ? '←' : '→', 248 'mid_size' => 1, 249 'end_size' => 3, 250 'add_args' => $add_args, 251 252 // Unused by callers 253 'show_all' => false, 254 'type' => 'plain', 255 'format' => '', 256 'add_fragment' => '', 257 'before_page_number' => '', 258 'after_page_number' => '' 259 ), 'paginate_links' ); 260 261 // Return paginated links 262 return bbp_make_first_page_canonical( paginate_links( $r ) ); 263 } 264 265 /** 192 266 * Is the environment using pretty URLs? 193 267 *
Note: See TracChangeset
for help on using the changeset viewer.