';print_r(ABPTB_Function::get_option('abptb_organizer'));echo '';
// echo '
';print_r(ABPTB_Function::get_taxonomy('abptb_organizer'));echo '';
if (ABPTB_Function::on_off('organizer')) {
$label = ABPTB_Function::organizer_label(); ?>
🏢
organizer_list(); ?>
__('Invalid security token or Insufficient permissions.', 'abp-transport-booking'), 'type' => 'warn'], 403);
}
$term_id = isset($_POST['id']) ? absint(wp_unslash($_POST['id'])) : 0;
ob_start();
$name = $slug = $des = '';
$label = ABPTB_Function::organizer_label();
$btn_label = __('Save', 'abp-transport-booking') . ' ' . $label;
$title = __('Add new ', 'abp-transport-booking') . ' ' . $label;
if (!empty($term_id)) {
$term = get_term($term_id);
if (!empty($term)) {
$name = $term->name;
$slug = $term->slug;
$des = $term->description;
$btn_label = __('Update', 'abp-transport-booking') . ' ' . $label . ' ' . $name;
$title = __('Edit ', 'abp-transport-booking') . ' ' . $label . ' ' . $name;
}
}
?>
$html, 'type' => 'success', 'msg' => $label . ' ' . __('Form Loaded Successfully .....! ', 'abp-transport-booking')]);
}
public function save_tax_organizer(): void {
if (!check_ajax_referer('abptb_admin_ajax_nonce', 'nonce', false) || !current_user_can('manage_options')) {
wp_send_json_error(['msg' => __('Invalid security token or Insufficient permissions.', 'abp-transport-booking'), 'type' => 'warn'], 403);
}
$post_int = fn($key, $default = 0) => isset($_POST[$key]) ? absint($_POST[$key]) : $default;
$post_val = fn($key, $default = '') => isset($_POST[$key]) ? sanitize_text_field(wp_unslash($_POST[$key])) : $default;
$post_textarea = fn($key, $default = '') => isset($_POST[$key]) ? sanitize_textarea_field(wp_unslash($_POST[$key])) : $default;
$post_slug = fn($key, $default = '') => isset($_POST[$key]) ? sanitize_title(wp_unslash($_POST[$key])) : $default;
$tax_id = $post_int('id');
$name = $post_val('name');
$slug = $post_slug('slug');
$description = $post_textarea('description');
$post_id = $post_int('post_id');
if (empty($name)) {
ob_start();
if ($post_id > 0) {
$_category = ABPTB_Function::get_post_info($post_id, 'abptb_organizer');
self::organizer_selection($_category);
} else {
$this->organizer_list();
}
$html = ob_get_clean();
wp_send_json_error(['html' => $html, 'type' => 'warn', 'msg' => ABPTB_Function::organizer_label() . ' ' . __('Name cannot be blank!', 'abp-transport-booking')], 400);
}
if ($tax_id > 0) {
$result = wp_update_term($tax_id, 'abptb_organizer', [
'name' => $name,
'slug' => $slug,
'description' => $description,
]);
} else {
$result = wp_insert_term($name, 'abptb_organizer', [
'slug' => $slug,
'description' => $description,
]);
}
$this->update_organizer();
ob_start();
if ($post_id > 0) {
$_organizer = ABPTB_Function::get_post_info($post_id, 'abptb_organizer');
self::organizer_selection($_organizer);
} else {
$this->organizer_list();
}
$html = ob_get_clean();
if (is_wp_error($result)) {
wp_send_json_error(['html' => $html, 'type' => 'warn', 'msg' => $result->get_error_message()], 400);
}
wp_send_json_success(['html' => $html, 'type' => 'success', 'msg' => ABPTB_Function::organizer_label() . ' ' . __('Saved Successfully !', 'abp-transport-booking'),]);
}
public function delete_tax_organizer(): void {
if (!check_ajax_referer('abptb_admin_ajax_nonce', 'nonce', false) || !current_user_can('manage_options')) {
wp_send_json_error(['msg' => __('Invalid security token or Insufficient permissions.', 'abp-transport-booking'), 'type' => 'warn'], 403);
}
$tax_id = isset($_POST['id']) ? absint(wp_unslash($_POST['id'])) : '';
if (empty($tax_id) || !is_numeric($tax_id)) {
ob_start();
$this->organizer_list();
$html = ob_get_clean();
wp_send_json_error(['html' => $html, 'msg' => ABPTB_Function::organizer_label() . ' ' . __('id Invalid...!', 'abp-transport-booking'), 'type' => 'warn']);
}
$result = wp_delete_term($tax_id, 'abptb_organizer');
$this->update_organizer();
ob_start();
$this->organizer_list();
$html = ob_get_clean();
if (is_wp_error($result)) {
wp_send_json_error(['html' => $html, 'msg' => $result->get_error_message(), 'type' => 'warn']);
}
wp_send_json_success(['html' => $html, 'type' => 'success', 'msg' => ABPTB_Function::organizer_label() . ' ' . __('Deleted Successfully !', 'abp-transport-booking')]);
}
public function update_organizer(): void {
$taxonomies = ABPTB_Function::get_taxonomy('abptb_organizer');
$organizer = [];
if (!empty($taxonomies) && is_array($taxonomies) && sizeof($taxonomies) > 0) {
foreach ($taxonomies as $taxonomy) {
$organizer[$taxonomy->term_id]['name'] = $taxonomy->name;
$organizer[$taxonomy->term_id]['description'] = $taxonomy->description;
}
}
ksort($organizer);
update_option('abptb_organizer', $organizer);
}
public function organizer_list(): void {
$all_organizer = ABPTB_Function::get_option('abptb_organizer');
$count = 1;
if (!empty($all_organizer) && is_array($all_organizer) && sizeof($all_organizer) > 0) { ?>
|
|
|
|
|
|
$organizer) {
$name = $organizer['name'] ?? '';
$description = $organizer['description'] ?? '';
?>
| . |
|
|
|
[abptb-post org_id=""] |
|
0) { ?>