|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
## Фильтр элементо втаксономии для метабокса таксономий в админке. add_action( 'admin_print_scripts', 'my_admin_term_filter', 99 ); function my_admin_term_filter() { $screen = get_current_screen(); if( 'post' !== $screen->base ) return; // только для страницы редактирвоания любой записи ?> <script> jQuery(document).ready(function($){ var $categoryDivs = $('#taxonomy-areas'); var $categoryDivs2 = $('#taxonomy-themes'); $categoryDivs.prepend('<label><input type="checkbox" id="check_all" />Выбрать все<label >'); $categoryDivs2.prepend('<label><input type="checkbox" id="check_all_2" />Выбрать все<label >'); $("#check_all").click(function () { var t = $('#areaschecklist'); t.find('input[type=checkbox]').each(function() { this.checked = true; }); if($("#check_all").attr("checked") != 'checked') { $("#check_all").click(function () { t.find('input[type=checkbox]').each(function() { this.checked = true; }); }); }else{ $("#check_all").click(function () { t.find('input[type=checkbox]').each(function() { this.checked = false; }); }); }; }); /**/ $("#check_all_2").click(function () { var t = $('#themeschecklist'); t.find('input[type=checkbox]').each(function() { this.checked = true; }); if($("#check_all_2").attr("checked") != 'checked') { $("#check_all_2").click(function () { t.find('input[type=checkbox]').each(function() { this.checked = true; }); }); }else{ $("#check_all_2").click(function () { t.find('input[type=checkbox]').each(function() { this.checked = false; }); }); }; }); }); </script> <?php } |
добавляем код в файл functions.php