/** * Initialize fields for use on front-end of forms * * @param array $instance * @param array $fields (optional) * @param bool $ordered (optional) * * @return array */ protected function get_fields(array $instance, array $fields = [], $ordered = false) { include 'social-networks.php'; foreach ($fields as $key => &$field) { $default = ['sanitizer' => 'esc_url_raw', 'escaper' => 'esc_url', 'select' => '', 'social' => true, 'target' => '_blank']; $field = wp_parse_args($field, $default); } $title = ['title' => ['label' => __('Title:', 'contact-widgets'), 'description' => __('The title of widget. Leave empty for no title.', 'contact-widgets'), 'value' => !empty($instance['title']) ? $instance['title'] : '', 'sortable' => false]]; // Prepend title field to the array $fields = $title + $fields; $fields['labels'] = ['label' => __('Display labels?', 'contact-widgets'), 'class' => '', 'label_after' => true, 'type' => 'checkbox', 'sortable' => false, 'value' => 'yes', 'atts' => $this->checked('yes', isset($instance['labels']['value']) ? $instance['labels']['value'] : 'no'), 'show_front_end' => false]; $fields = apply_filters('wpcw_widget_social_custom_fields', $fields, $instance); $fields = parent::get_fields($instance, $fields, $ordered); /** * Filter the social fields * * @since 1.0.0 * * @var array */ return (array) apply_filters('wpcw_widget_social_fields', $fields, $instance); }
/** * Initialize fields for use on front-end of forms * * @param array $instance * @param array $fields * @param bool $ordered * * @return array */ protected function get_fields(array $instance, array $fields = [], $ordered = true) { $fields = ['title' => ['label' => __('Title:', 'contact-widgets'), 'description' => __('The title of widget. Leave empty for no title.', 'contact-widgets'), 'value' => !empty($instance['title']) ? $instance['title'] : '', 'sortable' => false], 'email' => ['label' => __('Email:', 'contact-widgets'), 'type' => 'email', 'sanitizer' => 'sanitize_email', 'escaper' => function ($value) { // Work around until https://core.trac.wordpress.org/ticket/32787 return sprintf('<a href="mailto:%1$s">%1$s</a>', antispambot($value)); }, 'description' => __('An email address where website vistors can contact you.', 'contact-widgets')], 'phone' => ['label' => __('Phone:', 'contact-widgets'), 'type' => 'text', 'description' => __('A phone number that website vistors can call if they have questions.', 'contact-widgets')], 'fax' => ['label' => __('Fax:', 'contact-widgets'), 'type' => 'text', 'description' => __('A fax number that website vistors can use to send important documents.', 'contact-widgets')], 'address' => ['label' => __('Address:', 'contact-widgets'), 'type' => 'textarea', 'sanitizer' => function ($value) { return current_user_can('unfiltered_html') ? $value : wp_kses_post(stripslashes($value)); }, 'escaper' => function ($value) { return nl2br(apply_filters('widget_text', $value)); }, 'form_callback' => 'render_form_textarea', 'description' => __('A physical address where website vistors can go to visit you in person.', 'contact-widgets')], 'labels' => ['label' => __('Display labels?', 'contact-widgets'), 'class' => '', 'label_after' => true, 'type' => 'checkbox', 'sortable' => false, 'value' => 'yes', 'atts' => $this->checked('yes', isset($instance['labels']['value']) ? $instance['labels']['value'] : 'yes'), 'show_front_end' => false], 'map' => ['label' => __('Display map of address?', 'contact-widgets'), 'class' => '', 'label_after' => true, 'type' => 'checkbox', 'sortable' => false, 'value' => 'yes', 'atts' => $this->checked('yes', isset($instance['map']['value']) ? $instance['map']['value'] : 'yes'), 'show_front_end' => false]]; $fields = apply_filters('wpcw_widget_contact_custom_fields', $fields, $instance); $fields = parent::get_fields($instance, $fields); /** * Filter the contact fields * * @since 1.0.0 * * @var array */ return (array) apply_filters('wpcw_widget_contact_fields', $fields, $instance); }