WP PLUGIN ソート対象拡張

・サイドメニュー位置修正
・カスタムフィールド入力用テキストボックス位置等修正
・ソート対象チェックボックスのチェック状態によって昇降順ラジオボタンの活性/非活性化するよう修正
This commit is contained in:
2021-05-11 20:48:30 +09:00
parent 12d16b2f2c
commit ad509c0977
8 changed files with 109 additions and 96 deletions
+1 -2
View 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
+27 -17
View File
@@ -288,57 +288,67 @@ value="' . $sort_num . '">
);
$list = array();
foreach ( $target_keys as $target_key ) {
$cnv_order_params = self::set_order_list_param( $order_param, $target_key );
$use = $cnv_order_params['use'];
$sort = $cnv_order_params['sort'];
$alert = $cnv_order_params['alert'];
$no_order_class = $cnv_order_params['no_order_class'];
$cnv_order_params = self::set_order_list_param( $order_param, $target_key );
$use = $cnv_order_params['use'];
$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 );
$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>';
}
private static function set_order_list_param( $order_param, $target_key ): array {
$param = array(
'use' => 0,
'sort' => 2,