🎤

🎤
speaker_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 = ''; $meta = []; $label = ABPET_Function::speaker_label(); $btn_label = __( 'Save', 'abp-event-ticket' ) . ' ' . $label; $title = __( 'Add new ', 'abp-event-ticket' ) . ' ' . $label; if ( ! empty( $term_id ) ) { $term = get_term( $term_id, 'abpet_speaker' ); if ( ! empty( $term ) && ! is_wp_error( $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; $meta = get_term_meta( $term_id, '_abpet_speaker_meta', true ); $meta = is_array( $meta ) ? $meta : []; } } ?>
🎤
[ 'icon' => 'fab fa-twitter', 'label' => 'Twitter/X', 'info' => 'speaker_social_twitter' ], 'linkedin' => [ 'icon' => 'fab fa-linkedin', 'label' => 'LinkedIn', 'info' => 'speaker_social_linkedin' ], 'facebook' => [ 'icon' => 'fab fa-facebook', 'label' => 'Facebook', 'info' => 'speaker_social_facebook' ], 'instagram' => [ 'icon' => 'fab fa-instagram', 'label' => 'Instagram', 'info' => 'speaker_social_instagram' ], ]; foreach ( $social_fields as $key => $info ) { ?>
$html, 'type' => 'success', 'msg' => $label . ' ' . __( 'Form Loaded Successfully .....! ', 'abp-event-ticket' ) ] ); } public function save_tax_speaker(): 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 ] ) ? wp_kses_post( wp_unslash( $_POST[ $key ] ) ) : $default; $post_slug = fn( $key, $default = '' ) => isset( $_POST[ $key ] ) ? sanitize_title( wp_unslash( $_POST[ $key ] ) ) : $default; $post_meta = fn( $key, $default = '' ) => isset( $_POST['meta'] ) && is_array( $_POST['meta'] ) && isset( $_POST['meta'][ $key ] ) ? sanitize_text_field( wp_unslash( $_POST['meta'][ $key ] ) ) : $default; $post_meta_url = fn( $key, $default = '' ) => isset( $_POST['meta'] ) && is_array( $_POST['meta'] ) && isset( $_POST['meta'][ $key ] ) ? esc_url_raw( wp_unslash( $_POST['meta'][ $key ] ) ) : $default; $post_meta_int = fn( $key, $default = 0 ) => isset( $_POST['meta'] ) && is_array( $_POST['meta'] ) && isset( $_POST['meta'][ $key ] ) ? absint( $_POST['meta'][ $key ] ) : $default; $post_social = fn( $key, $default = '' ) => isset( $_POST['meta'] ) && is_array( $_POST['meta'] ) && isset( $_POST['meta']['social'] ) && is_array( $_POST['meta']['social'] ) && isset( $_POST['meta']['social'][ $key ] ) ? esc_url_raw( wp_unslash( $_POST['meta']['social'][ $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' ); $meta = [ 'photo' => $post_meta_int( 'photo' ), 'designation' => $post_meta( 'designation' ), 'company' => $post_meta( 'company' ), 'website' => $post_meta_url( 'website' ), 'social' => [], ]; $social_keys = [ 'twitter', 'linkedin', 'facebook', 'instagram' ]; foreach ( $social_keys as $key ) { $meta['social'][ $key ] = $post_social( $key ); } if ( empty( $name ) ) { ob_start(); if ( empty( $post_id ) || $post_id <= 0 ) { $this->speaker_list(); } $html = ob_get_clean(); wp_send_json_error( [ 'html' => $html, 'type' => 'warn', 'msg' => ABPET_Function::speaker_label() . ' ' . __( 'Name cannot be blank!', 'abp-event-ticket' ) ], 400 ); } if ( $tax_id > 0 ) { $result = wp_update_term( $tax_id, 'abpet_speaker', [ 'name' => $name, 'slug' => $slug, 'description' => $description, ] ); } else { $result = wp_insert_term( $name, 'abpet_speaker', [ 'slug' => $slug, 'description' => $description, ] ); } if ( is_wp_error( $result ) ) { wp_send_json_error( [ 'html' => '', 'msg' => $result->get_error_message() ] ); } $term_id = absint( $result['term_id'] ?? 0 ); if ( $term_id <= 0 ) { wp_send_json_error( [ 'html' => '', 'msg' => __( 'Failed to resolve speaker context.', 'abp-event-ticket' ), 'type' => 'warn' ] ); } update_term_meta( $term_id, '_abpet_speaker_meta', $meta ); $this->update_speaker(); ob_start(); if ( empty( $post_id ) || $post_id <= 0 ) { $this->speaker_list(); } $html = ob_get_clean(); wp_send_json_success( [ 'html' => $html, 'type' => 'success', 'js' => ABPET_Function::option_js( $post_id, 'abpet_speaker' ), 'msg' => ABPET_Function::speaker_label() . ' ' . __( 'Saved Successfully !', 'abp-event-ticket' ), ] ); } public function delete_tax_speaker(): 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'] ) ) : ''; if ( empty( $tax_id ) || ! is_numeric( $tax_id ) ) { ob_start(); $this->speaker_list(); $html = ob_get_clean(); wp_send_json_error( [ 'html' => $html, 'msg' => ABPET_Function::speaker_label() . ' ' . __( 'id Invalid...!', 'abp-event-ticket' ), 'type' => 'warn' ] ); } delete_term_meta( $tax_id, '_abpet_speaker_meta' ); $result = wp_delete_term( $tax_id, 'abpet_speaker' ); $this->update_speaker(); ob_start(); $this->speaker_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::speaker_label() . ' ' . __( 'Deleted Successfully !', 'abp-event-ticket' ) ] ); } public function update_speaker(): void { $taxonomies = ABPET_Function::get_taxonomy( 'abpet_speaker' ); $speaker = []; if ( ! empty( $taxonomies ) && is_array( $taxonomies ) && sizeof( $taxonomies ) > 0 ) { foreach ( $taxonomies as $taxonomy ) { $meta = get_term_meta( $taxonomy->term_id, '_abpet_speaker_meta', true ); $meta = is_array( $meta ) ? $meta : []; $speaker[ $taxonomy->term_id ]['label'] = $taxonomy->name; $speaker[ $taxonomy->term_id ]['description'] = $taxonomy->description; $speaker[ $taxonomy->term_id ]['meta'] = $meta; } } ksort( $speaker ); update_option( 'abpet_speaker', $speaker ); } public function speaker_list(): void { $all_speaker = ABPET_Function::get_option( 'abpet_speaker' ); if ( ! empty( $all_speaker ) && is_array( $all_speaker ) && sizeof( $all_speaker ) > 0 ) { $count = 1; ?> $speaker ) { $meta = $speaker['meta'] ?? []; $photo_url = ''; if ( ! empty( $meta['photo'] ) ) { $photo_url = wp_get_attachment_url( $meta['photo'] ); } ?>