From 00d6775f7760cb6511a00650de0bde2d9cfc49d3 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 17 Jun 2021 14:00:18 +0900 Subject: [PATCH] =?UTF-8?q?WP=20PLUGIN=E3=80=80=E7=94=B3=E8=AB=8B=E6=8C=87?= =?UTF-8?q?=E6=91=98=E4=BA=8B=E9=A0=85=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ・$_POSTのサニタイズ ・echoのエスケープ ・readmeの修正 --- archive-post-order-plus.php | 8 ++-- class/class.apop.apop_post.php | 3 +- class/class.apop.apop_ui.php | 4 +- css/apop-style.css | 4 ++ readme.txt | 51 ++++++++++++++------------ template/order.php | 4 +- template/order_parts_menu.php | 6 +-- template/order_parts_taxonomy.php | 10 ++--- template/setting.php | 6 +-- template/setting_parts_taxonomy.php | 22 +++++------ template/setting_post_custom_field.php | 4 +- util/apop-order-setting.php | 49 +++++++++++++------------ 12 files changed, 91 insertions(+), 80 deletions(-) diff --git a/archive-post-order-plus.php b/archive-post-order-plus.php index 76ec47e..70bd34c 100644 --- a/archive-post-order-plus.php +++ b/archive-post-order-plus.php @@ -4,8 +4,8 @@ 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 +Description: 通常表示、検索表示、タクソノミー毎に投稿の表示順を設定するプラグイン +Version: 1.0.1 License: GPLv2 */ @@ -35,8 +35,8 @@ $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', 'mtee_register_my_styles' ); +function mtee_register_my_styles() { wp_enqueue_style( 'hrc_post_style', APOP_PLUGIN_URL . 'css/apop-style.css' ); wp_enqueue_script( 'jquery-ui-sortable' ); wp_enqueue_script( 'post-sort-cat-order_js', APOP_PLUGIN_URL . 'js/apop-style.js' ); diff --git a/class/class.apop.apop_post.php b/class/class.apop.apop_post.php index cf50787..efb098e 100644 --- a/class/class.apop.apop_post.php +++ b/class/class.apop.apop_post.php @@ -119,8 +119,7 @@ if ( ! class_exists( 'APOP_POST' ) ) { 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, $_POST[ $save_key ] ?? '' ); - update_post_meta( $post_id, $save_key, $_POST[ $save_key ] ?? '' ); + update_post_meta( $post_id, $save_key, APOP_UI::input_post_filter( $save_key, 'str' ) ); } } } diff --git a/class/class.apop.apop_ui.php b/class/class.apop.apop_ui.php index 524279e..f693ec0 100644 --- a/class/class.apop.apop_ui.php +++ b/class/class.apop.apop_ui.php @@ -433,10 +433,10 @@ value="meta_value_num"' . self::set_search_normal_checked( $value_type, 'meta_va public static function input_post_filter( $var_name, $type ) { if ( $type == 'array' ) { - return filter_input( INPUT_POST, $var_name, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + return filter_input( INPUT_POST, $var_name, FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY ); } if ( $type == 'str' ) { - return filter_input( INPUT_POST, $var_name ); + return filter_input( INPUT_POST, $var_name, FILTER_SANITIZE_STRING ); } } diff --git a/css/apop-style.css b/css/apop-style.css index 6a1ef4e..b0a3998 100644 --- a/css/apop-style.css +++ b/css/apop-style.css @@ -134,6 +134,10 @@ dl.apop_setting_list_dd dd input { border-bottom: 1px solid #ccc; } +.drag_sort .product-list { + border: 1px solid #ccc; +} + .enable_box .product-list { padding: 1em 0; } diff --git a/readme.txt b/readme.txt index 45c59da..f0eded1 100644 --- a/readme.txt +++ b/readme.txt @@ -1,56 +1,61 @@ -=== 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 +Tested up to: 5.7.2 Requires PHP: 7.0 -Stable tag: 1.0.0 +Stable tag: 1.0.1 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html -アーカイブページの投稿表示順をタクソノミー毎に設定するプラグイン。 +投稿の表示順を通常とタクソノミー毎に設定するプラグイン。 == Description == -このプラグインはタクソノミー毎に投稿表示順を設定するプラグインです。 +このプラグインは通常表示とタクソノミー毎に投稿表示順を設定するプラグインです。 = 仕様 = -投稿表示順をカスタマイズしたいタクソノミーを選択します。 -選択した各タクソノミー内の投稿順をドラッグ&ドロップで変更し保存します。 +カスタマイズしたいカテゴリー、タグ、カスタム分類毎に投稿表示順を設定可能にします。 +表示順は 1)通常+カスタムフィールドソート、2)ドラッグソートのどちらが選択可能です。 + +1)通常+カスタムフィールドソート +投稿の更新日、ID、タイトル、登録日のソートに加え、4つのカスタムフィールドが登録可能です。 +有効にしたい項目を選択し、ドラッグで順番を設定します。 + +2)ドラッグソート +カテゴリー、タグ、カスタム分類に属する投稿表示順をドラッグで設定します。 -【サブクエリコード】 -get_posts()などを利用する場合、下記のコードに並び順のパラメータを取得できます。 -

-
-
== Installation == = 自動インストール = -1. プラグインの検索フィールドより「Archive Post Order Plus」や「投稿表示順」と入力し、"プラグインの検索"をクリックします。 -1. 当プラグインを見つけたら、"今すぐインストール"をクリックしてインストールし、プラグインを有効化してください。 +1. プラグインの検索フィールドより「Archive Post Order Plus」と入力し、"プラグインの検索"をクリックします。 +2. 当プラグインを見つけたら、"今すぐインストール"をクリックしてインストールし、プラグインを有効化してください。 = 手動インストール = 1. プラグインをダウンロードします。 -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 + == Changelog == = 1.0.0 = -Initial working version. +初回リリース + += 1.0.1 = +関数名の修正と$_POSTのサニタイズとHTML出力のエスケープ + == Upgrade Notice == No information + + +== Arbitrary section == \ No newline at end of file diff --git a/template/order.php b/template/order.php index 96c662c..4931a1a 100644 --- a/template/order.php +++ b/template/order.php @@ -42,7 +42,7 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
-
@@ -75,7 +75,7 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
-
diff --git a/template/order_parts_menu.php b/template/order_parts_menu.php index 2d10a3e..7fa395c 100644 --- a/template/order_parts_menu.php +++ b/template/order_parts_menu.php @@ -1,11 +1,11 @@
-

name; ?>

+

name); ?>

