diff --git a/archive-post-oder-plus.php b/archive-post-oder-plus.php
new file mode 100644
index 0000000..2b306d1
--- /dev/null
+++ b/archive-post-oder-plus.php
@@ -0,0 +1,41 @@
+ 'post',
'post_status' => array( 'publish', 'draft' ),
'posts_per_page' => - 1,
'category' => $cat_id,
@@ -32,7 +31,7 @@ class activate {
* @param $cat_id
*/
public static function create_sort_field( $post_id, $cat_id ) {
- $sort_key = 'nb_post_sort_' . $cat_id;
+ $sort_key = '_apop_post_sort_' . $cat_id;
//カスタムフィールドが存在しなければ追加する
$sort_filed = get_post_meta( $post_id, $sort_key, true );
if ( empty( $sort_filed ) ) {
diff --git a/class/class.apop.order.php b/class/class.apop.order.php
new file mode 100644
index 0000000..65686aa
--- /dev/null
+++ b/class/class.apop.order.php
@@ -0,0 +1,94 @@
+update_post_sort( 'category' );
+ $this->update_post_sort( 'post_tag' );
+ require_once self::TEMPLATE_DIR . 'success.php';
+ }
+
+ require_once self::TEMPLATE_DIR . 'order.php';
+ }
+
+ //投稿表示順の設定
+ private function update_post_sort( $target ) {
+ $target = '_apop_post_' . $target;
+ $posts_sort = $_POST[ $target ]['post_sort'];
+ foreach ( $posts_sort as $cat_id => $posts ) {
+ $sort_key = $target . '_' . $cat_id;
+ foreach ( $posts as $post_id => $sort ) {
+ update_post_meta( $post_id, $sort_key, $sort );
+ }
+ }
+ }
+
+
+ }
+}
+
diff --git a/class/class.apop.ui.php b/class/class.apop.ui.php
new file mode 100644
index 0000000..2949e84
--- /dev/null
+++ b/class/class.apop.ui.php
@@ -0,0 +1,73 @@
+ $key, 'get' => 'all' ) );
+ }
+ return get_taxonomies( array( 'public' => true, '_builtin' => false ) );
+ }
+
+ public static function get_tax_name( $tax_key ): string {
+ $tax_names = array(
+ 'category' => 'カテゴリー',
+ 'tag_id' => 'タグ',
+ 'custom_tax' => 'カスタム分類',
+ );
+
+ return $tax_names[ $tax_key ];
+ }
+
+ public static function get_cat_tag_list( $target, $key ): array {
+ $opt = get_option( '_apop_' . $target . '_order' );
+ $include = array();
+ if ( isset( $opt['target_cat'] ) ) {
+ foreach ( $opt['target_cat'] as $tax_id => $check ) {
+ if ( $check ) {
+ $include[] = $tax_id;
+ }
+ }
+ $include_tax = implode( ',', $include );
+ if ( ! empty( $include_tax ) ) {
+ $args = array(
+ 'taxonomy' => $key,
+ 'hide_empty' => 0,
+ 'include' => $include_tax,
+ );
+
+ return get_terms( $args );
+ }
+ }
+
+ return array();
+ }
+
+ public static function get_sort_post_list( $tax_id, $search_param, $tax_key ) {
+ $args = [
+ 'post_status' => array( 'publish', 'draft' ),
+ 'posts_per_page' => - 1,
+ $search_param => $tax_id,
+ 'orderby' => 'meta_value_num',
+ 'order' => 'ASC',
+ 'meta_key' => '_apop_post_' . $tax_key . '_' . $tax_id,
+ ];
+
+ return get_posts( $args );
+ }
+
+ public static function get_none_sort_post_list( $tax_id, $key, $exclude_posts ) {
+ $exclude = implode( ',', $exclude_posts );
+ $args = [
+ 'post_status' => array( 'publish', 'draft' ),
+ 'posts_per_page' => - 1,
+ $key => $tax_id,
+ ];
+ if ( ! empty( $exclude ) ) {
+ $args['exclude'] = $exclude;
+ }
+
+ return get_posts( $args );
+ }
+
+}
\ No newline at end of file
diff --git a/css/base.css b/css/apop-style.css
similarity index 97%
rename from css/base.css
rename to css/apop-style.css
index 21fe4c9..e6ce059 100644
--- a/css/base.css
+++ b/css/apop-style.css
@@ -40,6 +40,7 @@ h3 {
.list-orders-outer {
width: 100%;
+ margin-bottom: 1em;
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
diff --git a/js/post-sort-cat-order.js b/js/apop-style.js
similarity index 100%
rename from js/post-sort-cat-order.js
rename to js/apop-style.js
diff --git a/lib/post-sort-cat-order.php b/lib/post-sort-cat-order.php
deleted file mode 100644
index 5a35825..0000000
--- a/lib/post-sort-cat-order.php
+++ /dev/null
@@ -1,125 +0,0 @@
-update_post_sort();
- require_once self::TEMPLATE_DIR . 'success.php';
- }
-
- require_once self::TEMPLATE_DIR . 'sort.php';
- }
-
- //投稿表示順の設定
- private function update_post_sort() {
- $posts_sort = $_POST['nb_post_cat']['post_sort'];
- foreach ( $posts_sort as $cat_id => $posts ) {
- $sort_key = 'nb_post_sort_' . $cat_id;
- foreach ( $posts as $post_id => $sort ) {
- update_post_meta( $post_id, $sort_key, $sort );
- }
- }
- }
-
-
- /**
- * 対象カテゴリー
- *
- * @param $opt
- *
- * @return array
- */
- public static function get_category_list( $opt ): array {
- if ( isset( $opt['target_cat'] ) ) {
- $include_cat = implode( ',', $opt['target_cat'] );
- if ( ! empty( $include_cat ) ) {
- $category_args = array(
- 'hide_empty' => 0,
- 'include' => $include_cat,
- );
-
- return get_categories( $category_args );
- }
- }
-
- return array();
- }
-
-
-// public function add_cat_post_order( $new_status, $old_status, $post ) {
-// //リビジョンはパスする
-// if ( wp_is_post_revision( $post->ID ) ) {
-// return;
-// }
-//
-// }
-
- public static function get_sort_post_list( $cat_id ) {
- $product_args = [
- 'post_type' => 'post',
- 'post_status' => array( 'publish', 'draft' ),
- 'posts_per_page' => - 1,
- 'category' => $cat_id,
- 'orderby' => 'meta_value_num',
- 'order' => 'ASC',
- 'meta_key' => 'nb_post_sort_' . $cat_id,
- ];
-
- return get_posts( $product_args );
- }
-
- }
-}
-
diff --git a/nb-post-sort-cat-order.php b/nb-post-sort-cat-order.php
deleted file mode 100644
index b0dbb95..0000000
--- a/nb-post-sort-cat-order.php
+++ /dev/null
@@ -1,27 +0,0 @@
-
+
+
+
+== Installation ==
+
+= 自動インストール =
+1. プラグインの検索フィールドより「Archive Post Order Plus」や「投稿表示順」と入力し、"プラグインの検索"をクリックします。
+1. 当プラグインを見つけたら、"今すぐインストール"をクリックしてインストールし、プラグインを有効化してください。
+
+= 手動インストール =
+1. プラグインをダウンロードします。
+1. プラグインフォルダ内にアップロードし、管理画面よりプラグインを有効化してください。
+
+
+== Frequently Asked Questions ==
+
+== Screenshots ==
+
+1. /assets/screenshot-1.png
+2. /assets/screenshot-2.png
+3. /assets/screenshot-3.png
+4. /assets/screenshot-4.png
+5. /assets/screenshot-5.png
+6. /assets/screenshot-6.png
+
+== Changelog ==
+
+= 1.0.0 =
+Initial working version.
+
+== Upgrade Notice ==
+No information
diff --git a/template/order.php b/template/order.php
new file mode 100644
index 0000000..f1978ad
--- /dev/null
+++ b/template/order.php
@@ -0,0 +1,53 @@
+ APOP_UI::get_cat_tag_list( 'cat', 'category' ),
+ 'tag_id' => APOP_UI::get_cat_tag_list( 'tag', 'post_tag' ),
+);
+?>
+