ARCHIVE POST ORDER PLUS:カスタム投稿アーカイブの追加

カスタム投稿アーカイブ対応
全体設定で「全件」指定時に「全体設定に従う」の設定が反映されないバグの修正
This commit is contained in:
2021-07-19 19:47:26 +09:00
parent b8dcf1c44c
commit 4bc96228bd
16 changed files with 848 additions and 338 deletions
+84 -20
View File
@@ -7,10 +7,13 @@ if ( ! class_exists( 'APOP' ) ) {
require_once __DIR__ . '/../util/apop-order-setting.php';
require_once __DIR__ . '/../util/apop-customfield-select.php';
require_once __DIR__ . '/../util/apop-customposts.php';
require_once __DIR__ . '/../util/apop-tax.php';
require_once __DIR__ . '/../util/apop-output.php';
class APOP {
use APOP_ORDER_SETTING, CUSTOMFIELD_SELECT;
use APOP_ORDER_SETTING, CUSTOMFIELD_SELECT, CUSTOMPOSTS, TAX, APOP_OUTPUT;
const TEMPLATE_DIR = __DIR__ . '/../template/';
@@ -55,6 +58,7 @@ if ( ! class_exists( 'APOP' ) ) {
'_apop_per_page', //1ページ表示件数
'_apop_tag_order', //タグ設定
'_apop_tax_order', //カスタムタクソノミー設定
'_apop_custompost_archive_order', //カスタム投稿設定
);
foreach ( $settings as $setting ) {
@@ -72,9 +76,26 @@ if ( ! class_exists( 'APOP' ) ) {
public function show_option_page() {
//-------------------------------------
// 最新の投稿表示
// ------------------------------------
//最新の投稿表示
$this->set_new_lists();
// 検索表示
$this->set_search_lists();
// カスタム投稿アーカイブ
$this->set_custompost_archive_list();
// タクソノミー
$this->set_tax_list();
require_once self::TEMPLATE_DIR . 'order.php';
}
//---------------------------------------------------------------------------------
// 最新の投稿表示
//---------------------------------------------------------------------------------
private function set_new_lists() {
$apop_normal_order = APOP_UI::input_post_filter( '_apop_normal_order', 'str' );
$apop_normal_order_param = APOP_UI::input_post_filter( '_apop_normal_order_param', 'array' );
$apop_post_normal = APOP_UI::input_post_filter( '_apop_post_normal', 'array' );
@@ -98,10 +119,12 @@ if ( ! class_exists( 'APOP' ) ) {
$this->update_search_normal_sort( $apop_post_normal, 'normal' );
require_once self::TEMPLATE_DIR . 'success.php';
}
}
//-------------------------------------
// 検索表示
// ------------------------------------
//---------------------------------------------------------------------------------
// 検索結果
//---------------------------------------------------------------------------------
private function set_search_lists() {
$apop_search_order = APOP_UI::input_post_filter( '_apop_search_order', 'str' );
$apop_search_order_param = APOP_UI::input_post_filter( '_apop_search_order_param', 'array' );
$apop_post_search = APOP_UI::input_post_filter( '_apop_post_search', 'array' );
@@ -125,10 +148,60 @@ if ( ! class_exists( 'APOP' ) ) {
$this->update_search_normal_sort( $apop_post_search, 'search' );
require_once self::TEMPLATE_DIR . 'success.php';
}
}
//-------------------------------------
// タクソノミー
// ------------------------------------
//検索結果と最近の投稿の表示順の保存
private function update_search_normal_sort( $apop_post_search_normal, $key ) {
$posts_sort = $apop_post_search_normal['post_sort'];
foreach ( $posts_sort as $post_id => $sort ) {
update_post_meta( $post_id, '_apop_post_' . $key, $sort );
}
}
//---------------------------------------------------------------------------------
// カスタム投稿アーカイブ
//---------------------------------------------------------------------------------
private function set_custompost_archive_list() {
$custompost_archive_sort_type = APOP_UI::input_post_filter( '_apop_custompost_archive_sort_type', 'array' );
$apop_custompost_archive_order_param = APOP_UI::input_post_filter( '_apop_custompost_archive_order_param', 'array' );
$apop_custompost_archive = APOP_UI::input_post_filter( '_apop_customposts', 'array' );
//カスタム投稿アーカイブのソートタイプ設定
if ( $custompost_archive_sort_type ) {
check_admin_referer( 'sh_options' );
update_option( '_apop_custompost_archive_sort_type', $custompost_archive_sort_type );
require_once self::TEMPLATE_DIR . 'success.php';
}
//カスタム投稿アーカイブの標準ソートパラメータ
if ( $apop_custompost_archive_order_param ) {
check_admin_referer( 'sh_options' );
update_option( '_apop_custompost_archive_order_param', $apop_custompost_archive_order_param );
require_once self::TEMPLATE_DIR . 'success.php';
}
//カスタム投稿アーカイブの投稿表示順設定
if ( $apop_custompost_archive ) {
check_admin_referer( 'sh_options' );
$this->update_custom_post_sort( $apop_custompost_archive );
require_once self::TEMPLATE_DIR . 'success.php';
}
}
//カスタム投稿アーカイブ表示順の保存
private function update_custom_post_sort( $post_value ) {
foreach ( $post_value as $custom_post_type => $posts ) {
foreach ( $posts as $post_id => $sort ) {
$sort_key = '_apop_customposts_' . $custom_post_type;
update_post_meta( $post_id, $sort_key, $sort );
}
}
}
//---------------------------------------------------------------------------------
// タクソノミー
//---------------------------------------------------------------------------------
private function set_tax_list() {
$tax_sort_type = APOP_UI::input_post_filter( '_apop_tax_sort_type', 'array' );
$apop_tax_order_param = APOP_UI::input_post_filter( '_apop_tax_order_param', 'array' );
$apop_post_category = APOP_UI::input_post_filter( '_apop_post_category', 'array' );
@@ -169,11 +242,9 @@ if ( ! class_exists( 'APOP' ) ) {
$this->update_post_sort( 'tax', $apop_post_tax );
require_once self::TEMPLATE_DIR . 'success.php';
}
require_once self::TEMPLATE_DIR . 'order.php';
}
//投稿表示順の設定
//タクソノミーの表示順の保存
private function update_post_sort( $target, $post_value ) {
$posts_sort = $post_value['post_sort'];
foreach ( $posts_sort as $cat_id => $posts ) {
@@ -184,13 +255,6 @@ if ( ! class_exists( 'APOP' ) ) {
}
}
private function update_search_normal_sort( $apop_post_search_normal, $key ) {
$posts_sort = $apop_post_search_normal['post_sort'];
foreach ( $posts_sort as $post_id => $sort ) {
update_post_meta( $post_id, '_apop_post_' . $key, $sort );
}
}
}
}