/**
 * Display the HTML attributes for the search input tag.
 *
 * Builds up a set of HTML attributes containing the name, value, placeholder, and title
 * values for the input.
 *
 * @param string $placeholder Optional. Defaults to "Search...".
 */
function boilerplate_search_input_attributes($placeholder = null)
{
    $attributes = [];
    if (empty($placeholder)) {
        $placeholder = _x('Search…', 'search field placeholder', 'boilerplate');
    }
    $attributes['name'] = 's';
    $attributes['value'] = get_search_query();
    $attributes['placeholder'] = esc_attr($placeholder);
    $attributes['title'] = esc_attr_x('Search for:', 'label');
    /**
     * Filter the search input attributes for display in the HTML tag.
     *
     * @param string $output A space-separated list of search input attributes.
     */
    echo apply_filters('search_input_attributes', html_build_attributes($attributes));
}
/**
 * Retrieve a formatted link for a value.
 *
 * @param string   $value
 * @param string   $type
 * @param string[] $classes
 *
 * @return string
 */
function boilerplate_link_to($value, $type = 'url', $classes = null)
{
    $output = '';
    switch ($type) {
        case 'url':
            $value = esc_url($value);
            $label = parse_url($value, PHP_URL_HOST);
            $label = preg_replace('#^www\\d?\\.#', '', $label);
            break;
        case 'mail':
        case 'email':
        case 'mailto':
            $value = sanitize_email($value);
            $label = $value;
            $value = 'mailto:' . $value;
            break;
        case 'tel':
        case 'phone':
        case 'telephone':
            $value = sanitize_text_field($value);
            $label = $value;
            $value = 'tel:' . $value;
            break;
        case 'fax':
        case 'telefax':
        case 'telecopier':
            $value = sanitize_text_field($value);
            $label = $value;
            $value = 'fax:' . $value;
            break;
        default:
            $label = $value;
            break;
    }
    if ($value && $label) {
        $link_attr = ['href' => $value];
        if ($classes) {
            if (!is_array($classes)) {
                $classes = [$classes];
            }
            $link_attr['class'] = implode(' ', $classes);
        }
        $output = '<a ' . html_build_attributes($link_attr) . '>' . $label . '</a>';
    }
    return $output;
}