array('min' => 0, 'max' => 32), 'field_gap' => array('min' => 0, 'max' => 60), 'field_padding' => array('min' => 4, 'max' => 32), 'font_size' => array('min' => 10, 'max' => 28), ); foreach ($numeric_bounds as $key => $bounds) { if (isset($_POST[$key])) { $settings[$key] = max($bounds['min'], min($bounds['max'], absint($_POST[$key]))); } } if (isset($_POST['label_position']) && in_array(sanitize_key(wp_unslash($_POST['label_position'])), array('above', 'inside'), true)) { $settings['label_position'] = sanitize_key(wp_unslash($_POST['label_position'])); } update_option('adpf_styling_settings', $settings); wp_safe_redirect(add_query_arg(array('page' => 'adpf-styling', 'saved' => '1'), admin_url('admin.php'))); exit; } public static function get_defaults() { return array( 'primary_color' => '#2271b1', 'text_color' => '#333333', 'label_color' => '#333333', 'border_color' => '#dddddd', 'success_color' => '#00a32a', 'error_color' => '#d63638', 'border_radius' => 4, 'field_gap' => 24, 'field_padding' => 12, 'font_size' => 16, 'label_position' => 'above', ); } public static function get_settings() { return wp_parse_args(get_option('adpf_styling_settings', array()), self::get_defaults()); } public function enqueue_assets($hook) { if (strpos($hook, 'adpf-styling') === false) { return; } wp_enqueue_style('wp-color-picker'); wp_enqueue_script('wp-color-picker'); wp_add_inline_script('wp-color-picker', ' jQuery(document).ready(function($) { $(".adpf-color-picker").wpColorPicker(); $(".adpf-range-input").on("input", function() { var unit = $(this).data("unit") || ""; $(this).next(".adpf-range-display").text($(this).val() + unit); }); $("input[name=\'label_position\']").on("change", function() { $(".adpf-toggle-option").removeClass("adpf-toggle-active"); $(this).closest(".adpf-toggle-option").addClass("adpf-toggle-active"); }); }); '); } public function render_page() { if (!current_user_can('manage_options')) { return; } $settings = self::get_settings(); $upgrade_url = adpf_get_upgrade_url(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only display flag $saved = isset($_GET['saved']) && sanitize_key(wp_unslash($_GET['saved'])) === '1'; ?>

color_field('primary_color', __('Button & Accent Color', 'ad-pro-forms'), $settings['primary_color'], __('Used for the submit button and field focus rings.', 'ad-pro-forms')); $this->color_field('text_color', __('Text Color', 'ad-pro-forms'), $settings['text_color'], __('Color of text entered inside form fields.', 'ad-pro-forms')); $this->color_field('label_color', __('Label Color', 'ad-pro-forms'), $settings['label_color'], __('Color of field labels shown above inputs.', 'ad-pro-forms')); $this->color_field('border_color', __('Border Color', 'ad-pro-forms'), $settings['border_color'], __('Default border color of input fields.', 'ad-pro-forms')); $this->color_field('success_color', __('Success Color', 'ad-pro-forms'), $settings['success_color'], __('Background of the success message shown after submission.', 'ad-pro-forms')); $this->color_field('error_color', __('Error Color', 'ad-pro-forms'), $settings['error_color'], __('Color of error messages and invalid field borders.', 'ad-pro-forms')); ?>

range_field('border_radius', __('Border Radius', 'ad-pro-forms'), $settings['border_radius'], 0, 32, 'px', __('Roundness of input fields and the submit button.', 'ad-pro-forms')); $this->range_field('field_padding', __('Field Padding', 'ad-pro-forms'), $settings['field_padding'], 4, 32, 'px', __('Inner padding inside each input field.', 'ad-pro-forms')); $this->range_field('field_gap', __('Field Spacing', 'ad-pro-forms'), $settings['field_gap'], 0, 60, 'px', __('Vertical gap between form fields.', 'ad-pro-forms')); ?>

range_field('font_size', __('Field Font Size', 'ad-pro-forms'), $settings['font_size'], 10, 28, 'px', __('Font size of text inside input fields.', 'ad-pro-forms')); ?>

render_footer(); } private function color_field($name, $label, $value, $hint = '') { ?>