🔗
feature_list(); ?>
__('Invalid security token or Insufficient permissions.', 'abp-event-ticket'), 'type' => 'warn'], 403); } ob_start(); $id = isset($_POST['id']) ? absint(wp_unslash($_POST['id'])) : ''; $options = ABPET_Function::get_option('abpet_feature'); $options = is_array($options) ? $options : []; $feature = $options[$id] ?? []; $label = ABPET_Function::feature_label(); $btn_label = __('Save', 'abp-event-ticket') . ' ' . $label; $title = __('Add new ', 'abp-event-ticket') . ' ' . $label; ?>
🔗
*
$html, 'type' => 'success', 'msg' => $label . ' ' . __('Form Loaded Successfully .....! ', 'abp-event-ticket')]); } public function save_option_feature(): 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_array = fn($key) => (isset($_POST[$key]) && is_array($_POST[$key])) ? array_map('sanitize_text_field', wp_unslash($_POST[$key])) : []; $old_features = ABPET_Function::get_option('abpet_feature'); $old_features = is_array($old_features) ? $old_features : []; $feature_ids = $post_array('feature_id'); $feature_names = $post_array('feature_name'); $feature_values = $post_array('feature_value'); $feature_icon = $post_array('feature_icon'); $post_id = $post_int('post_id'); if (!empty($feature_names)) { foreach ($feature_names as $key => $feature_name) { $feature_val = $feature_values[$key] ?? ''; if ($feature_name !== '') { $old_id = isset($feature_ids[$key]) ? (int)$feature_ids[$key] : ''; if (!empty($old_id) && isset($old_features[$old_id])) { $id = $old_id; } else { $id = 1; while (isset($old_features[$id])) { $id++; } } $old_features[$id] = [ 'label' => $feature_name, 'value' => $feature_val, 'icon' => $feature_icon[$key] ?? '', ]; } } } update_option('abpet_feature', $old_features); $html = ''; if (empty($post_id) || $post_id <= 0) { ob_start(); $this->feature_list(); $html = ob_get_clean(); } wp_send_json_success([ 'html' => $html, 'msg' => __('Feature Saved Successfully..........!!', 'abp-event-ticket'), 'js' => ABPET_Function::option_js($post_id,'abpet_feature'), ]); } public function delete_option_feature(): 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); } $id = isset($_POST['id']) ? absint(wp_unslash($_POST['id'])) : 0; $options = ABPET_Function::get_option('abpet_feature'); $options = is_array($options) ? $options : []; if (!empty($id) && isset($options[$id])) { unset($options[$id]); update_option('abpet_feature', $options); } ob_start(); $this->feature_list(); $html = ob_get_clean(); wp_send_json_success([ 'html' => $html, 'msg' => ABPET_Function::feature_label() . ' ' . __('Deleted Successfully!', 'abp-event-ticket'), 'type' => 'success' ]); } public function feature_list(): void { $features = ABPET_Function::get_option('abpet_feature'); if (sizeof($features) > 0) { ?>
$feature) { $label = $feature['label'] ?? ''; $value = $feature['value'] ?? ''; if (!empty($label)) { ?>