Skip to content

Commit 4ca20a5

Browse files
committed
Update from vk-blocks-pro
1 parent 6b73e8b commit 4ca20a5

16 files changed

+537
-382
lines changed

inc/vk-blocks/view/class-vk-blocks-postlist.php

+12-5
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ public static function get_loop_query( $attributes ) {
143143
$post__not_in = array( get_the_ID() );
144144
}
145145

146-
$offset = isset( $attributes['offset'] ) ? intval( $attributes['offset'] ) : 0;
146+
$offset = isset( $attributes['offset'] ) ? intval( $attributes['offset'] ) : 0;
147+
$posts_per_page = isset( $attributes['numberPosts'] ) ? intval( $attributes['numberPosts'] ) : 0;
147148

148149
$date_query = array();
149150
if ( ! empty( $attributes['targetPeriod'] ) ) {
@@ -179,14 +180,17 @@ public static function get_loop_query( $attributes ) {
179180
}
180181

181182
global $wp_query;
183+
182184
// とりあえず1を入れつつ2ページ目の情報があったら上書き
183185
$paged = 1;
184186
if ( ! empty( $attributes['pagedlock'] ) ) {
185187
$paged = 1;
186188
} elseif ( is_singular() && isset( $wp_query->query_vars['page'] ) ) {
187-
$paged = $wp_query->query_vars['page'];
189+
$paged = $wp_query->query_vars['page'] ? $wp_query->query_vars['page'] : 1;
190+
$offset = $offset + $posts_per_page * ( $paged - 1 );
188191
} elseif ( isset( $wp_query->query_vars['paged'] ) ) {
189-
$paged = $wp_query->query_vars['paged'];
192+
$paged = $wp_query->query_vars['paged'] ? $wp_query->query_vars['paged'] : 1;
193+
$offset = $offset + $posts_per_page * ( $paged - 1 );
190194
}
191195

192196
$args = array(
@@ -195,16 +199,19 @@ public static function get_loop_query( $attributes ) {
195199
'tax_query' => ! empty( $is_checked_terms ) ? self::format_terms( $tax_query_relation, $is_checked_terms, $is_checked_post_type ) : array(),
196200
'paged' => $paged,
197201
// 0で全件取得
198-
'posts_per_page' => intval( $attributes['numberPosts'] ),
202+
'posts_per_page' => $posts_per_page,
199203
'order' => $attributes['order'],
200204
'orderby' => $attributes['orderby'],
201-
'offset' => $offset,
202205
'post__not_in' => array_map( 'intval', $post__not_in ),
203206
'date_query' => $date_query,
204207
'update_post_meta_cache' => false,
205208
'no_found_rows' => true,
206209
);
207210

211+
if ( ! is_null( $offset ) ) {
212+
$args['offset'] = $offset;
213+
}
214+
208215
if ( ! empty( $date_query ) ) {
209216
$args['date_query'] = $date_query;
210217
}

languages/vk-blocks-pro-ja-vk-blocks-admin-js.json

+1-1
Large diffs are not rendered by default.

languages/vk-blocks-pro-ja-vk-blocks-build-js.json

+1-1
Large diffs are not rendered by default.

languages/vk-blocks-pro-ja.l10n.php

+1-1
Large diffs are not rendered by default.

languages/vk-blocks-pro-ja.mo

378 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)