__('Logs Settings'), 'gosmtp-connections-settings' => __('Additional Connections'), 'gosmtp-notifications-settings' => __('Notifications', 'gosmtp-pro'), 'gosmtp-smart-routing-settings' => __('Smart Routing', 'gosmtp-pro'), ); // Add the $_navs array in 1 position of $navs; $navs = array_slice( $navs, 0, $offset, true ) + $_navs + array_slice( $navs, $offset, null, true ); return $navs; } // Add settings tab panel add_action('gosmtp_after_settings_tab_panel', 'gosmtp_pro_after_settings_tab_panel'); function gosmtp_pro_after_settings_tab_panel(){ $smtp_options = get_option('gosmtp_options', array()); $mailer_count = !empty($smtp_options['mailer']) ? count($smtp_options['mailer']) : 0; // Default mailer set mail if(!isset($smtp_options['mailer']) || !is_array($smtp_options['mailer']) || empty($smtp_options['mailer'][0])){ $smtp_options['mailer'] = []; $smtp_options['mailer'][0]['mail_type'] = 'mail'; } ?>
service); foreach($fields as $key => $field){ $val = $service->get_option($key, $service->service); if($val === '' && isset($field['default'])){ $val = $field['default']; } $attrs = 'name="' . esc_attr($service_class . '[' . $key . ']') . '"'; if(!empty($field['type']) && $field['type'] != 'select'){ $attrs .= 'type="' . esc_attr($field['type']) . '"'; } $input_html = ''; if(in_array($field['type'], ['text', 'password', 'number'])){ $input_html = ''; } elseif($field['type'] === 'email'){ $input_html = ''; } $description = empty($field['desc']) ? '' : wp_kses_post($field['desc']); $html .= ' ' . esc_html($field['title']) . ' '.$input_html.'

' .wp_kses_post($description).'

'; } return $html; } add_action('gosmtp_pro_test_connection_and_template', 'gosmtp_pro_connection_and_template_settings'); function gosmtp_pro_connection_and_template_settings(){ global $gosmtp; $smtp_options = $gosmtp->options; $mailer_count = !empty($smtp_options['mailer']) ? count($smtp_options['mailer']) : 0; if($mailer_count > 1){ ?>

save_options($options['notifications']); } } // Is notification enabled $options['notifications']['notifications_enabled'] = !empty($_POST['gosmtp-pro-notifications-checkbox']); if(update_option('gosmtp_options', $options)){ add_settings_error('gosmtp', 'notification_success', __('Notification settings saved successfully!', 'gosmtp-pro'), 'updated'); } } add_action('gosmtp_pro_save_smart_routing_settings', 'gosmtp_pro_save_smart_routing', 10); function gosmtp_pro_save_smart_routing(){ if(!isset($_REQUEST['save_smart_routing_settings'])){ return; } check_admin_referer('gosmtp-settings'); // TODO: authorization check if(!current_user_can('activate_plugins')){ return; } $options = get_option('gosmtp_options', []); $enabled = isset($_POST['gosmtp-pro-smart-routing-checkbox']); $smart_routing = [ 'enabled' => $enabled, 'rules' => [] ]; if(!empty($_POST['smartrouting']) && is_array($_POST['smartrouting'])){ foreach($_POST['smartrouting'] as $key => $block){ $connection_id = isset($block['connection_id']) ? sanitize_text_field(wp_unslash($block['connection_id'])) : ''; if(empty($connection_id)){ continue; } $new_rule_block = [ 'connection_id' => $connection_id, 'groups' => [] ]; $groups_input = !empty($block['rules']['groups']) ? $block['rules']['groups'] : []; foreach($groups_input as $group_index => $group_data){ $conditions = []; if(is_array($group_data)){ foreach($group_data as $condition_index => $condition){ if(is_array($condition) && !empty($condition['value'])){ $conditions[] = [ 'type' => sanitize_text_field(wp_unslash($condition['type'])), 'operator' => sanitize_text_field(wp_unslash($condition['operator'])), 'value' => sanitize_text_field(wp_unslash($condition['value'])) ]; } } } if(!empty($conditions)){ $new_rule_block['groups'][$group_index] = $conditions; } } if(!empty($new_rule_block['groups'])){ $smart_routing['rules'][] = $new_rule_block; } } } $options['smart_routing'] = $smart_routing; if(update_option('gosmtp_options', $options)){ add_settings_error('gosmtp', 'notification_success', __('Smart Routing Setting saved Successfully!', 'gosmtp-pro'), 'updated'); } } ?>