diff --git a/archive-post-oder-plus.php b/archive-post-oder-plus.php index 2db47bf..536fa30 100644 --- a/archive-post-oder-plus.php +++ b/archive-post-oder-plus.php @@ -22,6 +22,9 @@ License: GPLv2 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +define( 'APOP_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); +define( 'APOP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); + //メイン処理のクラスをインスタンス化 require_once __DIR__ . '/class/class.apop.order.php'; require_once __DIR__ . '/class/class.apop.ui.php'; @@ -31,10 +34,9 @@ $APOP = new APOP; //CSS, JSの読み込み add_action( 'admin_enqueue_scripts', 'register_my_styles' ); function register_my_styles() { - $plugin_url = plugin_dir_url( __FILE__ ); - wp_enqueue_style( 'hrc_post_style', $plugin_url . 'css/apop-style.css' ); + wp_enqueue_style( 'hrc_post_style', APOP_PLUGIN_URL . 'css/apop-style.css' ); wp_enqueue_script( 'jquery-ui-sortable' ); - wp_enqueue_script( 'post-sort-cat-order_js', $plugin_url . 'js/apop-style.js' ); + wp_enqueue_script( 'post-sort-cat-order_js', APOP_PLUGIN_URL . 'js/apop-style.js' ); } $APOP->set_query(); diff --git a/class/class.apop.ui.php b/class/class.apop.ui.php index 48c8b26..3201500 100644 --- a/class/class.apop.ui.php +++ b/class/class.apop.ui.php @@ -32,7 +32,7 @@ if ( ! class_exists( 'APOP_UI' ) ) { return implode( PHP_EOL, $list ); } - private static function crate_non_registerd_mark( $no_order ) { + private static function crate_non_registerd_mark( $no_order ): string { if ( ! empty( $no_order ) ) { return '■'; } @@ -44,6 +44,8 @@ if ( ! class_exists( 'APOP_UI' ) ) { return array( 'post_status' => array( 'publish', 'draft' ), 'posts_per_page' => - 1, + 'orderby' => 'meta_value_num', + 'order' => 'ASC', 'meta_query' => array( 'relation' => 'OR', array( @@ -58,13 +60,20 @@ if ( ! class_exists( 'APOP_UI' ) ) { ); } - - public static function get_all_taxonomies( $key ) { + private static function get_all_taxonomies( $key ) { if ( $key !== 'taxonomy' ) { return get_terms( array( 'taxonomy' => $key, 'get' => 'all' ) ); } + $all_custom_tax = get_taxonomies( array( 'public' => true, '_builtin' => false ) ); + $custom_tax_list = []; + foreach ( $all_custom_tax as $custom_tax ) { + $custom_tax_list = array_merge( $custom_tax_list, get_terms( array( + 'taxonomy' => $custom_tax, + 'get' => 'all' + ) ) ); + } - return get_taxonomies( array( 'public' => true, '_builtin' => false ) ); + return $custom_tax_list; } public static function get_cat_tag_list( $target, $key ): array { @@ -221,6 +230,37 @@ value="' . $sort_num . '"> ); } + public static function disp_tax_setting( $key, $title, $order_name ) { + $tax_data = APOP_UI::get_all_taxonomies( $key ); + if ( count( $tax_data ) > 0 ) { + $order_name = $order_name; + $order_tax = $key == 'post_tag' ? 'tag' : $key; + echo '