function gp_link_get($url, $text, $attrs = array()) { $before = $after = ''; foreach (array('before', 'after') as $key) { if (isset($attrs[$key])) { ${$key} = $attrs[$key]; unset($attrs[$key]); } } $attributes = gp_html_attributes($attrs); $attributes = $attributes ? " {$attributes}" : ''; return sprintf('%1$s<a href="%2$s"%3$s>%4$s</a>%5$s', $before, esc_url($url), $attributes, $text, $after); }
function gp_select($name_and_id, $options, $selected_key, $attrs = array()) { $attributes = gp_html_attributes($attrs); $attributes = $attributes ? " {$attributes}" : ''; $res = "<select name='" . esc_attr($name_and_id) . "' id='" . esc_attr($name_and_id) . "' {$attributes}>\n"; foreach ($options as $value => $label) { $selected = $value == $selected_key ? " selected='selected'" : ''; $res .= "\t<option value='" . esc_attr($value) . "' {$selected}>" . esc_html($label) . "</option>\n"; } $res .= "</select>\n"; return $res; }