public function form($instance) { $this->instance = $instance; $title = isset($instance['title']) ? $instance['title'] : ''; $register = hocwp_get_value_by_key($instance, 'register', hocwp_get_value_by_key($this->args, 'register')); $button_text = hocwp_get_value_by_key($instance, 'button_text', hocwp_get_value_by_key($this->args, 'button_text')); $captcha = hocwp_get_value_by_key($instance, 'captcha', hocwp_get_value_by_key($this->args, 'captcha')); $captcha_label = hocwp_get_value_by_key($instance, 'captcha_label', hocwp_get_value_by_key($this->args, 'captcha_label')); $captcha_placeholder = hocwp_get_value_by_key($instance, 'captcha_placeholder', hocwp_get_value_by_key($this->args, 'captcha_placeholder')); $description = hocwp_get_value_by_key($instance, 'description', hocwp_get_value_by_key($this->args, 'description')); $desc_position = hocwp_get_value_by_key($instance, 'desc_position', hocwp_get_value_by_key($this->args, 'desc_position')); $fields = $this->get_value_fields($instance); $all_fields = explode(',', $fields); hocwp_field_widget_before($this->admin_args['class']); hocwp_widget_field_title($this->get_field_id('title'), $this->get_field_name('title'), $title); $args = array('id' => $this->get_field_id('fields'), 'name' => $this->get_field_name('fields'), 'value' => $fields, 'label' => __('Fields:', 'hocwp-theme')); hocwp_widget_field('hocwp_field_input_text', $args); foreach ($all_fields as $field_name) { $field = hocwp_get_value_by_key($this->args['fields'], $field_name); if (hocwp_array_has_value($field)) { foreach ($field as $key => $data) { $field_label = hocwp_uppercase_first_char($field_name); $field_label .= ' ' . strtolower($key); $field_callback = 'hocwp_field_input_text'; if ('required' == $key) { $field_label .= '?'; $field_callback = 'hocwp_field_input_checkbox'; } else { $field_label .= ':'; } $field_value = $this->get_value_field($instance, $field_name, $key); $args = array('id' => $this->get_field_id('subscribe_' . $field_name . '_' . $key), 'name' => $this->get_field_name('subscribe_' . $field_name . '_' . $key), 'value' => $field_value, 'label' => $field_label); hocwp_widget_field($field_callback, $args); } } } $args = array('id' => $this->get_field_id('button_text'), 'name' => $this->get_field_name('button_text'), 'value' => $button_text, 'label' => __('Button text:', 'hocwp-theme')); hocwp_widget_field('hocwp_field_input_text', $args); $args = array('id' => $this->get_field_id('description'), 'name' => $this->get_field_name('description'), 'value' => $description, 'label' => __('Description:', 'hocwp-theme')); hocwp_widget_field('hocwp_field_textarea', $args); $lists = $this->args['desc_positions']; $all_option = ''; foreach ($lists as $lkey => $lvalue) { $all_option .= hocwp_field_get_option(array('value' => $lkey, 'text' => $lvalue, 'selected' => $desc_position)); } $args = array('id' => $this->get_field_id('desc_position'), 'name' => $this->get_field_name('desc_position'), 'value' => $desc_position, 'all_option' => $all_option, 'label' => __('Description position:', 'hocwp-theme'), 'class' => 'desc-position'); hocwp_widget_field('hocwp_field_select', $args); if ($captcha) { $args = array('id' => $this->get_field_id('captcha_label'), 'name' => $this->get_field_name('captcha_label'), 'value' => $captcha_label, 'label' => __('Captcha label:', 'hocwp-theme')); hocwp_widget_field('hocwp_field_input_text', $args); $args = array('id' => $this->get_field_id('captcha_placeholder'), 'name' => $this->get_field_name('captcha_placeholder'), 'value' => $captcha_placeholder, 'label' => __('Captcha placeholder:', 'hocwp-theme')); hocwp_widget_field('hocwp_field_input_text', $args); } $args = array('id' => $this->get_field_id('captcha'), 'name' => $this->get_field_name('captcha'), 'value' => $captcha, 'label' => __('Using captcha in form?', 'hocwp-theme')); hocwp_widget_field('hocwp_field_input_checkbox', $args); $args = array('id' => $this->get_field_id('register'), 'name' => $this->get_field_name('register'), 'value' => $register, 'label' => __('Add suscriber as a user?', 'hocwp-theme')); hocwp_widget_field('hocwp_field_input_checkbox', $args); hocwp_field_widget_after(); }
function hocwp_uppercase_first_char_only($string, $encoding = 'utf-8') { $string = hocwp_lowercase($string, $encoding); $string = hocwp_uppercase_first_char($string, $encoding); return $string; }