widget_fields();
// Loop through fields
foreach ($widget_fields as $field_key => $field) {
if (!isset($field['name']) || !isset($field['type'])) {
continue;
}
if ($field_key != $field['name']) {
continue;
}
$this->form_single($field_key, $field, $instance);
}
}
private function form_single($field_key, $field = array(), $instance)
{
$field_default = array(
'name' => '',
'title' => '',
'type' => 'text',
);
$extra_attributes = array();
$field = wp_parse_args($field, $field_default);
$value = isset($instance[$field_key]) ? $instance[$field_key] : ((isset($field['default']) && $field['type'] != 'checkbox') ? $field['default'] : '');
$extra_attributes = isset($field['extra_attributes']) ? $field['extra_attributes'] : array();
$extra_attribute_text = $this->get_extra_attribute_text($extra_attributes);
$class = isset($field['class']) ? $field['class'] : '';
switch ($field['type']) {
case "repeater":
$repeater_number = isset($field['repeater_num']) ? absint($field['repeater_num']) : 3;
?>
get_repeater_template($field, $field_key, $instance, $value);
?>
description($field) ?>
/>
description($field) ?>
/>
description($field) ?>
/>
description($field) ?>
$choice) { ?>
/>
description($field) ?>
description($field) ?>
description($field) ?>
'name',
'hide_empty' => true,
'class' => 'widefat',
'taxonomy' => 'category',
'selected' => is_array($value) ? implode(",", $value) : $value,
'name' => esc_attr($this->get_field_name($field_key)),
'id' => esc_attr($this->get_field_id($field_key)),
'show_option_all' => esc_html__('All Categories', 'pragyan'),
'echo' => false,
'multiple' => false
);
$cat_args = wp_parse_args($args, $cat_default_args);
?>
wp_dropdown_cats_multiple($output, $cat_args);
} else {
/* translators: 1: taxonomy */
echo '
' . sprintf(esc_html__('Taxonomy (%s) not found', 'pragyan'), $taxonomy) . '
';
}
$this->description($field) ?>
esc_attr($this->get_field_name($field_key)),
'id' => esc_attr($this->get_field_id($field_key)),
'selected' => is_array($value) ? implode(",", $value) : $value,
'class' => ''
);
$pages_args = wp_parse_args($args, $default_args);
?>
description($field) ?>
description($field) ?>
description($field);
foreach ($repeater_options as $rp_key => $rp_option) {
if (!empty($rp_option['name'])) {
$rp_option['name'] = $field_key . '[__mb_index__][' . $rp_option['name'] . ']';
}
$rp_field_key = isset($rp_option['name']) ? $rp_option['name'] : '';
if (!empty($rp_field_key)) {
$this->form_single($rp_field_key, $rp_option, $instance);
}
}
// Main Content
?>
';
echo '';
$this->description($field);
foreach ($repeater_options as $rp_single_key => $rp_option_single) {
if (!empty($rp_option_single['name'])) {
$rp_option_single['name'] = $field_key . '[0][' . $rp_option_single['name'] . ']';
}
$rp_field_key = isset($rp_option_single['name']) ? $rp_option_single['name'] : '';
if (!empty($rp_field_key)) {
$this->form_single($rp_field_key, $rp_option_single, $instance);
}
}
echo '';
} else {
foreach ($value as $value_index => $value_content) {
echo '';
$class = 'remove';
$class = count($value) == ($value_index + 1) ? 'add' : $class;
echo '';
foreach ($repeater_options as $_single_key => $_option_single) {
if (!empty($_option_single['name'])) {
$_option_single['name'] = $field_key . '[' . $value_index . '][' . $_option_single['name'] . ']';
$_option_single['default'] = isset($value_content[$_single_key]) ? $value_content[$_single_key] : '';
}
$_field_key = isset($_option_single['name']) ? $_option_single['name'] : '';
if (!empty($_field_key)) {
$this->form_single($_field_key, $_option_single, $instance);
}
}
echo '
';
}
}
}
public
function description($field)
{
if (isset($field['description'])) {
$allowed_tags = array(
'p' => array(),
'em' => array(),
'strong' => array(),
'a' => array(
'href' => array(),
'target' => array(),
),
);
$updated_value = wp_kses($field['description'], $allowed_tags);
?>
$attribute_value) {
$extra_attribute_text .= ' ' . esc_html($attribute_key) . '="' . esc_attr($attribute_value) . '"';
}
return $extra_attribute_text;
}
public
function update($new_instance, $old_instance)
{
$instance = $old_instance;
$widget_fields = $this->widget_fields();
$field_default = array(
'name' => '',
'title' => '',
'type' => 'text',
);
// Loop through fields
foreach ($widget_fields as $field_key => $field) {
if (!isset($field['name']) || !isset($field['type'])) {
continue;
}
if ($field_key != $field['name']) {
continue;
}
$field = wp_parse_args($field, $field_default);
$new_field_value = isset($new_instance[$field_key]) ? $new_instance[$field_key] : '';
$instance[$field['name']] = Pragyan_Widget_Validation::instance()->sanitize($new_field_value, $field);
}
return $instance;
}
function wp_dropdown_cats_multiple($output, $r)
{
if (isset($r['multiple']) && $r['multiple']) {
$output = preg_replace('/^