WP PLUGIN 申請指摘事項の修正

・$_POSTのサニタイズ
・echoのエスケープ
・readmeの修正
This commit is contained in:
2021-06-17 14:00:18 +09:00
parent e3c8fc967c
commit 00d6775f77
12 changed files with 91 additions and 80 deletions
+4 -4
View File
@@ -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' );
+1 -2
View File
@@ -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' ) );
}
}
}
+2 -2
View File
@@ -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 );
}
}
+4
View File
@@ -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;
}
+28 -23
View File
@@ -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()などを利用する場合、下記のコードに並び順のパラメータを取得できます。
<pre><code>
<?php
?>
</code></pre>
== 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 ==
+2 -2
View File
@@ -42,7 +42,7 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
</div>
<div class="sort_box">
<?php echo APOP_UI::none_registered_alert_msg(); ?>
<ul class="post-order-list">
<ul class="post-order-list drag_sort">
<?php echo APOP_UI::get_all_search_normal_posts( 'normal' ); ?>
</ul>
</div>
@@ -75,7 +75,7 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
</div>
<div class="sort_box">
<?php echo APOP_UI::none_registered_alert_msg(); ?>
<ul class="post-order-list">
<ul class="post-order-list drag_sort">
<?php echo APOP_UI::get_all_search_normal_posts( 'search' ); ?>
</ul>
</div>
+3 -3
View File
@@ -1,11 +1,11 @@
<?php if ( isset( $order_target, $order_target_type ) ): ?>
<ul class="sort_menu_list"
data-order_target="<?php echo $order_target; ?>">
data-order_target="<?php echo esc_html($order_target); ?>">
<li><label>
<input class="sort_menu" type="radio" name="<?php echo $order_target_type; ?>"
<input class="sort_menu" type="radio" name="<?php echo esc_html($order_target_type); ?>"
value="1"<?php checked( $order_target, 1 ); ?>>標準+カスタムフィールドソート</label></li>
<li><label>
<input class="sort_menu" type="radio" name="<?php echo $order_target_type; ?>"
<input class="sort_menu" type="radio" name="<?php echo esc_html($order_target_type); ?>"
value="2"<?php checked( $order_target, 2 ); ?>>ドラッグソート</label></li>
</ul>
<?php endif;
+5 -5
View File
@@ -5,7 +5,7 @@
<?php echo APOP_UI::none_registered_alert_msg(); ?>
<?php foreach ( $tax_list as $tax_data ): ?>
<div class="list-orders-inner">
<h3><?php echo $tax_data->name; ?></h3>
<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 ] ) ) {
@@ -15,23 +15,23 @@
}
?>
<ul class="sort_menu_list"
data-order_target="<?php echo $order_target; ?>">
data-order_target="<?php echo esc_html($order_target); ?>">
<li>
<label>
<input class="sort_menu" type="radio"
name="_apop_tax_sort_type[<?php echo $tax_data->term_id; ?>]"
name="_apop_tax_sort_type[<?php echo esc_html($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; ?>]"
name="_apop_tax_sort_type[<?php echo esc_html($tax_data->term_id); ?>]"
value="2"<?php checked( $order_target, 2 ); ?>>標準+カスタムフィールドソート</label>
</li>
</ul>
<div class="sort_box">
<ul class="post-order-list">
<ul class="post-order-list drag_sort">
<?php echo APOP_UI::create_order_list( $tax_data, $tax_key ); ?>
</ul>
</div>
+3 -3
View File
@@ -17,7 +17,7 @@
<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; ?>
value="default"<?php checked( $per_page_data['_per_page'], 'default' ); ?>>表示設定に従う(<?php echo esc_html($default_per_page); ?>
件)</label>
</li>
<li><label>
@@ -27,10 +27,10 @@
<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_html($per_page_data['_checked']); ?>">表示数設定
<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_html($per_page_data['_per_page_num']); ?>" required>
</label>
</li>
</ul>
+11 -11
View File
@@ -17,13 +17,13 @@
<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_html($order_name); ?>[target_cat][<?php echo esc_html($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_html($order_name); ?>[target_cat][<?php echo esc_html($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 ); ?>
@@ -32,27 +32,27 @@
<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; ?>
name="_apop_per_page[<?php echo esc_html($order_tax); ?>][<?php echo esc_html($tax_datum->term_id); ?>]"
value="default"<?php checked( $per_page_data['_per_page'], 'default' ); ?>>表示設定に従う(<?php echo esc_html($default_per_page); ?>
件)</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; ?>]"
name="_apop_per_page[<?php echo esc_html($order_tax); ?>][<?php echo esc_html($tax_datum->term_id); ?>]"
value="all"<?php checked( $per_page_data['_per_page'], 'all' ); ?>>全体設定に従う</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; ?>]"
name="_apop_per_page[<?php echo esc_html($order_tax); ?>][<?php echo esc_html($tax_datum->term_id); ?>]"
value="-1"<?php checked( $per_page_data['_per_page'], '-1' ); ?>>全件</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_html($order_tax); ?>][<?php echo esc_html($tax_datum->term_id); ?>]"
value=""<?php echo esc_html($per_page_data['_checked']); ?>>表示数設定
<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_html($order_tax); ?>][<?php echo esc_html($tax_datum->term_id); ?>]"
value="<?php echo esc_html($per_page_data['_per_page_num']); ?>" required>
</label>
</li>
</ul>
+2 -2
View File
@@ -2,12 +2,12 @@
<?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 $this->labels[ $type ]; ?></dt>
<dt><?php echo esc_html($this->labels[ $type ]); ?></dt>
<dd>
<ul>
<?php foreach ( $items as $item ): ?>
<?php if ( ! empty( $item ) ): ?>
<li><label><?php echo $item; ?></label>
<li><label><?php echo esc_html($item); ?></label>
<input type="text" name="<?php echo APOP_CUSTOM_FIELD_PREFIX . $item; ?>"
value="<?php echo $this->get_custom_field_data( $item ); ?>"/>
</li>
+26 -23
View File
@@ -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 ) );
}
}
}