term_id ] ) ) { @@ -15,23 +15,23 @@ } ?>
-
    +
diff --git a/template/setting.php b/template/setting.php index 878e3ce..d96d327 100644 --- a/template/setting.php +++ b/template/setting.php @@ -17,7 +17,7 @@
  • diff --git a/template/setting_parts_taxonomy.php b/template/setting_parts_taxonomy.php index 0c185e1..b08572d 100644 --- a/template/setting_parts_taxonomy.php +++ b/template/setting_parts_taxonomy.php @@ -17,13 +17,13 @@
    term_id ); ?> @@ -32,27 +32,27 @@
  • diff --git a/template/setting_post_custom_field.php b/template/setting_post_custom_field.php index 81bfe3d..d7ebb71 100644 --- a/template/setting_post_custom_field.php +++ b/template/setting_post_custom_field.php @@ -2,12 +2,12 @@ order_field ) && count( $this->order_field ) > 0 ): ?>
    order_field as $type => $items ): ?> -
    labels[ $type ]; ?>
    +
    labels[ $type ]); ?>
      -
    • +
    • diff --git a/util/apop-order-setting.php b/util/apop-order-setting.php index 7070a3d..d8e48d0 100644 --- a/util/apop-order-setting.php +++ b/util/apop-order-setting.php @@ -199,8 +199,32 @@ if ( ! trait_exists( 'APOP_ORDER_SETTING' ) ) { ); } + /** - * 通常ページの1ページ表示件数を取得する + * + * 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 */ @@ -228,7 +252,7 @@ if ( ! trait_exists( 'APOP_ORDER_SETTING' ) ) { } /** - * カテゴリー、タグ、カスタム分類の1ページ表示件数を取得する + * カテゴリー、タグ、カスタム分類のソートを取得する * APOP::orderby_tax([ID, TARGET], ); * [TARGET] * cat @@ -265,26 +289,5 @@ if ( ! trait_exists( 'APOP_ORDER_SETTING' ) ) { 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'; - } - - return array( 'posts_per_page' => self::set_per_page( $target, $id ) ); - } } }