Plugin Directory

Changeset 3469922


Ignore:
Timestamp:
02/26/2026 06:20:01 AM (5 weeks ago)
Author:
jidaikobo
Message:

Update trunk for version 3.3.4

Location:
dashi/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • dashi/trunk/assets/css/css.css

    r1900879 r3469922  
    3030{
    3131    background-color: transparent !important;
     32}
     33
     34/* filter */
     35
     36.dashi_filter
     37{
     38    margin: 0 0 8px;
     39}
     40
     41.dashi_filter_input
     42{
     43    width: 100%;
     44    max-width: 320px;
     45    margin: 0 0 6px;
     46    display: block;
     47}
     48
     49.dashi_filter_label
     50{
     51    display: block;
     52    font-weight: bold;
     53    margin: 0 0 4px;
    3254}
    3355
  • dashi/trunk/assets/js/js.js

    r2161914 r3469922  
    2323        },100);
    2424    }
     25});
     26
     27// filter options (select / radio / checkbox)
     28jQuery(function($){
     29    $('.dashi_filter_input').on('input', function(){
     30        var $input = $(this);
     31        var query = $.trim($input.val()).toLowerCase();
     32        var target = $input.data('dashi-filter-target');
     33        if (!target) return;
     34
     35        var $select = $('[data-dashi-filter-id="' + target + '"]');
     36        if ($select.length) {
     37            $select.find('option').each(function(){
     38                var $opt = $(this);
     39                var text = ($opt.data('dashi-filter-text') || $opt.text() || '').toString().toLowerCase();
     40                var match = !query || text.indexOf(query) !== -1;
     41                $opt.prop('hidden', !match);
     42            });
     43            return;
     44        }
     45
     46        var $group = $('[data-dashi-filter-group="' + target + '"]');
     47        if (!$group.length) return;
     48
     49        $group.find('.dashi_filter_item').each(function(){
     50            var $item = $(this);
     51            var text = ($item.data('dashi-filter-text') || $item.text() || '').toString().toLowerCase();
     52            var match = !query || text.indexOf(query) !== -1;
     53            $item.toggle(match);
     54        });
     55    });
    2556});
    2657
  • dashi/trunk/classes/Field.php

    r3268587 r3469922  
    44class Field
    55{
     6    private static $filter_seq = 0;
     7
     8    private static function next_filter_id()
     9    {
     10        self::$filter_seq++;
     11        return 'dashi_filter_' . self::$filter_seq;
     12    }
     13
     14    private static function build_filter_input($filter_id)
     15    {
     16        $input_id = $filter_id . '_input';
     17        $label = __('Filter options', 'dashi');
     18        return '<label class="dashi_filter_label" for="' . esc_attr($input_id) . '">' . esc_html($label) . '</label>' .
     19            '<input type="text" class="dashi_filter_input" id="' . esc_attr($input_id) .
     20            '" data-dashi-filter-target="' . esc_attr($filter_id) . '" placeholder="' .
     21            esc_attr($label) . '" />';
     22    }
    623    /*
    724     * input_base
     
    160177        $description = '',
    161178        $attrs = array(),
    162         $template = ''
     179        $template = '',
     180        $filterable = false
    163181    )
    164182    {
     
    177195        {
    178196            $template = str_replace('{name}', '{name}[]', $template);
     197        }
     198
     199        $filter_id = '';
     200        if ($filterable)
     201        {
     202            $filter_id = self::next_filter_id();
     203            $attrs['data-dashi-filter-id'] = $filter_id;
    179204        }
    180205
     
    190215                $selected = $key == $value ? ' selected="selected" ' : '';
    191216            }
    192             $options_html .= '<option value="'.esc_html($key).'" '.$selected.'>'.esc_html($text).'</option>';
    193         }
    194 
    195         return str_replace(
     217            $options_html .= '<option value="'.esc_html($key).'" data-dashi-filter-text="'.
     218                esc_attr($text).'" '.$selected.'>'.esc_html($text).'</option>';
     219        }
     220
     221        $html = str_replace(
    196222            array(
    197223                '{name}',
     
    207233            ),
    208234            $template);
     235
     236        if ($filterable)
     237        {
     238            $html = '<div class="dashi_filter">' .
     239                self::build_filter_input($filter_id) .
     240                $html .
     241                '</div>';
     242        }
     243
     244        return $html;
    209245    }
    210246
     
    218254        $description = '',
    219255        $attrs = array(),
    220         $template = ''
     256        $template = '',
     257        $filterable = false
    221258    )
    222259    {
    223260        $options_html = '';
    224261        $name_attr = esc_attr($name);
     262
     263        $filter_id = '';
     264        if ($filterable)
     265        {
     266            $filter_id = self::next_filter_id();
     267        }
     268
    225269        foreach ($options as $key => $text) {
    226270            $key_attr = esc_attr($key);
    227271            $checked = $key == $value ? ' checked="checked"' : '';
    228             $options_html .= '<label for="'.$name_attr.'_'.$key_attr.'" class="label_fb">';
     272            $options_html .= '<label for="'.$name_attr.'_'.$key_attr.'" class="label_fb dashi_filter_item" data-dashi-filter-text="'.
     273                esc_attr($text).'">';
    229274            $options_html .= '<input type="radio" name="'.$name_attr.'" value="'.$key_attr.'" id="'.$name_attr.'_'.$key_attr.'"'.$checked.' '.static::array_to_attr($attrs).' />';
    230275            $options_html .= esc_html($text);
     
    235280{options}';
    236281
    237         return str_replace(
     282        $html = str_replace(
    238283            array(
    239284                '{name}',
     
    249294            ),
    250295            $template);
     296
     297        if ($filterable)
     298        {
     299            $html = '<div class="dashi_filter">' .
     300                self::build_filter_input($filter_id) .
     301                '<div class="dashi_filter_group" data-dashi-filter-group="' . esc_attr($filter_id) . '">' .
     302                $html .
     303                '</div></div>';
     304        }
     305
     306        return $html;
    251307    }
    252308
     
    257313        $description = '',
    258314        $attrs = array(),
    259         $template = ''
     315        $template = '',
     316        $filterable = false
    260317    )
    261318    {
    262319        $options_html = '';
    263320        $name_attr = esc_attr($name);
     321
     322        $filter_id = '';
     323        if ($filterable)
     324        {
     325            $filter_id = self::next_filter_id();
     326        }
    264327
    265328        foreach ($options as $key => $text)
     
    269332            $checked = is_array($value) && in_array($key, $value) ? ' checked="checked"' : '';
    270333
    271             $options_html .= '<label for="' . $input_id . '" class="label_fb">';
     334            $options_html .= '<label for="' . $input_id . '" class="label_fb dashi_filter_item" data-dashi-filter-text="'.
     335                esc_attr($text).'">';
    272336            $options_html .= '<input type="checkbox" name="' . $name_attr . '[]" value="' . $key_attr . '" id="' . $input_id . '"' . $checked . ' ' . static::array_to_attr($attrs) . ' />';
    273337            $options_html .= esc_html($text);
     
    278342    {options}';
    279343
    280         return str_replace(
     344        $html = str_replace(
    281345            array(
    282346                '{name}',
     
    293357            $template
    294358        );
     359
     360        if ($filterable)
     361        {
     362            $html = '<div class="dashi_filter">' .
     363                self::build_filter_input($filter_id) .
     364                '<div class="dashi_filter_group" data-dashi-filter-group="' . esc_attr($filter_id) . '">' .
     365                $html .
     366                '</div></div>';
     367        }
     368
     369        return $html;
    295370    }
    296371
  • dashi/trunk/classes/Posttype/CustomFields.php

    r3467550 r3469922  
    304304        $description = isset($value['args']['description']) ? $value['args']['description'] : '';
    305305        $attrs = isset($value['args']['attrs']) ? $value['args']['attrs'] : array();
     306        $filterable = ! empty($value['args']['filter']);
    306307
    307308        // default or population value
     
    460461                        $description,
    461462                        $attrs,
    462                         $template
     463                        $template,
     464                        $filterable
    463465                    );
    464466                    break;
     
    471473                        $description,
    472474                        $attrs,
    473                         $template
     475                        $template,
     476                        $filterable
    474477                    );
    475478                    $is_label = false;
     
    483486                        $description,
    484487                        $attrs,
    485                         $template
     488                        $template,
     489                        $filterable
    486490                    );
    487491                    $is_label = false;
  • dashi/trunk/classes/Posttype/CustomFieldsCategories.php

    r3437610 r3469922  
    2828            $description = isset($custom_field['description']) ? $custom_field['description'] : '';
    2929            $attrs = isset($custom_field['attrs']) ? $custom_field['attrs'] : array();
     30            $filterable = ! empty($custom_field['filter']);
    3031            // $options = isset($custom_field['options']) ? $custom_field['options'] : array();
    3132            $options = [];
     
    6263                        $attrs,
    6364                        '', //template
    64                         true
     65                        $filterable
    6566                    );
    6667                    break;
     
    7374                        $attrs,
    7475                        '', //template
    75                         true
     76                        $filterable
    7677                    );
    7778                    break;
  • dashi/trunk/classes/Posttype/Option.php

    r2244334 r3469922  
    6969          'label'       => 'sample field 1',
    7070          'description' => '',
     71
     72          // <?php echo __('show filter input to narrow down options (select/radio/checkbox)', 'dashi')."\n" ?>
     73          'filter' => true,
    7174
    7275          // <?php echo __('You may create duplicatable meta_box.', 'dashi')."\n" ?>
  • dashi/trunk/dashi.php

    r3467550 r3469922  
    77Text Domain: dashi
    88Domain Path: /languages/
    9 Version: 3.3.3
     9Version: 3.3.4
    1010Author URI: http://www.jidaikobo.com/
    1111thx: https://github.com/trentrichardson/jQuery-Timepicker-Addon/tree/master/src
  • dashi/trunk/languages/dashi-ja.po

    r3329379 r3469922  
    673673msgid "<span title=\"some characters disappear\">Microsoft Excel compatible CSV</span>"
    674674msgstr "<span title=\"一部文字が表示されなくなります\">Microsoft Excel互換のCSVにする</span>"
     675
     676msgid "Filter options"
     677msgstr "候補絞り込み"
     678
     679msgid "show filter input to narrow down options (select/radio/checkbox)"
     680msgstr "選択肢の絞り込み入力を表示(select/radio/checkbox)"
  • dashi/trunk/readme.txt

    r3467550 r3469922  
    44Tags: custom field, custom post type
    55Tested up to: 6.9.0
    6 Stable tag: 3.3.3
     6Stable tag: 3.3.4
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4242
    4343== Changelog ==
     44
     45= 3.3.4 =
     46add: filter input for select/radio/checkbox options (opt-in via `filter`)
     47add: help text for filter option in Option help
     48add: visible label for filter input
     49fix: make filter input block-level for layout consistency
    4450
    4551= 3.3.3 =
Note: See TracChangeset for help on using the changeset viewer.