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

・不要な初期化を削除
・カスタムタクソノミー対応
・設定画面のタブ化
・設定画面各タクソノミーの投稿リスト表示をメソッド化
・name属性の閉じ忘れ修正
・不要なreturn削除
・APOP_UI::create_product_none_order_list() returnに変数が未設定の場合の条件を追加
・readmeに若干加筆
This commit is contained in:
2021-05-05 17:48:32 +09:00
parent 7722f53f10
commit 05b5fa91aa
12 changed files with 280 additions and 173 deletions
+83 -42
View File
@@ -1,53 +1,94 @@
<?php
$order_list = array(
'category' => APOP_UI::get_cat_tag_list( 'cat', 'category' ),
'tag_id' => APOP_UI::get_cat_tag_list( 'tag', 'post_tag' ),
);
$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' ) );
?>
<div class="post-order-box">
<form action="" method="post">
<?php wp_nonce_field( 'sh_options' ); ?>
<?php foreach ( $order_list as $tax_key => $tax_list ) : ?>
<nav class="post-order-nav">
<ul>
<li class="en">カテゴリー</li>
<li>タグ</li>
<li>カスタム分類</li>
</ul>
</nav>
<div class="post-order-box-outer">
<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 ): ?>
<p>対象<?php echo APOP_UI::get_tax_name($tax_key); ?>を選択してください。
<a href="./admin.php?page=apop_post_sort_setting"><?php echo APOP_UI::get_tax_name($tax_key); ?>選択</a>
</p>
<?php else: $exclude_posts = []; ?>
<?php if ( count( $tax_list ) > 0 ): $exclude_posts = []; ?>
<?php foreach ( $tax_list as $tax_data ): ?>
<div class="list-orders-inner">
<h3><?php echo $tax_data->name; ?></h3>
<?php $target_posts = APOP_UI::get_sort_post_list( $tax_data->term_id, $tax_key, $tax_data->taxonomy ); ?>
<ul class="post-order-list">
<?php foreach ( $target_posts as $key => $target_post ): $sort_num = $key + 1;
$exclude_posts[] = $target_post->ID; ?>
<li class="product-list">
<span class="sort-num-label"><?php echo $sort_num; ?></span>
<?php echo get_the_title( $target_post->ID ); ?>
<input type="hidden" class="list_order"
name="_apop_post_<?php echo $tax_data->taxonomy; ?>[post_sort][<?php echo $tax_data->term_id; ?>][<?php echo $target_post->ID; ?>]"
value="<?php echo $sort_num; ?>">
</li>
<?php endforeach; ?>
<?php $target_posts_no_order = APOP_UI::get_none_sort_post_list( $tax_data->term_id, $tax_key, $exclude_posts ); ?>
<?php if ( count( $target_posts_no_order ) > 0 ): ?>
<?php $sort_num = $sort_num ?? 0; ?>
<?php foreach ( $target_posts_no_order as $key => $target_post_no_order ): $sort_num_no_order = $sort_num + $key + 1; ?>
<li class="product-list">
<span class="sort-num-label"><?php echo $sort_num_no_order; ?></span>
<?php echo get_the_title( $target_post_no_order->ID ); ?>
<input type="hidden" class="list_order"
name="_apop_post_<?php echo $tax_data->taxonomy; ?>[post_sort][<?php echo $tax_data->term_id; ?>][<?php echo $target_post_no_order->ID; ?>]"
value="<?php echo $sort_num_no_order; ?>">
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
<form action="" method="post">
<?php wp_nonce_field( 'sh_options' ); ?>
<h3><?php echo $tax_data->name; ?></h3>
<ul class="post-order-list">
<?php
list( $product_order_list, $exclude_posts, $sort_num ) = APOP_UI::create_order_list( $tax_data, $tax_key, $exclude_posts );
echo $product_order_list;
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>
</form>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?php endforeach; ?>
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
</form>
</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 = []; ?>
<?php foreach ( $tax_list as $tax_data ): ?>
<div class="list-orders-inner">
<form action="" method="post">
<?php wp_nonce_field( 'sh_options' ); ?>
<h3><?php echo $tax_data->name; ?></h3>
<ul class="post-order-list">
<?php
list( $product_order_list, $exclude_posts, $sort_num ) = APOP_UI::create_order_list( $tax_data, $tax_key, $exclude_posts );
echo $product_order_list;
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>
</form>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?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 ) : ?>
<?php if ( count( $taxonomy_list ) > 0 ): $exclude_posts = []; ?>
<?php foreach ( $tax_list as $tax_data ): ?>
<div class="list-orders-inner">
<form action="" method="post">
<?php wp_nonce_field( 'sh_options' ); ?>
<h3><?php echo $tax_data->name; ?></h3>
<ul class="post-order-list">
<?php
list( $product_order_list, $exclude_posts, $sort_num ) = APOP_UI::create_order_list( $tax_data, $tax_key, $exclude_posts );
echo $product_order_list;
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>
</form>
</div>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
</div>