Changeset 13184 for trunk/src/bp-blogs/classes/class-bp-blogs-template.php
- Timestamp:
- 12/12/2021 02:09:02 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/classes/class-bp-blogs-template.php
r10517 r13184 84 84 * Constructor method. 85 85 * 86 * @since 1.2.0 87 * @since 10.0.0 Converted to array as main function argument. Added $date_query parameter. 88 * 86 89 * @see BP_Blogs_Blog::get() for a description of parameters. 87 90 * 88 * @param string $type See {@link BP_Blogs_Blog::get()}. 89 * @param string $page See {@link BP_Blogs_Blog::get()}. 90 * @param string $per_page See {@link BP_Blogs_Blog::get()}. 91 * @param string $max See {@link BP_Blogs_Blog::get()}. 92 * @param string $user_id See {@link BP_Blogs_Blog::get()}. 93 * @param string $search_terms See {@link BP_Blogs_Blog::get()}. 94 * @param string $page_arg The string used as a query parameter in 95 * pagination links. Default: 'bpage'. 96 * @param bool $update_meta_cache Whether to pre-fetch metadata for 97 * queried blogs. 98 * @param array|bool $include_blog_ids Array of blog IDs to include. 99 */ 100 public function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage', $update_meta_cache = true, $include_blog_ids = false ) { 101 102 $this->pag_arg = sanitize_key( $page_arg ); 103 $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page ); 104 $this->pag_num = bp_sanitize_pagination_arg( 'num', $per_page ); 91 * @param array $args { 92 * Array of arguments. See {@link BP_Blogs_Blog::get()}. 93 * } 94 */ 95 public function __construct( ...$args ) { 96 // Backward compatibility with old method of passing arguments. 97 if ( ! is_array( $args[0] ) || count( $args ) > 1 ) { 98 _deprecated_argument( __METHOD__, '10.0.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__ ) ); 99 100 $old_args_keys = [ 101 0 => 'type', 102 1 => 'page', 103 2 => 'per_page', 104 3 => 'max', 105 4 => 'user_id', 106 5 => 'search_terms', 107 6 => 'page_arg', 108 7 => 'update_meta_cache', 109 8 => 'include_blog_ids', 110 ]; 111 112 $args = bp_core_parse_args_array( $old_args_keys, $args ); 113 } else { 114 $args = reset( $args ); 115 } 116 117 $r = bp_parse_args( 118 $args, 119 array( 120 'type' => '', 121 'page' => false, 122 'per_page' => false, 123 'max' => false, 124 'user_id' => false, 125 'search_terms' => false, 126 'page_arg' => 'bpage', 127 'update_meta_cache' => true, 128 'include_blog_ids' => false, 129 'date_query' => false, 130 ), 131 'blogs_template' 132 ); 133 134 $this->pag_arg = sanitize_key( $r['page_arg'] ); 135 $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] ); 136 $this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] ); 105 137 106 138 // Backwards compatibility support for blogs by first letter. … … 111 143 } else { 112 144 $this->blogs = bp_blogs_get_blogs( array( 113 'type' => $ type,145 'type' => $r['type'], 114 146 'per_page' => $this->pag_num, 115 147 'page' => $this->pag_page, 116 'user_id' => $user_id, 117 'search_terms' => $search_terms, 118 'update_meta_cache' => $update_meta_cache, 119 'include_blog_ids' => $include_blog_ids, 148 'user_id' => $r['user_id'], 149 'search_terms' => $r['search_terms'], 150 'update_meta_cache' => $r['update_meta_cache'], 151 'include_blog_ids' => $r['include_blog_ids'], 152 'date_query' => $r['date_query'] 120 153 ) ); 121 154 } 122 155 123 156 // Set the total blog count. 124 if ( empty( $ max ) || ( $max>= (int) $this->blogs['total'] ) ) {157 if ( empty( $r['max'] ) || ( $r['max'] >= (int) $this->blogs['total'] ) ) { 125 158 $this->total_blog_count = (int) $this->blogs['total']; 126 159 } else { … … 135 168 136 169 // Set the current blog count. 137 if ( empty( $ max ) || ( $max>= (int) $blog_count ) ) {170 if ( empty( $r['max'] ) || ( $r['max'] >= (int) $blog_count ) ) { 138 171 $this->blog_count = (int) $blog_count; 139 172 } else {
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)