From ff1dcdc5f46140e5a8794c5347f6c94003751171 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 19 Jun 2021 09:18:48 +0900 Subject: [PATCH] =?UTF-8?q?WP=20PLUGIN=E3=80=80=E3=82=A8=E3=82=B9=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=83=97=E5=87=A6=E7=90=86=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ・echo時にエスケープするようメソッド修正 ・HTMLタグないのエスケープをesc_attr()に変更 --- class/class.apop.apop_post.php | 15 ++- class/class.apop.apop_ui.php | 123 ++++++++++++------------- template/order.php | 18 ++-- template/order_parts_menu.php | 6 +- template/order_parts_taxonomy.php | 15 +-- template/setting.php | 81 ++++++++-------- template/setting_parts_taxonomy.php | 30 +++--- template/setting_post_custom_field.php | 4 +- 8 files changed, 144 insertions(+), 148 deletions(-) diff --git a/class/class.apop.apop_post.php b/class/class.apop.apop_post.php index efb098e..f17e540 100644 --- a/class/class.apop.apop_post.php +++ b/class/class.apop.apop_post.php @@ -38,9 +38,13 @@ if ( ! class_exists( 'APOP_POST' ) ) { public function insert_meta_fields() { //通常ソート - $this->create_order_field_data( get_option( '_apop_normal_order_param' ), 'normal' ); + if ( get_option( '_apop_normal_order' ) == '1' ) { + $this->create_order_field_data( get_option( '_apop_normal_order_param' ), 'normal' ); + } //検索ソート - $this->create_order_field_data( get_option( '_apop_search_order_param' ), 'search' ); + if ( get_option( '_apop_tax_sort_type' ) == '1' ) { + $this->create_order_field_data( get_option( '_apop_search_order_param' ), 'search' ); + } //カテゴリー、タグ、カスタム分類 $this->create_order_tax_field_data( get_option( '_apop_tax_order_param' ) ); @@ -75,7 +79,14 @@ if ( ! class_exists( 'APOP_POST' ) ) { 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'] ) ) { diff --git a/class/class.apop.apop_ui.php b/class/class.apop.apop_ui.php index eb6120b..28d0aab 100644 --- a/class/class.apop.apop_ui.php +++ b/class/class.apop.apop_ui.php @@ -15,9 +15,7 @@ if ( ! class_exists( 'APOP_UI' ) ) { return $type_data; } - public static function get_all_search_normal_posts( - $key - ): string { + public static function get_all_search_normal_posts( $key ) { $meta_key = '_apop_post_' . $key; $args = self::create_search_normal_args( $meta_key ); $posts_data = get_posts( $args ); @@ -25,13 +23,14 @@ if ( ! class_exists( 'APOP_UI' ) ) { 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[] = '
  • ' . esc_html( self::crate_non_registerd_mark( $no_order ) ) . ' -' . esc_html( $order ) . '' . esc_html( $post_data->post_title ) . ' - -
  • '; + echo '
  • ' + . esc_attr( self::crate_non_registerd_mark( $no_order ) ) + . '' . esc_html( $order ) . '' . esc_html( $post_data->post_title ) + . ' +
  • '; } - - return implode( PHP_EOL, $list ); } private static function crate_non_registerd_mark( $no_order ): string { @@ -270,7 +269,7 @@ value="' . esc_html( $sort_num ) . '"> ); } - public static function create_search_normal_list( $type, $id = null ): array { + 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']; @@ -298,67 +297,64 @@ value="' . esc_html( $sort_num ) . '"> $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 = ''; $name_use_key = '_' . $name_key . '[' . $target_key . '][use]'; $name_sort_key = '_' . $name_key . '[' . $target_key . '][sort]'; 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[] = '
  • -
    ' . esc_html( $target_values[ $target_key ] ) . '
    -
    - - - - ' . $field_metakey_input . ' -
    -
  • '; - } - return array( - implode( PHP_EOL, $list ), - $alert, - ); + echo '
  • +
    ' . esc_attr( $target_values[ $target_key ] ) . '
    +
    + + + '; + + if ( strpos( $target_key, 'custom_field' ) !== false ) { + self::create_custom_field_sort_type( $name_key, $target_key, $cnv_order_params ); + } + + echo '
    +
  • '; + } } - private static function create_custom_field_sort_type( $name_key, $target_key, $meta_key, $value_type ): string { + 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']; $name_meta_key = '_' . $name_key . '[' . $target_key . '][field][meta_key]'; $name_value_type = '_' . $name_key . '[' . $target_key . '][field][value_type]'; - - return '
    -
    カスタムフィールドキー:
    - -
    -
    -
    値タイプ:
    - - -
    -
    '; + echo '
    +
    カスタムフィールドキー:
    + +
    +
    +
    値タイプ:
    + + +
    +
    '; } private static function set_order_list_param( $order_param, $target_key ): array { @@ -366,9 +362,9 @@ value="meta_value_num"' . esc_html( self::set_search_normal_checked( $value_type $param = array( 'use' => 0, 'sort' => 2, - 'alert' => '並べ替えを登録するには「変更を保存」をクリックしてください。', 'no_order_class' => ' no_order', ); + if ( strpos( $target_key, 'custom_field' ) !== false ) { $param[ $target_key ] = array( 'meta_key' => '', @@ -380,7 +376,6 @@ value="meta_value_num"' . esc_html( self::set_search_normal_checked( $value_type $param = array( 'use' => $order_param[ $target_key ]['use'] ?? 0, 'sort' => $order_param[ $target_key ]['sort'] ?? 2, - 'alert' => ! $order_param[ $target_key ]['use'] ? '並べ替えを登録するには「変更を保存」をクリックしてください。' : '', 'no_order_class' => ! $order_param[ $target_key ]['use'] ? ' no_order' : '', ); if ( strpos( $target_key, 'custom_field' ) !== false ) { @@ -448,11 +443,11 @@ value="meta_value_num"' . esc_html( self::set_search_normal_checked( $value_type } } - public static function is_disp_per_page( &$disp, $disp_per_page ) { - if ( $disp_per_page ) { - $disp = true; - } - } +// public static function is_disp_per_page( &$disp, $disp_per_page ) { +// if ( $disp_per_page ) { +// $disp = true; +// } +// } } } \ No newline at end of file diff --git a/template/order.php b/template/order.php index 134dfae..7d9a0e7 100644 --- a/template/order.php +++ b/template/order.php @@ -16,7 +16,7 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
    + value="">
    @@ -27,13 +27,12 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' ); ?>
    +

    並べ替えを登録するには「変更を保存」をクリックしてください

    - -

    有効

      - +
    @@ -42,9 +41,8 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
    -
    ■は未登録項目です。ドラッグして並び順を変更後に「変更を保存」をクリックしてください。
      - +
    @@ -60,13 +58,12 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' ); ?>
    +

    並べ替えを登録するには「変更を保存」をクリックしてください

    - -

    有効

      - +
    @@ -75,9 +72,8 @@ $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 7fa395c..e1fc517 100644 --- a/template/order_parts_menu.php +++ b/template/order_parts_menu.php @@ -1,11 +1,11 @@
      + data-order_target="">
    $tax_list ) : ?>
    0 ): ?> -
    ■は未登録項目です。ドラッグして並び順を変更後に「変更を保存」をクリックしてください。

    name ); ?>

    @@ -15,33 +14,35 @@ } ?>
      + data-order_target="">
    +
    +

    並べ替えを登録するには「変更を保存」をクリックしてください

    - term_id ); ?> -

    +
    +

    並べ替えを登録するには「変更を保存」をクリックしてください

    有効

      - + term_id ); ?>
    diff --git a/template/setting.php b/template/setting.php index d96d327..7ede176 100644 --- a/template/setting.php +++ b/template/setting.php @@ -1,47 +1,44 @@
    - -

    設定

    - - - - - - - - -
    全体設定 -
    -
    1ページ表示件数
    -
    -
      -
    • - -
    • -
    • -
    • -
    • - -
    • -
    -
    -
    -
    + +

    設定

    + + + + + + + + +
    全体設定 +
    +
    1ページ表示件数
    +
    +
      +
    • + +
    • +
    • +
    • +
    • + +
    • +
    +
    +
    +

    \ No newline at end of file diff --git a/template/setting_parts_taxonomy.php b/template/setting_parts_taxonomy.php index b08572d..00e0a41 100644 --- a/template/setting_parts_taxonomy.php +++ b/template/setting_parts_taxonomy.php @@ -1,8 +1,4 @@ -
    対象
    @@ -11,48 +7,48 @@ term_id ] ?? ''; - APOP_UI::is_disp_per_page( $disp, $check_slug ); ?>
  • - term_id ); ?> + term_id ); ?>
    diff --git a/template/setting_post_custom_field.php b/template/setting_post_custom_field.php index 5e5f702..e55db16 100644 --- a/template/setting_post_custom_field.php +++ b/template/setting_post_custom_field.php @@ -9,8 +9,8 @@
  • + name="" + value="get_custom_field_data( $item ) ); ?>"/>