WP PLUGIN ソート対象拡張
・サイドメニュー位置修正 ・カスタムフィールド入力用テキストボックス位置等修正 ・ソート対象チェックボックスのチェック状態によって昇降順ラジオボタンの活性/非活性化するよう修正
This commit is contained in:
@@ -22,6 +22,16 @@ License: GPLv2
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* todo:カスタムフィールド追加処理
|
||||
* 指定したキーが無ければ、投稿の管理画面表示時にメタボックスを追加する。
|
||||
* メタキーは下記のオプションテーブルから取得する
|
||||
* _apop_normal_order_param
|
||||
* _apop_search_order_param
|
||||
* _apop_tax_order_param
|
||||
* ラベルは「APO+カスタムフィールド:XXXX」とする
|
||||
*/
|
||||
|
||||
define( 'APOP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||
define( 'APOP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
|
||||
|
||||
|
||||
@@ -23,8 +23,7 @@ if ( ! class_exists( 'APOP' ) ) {
|
||||
'level_8',
|
||||
'apop_post_sort',
|
||||
array( $this, 'display_setting_page' ),
|
||||
'',
|
||||
50
|
||||
''
|
||||
);
|
||||
add_submenu_page(
|
||||
'apop_post_sort', // parent_slug
|
||||
|
||||
+18
-8
@@ -293,47 +293,57 @@ value="' . $sort_num . '">
|
||||
$sort = $cnv_order_params['sort'];
|
||||
$alert = $cnv_order_params['alert'];
|
||||
$no_order_class = $cnv_order_params['no_order_class'];
|
||||
$field_metakey_input = '';
|
||||
if ( $target_key == 'custom_field' ) {
|
||||
$meta_key = $cnv_order_params['custom_field']['meta_key'];
|
||||
$value_type = $cnv_order_params['custom_field']['value_type'];
|
||||
$field_metakey_input = self::create_custom_field_sort_type( $name_key, $target_key, $meta_key, $value_type );
|
||||
$target_key_check_class = 'custom_field_check';
|
||||
} else {
|
||||
$target_key_check_class = 'sort_' . $target_key . '_check';
|
||||
}
|
||||
$list[] = '<li class="product-list' . $no_order_class . '">
|
||||
<div class="product-list-type-label"><b>' . $target_values[ $target_key ] . '</b></div>
|
||||
<div class="product-list-sort-type">
|
||||
<label>
|
||||
<input type="hidden" name="_' . $name_key . '[' . $target_key . '][use]" value="0"' . self::set_search_normal_checked( $use, 0 ) . '>
|
||||
有効:<input type="checkbox" name="_' . $name_key . '[' . $target_key . '][use]" value="1"' . self::set_search_normal_checked( $use, 1 ) . '>
|
||||
有効:<input class="' . $target_key_check_class . '" type="checkbox" name="_' . $name_key . '[' . $target_key . '][use]" value="1"' . self::set_search_normal_checked( $use, 1 ) . '>
|
||||
</label>
|
||||
<label>
|
||||
<input class="' . $name_key . '" type="radio"
|
||||
<input class="order_param" type="radio"
|
||||
name="_' . $name_key . '[' . $target_key . '][sort]"
|
||||
value="1"' . self::set_search_normal_checked( $sort, 1 ) . '>昇順</label>
|
||||
<label>
|
||||
<input class="' . $name_key . '" type="radio"
|
||||
<input class="order_param" type="radio"
|
||||
name="_' . $name_key . '[' . $target_key . '][sort]"
|
||||
value="2"' . self::set_search_normal_checked( $sort, 2 ) . '>降順</label>
|
||||
' . $field_metakey_input . '
|
||||
</div>
|
||||
</li>';
|
||||
}
|
||||
|
||||
return array(
|
||||
implode( PHP_EOL, $list ),
|
||||
$alert,
|
||||
$field_metakey_input,
|
||||
$alert
|
||||
);
|
||||
}
|
||||
|
||||
private static function create_custom_field_sort_type( $name_key, $target_key, $meta_key, $value_type ): string {
|
||||
return '<div class="sort_custom_field">カスタムフィールドキー:
|
||||
<input type="text" name="_' . $name_key . '[' . $target_key . '][field][meta_key]" value="' . $meta_key . '">
|
||||
値タイプ:
|
||||
return '<div class="sort_custom_field">
|
||||
<div class="sort_custom_field_inner"><div class="sort_custom_field_inner_label">カスタムフィールドキー:</div>
|
||||
<input type="text" class="custom_field_key" name="_' . $name_key . '[' . $target_key . '][field][meta_key]" value="' . $meta_key . '">
|
||||
</div>
|
||||
<div class="sort_custom_field_inner">
|
||||
<div class="sort_custom_field_inner_label">値タイプ:</div>
|
||||
<label><input type="radio"
|
||||
class="custom_field_meta_value"
|
||||
name="_' . $name_key . '[' . $target_key . '][field][value_type]"
|
||||
value="meta_value"' . self::set_search_normal_checked( $value_type, 'meta_value' ) . '>テキスト</label>
|
||||
<label><input type="radio"
|
||||
class="custom_field_meta_value"
|
||||
name="_' . $name_key . '[' . $target_key . '][field][value_type]"
|
||||
value="meta_value_num"' . self::set_search_normal_checked( $value_type, 'meta_value_num' ) . '>数値</label>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ dl.apop_setting_list dd:first-of-type {
|
||||
.search_normal_sort .product-list-sort-type {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.search_normal_sort .product-list-sort-type label {
|
||||
@@ -163,6 +164,21 @@ dl.apop_setting_list dd:first-of-type {
|
||||
|
||||
.sort_custom_field {
|
||||
width: 100%;
|
||||
margin-top: .5em;
|
||||
padding-top: .5em;
|
||||
border-top: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.sort_custom_field_inner {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.sort_custom_field_inner:first-child {
|
||||
margin-bottom: .5em;
|
||||
}
|
||||
|
||||
.sort_custom_field_inner_label {
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1264px) {
|
||||
|
||||
+50
-69
@@ -7,8 +7,6 @@ jQuery(function ($) {
|
||||
order_list();
|
||||
|
||||
//order type
|
||||
// change_search_order();
|
||||
// change_normal_order();
|
||||
change_sort_box();
|
||||
|
||||
//Tax select
|
||||
@@ -18,6 +16,8 @@ jQuery(function ($) {
|
||||
change_search_per_page();
|
||||
change_tax_per_page();
|
||||
|
||||
change_custom_field_sort();
|
||||
change_normal_field_sort();
|
||||
|
||||
function change_tab_menu() {
|
||||
let submit_type = $('.post-order-box-outer').data('submit_type');
|
||||
@@ -60,80 +60,23 @@ jQuery(function ($) {
|
||||
}
|
||||
}
|
||||
|
||||
function change_normal_order() {
|
||||
let s_radio = $('.apop_normal_order');
|
||||
let s_box = $('.normal_sort_box');
|
||||
let default_index = $('.apop_normal_order_target').data('normal_order_target') - 1;
|
||||
|
||||
s_box.hide().find('input').each(function () {
|
||||
$(this).prop('disabled', true);
|
||||
});
|
||||
$('.normal_sort_box:eq(' + default_index + ')').show().find('input').prop('disabled', false);
|
||||
|
||||
s_radio.on('click', function () {
|
||||
let target_index = $(this).val() - 1;
|
||||
s_box.hide().find('input').each(function () {
|
||||
$(this).prop('disabled', true);
|
||||
});
|
||||
$('.normal_sort_box:eq(' + target_index + ')').show().find('input').prop('disabled', false);
|
||||
})
|
||||
}
|
||||
|
||||
function change_search_order() {
|
||||
let s_radio = $('.apop_search_order');
|
||||
let s_box = $('.search_sort_box');
|
||||
let default_index = $('.apop_search_order_target').data('search_order_target') - 1;
|
||||
|
||||
s_box.hide().find('input').each(function () {
|
||||
$(this).prop('disabled', true);
|
||||
});
|
||||
|
||||
$('.search_sort_box:eq(' + default_index + ')').show().find('input').prop('disabled', false);
|
||||
|
||||
s_radio.on('click', function () {
|
||||
let target_index = $(this).val() - 1;
|
||||
s_box.hide().find('input').each(function () {
|
||||
$(this).prop('disabled', true);
|
||||
});
|
||||
$('.search_sort_box:eq(' + target_index + ')').show().find('input').prop('disabled', false);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function change_sort_box() {
|
||||
let parent_selector = $('.list-orders-inner');
|
||||
let parent_selector_size = parent_selector.length;
|
||||
let s_radio = $('.sort_menu');
|
||||
let s_box = $('.sort_box');
|
||||
let sort_menu_size = $('.sort_menu_list').length;
|
||||
|
||||
s_box.hide().find('input').each(function () {
|
||||
$(this).prop('disabled', true);
|
||||
});
|
||||
|
||||
for (let i = 0; i < parent_selector_size; i++) {
|
||||
let my_target = $('.list-orders-inner:eq(' + i + ')');
|
||||
let default_index = my_target.find('.sort_menu_list').data('order_target') - 1;
|
||||
if (typeof default_index !== "undefined") {
|
||||
my_target.find('.sort_box:eq(' + default_index + ')').show().find('input').prop('disabled', false);
|
||||
} else if (isNaN(default_index)) {
|
||||
my_target.find('.sort_box:eq(0)').show().find('input').prop('disabled', false);
|
||||
}
|
||||
$('.sort_box').hide();
|
||||
for (let i = 0; i < sort_menu_size; i++) {
|
||||
let type_index = $('.sort_menu_list:eq(' + i + ')').data('order_target') - 1;
|
||||
$('.sort_menu_list:eq(' + i + ')').siblings('.sort_box:eq(' + type_index + ')').show();
|
||||
}
|
||||
|
||||
s_radio.on('click', function () {
|
||||
let target_index = $(this).val() - 1;
|
||||
$(this).parents('.list-orders-inner')
|
||||
.find('.sort_box').hide()
|
||||
.find('input').each(function () {
|
||||
$(this).prop('disabled', true);
|
||||
});
|
||||
$(this).parents('.list-orders-inner')
|
||||
.find('.sort_box:eq(' + target_index + ')').show()
|
||||
.find('input').prop('disabled', false);
|
||||
$(this).parents('.list-orders-inner').find('.sort_box').hide();
|
||||
$(this).parents('.list-orders-inner').find('.sort_box:eq(' + target_index + ')').show();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function select_tax() {
|
||||
let select_cat_checkbox = $('.select_cat_checkbox');
|
||||
let input_chk_size = select_cat_checkbox.length;
|
||||
@@ -182,9 +125,7 @@ jQuery(function ($) {
|
||||
function change_tax_per_page() {
|
||||
let set_number = $('.set_number');
|
||||
let input_chk_size = set_number.length;
|
||||
|
||||
let i = 0;
|
||||
for (i; i < input_chk_size; i++) {
|
||||
for (let i = 0; i < input_chk_size; i++) {
|
||||
let input_num_box = $('.set_number:eq(' + i + ')').siblings('.per_page_cat_input');
|
||||
if (input_num_box.val() == '') {
|
||||
input_num_box.prop('disabled', true);
|
||||
@@ -202,4 +143,44 @@ jQuery(function ($) {
|
||||
});
|
||||
}
|
||||
|
||||
function change_custom_field_sort() {
|
||||
let s_box = $('.sort_box');
|
||||
let custom_field_check = $('.custom_field_check');
|
||||
|
||||
s_box.find(custom_field_check).each(function () {
|
||||
if ($(this).prop('checked') == false) {
|
||||
$(this).parents('.product-list-sort-type').find('.custom_field_key').prop('disabled', true);
|
||||
$(this).parents('.product-list-sort-type').find('.custom_field_meta_value').prop('disabled', true);
|
||||
}
|
||||
});
|
||||
|
||||
custom_field_check.on('click', function () {
|
||||
if ($(this).prop('checked') == true) {
|
||||
$(this).parents('.product-list-sort-type').find('.custom_field_key').prop('disabled', false);
|
||||
$(this).parents('.product-list-sort-type').find('.custom_field_meta_value').prop('disabled', false);
|
||||
} else {
|
||||
$(this).parents('.product-list-sort-type').find('.custom_field_key').val('').prop('disabled', true);
|
||||
$(this).parents('.product-list-sort-type').find('.custom_field_meta_value').prop('disabled', true);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function change_normal_field_sort() {
|
||||
let s_box = $('.sort_box');
|
||||
let targets = '.custom_field_check, .sort_date_check, .sort_title_check, .sort_ID_check, .sort_modified_check';
|
||||
|
||||
s_box.find(targets).each(function () {
|
||||
if ($(this).prop('checked') == false) {
|
||||
$(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', true);
|
||||
}
|
||||
});
|
||||
$(targets).on('click', function () {
|
||||
if ($(this).prop('checked') == true) {
|
||||
$(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', false)
|
||||
} else {
|
||||
$(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
+2
-4
@@ -26,12 +26,11 @@ $submit_type = APOP_UI::input_post_filter( 'submit_type', 'str' );
|
||||
<?php include APOP_PLUGIN_PATH . 'template/order_parts_menu.php'; ?>
|
||||
<hr>
|
||||
<div class="sort_box">
|
||||
<?php list( $list, $alert, $field_metakey_input ) = APOP_UI::create_search_normal_list( 'normal' ); ?>
|
||||
<?php list( $list, $alert ) = APOP_UI::create_search_normal_list( 'normal' ); ?>
|
||||
<?php echo $alert; ?>
|
||||
<ul class="post-order-list search_normal_sort">
|
||||
<?php echo $list; ?>
|
||||
</ul>
|
||||
<?php echo $field_metakey_input; ?>
|
||||
</div>
|
||||
<div class="sort_box">
|
||||
<?php echo APOP_UI::none_registered_alert_msg(); ?>
|
||||
@@ -59,12 +58,11 @@ $submit_type = APOP_UI::input_post_filter( 'submit_type', 'str' );
|
||||
<?php include APOP_PLUGIN_PATH . 'template/order_parts_menu.php'; ?>
|
||||
<hr>
|
||||
<div class="sort_box">
|
||||
<?php list( $list, $alert, $field_metakey_input ) = APOP_UI::create_search_normal_list( 'search' ); ?>
|
||||
<?php list( $list, $alert ) = APOP_UI::create_search_normal_list( 'search' ); ?>
|
||||
<?php echo $alert; ?>
|
||||
<ul class="post-order-list search_normal_sort">
|
||||
<?php echo $list; ?>
|
||||
</ul>
|
||||
<?php echo $field_metakey_input; ?>
|
||||
</div>
|
||||
<div class="sort_box">
|
||||
<?php echo APOP_UI::none_registered_alert_msg(); ?>
|
||||
|
||||
@@ -38,12 +38,11 @@
|
||||
</ul>
|
||||
</div>
|
||||
<div class="sort_box">
|
||||
<?php list( $list, $alert, $field_metakey_input ) = APOP_UI::create_search_normal_list( 'tax', $tax_data->term_id ); ?>
|
||||
<?php list( $list, $alert) = APOP_UI::create_search_normal_list( 'tax', $tax_data->term_id ); ?>
|
||||
<?php echo $alert; ?>
|
||||
<ul class="post-order-list search_normal_sort">
|
||||
<?php echo $list; ?>
|
||||
</ul>
|
||||
<?php echo $field_metakey_input; ?>
|
||||
</div>
|
||||
<input type="hidden" name="submit_type" value="<?php echo $submit_type_number; ?>">
|
||||
<p class="submit post-order"><input type="submit" name="Submit"
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ $param_settings = array(
|
||||
'_apop_tax_sort_type',
|
||||
'_apop_normal_order_param',
|
||||
'_apop_search_order_param',
|
||||
'apop_tax_order_param',
|
||||
'_apop_tax_order_param',
|
||||
);
|
||||
foreach ( $param_settings as $param_setting ) {
|
||||
delete_option( $param_setting );
|
||||
|
||||
Reference in New Issue
Block a user