/** * Admin backend form */ public function form($instance) { global $otw_components; $output = ''; $output .= "\n<div class=\"otw-ws-content\">"; $output .= "\n<div id=\"" . $this->get_field_id('otw-sw-controls') . "\">"; $output .= "\n<label for=\"" . $this->get_field_id('otw-shortcode-type') . "\">" . __('Select Shortcode', 'otw-shortcode-widget') . "</label><br />"; $output .= "\n<select id=\"" . $this->get_field_id('otw-shortcode-type') . "\">"; if (isset($otw_components['loaded']) && isset($otw_components['loaded']['otw_shortcode'])) { foreach ($otw_components['loaded']['otw_shortcode'] as $otw_shortcode_component) { foreach ($otw_shortcode_component['objects'][1]->shortcodes as $shortcode_key => $shortcode) { if (!is_array($shortcode['children'])) { if (!preg_match("/^widget_shortcode/", $shortcode_key)) { $output .= "\n<option value=\"" . $shortcode_key . "\" >" . $shortcode['title'] . "</option>"; } } } break; } } $output .= "\n</select>"; $output .= " <input type=\"button\" value=\"" . __('Add', 'otw-shortcode-widget') . "\" class=\"button button-primary\" id=\"" . $this->get_field_id('otw-sw-add-shortcode') . "\" onclick=\"otw_sw_add_shortcode( this );\"/>"; $output .= "\n</div>"; $output .= "\n<div id=\"" . $this->get_field_id('otw-sw-selected-shortcodes') . "\">"; $output .= "\n</div>"; $output .= "\n</div>"; $otw_sw_code = ''; if (isset($instance['otw-sw-code'])) { $otw_sw_code = $instance['otw-sw-code']; } $output .= "\n<input type=\"hidden\" id=\"" . $this->get_field_id('otw-sw-code') . "\" value=\"" . otw_htmlentities($otw_sw_code) . "\" name=\"" . $this->get_field_name('otw-sw-code') . "\"/>"; $output .= "\n<script type=\"text/javascript\">"; $output .= "\notw_sw_dislpay_code('" . $this->get_field_id('otw-sw-code') . "')"; $output .= "\n</script>"; echo $output; }
public function clean_attribute($attribute_value, $htmlentities) { if ($htmlentities) { $attribute_value = otw_htmlentities($attribute_value); } return $attribute_value; }
/** * format attribute * * @param string name * * @param string key * * @param array with attributes * * @param boolean create attribute if no value * * @return string */ public static function format_attribute($attribute_name, $attribute_key, $attributes, $show_empty = false, $element_type = '') { if (isset($attributes[$attribute_key]) && strlen(trim($attributes[$attribute_key]))) { if (in_array($element_type, array('text_input')) && $attribute_key == 'value') { return ' ' . $attribute_name . '="' . otw_htmlentities(otw_stripslashes($attributes[$attribute_key])) . '"'; } else { return ' ' . $attribute_name . '="' . $attributes[$attribute_key] . '"'; } } elseif ($show_empty) { return ' ' . $attribute_name . '=""'; } }