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
+27
View File
@@ -0,0 +1,27 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( ! trait_exists( 'CUSTOMFIELD_SELECT' ) ) {
trait CUSTOMFIELD_SELECT {
public static function set_all_customfield_select( $name_meta_key ) {
$selects = self::get_all_custom_fields();
echo '<select class="custom_field_key_select" name="' . esc_attr( $name_meta_key ) . '" required>';
foreach ( $selects as $select ) {
echo '<option value="' . esc_attr( $select->meta_key ) . '">' . esc_html( $select->meta_key ) . '</option>';
}
echo '</select>';
}
private static function get_all_custom_fields() {
global $wpdb;
//アンダーバーで始まるシステム系のパラメータは除外する
return $wpdb->get_results( 'SELECT DISTINCT meta_key FROM ' . $wpdb->prefix . 'postmeta WHERE meta_key NOT LIKE ' . "'\_%' ORDER BY meta_key ASC" );
}
}
}
+5 -1
View File
@@ -90,7 +90,11 @@ if ( ! trait_exists( 'APOP_ORDER_SETTING' ) ) {
private static function set_custom_filed_sort( &$orderby, $order_col, $orders, $sort_param ): array {
if ( strpos( $order_col, 'custom_field' ) !== false ) {
$meta_key = APOP_CUSTOM_FIELD_PREFIX . $orders['field']['meta_key'];
if($orders['field']['custom_field_type'] == 2){
$meta_key = APOP_CUSTOM_FIELD_PREFIX . $orders['field']['meta_key'];
}else{
$meta_key = $orders['field']['meta_key'];
}
$type = 'CHAR';
if ( $orders['field']['value_type'] == 'meta_value_num' ) {
$type = 'NUMERIC';