WP PLUGIN バグ修正 ソートのカスタムフィールドのメタボックス追加

・ソートのカスタムフィールドのメタボックスを追加
・共通nameタグが更新されないバグ対策としてフォームタグを共通化
・ファイル名をクラス名に合わせるよう変更
This commit is contained in:
2021-06-13 10:11:17 +09:00
parent 2c72904078
commit 9cc82988e2
8 changed files with 326 additions and 149 deletions
+39 -48
View File
@@ -13,12 +13,12 @@ $submit_type = APOP_UI::input_post_filter( 'submit_type', 'str' );
</ul>
</nav>
<div class="post-order-box-outer" data-submit_type="<?php echo $submit_type; ?>">
<div class="post-order-box">
<div class="list-orders-outer">
<div class="list-orders-inner">
<form action="" method="post">
<form action="" method="post">
<?php wp_nonce_field( 'sh_options' ); ?>
<div class="post-order-box">
<div class="list-orders-outer">
<div class="list-orders-inner">
<h3>通常</h3>
<?php wp_nonce_field( 'sh_options' ); ?>
<?php
$order_target_type = '_apop_normal_order';
$order_target = APOP_UI::get_order_type( $order_target_type );
@@ -43,20 +43,13 @@ $submit_type = APOP_UI::input_post_filter( 'submit_type', 'str' );
<?php echo APOP_UI::get_all_search_normal_posts( 'normal' ); ?>
</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>
<div class="post-order-box">
<div class="list-orders-outer">
<div class="list-orders-inner">
<form action="" method="post">
<div class="post-order-box">
<div class="list-orders-outer">
<div class="list-orders-inner">
<h3>検索</h3>
<?php wp_nonce_field( 'sh_options' ); ?>
<?php
$order_target_type = '_apop_search_order';
$order_target = APOP_UI::get_order_type( $order_target_type );
@@ -81,42 +74,40 @@ $submit_type = APOP_UI::input_post_filter( 'submit_type', 'str' );
<?php echo APOP_UI::get_all_search_normal_posts( 'search' ); ?>
</ul>
</div>
<input type="hidden" name="submit_type" value="1">
<p class="submit post-order"><input type="submit" name="Submit" class="button-primary"
value="変更を保存"/></p>
</form>
</div>
</div>
</div>
</div>
<div class="post-order-box">
<div class="tax_sort_box">
<?php
$tax_lists = array( 'category' => APOP_UI::get_cat_tag_list( 'cat', 'category' ) );
$tax_title_text = 'カテゴリー';
$submit_type_number = 2;
?>
<?php include APOP_PLUGIN_PATH . 'template/order_parts_taxonomy.php'; ?>
<div class="post-order-box">
<div class="tax_sort_box">
<?php
$tax_lists = array( 'category' => APOP_UI::get_cat_tag_list( 'cat', 'category' ) );
$tax_title_text = 'カテゴリー';
$submit_type_number = 2;
?>
<?php include APOP_PLUGIN_PATH . 'template/order_parts_taxonomy.php'; ?>
</div>
</div>
</div>
<div class="post-order-box">
<div class="tax_sort_box">
<?php
$tax_lists = array( 'tag_id' => APOP_UI::get_cat_tag_list( 'tag', 'post_tag' ) );
$tax_title_text = 'タグ';
$submit_type_number = 3;
?>
<?php include APOP_PLUGIN_PATH . 'template/order_parts_taxonomy.php'; ?>
<div class="post-order-box">
<div class="tax_sort_box">
<?php
$tax_lists = array( 'tag_id' => APOP_UI::get_cat_tag_list( 'tag', 'post_tag' ) );
$tax_title_text = 'タグ';
$submit_type_number = 3;
?>
<?php include APOP_PLUGIN_PATH . 'template/order_parts_taxonomy.php'; ?>
</div>
</div>
</div>
<div class="post-order-box">
<div class="tax_sort_box">
<?php
$tax_lists = array( 'taxonomy' => APOP_UI::get_cat_tag_list( 'tax', 'taxonomy' ) );
$tax_title_text = 'カスタム分類';
$submit_type_number = 4;
?>
<?php include APOP_PLUGIN_PATH . 'template/order_parts_taxonomy.php'; ?>
<div class="post-order-box">
<div class="tax_sort_box">
<?php
$tax_lists = array( 'taxonomy' => APOP_UI::get_cat_tag_list( 'tax', 'taxonomy' ) );
$tax_title_text = 'カスタム分類';
$submit_type_number = 4;
?>
<?php include APOP_PLUGIN_PATH . 'template/order_parts_taxonomy.php'; ?>
</div>
</div>
</div>
<p class="apop-submit"><input type="submit" name="submit" class="button-primary" value="変更を保存"/></p>
</form>
</div>
</div>
+40 -48
View File
@@ -5,56 +5,48 @@
<?php echo APOP_UI::none_registered_alert_msg(); ?>
<?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>
<?php
$order_target_data = get_option( '_apop_tax_sort_type' );
if ( isset( $order_target_data[ $tax_data->term_id ] ) ) {
$order_target = $order_target_data[ $tax_data->term_id ];
} else {
$order_target = 1;
}
?>
<ul class="sort_menu_list"
data-order_target="<?php echo $order_target; ?>">
<li>
<label>
<input class="sort_menu" type="radio"
name="_apop_tax_sort_type[<?php echo $tax_data->term_id; ?>]"
value="1"<?php checked( $order_target, 1 ); ?>>ドラッグソート</label>
</li>
<li>
<label>
<input class="sort_menu" type="radio"
name="_apop_tax_sort_type[<?php echo $tax_data->term_id; ?>]"
value="2"<?php checked( $order_target, 2 ); ?>>標準+カスタムフィールドソート</label>
</li>
</ul>
<h3><?php echo $tax_data->name; ?></h3>
<?php
$order_target_data = get_option( '_apop_tax_sort_type' );
if ( isset( $order_target_data[ $tax_data->term_id ] ) ) {
$order_target = $order_target_data[ $tax_data->term_id ];
} else {
$order_target = 1;
}
?>
<ul class="sort_menu_list"
data-order_target="<?php echo $order_target; ?>">
<li>
<label>
<input class="sort_menu" type="radio"
name="_apop_tax_sort_type[<?php echo $tax_data->term_id; ?>]"
value="1"<?php checked( $order_target, 1 ); ?>>ドラッグソート</label>
</li>
<li>
<label>
<input class="sort_menu" type="radio"
name="_apop_tax_sort_type[<?php echo $tax_data->term_id; ?>]"
value="2"<?php checked( $order_target, 2 ); ?>>標準+カスタムフィールドソート</label>
</li>
</ul>
<div class="sort_box">
<ul class="post-order-list">
<?php echo APOP_UI::create_order_list( $tax_data, $tax_key ); ?>
</ul>
<div class="sort_box">
<ul class="post-order-list">
<?php echo APOP_UI::create_order_list( $tax_data, $tax_key ); ?>
</ul>
</div>
<div class="sort_box">
<?php list( $list, $alert ) = APOP_UI::create_search_normal_list( 'tax', $tax_data->term_id ); ?>
<?php echo $alert; ?>
<h4>有効</h4>
<ul class="post-order-list search_normal_sort">
<?php echo $list; ?>
</ul>
<div class="disable_box">
<h4>無効</h4>
<ul class="disable_normal_list"></ul>
</div>
<div class="sort_box">
<?php list( $list, $alert ) = APOP_UI::create_search_normal_list( 'tax', $tax_data->term_id ); ?>
<?php echo $alert; ?>
<h4>有効</h4>
<ul class="post-order-list search_normal_sort">
<?php echo $list; ?>
</ul>
<div class="disable_box">
<h4>無効</h4>
<ul class="disable_normal_list"></ul>
</div>
</div>
<input type="hidden" name="submit_type" value="<?php echo $submit_type_number; ?>">
<p class="submit post-order"><input type="submit" name="Submit"
class="button-primary"
value="変更を保存"/></p>
<input type="hidden" name="sort_type[cat]" value="1">
</form>
</div>
</div>
<?php endforeach; ?>
<?php else: ?>
+41 -41
View File
@@ -1,47 +1,47 @@
<div class="post-setting-box">
<form action="" method="post">
<?php
<?php
wp_nonce_field( 'sh_options' );
$opt_per_page = get_option( '_apop_per_page' );
$default_per_page = get_option( 'posts_per_page' );
?>
<h2>設定</h2>
<table class="form-table">
<tr>
<th scope="row">全体設定</th>
<td>
<dl class="apop_setting_list">
<dt>1ページ表示件数</dt>
<dd><?php $per_page_data = APOP_UI::create_cat_per_page( $opt_per_page, 'search' ); ?>
<ul>
<li>
<label>
<input class="per_page_search" type="radio" name="_apop_per_page[search]"
value="default"<?php checked( $per_page_data['_per_page'], 'default' ); ?>>表示設定に従う(<?php echo $default_per_page; ?>
件)</label>
</li>
<li><label>
<input class="per_page_search" type="radio" name="_apop_per_page[search]"
value="-1"<?php checked( $per_page_data['_per_page'], '-1' ); ?>>全件</label>
</li>
<li>
<label><input class="per_page_search" type="radio"
name="_apop_per_page[search]"
value=""<?php echo $per_page_data['_checked']; ?>>表示数設定
<input class="per_page_search_input" type="text"
name="_apop_per_page[search]"
value="<?php echo $per_page_data['_per_page_num']; ?>" required>
</label>
</li>
</ul>
</dd>
</dl>
</td>
</tr>
<?php APOP_UI::disp_tax_setting( 'category', 'カテゴリー', '_apop_cat_order' ); ?>
<?php APOP_UI::disp_tax_setting( 'post_tag', 'タグ', '_apop_tag_order' ); ?>
<?php APOP_UI::disp_tax_setting( 'taxonomy', 'カスタム分類', '_apop_tax_order' ); ?>
</table>
$opt_per_page = get_option( '_apop_per_page' );
$default_per_page = get_option( 'posts_per_page' );
?>
<h2>設定</h2>
<table class="form-table apop-form_table">
<tr>
<th scope="row">全体設定</th>
<td>
<dl class="apop_setting_list">
<dt>1ページ表示件数</dt>
<dd><?php $per_page_data = APOP_UI::create_cat_per_page( $opt_per_page, 'search' ); ?>
<ul>
<li>
<label>
<input class="per_page_search" type="radio" name="_apop_per_page[search]"
value="default"<?php checked( $per_page_data['_per_page'], 'default' ); ?>>表示設定に従う(<?php echo $default_per_page; ?>
件)</label>
</li>
<li><label>
<input class="per_page_search" type="radio" name="_apop_per_page[search]"
value="-1"<?php checked( $per_page_data['_per_page'], '-1' ); ?>>全件</label>
</li>
<li>
<label><input class="per_page_search" type="radio"
name="_apop_per_page[search]"
value=""<?php echo $per_page_data['_checked']; ?>>表示数設定
<input class="per_page_search_input" type="text"
name="_apop_per_page[search]"
value="<?php echo $per_page_data['_per_page_num']; ?>" required>
</label>
</li>
</ul>
</dd>
</dl>
</td>
</tr>
<?php APOP_UI::disp_tax_setting( 'category', 'カテゴリー', '_apop_cat_order' ); ?>
<?php APOP_UI::disp_tax_setting( 'post_tag', 'タグ', '_apop_tag_order' ); ?>
<?php APOP_UI::disp_tax_setting( 'taxonomy', 'カスタム分類', '_apop_tax_order' ); ?>
</table>
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/>
</form>
</div>
+21
View File
@@ -0,0 +1,21 @@
<div class="order_setting_custom_field_box">
<?php if ( isset( $this->order_field ) && count( $this->order_field ) > 0 ): ?>
<dl class="apop_setting_list_dd">
<?php foreach ( $this->order_field as $type => $items ): ?>
<dt><?php echo $this->labels[ $type ]; ?></dt>
<dd>
<ul>
<?php foreach ( $items as $item ): ?>
<?php if ( ! empty( $item ) ): ?>
<li><label><?php echo $item; ?></label>
<input type="text" name="<?php echo $item; ?>"
value="<?php echo $this->get_custom_field_data( $item ); ?>"/>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</dd>
<?php endforeach; ?>
</dl>
<?php endif; ?>
</div>