Compare commits

...

12 Commits

Author SHA1 Message Date
nobu d4e4c772aa ・WordPress6.9動作確認
・PHP8.3対応修正
2025-12-17 09:23:22 +09:00
nobu d8375c5abe Fixed Notice Error 2024-06-08 00:02:54 +09:00
nobu 49f7d3088c Fixed Notice Error 2024-06-07 23:58:28 +09:00
nobu 49d6527486 add WP Confirm Version 2023-09-12 19:12:19 +09:00
nobu 1791cd0ab7 add WP Confirm Version 2023-09-12 17:04:13 +09:00
nobu 7d3fb10582 WordPress6.1 動作確認 2022-11-04 01:02:50 +09:00
nobu 6f064eaafa WP6.0 対応チェック
軽微な修正
・テンプレートのミスタイプの修正
・メソッドの戻り型指定の追加
・不要な変数代入の削除
・ファイルインクルードの条件追加
2022-05-28 19:57:51 +09:00
nobu 7b67bdf5f4 WordPress5.9動作確認
カスタム投稿アーカイブのNoticeエラー修正
2022-02-06 11:25:55 +09:00
nobu 5fd91acb2e バージョン情報を追記 2021-12-12 18:25:43 +09:00
nobu f96800dc9e 並べ替えのレイアウト修正
JSの変数宣言を最適化
2021-12-12 18:07:35 +09:00
nobu bc37f8ac26 ARCHIVE POST ORDER PLUS:Readme修正 2021-07-23 17:36:40 +09:00
nobu 8b2c2e520f ARCHIVE POST ORDER PLUS:Readme修正 2021-07-23 17:30:45 +09:00
12 changed files with 584 additions and 505 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ Plugin URI: https://develop.n-k-y.net/wordpress/wp_plugin/apop/
Author: NBK45 Author: NBK45
Author URI: https://develop.n-k-y.net Author URI: https://develop.n-k-y.net
Description: Archive Post Order Plus は「最新の投稿」「検索結果」「カテゴリー」「タグ」「カスタム分類」の投稿記事の表示順をドラッグで並べ替えて設定するプラグインです。 Description: Archive Post Order Plus は「最新の投稿」「検索結果」「カテゴリー」「タグ」「カスタム分類」の投稿記事の表示順をドラッグで並べ替えて設定するプラグインです。
Version: 1.1.8 Version: 1.2.1
License: GPLv2 License: GPLv2
Text Domain: ArchivePostOrderPlus Text Domain: ArchivePostOrderPlus
Domain Path: /languages Domain Path: /languages
+2 -1
View File
@@ -92,7 +92,8 @@ if ( ! class_exists( 'APOP_POST' ) ) {
} }
$archive_settings = get_option( '_apop_custompost_archive_sort_type' ); $archive_settings = get_option( '_apop_custompost_archive_sort_type' );
if ( array_key_exists( $post_type, $archive_settings ) && $archive_settings[ $post_type ] == 2 ) { if ( $archive_settings && array_key_exists( $post_type, $archive_settings )
&& $archive_settings[ $post_type ] == 2 ) {
foreach ( $this->order_param_keys as $order_param_key ) { foreach ( $this->order_param_keys as $order_param_key ) {
if ( isset( $param[ $post_type ][ $order_param_key ]['field']['meta_key'] ) && if ( isset( $param[ $post_type ][ $order_param_key ]['field']['meta_key'] ) &&
! empty( $param[ $post_type ][ $order_param_key ]['field']['meta_key'] ) ) { ! empty( $param[ $post_type ][ $order_param_key ]['field']['meta_key'] ) ) {
+419 -397
View File
@@ -1,348 +1,349 @@
<?php <?php
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} // Exit if accessed directly } // Exit if accessed directly
if ( ! class_exists( 'APOP_UI' ) ) { if ( ! class_exists( 'APOP_UI' ) ) {
require_once __DIR__ . '/../util/apop-customfield-select.php'; require_once __DIR__ . '/../util/apop-customfield-select.php';
require_once __DIR__ . '/../util/apop-customposts.php'; require_once __DIR__ . '/../util/apop-customposts.php';
class APOP_UI { class APOP_UI {
use CUSTOMFIELD_SELECT, CUSTOMPOSTS; use CUSTOMFIELD_SELECT, CUSTOMPOSTS;
public static function get_order_type( $type ) { public static function get_order_type( $type ) {
$type_data = get_option( $type ); $type_data = get_option( $type );
if ( ! $type_data ) { if ( ! $type_data ) {
return 1; return 1;
} }
return $type_data; return $type_data;
} }
public static function get_all_search_normal_posts( $key ) { public static function get_all_search_normal_posts( $key ) {
$meta_key = '_apop_post_' . $key; $meta_key = '_apop_post_' . $key;
$args = self::create_search_normal_args( $meta_key, $key ); $args = self::create_search_normal_args( $meta_key, $key );
$posts_data = get_posts( $args ); $posts_data = get_posts( $args );
foreach ( $posts_data as $i => $post_data ) { foreach ( $posts_data as $i => $post_data ) {
$order = $i + 1; $order = $i + 1;
$no_order = self::is_sort_post_registered( $post_data->ID, $meta_key ) ? '' : ' no-order'; $no_order = self::is_sort_post_registered( $post_data->ID, $meta_key ) ? '' : ' no-order';
echo '<li class="product-list' . esc_attr( $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 ) . '<span class="sort-num-label">' . esc_html( $order ) . '</span>' . esc_html( $post_data->post_title )
. '<input type="hidden" class="list-order" . '<input type="hidden" class="list-order"
name="_apop_post_' . esc_attr( $key ) . '[post_sort][' . esc_attr( $post_data->ID ) . ']" name="_apop_post_' . esc_attr( $key ) . '[post_sort][' . esc_attr( $post_data->ID ) . ']"
value="' . esc_attr( $order ) . '"> value="' . esc_attr( $order ) . '">
</li>'; </li>';
} }
} }
private static function create_search_normal_args( $meta_key, $key = 'normal' ): array { private static function create_search_normal_args( $meta_key, $key = 'normal' ): array {
$post_type = array( 'post' ); $post_type = array( 'post' );
if ( $key == 'search' ) { if ( $key == 'search' ) {
$add_post_type = array_values( get_post_types( array( $add_post_type = array_values( get_post_types( array(
'public' => true, 'public' => true,
'_builtin' => false, '_builtin' => false,
) )
) )
); );
$post_type = array_merge( $post_type, $add_post_type ); $post_type = array_merge( $post_type, $add_post_type );
} }
return array( return array(
'post_type' => $post_type, 'post_type' => $post_type,
'post_status' => array( 'publish', 'draft' ), 'post_status' => array( 'publish', 'draft' ),
'posts_per_page' => - 1, 'posts_per_page' => - 1,
'orderby' => 'meta_value_num', 'orderby' => 'meta_value_num',
'order' => 'ASC', 'order' => 'ASC',
'meta_query' => array( 'meta_query' => array(
'relation' => 'OR', 'relation' => 'OR',
array( array(
'key' => $meta_key, 'key' => $meta_key,
'compare' => 'EXISTS', 'compare' => 'EXISTS',
), ),
array( array(
'key' => $meta_key, 'key' => $meta_key,
'compare' => 'NOT EXISTS', 'compare' => 'NOT EXISTS',
), ),
), ),
); );
} }
private static function get_all_custom_posts() { private static function get_all_custom_posts(): array {
$custom_posts = array_values( get_post_types( array( 'public' => true, '_builtin' => false ) ) ); $custom_posts = array_values( get_post_types( array( 'public' => true, '_builtin' => false ) ) );
$custom_post_data = array(); $custom_post_data = array();
foreach ( $custom_posts as $custom_post ) { foreach ( $custom_posts as $custom_post ) {
$label = get_post_type_object( $custom_post )->label; $label = get_post_type_object( $custom_post )->label;
$custom_post_data[ $custom_post ] = $label; $custom_post_data[ $custom_post ] = $label;
} }
return $custom_post_data; return $custom_post_data;
} }
private static function get_all_taxonomies( $key ) { private static function get_all_taxonomies( $key ) {
if ( $key !== 'taxonomy' ) { if ( $key !== 'taxonomy' ) {
return get_terms( array( 'taxonomy' => $key, 'get' => 'all' ) ); return get_terms( array( 'taxonomy' => $key, 'get' => 'all' ) );
} }
$all_custom_tax = get_taxonomies( array( 'public' => true, '_builtin' => false ) ); $all_custom_tax = get_taxonomies( array( 'public' => true, '_builtin' => false ) );
$custom_tax_list = array(); $custom_tax_list = array();
foreach ( $all_custom_tax as $custom_tax ) { foreach ( $all_custom_tax as $custom_tax ) {
$custom_tax_list = array_merge( $custom_tax_list, get_terms( array( $custom_tax_list = array_merge( $custom_tax_list, get_terms( array(
'taxonomy' => $custom_tax, 'taxonomy' => $custom_tax,
'get' => 'all' 'get' => 'all'
) ) ); ) ) );
} }
return $custom_tax_list; return $custom_tax_list;
} }
public static function get_cat_tag_list( $target, $key ): array { public static function get_cat_tag_list( $target, $key ): array {
$opt = get_option( '_apop_' . $target . '_order' ); $opt = get_option( '_apop_' . $target . '_order' );
if ( ! isset( $opt['target_cat'] ) ) { if ( ! isset( $opt['target_cat'] ) ) {
return array(); return array();
} }
if ( $key == 'taxonomy' ) { if ( $key == 'taxonomy' ) {
return self::create_custom_tax_term( $opt ); return self::create_custom_tax_term( $opt );
} else { } else {
return self::create_tax_term( $opt, $key ); return self::create_tax_term( $opt, $key );
} }
} }
private static function create_custom_tax_term( $opt ): array { private static function create_custom_tax_term( $opt ): array {
$tax_data = array(); $tax_data = array();
foreach ( $opt['target_cat'] as $tax_id => $status ) { foreach ( $opt['target_cat'] as $tax_id => $status ) {
//フラグが立っているカスタムタクソノミーは情報を取得する //フラグが立っているカスタムタクソノミーは情報を取得する
if ( $status ) { if ( $status ) {
$args = array( $args = array(
'taxonomy' => get_term( $tax_id )->taxonomy, 'taxonomy' => get_term( $tax_id )->taxonomy,
'hide_empty' => 0, 'hide_empty' => 0,
'include' => $tax_id, 'include' => $tax_id,
); );
$tax_data = array_merge( $tax_data, get_terms( $args ) ); $tax_data = array_merge( $tax_data, get_terms( $args ) );
} }
} }
if ( count( $tax_data ) > 0 ) { if ( count( $tax_data ) > 0 ) {
return $tax_data; return $tax_data;
} }
return array(); return array();
} }
private static function create_tax_term( $opt, $key ) { private static function create_tax_term( $opt, $key ) {
$include = array(); $include = array();
foreach ( $opt['target_cat'] as $tax_id => $status ) { foreach ( $opt['target_cat'] as $tax_id => $status ) {
//フラグが立っているタクソノミーIDを取得 //フラグが立っているタクソノミーIDを取得
if ( $status ) { if ( $status ) {
$include[] = $tax_id; $include[] = $tax_id;
} }
} }
$include_tax = implode( ',', $include ); $include_tax = implode( ',', $include );
if ( ! empty( $include_tax ) ) { if ( ! empty( $include_tax ) ) {
$args = array( $args = array(
'taxonomy' => $key, 'taxonomy' => $key,
'hide_empty' => 0, 'hide_empty' => 0,
'include' => $include_tax, 'include' => $include_tax,
); );
return get_terms( $args ); return get_terms( $args );
} }
return array(); return array();
} }
public static function create_order_list( $tax_data, $tax_key ): string { 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 ); $return_data = self::get_sort_post_list( $tax_data->term_id, $tax_key, $tax_data->taxonomy );
$list = array(); $list = array();
foreach ( $return_data['data'] as $key => $target_post ) { foreach ( $return_data['data'] as $key => $target_post ) {
$sort_num = $key + 1; $sort_num = $key + 1;
$no_order = self::is_sort_post_registered( $target_post->ID, $return_data['meta_key'] ) ? '' : ' no-order'; $no_order = self::is_sort_post_registered( $target_post->ID, $return_data['meta_key'] ) ? '' : ' no-order';
$list[] = ' $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 ) . ' <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" <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 ) . ']" 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 ) . '"> value="' . esc_html( $sort_num ) . '">
</li>'; </li>';
} }
return implode( PHP_EOL, $list ); return implode( PHP_EOL, $list );
} }
private static function is_sort_post_registered( $id, $key ): bool { private static function is_sort_post_registered( $id, $key ): bool {
if ( get_post_meta( $id, $key, true ) ) { if ( get_post_meta( $id, $key, true ) ) {
return true; return true;
} }
return false; return false;
} }
private static function get_sort_post_list( $tax_id, $search_param, $tax_name ): array { private static function get_sort_post_list( $tax_id, $search_param, $tax_name ): array {
$post_types = array( 'post' ); $post_types = array( 'post' );
$custom_post_types = array_values( get_post_types( array( 'public' => true, '_builtin' => false ) ) ); $custom_post_types = array_values( get_post_types( array( 'public' => true, '_builtin' => false ) ) );
$args = array( $args = array(
'post_type' => array_merge( $post_types, $custom_post_types ), 'post_type' => array_merge( $post_types, $custom_post_types ),
'post_status' => array( 'publish', 'draft' ), 'post_status' => array( 'publish', 'draft' ),
'posts_per_page' => - 1, 'posts_per_page' => - 1,
'orderby' => 'meta_value_num', 'orderby' => 'meta_value_num',
'order' => 'ASC', 'order' => 'ASC',
); );
$meta_key = '_apop_post_' . self::create_post_sort_key( $tax_name, $search_param ) . '_' . $tax_id; $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_sort_post_list_meta_query( $args, $meta_key );
self::create_post_tax_query( $args, $search_param, $tax_name, $tax_id ); self::create_post_tax_query( $args, $search_param, $tax_name, $tax_id );
return array( return array(
'meta_key' => $meta_key, 'meta_key' => $meta_key,
'data' => get_posts( $args ) 'data' => get_posts( $args )
); );
} }
private static function create_sort_post_list_meta_query( &$args, $meta_key ) { private static function create_sort_post_list_meta_query( &$args, $meta_key ) {
$args['meta_query'] = array( $args['meta_query'] = array(
'relation' => 'OR', 'relation' => 'OR',
array( array(
'key' => $meta_key, 'key' => $meta_key,
'compare' => 'EXISTS', 'compare' => 'EXISTS',
), ),
array( array(
'key' => $meta_key, 'key' => $meta_key,
'compare' => 'NOT EXISTS', 'compare' => 'NOT EXISTS',
), ),
); );
} }
public static function create_post_sort_key( $tax_name, $tax_key ) { public static function create_post_sort_key( $tax_name, $tax_key ) {
if ( $tax_key == 'taxonomy' ) { if ( $tax_key == 'taxonomy' ) {
return 'tax'; return 'tax';
} }
return $tax_name; return $tax_name;
} }
private static function create_post_tax_query( &$args, $key, $tax_name, $tax_id ) { private static function create_post_tax_query( &$args, $key, $tax_name, $tax_id ) {
if ( $key == 'taxonomy' ) { if ( $key == 'taxonomy' ) {
$args['tax_query'] = array( $args['tax_query'] = array(
array( array(
'taxonomy' => $tax_name, 'taxonomy' => $tax_name,
'field' => 'term_id', 'field' => 'term_id',
'terms' => $tax_id, 'terms' => $tax_id,
'include_children' => false 'include_children' => false
) )
); );
} else { } else {
$args[ $key ] = $tax_id; $args[ $key ] = $tax_id;
} }
} }
public static function create_cat_per_page( $opt_per_page, $type ): array { public static function create_cat_per_page( $opt_per_page, $type ): array {
$cat_per_page = $opt_per_page[ $type ] ?? 'default'; $cat_per_page = $opt_per_page[ $type ] ?? 'default';
$checked = ''; $checked = '';
$cat_per_page_num = ''; $cat_per_page_num = '';
if ( isset( $opt_per_page[ $type ] ) ) { if ( isset( $opt_per_page[ $type ] ) ) {
if ( $opt_per_page[ $type ] != 'default' if ( $opt_per_page[ $type ] != 'default'
&& $opt_per_page[ $type ] != '-1' && $opt_per_page[ $type ] != '-1'
&& $opt_per_page[ $type ] != 'all' ) { && $opt_per_page[ $type ] != 'all' ) {
$checked = ' checked="checked"'; $checked = ' checked="checked"';
$cat_per_page_num = $cat_per_page; $cat_per_page_num = $cat_per_page;
} }
} }
return array( return array(
'_per_page' => $cat_per_page, '_per_page' => $cat_per_page,
'_checked' => $checked, '_checked' => $checked,
'_per_page_num' => $cat_per_page_num, '_per_page_num' => $cat_per_page_num,
); );
} }
public static function disp_tax_setting( $key, $title, $order_name ) { public static function disp_tax_setting( $key, $title, $order_name ) {
$tax_data = APOP_UI::get_all_taxonomies( $key ); $tax_data = APOP_UI::get_all_taxonomies( $key );
if ( count( $tax_data ) > 0 ) { if ( count( $tax_data ) > 0 ) {
$order_name = $order_name; $order_tax = $key == 'post_tag' ? 'tag' : $key;
$order_tax = $key == 'post_tag' ? 'tag' : $key; echo '<tr><th scope="row">' . esc_html( $title ) . '</th><td>';
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'; include APOP_PLUGIN_PATH . 'template/setting_parts_taxonomy.php';
echo '</td></tr>'; }
} echo '</td></tr>';
} }
}
public static function disp_customposts_setting( $key, $title, $order_name ) { public static function disp_customposts_setting( $key, $title, $order_name ) {
$custom_post_data = APOP_UI::get_all_custom_posts(); $custom_post_data = APOP_UI::get_all_custom_posts();
if ( count( $custom_post_data ) > 0 ) { if ( count( $custom_post_data ) > 0 ) {
$order_name = $order_name; echo '<tr><th scope="row">' . esc_html( $title ) . '</th><td>';
$order = $key; if ( isset( $custom_post_data, $order_name, $key ) ) {
echo '<tr><th scope="row">' . esc_html( $title ) . '</th><td>'; include APOP_PLUGIN_PATH . 'template/setting_parts_customposts.php';
include APOP_PLUGIN_PATH . 'template/setting_parts_customposts.php'; }
echo '</td></tr>'; echo '</td></tr>';
} }
} }
public static function create_custom_posts_per_page( $opt_per_page, $type, $slug ): array { public static function create_custom_posts_per_page( $opt_per_page, $type, $slug ): array {
$cat_per_page = $opt_per_page[ $type ][ $slug ] ?? 'default'; $cat_per_page = $opt_per_page[ $type ][ $slug ] ?? 'default';
$checked = ''; $checked = '';
$cat_per_page_num = ''; $cat_per_page_num = '';
if ( isset( $opt_per_page[ $type ][ $slug ] ) ) { if ( isset( $opt_per_page[ $type ][ $slug ] ) ) {
if ( $opt_per_page[ $type ][ $slug ] != 'default' if ( $opt_per_page[ $type ][ $slug ] != 'default'
&& $opt_per_page[ $type ][ $slug ] != '-1' && $opt_per_page[ $type ][ $slug ] != '-1'
&& $opt_per_page[ $type ][ $slug ] != 'all' ) { && $opt_per_page[ $type ][ $slug ] != 'all' ) {
$checked = ' checked="checked"'; $checked = ' checked="checked"';
$cat_per_page_num = $cat_per_page; $cat_per_page_num = $cat_per_page;
} }
} }
return array( return array(
'_per_page' => $cat_per_page, '_per_page' => $cat_per_page,
'_checked' => $checked, '_checked' => $checked,
'_per_page_num' => $cat_per_page_num, '_per_page_num' => $cat_per_page_num,
); );
} }
public static function create_tax_per_page( $opt_per_page, $type, $id ): array { public static function create_tax_per_page( $opt_per_page, $type, $id ): array {
$cat_per_page = $opt_per_page[ $type ][ $id ] ?? 'default'; $cat_per_page = $opt_per_page[ $type ][ $id ] ?? 'default';
$checked = ''; $checked = '';
$cat_per_page_num = ''; $cat_per_page_num = '';
if ( isset( $opt_per_page[ $type ][ $id ] ) ) { if ( isset( $opt_per_page[ $type ][ $id ] ) ) {
if ( $opt_per_page[ $type ][ $id ] != 'default' if ( $opt_per_page[ $type ][ $id ] != 'default'
&& $opt_per_page[ $type ][ $id ] != '-1' && $opt_per_page[ $type ][ $id ] != '-1'
&& $opt_per_page[ $type ][ $id ] != 'all' ) { && $opt_per_page[ $type ][ $id ] != 'all' ) {
$checked = ' checked="checked"'; $checked = ' checked="checked"';
$cat_per_page_num = $cat_per_page; $cat_per_page_num = $cat_per_page;
} }
} }
return array( return array(
'_per_page' => $cat_per_page, '_per_page' => $cat_per_page,
'_checked' => $checked, '_checked' => $checked,
'_per_page_num' => $cat_per_page_num, '_per_page_num' => $cat_per_page_num,
); );
} }
public static function create_search_normal_list( $type, $id = null ) { public static function create_search_normal_list( $type, $id = null ) {
$name_keys = self::create_name_keys( $id, $type ); $name_keys = self::create_name_keys( $id, $type );
$name_key = $name_keys['name_key']; $name_key = $name_keys['name_key'];
$get_option_key = $name_keys['get_option_key']; $get_option_key = $name_keys['get_option_key'];
$order_param_base = get_option( $get_option_key ); $order_param_base = get_option( $get_option_key );
$order_param = ''; $order_param = '';
if ( is_null( $id ) ) { if ( is_null( $id ) ) {
$order_param = $order_param_base; $order_param = $order_param_base;
} }
if ( isset( $order_param_base[ $id ] ) ) { if ( isset( $order_param_base[ $id ] ) ) {
$order_param = $order_param_base[ $id ]; $order_param = $order_param_base[ $id ];
} }
self::create_normal_sort_list( $name_key, $order_param ); self::create_normal_sort_list( $name_key, $order_param );
} }
private static function create_custom_field_sort_type( $name_key, $target_key, $cnv_order_params ) { private static function create_custom_field_sort_type( $name_key, $target_key, $cnv_order_params ) {
$meta_key = $cnv_order_params[ $target_key ]['meta_key']; $meta_key = $cnv_order_params[ $target_key ]['meta_key'];
$value_type = $cnv_order_params[ $target_key ]['value_type']; $value_type = $cnv_order_params[ $target_key ]['value_type'];
$custom_field_type = $cnv_order_params[ $target_key ]['custom_field_type']; $custom_field_type = $cnv_order_params[ $target_key ]['custom_field_type'];
$name_meta_key = '_' . $name_key . '[' . $target_key . '][field][meta_key]'; $name_meta_key = '_' . $name_key . '[' . $target_key . '][field][meta_key]';
$name_value_type = '_' . $name_key . '[' . $target_key . '][field][value_type]'; $name_value_type = '_' . $name_key . '[' . $target_key . '][field][value_type]';
$name_custom_field_type = '_' . $name_key . '[' . $target_key . '][field][custom_field_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_1 = $custom_field_type == '1' ? $meta_key : '';
$custom_field_val_2 = $custom_field_type == '2' ? $meta_key : '';; $custom_field_val_2 = $custom_field_type == '2' ? $meta_key : '';
echo '<div class="sort-custom-field"> echo '<div class="sort-custom-field">
<div class="sort-custom-field-types"> <div class="sort-custom-field-types">
<div class="sort-custom-field-inner-label"> <div class="sort-custom-field-inner-label">
<label> <label>
@@ -356,7 +357,7 @@ value="' . esc_html( $sort_num ) . '">
name="' . esc_attr( $name_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> value="2"' . esc_attr( self::set_search_normal_checked( $custom_field_type, '2' ) ) . '>' . __( 'Add', APOP_DOMAIN ) . '</label>
</div>'; </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> 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> <input type="text" class="custom_field_key" name="' . esc_attr( $name_meta_key ) . '" value="' . esc_attr( $custom_field_val_2 ) . '" required>
</div> </div>
<div class="custom-field-select-alert"></div> <div class="custom-field-select-alert"></div>
@@ -373,122 +374,143 @@ value="' . esc_html( $sort_num ) . '">
value="meta_value_num"' . esc_attr( self::set_search_normal_checked( $value_type, 'meta_value_num' ) ) . '>' . __( 'Number', APOP_DOMAIN ) . '</label> value="meta_value_num"' . esc_attr( self::set_search_normal_checked( $value_type, 'meta_value_num' ) ) . '>' . __( 'Number', APOP_DOMAIN ) . '</label>
</div> </div>
</div>'; </div>';
} }
private static function set_order_list_param( $order_param, $target_key ): array { private static function set_order_list_param( $order_param, $target_key ): array {
$param = array( $param = array(
'use' => 0, 'use' => 0,
'sort' => 2, 'sort' => 2,
'no_order_class' => ' no-order', 'no_order_class' => ' no-order',
); );
if ( strpos( $target_key, 'custom_field' ) !== false ) { if ( strpos( $target_key, 'custom_field' ) !== false ) {
$param[ $target_key ] = array( $param[ $target_key ] = array(
'meta_key' => '', 'meta_key' => '',
'value_type' => 'meta_value', 'value_type' => 'meta_value',
'custom_field_type' => '1', 'custom_field_type' => '1',
); );
} }
if ( isset( $order_param[ $target_key ] ) ) { if ( isset( $order_param[ $target_key ] ) ) {
$param = array( $param = array(
'use' => $order_param[ $target_key ]['use'] ?? 0, 'use' => $order_param[ $target_key ]['use'] ?? 0,
'sort' => $order_param[ $target_key ]['sort'] ?? 2, 'sort' => $order_param[ $target_key ]['sort'] ?? 2,
'no_order_class' => ! $order_param[ $target_key ]['use'] ? ' no-order' : '', 'no_order_class' => ! $order_param[ $target_key ]['use'] ? ' no-order' : '',
); );
if ( strpos( $target_key, 'custom_field' ) !== false ) { if ( strpos( $target_key, 'custom_field' ) !== false ) {
$param[ $target_key ] = array( $param[ $target_key ] = array(
'meta_key' => $order_param[ $target_key ]['field']['meta_key'] ?? '', 'meta_key' => $order_param[ $target_key ]['field']['meta_key'] ?? '',
'value_type' => $order_param[ $target_key ]['field']['value_type'] ?? 'meta_value', 'value_type' => $order_param[ $target_key ]['field']['value_type'] ?? 'meta_value',
'custom_field_type' => $order_param[ $target_key ]['field']['custom_field_type'] ?? '1', 'custom_field_type' => $order_param[ $target_key ]['field']['custom_field_type'] ?? '1',
); );
} }
} }
return $param; return $param;
} }
private static function create_name_keys( $id, $type ): array { private static function create_name_keys( $id, $type ): array {
if ( is_null( $id ) ) { if ( is_null( $id ) ) {
return array( return array(
'name_key' => 'apop_' . $type . '_order_param', 'name_key' => 'apop_' . $type . '_order_param',
'get_option_key' => '_' . 'apop_' . $type . '_order_param', 'get_option_key' => '_' . 'apop_' . $type . '_order_param',
); );
} else { } else {
return array( return array(
'name_key' => 'apop_tax_order_param[' . $id . ']', 'name_key' => 'apop_tax_order_param[' . $id . ']',
'get_option_key' => '_apop_tax_order_param', 'get_option_key' => '_apop_tax_order_param',
); );
} }
} }
private static function set_search_normal_target_keys( $post_apop_search_order_param ) { private static function set_search_normal_target_keys( $post_apop_search_order_param ): array {
$set_keys = array( $set_keys = array(
'date', 'date',
'title', 'title',
'ID', 'ID',
'modified', 'modified',
'custom_field', 'custom_field',
'custom_field_2', 'custom_field_2',
'custom_field_3', 'custom_field_3',
'custom_field_4', 'custom_field_4',
); );
if ( $post_apop_search_order_param ) { if ( $post_apop_search_order_param ) {
$register_keys = array_keys( $post_apop_search_order_param ); $register_keys = array_keys( $post_apop_search_order_param );
return array_unique( array_merge( $register_keys, $set_keys ) ); return array_unique( array_merge( $register_keys, $set_keys ) );
} }
return $set_keys; return $set_keys;
} }
private static function set_search_normal_checked( $param, $default ): string { private static function set_search_normal_checked( $param, $default ): string {
if ( $param == $default ) { if ( $param == $default ) {
return ' checked="checked"'; return ' checked="checked"';
} }
return ''; return '';
} }
public static function input_post_filter( $var_name, $type ) { /**
if ( $type == 'array' ) { * POSTデータのフィルタリングを行います。
return filter_input( INPUT_POST, $var_name, FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY ); *
} * @param string $var_name 取得するPOST変数名。
if ( $type == 'str' ) { * @param string $type 'array' または 'str' を指定します。
return filter_input( INPUT_POST, $var_name, FILTER_SANITIZE_STRING ); *
} * @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 '';
}
public static function create_normal_sort_list( $name_key, $order_param ) { return '';
$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 ) . '"> 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-type-label"><b>' . esc_attr( $target_values[ $target_key ] ) . '</b></div>
<div class="product-list-sort-type"> <div class="product-list-sort-type">
<label> <label>
@@ -506,14 +528,14 @@ value="' . esc_html( $sort_num ) . '">
name="' . esc_attr( $name_sort_key ) . '" name="' . esc_attr( $name_sort_key ) . '"
value="2"' . esc_attr( self::set_search_normal_checked( $sort, 2 ) ) . '>' . __( 'Desc', APOP_DOMAIN ) . '</label>'; value="2"' . esc_attr( self::set_search_normal_checked( $sort, 2 ) ) . '>' . __( 'Desc', APOP_DOMAIN ) . '</label>';
if ( strpos( $target_key, 'custom_field' ) !== false ) { if ( strpos( $target_key, 'custom_field' ) !== false ) {
self::create_custom_field_sort_type( $name_key, $target_key, $cnv_order_params ); self::create_custom_field_sort_type( $name_key, $target_key, $cnv_order_params );
} }
echo '</div> echo '</div>
</li>'; </li>';
} }
} }
} }
} }
+27 -21
View File
@@ -52,16 +52,18 @@ h3 {
.list-orders-outer { .list-orders-outer {
width: 100%; width: 100%;
display: flex;
margin-bottom: 1em; margin-bottom: 1em;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-between; justify-content: space-between;
} }
.list-orders-inner { .list-orders-inner {
width: calc((100% / 2) - 20px); width: calc(100% - 60px);
padding: .5em; margin: 1em auto;
padding: .5em 1em;
position: relative; position: relative;
background: #eee;
border-radius: 12px;
} }
.sort-menu-list { .sort-menu-list {
@@ -146,15 +148,19 @@ dl.apop-setting-list-dd .sort-custom-field-input {
.drag-sort .product-list { .drag-sort .product-list {
border: 1px solid #ccc; border: 1px solid #ccc;
border-radius: 6px;
} }
.enable-box .product-list { .enable-box .product-list {
padding: 1em .3em; width: calc((50%) - 30px);
background: #eee; padding: 1em;
background: #fff;
border: 1px solid #bbb;
border-radius: 6px;
} }
.enable-box .product-list:hover { .enable-box .product-list:hover {
border: 1px solid #bbb; border: 1px solid #999;
} }
.custom_field_key_select, .custom_field_key_select,
@@ -172,10 +178,6 @@ dl.apop-setting-list-dd .sort-custom-field-input {
width: calc((100%) - 60px); width: calc((100%) - 60px);
} }
.enable-box .product-list-type-label {
width: calc(100% / 2);
}
.search-normal-sort .product-list-sort-type { .search-normal-sort .product-list-sort-type {
width: 100%; width: 100%;
display: flex; display: flex;
@@ -196,6 +198,7 @@ dl.apop-setting-list-dd .sort-custom-field-input {
.product-list.no-order { .product-list.no-order {
background: #ababab; background: #ababab;
border-radius: 6px;
} }
.list-order { .list-order {
@@ -256,7 +259,6 @@ dl.apop-setting-list-dd .sort-custom-field-input {
.disable-normal-list { .disable-normal-list {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-between;
margin: .5em 1em 1em 0; margin: .5em 1em 1em 0;
} }
@@ -267,7 +269,7 @@ dl.apop-setting-list-dd .sort-custom-field-input {
} }
.disable-box .product-list { .disable-box .product-list {
width: calc((100% / 2) - 15px); width: calc((25%) - 15px);
display: flex; display: flex;
cursor: default; cursor: default;
} }
@@ -291,7 +293,7 @@ dl.apop-setting-list-dd .sort-custom-field-input {
.enable-box, .enable-box,
.disable-box { .disable-box {
padding: .5em; padding: .5em;
border: 1px solid #ccc; /*border-bottom: 1px solid #ccc;*/
} }
.enable-box h4 { .enable-box h4 {
@@ -311,9 +313,9 @@ dl.apop-setting-list-dd .sort-custom-field-input {
@media only screen and (max-width: 1264px) { @media only screen and (max-width: 1264px) {
.enable-box .product-list,
.disable-box .product-list { .enable-box .product-list {
display: block; width: calc((100%) - 15px);
} }
.search-normal-sort .product-list { .search-normal-sort .product-list {
@@ -351,13 +353,9 @@ dl.apop-setting-list-dd .sort-custom-field-input {
width: 98%; width: 98%;
} }
.list-orders-outer {
display: block;;
}
.list-orders-inner { .list-orders-inner {
width: auto; width: auto;
margin: 1.5em 0 0 0; margin: 1.5em 1em 0;
} }
dl.apop-setting-list dt { dl.apop-setting-list dt {
@@ -379,4 +377,12 @@ dl.apop-setting-list-dd .sort-custom-field-input {
width: auto; width: auto;
white-space: normal; white-space: normal;
} }
.disable-normal-list {
display: block;
}
.disable-box .product-list {
width: 100%;
}
} }
+50 -50
View File
@@ -21,15 +21,15 @@ jQuery(function ($) {
custom_field_select(); custom_field_select();
function change_tab_menu() { function change_tab_menu() {
let apop_submit_type = $('#apop_submit_type'); const apop_submit_type = $('#apop_submit_type');
let order_nav_list = $('.post-order-nav li'); const order_nav_list = $('.post-order-nav li');
let order_box = $('.post-order-box'); const order_box = $('.post-order-box');
init(); init();
click_menu(); click_menu();
function init() { function init() {
let submit_type = apop_submit_type.val(); const submit_type = apop_submit_type.val();
order_nav_list.removeClass('en'); order_nav_list.removeClass('en');
order_box.hide(); order_box.hide();
$('.post-order-nav li:eq(' + submit_type + ')').addClass('en'); $('.post-order-nav li:eq(' + submit_type + ')').addClass('en');
@@ -39,7 +39,7 @@ jQuery(function ($) {
function click_menu() { function click_menu() {
order_nav_list.on('click', function () { order_nav_list.on('click', function () {
if (!$(this).hasClass('en')) { if (!$(this).hasClass('en')) {
let target_index = $(this).index(); const target_index = $(this).index();
order_nav_list.removeClass('en'); order_nav_list.removeClass('en');
$(this).addClass('en'); $(this).addClass('en');
order_box.hide(); order_box.hide();
@@ -51,13 +51,13 @@ jQuery(function ($) {
} }
function order_list() { 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++) { 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( my_list.sortable(
{ {
update: function () { 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++) { for (let j = 0; j < list_count; j++) {
let list_order_num = j + 1; let list_order_num = j + 1;
$('.list-order:eq(' + j + ')', my_list).val(list_order_num); $('.list-order:eq(' + j + ')', my_list).val(list_order_num);
@@ -71,38 +71,38 @@ jQuery(function ($) {
} }
function change_sort_box() { function change_sort_box() {
let s_radio = $('.sort_menu'); const s_radio = $('.sort_menu');
let sort_menu_size = $('.sort-menu-list').length; const sort_menu_size = $('.sort-menu-list').length;
$('.sort_box').hide(); $('.sort_box').hide();
for (let i = 0; i < sort_menu_size; i++) { for (let i = 0; i < sort_menu_size; i++) {
let type_index = $('.sort-menu-list:eq(' + i + ')').data('order_target') - 1; const elm = $('.sort-menu-list:eq(' + i + ')');
$('.sort-menu-list:eq(' + i + ')').siblings('.sort_box:eq(' + type_index + ')').show(); const type_index = elm.data('order_target') - 1;
elm.siblings('.sort_box:eq(' + type_index + ')').show();
} }
s_radio.on('click', function () { 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').hide();
$(this).parents('.list-orders-inner').find('.sort_box:eq(' + target_index + ')').show(); $(this).parents('.list-orders-inner').find('.sort_box:eq(' + target_index + ')').show();
}) })
} }
function select_tax() { function select_tax() {
let select_cat_checkbox = $('.select_cat_checkbox'); const select_cat_checkbox = $('.select_cat_checkbox');
let input_chk_size = select_cat_checkbox.length; const input_chk_size = select_cat_checkbox.length;
let i = 0; for (let i = 0; i < input_chk_size; i++) {
const chk = $('.select_cat_checkbox:eq(' + i + '):checked').length;
for (i; i < input_chk_size; i++) { const elm = $('.select_cat:eq(' + i + ')');
let chk = $('.select_cat_checkbox:eq(' + i + '):checked').length; if (chk === 1) {
if (chk == 1) { elm.siblings('.select-per-page').show();
$('.select_cat:eq(' + i + ')').siblings('.select-per-page').show();
} else { } else {
$('.select_cat:eq(' + i + ')').siblings('.select-per-page').hide(); elm.siblings('.select-per-page').hide();
} }
} }
select_cat_checkbox.on('click', function () { select_cat_checkbox.on('click', function () {
let checked = $(this).prop('checked'); const checked = $(this).prop('checked');
if (checked) { if (checked) {
$(this).parent().parent().siblings('.select-per-page').show(200); $(this).parent().parent().siblings('.select-per-page').show(200);
} else { } else {
@@ -113,17 +113,17 @@ jQuery(function ($) {
} }
function change_search_per_page() { function change_search_per_page() {
let per_page_cat = $('.per_page_search'); const per_page_cat = $('.per_page_search');
let per_page_input = $('.per_page_search_input'); const per_page_input = $('.per_page_search_input');
if (per_page_input.val() == '') { if (per_page_input.val() === '') {
per_page_input.prop('disabled', true); per_page_input.prop('disabled', true);
} else { } else {
per_page_input.prop('disabled', false); per_page_input.prop('disabled', false);
} }
per_page_cat.on('click', function () { 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); per_page_input.prop('disabled', false);
} else { } else {
per_page_input.val(''); per_page_input.val('');
@@ -133,11 +133,11 @@ jQuery(function ($) {
} }
function change_tax_per_page() { function change_tax_per_page() {
let set_number = $('.set_number'); const set_number = $('.set_number');
let input_chk_size = set_number.length; const input_chk_size = set_number.length;
for (let i = 0; i < input_chk_size; i++) { for (let i = 0; i < input_chk_size; i++) {
let input_num_box = $('.set_number:eq(' + i + ')').siblings('.per_page_cat_input'); const input_num_box = $('.set_number:eq(' + i + ')').siblings('.per_page_cat_input');
if (input_num_box.val() == '') { if (input_num_box.val() === '') {
input_num_box.prop('disabled', true); input_num_box.prop('disabled', true);
} else { } else {
input_num_box.prop('disabled', false); input_num_box.prop('disabled', false);
@@ -154,57 +154,57 @@ jQuery(function ($) {
} }
function change_normal_field_sort() { function change_normal_field_sort() {
let s_box = $('.sort_box'); const s_box = $('.sort_box');
let targets = '.sort_date_check, .sort_title_check, .sort_ID_check, .sort_modified_check'; const targets = '.sort_date_check, .sort_title_check, .sort_ID_check, .sort_modified_check';
s_box.find(targets).each(function () { 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); $(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); $(this).parents('li').appendTo(disable_list);
} }
}); });
$(targets).on('click', function () { $(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); $(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', false);
let enable_list = $(this).parents('.sort_box').find('.post-order-list'); const enable_list = $(this).parents('.sort_box').find('.post-order-list');
$(this).parents('li').appendTo(enable_list).removeClass('no-order').hide().fadeIn(200); $(this).parents('li').appendTo(enable_list).removeClass('no-order').hide().fadeIn(200);
} else { } else {
$(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', true); $(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).addClass('no-order').hide().fadeIn(200); $(this).parents('li').appendTo(disable_list).addClass('no-order').hide().fadeIn(200);
} }
}); });
} }
function custom_field_select() { function custom_field_select() {
let s_box = $('.sort_box'); const s_box = $('.sort_box');
let targets = $('.custom-field-type'); const targets = $('.custom-field-type');
let en_dis_check = $('.custom_field_check'); const en_dis_check = $('.custom_field_check');
// カスタムフィールドソートの有効・無効を判定する。 // カスタムフィールドソートの有効・無効を判定する。
// 有効の場合はカスタムフィールド選択or追加のステータスに応じてテキストエリアとセレクトタグenableに変更し表示を切り替える。 // 有効の場合はカスタムフィールド選択or追加のステータスに応じてテキストエリアとセレクトタグenableに変更し表示を切り替える。
// 無効の場合はカスタムフィールドのテキストエリアとセレクトタグをDisableにし無効ボックスに移動する。 // 無効の場合はカスタムフィールドのテキストエリアとセレクトタグをDisableにし無効ボックスに移動する。
s_box.find('.custom_field_check').each(function () { s_box.find('.custom_field_check').each(function () {
if ($(this).prop('checked') == false) { if ($(this).prop('checked') === false) {
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); $(this).parents('li').appendTo(disable_list);
dis_list($(this)); dis_list($(this));
} else { } else {
let target_type = $(this).parents('.product-list-sort-type').find('.custom-field-type').filter(':checked').val(); const target_type = $(this).parents('.product-list-sort-type').find('.custom-field-type').filter(':checked').val();
en_dis_list($(this), target_type); en_dis_list($(this), target_type);
} }
}); });
//有効・無効チェックボックスクリック時 //有効・無効チェックボックスクリック時
en_dis_check.on('click', function () { en_dis_check.on('click', function () {
if ($(this).prop('checked') == true) { if ($(this).prop('checked') === true) {
let enable_list = $(this).parents('.sort_box').find('.post-order-list'); const enable_list = $(this).parents('.sort_box').find('.post-order-list');
let target_type = $(this).parents('.product-list-sort-type').find('.custom-field-type').filter(':checked').val(); 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('.product-list-sort-type').find('.order_param').prop('disabled', false);
$(this).parents('li').appendTo(enable_list).removeClass('no-order').hide().fadeIn(200); $(this).parents('li').appendTo(enable_list).removeClass('no-order').hide().fadeIn(200);
en_dis_list($(this), target_type); en_dis_list($(this), target_type);
} else { } else {
let disable_list = $(this).parents('.sort_box').find('.disable-normal-list'); 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('.product-list-sort-type').find('.order_param').prop('disabled', true);
$(this).parents('li').appendTo(disable_list).addClass('no-order').hide().fadeIn(200); $(this).parents('li').appendTo(disable_list).addClass('no-order').hide().fadeIn(200);
dis_list($(this)); dis_list($(this));
@@ -228,11 +228,11 @@ jQuery(function ($) {
select_msg = '既存のカスタムフィールドから選択'; select_msg = '既存のカスタムフィールドから選択';
add_msg = 'APOP専用カスタムフィールドを追加'; add_msg = 'APOP専用カスタムフィールドを追加';
} }
if (type == 1) { 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_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_key').prop('disabled', true).hide();
obj.parents('.product-list-sort-type').find('.custom-field-select-alert').text(select_msg); obj.parents('.product-list-sort-type').find('.custom-field-select-alert').text(select_msg);
} else if (type == 2) { } 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').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_key_select').prop('disabled', true).hide();
obj.parents('.product-list-sort-type').find('.custom-field-select-alert').text(add_msg); obj.parents('.product-list-sort-type').find('.custom-field-select-alert').text(add_msg);
+52 -4
View File
@@ -1,10 +1,10 @@
=== Archive Post Order Plus === === Archive Post Order Plus ===
Contributors: nbk45 Contributors: nbk45
Tags: latest posts order,categories post order,tags post order,custom taxonomy post order Tags: latest posts order,categories post order,tags post order,custom taxonomy post order
Requires at least: 4.9 Requires at least: 6.7
Tested up to: 5.8 Tested up to: 6.9
Requires PHP: 7.0 Requires PHP: 8.3
Stable tag: 1.1.7 Stable tag: 1.2.4
License: GPLv2 or later License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -18,6 +18,7 @@ This plugin is a plugin that customizes the posting order below.
- Category - Category
- Tag - Tag
- Custom Taxonomy - Custom Taxonomy
- Custom Posts Archive
このプラグインは、下記の投稿表示順をカスタマイズするプラグインです。 このプラグインは、下記の投稿表示順をカスタマイズするプラグインです。
・[設定]-[表示設定]の「最新の投稿」 ・[設定]-[表示設定]の「最新の投稿」
@@ -25,6 +26,7 @@ This plugin is a plugin that customizes the posting order below.
・カテゴリー ・カテゴリー
・タグ ・タグ
・カスタム分類 ・カスタム分類
・カスタム投稿アーカイブ
= Specification = = Specification =
Select either 1) standard + custom field sort or 2) drag sort for the display order. Select either 1) standard + custom field sort or 2) drag sort for the display order.
@@ -80,6 +82,52 @@ screenshot-7.png
screenshot-8.png screenshot-8.png
== Changelog == == 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 = = 1.1.7 =
Supports translation. Supports translation.
+6 -2
View File
@@ -18,6 +18,7 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
<?php wp_nonce_field( 'sh_options' ); ?> <?php wp_nonce_field( 'sh_options' ); ?>
<input id="apop_submit_type" type="hidden" name="apop_submit_type" <input id="apop_submit_type" type="hidden" name="apop_submit_type"
value="<?php echo esc_attr( $submit_type ); ?>"> value="<?php echo esc_attr( $submit_type ); ?>">
<!-- 最新の投稿の設定 -->
<div class="post-order-box"> <div class="post-order-box">
<div class="list-orders-outer"> <div class="list-orders-outer">
<div class="list-orders-inner"> <div class="list-orders-inner">
@@ -27,7 +28,6 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
$order_target = APOP_UI::get_order_type( $order_target_type ); $order_target = APOP_UI::get_order_type( $order_target_type );
?> ?>
<?php include APOP_PLUGIN_PATH . 'template/order_parts_menu.php'; ?> <?php include APOP_PLUGIN_PATH . 'template/order_parts_menu.php'; ?>
<hr>
<p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p> <p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p>
<div class="sort_box"> <div class="sort_box">
<div class="enable-box"> <div class="enable-box">
@@ -49,6 +49,7 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
</div> </div>
</div> </div>
</div> </div>
<!-- 検索の設定 -->
<div class="post-order-box"> <div class="post-order-box">
<div class="list-orders-outer"> <div class="list-orders-outer">
<div class="list-orders-inner"> <div class="list-orders-inner">
@@ -58,7 +59,6 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
$order_target = APOP_UI::get_order_type( $order_target_type ); $order_target = APOP_UI::get_order_type( $order_target_type );
?> ?>
<?php include APOP_PLUGIN_PATH . 'template/order_parts_menu.php'; ?> <?php include APOP_PLUGIN_PATH . 'template/order_parts_menu.php'; ?>
<hr>
<p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p> <p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p>
<div class="sort_box"> <div class="sort_box">
<div class="enable-box"> <div class="enable-box">
@@ -80,6 +80,7 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
</div> </div>
</div> </div>
</div> </div>
<!-- カテゴリーの設定 -->
<div class="post-order-box"> <div class="post-order-box">
<div class="tax_sort_box"> <div class="tax_sort_box">
<?php <?php
@@ -89,6 +90,7 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
?> ?>
</div> </div>
</div> </div>
<!-- タグの設定 -->
<div class="post-order-box"> <div class="post-order-box">
<div class="tax_sort_box"> <div class="tax_sort_box">
<?php <?php
@@ -98,6 +100,7 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
?> ?>
</div> </div>
</div> </div>
<!-- カスタム分類の設定 -->
<div class="post-order-box"> <div class="post-order-box">
<div class="tax_sort_box"> <div class="tax_sort_box">
<?php <?php
@@ -106,6 +109,7 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
include APOP_PLUGIN_PATH . 'template/order_parts_taxonomy.php'; ?> include APOP_PLUGIN_PATH . 'template/order_parts_taxonomy.php'; ?>
</div> </div>
</div> </div>
<!-- カスタム投稿アーカイブの設定 -->
<div class="post-order-box"> <div class="post-order-box">
<div class="tax_sort_box"> <div class="tax_sort_box">
<?php <?php
-2
View File
@@ -32,7 +32,6 @@
</ul> </ul>
<div class="sort_box"> <div class="sort_box">
<hr>
<p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p> <p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p>
<ul class="post-order-list drag-sort"> <ul class="post-order-list drag-sort">
<?php echo APOP_UI::create_custompost_archive_order_list( $custom_post['slug'] ); ?> <?php echo APOP_UI::create_custompost_archive_order_list( $custom_post['slug'] ); ?>
@@ -40,7 +39,6 @@
</div> </div>
<div class="sort_box"> <div class="sort_box">
<hr>
<p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p> <p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p>
<div class="enable-box"> <div class="enable-box">
<h4><?php _e( 'Enabled', APOP_DOMAIN ); ?></h4> <h4><?php _e( 'Enabled', APOP_DOMAIN ); ?></h4>
-2
View File
@@ -32,7 +32,6 @@
</ul> </ul>
<div class="sort_box"> <div class="sort_box">
<hr>
<p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p> <p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p>
<ul class="post-order-list drag-sort"> <ul class="post-order-list drag-sort">
<?php echo APOP_UI::create_order_list( $tax_data, $tax_key ); ?> <?php echo APOP_UI::create_order_list( $tax_data, $tax_key ); ?>
@@ -40,7 +39,6 @@
</div> </div>
<div class="sort_box"> <div class="sort_box">
<hr>
<p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p> <p><?php _e( 'Click "Save Changes" to register the sort.', APOP_DOMAIN ); ?></p>
<div class="enable-box"> <div class="enable-box">
<h4><?php _e( 'Enabled', APOP_DOMAIN ); ?></h4> <h4><?php _e( 'Enabled', APOP_DOMAIN ); ?></h4>
+23 -23
View File
@@ -1,35 +1,35 @@
<?php <?php
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} // Exit if accessed directly } // Exit if accessed directly
if ( ! trait_exists( 'CUSTOMFIELD_SELECT' ) ) { if ( ! trait_exists( 'CUSTOMFIELD_SELECT' ) ) {
trait CUSTOMFIELD_SELECT { trait CUSTOMFIELD_SELECT {
public function set_custom_field_ajax() { public function set_custom_field_ajax() {
$handle = 'custom_field_ajax'; $handle = 'custom_field_ajax';
wp_register_script( $handle, APOP_PLUGIN_URL . 'js/custom_field.js', [ 'jquery' ], '', true ); wp_register_script( $handle, APOP_PLUGIN_URL . 'js/custom_field.js', [ 'jquery' ], '', true );
$localize = [ $localize = [
'ajax_url' => admin_url( 'admin-ajax.php' ), 'ajax_url' => admin_url( 'admin-ajax.php' ),
'action' => 'set_custom_field', 'action' => 'set_custom_field',
]; ];
wp_localize_script( $handle, 'localize', $localize ); wp_localize_script( $handle, 'localize', $localize );
wp_enqueue_script( $handle ); wp_enqueue_script( $handle );
} }
public function set_custom_field() { public function set_custom_field() {
$param = filter_input( INPUT_GET, 'param', FILTER_SANITIZE_STRING ); $param = filter_input( INPUT_GET, 'param', FILTER_DEFAULT );
echo json_encode( $this->get_custom_fields_by_param( $param ) ); echo json_encode( $this->get_custom_fields_by_param( $param ) );
die(); die();
} }
private function get_custom_fields_by_param( $param ) { private function get_custom_fields_by_param( $param ) {
global $wpdb; 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"; $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( '_%' ) ) ); return $wpdb->get_results( $wpdb->prepare( $stmnt, $wpdb->esc_like( $param ) . '%', $wpdb->esc_like( '_%' ) ) );
} }
} }
} }
+4
View File
@@ -121,6 +121,10 @@ if ( ! trait_exists( 'CUSTOMPOSTS' ) ) {
return; return;
} }
if( ! isset($per_page_option['custompost_archive'] ) ){
return;
}
$per_page_option_data = $per_page_option['custompost_archive'][ $post_type ]; $per_page_option_data = $per_page_option['custompost_archive'][ $post_type ];
if ( ! isset( $per_page_option_data ) ) { if ( ! isset( $per_page_option_data ) ) {
return; return;
-2
View File
@@ -57,7 +57,6 @@ if ( ! trait_exists( 'APOP_OUTPUT' ) ) {
return $meta_orderby; return $meta_orderby;
} }
return;
} }
/** /**
@@ -95,7 +94,6 @@ if ( ! trait_exists( 'APOP_OUTPUT' ) ) {
return self::set_tax_custom_field_orderby( $id ); return self::set_tax_custom_field_orderby( $id );
} }
return;
} }
} }