diff --git a/archive-post-order-plus.php b/archive-post-order-plus.php index 1ad5203..76ec47e 100644 --- a/archive-post-order-plus.php +++ b/archive-post-order-plus.php @@ -22,18 +22,9 @@ License: GPLv2 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/** - * TODO: - 1)カテゴリーのソート用カスタムフィールド取得と設定 - ・保存しているタームIDと投稿が属するタームIDが一致する場合、管理画面に表示する - class.apop.apop_post.php、setting_post_custom_field.php - * 2)uninstall.php - * 投稿とタクソノミーのカスタムフィールド削除方法修正 - * ・delete_post_meta_by_key()を廃止し、WP_QUERYに変更する - */ - define( 'APOP_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'APOP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); +define( 'APOP_CUSTOM_FIELD_PREFIX', '_apop_postorder_' ); //メイン処理のクラスをインスタンス化 require_once __DIR__ . '/class/class.apop.order.php'; diff --git a/class/class.apop.apop_post.php b/class/class.apop.apop_post.php index b950f84..cf50787 100644 --- a/class/class.apop.apop_post.php +++ b/class/class.apop.apop_post.php @@ -110,7 +110,7 @@ if ( ! class_exists( 'APOP_POST' ) ) { private function get_custom_field_data( $custom_filed_name ) { global $post; - return get_post_meta( $post->ID, $custom_filed_name, true ); + return get_post_meta( $post->ID, APOP_CUSTOM_FIELD_PREFIX . $custom_filed_name, true ); } // カスタムフィールドの値を保存 @@ -118,8 +118,9 @@ if ( ! class_exists( 'APOP_POST' ) ) { $this->get_update_meta_fields(); if ( count( $this->name_keys ) > 0 ) { foreach ( $this->name_keys as $name_key ) { - update_post_meta( $post_id, $name_key, $_POST[ $name_key ] ?? '' ); - update_post_meta( $post_id, $name_key, $_POST[ $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 ] ?? '' ); } } } diff --git a/class/class.apop.apop_ui.php b/class/class.apop.apop_ui.php index 2d0f6fd..524279e 100644 --- a/class/class.apop.apop_ui.php +++ b/class/class.apop.apop_ui.php @@ -447,7 +447,7 @@ value="meta_value_num"' . self::set_search_normal_checked( $value_type, 'meta_va } public static function create_none_select_msg( $str ): string { - return '

並べ替えをカスタマイズする' . $str . 'は選択されていません。

'; + return '

並べ替えをカスタマイズする' . $str . 'は選択されていません。

'; } public static function none_registered_alert_msg(): string { diff --git a/css/apop-style.css b/css/apop-style.css index 54598c3..6a1ef4e 100644 --- a/css/apop-style.css +++ b/css/apop-style.css @@ -131,7 +131,11 @@ dl.apop_setting_list_dd dd input { background: #fff; cursor: move; color: #4b4b4b; - border: 1px solid #ccc; + border-bottom: 1px solid #ccc; +} + +.enable_box .product-list { + padding: 1em 0; } .search_normal_sort .product-list { @@ -140,6 +144,10 @@ dl.apop_setting_list_dd dd input { .search_normal_sort .product-list-type-label, .disable_box .product-list-type-label { + width: calc((100%) - 60px); +} + +.enable_box .product-list-type-label { width: calc(100% / 2); } @@ -218,7 +226,7 @@ dl.apop_setting_list_dd dd input { } .disable_box .product-list { - width: calc((100% / 2) - 20px); + width: calc((100% / 2) - 15px); display: flex; cursor: default; } @@ -235,12 +243,41 @@ dl.apop_setting_list_dd dd input { padding-left: .5em; } +.enable_box { + margin-bottom: 1em; +} + +.enable_box, +.disable_box { + padding: .5em; + border: 1px solid #ccc; +} + +.enable_box h4 { + margin: .5em 0 0; +} + +.disable_box h4 { + margin: .5em 0; +} + @media only screen and (max-width: 1264px) { + .enable_box .product-list, + .disable_box .product-list { + display: block; + } + .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; diff --git a/template/order.php b/template/order.php index 72103de..96c662c 100644 --- a/template/order.php +++ b/template/order.php @@ -29,10 +29,12 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
-

有効

- +
+

有効

+ +

無効

@@ -60,10 +62,12 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
-

有効

-
    - -
+
+

有効

+
    + +
+

無効

    diff --git a/template/order_parts_taxonomy.php b/template/order_parts_taxonomy.php index 117ee71..f5bd471 100644 --- a/template/order_parts_taxonomy.php +++ b/template/order_parts_taxonomy.php @@ -38,10 +38,12 @@
    term_id ); ?> -

    有効

    -
      - -
    +
    +

    有効

    +
      + +
    +

    無効

      diff --git a/template/setting_post_custom_field.php b/template/setting_post_custom_field.php index 8077d83..81bfe3d 100644 --- a/template/setting_post_custom_field.php +++ b/template/setting_post_custom_field.php @@ -8,7 +8,7 @@
    • -
    • diff --git a/uninstall.php b/uninstall.php index 657cf19..fbe738e 100644 --- a/uninstall.php +++ b/uninstall.php @@ -7,42 +7,39 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { //通常と検索の表示件数、ソート対象設定等を削除 $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_tax_order_param', + '_apop_tax_sort_type', + '_apop_normal_order', + '_apop_search_order', + '_apop_cat_order', + '_apop_tag_order', + '_apop_tax_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_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 ); } - - - - diff --git a/util/apop-order-setting.php b/util/apop-order-setting.php index bee7095..7070a3d 100644 --- a/util/apop-order-setting.php +++ b/util/apop-order-setting.php @@ -90,7 +90,7 @@ if ( ! trait_exists( 'APOP_ORDER_SETTING' ) ) { 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']; + $meta_key = APOP_CUSTOM_FIELD_PREFIX . $orders['field']['meta_key']; $orderby_sort = $orders['sort']; $type = 'CHAR'; if ( $orders['field']['value_type'] == 'meta_value_num' ) {