WP PLUGIN アーカイブページの投稿表示順設定

・管理画面メニュー(サブメニュー)の修正
・1ページ表示件数の追加
・pre_get_postするクエリの追加
・検索用設定の追加
This commit is contained in:
2021-05-06 21:09:35 +09:00
parent 05b5fa91aa
commit 803c742a9f
8 changed files with 773 additions and 234 deletions
+146 -12
View File
@@ -1,18 +1,150 @@
<?php
$category_lists = array( 'category' => APOP_UI::get_cat_tag_list( 'cat', 'category' ) );
$tag_lists = array( 'tag_id' => APOP_UI::get_cat_tag_list( 'tag', 'post_tag' ) );
$taxonomy_lists = array( 'taxonomy' => APOP_UI::get_cat_tag_list( 'tax', 'taxonomy' ) );
$search_lists = APOP_UI::get_all_search_posts( 'registered' );
$category_lists = array( 'category' => APOP_UI::get_cat_tag_list( 'cat', 'category' ) );
$tag_lists = array( 'tag_id' => APOP_UI::get_cat_tag_list( 'tag', 'post_tag' ) );
$taxonomy_lists = array( 'taxonomy' => APOP_UI::get_cat_tag_list( 'tax', 'taxonomy' ) );
$submit_type = $_POST['submit_type'] ?? '0';
$apop_search_order = get_option( '_apop_search_order' ) ?? '1';
?>
<h2>並べ替え</h2>
<nav class="post-order-nav">
<ul>
<li class="en">カテゴリー</li>
<li class="en">検索</li>
<li>カテゴリー</li>
<li>タグ</li>
<li>カスタム分類</li>
</ul>
</nav>
<div class="post-order-box-outer">
<div class="post-order-box-outer" data-submit_type="<?php echo $submit_type; ?>">
<div class="post-order-box">
<div class="list-orders-outer">
<?php $exclude_posts = []; ?>
<div class="list-orders-inner search_inner">
<form action="" method="post">
<?php wp_nonce_field( 'sh_options' ); ?>
<ul class="apop_search_order_target" data-search_order_target="<?php echo $apop_search_order; ?>">
<li><label>
<input class="apop_search_order" type="radio" name="_apop_search_order"
value="1"<?php echo checked( $apop_search_order, 1 ); ?>>標準</label></li>
<li><label>
<input class="apop_search_order" type="radio" name="_apop_search_order"
value="2"<?php echo checked( $apop_search_order, 2 ); ?>>カスタム</label></li>
</ul>
<hr>
<div class="search_sort_box">
<ul class="post-order-list search_normal_sort">
<li class="product-list">
<label>
<input type="hidden" name="_apop_search_order_param[id][use]" value="0">
<input type="checkbox" name="_apop_search_order_param[id][use]" value="1">
<b>ID</b>
</label>
&nbsp;&nbsp;
<label><input class="apop_search_order_param" type="radio"
name="_apop_search_order_param[id][sort]"
value="1">昇順</label>
&nbsp;&nbsp;
<label><input class="apop_search_order_param" type="radio"
name="_apop_search_order_param[id][sort]"
value="2">降順
</label>
<input type="hidden" class="list_order"
name="_apop_search_order_param[post_sort][id]"
value="">
</li>
<li class="product-list">
<label>
<input type="hidden" name="_apop_search_order_param[title][use]" value="0">
<input type="checkbox" name="_apop_search_order_param[title][use]" value="1">
<b>タイトル</b>
</label>
&nbsp;&nbsp;
<label><input class="apop_search_order_param" type="radio"
name="_apop_search_order_param[title][sort]"
value="1">昇順</label>
&nbsp;&nbsp;
<label><input class="apop_search_order_param" type="radio"
name="_apop_search_order_param[title][sort]"
value="2">降順
</label>
<input type="hidden" class="list_order"
name="_apop_search_order_param[post_sort][title]"
value="">
</li>
<li class="product-list">
<label>
<input type="hidden" name="_apop_search_order_param[register][use]" value="0">
<input type="checkbox" name="_apop_search_order_param[register][use]" value="1">
<b>登録日</b>
</label>
&nbsp;&nbsp;
<label><input class="apop_search_order_param" type="radio"
name="_apop_search_order_param[register][sort]"
value="1">昇順</label>
&nbsp;&nbsp;
<label><input class="apop_search_order_param" type="radio"
name="_apop_search_order_param[register][sort]"
value="2">降順</label>
<input type="hidden" class="list_order"
name="_apop_search_order_param[post_sort][register]"
value="">
</li>
<li class="product-list">
<label>
<input type="hidden" name="_apop_search_order_param[modified][use]" value="0">
<input type="checkbox" name="_apop_search_order_param[modified][use]" value="1">
<b>更新日</b>
</label>
&nbsp;&nbsp;
<label><input class="apop_search_order_param" type="radio"
name="_apop_search_order_param[modified][sort]"
value="1">昇順</label>
&nbsp;&nbsp;
<label><input class="apop_search_order_param" type="radio"
name="_apop_search_order_param[modified][sort]"
value="2">降順</label>
<input type="hidden" class="list_order"
name="_apop_search_order_param[post_sort][modified]"
value="">
</li>
</ul>
</div>
<div class="search_sort_box">
<ul class="post-order-list">
<?php foreach ( $search_lists as $i => $search_list ): $search_order = $i + 1; ?>
<?php $exclude_posts[] = $search_list->ID; ?>
<li class="product-list">
<span class="sort-num-label"><?php echo $search_order; ?></span>
<?php echo $search_list->post_title; ?>
<input type="hidden" class="list_order"
name="_apop_post_search[post_sort][<?php echo $search_list->ID; ?>]"
value="<?php echo $search_order; ?>">
</li>
<?php endforeach; ?>
<?php $search_none_lists = APOP_UI::get_all_search_posts( 'none', $exclude_posts ); ?>
<?php $search_order = $search_order ?? 0; ?>
<?php foreach ( $search_none_lists as $i => $search_list ): $search_order = $search_order + $i + 1; ?>
<li class="product-list no_order">
<span class="sort-num-label"><?php echo $search_order; ?></span>
<?php echo $search_list->post_title; ?>
<input type="hidden" class="list_order"
name="_apop_post_search[post_sort][<?php echo $search_list->ID; ?>]"
value="<?php echo $search_order; ?>">
</li>
<?php endforeach; ?>
</ul>
</div>
<input type="hidden" name="submit_type" value="0">
<p class="submit post-order"><input type="submit" name="Submit" class="button-primary"
value="変更を保存"/></p>
</form>
</div>
</div>
</div>
<div class="post-order-box">
<h2>カテゴリー</h2>
<?php foreach ( $category_lists as $tax_key => $tax_list ) : ?>
<div class="list-orders-outer">
<?php if ( count( $tax_list ) > 0 ): $exclude_posts = []; ?>
@@ -28,8 +160,9 @@ $taxonomy_lists = array( 'taxonomy' => APOP_UI::get_cat_tag_list( 'tax', 'taxono
echo APOP_UI::create_product_none_order_list( $tax_data, $tax_key, $exclude_posts, $sort_num );
?>
</ul>
<input type="hidden" name="submit_type" value="1">
<p class="submit post-order"><input type="submit" name="Submit" class="button-primary"
value="変更を保存"/></p>
value="変更を保存"/></p>
</form>
</div>
<?php endforeach; ?>
@@ -38,7 +171,6 @@ $taxonomy_lists = array( 'taxonomy' => APOP_UI::get_cat_tag_list( 'tax', 'taxono
<?php endforeach; ?>
</div>
<div class="post-order-box">
<h2>タグ</h2>
<?php foreach ( $tag_lists as $tax_key => $tax_list ) : ?>
<div class="list-orders-outer">
<?php if ( count( $tax_list ) > 0 ): $exclude_posts = []; ?>
@@ -54,8 +186,9 @@ $taxonomy_lists = array( 'taxonomy' => APOP_UI::get_cat_tag_list( 'tax', 'taxono
echo APOP_UI::create_product_none_order_list( $tax_data, $tax_key, $exclude_posts, $sort_num );
?>
</ul>
<input type="hidden" name="submit_type" value="2">
<p class="submit post-order"><input type="submit" name="Submit" class="button-primary"
value="変更を保存"/></p>
value="変更を保存"/></p>
</form>
</div>
<?php endforeach; ?>
@@ -64,7 +197,6 @@ $taxonomy_lists = array( 'taxonomy' => APOP_UI::get_cat_tag_list( 'tax', 'taxono
<?php endforeach; ?>
</div>
<div class="post-order-box">
<h2>カスタム分類</h2>
<?php foreach ( $taxonomy_lists as $tax_key => $taxonomy_list ): ?>
<div class="list-orders-outer">
<?php foreach ( $taxonomy_list as $tax_list ) : ?>
@@ -81,8 +213,10 @@ $taxonomy_lists = array( 'taxonomy' => APOP_UI::get_cat_tag_list( 'tax', 'taxono
echo APOP_UI::create_product_none_order_list( $tax_data, $tax_key, $exclude_posts, $sort_num );
?>
</ul>
<p class="submit post-order"><input type="submit" name="Submit" class="button-primary"
value="変更を保存"/></p>
<input type="hidden" name="submit_type" value="3">
<p class="submit post-order"><input type="submit" name="Submit"
class="button-primary"
value="変更を保存"/></p>
</form>
</div>
<?php endforeach; ?>