diff --git a/archive-post-oder-plus.php b/archive-post-oder-plus.php index 536fa30..ba45733 100644 --- a/archive-post-oder-plus.php +++ b/archive-post-oder-plus.php @@ -22,6 +22,16 @@ License: GPLv2 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * todo:カスタムフィールド追加処理 + * 指定したキーが無ければ、投稿の管理画面表示時にメタボックスを追加する。 + * メタキーは下記のオプションテーブルから取得する + * _apop_normal_order_param + * _apop_search_order_param + * _apop_tax_order_param + * ラベルは「APO+カスタムフィールド:XXXX」とする + */ + define( 'APOP_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'APOP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); diff --git a/class/class.apop.order.php b/class/class.apop.order.php index 1fdf512..90af176 100644 --- a/class/class.apop.order.php +++ b/class/class.apop.order.php @@ -23,8 +23,7 @@ if ( ! class_exists( 'APOP' ) ) { 'level_8', 'apop_post_sort', array( $this, 'display_setting_page' ), - '', - 50 + '' ); add_submenu_page( 'apop_post_sort', // parent_slug diff --git a/class/class.apop.ui.php b/class/class.apop.ui.php index ee78e24..ac0f1f4 100644 --- a/class/class.apop.ui.php +++ b/class/class.apop.ui.php @@ -288,57 +288,67 @@ value="' . $sort_num . '"> ); $list = array(); 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']; - $alert = $cnv_order_params['alert']; - $no_order_class = $cnv_order_params['no_order_class']; + $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 = ''; if ( $target_key == 'custom_field' ) { - $meta_key = $cnv_order_params['custom_field']['meta_key']; - $value_type = $cnv_order_params['custom_field']['value_type']; - $field_metakey_input = self::create_custom_field_sort_type( $name_key, $target_key, $meta_key, $value_type ); + $meta_key = $cnv_order_params['custom_field']['meta_key']; + $value_type = $cnv_order_params['custom_field']['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[] = '
  • ' . $target_values[ $target_key ] . '
    + ' . $field_metakey_input . '
  • '; } return array( implode( PHP_EOL, $list ), - $alert, - $field_metakey_input, + $alert ); } private static function create_custom_field_sort_type( $name_key, $target_key, $meta_key, $value_type ): string { - return '
    カスタムフィールドキー: - -値タイプ: + return '
    +
    カスタムフィールドキー:
    + +
    +
    +
    値タイプ:
    +
    '; } private static function set_order_list_param( $order_param, $target_key ): array { - + $param = array( 'use' => 0, 'sort' => 2, diff --git a/css/apop-style.css b/css/apop-style.css index a81a046..5985241 100644 --- a/css/apop-style.css +++ b/css/apop-style.css @@ -119,6 +119,7 @@ dl.apop_setting_list dd:first-of-type { .search_normal_sort .product-list-sort-type { width: 100%; display: flex; + flex-wrap: wrap; } .search_normal_sort .product-list-sort-type label { @@ -161,8 +162,23 @@ dl.apop_setting_list dd:first-of-type { border-top: 1px solid #ccc; } -.sort_custom_field{ +.sort_custom_field { width: 100%; + margin-top: .5em; + padding-top: .5em; + border-top: 1px solid #ccc; +} + +.sort_custom_field_inner { + display: flex; +} + +.sort_custom_field_inner:first-child { + margin-bottom: .5em; +} + +.sort_custom_field_inner_label { + width: 40%; } @media only screen and (max-width: 1264px) { diff --git a/js/apop-style.js b/js/apop-style.js index 32fc553..76dbb02 100644 --- a/js/apop-style.js +++ b/js/apop-style.js @@ -7,8 +7,6 @@ jQuery(function ($) { order_list(); //order type - // change_search_order(); - // change_normal_order(); change_sort_box(); //Tax select @@ -18,6 +16,8 @@ jQuery(function ($) { change_search_per_page(); change_tax_per_page(); + change_custom_field_sort(); + change_normal_field_sort(); function change_tab_menu() { let submit_type = $('.post-order-box-outer').data('submit_type'); @@ -60,80 +60,23 @@ jQuery(function ($) { } } - function change_normal_order() { - let s_radio = $('.apop_normal_order'); - let s_box = $('.normal_sort_box'); - let default_index = $('.apop_normal_order_target').data('normal_order_target') - 1; - - s_box.hide().find('input').each(function () { - $(this).prop('disabled', true); - }); - $('.normal_sort_box:eq(' + default_index + ')').show().find('input').prop('disabled', false); - - s_radio.on('click', function () { - let target_index = $(this).val() - 1; - s_box.hide().find('input').each(function () { - $(this).prop('disabled', true); - }); - $('.normal_sort_box:eq(' + target_index + ')').show().find('input').prop('disabled', false); - }) - } - - function change_search_order() { - let s_radio = $('.apop_search_order'); - let s_box = $('.search_sort_box'); - let default_index = $('.apop_search_order_target').data('search_order_target') - 1; - - s_box.hide().find('input').each(function () { - $(this).prop('disabled', true); - }); - - $('.search_sort_box:eq(' + default_index + ')').show().find('input').prop('disabled', false); - - s_radio.on('click', function () { - let target_index = $(this).val() - 1; - s_box.hide().find('input').each(function () { - $(this).prop('disabled', true); - }); - $('.search_sort_box:eq(' + target_index + ')').show().find('input').prop('disabled', false); - }) - } - - function change_sort_box() { - let parent_selector = $('.list-orders-inner'); - let parent_selector_size = parent_selector.length; let s_radio = $('.sort_menu'); - let s_box = $('.sort_box'); + let sort_menu_size = $('.sort_menu_list').length; - s_box.hide().find('input').each(function () { - $(this).prop('disabled', true); - }); - - for (let i = 0; i < parent_selector_size; i++) { - let my_target = $('.list-orders-inner:eq(' + i + ')'); - let default_index = my_target.find('.sort_menu_list').data('order_target') - 1; - if (typeof default_index !== "undefined") { - my_target.find('.sort_box:eq(' + default_index + ')').show().find('input').prop('disabled', false); - } else if (isNaN(default_index)) { - my_target.find('.sort_box:eq(0)').show().find('input').prop('disabled', false); - } + $('.sort_box').hide(); + for (let i = 0; i < sort_menu_size; i++) { + let type_index = $('.sort_menu_list:eq(' + i + ')').data('order_target') - 1; + $('.sort_menu_list:eq(' + i + ')').siblings('.sort_box:eq(' + type_index + ')').show(); } s_radio.on('click', function () { let target_index = $(this).val() - 1; - $(this).parents('.list-orders-inner') - .find('.sort_box').hide() - .find('input').each(function () { - $(this).prop('disabled', true); - }); - $(this).parents('.list-orders-inner') - .find('.sort_box:eq(' + target_index + ')').show() - .find('input').prop('disabled', false); + $(this).parents('.list-orders-inner').find('.sort_box').hide(); + $(this).parents('.list-orders-inner').find('.sort_box:eq(' + target_index + ')').show(); }) } - function select_tax() { let select_cat_checkbox = $('.select_cat_checkbox'); let input_chk_size = select_cat_checkbox.length; @@ -182,9 +125,7 @@ jQuery(function ($) { function change_tax_per_page() { let set_number = $('.set_number'); let input_chk_size = set_number.length; - - let i = 0; - for (i; 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'); if (input_num_box.val() == '') { input_num_box.prop('disabled', true); @@ -202,4 +143,44 @@ jQuery(function ($) { }); } + function change_custom_field_sort() { + let s_box = $('.sort_box'); + let custom_field_check = $('.custom_field_check'); + + s_box.find(custom_field_check).each(function () { + if ($(this).prop('checked') == false) { + $(this).parents('.product-list-sort-type').find('.custom_field_key').prop('disabled', true); + $(this).parents('.product-list-sort-type').find('.custom_field_meta_value').prop('disabled', true); + } + }); + + custom_field_check.on('click', function () { + if ($(this).prop('checked') == true) { + $(this).parents('.product-list-sort-type').find('.custom_field_key').prop('disabled', false); + $(this).parents('.product-list-sort-type').find('.custom_field_meta_value').prop('disabled', false); + } else { + $(this).parents('.product-list-sort-type').find('.custom_field_key').val('').prop('disabled', true); + $(this).parents('.product-list-sort-type').find('.custom_field_meta_value').prop('disabled', true); + } + }) + } + + function change_normal_field_sort() { + let s_box = $('.sort_box'); + let targets = '.custom_field_check, .sort_date_check, .sort_title_check, .sort_ID_check, .sort_modified_check'; + + s_box.find(targets).each(function () { + if ($(this).prop('checked') == false) { + $(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', true); + } + }); + $(targets).on('click', function () { + if ($(this).prop('checked') == true) { + $(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', false) + } else { + $(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', true); + } + }); + } + }); \ No newline at end of file diff --git a/template/order.php b/template/order.php index 2a0734e..4647d34 100644 --- a/template/order.php +++ b/template/order.php @@ -26,12 +26,11 @@ $submit_type = APOP_UI::input_post_filter( 'submit_type', 'str' );
    - + -
    @@ -59,12 +58,11 @@ $submit_type = APOP_UI::input_post_filter( 'submit_type', 'str' );
    - +
    -
    diff --git a/template/order_parts_taxonomy.php b/template/order_parts_taxonomy.php index aae56ff..8b1d1c5 100644 --- a/template/order_parts_taxonomy.php +++ b/template/order_parts_taxonomy.php @@ -38,12 +38,11 @@
    - term_id ); ?> + term_id ); ?>
    -