| 1 |
<?php |
| 2 |
if (!class_exists('WP_List_Table')) { |
| 3 |
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php'); |
| 4 |
} |
| 5 |
|
| 6 |
class Taxopress_Terms_List extends WP_List_Table |
| 7 |
{ |
| 8 |
|
| 9 |
/** Class constructor */ |
| 10 |
public function __construct() |
| 11 |
{ |
| 12 |
|
| 13 |
parent::__construct([ |
| 14 |
'singular' => esc_html__('Term', 'simple-tags'), //singular name of the listed records |
| 15 |
'plural' => esc_html__('Terms', 'simple-tags'), //plural name of the listed records |
| 16 |
'ajax' => true //does this table support ajax? |
| 17 |
]); |
| 18 |
|
| 19 |
} |
| 20 |
|
| 21 |
public function get_all_terms($count = false){ |
| 22 |
|
| 23 |
$taxonomies = array_keys(get_all_taxopress_taxonomies_request()); |
| 24 |
|
| 25 |
$search = (!empty($_REQUEST['s'])) ? sanitize_text_field($_REQUEST['s']) : ''; |
| 26 |
|
| 27 |
$orderby = (!empty($_REQUEST['orderby'])) ? sanitize_text_field($_REQUEST['orderby']) : 'ID'; |
| 28 |
$order = (!empty($_REQUEST['order'])) ? sanitize_text_field($_REQUEST['order']) : 'desc'; |
| 29 |
$items_per_page = $this->get_items_per_page('st_Terms_per_page', 20); |
| 30 |
$page = $this->get_pagenum(); |
| 31 |
$offset = ($page - 1) * $items_per_page; |
| 32 |
|
| 33 |
$selected_post_type = (!empty($_REQUEST['terms_filter_post_type'])) ? [sanitize_text_field($_REQUEST['terms_filter_post_type'])] : ''; |
| 34 |
$selected_taxonomy = (!empty($_REQUEST['terms_filter_taxonomy'])) ? sanitize_text_field($_REQUEST['terms_filter_taxonomy']) : ''; |
| 35 |
if(!empty($selected_taxonomy)){ |
| 36 |
$taxonomies = [$selected_taxonomy]; |
| 37 |
} |
| 38 |
|
| 39 |
$terms_attr = array ( |
| 40 |
'taxonomy' => $taxonomies, |
| 41 |
'post_types' => $selected_post_type, |
| 42 |
'orderby' => $orderby, |
| 43 |
'order' => $order, |
| 44 |
'search' => $search, |
| 45 |
'hide_empty' => false, |
| 46 |
'include' => 'all', |
| 47 |
'pad_counts' => true, |
| 48 |
'update_term_meta_cache' => true, |
| 49 |
); |
| 50 |
if($count){ |
| 51 |
$terms_attr['number'] = 0; |
| 52 |
} else { |
| 53 |
$terms_attr['offset'] = $offset; |
| 54 |
$terms_attr['number'] = $items_per_page; |
| 55 |
} |
| 56 |
|
| 57 |
$terms = get_terms($terms_attr); |
| 58 |
|
| 59 |
if(empty($terms) || is_wp_error($terms)){ |
| 60 |
return []; |
| 61 |
} |
| 62 |
|
| 63 |
return $terms; |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Retrieve st_Terms data from the database |
| 68 |
* |
| 69 |
* @param int $per_page |
| 70 |
* @param int $page_number |
| 71 |
* |
| 72 |
* @return mixed |
| 73 |
*/ |
| 74 |
public function get_st_Terms() |
| 75 |
{ |
| 76 |
return $this->get_all_terms(); |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* Returns the count of records in the database. |
| 81 |
* |
| 82 |
* @return null|string |
| 83 |
*/ |
| 84 |
public function record_count() |
| 85 |
{ |
| 86 |
return count($this->get_all_terms(true)); |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* Show single row item |
| 91 |
* |
| 92 |
* @param array $item |
| 93 |
*/ |
| 94 |
public function single_row($item) |
| 95 |
{ |
| 96 |
$class = ['st-terms-tr']; |
| 97 |
$id = 'term-' . $item->term_id . ''; |
| 98 |
echo sprintf('<tr id="%s" class="%s">', esc_attr($id), esc_attr(implode(' ', $class))); |
| 99 |
$this->single_row_columns($item); |
| 100 |
echo '</tr>'; |
| 101 |
} |
| 102 |
|
| 103 |
/** |
| 104 |
* Associative array of columns |
| 105 |
* |
| 106 |
* @return array |
| 107 |
*/ |
| 108 |
function get_columns() |
| 109 |
{ |
| 110 |
$columns = [ |
| 111 |
'cb' => '<input type="checkbox" />', |
| 112 |
'name' => esc_html__('Title', 'simple-tags'), |
| 113 |
'slug' => esc_html__('Slug', 'simple-tags'), |
| 114 |
'taxonomy' => esc_html__('Taxonomy', 'simple-tags'), |
| 115 |
'posttypes' => esc_html__('Post Types', 'simple-tags'), |
| 116 |
'count' => esc_html__('Count', 'simple-tags') |
| 117 |
]; |
| 118 |
|
| 119 |
return $columns; |
| 120 |
} |
| 121 |
|
| 122 |
/** |
| 123 |
* Columns to make sortable. |
| 124 |
* |
| 125 |
* @return array |
| 126 |
*/ |
| 127 |
protected function get_sortable_columns() |
| 128 |
{ |
| 129 |
$sortable_columns = [ |
| 130 |
'name' => ['name', true], |
| 131 |
'slug' => ['taxonomy', true], |
| 132 |
'taxonomy' => ['taxonomy', true], |
| 133 |
'count' => ['count', true], |
| 134 |
]; |
| 135 |
|
| 136 |
return $sortable_columns; |
| 137 |
} |
| 138 |
|
| 139 |
/** |
| 140 |
* Render the bulk edit checkbox |
| 141 |
* |
| 142 |
* @param array $item |
| 143 |
* |
| 144 |
* @return string |
| 145 |
*/ |
| 146 |
function column_cb( $item ) { |
| 147 |
return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', 'taxopress_terms', $item->term_id); |
| 148 |
} |
| 149 |
|
| 150 |
/** |
| 151 |
* Get the bulk actions to show in the top page dropdown |
| 152 |
* |
| 153 |
* @return array |
| 154 |
*/ |
| 155 |
protected function get_bulk_actions() |
| 156 |
{ |
| 157 |
$actions = [ |
| 158 |
'taxopress-terms-delete-terms' => esc_html__('Delete', 'simple-tags') |
| 159 |
]; |
| 160 |
|
| 161 |
return $actions; |
| 162 |
} |
| 163 |
|
| 164 |
/** |
| 165 |
* Add custom filter to tablenav |
| 166 |
* |
| 167 |
* @param string $which |
| 168 |
*/ |
| 169 |
protected function extra_tablenav( $which ) { |
| 170 |
|
| 171 |
if ( 'top' === $which ) { |
| 172 |
|
| 173 |
$post_types = get_post_types(['public' => true], 'objects'); |
| 174 |
|
| 175 |
$taxonomies = get_all_taxopress_public_taxonomies(); |
| 176 |
|
| 177 |
$selected_post_type = (!empty($_REQUEST['terms_filter_post_type'])) ? sanitize_text_field($_REQUEST['terms_filter_post_type']) : ''; |
| 178 |
$selected_taxonomy = (!empty($_REQUEST['terms_filter_taxonomy'])) ? sanitize_text_field($_REQUEST['terms_filter_taxonomy']) : ''; |
| 179 |
|
| 180 |
$selected_option = 'public'; |
| 181 |
if ( isset($_GET['taxonomy_type']) && $_GET['taxonomy_type'] === 'all') { |
| 182 |
$selected_option = 'all'; |
| 183 |
}elseif ( isset($_GET['taxonomy_type']) && $_GET['taxonomy_type'] === 'private') { |
| 184 |
$selected_option = 'private'; |
| 185 |
} |
| 186 |
?> |
| 187 |
|
| 188 |
|
| 189 |
<div class="alignleft actions autoterms-terms-table-filter"> |
| 190 |
|
| 191 |
<select class="auto-terms-terms-filter-select" name="terms_filter_select_post_type" id="terms_filter_select_post_type"> |
| 192 |
<option value=""><?php esc_html_e('Post type', 'simple-tags'); ?></option> |
| 193 |
<?php |
| 194 |
foreach ( $post_types as $post_type ) { |
| 195 |
echo '<option value="'. esc_attr($post_type->name) .'" '.selected($selected_post_type, $post_type->name, false).'>'. esc_html($post_type->label) .'</option>'; |
| 196 |
} |
| 197 |
?> |
| 198 |
</select> |
| 199 |
|
| 200 |
<select class="auto-terms-terms-filter-select" name="terms_filter_select_taxonomy" id="terms_filter_select_taxonomy"> |
| 201 |
<option value=""><?php esc_html_e('Taxonomy', 'simple-tags'); ?></option> |
| 202 |
<?php |
| 203 |
foreach ( $taxonomies as $taxonomy ) { |
| 204 |
echo '<option value="'. esc_attr($taxonomy->name) .'" '.selected($selected_taxonomy, $taxonomy->name, false).'>'. esc_html($taxonomy->labels->name) .'</option>'; |
| 205 |
} |
| 206 |
?> |
| 207 |
</select> |
| 208 |
|
| 209 |
<select class="auto-terms-terms-filter-select" name="terms_filter_select_taxonomy_type" id="terms_filter_select_taxonomy_type"> |
| 210 |
<option value="all" <?php echo ($selected_option === 'all' ? 'selected="selected"' : ''); ?>><?php echo esc_html__('All Taxonomies', 'simple-tags'); ?></option> |
| 211 |
<option value="public" <?php echo ($selected_option === 'public' ? 'selected="selected"' : ''); ?>><?php echo esc_html__('Public Taxonomies', 'simple-tags'); ?></option> |
| 212 |
<option value="private" <?php echo ($selected_option === 'private' ? 'selected="selected"' : ''); ?>><?php echo esc_html__('Private Taxonomies', 'simple-tags'); ?></option> |
| 213 |
</select> |
| 214 |
|
| 215 |
<a href="javascript:void(0)" class="taxopress-terms-tablenav-filter button"><?php esc_html_e('Filter', 'simple-tags'); ?></a> |
| 216 |
|
| 217 |
</div> |
| 218 |
<?php |
| 219 |
} |
| 220 |
} |
| 221 |
|
| 222 |
/** |
| 223 |
* Process bulk actions |
| 224 |
*/ |
| 225 |
public function process_bulk_action() |
| 226 |
{ |
| 227 |
|
| 228 |
$query_arg = '_wpnonce'; |
| 229 |
$action = 'bulk-' . $this->_args['plural']; |
| 230 |
$checked = isset($_REQUEST[$query_arg]) ? wp_verify_nonce(sanitize_key($_REQUEST[$query_arg]), $action) : false; |
| 231 |
|
| 232 |
if (!$checked || !current_user_can('simple_tags')) { |
| 233 |
return; |
| 234 |
} |
| 235 |
|
| 236 |
if($this->current_action() === 'taxopress-terms-delete-terms'){ |
| 237 |
$taxopress_terms = array_map('sanitize_text_field', (array)$_REQUEST['taxopress_terms']); |
| 238 |
if (!empty($taxopress_terms)) { |
| 239 |
foreach($taxopress_terms as $taxopress_term){ |
| 240 |
$term = get_term( $taxopress_term ); |
| 241 |
wp_delete_term( $term->term_id, $term->taxonomy ); |
| 242 |
} |
| 243 |
if(count($taxopress_terms) > 1){ |
| 244 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 245 |
echo taxopress_admin_notices_helper(esc_html__('Terms deleted successfully.', 'simple-tags'), false); |
| 246 |
}else{ |
| 247 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 248 |
echo taxopress_admin_notices_helper(esc_html__('Term deleted successfully.', 'simple-tags'), false); |
| 249 |
} |
| 250 |
} |
| 251 |
} |
| 252 |
|
| 253 |
} |
| 254 |
|
| 255 |
/** |
| 256 |
* Render a column when no column specific method exist. |
| 257 |
* |
| 258 |
* @param array $item |
| 259 |
* @param string $column_name |
| 260 |
* |
| 261 |
* @return mixed |
| 262 |
*/ |
| 263 |
public function column_default($item, $column_name) |
| 264 |
{ |
| 265 |
return !empty($item->$column_name) ? $item->$column_name : '—'; |
| 266 |
} |
| 267 |
|
| 268 |
/** Text displayed when no stterm data is available */ |
| 269 |
public function no_items() |
| 270 |
{ |
| 271 |
esc_html_e('No item avaliable.', 'simple-tags'); |
| 272 |
} |
| 273 |
|
| 274 |
/** |
| 275 |
* Displays the search box. |
| 276 |
* |
| 277 |
* @param string $text The 'submit' button label. |
| 278 |
* @param string $input_id ID attribute value for the search input field. |
| 279 |
* |
| 280 |
* |
| 281 |
*/ |
| 282 |
public function search_box($text, $input_id) |
| 283 |
{ |
| 284 |
if (empty($_REQUEST['s']) && !$this->has_items()) { |
| 285 |
//return; |
| 286 |
} |
| 287 |
|
| 288 |
$input_id = $input_id . '-search-input'; |
| 289 |
|
| 290 |
if (!empty($_REQUEST['orderby'])) { |
| 291 |
echo '<input type="hidden" name="orderby" value="' . esc_attr(sanitize_text_field($_REQUEST['orderby'])) . '" />'; |
| 292 |
} |
| 293 |
if (!empty($_REQUEST['order'])) { |
| 294 |
echo '<input type="hidden" name="order" value="' . esc_attr(sanitize_text_field($_REQUEST['order'])) . '" />'; |
| 295 |
} |
| 296 |
if (!empty($_REQUEST['page'])) { |
| 297 |
echo '<input type="hidden" name="page" value="' . esc_attr(sanitize_text_field($_REQUEST['page'])) . '" />'; |
| 298 |
} |
| 299 |
|
| 300 |
$custom_filters = ['terms_filter_post_type', 'terms_filter_taxonomy', 'taxonomy_type']; |
| 301 |
|
| 302 |
foreach ($custom_filters as $custom_filter) { |
| 303 |
$filter_value = !empty($_REQUEST[$custom_filter]) ? sanitize_text_field($_REQUEST[$custom_filter]) : ''; |
| 304 |
echo '<input type="hidden" name="' . esc_attr($custom_filter) . '" value="' . esc_attr($filter_value) . '" />'; |
| 305 |
} |
| 306 |
?> |
| 307 |
<p class="search-box"> |
| 308 |
<label class="screen-reader-text" for="<?php echo esc_attr($input_id); ?>"><?php echo esc_html($text); ?>:</label> |
| 309 |
<input type="search" id="<?php echo esc_attr($input_id); ?>" name="s" |
| 310 |
value="<?php _admin_search_query(); ?>"/> |
| 311 |
<?php submit_button($text, '', '', false, ['id' => 'taxopress-terms-search-submit']); ?> |
| 312 |
</p> |
| 313 |
<?php |
| 314 |
} |
| 315 |
|
| 316 |
/** |
| 317 |
* Sets up the items (roles) to list. |
| 318 |
*/ |
| 319 |
public function prepare_items() |
| 320 |
{ |
| 321 |
|
| 322 |
$this->_column_headers = $this->get_column_info(); |
| 323 |
$this->process_bulk_action(); |
| 324 |
|
| 325 |
/** |
| 326 |
* First, lets decide how many records per page to show |
| 327 |
*/ |
| 328 |
$per_page = $this->get_items_per_page('st_Terms_per_page', 20); |
| 329 |
|
| 330 |
/** |
| 331 |
* Fetch the data |
| 332 |
*/ |
| 333 |
$data = $this->get_st_Terms(); |
| 334 |
|
| 335 |
/** |
| 336 |
* Pagination. |
| 337 |
*/ |
| 338 |
$current_page = $this->get_pagenum(); |
| 339 |
$total_items = $this->record_count(); |
| 340 |
|
| 341 |
/** |
| 342 |
* Now we can add the data to the items property, where it can be used by the rest of the class. |
| 343 |
*/ |
| 344 |
$this->items = $data; |
| 345 |
|
| 346 |
/** |
| 347 |
* We also have to register our pagination options & calculations. |
| 348 |
*/ |
| 349 |
$this->set_pagination_args([ |
| 350 |
'total_items' => $total_items, //calculate the total number of items |
| 351 |
'per_page' => $per_page, //determine how many items to show on a page |
| 352 |
'total_pages' => ceil($total_items / $per_page) //calculate the total number of pages |
| 353 |
]); |
| 354 |
} |
| 355 |
|
| 356 |
/** |
| 357 |
* Generates and display row actions links for the list table. |
| 358 |
* |
| 359 |
* @param object $item The item being acted upon. |
| 360 |
* @param string $column_name Current column name. |
| 361 |
* @param string $primary Primary column name. |
| 362 |
* |
| 363 |
* @return string The row actions HTML, or an empty string if the current column is the primary column. |
| 364 |
*/ |
| 365 |
protected function handle_row_actions($item, $column_name, $primary) |
| 366 |
{ |
| 367 |
$taxonomy = get_taxonomy($item->taxonomy); |
| 368 |
|
| 369 |
//Build row actions |
| 370 |
$actions = []; |
| 371 |
|
| 372 |
if ( current_user_can( 'edit_term', $item->term_id ) ) { |
| 373 |
$actions['edit'] = sprintf( |
| 374 |
'<a href="%s">%s</a>', |
| 375 |
add_query_arg( |
| 376 |
[ |
| 377 |
'taxonomy' => $item->taxonomy, |
| 378 |
'tag_ID' => $item->term_id, |
| 379 |
'post_type' => isset($taxonomy->object_type[0]) ? $taxonomy->object_type[0] : 'post', |
| 380 |
], |
| 381 |
admin_url('term.php') |
| 382 |
), |
| 383 |
esc_html__('Edit', 'simple-tags') |
| 384 |
); |
| 385 |
$actions['inline hide-if-no-js'] = sprintf( |
| 386 |
'<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>', |
| 387 |
/* translators: %s: Taxonomy term name. */ |
| 388 |
esc_attr( sprintf( esc_html__( 'Quick edit “%s” inline', 'simple-tags'), $item->name ) ), |
| 389 |
esc_html__('Quick Edit', 'simple-tags') |
| 390 |
); |
| 391 |
} |
| 392 |
|
| 393 |
if ( current_user_can( 'delete_term', $item->term_id ) ) { |
| 394 |
$actions['delete'] = sprintf( |
| 395 |
'<a href="%s" class="delete-terms">%s</a>', |
| 396 |
add_query_arg([ |
| 397 |
'page' => 'st_terms', |
| 398 |
'action' => 'taxopress-delete-terms', |
| 399 |
'taxopress_terms' => esc_attr($item->term_id), |
| 400 |
'_wpnonce' => wp_create_nonce('terms-action-request-nonce') |
| 401 |
], |
| 402 |
admin_url('admin.php')), |
| 403 |
esc_html__('Delete', 'simple-tags') |
| 404 |
); |
| 405 |
} |
| 406 |
|
| 407 |
if (is_taxonomy_viewable($item->taxonomy)) { |
| 408 |
$actions['view'] = sprintf( |
| 409 |
'<a href="%s">%s</a>', |
| 410 |
get_term_link($item->term_id), |
| 411 |
esc_html__('View', 'simple-tags') |
| 412 |
); |
| 413 |
} |
| 414 |
|
| 415 |
return $column_name === $primary ? $this->row_actions($actions, false) : ''; |
| 416 |
} |
| 417 |
|
| 418 |
/** |
| 419 |
* Method for name column |
| 420 |
* |
| 421 |
* @param array $item |
| 422 |
* |
| 423 |
* @return string |
| 424 |
*/ |
| 425 |
protected function column_name($item) |
| 426 |
{ |
| 427 |
$taxonomy = get_taxonomy($item->taxonomy); |
| 428 |
|
| 429 |
$title = sprintf( |
| 430 |
'<a href="%1$s"><strong><span class="row-title">%2$s</span></strong></a>', |
| 431 |
add_query_arg( |
| 432 |
[ |
| 433 |
'taxonomy' => $item->taxonomy, |
| 434 |
'tag_ID' => $item->term_id, |
| 435 |
'post_type' => isset($taxonomy->object_type[0]) ? $taxonomy->object_type[0] : 'post', |
| 436 |
], |
| 437 |
admin_url('term.php') |
| 438 |
), |
| 439 |
esc_html($item->name) |
| 440 |
); |
| 441 |
|
| 442 |
//for inline edit |
| 443 |
$qe_data = get_term( $item->term_id, $item->taxonomy, OBJECT, 'edit'); |
| 444 |
|
| 445 |
$title .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; |
| 446 |
$title .= '<div class="taxonomy">'. $item->taxonomy .'</div>'; |
| 447 |
$title .= '<div class="name">' . $qe_data->name . '</div>'; |
| 448 |
|
| 449 |
$title .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>'; |
| 450 |
$title .= '<div class="parent">' . $qe_data->parent . '</div></div>'; |
| 451 |
|
| 452 |
return $title; |
| 453 |
} |
| 454 |
|
| 455 |
/** |
| 456 |
* The action column |
| 457 |
* |
| 458 |
* @param $item |
| 459 |
* |
| 460 |
* @return string |
| 461 |
*/ |
| 462 |
protected function column_slug($item) |
| 463 |
{ |
| 464 |
return !empty($item->slug) ? $item->slug : '—'; |
| 465 |
} |
| 466 |
|
| 467 |
/** |
| 468 |
* The action column |
| 469 |
* |
| 470 |
* @param $item |
| 471 |
* |
| 472 |
* @return string |
| 473 |
*/ |
| 474 |
protected function column_posttypes($item) |
| 475 |
{ |
| 476 |
$posttype = ''; |
| 477 |
$sn = 0; |
| 478 |
$taxonomy = get_taxonomy($item->taxonomy); |
| 479 |
foreach ($taxonomy->object_type as $objecttype) { |
| 480 |
$sn++; |
| 481 |
$post_type_object = get_post_type_object($objecttype); |
| 482 |
if(is_object($post_type_object)){ |
| 483 |
$posttype .= $post_type_object->label; |
| 484 |
if ($sn < count($taxonomy->object_type)) { |
| 485 |
$posttype .= ', '; |
| 486 |
} |
| 487 |
} |
| 488 |
} |
| 489 |
|
| 490 |
return $posttype; |
| 491 |
} |
| 492 |
|
| 493 |
/** |
| 494 |
* The action column |
| 495 |
* |
| 496 |
* @param $item |
| 497 |
* |
| 498 |
* @return string |
| 499 |
*/ |
| 500 |
protected function column_count($item) |
| 501 |
{ |
| 502 |
|
| 503 |
$taxonomy = get_taxonomy($item->taxonomy); |
| 504 |
|
| 505 |
if($taxonomy->query_var){ |
| 506 |
return sprintf('<a href="%s" class="">%s</a>', |
| 507 |
add_query_arg( |
| 508 |
[ |
| 509 |
$taxonomy->query_var => esc_attr($item->slug), |
| 510 |
'post_type' => isset($taxonomy->object_type[0]) ? $taxonomy->object_type[0] : 'post', |
| 511 |
], |
| 512 |
admin_url('edit.php') |
| 513 |
), |
| 514 |
number_format_i18n($item->count)); |
| 515 |
}else{ |
| 516 |
return number_format_i18n($item->count); |
| 517 |
} |
| 518 |
|
| 519 |
} |
| 520 |
|
| 521 |
/** |
| 522 |
* Method for taxonomy column |
| 523 |
* |
| 524 |
* @param array $item |
| 525 |
* |
| 526 |
* @return string |
| 527 |
*/ |
| 528 |
protected function column_taxonomy($item) |
| 529 |
{ |
| 530 |
$taxonomy = get_taxonomy($item->taxonomy); |
| 531 |
|
| 532 |
if($taxonomy){ |
| 533 |
$return = sprintf( |
| 534 |
'<a href="%1$s">%2$s</a>', |
| 535 |
add_query_arg( |
| 536 |
[ |
| 537 |
'page' => 'st_taxonomies', |
| 538 |
'add' => 'taxonomy', |
| 539 |
'action' => 'edit', |
| 540 |
'taxopress_taxonomy' => $taxonomy->name, |
| 541 |
], |
| 542 |
taxopress_admin_url('admin.php') |
| 543 |
), |
| 544 |
esc_html($taxonomy->labels->name) |
| 545 |
); |
| 546 |
}else{ |
| 547 |
$return = '—'; |
| 548 |
} |
| 549 |
|
| 550 |
return $return; |
| 551 |
} |
| 552 |
|
| 553 |
/** |
| 554 |
* Outputs the hidden row displayed when inline editing |
| 555 |
* |
| 556 |
* @since 3.1.0 |
| 557 |
*/ |
| 558 |
public function inline_edit() { |
| 559 |
?> |
| 560 |
|
| 561 |
<form method="get"> |
| 562 |
<table style="display: none"><tbody id="inlineedit"> |
| 563 |
|
| 564 |
<tr id="inline-edit" class="inline-edit-row" style="display: none"> |
| 565 |
<td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
| 566 |
|
| 567 |
<fieldset> |
| 568 |
<legend class="inline-edit-legend"><?php esc_html_e('Quick Edit', 'simple-tags'); ?></legend> |
| 569 |
<div class="inline-edit-col"> |
| 570 |
<label> |
| 571 |
<span class="title"><?php _ex( 'Name', 'term name', 'simple-tags'); ?></span> |
| 572 |
<span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> |
| 573 |
</label> |
| 574 |
|
| 575 |
<?php if ( ! global_terms_enabled() ) : ?> |
| 576 |
<label> |
| 577 |
<span class="title"><?php esc_html_e('Slug', 'simple-tags'); ?></span> |
| 578 |
<span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span> |
| 579 |
</label> |
| 580 |
<?php endif; ?> |
| 581 |
<label> |
| 582 |
<span class="taxonomy"><?php _ex( 'Taxonomy', 'term name', 'simple-tags'); ?></span> |
| 583 |
|
| 584 |
<?php $taxonomies = get_all_taxopress_taxonomies(); ?> |
| 585 |
<select class="input-text-wrap edit-tax edit_taxonomy" name="edit_taxonomy"> |
| 586 |
<?php |
| 587 |
foreach ( $taxonomies as $taxonomy ) { |
| 588 |
echo '<option value="'. esc_attr($taxonomy->name) .'">'. esc_html($taxonomy->labels->name) .'</option>'; |
| 589 |
} |
| 590 |
?> |
| 591 |
</select> |
| 592 |
</label> |
| 593 |
</div> |
| 594 |
</fieldset> |
| 595 |
|
| 596 |
<div class="inline-edit-save submit"> |
| 597 |
<button type="button" class="cancel button alignleft"><?php esc_html_e('Cancel', 'simple-tags'); ?></button> |
| 598 |
<button type="button" class="taxopress-save button button-primary alignright"><?php esc_html_e('Update', 'simple-tags'); ?></button> |
| 599 |
<span class="spinner"></span> |
| 600 |
|
| 601 |
<?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?> |
| 602 |
<br class="clear" /> |
| 603 |
|
| 604 |
<div class="notice notice-error notice-alt inline hidden"> |
| 605 |
<p class="error"></p> |
| 606 |
</div> |
| 607 |
</div> |
| 608 |
|
| 609 |
</td></tr> |
| 610 |
|
| 611 |
</tbody></table> |
| 612 |
</form> |
| 613 |
<?php |
| 614 |
} |
| 615 |
|
| 616 |
|
| 617 |
} |
| 618 |
|