Changeset 3469922
- Timestamp:
- 02/26/2026 06:20:01 AM (5 weeks ago)
- Location:
- dashi/trunk
- Files:
-
- 10 edited
-
assets/css/css.css (modified) (1 diff)
-
assets/js/js.js (modified) (1 diff)
-
classes/Field.php (modified) (12 diffs)
-
classes/Posttype/CustomFields.php (modified) (4 diffs)
-
classes/Posttype/CustomFieldsCategories.php (modified) (3 diffs)
-
classes/Posttype/Option.php (modified) (1 diff)
-
dashi.php (modified) (1 diff)
-
languages/dashi-ja.mo (modified) (previous)
-
languages/dashi-ja.po (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dashi/trunk/assets/css/css.css
r1900879 r3469922 30 30 { 31 31 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; 32 54 } 33 55 -
dashi/trunk/assets/js/js.js
r2161914 r3469922 23 23 },100); 24 24 } 25 }); 26 27 // filter options (select / radio / checkbox) 28 jQuery(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 }); 25 56 }); 26 57 -
dashi/trunk/classes/Field.php
r3268587 r3469922 4 4 class Field 5 5 { 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 } 6 23 /* 7 24 * input_base … … 160 177 $description = '', 161 178 $attrs = array(), 162 $template = '' 179 $template = '', 180 $filterable = false 163 181 ) 164 182 { … … 177 195 { 178 196 $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; 179 204 } 180 205 … … 190 215 $selected = $key == $value ? ' selected="selected" ' : ''; 191 216 } 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( 196 222 array( 197 223 '{name}', … … 207 233 ), 208 234 $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; 209 245 } 210 246 … … 218 254 $description = '', 219 255 $attrs = array(), 220 $template = '' 256 $template = '', 257 $filterable = false 221 258 ) 222 259 { 223 260 $options_html = ''; 224 261 $name_attr = esc_attr($name); 262 263 $filter_id = ''; 264 if ($filterable) 265 { 266 $filter_id = self::next_filter_id(); 267 } 268 225 269 foreach ($options as $key => $text) { 226 270 $key_attr = esc_attr($key); 227 271 $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).'">'; 229 274 $options_html .= '<input type="radio" name="'.$name_attr.'" value="'.$key_attr.'" id="'.$name_attr.'_'.$key_attr.'"'.$checked.' '.static::array_to_attr($attrs).' />'; 230 275 $options_html .= esc_html($text); … … 235 280 {options}'; 236 281 237 returnstr_replace(282 $html = str_replace( 238 283 array( 239 284 '{name}', … … 249 294 ), 250 295 $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; 251 307 } 252 308 … … 257 313 $description = '', 258 314 $attrs = array(), 259 $template = '' 315 $template = '', 316 $filterable = false 260 317 ) 261 318 { 262 319 $options_html = ''; 263 320 $name_attr = esc_attr($name); 321 322 $filter_id = ''; 323 if ($filterable) 324 { 325 $filter_id = self::next_filter_id(); 326 } 264 327 265 328 foreach ($options as $key => $text) … … 269 332 $checked = is_array($value) && in_array($key, $value) ? ' checked="checked"' : ''; 270 333 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).'">'; 272 336 $options_html .= '<input type="checkbox" name="' . $name_attr . '[]" value="' . $key_attr . '" id="' . $input_id . '"' . $checked . ' ' . static::array_to_attr($attrs) . ' />'; 273 337 $options_html .= esc_html($text); … … 278 342 {options}'; 279 343 280 returnstr_replace(344 $html = str_replace( 281 345 array( 282 346 '{name}', … … 293 357 $template 294 358 ); 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; 295 370 } 296 371 -
dashi/trunk/classes/Posttype/CustomFields.php
r3467550 r3469922 304 304 $description = isset($value['args']['description']) ? $value['args']['description'] : ''; 305 305 $attrs = isset($value['args']['attrs']) ? $value['args']['attrs'] : array(); 306 $filterable = ! empty($value['args']['filter']); 306 307 307 308 // default or population value … … 460 461 $description, 461 462 $attrs, 462 $template 463 $template, 464 $filterable 463 465 ); 464 466 break; … … 471 473 $description, 472 474 $attrs, 473 $template 475 $template, 476 $filterable 474 477 ); 475 478 $is_label = false; … … 483 486 $description, 484 487 $attrs, 485 $template 488 $template, 489 $filterable 486 490 ); 487 491 $is_label = false; -
dashi/trunk/classes/Posttype/CustomFieldsCategories.php
r3437610 r3469922 28 28 $description = isset($custom_field['description']) ? $custom_field['description'] : ''; 29 29 $attrs = isset($custom_field['attrs']) ? $custom_field['attrs'] : array(); 30 $filterable = ! empty($custom_field['filter']); 30 31 // $options = isset($custom_field['options']) ? $custom_field['options'] : array(); 31 32 $options = []; … … 62 63 $attrs, 63 64 '', //template 64 true65 $filterable 65 66 ); 66 67 break; … … 73 74 $attrs, 74 75 '', //template 75 true76 $filterable 76 77 ); 77 78 break; -
dashi/trunk/classes/Posttype/Option.php
r2244334 r3469922 69 69 'label' => 'sample field 1', 70 70 'description' => '', 71 72 // <?php echo __('show filter input to narrow down options (select/radio/checkbox)', 'dashi')."\n" ?> 73 'filter' => true, 71 74 72 75 // <?php echo __('You may create duplicatable meta_box.', 'dashi')."\n" ?> -
dashi/trunk/dashi.php
r3467550 r3469922 7 7 Text Domain: dashi 8 8 Domain Path: /languages/ 9 Version: 3.3. 39 Version: 3.3.4 10 10 Author URI: http://www.jidaikobo.com/ 11 11 thx: https://github.com/trentrichardson/jQuery-Timepicker-Addon/tree/master/src -
dashi/trunk/languages/dashi-ja.po
r3329379 r3469922 673 673 msgid "<span title=\"some characters disappear\">Microsoft Excel compatible CSV</span>" 674 674 msgstr "<span title=\"一部文字が表示されなくなります\">Microsoft Excel互換のCSVにする</span>" 675 676 msgid "Filter options" 677 msgstr "候補絞り込み" 678 679 msgid "show filter input to narrow down options (select/radio/checkbox)" 680 msgstr "選択肢の絞り込み入力を表示(select/radio/checkbox)" -
dashi/trunk/readme.txt
r3467550 r3469922 4 4 Tags: custom field, custom post type 5 5 Tested up to: 6.9.0 6 Stable tag: 3.3. 36 Stable tag: 3.3.4 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 42 42 43 43 == Changelog == 44 45 = 3.3.4 = 46 add: filter input for select/radio/checkbox options (opt-in via `filter`) 47 add: help text for filter option in Option help 48 add: visible label for filter input 49 fix: make filter input block-level for layout consistency 44 50 45 51 = 3.3.3 =
Note: See TracChangeset
for help on using the changeset viewer.