<input id="cb-select-all-2" type="checkbox"> </td> <th class="manage-column column-col_category_name" scope="col"><?php echo __('Category', 'idp-plugin'); ?> </th> <th class="manage-column column-col_category_ranking" scope="col"><?php echo __('Ranking', 'idp-plugin'); ?> </th> </tr> </tfoot> <tbody class="searchable"> <?php $categories = Idp_Main::getImageCategories(); $row_alternate = true; foreach ($categories as $category) { if ($row_alternate) { ?> <tr class=\"alternate\" valign=\"top\"> <?php } else { ?> <tr valign=\"top\"> <?php } ?> <th class="check-column" scope="row"> <label class="screen-reader-text" for="cb-select-<?php echo $category->id;
function showImageCategoryForm($image, $building_id, $user_id, $image_category) { $categorySelected = false; ?> <form method="post" action="." id="image_category_form_<?php echo $image; ?> " name="image_category_form_<?php echo $image; ?> "> <?php $categories = Idp_Main::getImageCategories(); $options = ""; $style = "has-success"; foreach ($categories as $category) { $selected = ""; if (!empty($image_category) && $category->id == $image_category[0]->id) { $selected = "selected"; $categorySelected = true; } $options = $options . "<option {$selected} value=\"{$category->id}\">{$category->name}</option>"; } if (!$categorySelected) { $options = "<option value=\"0\">Kategorie wählen...</option>" . $options; $style = "has-error"; } ?> <div class="input-group input-group-sm"> <div class="form-group form-group-sm <?php echo $style; ?> "> <select name="image_category_<?php echo $image; ?> " id="image_category_<?php echo $image; ?> " class="form-control"> <?php echo $options; ?> </select> </div> <span id="success_category_<?php echo $image; ?> " class="input-group-addon"><span class="glyphicon glyphicon-folder-open" aria-hidden="true" title="Kategorie wählen"></span></span> </div> <?php wp_nonce_field('image_category', 'image_category_nonce'); ?> </form> <script> $('#image_category_<?php echo $image; ?> ').on("change", function(){ if($(this).val() == 0){ $(this).parent().prop('class', 'form-group form-group-sm has-error'); } else{ $(this).parent().prop('class', 'form-group form-group-sm has-success'); $(this).find("option[value='0']").remove(); } if($("select[id^='image_category_']").children("option[value='0']").length == 0){ $('#category_warning').hide(); } else{ $('#category_warning').show(); } $('#success_category_<?php echo $image; ?> ').html("<span class=\"glyphicon glyphicon-refresh\" aria-hidden=\"true\" title=\"Kategorie speichern\"></span>"); var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?> '; var data = {'action': 'saveImageCategory', 'image_id': '<?php echo $image; ?> ', 'image_category': $( this ).val(), 'user_id': '<?php echo $user_id; ?> ', 'building_id': '<?php echo $building_id; ?> ', 'image_category_nonce': $('#image_category_nonce').val()}; jQuery.post(ajaxurl, data, function(response) { $('#success_category_<?php echo $image; ?> ').html(response); }); }); </script> <?php }