Compare commits
46 Commits
0ff512307f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| d4e4c772aa | |||
| d8375c5abe | |||
| 49f7d3088c | |||
| 49d6527486 | |||
| 1791cd0ab7 | |||
| 7d3fb10582 | |||
| 6f064eaafa | |||
| 7b67bdf5f4 | |||
| 5fd91acb2e | |||
| f96800dc9e | |||
| bc37f8ac26 | |||
| 8b2c2e520f | |||
| fd93eb9a07 | |||
| f9351fc32f | |||
| 4bc96228bd | |||
| 6051380d2c | |||
| b8dcf1c44c | |||
| ae93196007 | |||
| 5598be1d0b | |||
| 8c3f79d7a9 | |||
| ada1e0eadf | |||
| 1414f330e8 | |||
| a6568404e9 | |||
| 8ec3d53bfe | |||
| 49087f4950 | |||
| 693752d71a | |||
| b69c5fbd88 | |||
| 188966cff5 | |||
| ff50cbdff8 | |||
| f6d64404a7 | |||
| c7996062fa | |||
| 2b21a55317 | |||
| b14b9739a7 | |||
| 99593ee863 | |||
| a76410908b | |||
| ff1dcdc5f4 | |||
| f9fe860c81 | |||
| 0d102684e3 | |||
| 28c02ebce2 | |||
| 00d6775f77 | |||
| e3c8fc967c | |||
| e15a46eec4 | |||
| 9cc82988e2 | |||
| 2c72904078 | |||
| 53ffbd213f | |||
| 5f651cab0f |
@@ -0,0 +1 @@
|
||||
/.idea/
|
||||
Generated
-31
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CakeStormCakeSettings">
|
||||
<option name="cakeVersionAbsorption">
|
||||
<map>
|
||||
<entry key="Controller" value="/controllers/" />
|
||||
<entry key="View" value="/views/" />
|
||||
<entry key="Model" value="/models/" />
|
||||
<entry key="Helper" value="/views/helpers/" />
|
||||
<entry key="Component" value="/controllers/components/" />
|
||||
<entry key="Behavior" value="/models/behaviors/" />
|
||||
<entry key="Plugin" value="plugins/" />
|
||||
<entry key="Shell" value="/vendors/shell" />
|
||||
<entry key="Task" value="/vendors/Shell/Task" />
|
||||
<entry key="ControllerTest" value="/tests/cases/controllers/" />
|
||||
<entry key="ModelTest" value="/tests/cases/models/" />
|
||||
<entry key="BehaviorTest" value="/tests/cases/behaviors/" />
|
||||
<entry key="ComponentTest" value="/tests/cases/components/" />
|
||||
<entry key="HelperTest" value="/tests/cases/helpers/" />
|
||||
<entry key="TestFile" value="test" />
|
||||
<entry key="FileSeparator" value="." />
|
||||
<entry key="FileWordSeparator" value="_" />
|
||||
<entry key="Fixture" value="/tests/fixtures/" />
|
||||
<entry key="Element" value="elements/" />
|
||||
<entry key="FixtureFile" value="fixture" />
|
||||
<entry key="Layout" value="layouts/" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="cakeVersion" value="1" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
-56
@@ -1,56 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<PHPCodeStyleSettings>
|
||||
<option name="ALIGN_KEY_VALUE_PAIRS" value="true" />
|
||||
<option name="ALIGN_ASSIGNMENTS" value="true" />
|
||||
<option name="PHPDOC_BLANK_LINES_AROUND_PARAMETERS" value="true" />
|
||||
<option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
|
||||
<option name="LOWER_CASE_NULL_CONST" value="true" />
|
||||
<option name="GETTERS_SETTERS_NAMING_STYLE" value="SNAKE_CASE" />
|
||||
<option name="VARIABLE_NAMING_STYLE" value="SNAKE_CASE" />
|
||||
<option name="BLANK_LINES_BEFORE_RETURN_STATEMENT" value="1" />
|
||||
<option name="KEEP_RPAREN_AND_LBRACE_ON_ONE_LINE" value="true" />
|
||||
<option name="SPACES_AROUND_VAR_WITHIN_BRACKETS" value="true" />
|
||||
<option name="SPACE_BEFORE_UNARY_NOT" value="true" />
|
||||
<option name="SPACE_AFTER_UNARY_NOT" value="true" />
|
||||
</PHPCodeStyleSettings>
|
||||
<codeStyleSettings language="PHP">
|
||||
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
|
||||
<option name="CLASS_BRACE_STYLE" value="1" />
|
||||
<option name="METHOD_BRACE_STYLE" value="1" />
|
||||
<option name="SPECIAL_ELSE_IF_TREATMENT" value="true" />
|
||||
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
||||
<option name="ALIGN_MULTILINE_FOR" value="false" />
|
||||
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
|
||||
<option name="SPACE_AROUND_UNARY_OPERATOR" value="true" />
|
||||
<option name="SPACE_WITHIN_PARENTHESES" value="true" />
|
||||
<option name="SPACE_WITHIN_METHOD_CALL_PARENTHESES" value="true" />
|
||||
<option name="SPACE_WITHIN_METHOD_PARENTHESES" value="true" />
|
||||
<option name="SPACE_WITHIN_IF_PARENTHESES" value="true" />
|
||||
<option name="SPACE_WITHIN_WHILE_PARENTHESES" value="true" />
|
||||
<option name="SPACE_WITHIN_FOR_PARENTHESES" value="true" />
|
||||
<option name="SPACE_WITHIN_CATCH_PARENTHESES" value="true" />
|
||||
<option name="SPACE_WITHIN_SWITCH_PARENTHESES" value="true" />
|
||||
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACES" value="true" />
|
||||
<option name="SPACE_AFTER_TYPE_CAST" value="true" />
|
||||
<option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
|
||||
<option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
|
||||
<option name="PARENTHESES_EXPRESSION_LPAREN_WRAP" value="true" />
|
||||
<option name="PARENTHESES_EXPRESSION_RPAREN_WRAP" value="true" />
|
||||
<option name="FOR_STATEMENT_LPAREN_ON_NEXT_LINE" value="true" />
|
||||
<option name="FOR_STATEMENT_RPAREN_ON_NEXT_LINE" value="true" />
|
||||
<option name="ARRAY_INITIALIZER_WRAP" value="5" />
|
||||
<option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
|
||||
<option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
|
||||
<option name="IF_BRACE_FORCE" value="3" />
|
||||
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||
<option name="FOR_BRACE_FORCE" value="3" />
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="SMART_TABS" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
Generated
-5
@@ -1,5 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
||||
Generated
-8
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/archive-post-oder-plus.iml" filepath="$PROJECT_DIR$/.idea/archive-post-oder-plus.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
-6
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="7">
|
||||
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
||||
</component>
|
||||
</project>
|
||||
+20
-17
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Archive Post Order Plus
|
||||
Plugin URI: https://www.n-k-y.net/wp_plugin_apop/
|
||||
Author: Nobuhiro Kimura
|
||||
Author URI: https://www.n-k-y.net
|
||||
Description: アーカイブのタクソノミー毎に投稿の表示順を設定するプラグイン
|
||||
Version: 1.0.0
|
||||
Plugin URI: https://develop.n-k-y.net/wordpress/wp_plugin/apop/
|
||||
Author: NBK45
|
||||
Author URI: https://develop.n-k-y.net
|
||||
Description: Archive Post Order Plus は「最新の投稿」「検索結果」「カテゴリー」「タグ」「カスタム分類」の投稿記事の表示順をドラッグで並べ替えて設定するプラグインです。
|
||||
Version: 1.2.1
|
||||
License: GPLv2
|
||||
Text Domain: ArchivePostOrderPlus
|
||||
Domain Path: /languages
|
||||
*/
|
||||
|
||||
/* Copyright 2021 Nobuhiro Kimura (email : big-me@n-k-y.net)
|
||||
@@ -22,30 +24,31 @@ License: GPLv2
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* 指定したキーが無ければ、投稿の管理画面表示時にメタボックスを追加する。
|
||||
* メタキーは下記のオプションテーブルから取得する
|
||||
* _apop_normal_order_param
|
||||
* _apop_search_order_param
|
||||
* _apop_tax_order_param
|
||||
* ラベルは「APO+カスタムフィールド:XXXX」とする
|
||||
*/
|
||||
|
||||
define( 'APOP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||
define( 'APOP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
|
||||
define( 'APOP_CUSTOM_FIELD_PREFIX', '_apop_postorder_' );
|
||||
define( 'APOP_DOMAIN', 'ArchivePostOrderPlus' );
|
||||
load_plugin_textdomain( APOP_DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages' );
|
||||
|
||||
//メイン処理のクラスをインスタンス化
|
||||
require_once __DIR__ . '/class/class.apop.order.php';
|
||||
require_once __DIR__ . '/class/class.apop.ui.php';
|
||||
require_once __DIR__ . '/class/class.apop.apop_ui.php';
|
||||
require_once __DIR__ . '/class/class.apop.apop_post.php';
|
||||
|
||||
$APOP = new APOP;
|
||||
new APOP_POST;
|
||||
|
||||
//CSS, JSの読み込み
|
||||
add_action( 'admin_enqueue_scripts', 'register_my_styles' );
|
||||
function register_my_styles() {
|
||||
add_action( 'admin_enqueue_scripts', 'apop_register_my_styles' );
|
||||
function apop_register_my_styles() {
|
||||
wp_enqueue_style( 'jq_ui_css', APOP_PLUGIN_URL . 'css/jquery-ui.css' );
|
||||
wp_enqueue_style( 'hrc_post_style', APOP_PLUGIN_URL . 'css/apop-style.css' );
|
||||
wp_enqueue_script( 'jquery-ui-sortable' );
|
||||
wp_enqueue_script( 'jquery-ui-autocomplete' );
|
||||
wp_enqueue_script( 'post-sort-cat-order_js', APOP_PLUGIN_URL . 'js/apop-style.js' );
|
||||
if ( wp_is_mobile() ) {
|
||||
wp_enqueue_script( 'jquery-touch-punch' );
|
||||
}
|
||||
}
|
||||
|
||||
$APOP->set_query();
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if ( ! class_exists( 'APOP_POST' ) ) {
|
||||
|
||||
class APOP_POST {
|
||||
|
||||
const TEMPLATE_DIR = __DIR__ . '/../template/';
|
||||
|
||||
private $order_field = array();
|
||||
private $custom_field_type = array();
|
||||
private $name_keys = array();
|
||||
private $order_param_keys = array(
|
||||
'custom_field',
|
||||
'custom_field_2',
|
||||
'custom_field_3',
|
||||
'custom_field_4',
|
||||
);
|
||||
private $labels;
|
||||
|
||||
public function __construct() {
|
||||
add_action( 'admin_menu', array( $this, 'add_meta_fields' ) );
|
||||
add_action( 'save_post', array( $this, 'save_meta_fields' ) );
|
||||
}
|
||||
|
||||
//メタボックスを追加
|
||||
public function add_meta_fields() {
|
||||
$target_posts = $this->set_post_types();
|
||||
foreach ( $target_posts as $target_post ) {
|
||||
add_meta_box( 'apo_custom_fields', __( 'APO + custom field settings', APOP_DOMAIN ), array(
|
||||
$this,
|
||||
'insert_meta_fields'
|
||||
), $target_post, 'normal' );
|
||||
}
|
||||
}
|
||||
|
||||
public function insert_meta_fields() {
|
||||
//最新の投稿ソート
|
||||
if ( get_option( '_apop_normal_order' ) == '1' ) {
|
||||
$this->create_order_field_data( get_option( '_apop_normal_order_param' ), 'normal' );
|
||||
}
|
||||
//検索ソート
|
||||
if ( get_option( '_apop_search_order' ) == '1' ) {
|
||||
$this->create_order_field_data( get_option( '_apop_search_order_param' ), 'search' );
|
||||
}
|
||||
|
||||
//カスタム投稿アーカイブソート
|
||||
$this->create_order_custompost_data( get_option( '_apop_custompost_archive_order_param' ) );
|
||||
|
||||
//カテゴリー、タグ、カスタム分類
|
||||
$this->create_order_tax_field_data( get_option( '_apop_tax_order_param' ) );
|
||||
|
||||
$this->labels = array(
|
||||
'normal' => __( 'Your latest posts', APOP_DOMAIN ),
|
||||
'search' => __( 'Search', APOP_DOMAIN ),
|
||||
'tax' => __( 'Category, Tag, Custom Taxonomy', APOP_DOMAIN ),
|
||||
'custompost' => __( 'Custom posts archive', APOP_DOMAIN ),
|
||||
);
|
||||
|
||||
require_once self::TEMPLATE_DIR . 'setting_post_custom_field.php';
|
||||
|
||||
}
|
||||
|
||||
private function set_post_types() {
|
||||
$custom_posts = array_values( get_post_types( array( 'public' => true, '_builtin' => false ) ) );
|
||||
|
||||
return array_merge( array( 'page', 'post', ), $custom_posts );
|
||||
}
|
||||
|
||||
private function create_order_field_data( $param, $key, $update = false ) {
|
||||
foreach ( $this->order_param_keys as $order_param_key ) {
|
||||
if ( isset( $param[ $order_param_key ]['field']['meta_key'] ) &&
|
||||
! empty( $param[ $order_param_key ]['field']['meta_key'] ) ) {
|
||||
if ( $update ) {
|
||||
$this->name_keys[] = $param[ $order_param_key ]['field']['meta_key'];
|
||||
} else {
|
||||
$this->custom_field_type[ $key ][] = $param[ $order_param_key ]['field']['custom_field_type'];
|
||||
$this->order_field[ $key ][] = $param[ $order_param_key ]['field']['meta_key'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function create_order_custompost_data( $param, $update = false ) {
|
||||
global $post_type;
|
||||
//カスタム投稿タイプでないときは処理を抜ける
|
||||
if ( $post_type == 'page' || $post_type == 'post' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$archive_settings = get_option( '_apop_custompost_archive_sort_type' );
|
||||
if ( $archive_settings && array_key_exists( $post_type, $archive_settings )
|
||||
&& $archive_settings[ $post_type ] == 2 ) {
|
||||
foreach ( $this->order_param_keys as $order_param_key ) {
|
||||
if ( isset( $param[ $post_type ][ $order_param_key ]['field']['meta_key'] ) &&
|
||||
! empty( $param[ $post_type ][ $order_param_key ]['field']['meta_key'] ) ) {
|
||||
if ( $update ) {
|
||||
$this->name_keys[] = $param[ $post_type ][ $order_param_key ]['field']['meta_key'];
|
||||
} else {
|
||||
$this->custom_field_type['custompost'][] = $param[ $post_type ][ $order_param_key ]['field']['custom_field_type'];
|
||||
$this->order_field['custompost'][] = $param[ $post_type ][ $order_param_key ]['field']['meta_key'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function create_order_tax_field_data( $param, $update = false ) {
|
||||
$term_ids = $this->create_post_term_ids();
|
||||
$sort_types = get_option( '_apop_tax_sort_type' );
|
||||
foreach ( $term_ids as $term_id ) {
|
||||
if ( ! isset( $sort_types[ $term_id ] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( $sort_types[ $term_id ] == '1' ) {
|
||||
break;
|
||||
}
|
||||
foreach ( $this->order_param_keys as $order_param_key ) {
|
||||
if ( isset( $param[ $term_id ][ $order_param_key ]['field']['meta_key'] ) &&
|
||||
! empty( $param[ $term_id ][ $order_param_key ]['field']['meta_key'] ) ) {
|
||||
if ( $update ) {
|
||||
$this->name_keys[] = $param[ $term_id ][ $order_param_key ]['field']['meta_key'];
|
||||
} else {
|
||||
$this->custom_field_type['tax'][] = $param[ $term_id ][ $order_param_key ]['field']['custom_field_type'];
|
||||
$this->order_field['tax'][] = $param[ $term_id ][ $order_param_key ]['field']['meta_key'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function create_post_term_ids() {
|
||||
global $post;
|
||||
$terms = array();
|
||||
$term_ids = array();
|
||||
$taxonomy_slugs = array_keys( get_the_taxonomies() );
|
||||
foreach ( $taxonomy_slugs as $taxonomy_slug ) {
|
||||
$terms[] = get_the_terms( $post->ID, $taxonomy_slug );
|
||||
|
||||
}
|
||||
foreach ( $terms as $term ) {
|
||||
foreach ( $term as $tax ) {
|
||||
$term_ids[] = $tax->term_id;
|
||||
}
|
||||
}
|
||||
|
||||
return $term_ids;
|
||||
}
|
||||
|
||||
private function get_custom_field_data( $custom_filed_name, $prefix ) {
|
||||
global $post;
|
||||
|
||||
return get_post_meta( $post->ID, $prefix . $custom_filed_name, true );
|
||||
}
|
||||
|
||||
// カスタムフィールドの値を保存
|
||||
public function save_meta_fields( $post_id ) {
|
||||
$this->get_update_meta_fields();
|
||||
if ( count( $this->name_keys ) > 0 ) {
|
||||
foreach ( $this->name_keys as $name_key ) {
|
||||
$save_key = APOP_CUSTOM_FIELD_PREFIX . $name_key;
|
||||
update_post_meta( $post_id, $save_key, APOP_UI::input_post_filter( $save_key, 'str' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function get_update_meta_fields() {
|
||||
//最新の投稿ソート
|
||||
$this->create_order_field_data( get_option( '_apop_normal_order_param' ), 'normal', true );
|
||||
//検索ソート
|
||||
$this->create_order_field_data( get_option( '_apop_search_order_param' ), 'search', true );
|
||||
//カスタム投稿アーカイブ
|
||||
$this->create_order_custompost_data( get_option( '_apop_custompost_archive_order_param' ), true );
|
||||
//カテゴリー、タグ、カスタム分類
|
||||
$this->create_order_tax_field_data( get_option( '_apop_tax_order_param' ), true );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,541 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if ( ! class_exists( 'APOP_UI' ) ) {
|
||||
|
||||
require_once __DIR__ . '/../util/apop-customfield-select.php';
|
||||
require_once __DIR__ . '/../util/apop-customposts.php';
|
||||
|
||||
class APOP_UI {
|
||||
|
||||
use CUSTOMFIELD_SELECT, CUSTOMPOSTS;
|
||||
|
||||
public static function get_order_type( $type ) {
|
||||
$type_data = get_option( $type );
|
||||
if ( ! $type_data ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return $type_data;
|
||||
}
|
||||
|
||||
public static function get_all_search_normal_posts( $key ) {
|
||||
$meta_key = '_apop_post_' . $key;
|
||||
$args = self::create_search_normal_args( $meta_key, $key );
|
||||
$posts_data = get_posts( $args );
|
||||
foreach ( $posts_data as $i => $post_data ) {
|
||||
$order = $i + 1;
|
||||
$no_order = self::is_sort_post_registered( $post_data->ID, $meta_key ) ? '' : ' no-order';
|
||||
echo '<li class="product-list' . esc_attr( $no_order ) . '">'
|
||||
. '<span class="sort-num-label">' . esc_html( $order ) . '</span>' . esc_html( $post_data->post_title )
|
||||
. '<input type="hidden" class="list-order"
|
||||
name="_apop_post_' . esc_attr( $key ) . '[post_sort][' . esc_attr( $post_data->ID ) . ']"
|
||||
value="' . esc_attr( $order ) . '">
|
||||
</li>';
|
||||
}
|
||||
}
|
||||
|
||||
private static function create_search_normal_args( $meta_key, $key = 'normal' ): array {
|
||||
$post_type = array( 'post' );
|
||||
if ( $key == 'search' ) {
|
||||
$add_post_type = array_values( get_post_types( array(
|
||||
'public' => true,
|
||||
'_builtin' => false,
|
||||
)
|
||||
)
|
||||
);
|
||||
$post_type = array_merge( $post_type, $add_post_type );
|
||||
}
|
||||
|
||||
return array(
|
||||
'post_type' => $post_type,
|
||||
'post_status' => array( 'publish', 'draft' ),
|
||||
'posts_per_page' => - 1,
|
||||
'orderby' => 'meta_value_num',
|
||||
'order' => 'ASC',
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => $meta_key,
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => $meta_key,
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
private static function get_all_custom_posts(): array {
|
||||
$custom_posts = array_values( get_post_types( array( 'public' => true, '_builtin' => false ) ) );
|
||||
$custom_post_data = array();
|
||||
foreach ( $custom_posts as $custom_post ) {
|
||||
$label = get_post_type_object( $custom_post )->label;
|
||||
$custom_post_data[ $custom_post ] = $label;
|
||||
}
|
||||
|
||||
return $custom_post_data;
|
||||
}
|
||||
|
||||
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 = array();
|
||||
foreach ( $all_custom_tax as $custom_tax ) {
|
||||
$custom_tax_list = array_merge( $custom_tax_list, get_terms( array(
|
||||
'taxonomy' => $custom_tax,
|
||||
'get' => 'all'
|
||||
) ) );
|
||||
}
|
||||
|
||||
return $custom_tax_list;
|
||||
}
|
||||
|
||||
public static function get_cat_tag_list( $target, $key ): array {
|
||||
$opt = get_option( '_apop_' . $target . '_order' );
|
||||
|
||||
if ( ! isset( $opt['target_cat'] ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if ( $key == 'taxonomy' ) {
|
||||
return self::create_custom_tax_term( $opt );
|
||||
} else {
|
||||
return self::create_tax_term( $opt, $key );
|
||||
}
|
||||
}
|
||||
|
||||
private static function create_custom_tax_term( $opt ): array {
|
||||
$tax_data = array();
|
||||
foreach ( $opt['target_cat'] as $tax_id => $status ) {
|
||||
//フラグが立っているカスタムタクソノミーは情報を取得する
|
||||
if ( $status ) {
|
||||
$args = array(
|
||||
'taxonomy' => get_term( $tax_id )->taxonomy,
|
||||
'hide_empty' => 0,
|
||||
'include' => $tax_id,
|
||||
);
|
||||
$tax_data = array_merge( $tax_data, get_terms( $args ) );
|
||||
|
||||
}
|
||||
}
|
||||
if ( count( $tax_data ) > 0 ) {
|
||||
return $tax_data;
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
private static function create_tax_term( $opt, $key ) {
|
||||
$include = array();
|
||||
foreach ( $opt['target_cat'] as $tax_id => $status ) {
|
||||
//フラグが立っているタクソノミーIDを取得
|
||||
if ( $status ) {
|
||||
$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 create_order_list( $tax_data, $tax_key ): string {
|
||||
$return_data = self::get_sort_post_list( $tax_data->term_id, $tax_key, $tax_data->taxonomy );
|
||||
$list = array();
|
||||
foreach ( $return_data['data'] as $key => $target_post ) {
|
||||
$sort_num = $key + 1;
|
||||
$no_order = self::is_sort_post_registered( $target_post->ID, $return_data['meta_key'] ) ? '' : ' no-order';
|
||||
$list[] = '
|
||||
<li class="product-list' . esc_html( $no_order ) . '">' . '<span class="sort-num-label">' . esc_html( $sort_num ) . '</span>' . get_the_title( $target_post->ID ) . '
|
||||
<input type="hidden" class="list-order"
|
||||
name="_apop_post_' . esc_html( self::create_post_sort_key( $tax_data->taxonomy, $tax_key ) ) . '[post_sort][' . esc_html( $tax_data->term_id ) . '][' . esc_html( $target_post->ID ) . ']"
|
||||
value="' . esc_html( $sort_num ) . '">
|
||||
</li>';
|
||||
}
|
||||
|
||||
return implode( PHP_EOL, $list );
|
||||
}
|
||||
|
||||
private static function is_sort_post_registered( $id, $key ): bool {
|
||||
if ( get_post_meta( $id, $key, true ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function get_sort_post_list( $tax_id, $search_param, $tax_name ): array {
|
||||
$post_types = array( 'post' );
|
||||
$custom_post_types = array_values( get_post_types( array( 'public' => true, '_builtin' => false ) ) );
|
||||
$args = array(
|
||||
'post_type' => array_merge( $post_types, $custom_post_types ),
|
||||
'post_status' => array( 'publish', 'draft' ),
|
||||
'posts_per_page' => - 1,
|
||||
'orderby' => 'meta_value_num',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
$meta_key = '_apop_post_' . self::create_post_sort_key( $tax_name, $search_param ) . '_' . $tax_id;
|
||||
self::create_sort_post_list_meta_query( $args, $meta_key );
|
||||
self::create_post_tax_query( $args, $search_param, $tax_name, $tax_id );
|
||||
|
||||
return array(
|
||||
'meta_key' => $meta_key,
|
||||
'data' => get_posts( $args )
|
||||
);
|
||||
}
|
||||
|
||||
private static function create_sort_post_list_meta_query( &$args, $meta_key ) {
|
||||
|
||||
$args['meta_query'] = array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => $meta_key,
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => $meta_key,
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public static function create_post_sort_key( $tax_name, $tax_key ) {
|
||||
if ( $tax_key == 'taxonomy' ) {
|
||||
return 'tax';
|
||||
}
|
||||
|
||||
return $tax_name;
|
||||
}
|
||||
|
||||
private static function create_post_tax_query( &$args, $key, $tax_name, $tax_id ) {
|
||||
if ( $key == 'taxonomy' ) {
|
||||
$args['tax_query'] = array(
|
||||
array(
|
||||
'taxonomy' => $tax_name,
|
||||
'field' => 'term_id',
|
||||
'terms' => $tax_id,
|
||||
'include_children' => false
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$args[ $key ] = $tax_id;
|
||||
}
|
||||
}
|
||||
|
||||
public static function create_cat_per_page( $opt_per_page, $type ): array {
|
||||
$cat_per_page = $opt_per_page[ $type ] ?? 'default';
|
||||
$checked = '';
|
||||
$cat_per_page_num = '';
|
||||
if ( isset( $opt_per_page[ $type ] ) ) {
|
||||
if ( $opt_per_page[ $type ] != 'default'
|
||||
&& $opt_per_page[ $type ] != '-1'
|
||||
&& $opt_per_page[ $type ] != 'all' ) {
|
||||
$checked = ' checked="checked"';
|
||||
$cat_per_page_num = $cat_per_page;
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'_per_page' => $cat_per_page,
|
||||
'_checked' => $checked,
|
||||
'_per_page_num' => $cat_per_page_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_tax = $key == 'post_tag' ? 'tag' : $key;
|
||||
echo '<tr><th scope="row">' . esc_html( $title ) . '</th><td>';
|
||||
if ( isset( $tax_data, $order_name, $order_tax ) ) {
|
||||
include APOP_PLUGIN_PATH . 'template/setting_parts_taxonomy.php';
|
||||
}
|
||||
echo '</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
public static function disp_customposts_setting( $key, $title, $order_name ) {
|
||||
$custom_post_data = APOP_UI::get_all_custom_posts();
|
||||
if ( count( $custom_post_data ) > 0 ) {
|
||||
echo '<tr><th scope="row">' . esc_html( $title ) . '</th><td>';
|
||||
if ( isset( $custom_post_data, $order_name, $key ) ) {
|
||||
include APOP_PLUGIN_PATH . 'template/setting_parts_customposts.php';
|
||||
}
|
||||
echo '</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
public static function create_custom_posts_per_page( $opt_per_page, $type, $slug ): array {
|
||||
$cat_per_page = $opt_per_page[ $type ][ $slug ] ?? 'default';
|
||||
$checked = '';
|
||||
$cat_per_page_num = '';
|
||||
if ( isset( $opt_per_page[ $type ][ $slug ] ) ) {
|
||||
if ( $opt_per_page[ $type ][ $slug ] != 'default'
|
||||
&& $opt_per_page[ $type ][ $slug ] != '-1'
|
||||
&& $opt_per_page[ $type ][ $slug ] != 'all' ) {
|
||||
$checked = ' checked="checked"';
|
||||
$cat_per_page_num = $cat_per_page;
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'_per_page' => $cat_per_page,
|
||||
'_checked' => $checked,
|
||||
'_per_page_num' => $cat_per_page_num,
|
||||
);
|
||||
}
|
||||
|
||||
public static function create_tax_per_page( $opt_per_page, $type, $id ): array {
|
||||
$cat_per_page = $opt_per_page[ $type ][ $id ] ?? 'default';
|
||||
$checked = '';
|
||||
$cat_per_page_num = '';
|
||||
if ( isset( $opt_per_page[ $type ][ $id ] ) ) {
|
||||
if ( $opt_per_page[ $type ][ $id ] != 'default'
|
||||
&& $opt_per_page[ $type ][ $id ] != '-1'
|
||||
&& $opt_per_page[ $type ][ $id ] != 'all' ) {
|
||||
$checked = ' checked="checked"';
|
||||
$cat_per_page_num = $cat_per_page;
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'_per_page' => $cat_per_page,
|
||||
'_checked' => $checked,
|
||||
'_per_page_num' => $cat_per_page_num,
|
||||
);
|
||||
}
|
||||
|
||||
public static function create_search_normal_list( $type, $id = null ) {
|
||||
$name_keys = self::create_name_keys( $id, $type );
|
||||
$name_key = $name_keys['name_key'];
|
||||
$get_option_key = $name_keys['get_option_key'];
|
||||
$order_param_base = get_option( $get_option_key );
|
||||
$order_param = '';
|
||||
if ( is_null( $id ) ) {
|
||||
$order_param = $order_param_base;
|
||||
}
|
||||
if ( isset( $order_param_base[ $id ] ) ) {
|
||||
$order_param = $order_param_base[ $id ];
|
||||
}
|
||||
self::create_normal_sort_list( $name_key, $order_param );
|
||||
}
|
||||
|
||||
private static function create_custom_field_sort_type( $name_key, $target_key, $cnv_order_params ) {
|
||||
$meta_key = $cnv_order_params[ $target_key ]['meta_key'];
|
||||
$value_type = $cnv_order_params[ $target_key ]['value_type'];
|
||||
$custom_field_type = $cnv_order_params[ $target_key ]['custom_field_type'];
|
||||
$name_meta_key = '_' . $name_key . '[' . $target_key . '][field][meta_key]';
|
||||
$name_value_type = '_' . $name_key . '[' . $target_key . '][field][value_type]';
|
||||
$name_custom_field_type = '_' . $name_key . '[' . $target_key . '][field][custom_field_type]';
|
||||
$custom_field_val_1 = $custom_field_type == '1' ? $meta_key : '';
|
||||
$custom_field_val_2 = $custom_field_type == '2' ? $meta_key : '';
|
||||
echo '<div class="sort-custom-field">
|
||||
<div class="sort-custom-field-types">
|
||||
<div class="sort-custom-field-inner-label">
|
||||
<label>
|
||||
<input type="radio"
|
||||
class="custom-field-type"
|
||||
name="' . esc_attr( $name_custom_field_type ) . '"
|
||||
value="1"' . esc_attr( self::set_search_normal_checked( $custom_field_type, '1' ) ) . '>' . __( 'Select', APOP_DOMAIN ) . '</label>
|
||||
<label>
|
||||
<input type="radio"
|
||||
class="custom-field-type"
|
||||
name="' . esc_attr( $name_custom_field_type ) . '"
|
||||
value="2"' . esc_attr( self::set_search_normal_checked( $custom_field_type, '2' ) ) . '>' . __( 'Add', APOP_DOMAIN ) . '</label>
|
||||
</div>';
|
||||
echo '<input type="text" class="select-custom-field-input custom_field_key_select" name="' . esc_attr( $name_meta_key ) . '" value="' . esc_attr( $custom_field_val_1 ) . '" required>
|
||||
<input type="text" class="custom_field_key" name="' . esc_attr( $name_meta_key ) . '" value="' . esc_attr( $custom_field_val_2 ) . '" required>
|
||||
</div>
|
||||
<div class="custom-field-select-alert"></div>
|
||||
<div class="sort-custom-field-inner">
|
||||
<div class="sort-custom-field-inner-label">' . __( 'Type', APOP_DOMAIN ) . ':</div>
|
||||
<label class="sort-custom-field-text-label">
|
||||
<input type="radio"
|
||||
class="custom-field-meta-value"
|
||||
name="' . esc_attr( $name_value_type ) . '"
|
||||
value="meta_value"' . esc_attr( self::set_search_normal_checked( $value_type, 'meta_value' ) ) . '>' . __( 'Text', APOP_DOMAIN ) . '</label>
|
||||
<label><input type="radio"
|
||||
class="custom-field-meta-value"
|
||||
name="' . esc_attr( $name_value_type ) . '"
|
||||
value="meta_value_num"' . esc_attr( self::set_search_normal_checked( $value_type, 'meta_value_num' ) ) . '>' . __( 'Number', APOP_DOMAIN ) . '</label>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
private static function set_order_list_param( $order_param, $target_key ): array {
|
||||
|
||||
$param = array(
|
||||
'use' => 0,
|
||||
'sort' => 2,
|
||||
'no_order_class' => ' no-order',
|
||||
);
|
||||
|
||||
if ( strpos( $target_key, 'custom_field' ) !== false ) {
|
||||
$param[ $target_key ] = array(
|
||||
'meta_key' => '',
|
||||
'value_type' => 'meta_value',
|
||||
'custom_field_type' => '1',
|
||||
);
|
||||
}
|
||||
|
||||
if ( isset( $order_param[ $target_key ] ) ) {
|
||||
$param = array(
|
||||
'use' => $order_param[ $target_key ]['use'] ?? 0,
|
||||
'sort' => $order_param[ $target_key ]['sort'] ?? 2,
|
||||
'no_order_class' => ! $order_param[ $target_key ]['use'] ? ' no-order' : '',
|
||||
);
|
||||
if ( strpos( $target_key, 'custom_field' ) !== false ) {
|
||||
$param[ $target_key ] = array(
|
||||
'meta_key' => $order_param[ $target_key ]['field']['meta_key'] ?? '',
|
||||
'value_type' => $order_param[ $target_key ]['field']['value_type'] ?? 'meta_value',
|
||||
'custom_field_type' => $order_param[ $target_key ]['field']['custom_field_type'] ?? '1',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $param;
|
||||
|
||||
}
|
||||
|
||||
private static function create_name_keys( $id, $type ): array {
|
||||
if ( is_null( $id ) ) {
|
||||
return array(
|
||||
'name_key' => 'apop_' . $type . '_order_param',
|
||||
'get_option_key' => '_' . 'apop_' . $type . '_order_param',
|
||||
);
|
||||
} else {
|
||||
return array(
|
||||
'name_key' => 'apop_tax_order_param[' . $id . ']',
|
||||
'get_option_key' => '_apop_tax_order_param',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private static function set_search_normal_target_keys( $post_apop_search_order_param ): array {
|
||||
|
||||
$set_keys = array(
|
||||
'date',
|
||||
'title',
|
||||
'ID',
|
||||
'modified',
|
||||
'custom_field',
|
||||
'custom_field_2',
|
||||
'custom_field_3',
|
||||
'custom_field_4',
|
||||
);
|
||||
|
||||
if ( $post_apop_search_order_param ) {
|
||||
$register_keys = array_keys( $post_apop_search_order_param );
|
||||
|
||||
return array_unique( array_merge( $register_keys, $set_keys ) );
|
||||
}
|
||||
|
||||
return $set_keys;
|
||||
}
|
||||
|
||||
private static function set_search_normal_checked( $param, $default ): string {
|
||||
if ( $param == $default ) {
|
||||
return ' checked="checked"';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* POSTデータのフィルタリングを行います。
|
||||
*
|
||||
* @param string $var_name 取得するPOST変数名。
|
||||
* @param string $type 'array' または 'str' を指定します。
|
||||
*
|
||||
* @return array|string フィルタリングされたPOSTデータ、または失敗した場合は空文字列。
|
||||
*/
|
||||
public static function input_post_filter( $var_name, $type ) {
|
||||
if ( $type == 'array' ) {
|
||||
$data = filter_input( INPUT_POST, $var_name, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
|
||||
if ( is_array( $data ) ) {
|
||||
array_walk_recursive( $data, function ( &$value ) {
|
||||
$value = htmlspecialchars( $value, ENT_QUOTES, 'UTF-8' );
|
||||
} );
|
||||
return $data;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
if ( $type == 'str' ) {
|
||||
$data = filter_input( INPUT_POST, $var_name );
|
||||
if ( $data !== null && $data !== false ) {
|
||||
return htmlspecialchars( $data, ENT_QUOTES, 'UTF-8' );
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function create_normal_sort_list( $name_key, $order_param ) {
|
||||
$target_keys = self::set_search_normal_target_keys( $order_param );
|
||||
$target_values = array(
|
||||
'date' => __( 'Published', APOP_DOMAIN ),
|
||||
'title' => __( 'Post Title', APOP_DOMAIN ),
|
||||
'ID' => 'ID',
|
||||
'modified' => __( 'Modified', APOP_DOMAIN ),
|
||||
'custom_field' => __( 'Custom filed 1', APOP_DOMAIN ),
|
||||
'custom_field_2' => __( 'Custom filed 2', APOP_DOMAIN ),
|
||||
'custom_field_3' => __( 'Custom filed 3', APOP_DOMAIN ),
|
||||
'custom_field_4' => __( 'Custom filed 4', APOP_DOMAIN ),
|
||||
);
|
||||
foreach ( $target_keys as $target_key ) {
|
||||
$cnv_order_params = self::set_order_list_param( $order_param, $target_key );
|
||||
$use = $cnv_order_params['use'];
|
||||
$sort = $cnv_order_params['sort'];
|
||||
$no_order_class = $cnv_order_params['no_order_class'];
|
||||
$name_use_key = '_' . $name_key . '[' . $target_key . '][use]';
|
||||
$name_sort_key = '_' . $name_key . '[' . $target_key . '][sort]';
|
||||
if ( strpos( $target_key, 'custom_field' ) !== false ) {
|
||||
$target_key_check_class = 'custom_field_check';
|
||||
} else {
|
||||
$target_key_check_class = 'sort_' . $target_key . '_check';
|
||||
}
|
||||
|
||||
echo '<li class="product-list' . esc_attr( $no_order_class ) . '">
|
||||
<div class="product-list-type-label"><b>' . esc_attr( $target_values[ $target_key ] ) . '</b></div>
|
||||
<div class="product-list-sort-type">
|
||||
<label>
|
||||
<input type="hidden" name="' . esc_attr( $name_use_key ) . '"
|
||||
value="0"' . esc_attr( self::set_search_normal_checked( $use, 0 ) ) . '>
|
||||
<span class="en_dis_label">' . __( 'Enabled', APOP_DOMAIN ) . '</span>:<input class="' . esc_html( $target_key_check_class ) . '"
|
||||
type="checkbox" name="' . esc_attr( $name_use_key ) . '" value="1"' . esc_attr( self::set_search_normal_checked( $use, 1 ) ) . '>
|
||||
</label>
|
||||
<label>
|
||||
<input class="order_param" type="radio"
|
||||
name="' . esc_attr( $name_sort_key ) . '"
|
||||
value="1"' . esc_attr( self::set_search_normal_checked( $sort, 1 ) ) . '>' . __( 'Asc', APOP_DOMAIN ) . '</label>
|
||||
<label>
|
||||
<input class="order_param" type="radio"
|
||||
name="' . esc_attr( $name_sort_key ) . '"
|
||||
value="2"' . esc_attr( self::set_search_normal_checked( $sort, 2 ) ) . '>' . __( 'Desc', APOP_DOMAIN ) . '</label>';
|
||||
|
||||
if ( strpos( $target_key, 'custom_field' ) !== false ) {
|
||||
self::create_custom_field_sort_type( $name_key, $target_key, $cnv_order_params );
|
||||
}
|
||||
|
||||
echo '</div>
|
||||
</li>';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+91
-22
@@ -4,16 +4,23 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
} // Exit if accessed directly
|
||||
|
||||
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;
|
||||
use APOP_ORDER_SETTING, CUSTOMFIELD_SELECT, CUSTOMPOSTS, TAX, APOP_OUTPUT;
|
||||
|
||||
const TEMPLATE_DIR = __DIR__ . '/../template/';
|
||||
|
||||
public function __construct() {
|
||||
add_action( 'admin_menu', array( $this, 'add_pages' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'set_custom_field_ajax' ) );
|
||||
add_action( 'wp_ajax_set_custom_field', array( $this, 'set_custom_field' ) );
|
||||
}
|
||||
|
||||
public function add_pages() {
|
||||
@@ -25,10 +32,11 @@ if ( ! class_exists( 'APOP' ) ) {
|
||||
array( $this, 'display_setting_page' ),
|
||||
''
|
||||
);
|
||||
//
|
||||
add_submenu_page(
|
||||
'apop_post_sort', // parent_slug
|
||||
'Sort taxonomy', // page_title
|
||||
'表示件数・対象設定', // menu_title
|
||||
__( 'Display number / target setting', APOP_DOMAIN ), // menu_title
|
||||
'administrator', // capability
|
||||
'apop_post_sort', // menu_slug
|
||||
array( $this, 'display_setting_page' ) // function
|
||||
@@ -36,7 +44,7 @@ if ( ! class_exists( 'APOP' ) ) {
|
||||
add_submenu_page(
|
||||
'apop_post_sort', // parent_slug
|
||||
'Select taxonomy', // page_title
|
||||
'並べ替え', // menu_title
|
||||
__( 'Sorting', APOP_DOMAIN ), // menu_title
|
||||
'administrator', // capability
|
||||
'apop_post_sort_setting', // menu_slug
|
||||
array( $this, 'show_option_page' ) // function
|
||||
@@ -50,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 ) {
|
||||
@@ -67,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' );
|
||||
@@ -93,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' );
|
||||
@@ -120,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' );
|
||||
@@ -164,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 ) {
|
||||
@@ -179,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 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,458 +0,0 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if ( ! class_exists( 'APOP_UI' ) ) {
|
||||
class APOP_UI {
|
||||
|
||||
public static function get_order_type( $type ) {
|
||||
$type_data = get_option( $type );
|
||||
if ( ! $type_data ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return $type_data;
|
||||
}
|
||||
|
||||
public static function get_all_search_normal_posts(
|
||||
$key
|
||||
): string {
|
||||
$meta_key = '_apop_post_' . $key;
|
||||
$args = self::create_search_normal_args( $meta_key );
|
||||
$posts_data = get_posts( $args );
|
||||
$list = array();
|
||||
foreach ( $posts_data as $i => $post_data ) {
|
||||
$order = $i + 1;
|
||||
$no_order = self::is_sort_post_registered( $post_data->ID, $meta_key ) ? '' : ' no_order';
|
||||
$list[] = '<li class="product-list' . $no_order . '">' . self::crate_non_registerd_mark( $no_order ) . '
|
||||
<span class="sort-num-label">' . $order . '</span>' . $post_data->post_title . '
|
||||
<input type="hidden" class="list_order" name="_apop_post_' . $key . '[post_sort][' . $post_data->ID . ']" value="' . $order . '">
|
||||
</li>';
|
||||
}
|
||||
|
||||
return implode( PHP_EOL, $list );
|
||||
}
|
||||
|
||||
private static function crate_non_registerd_mark( $no_order ): string {
|
||||
if ( ! empty( $no_order ) ) {
|
||||
return '■';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
private static function create_search_normal_args( $meta_key ): array {
|
||||
return array(
|
||||
'post_status' => array( 'publish', 'draft' ),
|
||||
'posts_per_page' => - 1,
|
||||
'orderby' => 'meta_value_num',
|
||||
'order' => 'ASC',
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => $meta_key,
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => $meta_key,
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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 = array();
|
||||
foreach ( $all_custom_tax as $custom_tax ) {
|
||||
$custom_tax_list = array_merge( $custom_tax_list, get_terms( array(
|
||||
'taxonomy' => $custom_tax,
|
||||
'get' => 'all'
|
||||
) ) );
|
||||
}
|
||||
|
||||
return $custom_tax_list;
|
||||
}
|
||||
|
||||
public static function get_cat_tag_list( $target, $key ): array {
|
||||
$opt = get_option( '_apop_' . $target . '_order' );
|
||||
|
||||
if ( ! isset( $opt['target_cat'] ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if ( $key == 'taxonomy' ) {
|
||||
return self::create_custom_tax_term( $opt );
|
||||
} else {
|
||||
return self::create_tax_term( $opt, $key );
|
||||
}
|
||||
}
|
||||
|
||||
private static function create_custom_tax_term( $opt ): array {
|
||||
$tax_data = array();
|
||||
foreach ( $opt['target_cat'] as $tax_id => $status ) {
|
||||
//フラグが立っているカスタムタクソノミーは情報を取得する
|
||||
if ( $status ) {
|
||||
$args = array(
|
||||
'taxonomy' => get_term( $tax_id )->taxonomy,
|
||||
'hide_empty' => 0,
|
||||
'include' => $tax_id,
|
||||
);
|
||||
$tax_data = array_merge( $tax_data, get_terms( $args ) );
|
||||
|
||||
}
|
||||
}
|
||||
if ( count( $tax_data ) > 0 ) {
|
||||
return $tax_data;
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
private static function create_tax_term( $opt, $key ) {
|
||||
$include = array();
|
||||
foreach ( $opt['target_cat'] as $tax_id => $status ) {
|
||||
//フラグが立っているタクソノミーIDを取得
|
||||
if ( $status ) {
|
||||
$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 create_order_list( $tax_data, $tax_key ): string {
|
||||
$return_data = self::get_sort_post_list( $tax_data->term_id, $tax_key, $tax_data->taxonomy );
|
||||
$list = array();
|
||||
foreach ( $return_data['data'] as $key => $target_post ) {
|
||||
$sort_num = $key + 1;
|
||||
$no_order = self::is_sort_post_registered( $target_post->ID, $return_data['meta_key'] ) ? '' : ' no_order';
|
||||
$list[] = '
|
||||
<li class="product-list' . $no_order . '">' . self::crate_non_registerd_mark( $no_order ) . '<span class="sort-num-label">' . $sort_num . '</span>' . get_the_title( $target_post->ID ) . '
|
||||
<input type="hidden" class="list_order"
|
||||
name="_apop_post_' . self::create_post_sort_key( $tax_data->taxonomy, $tax_key ) . '[post_sort][' . $tax_data->term_id . '][' . $target_post->ID . ']"
|
||||
value="' . $sort_num . '">
|
||||
</li>';
|
||||
}
|
||||
|
||||
return implode( PHP_EOL, $list );
|
||||
}
|
||||
|
||||
private static function is_sort_post_registered( $id, $key ): bool {
|
||||
if ( get_post_meta( $id, $key, true ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function get_sort_post_list( $tax_id, $search_param, $tax_name ): array {
|
||||
$post_types = array( 'post' );
|
||||
$custom_post_types = array_values( get_post_types( array( 'public' => true, '_builtin' => false ) ) );
|
||||
$args = array(
|
||||
'post_type' => array_merge( $post_types, $custom_post_types ),
|
||||
'post_status' => array( 'publish', 'draft' ),
|
||||
'posts_per_page' => - 1,
|
||||
'orderby' => 'meta_value_num',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
$meta_key = '_apop_post_' . self::create_post_sort_key( $tax_name, $search_param ) . '_' . $tax_id;
|
||||
self::create_sort_post_list_meta_query( $args, $meta_key );
|
||||
self::create_post_tax_query( $args, $search_param, $tax_name, $tax_id );
|
||||
|
||||
return array(
|
||||
'meta_key' => $meta_key,
|
||||
'data' => get_posts( $args )
|
||||
);
|
||||
}
|
||||
|
||||
private static function create_sort_post_list_meta_query( &$args, $meta_key ) {
|
||||
|
||||
$args['meta_query'] = array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => $meta_key,
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => $meta_key,
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public static function create_post_sort_key( $tax_name, $tax_key ) {
|
||||
if ( $tax_key == 'taxonomy' ) {
|
||||
return 'tax';
|
||||
}
|
||||
|
||||
return $tax_name;
|
||||
}
|
||||
|
||||
private static function create_post_tax_query( &$args, $key, $tax_name, $tax_id ) {
|
||||
if ( $key == 'taxonomy' ) {
|
||||
$args['tax_query'] = array(
|
||||
array(
|
||||
'taxonomy' => $tax_name,
|
||||
'field' => 'term_id',
|
||||
'terms' => $tax_id,
|
||||
'include_children' => false
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$args[ $key ] = $tax_id;
|
||||
}
|
||||
}
|
||||
|
||||
public static function create_cat_per_page( $opt_per_page, $type ): array {
|
||||
$cat_per_page = $opt_per_page[ $type ] ?? 'default';
|
||||
$checked = '';
|
||||
$cat_per_page_num = '';
|
||||
if ( isset( $opt_per_page[ $type ] ) ) {
|
||||
if ( $opt_per_page[ $type ] != 'default'
|
||||
&& $opt_per_page[ $type ] != '-1'
|
||||
&& $opt_per_page[ $type ] != 'all' ) {
|
||||
$checked = ' checked="checked"';
|
||||
$cat_per_page_num = $cat_per_page;
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'_per_page' => $cat_per_page,
|
||||
'_checked' => $checked,
|
||||
'_per_page_num' => $cat_per_page_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 '<tr><th scope="row">' . $title . '設定</th><td>';
|
||||
include APOP_PLUGIN_PATH . 'template/setting_parts_taxonomy.php';
|
||||
echo '</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
public static function create_tax_per_page( $opt_per_page, $type, $id ): array {
|
||||
$cat_per_page = $opt_per_page[ $type ][ $id ] ?? 'default';
|
||||
$checked = '';
|
||||
$cat_per_page_num = '';
|
||||
if ( isset( $opt_per_page[ $type ][ $id ] ) ) {
|
||||
if ( $opt_per_page[ $type ][ $id ] != 'default'
|
||||
&& $opt_per_page[ $type ][ $id ] != '-1'
|
||||
&& $opt_per_page[ $type ][ $id ] != 'all' ) {
|
||||
$checked = ' checked="checked"';
|
||||
$cat_per_page_num = $cat_per_page;
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'_per_page' => $cat_per_page,
|
||||
'_checked' => $checked,
|
||||
'_per_page_num' => $cat_per_page_num,
|
||||
);
|
||||
}
|
||||
|
||||
public static function create_search_normal_list( $type, $id = null ): array {
|
||||
$name_keys = self::create_name_keys( $id, $type );
|
||||
$name_key = $name_keys['name_key'];
|
||||
$get_option_key = $name_keys['get_option_key'];
|
||||
$order_param_base = get_option( $get_option_key );
|
||||
$order_param = '';
|
||||
if ( is_null( $id ) ) {
|
||||
$order_param = $order_param_base;
|
||||
}
|
||||
if ( isset( $order_param_base[ $id ] ) ) {
|
||||
$order_param = $order_param_base[ $id ];
|
||||
}
|
||||
$target_keys = self::set_search_normal_target_keys( $order_param );
|
||||
$target_values = array(
|
||||
'date' => '登録日',
|
||||
'title' => 'タイトル',
|
||||
'ID' => 'ID',
|
||||
'modified' => '更新日',
|
||||
'custom_field' => 'カスタムフィールド1',
|
||||
'custom_field_2' => 'カスタムフィールド2',
|
||||
'custom_field_3' => 'カスタムフィールド3',
|
||||
'custom_field_4' => 'カスタムフィールド4',
|
||||
);
|
||||
$list = array();
|
||||
foreach ( $target_keys as $target_key ) {
|
||||
$cnv_order_params = self::set_order_list_param( $order_param, $target_key );
|
||||
$use = $cnv_order_params['use'];
|
||||
$sort = $cnv_order_params['sort'];
|
||||
$alert = $cnv_order_params['alert'];
|
||||
$no_order_class = $cnv_order_params['no_order_class'];
|
||||
$field_metakey_input = '';
|
||||
if ( strpos( $target_key, 'custom_field' ) !== false ) {
|
||||
$meta_key = $cnv_order_params[ $target_key ]['meta_key'];
|
||||
$value_type = $cnv_order_params[ $target_key ]['value_type'];
|
||||
$field_metakey_input = self::create_custom_field_sort_type( $name_key, $target_key, $meta_key, $value_type );
|
||||
$target_key_check_class = 'custom_field_check';
|
||||
} else {
|
||||
$target_key_check_class = 'sort_' . $target_key . '_check';
|
||||
}
|
||||
$list[] = '<li class="product-list' . $no_order_class . '">
|
||||
<div class="product-list-type-label"><b>' . $target_values[ $target_key ] . '</b></div>
|
||||
<div class="product-list-sort-type">
|
||||
<label>
|
||||
<input type="hidden" name="_' . $name_key . '[' . $target_key . '][use]" value="0"' . self::set_search_normal_checked( $use, 0 ) . '>
|
||||
<span class="en_dis_label">有効</span>:<input class="' . $target_key_check_class . '" type="checkbox" name="_' . $name_key . '[' . $target_key . '][use]" value="1"' . self::set_search_normal_checked( $use, 1 ) . '>
|
||||
</label>
|
||||
<label>
|
||||
<input class="order_param" type="radio"
|
||||
name="_' . $name_key . '[' . $target_key . '][sort]"
|
||||
value="1"' . self::set_search_normal_checked( $sort, 1 ) . '>昇順</label>
|
||||
<label>
|
||||
<input class="order_param" type="radio"
|
||||
name="_' . $name_key . '[' . $target_key . '][sort]"
|
||||
value="2"' . self::set_search_normal_checked( $sort, 2 ) . '>降順</label>
|
||||
' . $field_metakey_input . '
|
||||
</div>
|
||||
</li>';
|
||||
}
|
||||
|
||||
return array(
|
||||
implode( PHP_EOL, $list ),
|
||||
$alert
|
||||
);
|
||||
}
|
||||
|
||||
private static function create_custom_field_sort_type( $name_key, $target_key, $meta_key, $value_type ): string {
|
||||
return '<div class="sort_custom_field">
|
||||
<div class="sort_custom_field_inner"><div class="sort_custom_field_inner_label">カスタムフィールドキー:</div>
|
||||
<input type="text" class="custom_field_key" name="_' . $name_key . '[' . $target_key . '][field][meta_key]" value="' . $meta_key . '">
|
||||
</div>
|
||||
<div class="sort_custom_field_inner">
|
||||
<div class="sort_custom_field_inner_label">値タイプ:</div>
|
||||
<label><input type="radio"
|
||||
class="custom_field_meta_value"
|
||||
name="_' . $name_key . '[' . $target_key . '][field][value_type]"
|
||||
value="meta_value"' . self::set_search_normal_checked( $value_type, 'meta_value' ) . '>テキスト</label>
|
||||
<label><input type="radio"
|
||||
class="custom_field_meta_value"
|
||||
name="_' . $name_key . '[' . $target_key . '][field][value_type]"
|
||||
value="meta_value_num"' . self::set_search_normal_checked( $value_type, 'meta_value_num' ) . '>数値</label>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
private static function set_order_list_param( $order_param, $target_key ): array {
|
||||
|
||||
$param = array(
|
||||
'use' => 0,
|
||||
'sort' => 2,
|
||||
'alert' => '<p>並べ替えを登録するには「変更を保存」をクリックしてください。</p>',
|
||||
'no_order_class' => ' no_order',
|
||||
);
|
||||
if ( strpos( $target_key, 'custom_field' ) !== false ) {
|
||||
$param[ $target_key ] = array(
|
||||
'meta_key' => '',
|
||||
'value_type' => 'meta_value',
|
||||
);
|
||||
}
|
||||
|
||||
if ( isset( $order_param[ $target_key ] ) ) {
|
||||
$param = array(
|
||||
'use' => $order_param[ $target_key ]['use'] ?? 0,
|
||||
'sort' => $order_param[ $target_key ]['sort'] ?? 2,
|
||||
'alert' => ! $order_param[ $target_key ]['use'] ? '<p>並べ替えを登録するには「変更を保存」をクリックしてください。</p>' : '',
|
||||
'no_order_class' => ! $order_param[ $target_key ]['use'] ? ' no_order' : '',
|
||||
);
|
||||
if ( strpos( $target_key, 'custom_field' ) !== false ) {
|
||||
$param[ $target_key ] = array(
|
||||
'meta_key' => $order_param[ $target_key ]['field']['meta_key'] ?? '',
|
||||
'value_type' => $order_param[ $target_key ]['field']['value_type'] ?? 'meta_value',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $param;
|
||||
|
||||
}
|
||||
|
||||
private static function create_name_keys( $id, $type ): array {
|
||||
if ( is_null( $id ) ) {
|
||||
return array(
|
||||
'name_key' => 'apop_' . $type . '_order_param',
|
||||
'get_option_key' => '_' . 'apop_' . $type . '_order_param',
|
||||
);
|
||||
} else {
|
||||
return array(
|
||||
'name_key' => 'apop_tax_order_param[' . $id . ']',
|
||||
'get_option_key' => '_apop_tax_order_param',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private static function set_search_normal_target_keys( $post_apop_search_order_param ) {
|
||||
|
||||
$set_keys = array(
|
||||
'date',
|
||||
'title',
|
||||
'ID',
|
||||
'modified',
|
||||
'custom_field',
|
||||
'custom_field_2',
|
||||
'custom_field_3',
|
||||
'custom_field_4',
|
||||
);
|
||||
|
||||
if ( $post_apop_search_order_param ) {
|
||||
$register_keys = array_keys( $post_apop_search_order_param );
|
||||
|
||||
return array_unique( array_merge( $register_keys, $set_keys ) );
|
||||
}
|
||||
|
||||
return $set_keys;
|
||||
}
|
||||
|
||||
private static function set_search_normal_checked( $param, $default ): string {
|
||||
if ( $param == $default ) {
|
||||
return ' checked="checked"';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function input_post_filter( $var_name, $type ) {
|
||||
if ( $type == 'array' ) {
|
||||
return filter_input( INPUT_POST, $var_name, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
|
||||
}
|
||||
if ( $type == 'str' ) {
|
||||
return filter_input( INPUT_POST, $var_name );
|
||||
}
|
||||
}
|
||||
|
||||
public static function is_disp_per_page( &$disp, $disp_per_page ) {
|
||||
if ( $disp_per_page ) {
|
||||
$disp = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static function create_none_select_msg( $str ): string {
|
||||
return '<p>並べ替えをカスタマイズする' . $str . 'は選択されていません。</p>';
|
||||
}
|
||||
|
||||
public static function none_registered_alert_msg(): string {
|
||||
return '<div class="no_registered_exp">■は未登録項目です。ドラッグして並び順を変更後に「変更を保存」をクリックしてください。</div>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+187
-49
@@ -21,7 +21,7 @@ h3 {
|
||||
padding: .5em;
|
||||
text-align: center;
|
||||
background: #ababab;
|
||||
border: 1px solid #999;
|
||||
border: 1px solid #ccc;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,8 @@ h3 {
|
||||
.post-order-box-outer {
|
||||
width: 100%;
|
||||
margin: -1px 0 2em;
|
||||
border-top: 1px solid #999;
|
||||
border: 1px solid #ccc;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.post-order-box:not(:first-child) {
|
||||
@@ -52,21 +53,24 @@ h3 {
|
||||
.list-orders-outer {
|
||||
width: 100%;
|
||||
margin-bottom: 1em;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.list-orders-inner {
|
||||
width: 50%;
|
||||
margin: 1.5em 1em 0 0;
|
||||
padding: .5em;
|
||||
border: 1px solid #999;
|
||||
width: calc(100% - 60px);
|
||||
margin: 1em auto;
|
||||
padding: .5em 1em;
|
||||
position: relative;
|
||||
background: #eee;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.sort_menu_list {
|
||||
.sort-menu-list {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.sort_menu_list li:first-child {
|
||||
.sort-menu-list li:first-child {
|
||||
margin-right: 2em;
|
||||
}
|
||||
|
||||
@@ -75,23 +79,57 @@ p.submit.post-order .button-primary {
|
||||
bottom: 1em;
|
||||
}
|
||||
|
||||
dl.apop_setting_list {
|
||||
dl.apop-setting-list,
|
||||
dl.apop-setting-list-dd {
|
||||
width: 100%;
|
||||
margin-top: .5em;
|
||||
}
|
||||
|
||||
dl.apop_setting_list dt {
|
||||
dl.apop-setting-list dt {
|
||||
float: left;
|
||||
}
|
||||
|
||||
dl.apop_setting_list dd {
|
||||
dl.apop-setting-list dd {
|
||||
margin-left: 200px;
|
||||
}
|
||||
|
||||
dl.apop_setting_list dd:first-of-type {
|
||||
dl.apop-setting-list dd:first-of-type {
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
dl.apop-setting-list-dd dt {
|
||||
margin-top: 1em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
dl.apop-setting-list-dd dd {
|
||||
margin: .5em 0;
|
||||
border-bottom: 1px solid #c3c4c7;
|
||||
}
|
||||
|
||||
dl.apop-setting-list-dd dd ul {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
dl.apop-setting-list-dd dd li {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
dl.apop-setting-list-dd dd label {
|
||||
width: 25%;
|
||||
margin-bottom: .3em;
|
||||
cursor: inherit;
|
||||
}
|
||||
|
||||
dl.apop-setting-list-dd input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
dl.apop-setting-list-dd .sort-custom-field-input {
|
||||
width: 75%;
|
||||
}
|
||||
|
||||
.form-table tr {
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
@@ -105,33 +143,65 @@ dl.apop_setting_list dd:first-of-type {
|
||||
background: #fff;
|
||||
cursor: move;
|
||||
color: #4b4b4b;
|
||||
border: 1px solid #ababab;
|
||||
border: 1px solid #fff;
|
||||
}
|
||||
|
||||
.search_normal_sort .product-list {
|
||||
.drag-sort .product-list {
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.enable-box .product-list {
|
||||
width: calc((50%) - 30px);
|
||||
padding: 1em;
|
||||
background: #fff;
|
||||
border: 1px solid #bbb;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.enable-box .product-list:hover {
|
||||
border: 1px solid #999;
|
||||
}
|
||||
|
||||
.custom_field_key_select,
|
||||
.custom_field_key {
|
||||
display: none;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.search-normal-sort .product-list {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.search_normal_sort .product-list-type-label,
|
||||
.disable_box .product-list-type-label {
|
||||
width: calc(100% / 2);
|
||||
.search-normal-sort .product-list-type-label,
|
||||
.disable-box .product-list-type-label {
|
||||
width: calc((100%) - 60px);
|
||||
}
|
||||
|
||||
.search_normal_sort .product-list-sort-type {
|
||||
.search-normal-sort .product-list-sort-type {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.search_normal_sort .product-list-sort-type label {
|
||||
.search-normal-sort .product-list-sort-type label {
|
||||
width: calc((100% / 4) - 5px);
|
||||
}
|
||||
|
||||
.product-list.no_order {
|
||||
background: #ababab;
|
||||
.search-normal-sort .product-list-sort-type label:first-of-type {
|
||||
margin-right: 3em;
|
||||
}
|
||||
|
||||
.list_order {
|
||||
.disable-box ul.disable-normal-list li.product-list.no-order .product-list-sort-type {
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.product-list.no-order {
|
||||
background: #ababab;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.list-order {
|
||||
width: 2em;
|
||||
}
|
||||
|
||||
@@ -143,79 +213,138 @@ dl.apop_setting_list dd:first-of-type {
|
||||
content: "]";
|
||||
}
|
||||
|
||||
.no_registered_exp {
|
||||
.no-registered-exp {
|
||||
width: 100%;
|
||||
margin-top: 1em;
|
||||
margin: 1em 0 0 .5em;
|
||||
}
|
||||
|
||||
.order_setting_list > li {
|
||||
.order-setting-list > li {
|
||||
padding: 1em;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.select_per_page {
|
||||
.select-per-page {
|
||||
margin-top: 1em;
|
||||
padding-top: 1em;
|
||||
border-top: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.sort_custom_field {
|
||||
.sort-custom-field {
|
||||
width: 100%;
|
||||
margin-top: .5em;
|
||||
padding-top: .5em;
|
||||
border-top: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.sort_custom_field_inner {
|
||||
.sort-custom-field-types,
|
||||
.sort-custom-field-inner {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.sort_custom_field_inner:first-child {
|
||||
.sort-custom-field-types:first-child,
|
||||
.sort-custom-field-inner:first-child {
|
||||
margin-bottom: .5em;
|
||||
}
|
||||
|
||||
.sort_custom_field_inner_label {
|
||||
.sort-custom-field-inner-label {
|
||||
width: 40%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.disable_normal_list {
|
||||
.search-normal-sort .product-list-sort-type label.sort-custom-field-text-label {
|
||||
width: 7em;
|
||||
}
|
||||
|
||||
.disable-normal-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
margin: .5em 1em 1em 0;
|
||||
}
|
||||
|
||||
.disable_box .product-list-sort-type label:not(:first-of-type),
|
||||
.disable_box .sort_custom_field,
|
||||
.disable_box .sort_custom_field_inner {
|
||||
.disable-box .product-list-sort-type label:not(:first-of-type),
|
||||
.disable-box .sort-custom-field,
|
||||
.disable-box .sort-custom-field-inner {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.disable_box .product-list {
|
||||
width: calc((100% / 2) - 20px);
|
||||
.disable-box .product-list {
|
||||
width: calc((25%) - 15px);
|
||||
display: flex;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.apop-submit {
|
||||
margin: 1em .5em;
|
||||
}
|
||||
|
||||
.apop-form-table {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.apop-form-table th {
|
||||
padding-left: .5em;
|
||||
}
|
||||
|
||||
.enable-box {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.enable-box,
|
||||
.disable-box {
|
||||
padding: .5em;
|
||||
/*border-bottom: 1px solid #ccc;*/
|
||||
}
|
||||
|
||||
.enable-box h4 {
|
||||
margin: .5em 0 0;
|
||||
}
|
||||
|
||||
.disable-box h4 {
|
||||
margin: .5em 0;
|
||||
}
|
||||
|
||||
.custom-field-select-alert {
|
||||
width: 100%;
|
||||
margin-top: -.5em;
|
||||
color: crimson;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
||||
@media only screen and (max-width: 1264px) {
|
||||
.search_normal_sort .product-list {
|
||||
|
||||
.enable-box .product-list {
|
||||
width: calc((100%) - 15px);
|
||||
}
|
||||
|
||||
.search-normal-sort .product-list {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.search_normal_sort .product-list-type-label {
|
||||
.search-normal-sort .product-list-type-label,
|
||||
.disable-box .product-list-type-label {
|
||||
width: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.search-normal-sort .product-list-sort-type {
|
||||
width: 100%;
|
||||
margin-bottom: 1em;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.search_normal_sort .product-list-sort-type {
|
||||
.search-normal-sort .product-list-sort-type {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.search_normal_sort .product-list-sort-type label {
|
||||
.search-normal-sort .product-list-sort-type label {
|
||||
width: calc((100% / 3) - 5px);
|
||||
}
|
||||
|
||||
.search-normal-sort .product-list-sort-type label:first-of-type {
|
||||
margin-right: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 964px) {
|
||||
@@ -224,27 +353,36 @@ dl.apop_setting_list dd:first-of-type {
|
||||
width: 98%;
|
||||
}
|
||||
|
||||
.list-orders-outer {
|
||||
display: block;;
|
||||
}
|
||||
|
||||
.list-orders-inner {
|
||||
width: auto;
|
||||
margin: 1.5em 0 0 0;
|
||||
margin: 1.5em 1em 0;
|
||||
}
|
||||
|
||||
dl.apop_setting_list dt {
|
||||
dl.apop-setting-list dt {
|
||||
float: none;
|
||||
width: 100%;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
dl.apop_setting_list dd {
|
||||
dl.apop-setting-list dd {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
dl.apop_setting_list li label input[type="text"] {
|
||||
dl.apop-setting-list li label input[type="text"] {
|
||||
width: 95%;
|
||||
margin-top: .5em;
|
||||
}
|
||||
|
||||
.sort-custom-field-inner-label {
|
||||
width: auto;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.disable-normal-list {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.disable-box .product-list {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
Vendored
+1312
File diff suppressed because it is too large
Load Diff
+131
-56
@@ -18,39 +18,50 @@ jQuery(function ($) {
|
||||
|
||||
change_normal_field_sort();
|
||||
|
||||
custom_field_select();
|
||||
|
||||
function change_tab_menu() {
|
||||
let submit_type = $('.post-order-box-outer').data('submit_type');
|
||||
let order_nav_list = $('.post-order-nav li');
|
||||
let order_box = $('.post-order-box');
|
||||
const apop_submit_type = $('#apop_submit_type');
|
||||
const order_nav_list = $('.post-order-nav li');
|
||||
const order_box = $('.post-order-box');
|
||||
|
||||
order_nav_list.removeClass('en');
|
||||
order_box.hide();
|
||||
$('.post-order-nav li:eq(' + submit_type + ')').addClass('en');
|
||||
$('.post-order-box:eq(' + submit_type + ')').show()
|
||||
init();
|
||||
click_menu();
|
||||
|
||||
order_nav_list.on('click', function () {
|
||||
if (!$(this).hasClass('en')) {
|
||||
let target_index = $(this).index();
|
||||
order_nav_list.removeClass('en');
|
||||
$(this).addClass('en');
|
||||
order_box.hide();
|
||||
$('.post-order-box:eq(' + target_index + ')').show();
|
||||
}
|
||||
});
|
||||
function init() {
|
||||
const submit_type = apop_submit_type.val();
|
||||
order_nav_list.removeClass('en');
|
||||
order_box.hide();
|
||||
$('.post-order-nav li:eq(' + submit_type + ')').addClass('en');
|
||||
$('.post-order-box:eq(' + submit_type + ')').show()
|
||||
}
|
||||
|
||||
function click_menu() {
|
||||
order_nav_list.on('click', function () {
|
||||
if (!$(this).hasClass('en')) {
|
||||
const target_index = $(this).index();
|
||||
order_nav_list.removeClass('en');
|
||||
$(this).addClass('en');
|
||||
order_box.hide();
|
||||
$('.post-order-box:eq(' + target_index + ')').show();
|
||||
apop_submit_type.val(target_index);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function order_list() {
|
||||
let cat_ul_count = $('.post-order-list').length; //カテゴリ総数
|
||||
const cat_ul_count = $('.post-order-list').length; //カテゴリ総数
|
||||
for (let i = 0; i < cat_ul_count; i++) {
|
||||
let my_list = $('.post-order-list:eq(' + i + ')');
|
||||
const my_list = $('.post-order-list:eq(' + i + ')');
|
||||
my_list.sortable(
|
||||
{
|
||||
update: function () {
|
||||
let list_count = $('.product-list', my_list).length;
|
||||
const list_count = $('.product-list', my_list).length;
|
||||
for (let j = 0; j < list_count; j++) {
|
||||
let list_order = j + 1;
|
||||
$('.list_order:eq(' + j + ')', my_list).val(list_order);
|
||||
$('.list_order:eq(' + j + ')', my_list).siblings('.sort-num-label').text(list_order);
|
||||
let list_order_num = j + 1;
|
||||
$('.list-order:eq(' + j + ')', my_list).val(list_order_num);
|
||||
$('.list-order:eq(' + j + ')', my_list).siblings('.sort-num-label').text(list_order_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,59 +71,59 @@ jQuery(function ($) {
|
||||
}
|
||||
|
||||
function change_sort_box() {
|
||||
let s_radio = $('.sort_menu');
|
||||
let sort_menu_size = $('.sort_menu_list').length;
|
||||
const s_radio = $('.sort_menu');
|
||||
const sort_menu_size = $('.sort-menu-list').length;
|
||||
|
||||
$('.sort_box').hide();
|
||||
for (let i = 0; i < sort_menu_size; i++) {
|
||||
let type_index = $('.sort_menu_list:eq(' + i + ')').data('order_target') - 1;
|
||||
$('.sort_menu_list:eq(' + i + ')').siblings('.sort_box:eq(' + type_index + ')').show();
|
||||
const elm = $('.sort-menu-list:eq(' + i + ')');
|
||||
const type_index = elm.data('order_target') - 1;
|
||||
elm.siblings('.sort_box:eq(' + type_index + ')').show();
|
||||
}
|
||||
|
||||
s_radio.on('click', function () {
|
||||
let target_index = $(this).val() - 1;
|
||||
const target_index = $(this).val() - 1;
|
||||
$(this).parents('.list-orders-inner').find('.sort_box').hide();
|
||||
$(this).parents('.list-orders-inner').find('.sort_box:eq(' + target_index + ')').show();
|
||||
})
|
||||
}
|
||||
|
||||
function select_tax() {
|
||||
let select_cat_checkbox = $('.select_cat_checkbox');
|
||||
let input_chk_size = select_cat_checkbox.length;
|
||||
let i = 0;
|
||||
|
||||
for (i; i < input_chk_size; i++) {
|
||||
let chk = $('.select_cat_checkbox:eq(' + i + '):checked').length;
|
||||
if (chk == 1) {
|
||||
$('.select_cat:eq(' + i + ')').siblings('.select_per_page').show();
|
||||
const select_cat_checkbox = $('.select_cat_checkbox');
|
||||
const input_chk_size = select_cat_checkbox.length;
|
||||
for (let i = 0; i < input_chk_size; i++) {
|
||||
const chk = $('.select_cat_checkbox:eq(' + i + '):checked').length;
|
||||
const elm = $('.select_cat:eq(' + i + ')');
|
||||
if (chk === 1) {
|
||||
elm.siblings('.select-per-page').show();
|
||||
} else {
|
||||
$('.select_cat:eq(' + i + ')').siblings('.select_per_page').hide();
|
||||
elm.siblings('.select-per-page').hide();
|
||||
}
|
||||
}
|
||||
|
||||
select_cat_checkbox.on('click', function () {
|
||||
let checked = $(this).prop('checked');
|
||||
const checked = $(this).prop('checked');
|
||||
if (checked) {
|
||||
$(this).parent().parent().siblings('.select_per_page').show(200);
|
||||
$(this).parent().parent().siblings('.select-per-page').show(200);
|
||||
} else {
|
||||
$(this).parent().parent().siblings('.select_per_page').hide(200);
|
||||
$(this).parent().parent().siblings('.select-per-page').hide(200);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function change_search_per_page() {
|
||||
let per_page_cat = $('.per_page_search');
|
||||
let per_page_input = $('.per_page_search_input');
|
||||
const per_page_cat = $('.per_page_search');
|
||||
const per_page_input = $('.per_page_search_input');
|
||||
|
||||
if (per_page_input.val() == '') {
|
||||
if (per_page_input.val() === '') {
|
||||
per_page_input.prop('disabled', true);
|
||||
} else {
|
||||
per_page_input.prop('disabled', false);
|
||||
}
|
||||
|
||||
per_page_cat.on('click', function () {
|
||||
if ($(this).val() != 'default' && $(this).val() != '-1' && $(this).val() != 'all') {
|
||||
if ($(this).val() !== 'default' && $(this).val() !== '-1' && $(this).val() !== 'all') {
|
||||
per_page_input.prop('disabled', false);
|
||||
} else {
|
||||
per_page_input.val('');
|
||||
@@ -122,11 +133,11 @@ jQuery(function ($) {
|
||||
}
|
||||
|
||||
function change_tax_per_page() {
|
||||
let set_number = $('.set_number');
|
||||
let input_chk_size = set_number.length;
|
||||
const set_number = $('.set_number');
|
||||
const input_chk_size = set_number.length;
|
||||
for (let i = 0; i < input_chk_size; i++) {
|
||||
let input_num_box = $('.set_number:eq(' + i + ')').siblings('.per_page_cat_input');
|
||||
if (input_num_box.val() == '') {
|
||||
const input_num_box = $('.set_number:eq(' + i + ')').siblings('.per_page_cat_input');
|
||||
if (input_num_box.val() === '') {
|
||||
input_num_box.prop('disabled', true);
|
||||
} else {
|
||||
input_num_box.prop('disabled', false);
|
||||
@@ -143,26 +154,90 @@ jQuery(function ($) {
|
||||
}
|
||||
|
||||
function change_normal_field_sort() {
|
||||
let s_box = $('.sort_box');
|
||||
let targets = '.custom_field_check, .sort_date_check, .sort_title_check, .sort_ID_check, .sort_modified_check';
|
||||
const s_box = $('.sort_box');
|
||||
const targets = '.sort_date_check, .sort_title_check, .sort_ID_check, .sort_modified_check';
|
||||
s_box.find(targets).each(function () {
|
||||
if ($(this).prop('checked') == false) {
|
||||
if ($(this).prop('checked') === false) {
|
||||
$(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', true);
|
||||
let disable_list = $(this).parents('.sort_box').find('.disable_normal_list');
|
||||
const disable_list = $(this).parents('.sort_box').find('.disable-normal-list');
|
||||
$(this).parents('li').appendTo(disable_list);
|
||||
}
|
||||
});
|
||||
$(targets).on('click', function () {
|
||||
if ($(this).prop('checked') == true) {
|
||||
if ($(this).prop('checked') === true) {
|
||||
$(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', false);
|
||||
let enable_list = $(this).parents('.sort_box').find('.post-order-list');
|
||||
$(this).parents('li').appendTo(enable_list).removeClass('no_order').hide().fadeIn(200);
|
||||
const enable_list = $(this).parents('.sort_box').find('.post-order-list');
|
||||
$(this).parents('li').appendTo(enable_list).removeClass('no-order').hide().fadeIn(200);
|
||||
} else {
|
||||
$(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', true);
|
||||
let disable_list = $(this).parents('.sort_box').find('.disable_normal_list');
|
||||
$(this).parents('li').appendTo(disable_list).addClass('no_order').hide().fadeIn(200);
|
||||
const disable_list = $(this).parents('.sort_box').find('.disable-normal-list');
|
||||
$(this).parents('li').appendTo(disable_list).addClass('no-order').hide().fadeIn(200);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function custom_field_select() {
|
||||
const s_box = $('.sort_box');
|
||||
const targets = $('.custom-field-type');
|
||||
const en_dis_check = $('.custom_field_check');
|
||||
|
||||
// カスタムフィールドソートの有効・無効を判定する。
|
||||
// 有効の場合はカスタムフィールド選択or追加のステータスに応じてテキストエリアとセレクトタグenableに変更し表示を切り替える。
|
||||
// 無効の場合はカスタムフィールドのテキストエリアとセレクトタグをDisableにし無効ボックスに移動する。
|
||||
s_box.find('.custom_field_check').each(function () {
|
||||
if ($(this).prop('checked') === false) {
|
||||
const disable_list = $(this).parents('.sort_box').find('.disable-normal-list');
|
||||
$(this).parents('li').appendTo(disable_list);
|
||||
dis_list($(this));
|
||||
} else {
|
||||
const target_type = $(this).parents('.product-list-sort-type').find('.custom-field-type').filter(':checked').val();
|
||||
en_dis_list($(this), target_type);
|
||||
}
|
||||
});
|
||||
|
||||
//有効・無効チェックボックスクリック時
|
||||
en_dis_check.on('click', function () {
|
||||
if ($(this).prop('checked') === true) {
|
||||
const enable_list = $(this).parents('.sort_box').find('.post-order-list');
|
||||
const target_type = $(this).parents('.product-list-sort-type').find('.custom-field-type').filter(':checked').val();
|
||||
$(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', false);
|
||||
$(this).parents('li').appendTo(enable_list).removeClass('no-order').hide().fadeIn(200);
|
||||
en_dis_list($(this), target_type);
|
||||
} else {
|
||||
const disable_list = $(this).parents('.sort_box').find('.disable-normal-list');
|
||||
$(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', true);
|
||||
$(this).parents('li').appendTo(disable_list).addClass('no-order').hide().fadeIn(200);
|
||||
dis_list($(this));
|
||||
}
|
||||
});
|
||||
|
||||
//選択・追加のカスタムフィールド種類ラジオボタンのクリック
|
||||
targets.on('click', function () {
|
||||
en_dis_list($(this), $(this).val());
|
||||
});
|
||||
|
||||
function dis_list(obj) {
|
||||
obj.parents('.product-list-sort-type').find('.custom_field_key').prop('disabled', true);
|
||||
obj.parents('.product-list-sort-type').find('.custom_field_key_select').prop('disabled', true);
|
||||
}
|
||||
|
||||
function en_dis_list(obj, type) {
|
||||
let select_msg = 'Select from existing custom fields';
|
||||
let add_msg = 'Added custom field for APOP';
|
||||
if ($('.post-setting-box').hasClass('apop-lang-ja')) {
|
||||
select_msg = '既存のカスタムフィールドから選択';
|
||||
add_msg = 'APOP専用カスタムフィールドを追加';
|
||||
}
|
||||
if (type === 1) {
|
||||
obj.parents('.product-list-sort-type').find('.custom_field_key_select').prop('disabled', false).show();
|
||||
obj.parents('.product-list-sort-type').find('.custom_field_key').prop('disabled', true).hide();
|
||||
obj.parents('.product-list-sort-type').find('.custom-field-select-alert').text(select_msg);
|
||||
} else if (type === 2) {
|
||||
obj.parents('.product-list-sort-type').find('.custom_field_key').prop('disabled', false).show();
|
||||
obj.parents('.product-list-sort-type').find('.custom_field_key_select').prop('disabled', true).hide();
|
||||
obj.parents('.product-list-sort-type').find('.custom-field-select-alert').text(add_msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
jQuery(function ($) {
|
||||
$('.select-custom-field-input').autocomplete({
|
||||
source: function (req, resp) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: localize.ajax_url,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
action: localize.action,
|
||||
param: req.term
|
||||
}
|
||||
}).done(function (o) {
|
||||
resp(o);
|
||||
}).fail(function () {
|
||||
resp(['']);
|
||||
});
|
||||
},
|
||||
autoFocus: true,
|
||||
minLength: 2
|
||||
});
|
||||
});
|
||||
Binary file not shown.
@@ -0,0 +1,246 @@
|
||||
# Blank WordPress Pot
|
||||
# Copyright 2014 ...
|
||||
# This file is distributed under the GNU General Public License v3 or later.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Archive Post Order Plus\n"
|
||||
"Report-Msgid-Bugs-To: Translator Name <translations@example.com>\n"
|
||||
"POT-Creation-Date: 2021-07-23 16:59+0900\n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: NBK45 <nbk.develop@gmail.com>\n"
|
||||
"Language-Team: NBK45 <nbk.develop@gmail.com>\n"
|
||||
"Language: ja\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Textdomain-Support: yesX-Generator: Poedit 1.6.4\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html_x:1,2c;esc_html__;"
|
||||
"esc_attr_e;esc_attr_x:1,2c;esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;"
|
||||
"_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext:1,2;__ngettext_noop:1,2;_c,_nc:4c,1,2\n"
|
||||
"X-Poedit-Basepath: ..\n"
|
||||
"X-Generator: Poedit 3.0\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#: class/class.apop.apop_post.php:33
|
||||
msgid "APO + custom field settings"
|
||||
msgstr "APO+カスタムフィールド"
|
||||
|
||||
#: class/class.apop.apop_post.php:57 template/order.php:8
|
||||
msgid "Your latest posts"
|
||||
msgstr "最新の投稿"
|
||||
|
||||
#: class/class.apop.apop_post.php:58 template/order.php:9 template/order.php:55
|
||||
msgid "Search"
|
||||
msgstr "検索"
|
||||
|
||||
#: class/class.apop.apop_post.php:59
|
||||
msgid "Category, Tag, Custom Taxonomy"
|
||||
msgstr "カテゴリー、タグ、カスタム分類"
|
||||
|
||||
#: class/class.apop.apop_post.php:60
|
||||
msgid "Custom posts archive"
|
||||
msgstr "カスタム投稿アーカイブ"
|
||||
|
||||
#: class/class.apop.apop_ui.php:352
|
||||
msgid "Select"
|
||||
msgstr "選択"
|
||||
|
||||
#: class/class.apop.apop_ui.php:357
|
||||
msgid "Add"
|
||||
msgstr "追加"
|
||||
|
||||
#: class/class.apop.apop_ui.php:364
|
||||
msgid "Type"
|
||||
msgstr "値タイプ"
|
||||
|
||||
#: class/class.apop.apop_ui.php:369
|
||||
msgid "Text"
|
||||
msgstr "テキスト"
|
||||
|
||||
#: class/class.apop.apop_ui.php:373
|
||||
msgid "Number"
|
||||
msgstr "数値"
|
||||
|
||||
#: class/class.apop.apop_ui.php:469
|
||||
msgid "Published"
|
||||
msgstr "投稿日"
|
||||
|
||||
#: class/class.apop.apop_ui.php:470
|
||||
msgid "Post Title"
|
||||
msgstr "タイトル"
|
||||
|
||||
#: class/class.apop.apop_ui.php:472
|
||||
msgid "Modified"
|
||||
msgstr "更新日"
|
||||
|
||||
#: class/class.apop.apop_ui.php:473
|
||||
msgid "Custom filed 1"
|
||||
msgstr "カスタムフィールド1"
|
||||
|
||||
#: class/class.apop.apop_ui.php:474
|
||||
msgid "Custom filed 2"
|
||||
msgstr "カスタムフィールド2"
|
||||
|
||||
#: class/class.apop.apop_ui.php:475
|
||||
msgid "Custom filed 3"
|
||||
msgstr "カスタムフィールド3"
|
||||
|
||||
#: class/class.apop.apop_ui.php:476
|
||||
msgid "Custom filed 4"
|
||||
msgstr "カスタムフィールド4"
|
||||
|
||||
#: class/class.apop.apop_ui.php:497 template/order.php:34 template/order.php:65
|
||||
#: template/order_parts_custom_posts.php:46
|
||||
#: template/order_parts_taxonomy.php:46
|
||||
msgid "Enabled"
|
||||
msgstr "有効"
|
||||
|
||||
#: class/class.apop.apop_ui.php:503
|
||||
msgid "Asc"
|
||||
msgstr "昇順"
|
||||
|
||||
#: class/class.apop.apop_ui.php:507
|
||||
msgid "Desc"
|
||||
msgstr "降順"
|
||||
|
||||
#: class/class.apop.order.php:39
|
||||
msgid "Display number / target setting"
|
||||
msgstr "表示件数・対象設定"
|
||||
|
||||
#: class/class.apop.order.php:47 template/order.php:5
|
||||
msgid "Sorting"
|
||||
msgstr "並べ替え"
|
||||
|
||||
#: template/order.php:4
|
||||
msgid "apop-lang-en"
|
||||
msgstr "apop-lang-ja"
|
||||
|
||||
#: template/order.php:10 template/order.php:87
|
||||
msgid "Category"
|
||||
msgstr "カテゴリー"
|
||||
|
||||
#: template/order.php:11 template/order.php:96
|
||||
msgid "Tag"
|
||||
msgstr "タグ"
|
||||
|
||||
#: template/order.php:12 template/order.php:105
|
||||
msgid "Custom taxonomy"
|
||||
msgstr "カスタム分類"
|
||||
|
||||
#: template/order.php:13 template/order.php:113
|
||||
msgid "Custom posts"
|
||||
msgstr "カスタム投稿アーカイブ"
|
||||
|
||||
#: template/order.php:24
|
||||
msgid "Your latest posts / Settings - Reading Settings"
|
||||
msgstr "最新の投稿(設定-表示設定ーホームページの表示)"
|
||||
|
||||
#: template/order.php:31 template/order.php:62
|
||||
#: template/order_parts_custom_posts.php:36
|
||||
#: template/order_parts_custom_posts.php:44
|
||||
#: template/order_parts_taxonomy.php:36 template/order_parts_taxonomy.php:44
|
||||
msgid "Click \"Save Changes\" to register the sort."
|
||||
msgstr "並べ替えを登録するには「変更を保存」をクリックしてください。"
|
||||
|
||||
#: template/order.php:40 template/order.php:71
|
||||
#: template/order_parts_custom_posts.php:52
|
||||
#: template/order_parts_taxonomy.php:52
|
||||
msgid "Disabled"
|
||||
msgstr "無効"
|
||||
|
||||
#: template/order.php:120 template/setting.php:46
|
||||
msgid "Save changes"
|
||||
msgstr "変更を保存"
|
||||
|
||||
#: template/order_parts_custom_posts.php:22 template/order_parts_menu.php:6
|
||||
#: template/order_parts_taxonomy.php:22
|
||||
msgid "Standard + custom field sort"
|
||||
msgstr "標準+カスタムフィールドソート"
|
||||
|
||||
#: template/order_parts_custom_posts.php:29 template/order_parts_menu.php:9
|
||||
#: template/order_parts_taxonomy.php:29
|
||||
msgid "Drag sort"
|
||||
msgstr "ドラッグソート"
|
||||
|
||||
#: template/order_parts_custom_posts.php:60
|
||||
#: template/order_parts_taxonomy.php:59
|
||||
msgid "No"
|
||||
msgstr "並べ替えをカスタマイズする「"
|
||||
|
||||
#: template/order_parts_custom_posts.php:60
|
||||
#: template/order_parts_taxonomy.php:59
|
||||
msgid "has been selected."
|
||||
msgstr "」は選択されていません。"
|
||||
|
||||
#: template/setting.php:4
|
||||
msgid "Settings"
|
||||
msgstr "設定"
|
||||
|
||||
#: template/setting.php:7
|
||||
msgid "Global settings"
|
||||
msgstr "全体設定"
|
||||
|
||||
#: template/setting.php:10
|
||||
msgid "Displayed per page"
|
||||
msgstr "1ページ表示件数"
|
||||
|
||||
#: template/setting.php:16 template/setting_parts_customposts.php:31
|
||||
#: template/setting_parts_taxonomy.php:31
|
||||
msgid "Follow display settings"
|
||||
msgstr "表示設定に従う"
|
||||
|
||||
#: template/setting.php:18 template/setting_parts_customposts.php:33
|
||||
#: template/setting_parts_taxonomy.php:32
|
||||
msgid "Posts"
|
||||
msgstr "件"
|
||||
|
||||
#: template/setting.php:22 template/setting_parts_customposts.php:44
|
||||
#: template/setting_parts_taxonomy.php:42
|
||||
msgid "All posts"
|
||||
msgstr "全件"
|
||||
|
||||
#: template/setting.php:28 template/setting_parts_customposts.php:50
|
||||
#: template/setting_parts_taxonomy.php:47
|
||||
msgid "Set the number posts"
|
||||
msgstr "表示数設定"
|
||||
|
||||
#: template/setting.php:40
|
||||
msgid "Categories setting"
|
||||
msgstr "カテゴリー設定"
|
||||
|
||||
#: template/setting.php:41
|
||||
msgid "Tags setting"
|
||||
msgstr "タグ設定"
|
||||
|
||||
#: template/setting.php:42
|
||||
msgid "Custom Taxonomies setting"
|
||||
msgstr "カスタム分類設定"
|
||||
|
||||
#: template/setting.php:43
|
||||
msgid "Custom Posts Archive setting"
|
||||
msgstr "カスタム投稿アーカイブ設定"
|
||||
|
||||
#: template/setting_parts_customposts.php:3
|
||||
#: template/setting_parts_taxonomy.php:3
|
||||
msgid "Targets"
|
||||
msgstr "対象"
|
||||
|
||||
#: template/setting_parts_customposts.php:38
|
||||
#: template/setting_parts_taxonomy.php:37
|
||||
msgid "Follow global settings"
|
||||
msgstr "全体設定に従う"
|
||||
|
||||
#: template/setting_post_custom_field.php:18
|
||||
msgid "* Change from custom field"
|
||||
msgstr "※カスタムフィールドから変更してください"
|
||||
|
||||
#: template/success.php:2
|
||||
msgid "Saved the setting"
|
||||
msgstr "設定を保存しました"
|
||||
|
||||
#, fuzzy
|
||||
#~| msgid "Search"
|
||||
#~ msgid "Search!!!"
|
||||
#~ msgstr "検索"
|
||||
+160
-31
@@ -1,56 +1,185 @@
|
||||
=== Archive POst Order Plus ===
|
||||
=== Archive Post Order Plus ===
|
||||
Contributors: nbk45
|
||||
Tags: 投稿,表示順,投稿表示順,カテゴリー,タグ,カスタム分類,post,archive,category,tag,custom taxonomy,order
|
||||
Requires at least: 4.9
|
||||
Tested up to: 5.7
|
||||
Requires PHP: 7.0
|
||||
Stable tag: 1.0.0
|
||||
Tags: latest posts order,categories post order,tags post order,custom taxonomy post order
|
||||
Requires at least: 6.7
|
||||
Tested up to: 6.9
|
||||
Requires PHP: 8.3
|
||||
Stable tag: 1.2.4
|
||||
License: GPLv2 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
アーカイブページの投稿表示順をタクソノミー毎に設定するプラグイン。
|
||||
A plugin that sets the display order of posts.
|
||||
投稿の表示順を設定するプラグイン。
|
||||
|
||||
== Description ==
|
||||
This plugin is a plugin that customizes the posting order below.
|
||||
- Your latest posts / Settings - Reading Settings
|
||||
- Search results
|
||||
- Category
|
||||
- Tag
|
||||
- Custom Taxonomy
|
||||
- Custom Posts Archive
|
||||
|
||||
このプラグインはタクソノミー毎に投稿表示順を設定するプラグインです。
|
||||
このプラグインは、下記の投稿表示順をカスタマイズするプラグインです。
|
||||
・[設定]-[表示設定]の「最新の投稿」
|
||||
・検索結果
|
||||
・カテゴリー
|
||||
・タグ
|
||||
・カスタム分類
|
||||
・カスタム投稿アーカイブ
|
||||
|
||||
= 仕様 =
|
||||
投稿表示順をカスタマイズしたいタクソノミーを選択します。
|
||||
選択した各タクソノミー内の投稿順をドラッグ&ドロップで変更し保存します。
|
||||
= Specification =
|
||||
Select either 1) standard + custom field sort or 2) drag sort for the display order.
|
||||
|
||||
【サブクエリコード】
|
||||
get_posts()などを利用する場合、下記のコードに並び順のパラメータを取得できます。
|
||||
<pre><code>
|
||||
<?php
|
||||
?>
|
||||
</code></pre>
|
||||
[設定]-[表示設定]の「最新の投稿」、検索結果、カテゴリー、タグ、カスタム分類毎に投稿表示順を設定可能にします。
|
||||
表示順は 1)標準+カスタムフィールドソート、2)ドラッグソートのどちらを選択します。
|
||||
|
||||
1)Standard + custom field sort (標準+カスタムフィールドソート)
|
||||
In addition to the post update date, ID, title, and registration date, 4 custom fields (*) can be registered.
|
||||
Select the post you want to enable and drag to set the order.
|
||||
|
||||
*) Custom fields can be selected from existing custom fields or added for this plugin.
|
||||
*) When this plug-in is deleted, the added custom field will also be deleted.
|
||||
|
||||
投稿の更新日、ID、タイトル、登録日に加え、4つのカスタムフィールド(※)が登録可能です。
|
||||
有効にしたい項目を選択しドラッグで順番を設定します。
|
||||
|
||||
※)カスタムフィールドは、既存のカスタムフィールドから選択、もしくは本プラグイン用に追加可能です。
|
||||
(追加の場合は各投稿の専用入力フォームから登録します)
|
||||
※)本プラグインの削除時は、追加したカスタムフィールドも削除されます
|
||||
|
||||
2)Drag sort (ドラッグソート)
|
||||
In the list of posts displayed in the list, drag the posts to set the display order.
|
||||
|
||||
リスト表示されてた投稿一覧で、投稿をドラッグし表示順を設定します。
|
||||
|
||||
== Installation ==
|
||||
|
||||
= 自動インストール =
|
||||
1. プラグインの検索フィールドより「Archive Post Order Plus」や「投稿表示順」と入力し、"プラグインの検索"をクリックします。
|
||||
1. 当プラグインを見つけたら、"今すぐインストール"をクリックしてインストールし、プラグインを有効化してください。
|
||||
= Automatic installation (自動インストール) =
|
||||
1. Enter "Archive Post Order Plus" in the plugin search field and click "Search for Plugins".
|
||||
2. If you find this plugin, click "Install Now" to install it and activate the plugin.
|
||||
|
||||
= 手動インストール =
|
||||
1. プラグインをダウンロードします。
|
||||
1. プラグインフォルダ内にアップロードし、管理画面よりプラグインを有効化してください。
|
||||
1)プラグインの検索フィールドより「Archive Post Order Plus」と入力し、"プラグインの検索"をクリックします。
|
||||
2)当プラグインを見つけたら、"今すぐインストール"をクリックしてインストールし、プラグインを有効化してください。
|
||||
|
||||
= Manual installation (手動インストール) =
|
||||
1. Download this plugin.
|
||||
2. Please upload it in the plugin folder and activate the plugin from the management screen.
|
||||
|
||||
1)プラグインをダウンロードします。
|
||||
2)プラグインフォルダ内にアップロードし、管理画面よりプラグインを有効化してください。
|
||||
|
||||
== 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
|
||||
screenshot-1.png
|
||||
screenshot-2.png
|
||||
screenshot-3.png
|
||||
screenshot-4.png
|
||||
screenshot-5.png
|
||||
screenshot-6.png
|
||||
screenshot-7.png
|
||||
screenshot-8.png
|
||||
|
||||
== Changelog ==
|
||||
= 1.2.4 =
|
||||
・WordPress6.9動作確認
|
||||
・PHP8.3対応修正
|
||||
|
||||
= 1.2.3 =
|
||||
confirm WordPress6.5
|
||||
|
||||
= 1.2.2 =
|
||||
confirm WordPress6.3
|
||||
confirm WordPress6.1
|
||||
|
||||
WordPress6.1動作確認
|
||||
|
||||
= 1.2.1 =
|
||||
confirm WordPress6.0
|
||||
Fix template typos.
|
||||
Add method return type specification.
|
||||
Delete unnecessary variable assignments.
|
||||
Add condition to file include.
|
||||
|
||||
WordPress6.0動作確認
|
||||
テンプレートのミスタイプの修正
|
||||
メソッドの戻り型指定の追加
|
||||
不要な変数代入の削除
|
||||
ファイルインクルードの条件追加
|
||||
|
||||
= 1.2.0 =
|
||||
confirm WordPress5.9
|
||||
Fixed Notice error in custom post archive.
|
||||
|
||||
WordPress5.9動作確認
|
||||
カスタム投稿アーカイブのNoticeエラー修正
|
||||
|
||||
= 1.1.9 =
|
||||
Changed the layout of the sort menu.
|
||||
Modified JavaScript variable declaration and stored element specification in variable.
|
||||
|
||||
並べ替えのレイアウトを変更
|
||||
JavaScriptで要素を変数に格納
|
||||
|
||||
= 1.1.8 =
|
||||
Supports sort settings for custom post archives.
|
||||
Bug fixed: "Follow global settings" of category, tag, and custom classification does not work properly when all items are selected in global settings.
|
||||
|
||||
カスタム投稿アーカイブのソート設定対応
|
||||
全体設定で全件を選択している時にカテゴリー、タグ、カスタム分類の「全体設定に従う」が正常機能しないバグの修正
|
||||
|
||||
= 1.1.7 =
|
||||
Supports translation.
|
||||
Bug fixed: custom field selection by Search
|
||||
|
||||
翻訳対応
|
||||
検索のカスタムフィールド選択バグの修正
|
||||
|
||||
= 1.1.6 =
|
||||
Fixed the part where the notice error occurred when the initial data was not set.
|
||||
初期データ未設定時にnoticeエラーになっていた箇所を修正
|
||||
|
||||
= 1.1.5 =
|
||||
Smartphone support for drag sorting of posted articles.
|
||||
投稿記事のドラッグ並べ替えのスマートフォン対応
|
||||
|
||||
= 1.1.4 =
|
||||
Explicitly include jquery-ui-autocomplete.
|
||||
jquery-ui-autocompleteを明示的にインクルード
|
||||
|
||||
= 1.1.3 =
|
||||
Change selected custom field to autocomplete.
|
||||
選択カスタムフィールドをオートコンプリートに変更
|
||||
|
||||
= 1.1.2 =
|
||||
Fixed selected custom fields to be read-only.
|
||||
選択カスタムフィールドを読み取り専用表示するよう修正
|
||||
|
||||
= 1.1.1 =
|
||||
Bug fixed: Fixed missing addition of selected attribute of custom field.
|
||||
バグ修正:カスタムフィールドのselected属性の追加漏れ修正
|
||||
|
||||
= 1.1.0 =
|
||||
Fixed mandatory check omissions for custom fields.
|
||||
Fixed existing custom field selection.
|
||||
Set background color in sort list.
|
||||
Fixed refresh button position on sort settings page.
|
||||
Fixed the order of radio buttons for sorting by category, tag, and custom taxonomies to be the same as standard and search.
|
||||
|
||||
カスタムフィールドの必須チェック漏れの修正
|
||||
既存カスタムフィールド選択も可能なよう修正
|
||||
ソートのリストに背景色を設定
|
||||
並べ替え設定ページの更新ボタン位置を修正
|
||||
カテゴリー、タグ、カスタム分類のソート対象選択のラジオボタン並び順を標準、検索と同一になるよう修正
|
||||
|
||||
= 1.0.1 =
|
||||
Add custom posts to search sort.
|
||||
検索のソート対象にカスタム投稿を追加
|
||||
|
||||
= 1.0.0 =
|
||||
Initial working version.
|
||||
First lease.
|
||||
初回リリース
|
||||
|
||||
== Upgrade Notice ==
|
||||
No information
|
||||
+92
-88
@@ -1,122 +1,126 @@
|
||||
<?php
|
||||
$submit_type = APOP_UI::input_post_filter( 'submit_type', 'str' );
|
||||
$submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
|
||||
?>
|
||||
<div class="post-setting-box">
|
||||
<h2>並べ替え</h2>
|
||||
<div class="post-setting-box <?php _e( 'apop-lang-en', APOP_DOMAIN ); ?>">
|
||||
<h2><?php _e( 'Sorting', APOP_DOMAIN ); ?></h2>
|
||||
<nav class="post-order-nav">
|
||||
<ul>
|
||||
<li class="en">通常</li>
|
||||
<li>検索</li>
|
||||
<li>カテゴリー</li>
|
||||
<li>タグ</li>
|
||||
<li>カスタム分類</li>
|
||||
<li class="en"><?php _e( 'Your latest posts', APOP_DOMAIN ); ?></li>
|
||||
<li><?php _e( 'Search', APOP_DOMAIN ); ?></li>
|
||||
<li><?php _e( 'Category', APOP_DOMAIN ); ?></li>
|
||||
<li><?php _e( 'Tag', APOP_DOMAIN ); ?></li>
|
||||
<li><?php _e( 'Custom taxonomy', APOP_DOMAIN ); ?></li>
|
||||
<li><?php _e( 'Custom posts', APOP_DOMAIN ); ?></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="post-order-box-outer" data-submit_type="<?php echo $submit_type; ?>">
|
||||
<div class="post-order-box">
|
||||
<div class="list-orders-outer">
|
||||
<div class="list-orders-inner">
|
||||
<form action="" method="post">
|
||||
<h3>通常</h3>
|
||||
<?php wp_nonce_field( 'sh_options' ); ?>
|
||||
<form action="" method="post">
|
||||
<div class="post-order-box-outer">
|
||||
<?php wp_nonce_field( 'sh_options' ); ?>
|
||||
<input id="apop_submit_type" type="hidden" name="apop_submit_type"
|
||||
value="<?php echo esc_attr( $submit_type ); ?>">
|
||||
<!-- 最新の投稿の設定 -->
|
||||
<div class="post-order-box">
|
||||
<div class="list-orders-outer">
|
||||
<div class="list-orders-inner">
|
||||
<h3><?php _e( 'Your latest posts / Settings - Reading Settings', APOP_DOMAIN ); ?></h3>
|
||||
<?php
|
||||
$order_target_type = '_apop_normal_order';
|
||||
$order_target = APOP_UI::get_order_type( $order_target_type );
|
||||
?>
|
||||
<?php include APOP_PLUGIN_PATH . 'template/order_parts_menu.php'; ?>
|
||||
<hr>
|
||||
<p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p>
|
||||
<div class="sort_box">
|
||||
<?php list( $list, $alert ) = APOP_UI::create_search_normal_list( 'normal' ); ?>
|
||||
<?php echo $alert; ?>
|
||||
<h4>有効</h4>
|
||||
<ul class="post-order-list search_normal_sort">
|
||||
<?php echo $list; ?>
|
||||
</ul>
|
||||
<div class="disable_box">
|
||||
<h4>無効</h4>
|
||||
<ul class="disable_normal_list"></ul>
|
||||
<div class="enable-box">
|
||||
<h4><?php _e( 'Enabled', APOP_DOMAIN ); ?></h4>
|
||||
<ul class="post-order-list search-normal-sort">
|
||||
<?php APOP_UI::create_search_normal_list( 'normal' ); ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="disable-box">
|
||||
<h4><?php _e( 'Disabled', APOP_DOMAIN ); ?></h4>
|
||||
<ul class="disable-normal-list"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sort_box">
|
||||
<?php echo APOP_UI::none_registered_alert_msg(); ?>
|
||||
<ul class="post-order-list">
|
||||
<?php echo APOP_UI::get_all_search_normal_posts( 'normal' ); ?>
|
||||
<ul class="post-order-list drag-sort">
|
||||
<?php APOP_UI::get_all_search_normal_posts( 'normal' ); ?>
|
||||
</ul>
|
||||
</div>
|
||||
<input type="hidden" name="submit_type" value="0">
|
||||
<p class="submit post-order"><input type="submit" name="Submit" class="button-primary"
|
||||
value="変更を保存"/></p>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="post-order-box">
|
||||
<div class="list-orders-outer">
|
||||
<div class="list-orders-inner">
|
||||
<form action="" method="post">
|
||||
<h3>検索</h3>
|
||||
<?php wp_nonce_field( 'sh_options' ); ?>
|
||||
<!-- 検索の設定 -->
|
||||
<div class="post-order-box">
|
||||
<div class="list-orders-outer">
|
||||
<div class="list-orders-inner">
|
||||
<h3><?php _e( 'Search', APOP_DOMAIN ); ?></h3>
|
||||
<?php
|
||||
$order_target_type = '_apop_search_order';
|
||||
$order_target = APOP_UI::get_order_type( $order_target_type );
|
||||
?>
|
||||
<?php include APOP_PLUGIN_PATH . 'template/order_parts_menu.php'; ?>
|
||||
<hr>
|
||||
<p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p>
|
||||
<div class="sort_box">
|
||||
<?php list( $list, $alert ) = APOP_UI::create_search_normal_list( 'search' ); ?>
|
||||
<?php echo $alert; ?>
|
||||
<h4>有効</h4>
|
||||
<ul class="post-order-list search_normal_sort">
|
||||
<?php echo $list; ?>
|
||||
</ul>
|
||||
<div class="disable_box">
|
||||
<h4>無効</h4>
|
||||
<ul class="disable_normal_list"></ul>
|
||||
<div class="enable-box">
|
||||
<h4><?php _e( 'Enabled', APOP_DOMAIN ); ?></h4>
|
||||
<ul class="post-order-list search-normal-sort">
|
||||
<?php APOP_UI::create_search_normal_list( 'search' ); ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="disable-box">
|
||||
<h4><?php _e( 'Disabled', APOP_DOMAIN ); ?></h4>
|
||||
<ul class="disable-normal-list"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sort_box">
|
||||
<?php echo APOP_UI::none_registered_alert_msg(); ?>
|
||||
<ul class="post-order-list">
|
||||
<?php echo APOP_UI::get_all_search_normal_posts( 'search' ); ?>
|
||||
<ul class="post-order-list drag-sort">
|
||||
<?php APOP_UI::get_all_search_normal_posts( 'search' ); ?>
|
||||
</ul>
|
||||
</div>
|
||||
<input type="hidden" name="submit_type" value="1">
|
||||
<p class="submit post-order"><input type="submit" name="Submit" class="button-primary"
|
||||
value="変更を保存"/></p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- カテゴリーの設定 -->
|
||||
<div class="post-order-box">
|
||||
<div class="tax_sort_box">
|
||||
<?php
|
||||
$tax_lists = array( 'category' => APOP_UI::get_cat_tag_list( 'cat', 'category' ) );
|
||||
$tax_title_text = __( 'Category', APOP_DOMAIN );
|
||||
include APOP_PLUGIN_PATH . 'template/order_parts_taxonomy.php';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- タグの設定 -->
|
||||
<div class="post-order-box">
|
||||
<div class="tax_sort_box">
|
||||
<?php
|
||||
$tax_lists = array( 'tag_id' => APOP_UI::get_cat_tag_list( 'tag', 'post_tag' ) );
|
||||
$tax_title_text = __( 'Tag', APOP_DOMAIN );
|
||||
include APOP_PLUGIN_PATH . 'template/order_parts_taxonomy.php';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- カスタム分類の設定 -->
|
||||
<div class="post-order-box">
|
||||
<div class="tax_sort_box">
|
||||
<?php
|
||||
$tax_lists = array( 'taxonomy' => APOP_UI::get_cat_tag_list( 'tax', 'taxonomy' ) );
|
||||
$tax_title_text = __( 'Custom taxonomy', APOP_DOMAIN );
|
||||
include APOP_PLUGIN_PATH . 'template/order_parts_taxonomy.php'; ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- カスタム投稿アーカイブの設定 -->
|
||||
<div class="post-order-box">
|
||||
<div class="tax_sort_box">
|
||||
<?php
|
||||
$custom_posts_lists = APOP_UI::get_enable_custompost_archive();
|
||||
$custom_posts_title_text = __( 'Custom posts', APOP_DOMAIN );
|
||||
include APOP_PLUGIN_PATH . 'template/order_parts_custom_posts.php';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="post-order-box">
|
||||
<div class="tax_sort_box">
|
||||
<?php
|
||||
$tax_lists = array( 'category' => APOP_UI::get_cat_tag_list( 'cat', 'category' ) );
|
||||
$tax_title_text = 'カテゴリー';
|
||||
$submit_type_number = 2;
|
||||
?>
|
||||
<?php include APOP_PLUGIN_PATH . 'template/order_parts_taxonomy.php'; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="post-order-box">
|
||||
<div class="tax_sort_box">
|
||||
<?php
|
||||
$tax_lists = array( 'tag_id' => APOP_UI::get_cat_tag_list( 'tag', 'post_tag' ) );
|
||||
$tax_title_text = 'タグ';
|
||||
$submit_type_number = 3;
|
||||
?>
|
||||
<?php include APOP_PLUGIN_PATH . 'template/order_parts_taxonomy.php'; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="post-order-box">
|
||||
<div class="tax_sort_box">
|
||||
<?php
|
||||
$tax_lists = array( 'taxonomy' => APOP_UI::get_cat_tag_list( 'tax', 'taxonomy' ) );
|
||||
$tax_title_text = 'カスタム分類';
|
||||
$submit_type_number = 4;
|
||||
?>
|
||||
<?php include APOP_PLUGIN_PATH . 'template/order_parts_taxonomy.php'; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="apop-submit"><input type="submit" name="submit" class="button-primary"
|
||||
value="<?php _e( 'Save changes', APOP_DOMAIN ); ?>"/></p>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php if ( isset( $custom_posts_lists, $custom_posts_title_text ) ): ?>
|
||||
<div class="list-orders-outer">
|
||||
<?php if ( count( $custom_posts_lists ) > 0 ): ?>
|
||||
<?php foreach ( $custom_posts_lists as $custom_post ) : ?>
|
||||
<div class="list-orders-inner">
|
||||
<h3><?php echo esc_html( $custom_post['label'] ); ?></h3>
|
||||
<?php
|
||||
$order_target_data = get_option( '_apop_custompost_archive_sort_type' );
|
||||
if ( isset( $order_target_data[ $custom_post['slug'] ] ) ) {
|
||||
$order_target = $order_target_data[ $custom_post['slug'] ];
|
||||
} else {
|
||||
$order_target = 2;
|
||||
}
|
||||
?>
|
||||
<!-- ソートタイプ -->
|
||||
<ul class="sort-menu-list"
|
||||
data-order_target="<?php echo esc_attr( $order_target ); ?>">
|
||||
<li>
|
||||
<label>
|
||||
<input class="sort_menu" type="radio"
|
||||
name="_apop_custompost_archive_sort_type[<?php echo esc_attr( $custom_post['slug'] ); ?>]"
|
||||
value="2"<?php checked( $order_target, 2 ); ?>><?php _e( 'Standard + custom field sort', APOP_DOMAIN ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input class="sort_menu" type="radio"
|
||||
name="_apop_custompost_archive_sort_type[<?php echo esc_attr( $custom_post['slug'] ); ?>]"
|
||||
value="1"<?php checked( $order_target, 1 ); ?>><?php _e( 'Drag sort', APOP_DOMAIN ); ?>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="sort_box">
|
||||
<p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p>
|
||||
<ul class="post-order-list drag-sort">
|
||||
<?php echo APOP_UI::create_custompost_archive_order_list( $custom_post['slug'] ); ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="sort_box">
|
||||
<p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p>
|
||||
<div class="enable-box">
|
||||
<h4><?php _e( 'Enabled', APOP_DOMAIN ); ?></h4>
|
||||
<ul class="post-order-list search-normal-sort">
|
||||
<?php APOP_UI::create_custompost_archive_normal_list( $custom_post['slug'] ); ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="disable-box">
|
||||
<h4><?php _e( 'Disabled', APOP_DOMAIN ); ?></h4>
|
||||
<ul class="disable-normal-list"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<p class="no-registered-exp"><?php _e( 'No', APOP_DOMAIN ); ?><?php echo esc_html( $custom_posts_title_text . ' ' ); ?><?php _e( 'has been selected.', APOP_DOMAIN ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif;
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php if ( isset( $order_target, $order_target_type ) ): ?>
|
||||
<ul class="sort_menu_list"
|
||||
data-order_target="<?php echo $order_target; ?>">
|
||||
<ul class="sort-menu-list"
|
||||
data-order_target="<?php echo esc_attr( $order_target ); ?>">
|
||||
<li><label>
|
||||
<input class="sort_menu" type="radio" name="<?php echo $order_target_type; ?>"
|
||||
value="1"<?php checked( $order_target, 1 ); ?>>標準+カスタムフィールドソート</label></li>
|
||||
<input class="sort_menu" type="radio" name="<?php echo esc_attr( $order_target_type ); ?>"
|
||||
value="1"<?php checked( $order_target, 1 ); ?>><?php _e('Standard + custom field sort', APOP_DOMAIN); ?></label></li>
|
||||
<li><label>
|
||||
<input class="sort_menu" type="radio" name="<?php echo $order_target_type; ?>"
|
||||
value="2"<?php checked( $order_target, 2 ); ?>>ドラッグソート</label></li>
|
||||
<input class="sort_menu" type="radio" name="<?php echo esc_attr( $order_target_type ); ?>"
|
||||
value="2"<?php checked( $order_target, 2 ); ?>><?php _e('Drag sort', APOP_DOMAIN); ?></label></li>
|
||||
</ul>
|
||||
<?php endif;
|
||||
@@ -1,64 +1,60 @@
|
||||
<?php if ( isset( $tax_lists, $tax_title_text, $submit_type_number ) ): ?>
|
||||
<?php if ( isset( $tax_lists, $tax_title_text ) ): ?>
|
||||
<?php foreach ( $tax_lists as $tax_key => $tax_list ) : ?>
|
||||
<div class="list-orders-outer">
|
||||
<?php if ( count( $tax_list ) > 0 ): ?>
|
||||
<?php echo APOP_UI::none_registered_alert_msg(); ?>
|
||||
<?php foreach ( $tax_list as $tax_data ): ?>
|
||||
<div class="list-orders-inner">
|
||||
<form action="" method="post">
|
||||
<?php wp_nonce_field( 'sh_options' ); ?>
|
||||
<h3><?php echo $tax_data->name; ?></h3>
|
||||
<?php
|
||||
$order_target_data = get_option( '_apop_tax_sort_type' );
|
||||
if ( isset( $order_target_data[ $tax_data->term_id ] ) ) {
|
||||
$order_target = $order_target_data[ $tax_data->term_id ];
|
||||
} else {
|
||||
$order_target = 1;
|
||||
}
|
||||
?>
|
||||
<ul class="sort_menu_list"
|
||||
data-order_target="<?php echo $order_target; ?>">
|
||||
<li>
|
||||
<label>
|
||||
<input class="sort_menu" type="radio"
|
||||
name="_apop_tax_sort_type[<?php echo $tax_data->term_id; ?>]"
|
||||
value="1"<?php checked( $order_target, 1 ); ?>>ドラッグソート</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input class="sort_menu" type="radio"
|
||||
name="_apop_tax_sort_type[<?php echo $tax_data->term_id; ?>]"
|
||||
value="2"<?php checked( $order_target, 2 ); ?>>標準+カスタムフィールドソート</label>
|
||||
</li>
|
||||
</ul>
|
||||
<h3><?php echo esc_html( $tax_data->name ); ?></h3>
|
||||
<?php
|
||||
$order_target_data = get_option( '_apop_tax_sort_type' );
|
||||
if ( isset( $order_target_data[ $tax_data->term_id ] ) ) {
|
||||
$order_target = $order_target_data[ $tax_data->term_id ];
|
||||
} else {
|
||||
$order_target = 2;
|
||||
}
|
||||
?>
|
||||
<ul class="sort-menu-list"
|
||||
data-order_target="<?php echo esc_attr( $order_target ); ?>">
|
||||
<li>
|
||||
<label>
|
||||
<input class="sort_menu" type="radio"
|
||||
name="_apop_tax_sort_type[<?php echo esc_attr( $tax_data->term_id ); ?>]"
|
||||
value="2"<?php checked( $order_target, 2 ); ?>><?php _e( 'Standard + custom field sort', APOP_DOMAIN ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input class="sort_menu" type="radio"
|
||||
name="_apop_tax_sort_type[<?php echo esc_attr( $tax_data->term_id ); ?>]"
|
||||
value="1"<?php checked( $order_target, 1 ); ?>><?php _e( 'Drag sort', APOP_DOMAIN ); ?>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="sort_box">
|
||||
<ul class="post-order-list">
|
||||
<?php echo APOP_UI::create_order_list( $tax_data, $tax_key ); ?>
|
||||
<div class="sort_box">
|
||||
<p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p>
|
||||
<ul class="post-order-list drag-sort">
|
||||
<?php echo APOP_UI::create_order_list( $tax_data, $tax_key ); ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="sort_box">
|
||||
<p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p>
|
||||
<div class="enable-box">
|
||||
<h4><?php _e( 'Enabled', APOP_DOMAIN ); ?></h4>
|
||||
<ul class="post-order-list search-normal-sort">
|
||||
<?php APOP_UI::create_search_normal_list( 'tax', $tax_data->term_id ); ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="sort_box">
|
||||
<?php list( $list, $alert ) = APOP_UI::create_search_normal_list( 'tax', $tax_data->term_id ); ?>
|
||||
<?php echo $alert; ?>
|
||||
<h4>有効</h4>
|
||||
<ul class="post-order-list search_normal_sort">
|
||||
<?php echo $list; ?>
|
||||
</ul>
|
||||
<div class="disable_box">
|
||||
<h4>無効</h4>
|
||||
<ul class="disable_normal_list"></ul>
|
||||
</div>
|
||||
<div class="disable-box">
|
||||
<h4><?php _e( 'Disabled', APOP_DOMAIN ); ?></h4>
|
||||
<ul class="disable-normal-list"></ul>
|
||||
</div>
|
||||
<input type="hidden" name="submit_type" value="<?php echo $submit_type_number; ?>">
|
||||
<p class="submit post-order"><input type="submit" name="Submit"
|
||||
class="button-primary"
|
||||
value="変更を保存"/></p>
|
||||
<input type="hidden" name="sort_type[cat]" value="1">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<?php echo APOP_UI::create_none_select_msg( $tax_title_text ); ?>
|
||||
<p class="no-registered-exp"><?php _e( 'No', APOP_DOMAIN ); ?> <?php echo esc_html( $tax_title_text . ' ' ); ?><?php _e( 'has been selected.', APOP_DOMAIN ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
+21
-20
@@ -1,36 +1,35 @@
|
||||
<div class="post-setting-box">
|
||||
<form action="" method="post">
|
||||
<?php
|
||||
wp_nonce_field( 'sh_options' );
|
||||
$opt_per_page = get_option( '_apop_per_page' );
|
||||
$default_per_page = get_option( 'posts_per_page' );
|
||||
?>
|
||||
<h2>設定</h2>
|
||||
<table class="form-table">
|
||||
<?php wp_nonce_field( 'sh_options' ); ?>
|
||||
<h2><?php _e( 'Settings', APOP_DOMAIN ); ?></h2>
|
||||
<table class="form-table apop-form-table">
|
||||
<tr>
|
||||
<th scope="row">全体設定</th>
|
||||
<th scope="row"><?php _e( 'Global settings', APOP_DOMAIN ); ?></th>
|
||||
<td>
|
||||
<dl class="apop_setting_list">
|
||||
<dt>1ページ表示件数</dt>
|
||||
<dd><?php $per_page_data = APOP_UI::create_cat_per_page( $opt_per_page, 'search' ); ?>
|
||||
<dl class="apop-setting-list">
|
||||
<dt><?php _e( 'Displayed per page', APOP_DOMAIN ); ?></dt>
|
||||
<dd><?php $per_page_data = APOP_UI::create_cat_per_page( get_option( '_apop_per_page' ), 'search' ); ?>
|
||||
<ul>
|
||||
<li>
|
||||
<label>
|
||||
<input class="per_page_search" type="radio" name="_apop_per_page[search]"
|
||||
value="default"<?php checked( $per_page_data['_per_page'], 'default' ); ?>>表示設定に従う(<?php echo $default_per_page; ?>
|
||||
件)</label>
|
||||
value="default"<?php checked( $per_page_data['_per_page'], 'default' ); ?>><?php _e( 'Follow display settings', APOP_DOMAIN ); ?>
|
||||
(<?php echo esc_html( get_option( 'posts_per_page' ) ); ?>
|
||||
<?php _e( 'Posts', APOP_DOMAIN ); ?>)</label>
|
||||
</li>
|
||||
<li><label>
|
||||
<input class="per_page_search" type="radio" name="_apop_per_page[search]"
|
||||
value="-1"<?php checked( $per_page_data['_per_page'], '-1' ); ?>>全件</label>
|
||||
value="-1"<?php checked( $per_page_data['_per_page'], '-1' ); ?>><?php _e( 'All posts', APOP_DOMAIN ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label><input class="per_page_search" type="radio"
|
||||
name="_apop_per_page[search]"
|
||||
value=""<?php echo $per_page_data['_checked']; ?>>表示数設定
|
||||
value="" <?php echo esc_attr( $per_page_data['_checked'] ); ?>><?php _e( 'Set the number posts', APOP_DOMAIN ); ?>
|
||||
<input class="per_page_search_input" type="text"
|
||||
name="_apop_per_page[search]"
|
||||
value="<?php echo $per_page_data['_per_page_num']; ?>" required>
|
||||
value="<?php echo esc_attr( $per_page_data['_per_page_num'] ); ?>"
|
||||
required>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -38,10 +37,12 @@
|
||||
</dl>
|
||||
</td>
|
||||
</tr>
|
||||
<?php APOP_UI::disp_tax_setting( 'category', 'カテゴリー', '_apop_cat_order' ); ?>
|
||||
<?php APOP_UI::disp_tax_setting( 'post_tag', 'タグ', '_apop_tag_order' ); ?>
|
||||
<?php APOP_UI::disp_tax_setting( 'taxonomy', 'カスタム分類', '_apop_tax_order' ); ?>
|
||||
<?php APOP_UI::disp_tax_setting( 'category', __( 'Categories setting', APOP_DOMAIN ), '_apop_cat_order' ); ?>
|
||||
<?php APOP_UI::disp_tax_setting( 'post_tag', __( 'Tags setting', APOP_DOMAIN ), '_apop_tag_order' ); ?>
|
||||
<?php APOP_UI::disp_tax_setting( 'taxonomy', __( 'Custom Taxonomies setting', APOP_DOMAIN ), '_apop_tax_order' ); ?>
|
||||
<?php APOP_UI::disp_customposts_setting( 'custompost_archive', __( 'Custom Posts Archive setting', APOP_DOMAIN ), '_apop_custompost_archive_order' ); ?>
|
||||
</table>
|
||||
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/>
|
||||
<p class="submit"><input type="submit" name="Submit" class="button-primary"
|
||||
value="<?php _e( 'Save changes', APOP_DOMAIN ); ?>"/>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php if ( isset( $custom_post_data, $order_name, $order ) ): ?>
|
||||
<dl class="apop-setting-list">
|
||||
<dt><?php _e( 'Targets', APOP_DOMAIN ); ?></dt>
|
||||
<dd>
|
||||
<ul class="order-setting-list">
|
||||
<?php foreach ( $custom_post_data as $custom_post_datum => $label ): ?>
|
||||
<?php
|
||||
$opt_cat = get_option( $order_name );
|
||||
$check_slug = $opt_cat['target_post'][ $custom_post_datum ] ?? '';
|
||||
?>
|
||||
<li>
|
||||
<div class="select_cat">
|
||||
<label>
|
||||
<input type="hidden"
|
||||
name="<?php echo esc_attr( $order_name ); ?>[target_post][<?php echo esc_attr( $custom_post_datum ); ?>]"
|
||||
value="0">
|
||||
<input class="select_cat_checkbox" type="checkbox"
|
||||
name="<?php echo esc_attr( $order_name ); ?>[target_post][<?php echo esc_attr( $custom_post_datum ); ?>]"
|
||||
<?php checked( $check_slug, 1 ); ?>
|
||||
value="1">
|
||||
<?php echo esc_html( $label ); ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php $per_page_data = APOP_UI::create_custom_posts_per_page( get_option( '_apop_per_page' ), $order, $custom_post_datum ); ?>
|
||||
<div class="select-per-page">
|
||||
<ul>
|
||||
<li>
|
||||
<label>
|
||||
<input class="per_page_cat" type="radio"
|
||||
name="_apop_per_page[<?php echo esc_attr($order); ?>][<?php echo esc_attr( $custom_post_datum ); ?>]"
|
||||
value="default"<?php checked( $per_page_data['_per_page'], 'default' ); ?>><?php _e( 'Follow display settings', APOP_DOMAIN ); ?>
|
||||
(<?php echo esc_html( get_option( 'posts_per_page' ) ); ?>
|
||||
<?php _e( 'Posts', APOP_DOMAIN ); ?>)</label>
|
||||
</li>
|
||||
<li><label>
|
||||
<input class="per_page_cat" type="radio"
|
||||
name="_apop_per_page[<?php echo esc_attr( $order ); ?>][<?php echo esc_attr( $custom_post_datum ); ?>]"
|
||||
value="all"<?php checked( $per_page_data['_per_page'], 'all' ); ?>><?php _e( 'Follow global settings', APOP_DOMAIN ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li><label>
|
||||
<input class="per_page_cat" type="radio"
|
||||
name="_apop_per_page[<?php echo esc_attr( $order ); ?>][<?php echo esc_attr( $custom_post_datum ); ?>]"
|
||||
value="-1"<?php checked( $per_page_data['_per_page'], '-1' ); ?>><?php _e( 'All posts', APOP_DOMAIN ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li class="set_number_list">
|
||||
<label><input class="per_page_cat set_number" type="radio"
|
||||
name="_apop_per_page[<?php echo esc_attr( $order ); ?>][<?php echo esc_attr( $custom_post_datum ); ?>]"
|
||||
value=""<?php echo esc_attr( $per_page_data['_checked'] ); ?>><?php _e( 'Set the number posts', APOP_DOMAIN ); ?>
|
||||
<input class="per_page_cat_input" type="text"
|
||||
name="_apop_per_page[<?php echo esc_attr( $order ); ?>][<?php echo esc_attr( $custom_post_datum ); ?>]"
|
||||
value="<?php echo esc_attr( $per_page_data['_per_page_num'] ); ?>"
|
||||
required>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
<?php endif;
|
||||
@@ -1,58 +1,54 @@
|
||||
<?php if ( isset( $tax_data, $order_name, $order_tax ) ): ?>
|
||||
<?php
|
||||
$default_per_page = get_option( 'posts_per_page' );
|
||||
$opt_per_page = get_option( '_apop_per_page' );
|
||||
?>
|
||||
<dl class="apop_setting_list">
|
||||
<dt>対象</dt>
|
||||
<dl class="apop-setting-list">
|
||||
<dt><?php _e('Targets', APOP_DOMAIN); ?></dt>
|
||||
<dd>
|
||||
<ul class="order_setting_list">
|
||||
<ul class="order-setting-list">
|
||||
<?php foreach ( $tax_data as $tax_datum ): ?>
|
||||
<?php
|
||||
$opt_cat = get_option( $order_name );
|
||||
$check_slug = $opt_cat['target_cat'][ $tax_datum->term_id ] ?? '';
|
||||
APOP_UI::is_disp_per_page( $disp, $check_slug );
|
||||
?>
|
||||
<li>
|
||||
<div class="select_cat">
|
||||
<label>
|
||||
<input type="hidden"
|
||||
name="<?php echo $order_name; ?>[target_cat][<?php echo $tax_datum->term_id; ?>]"
|
||||
name="<?php echo esc_attr( $order_name ); ?>[target_cat][<?php echo esc_attr( $tax_datum->term_id ); ?>]"
|
||||
value="0">
|
||||
<input class="select_cat_checkbox" type="checkbox"
|
||||
name="<?php echo $order_name; ?>[target_cat][<?php echo $tax_datum->term_id; ?>]"
|
||||
name="<?php echo esc_attr( $order_name ); ?>[target_cat][<?php echo esc_attr( $tax_datum->term_id ); ?>]"
|
||||
<?php checked( $check_slug, 1 ); ?>
|
||||
value="1">
|
||||
<?php echo $tax_datum->name; ?>
|
||||
<?php echo esc_html( $tax_datum->name ); ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php $per_page_data = APOP_UI::create_tax_per_page( $opt_per_page, $order_tax, $tax_datum->term_id ); ?>
|
||||
<div class="select_per_page">
|
||||
<?php $per_page_data = APOP_UI::create_tax_per_page( get_option( '_apop_per_page' ), $order_tax, $tax_datum->term_id ); ?>
|
||||
<div class="select-per-page">
|
||||
<ul>
|
||||
<li>
|
||||
<label>
|
||||
<input class="per_page_cat" type="radio"
|
||||
name="_apop_per_page[<?php echo $order_tax; ?>][<?php echo $tax_datum->term_id; ?>]"
|
||||
value="default"<?php checked( $per_page_data['_per_page'], 'default' ); ?>>表示設定に従う(<?php echo $default_per_page; ?>
|
||||
件)</label>
|
||||
name="_apop_per_page[<?php echo esc_attr( $order_tax ); ?>][<?php echo esc_attr( $tax_datum->term_id ); ?>]"
|
||||
value="default"<?php checked( $per_page_data['_per_page'], 'default' ); ?>><?php _e( 'Follow display settings', APOP_DOMAIN ); ?>(<?php echo esc_html( get_option( 'posts_per_page' ) ); ?>
|
||||
<?php _e( 'Posts', APOP_DOMAIN ); ?>)</label>
|
||||
</li>
|
||||
<li><label>
|
||||
<input class="per_page_cat" type="radio"
|
||||
name="_apop_per_page[<?php echo $order_tax; ?>][<?php echo $tax_datum->term_id; ?>]"
|
||||
value="all"<?php checked( $per_page_data['_per_page'], 'all' ); ?>>全体設定に従う</label>
|
||||
name="_apop_per_page[<?php echo esc_attr( $order_tax ); ?>][<?php echo esc_attr( $tax_datum->term_id ); ?>]"
|
||||
value="all"<?php checked( $per_page_data['_per_page'], 'all' ); ?>><?php _e( 'Follow global settings', APOP_DOMAIN ); ?></label>
|
||||
</li>
|
||||
<li><label>
|
||||
<input class="per_page_cat" type="radio"
|
||||
name="_apop_per_page[<?php echo $order_tax; ?>][<?php echo $tax_datum->term_id; ?>]"
|
||||
value="-1"<?php checked( $per_page_data['_per_page'], '-1' ); ?>>全件</label>
|
||||
name="_apop_per_page[<?php echo esc_attr( $order_tax ); ?>][<?php echo esc_attr( $tax_datum->term_id ); ?>]"
|
||||
value="-1"<?php checked( $per_page_data['_per_page'], '-1' ); ?>><?php _e( 'All posts', APOP_DOMAIN ); ?></label>
|
||||
</li>
|
||||
<li class="set_number_list">
|
||||
<label><input class="per_page_cat set_number" type="radio"
|
||||
name="_apop_per_page[<?php echo $order_tax; ?>][<?php echo $tax_datum->term_id; ?>]"
|
||||
value=""<?php echo $per_page_data['_checked']; ?>>表示数設定
|
||||
name="_apop_per_page[<?php echo esc_attr( $order_tax ); ?>][<?php echo esc_attr( $tax_datum->term_id ); ?>]"
|
||||
value=""<?php echo esc_attr( $per_page_data['_checked'] ); ?>><?php _e( 'Set the number posts', APOP_DOMAIN ); ?>
|
||||
<input class="per_page_cat_input" type="text"
|
||||
name="_apop_per_page[<?php echo $order_tax; ?>][<?php echo $tax_datum->term_id; ?>]"
|
||||
value="<?php echo $per_page_data['_per_page_num']; ?>" required>
|
||||
name="_apop_per_page[<?php echo esc_attr( $order_tax ); ?>][<?php echo esc_attr( $tax_datum->term_id ); ?>]"
|
||||
value="<?php echo esc_attr( $per_page_data['_per_page_num'] ); ?>"
|
||||
required>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<div class="order_setting_custom_field_box">
|
||||
<?php if ( isset( $this->order_field ) && count( $this->order_field ) > 0 ): ?>
|
||||
<dl class="apop-setting-list-dd">
|
||||
<?php foreach ( $this->order_field as $type => $items ): ?>
|
||||
<dt><?php echo esc_html( $this->labels[ $type ] ); ?></dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<?php foreach ( $items as $idx => $item ): ?>
|
||||
<?php if ( ! empty( $item ) ): ?>
|
||||
<?php
|
||||
if ( $this->custom_field_type[ $type ][ $idx ] == '2' ) {
|
||||
$custom_field_prefix = APOP_CUSTOM_FIELD_PREFIX;
|
||||
$disabled = '';
|
||||
$read_only_class = '';
|
||||
} else {
|
||||
$custom_field_prefix = '';
|
||||
$disabled = ' disabled';
|
||||
$read_only_class = __( '* Change from custom field', APOP_DOMAIN );
|
||||
}
|
||||
?>
|
||||
<li>
|
||||
<label><?php echo esc_html( $item ); ?></label>
|
||||
<div class="sort-custom-field-input">
|
||||
<input type="text"
|
||||
name="<?php echo esc_attr( $custom_field_prefix . $item ); ?>"
|
||||
value="<?php echo esc_attr( $this->get_custom_field_data( $item, $custom_field_prefix ) ); ?>"<?php echo esc_attr( $disabled ); ?>/>
|
||||
<?php echo esc_html( $read_only_class ); ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</dd>
|
||||
<?php endforeach; ?>
|
||||
</dl>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -1 +1,2 @@
|
||||
<div id="settings_updated" class="updated notice is-dismissible"><p><strong>設定を保存しました</strong></p></div>
|
||||
<div id="settings_updated" class="updated notice is-dismissible"><p>
|
||||
<strong><?php _e( 'Saved the setting', APOP_DOMAIN ); ?></strong></p></div>
|
||||
|
||||
+27
-26
@@ -5,44 +5,45 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
//通常と検索の表示件数、ソート対象設定等を削除
|
||||
//最新の投稿と検索の表示件数、ソート対象設定等を削除
|
||||
$param_settings = array(
|
||||
'_apop_per_page',
|
||||
'_apop_normal_order',
|
||||
'_apop_search_order',
|
||||
'_apop_tax_sort_type',
|
||||
'_apop_normal_order_param',
|
||||
'_apop_search_order_param',
|
||||
'_apop_normal_order',
|
||||
'_apop_search_order',
|
||||
'_apop_tax_order_param',
|
||||
'_apop_tax_sort_type',
|
||||
'_apop_cat_order',
|
||||
'_apop_tag_order',
|
||||
'_apop_tax_order',
|
||||
'_apop_custompost_archive_order_param',
|
||||
'_apop_custompost_archive_sort_type',
|
||||
'_apop_custompost_archive_order',
|
||||
'_apop_per_page',
|
||||
);
|
||||
foreach ( $param_settings as $param_setting ) {
|
||||
delete_option( $param_setting );
|
||||
}
|
||||
|
||||
//通常と検索用のカスタム表示順を削除
|
||||
global $wpdb;
|
||||
|
||||
//最新の投稿と検索用のカスタム表示順を削除
|
||||
$option_orders = array(
|
||||
'_apop_post_normal',
|
||||
'_apop_post_search',
|
||||
"'" . '_apop_post_normal' . "'",
|
||||
"'" . '_apop_post_search' . "'",
|
||||
);
|
||||
foreach ( $option_orders as $option_order ) {
|
||||
delete_post_meta_by_key( $option_order );
|
||||
}
|
||||
$stmnt = 'DELETE FROM ' . $wpdb->prefix . 'postmeta WHERE meta_key IN(' . implode( ',', $option_orders ) . ')';
|
||||
$wpdb->query( $stmnt );
|
||||
|
||||
//タクソノミー設定を削除
|
||||
//タクソノミー設定を削除(WEHRE LIKE 'XXX%')
|
||||
$tax_order_settings = array(
|
||||
'_apop_cat_order' => '_apop_post_category_',
|
||||
'_apop_tax_order' => '_apop_post_tax_',
|
||||
'_apop_tag_order' => '_apop_post_post_tag_',
|
||||
|
||||
'_apop_post_category_',
|
||||
'_apop_post_post_tag_',
|
||||
'_apop_post_tax_',
|
||||
'_apop_customposts_',
|
||||
'_apop_postorder_'
|
||||
);
|
||||
foreach ( $tax_order_settings as $post_option => $post_meta ) {
|
||||
$target_tax = get_option( $post_option );
|
||||
foreach ( $target_tax['target_cat'] as $tax_id => $status ) {
|
||||
delete_post_meta_by_key( $post_meta . $tax_id );
|
||||
}
|
||||
delete_option( $post_option );
|
||||
foreach ( $tax_order_settings as $tax_order_setting ) {
|
||||
$stmnt = 'DELETE FROM ' . $wpdb->prefix . 'postmeta WHERE meta_key LIKE ' . "'" . $tax_order_setting . "%'";
|
||||
$wpdb->query( $stmnt );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
if ( ! trait_exists( 'CUSTOMFIELD_SELECT' ) ) {
|
||||
|
||||
trait CUSTOMFIELD_SELECT {
|
||||
|
||||
public function set_custom_field_ajax() {
|
||||
$handle = 'custom_field_ajax';
|
||||
wp_register_script( $handle, APOP_PLUGIN_URL . 'js/custom_field.js', [ 'jquery' ], '', true );
|
||||
$localize = [
|
||||
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'action' => 'set_custom_field',
|
||||
];
|
||||
wp_localize_script( $handle, 'localize', $localize );
|
||||
wp_enqueue_script( $handle );
|
||||
}
|
||||
|
||||
public function set_custom_field() {
|
||||
$param = filter_input( INPUT_GET, 'param', FILTER_DEFAULT );
|
||||
echo json_encode( $this->get_custom_fields_by_param( $param ) );
|
||||
die();
|
||||
}
|
||||
|
||||
private function get_custom_fields_by_param( $param ) {
|
||||
global $wpdb;
|
||||
$stmnt = "SELECT DISTINCT meta_key AS value, meta_key as label FROM $wpdb->postmeta WHERE meta_key LIKE %s AND meta_key NOT LIKE %s";
|
||||
|
||||
return $wpdb->get_results( $wpdb->prepare( $stmnt, $wpdb->esc_like( $param ) . '%', $wpdb->esc_like( '_%' ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if ( ! trait_exists( 'CUSTOMPOSTS' ) ) {
|
||||
|
||||
/**
|
||||
* カスタム投稿アーカイブのソート
|
||||
* Trait CUSTOMPOSTS
|
||||
*/
|
||||
trait CUSTOMPOSTS {
|
||||
|
||||
public static function get_enable_custompost_archive(): array {
|
||||
$opt = get_option( '_apop_custompost_archive_order' );
|
||||
if ( ! isset( $opt['target_post'] ) ) {
|
||||
return array();
|
||||
}
|
||||
$custom_post_list = array();
|
||||
foreach ( $opt['target_post'] as $target => $check ) {
|
||||
if ( $check == '1' ) {
|
||||
$custom_post_list[] = [
|
||||
'label' => get_post_type_object( $target )->label,
|
||||
'slug' => $target,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $custom_post_list;
|
||||
}
|
||||
|
||||
public static function create_custompost_archive_order_list( $slug ): string {
|
||||
$args = array(
|
||||
'posts_per_page' => - 1,
|
||||
'post_type' => array( $slug ),
|
||||
'orderby' => 'meta_value_num',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
self::create_sort_post_list_meta_query( $args, '_apop_customposts_' . $slug );
|
||||
$return_data = get_posts( $args );
|
||||
$list = array();
|
||||
foreach ( $return_data as $key => $target_post ) {
|
||||
$sort_num = $key + 1;
|
||||
$no_order = self::is_sort_custompost_archive_registered( $target_post->ID, $slug ) ? '' : ' no-order';
|
||||
$list[] = '
|
||||
<li class="product-list' . esc_attr( $no_order ) . '">' . '<span class="sort-num-label">' . esc_attr( $sort_num ) . '</span>' . get_the_title( $target_post->ID ) . '
|
||||
<input type="hidden" class="list-order" name="_apop_customposts[' . esc_attr( $slug ) . '][' . esc_attr( $target_post->ID ) . ']" value="' . esc_attr( $sort_num ) . '">
|
||||
</li>';
|
||||
}
|
||||
|
||||
return implode( PHP_EOL, $list );
|
||||
}
|
||||
|
||||
|
||||
private static function is_sort_custompost_archive_registered( $id, $slug ): bool {
|
||||
$post_meta = get_post_meta( $id, '_apop_customposts_' . $slug, true );
|
||||
if ( ! empty( $post_meta ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function create_custompost_archive_normal_list( $slug ) {
|
||||
$name_keys = array(
|
||||
'name_key' => 'apop_custompost_archive_order_param[' . $slug . ']',
|
||||
'get_option_key' => '_apop_custompost_archive_order_param',
|
||||
);
|
||||
$name_key = $name_keys['name_key'];
|
||||
$get_option_key = $name_keys['get_option_key'];
|
||||
$order_param_base = get_option( $get_option_key );
|
||||
$order_param = '';
|
||||
if ( isset( $order_param_base[ $slug ] ) ) {
|
||||
$order_param = $order_param_base[ $slug ];
|
||||
}
|
||||
self::create_normal_sort_list( $name_key, $order_param );
|
||||
}
|
||||
|
||||
private function set_custompost_orderby( $query, $post_type ) {
|
||||
$sort_type = get_option( '_apop_custompost_archive_sort_type' )[ $post_type ];
|
||||
if ( $sort_type == 1 ) {
|
||||
$sort_meta_key = self::set_custompost_sort_meta_key( $post_type );
|
||||
if ( is_null( $sort_meta_key ) ) {
|
||||
$this->set_search_normal_orderby( $query, 'custompost_archive' );
|
||||
} else {
|
||||
$query->set( 'meta_query', self::get_all_post_args( $sort_meta_key ) );
|
||||
$query->set( 'orderby', array( 'meta_value' => 'ASC', ) );
|
||||
}
|
||||
} else {
|
||||
$meta_orderby = self::set_custompost_custom_field_orderby( $post_type );
|
||||
if ( isset( $meta_orderby['meta_query'] ) ) {
|
||||
$query->set( 'meta_query', $meta_orderby['meta_query'] );
|
||||
}
|
||||
if ( isset( $meta_orderby['orderby'] ) ) {
|
||||
$query->set( 'orderby', $meta_orderby['orderby'] );
|
||||
}
|
||||
}
|
||||
$per_page_option_data = self::set_custompost_per_page( $post_type );
|
||||
$query->set( 'posts_per_page', $per_page_option_data );
|
||||
}
|
||||
|
||||
private static function set_custompost_sort_meta_key( $post_type ) {
|
||||
$order_settings = get_option( '_apop_custompost_archive_order' );
|
||||
if ( isset( $order_settings['target_post'][ $post_type ] ) && $order_settings['target_post'][ $post_type ] == 1 ) {
|
||||
return '_apop_customposts_' . $post_type;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function set_custompost_custom_field_orderby( $post_type ): array {
|
||||
$order_param = get_option( '_apop_custompost_archive_order_param' );
|
||||
if ( isset( $order_param[ $post_type ] ) ) {
|
||||
return self::set_custom_field_orderby( $order_param[ $post_type ] );
|
||||
}
|
||||
}
|
||||
|
||||
private static function set_custompost_per_page( $post_type ) {
|
||||
$per_page_option = get_option( '_apop_per_page' );
|
||||
if ( ! $per_page_option ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! isset($per_page_option['custompost_archive'] ) ){
|
||||
return;
|
||||
}
|
||||
|
||||
$per_page_option_data = $per_page_option['custompost_archive'][ $post_type ];
|
||||
if ( ! isset( $per_page_option_data ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $per_page_option_data == 'default' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $per_page_option_data == 'all' ) {
|
||||
if ( $per_page_option['search'] == 'default' ) {
|
||||
return;
|
||||
}
|
||||
$per_page_option_data = $per_page_option['search'];
|
||||
}
|
||||
|
||||
return $per_page_option_data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+81
-180
@@ -12,6 +12,11 @@ if ( ! trait_exists( 'APOP_ORDER_SETTING' ) ) {
|
||||
add_action( 'pre_get_posts', array( $this, 'apop_posts_per_page' ), 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* ソートのクエリを生成
|
||||
*
|
||||
* @param $query
|
||||
*/
|
||||
public function apop_posts_per_page( $query ) {
|
||||
|
||||
if ( is_admin() || ! $query->is_main_query() ) {
|
||||
@@ -26,6 +31,13 @@ if ( ! trait_exists( 'APOP_ORDER_SETTING' ) ) {
|
||||
$this->set_search_normal_orderby( $query, 'search' );
|
||||
}
|
||||
|
||||
if ( is_post_type_archive() ) {
|
||||
$post_type = get_query_var( 'post_type' );
|
||||
if ( $post_type ) {
|
||||
$this->set_custompost_orderby( $query, $post_type );
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_category() ) {
|
||||
$cat = get_category_by_slug( $query->query_vars['category_name'] );
|
||||
if ( isset( $cat->term_id ) ) {
|
||||
@@ -47,28 +59,9 @@ if ( ! trait_exists( 'APOP_ORDER_SETTING' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
private static function set_per_page( $target, $id = null ) {
|
||||
$per_page_option = get_option( '_apop_per_page' );
|
||||
if ( is_null( $id ) ) {
|
||||
$per_page_option_data = $per_page_option[ $target ];
|
||||
} else {
|
||||
$per_page_target = $target == 'tax' ? 'taxonomy' : $target;
|
||||
$per_page_option_data = $per_page_option[ $per_page_target ][ $id ];
|
||||
}
|
||||
|
||||
if ( ! isset( $per_page_option_data ) ) {
|
||||
return;
|
||||
}
|
||||
if ( $per_page_option_data == 'default' ) {
|
||||
return;
|
||||
}
|
||||
if ( $per_page_option_data == 'all' ) {
|
||||
$per_page_option_data = $per_page_option['search'];;
|
||||
}
|
||||
|
||||
return $per_page_option_data;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// 最近の投稿と検索のソートのクエリ生成
|
||||
//-----------------------------------------------------------
|
||||
private function set_search_normal_orderby( $query, $type ) {
|
||||
$apop_order = get_option( '_apop_' . $type . '_order' ) ?? 1;
|
||||
if ( $apop_order == 2 ) {
|
||||
@@ -88,11 +81,43 @@ if ( ! trait_exists( 'APOP_ORDER_SETTING' ) ) {
|
||||
$query->set( 'posts_per_page', $per_page_option_data );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
//標準ソート+カスタムフィールドソートのカスタムフィールドデータ取得
|
||||
//-----------------------------------------------------------
|
||||
private static function set_custom_field_orderby( $apop_order_param ): array {
|
||||
if ( ! $apop_order_param ) {
|
||||
return array();
|
||||
}
|
||||
$sort_param = array( 1 => 'ASC', 2 => 'DESC' );
|
||||
$meta_query = array( 'relation' => 'AND' );
|
||||
$orderby = null;
|
||||
foreach ( $apop_order_param as $order_col => $orders ) {
|
||||
if ( $orders['use'] == 1 ) {
|
||||
if ( strpos( $order_col, 'custom_field' ) !== false ) {
|
||||
list( $sort_meta_key, $type ) = self::set_custom_filed_sort( $orderby, $order_col, $orders, $sort_param );
|
||||
$meta_query[] = self::get_all_post_args( $sort_meta_key, $type );
|
||||
} else {
|
||||
if ( isset( $orders['sort'] ) ) {
|
||||
$orderby[ $order_col ] = $sort_param[ $orders['sort'] ];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'meta_query' => $meta_query,
|
||||
'orderby' => $orderby
|
||||
);
|
||||
}
|
||||
|
||||
private static function set_custom_filed_sort( &$orderby, $order_col, $orders, $sort_param ): array {
|
||||
if ( strpos( $order_col, 'custom_field' ) !== false ) {
|
||||
$meta_key = $orders['field']['meta_key'];
|
||||
$orderby_sort = $orders['sort'];
|
||||
$type = 'CHAR';
|
||||
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';
|
||||
} elseif ( $orders['field']['value_type'] == 'meta_value' ) {
|
||||
@@ -100,65 +125,17 @@ if ( ! trait_exists( 'APOP_ORDER_SETTING' ) ) {
|
||||
} elseif ( $orders['field']['value_type'] == 'meta_date' ) {
|
||||
$type = 'DATE';
|
||||
}
|
||||
$orderby[ $meta_key ] = $sort_param[ $orderby_sort ];
|
||||
if ( isset( $orders['sort'] ) ) {
|
||||
$orderby[ $meta_key ] = $sort_param[ $orders['sort'] ];
|
||||
}
|
||||
|
||||
return array( $meta_key, $type );
|
||||
}
|
||||
}
|
||||
|
||||
private function set_orderby( $query, $id, $target, $order_key ) {
|
||||
$sort_type = self::get_tax_sort_type( $id );
|
||||
if ( $sort_type == 1 ) {
|
||||
$sort_meta_key = self::set_tax_sort_meta_key( $id, $target, $order_key );
|
||||
if ( is_null( $sort_meta_key ) ) {
|
||||
$this->set_search_normal_orderby( $query, 'normal' );
|
||||
} else {
|
||||
$query->set( 'meta_query', self::get_all_post_args( $sort_meta_key ) );
|
||||
$query->set( 'orderby', array( 'meta_value' => 'ASC', ) );
|
||||
}
|
||||
} else {
|
||||
$meta_orderby = self::set_tax_custom_field_orderby( $id );
|
||||
if ( isset( $meta_orderby['meta_query'] ) ) {
|
||||
$query->set( 'meta_query', $meta_orderby['meta_query'] );
|
||||
}
|
||||
if ( isset( $meta_orderby['orderby'] ) ) {
|
||||
$query->set( 'orderby', $meta_orderby['orderby'] );
|
||||
}
|
||||
}
|
||||
$per_page_option_data = self::set_per_page( self::get_per_page_tag( $target ), $id );
|
||||
$query->set( 'posts_per_page', $per_page_option_data );
|
||||
}
|
||||
|
||||
private static function get_tax_sort_type( $id ) {
|
||||
$sort_type = get_option( '_apop_tax_sort_type' );
|
||||
|
||||
return $sort_type[ $id ] ?? 1;
|
||||
}
|
||||
|
||||
private static function set_tax_sort_meta_key( $id, $target, $order_key ) {
|
||||
$order_settings = get_option( '_apop_' . $order_key . '_order' );
|
||||
if ( isset( $order_settings['target_cat'][ $id ] ) && $order_settings['target_cat'][ $id ] == 1 ) {
|
||||
return '_apop_post_' . $target . '_' . $id;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function set_tax_custom_field_orderby( $id ): array {
|
||||
$tax_order_param = get_option( '_apop_tax_order_param' );
|
||||
if ( isset( $tax_order_param[ $id ] ) ) {
|
||||
return self::set_custom_field_orderby( $tax_order_param[ $id ] );
|
||||
}
|
||||
}
|
||||
|
||||
private static function get_per_page_tag( $target ) {
|
||||
if ( $target == 'post_tag' ) {
|
||||
return 'tag';
|
||||
}
|
||||
|
||||
return $target;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// ソートキーが無くともデータを抽出するようEXISTSとNOT EXISTSをリレーションする
|
||||
//-----------------------------------------------------------
|
||||
private static function get_all_post_args( $sort_meta_key, $type = 'numeric' ): array {
|
||||
return array(
|
||||
'relation' => 'OR',
|
||||
@@ -175,116 +152,40 @@ if ( ! trait_exists( 'APOP_ORDER_SETTING' ) ) {
|
||||
);
|
||||
}
|
||||
|
||||
private static function set_custom_field_orderby( $apop_order_param ): array {
|
||||
if ( ! $apop_order_param ) {
|
||||
return array();
|
||||
}
|
||||
$sort_param = array( 1 => 'ASC', 2 => 'DESC' );
|
||||
$meta_query = array( 'relation' => 'AND' );
|
||||
$orderby = null;
|
||||
foreach ( $apop_order_param as $order_col => $orders ) {
|
||||
if ( $orders['use'] == 1 ) {
|
||||
if ( strpos( $order_col, 'custom_field' ) !== false ) {
|
||||
list( $sort_meta_key, $type ) = self::set_custom_filed_sort( $orderby, $order_col, $orders, $sort_param );
|
||||
$meta_query[] = self::get_all_post_args( $sort_meta_key, $type );
|
||||
} else {
|
||||
$orderby[ $order_col ] = $sort_param[ $orders['sort'] ];
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------
|
||||
// 1ページ表示件数の取得
|
||||
//-----------------------------------------------------------
|
||||
private static function set_per_page( $target, $id = null ) {
|
||||
$per_page_option = get_option( '_apop_per_page' );
|
||||
|
||||
if ( ! $per_page_option ) {
|
||||
return;
|
||||
}
|
||||
|
||||
return array(
|
||||
'meta_query' => $meta_query,
|
||||
'orderby' => $orderby
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通常ページの1ページ表示件数を取得する
|
||||
* APOP::orderby_normal()
|
||||
* @return array|null
|
||||
*/
|
||||
public static function orderby_normal() {
|
||||
$apop_order = get_option( '_apop_normal_order' ) ?? 1;
|
||||
if ( $apop_order == 2 ) {
|
||||
return array(
|
||||
'meta_query' => self::get_all_post_args( '_apop_normal_order' ),
|
||||
'orderby' => array( 'meta_value_num' => 'ASC' ),
|
||||
);
|
||||
if ( is_null( $id ) ) {
|
||||
$per_page_option_data = $per_page_option[ $target ];
|
||||
} else {
|
||||
$apop_order_param = get_option( '_apop_normal_order_param' );
|
||||
$meta_orderby = self::set_custom_field_orderby( $apop_order_param );
|
||||
if ( is_null( $meta_orderby['meta_query'] ) ) {
|
||||
unset( $meta_orderby['meta_query'] );
|
||||
}
|
||||
if ( is_null( $meta_orderby['orderby'] ) ) {
|
||||
unset( $meta_orderby['orderby'] );
|
||||
}
|
||||
|
||||
return $meta_orderby;
|
||||
$per_page_target = $target == 'tax' ? 'taxonomy' : $target;
|
||||
$per_page_option_data = $per_page_option[ $per_page_target ][ $id ];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* カテゴリー、タグ、カスタム分類の1ページ表示件数を取得する
|
||||
* APOP::orderby_tax([ID, TARGET], );
|
||||
* [TARGET]
|
||||
* cat
|
||||
* tag
|
||||
* tax
|
||||
*
|
||||
* @param $id
|
||||
* @param $target
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function orderby_tax( $id, $target ) {
|
||||
$sort_type = self::get_tax_sort_type( $id );
|
||||
if ( $sort_type == 1 ) {
|
||||
$order_key = $target;
|
||||
if ( $target == 'tag' ) {
|
||||
$target == 'post_tag';
|
||||
} elseif ( $target = 'cat' ) {
|
||||
$target == 'category';
|
||||
}
|
||||
$sort_meta_key = self::set_tax_sort_meta_key( $id, $target, $order_key );
|
||||
if ( is_null( $sort_meta_key ) ) {
|
||||
return self::orderby_normal();
|
||||
} else {
|
||||
return array(
|
||||
'meta_query' => self::get_all_post_args( $sort_meta_key ),
|
||||
'orderby' => array( 'meta_value_num' => 'ASC' ),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return self::set_tax_custom_field_orderby( $id );
|
||||
if ( ! isset( $per_page_option_data ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 1ページ表示件数を取得する
|
||||
* APOP::per_page(ID, [TARGET]);
|
||||
* [TARGET]
|
||||
* cat
|
||||
* tag
|
||||
* tax
|
||||
*
|
||||
* @param string $target
|
||||
* @param null $id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function per_page( $id = null, string $target = 'search' ) {
|
||||
if ( $target == 'cat' ) {
|
||||
$target = 'category';
|
||||
if ( $per_page_option_data == 'default' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
return array( 'posts_per_page' => self::set_per_page( $target, $id ) );
|
||||
if ( $per_page_option_data == 'all' ) {
|
||||
if ( $per_page_option['search'] == 'default' ) {
|
||||
return;
|
||||
}
|
||||
$per_page_option_data = $per_page_option['search'];
|
||||
}
|
||||
|
||||
return $per_page_option_data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if ( ! trait_exists( 'APOP_OUTPUT' ) ) {
|
||||
/**
|
||||
* TODO: 出力用のコード
|
||||
* Trait APOP_OUTPUT
|
||||
*/
|
||||
trait APOP_OUTPUT {
|
||||
/**
|
||||
*
|
||||
* 1ページ表示件数を取得する
|
||||
* APOP::per_page(ID, [TARGET]);
|
||||
* [TARGET]
|
||||
* cat
|
||||
* tag
|
||||
* tax
|
||||
*
|
||||
* @param string $target
|
||||
* @param null $id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function per_page( $id = null, string $target = 'search' ) {
|
||||
if ( $target == 'cat' ) {
|
||||
$target = 'category';
|
||||
}
|
||||
|
||||
return array( 'posts_per_page' => self::set_per_page( $target, $id ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 最新の投稿ページのソートを取得する
|
||||
* APOP::orderby_normal()
|
||||
* @return array|null
|
||||
*/
|
||||
public static function orderby_normal() {
|
||||
$apop_order = get_option( '_apop_normal_order' ) ?? 1;
|
||||
if ( $apop_order == 2 ) {
|
||||
return array(
|
||||
'meta_query' => self::get_all_post_args( '_apop_normal_order' ),
|
||||
'orderby' => array( 'meta_value_num' => 'ASC' ),
|
||||
);
|
||||
} else {
|
||||
$apop_order_param = get_option( '_apop_normal_order_param' );
|
||||
$meta_orderby = self::set_custom_field_orderby( $apop_order_param );
|
||||
if ( is_null( $meta_orderby['meta_query'] ) ) {
|
||||
unset( $meta_orderby['meta_query'] );
|
||||
}
|
||||
if ( is_null( $meta_orderby['orderby'] ) ) {
|
||||
unset( $meta_orderby['orderby'] );
|
||||
}
|
||||
|
||||
return $meta_orderby;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* カテゴリー、タグ、カスタム分類のソートを取得する
|
||||
* APOP::orderby_tax([ID, TARGET], );
|
||||
* [TARGET]
|
||||
* cat
|
||||
* tag
|
||||
* tax
|
||||
*
|
||||
* @param $id
|
||||
* @param $target
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function orderby_tax( $id, $target ) {
|
||||
$sort_type = self::get_tax_sort_type( $id );
|
||||
if ( $sort_type == 1 ) {
|
||||
$order_key = $target;
|
||||
if ( $target == 'tag' ) {
|
||||
$target == 'post_tag';
|
||||
} elseif ( $target = 'cat' ) {
|
||||
$target == 'category';
|
||||
}
|
||||
$sort_meta_key = self::set_tax_sort_meta_key( $id, $target, $order_key );
|
||||
if ( is_null( $sort_meta_key ) ) {
|
||||
return self::orderby_normal();
|
||||
} else {
|
||||
return array(
|
||||
'meta_query' => self::get_all_post_args( $sort_meta_key ),
|
||||
'orderby' => array( 'meta_value_num' => 'ASC' ),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return self::set_tax_custom_field_orderby( $id );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if ( ! trait_exists( 'TAX' ) ) {
|
||||
/**
|
||||
* タクソノミーのソート
|
||||
* Trait TAX
|
||||
*/
|
||||
trait TAX {
|
||||
private function set_orderby( $query, $id, $target, $order_key ) {
|
||||
$sort_type = self::get_tax_sort_type( $id );
|
||||
if ( $sort_type == 1 ) {
|
||||
$sort_meta_key = self::set_tax_sort_meta_key( $id, $target, $order_key );
|
||||
if ( is_null( $sort_meta_key ) ) {
|
||||
$this->set_search_normal_orderby( $query, 'normal' );
|
||||
} else {
|
||||
$query->set( 'meta_query', self::get_all_post_args( $sort_meta_key ) );
|
||||
$query->set( 'orderby', array( 'meta_value' => 'ASC', ) );
|
||||
}
|
||||
} else {
|
||||
$meta_orderby = self::set_tax_custom_field_orderby( $id );
|
||||
if ( isset( $meta_orderby['meta_query'] ) ) {
|
||||
$query->set( 'meta_query', $meta_orderby['meta_query'] );
|
||||
}
|
||||
if ( isset( $meta_orderby['orderby'] ) ) {
|
||||
$query->set( 'orderby', $meta_orderby['orderby'] );
|
||||
}
|
||||
}
|
||||
$per_page_option_data = self::set_per_page( self::get_per_page_tag( $target ), $id );
|
||||
$query->set( 'posts_per_page', $per_page_option_data );
|
||||
}
|
||||
|
||||
private static function get_tax_sort_type( $id ) {
|
||||
$sort_type = get_option( '_apop_tax_sort_type' );
|
||||
|
||||
return $sort_type[ $id ] ?? 1;
|
||||
}
|
||||
|
||||
private static function set_tax_sort_meta_key( $id, $target, $order_key ) {
|
||||
$order_settings = get_option( '_apop_' . $order_key . '_order' );
|
||||
if ( isset( $order_settings['target_cat'][ $id ] ) && $order_settings['target_cat'][ $id ] == 1 ) {
|
||||
return '_apop_post_' . $target . '_' . $id;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function set_tax_custom_field_orderby( $id ): array {
|
||||
$tax_order_param = get_option( '_apop_tax_order_param' );
|
||||
if ( isset( $tax_order_param[ $id ] ) ) {
|
||||
return self::set_custom_field_orderby( $tax_order_param[ $id ] );
|
||||
}
|
||||
}
|
||||
|
||||
private static function get_per_page_tag( $target ) {
|
||||
if ( $target == 'post_tag' ) {
|
||||
return 'tag';
|
||||
}
|
||||
|
||||
return $target;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user