';print_r(ABPET_Function::get_taxonomy( 'abpet_category' ));echo ''; if ( ABPET_Function::on_off( 'category' ) ) { $label = ABPET_Function::category_label(); ?>
category_list(); ?>
__( 'Invalid security token or Insufficient permissions.', 'abp-event-ticket' ), 'type' => 'warn' ], 403 ); } $term_id = isset( $_POST['id'] ) ? absint( wp_unslash( $_POST['id'] ) ) : 0; ob_start(); $name = $slug = $des = ''; $label = ABPET_Function::category_label(); $btn_label = __( 'Save', 'abp-event-ticket' ) . ' ' . $label; $title = __( 'Add new ', 'abp-event-ticket' ) . ' ' . $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-event-ticket' ) . ' ' . $label . ' ' . $name; $title = __( 'Edit ', 'abp-event-ticket' ) . ' ' . $label . ' ' . $name; } } ?>
$html, 'type' => 'success', 'msg' => $label . ' ' . __( 'Form Loaded Successfully .....! ', 'abp-event-ticket' ) ] ); } public function save_tax_category(): void { if ( ! check_ajax_referer( 'abpet_admin_ajax_nonce', 'nonce', false ) || ! current_user_can( 'manage_options' ) ) { wp_send_json_error( [ 'msg' => __( 'Invalid security token or Insufficient permissions.', 'abp-event-ticket' ), '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' ); $label = ABPET_Function::category_label(); if ( empty( $name ) ) { ob_start(); if ( empty( $post_id ) || $post_id <= 0 ) { $this->category_list(); } $html = ob_get_clean(); wp_send_json_error( [ 'html' => $html, 'type' => 'warn', 'msg' => $label . ' ' . __( 'Name cannot be blank!', 'abp-event-ticket' ) ], 400 ); } if ( $tax_id > 0 ) { $result = wp_update_term( $tax_id, 'abpet_category', [ 'name' => $name, 'slug' => $slug, 'description' => $description, ] ); } else { $result = wp_insert_term( $name, 'abpet_category', [ 'slug' => $slug, 'description' => $description, ] ); } $this->update_category(); ob_start(); if ( empty( $post_id ) || $post_id <= 0 ) { $this->category_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', 'js' => ABPET_Function::option_js( $post_id, 'abpet_category' ), 'msg' => $label . ' ' . __( 'Saved Successfully !', 'abp-event-ticket' ), ] ); } public function delete_tax_category(): void { if ( ! check_ajax_referer( 'abpet_admin_ajax_nonce', 'nonce', false ) || ! current_user_can( 'manage_options' ) ) { wp_send_json_error( [ 'msg' => __( 'Invalid security token or Insufficient permissions.', 'abp-event-ticket' ), 'type' => 'warn' ], 403 ); } $tax_id = isset( $_POST['id'] ) ? absint( wp_unslash( $_POST['id'] ) ) : ''; $label = ABPET_Function::category_label(); if ( empty( $tax_id ) || ! is_numeric( $tax_id ) ) { ob_start(); $this->category_list(); $html = ob_get_clean(); wp_send_json_error( [ 'html' => $html, 'msg' => $label . ' ' . __( 'id Invalid...!', 'abp-event-ticket' ), 'type' => 'warn' ] ); } $result = wp_delete_term( $tax_id, 'abpet_category' ); $this->update_category(); ob_start(); $this->category_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' => ABPET_Function::category_label() . ' ' . __( 'Deleted Successfully !', 'abp-event-ticket' ) ] ); } public function update_category(): void { $taxonomies = ABPET_Function::get_taxonomy( 'abpet_category' ); $tax = []; if ( ! empty( $taxonomies ) && is_array( $taxonomies ) && sizeof( $taxonomies ) > 0 ) { foreach ( $taxonomies as $taxonomy ) { $tax[ $taxonomy->term_id ]['label'] = $taxonomy->name; $tax[ $taxonomy->term_id ]['description'] = $taxonomy->description; } } ksort( $tax ); update_option( 'abpet_category', $tax ); } public function category_list(): void { $all_categories = ABPET_Function::get_option( 'abpet_category' ); //echo '
';print_r($all_categories);echo '
'; $count = 1; if ( ! empty( $all_categories ) && is_array( $all_categories ) && sizeof( $all_categories ) > 0 ) { ?> $category ) { $name = $category['label'] ?? ''; ?>
. [abpet-post cat_id=""]