f6d64404a7
・カスタムフィールドの必須チェック漏れの修正 ・既存カスタムフィールド選択も可能なよう修正 ・ソートのリストに背景色を設定 ・並べ替え設定ページの更新ボタン位置を修正 ・カテゴリー、タグ、カスタム分類のソート対象選択のラジオボタン並び順を標準、検索と同一になるよう修正
27 lines
871 B
PHP
27 lines
871 B
PHP
<?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" );
|
|
}
|
|
}
|
|
} |