WP PLUGIN 

・カスタムフィールドの必須チェック漏れの修正
・既存カスタムフィールド選択も可能なよう修正
・ソートのリストに背景色を設定
・並べ替え設定ページの更新ボタン位置を修正
・カテゴリー、タグ、カスタム分類のソート対象選択のラジオボタン並び順を標準、検索と同一になるよう修正
This commit is contained in:
2021-06-25 20:58:52 +09:00
parent c7996062fa
commit f6d64404a7
12 changed files with 202 additions and 57 deletions
+10 -7
View File
@@ -11,6 +11,7 @@ if ( ! class_exists( 'APOP_POST' ) ) {
const TEMPLATE_DIR = __DIR__ . '/../template/';
private $order_field = array();
private $custom_field_type = array();
private $name_keys = array();
private $order_param_keys = array(
'custom_field',
@@ -71,20 +72,21 @@ if ( ! class_exists( 'APOP_POST' ) ) {
if ( $update ) {
$this->name_keys[] = $param[ $order_param_key ]['field']['meta_key'];
} else {
$this->order_field[ $key ][] = $param[ $order_param_key ]['field']['meta_key'];
$this->custom_field_type[ $key ][] = $param[ $order_param_key ]['field']['custom_field_type'];
$this->order_field[ $key ][] = $param[ $order_param_key ]['field']['meta_key'];
}
}
}
}
private function create_order_tax_field_data( $param, $update = false ) {
$term_ids = $this->create_post_term_ids();
$term_ids = $this->create_post_term_ids();
$sort_types = get_option( '_apop_tax_sort_type' );
foreach ( $term_ids as $term_id ) {
if(!isset($sort_types[$term_id])){
if ( ! isset( $sort_types[ $term_id ] ) ) {
continue;
}
if($sort_types[$term_id] == '1'){
if ( $sort_types[ $term_id ] == '1' ) {
break;
}
foreach ( $this->order_param_keys as $order_param_key ) {
@@ -93,7 +95,8 @@ if ( ! class_exists( 'APOP_POST' ) ) {
if ( $update ) {
$this->name_keys[] = $param[ $term_id ][ $order_param_key ]['field']['meta_key'];
} else {
$this->order_field['tax'][] = $param[ $term_id ][ $order_param_key ]['field']['meta_key'];
$this->custom_field_type['tax'][] = $param[ $term_id ][ $order_param_key ]['field']['custom_field_type'];
$this->order_field['tax'][] = $param[ $term_id ][ $order_param_key ]['field']['meta_key'];
}
}
}
@@ -118,10 +121,10 @@ if ( ! class_exists( 'APOP_POST' ) ) {
return $term_ids;
}
private function get_custom_field_data( $custom_filed_name ) {
private function get_custom_field_data( $custom_filed_name, $prefix ) {
global $post;
return get_post_meta( $post->ID, APOP_CUSTOM_FIELD_PREFIX . $custom_filed_name, true );
return get_post_meta( $post->ID, $prefix . $custom_filed_name, true );
}
// カスタムフィールドの値を保存
+51 -31
View File
@@ -4,8 +4,13 @@ if ( ! defined( 'ABSPATH' ) ) {
} // Exit if accessed directly
if ( ! class_exists( 'APOP_UI' ) ) {
require_once __DIR__ . '/../util/apop-customfield-select.php';
class APOP_UI {
use CUSTOMFIELD_SELECT;
public static function get_order_type( $type ) {
$type_data = get_option( $type );
if ( ! $type_data ) {
@@ -295,13 +300,12 @@ value="' . esc_html( $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'];
$no_order_class = $cnv_order_params['no_order_class'];
$field_metakey_input = '';
$name_use_key = '_' . $name_key . '[' . $target_key . '][use]';
$name_sort_key = '_' . $name_key . '[' . $target_key . '][sort]';
$cnv_order_params = self::set_order_list_param( $order_param, $target_key );
$use = $cnv_order_params['use'];
$sort = $cnv_order_params['sort'];
$no_order_class = $cnv_order_params['no_order_class'];
$name_use_key = '_' . $name_key . '[' . $target_key . '][use]';
$name_sort_key = '_' . $name_key . '[' . $target_key . '][sort]';
if ( strpos( $target_key, 'custom_field' ) !== false ) {
$target_key_check_class = 'custom_field_check';
} else {
@@ -336,27 +340,41 @@ value="' . esc_html( $sort_num ) . '">
}
private static function create_custom_field_sort_type( $name_key, $target_key, $cnv_order_params ) {
$meta_key = $cnv_order_params[ $target_key ]['meta_key'];
$value_type = $cnv_order_params[ $target_key ]['value_type'];
$name_meta_key = '_' . $name_key . '[' . $target_key . '][field][meta_key]';
$name_value_type = '_' . $name_key . '[' . $target_key . '][field][value_type]';
$meta_key = $cnv_order_params[ $target_key ]['meta_key'];
$value_type = $cnv_order_params[ $target_key ]['value_type'];
$custom_field_type = $cnv_order_params[ $target_key ]['custom_field_type'];
$name_meta_key = '_' . $name_key . '[' . $target_key . '][field][meta_key]';
$name_value_type = '_' . $name_key . '[' . $target_key . '][field][value_type]';
$name_custom_field_type = '_' . $name_key . '[' . $target_key . '][field][custom_field_type]';
echo '<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="' . esc_attr( $name_meta_key ) . '" value="' . esc_attr( $meta_key ) . '">
</div>
<div class="sort-custom-field-inner">
<div class="sort-custom-field-inner-label">値タイプ:</div>
<label class="sort-custom-field-text-label">
<input type="radio"
class="custom_field_meta_value"
name="' . esc_attr( $name_value_type ) . '"
value="meta_value"' . esc_attr( self::set_search_normal_checked( $value_type, 'meta_value' ) ) . '>テキスト</label>
<label><input type="radio"
class="custom_field_meta_value"
name="' . esc_attr( $name_value_type ) . '"
value="meta_value_num"' . esc_attr( self::set_search_normal_checked( $value_type, 'meta_value_num' ) ) . '>数値</label>
</div>
</div>';
<div class="sort-custom-field-types"><div class="sort-custom-field-inner-label">
<label>
<input type="radio"
class="custom-field-type"
name="' . esc_attr( $name_custom_field_type ) . '"
value="1"' . esc_attr( self::set_search_normal_checked( $custom_field_type, '1' ) ) . '>選択</label>
<label>
<input type="radio"
class="custom-field-type"
name="' . esc_attr( $name_custom_field_type ) . '"
value="2"' . esc_attr( self::set_search_normal_checked( $custom_field_type, '2' ) ) . '>追加</label>
</div>';
self::set_all_customfield_select( $name_meta_key );
echo '<input type="text" class="custom_field_key" name="' . esc_attr( $name_meta_key ) . '" value="' . esc_attr( $meta_key ) . '" required>
</div>
<div class="sort-custom-field-inner">
<div class="sort-custom-field-inner-label">値タイプ:</div>
<label class="sort-custom-field-text-label">
<input type="radio"
class="custom-field-meta-value"
name="' . esc_attr( $name_value_type ) . '"
value="meta_value"' . esc_attr( self::set_search_normal_checked( $value_type, 'meta_value' ) ) . '>テキスト</label>
<label><input type="radio"
class="custom-field-meta-value"
name="' . esc_attr( $name_value_type ) . '"
value="meta_value_num"' . esc_attr( 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 {
@@ -369,8 +387,9 @@ value="' . esc_html( $sort_num ) . '">
if ( strpos( $target_key, 'custom_field' ) !== false ) {
$param[ $target_key ] = array(
'meta_key' => '',
'value_type' => 'meta_value',
'meta_key' => '',
'value_type' => 'meta_value',
'custom_field_type' => '1',
);
}
@@ -382,8 +401,9 @@ value="' . esc_html( $sort_num ) . '">
);
if ( strpos( $target_key, 'custom_field' ) !== false ) {
$param[ $target_key ] = array(
'meta_key' => $order_param[ $target_key ]['field']['meta_key'] ?? '',
'value_type' => $order_param[ $target_key ]['field']['value_type'] ?? 'meta_value',
'meta_key' => $order_param[ $target_key ]['field']['meta_key'] ?? '',
'value_type' => $order_param[ $target_key ]['field']['value_type'] ?? 'meta_value',
'custom_field_type' => $order_param[ $target_key ]['field']['custom_field_type'] ?? '1',
);
}
}
+1
View File
@@ -4,6 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
} // Exit if accessed directly
if ( ! class_exists( 'APOP' ) ) {
require_once __DIR__ . '/../util/apop-order-setting.php';
class APOP {