Example #1
0
/**
 * Get Simple Contact module (primary meant for simple contact widget)
 *
 * @since 2.0.3
 *
 * @param array $args Arguments to be used for the elements
 * @return $module HTML to output
 */
function themeblvd_get_simple_contact($args)
{
    // Setup icon links
    $icons = array();
    for ($i = 1; $i <= 6; $i++) {
        if (!empty($args['link_' . $i . '_url'])) {
            $icons[$args['link_' . $i . '_icon']] = $args['link_' . $i . '_url'];
        }
    }
    // Start Output
    $module = '<ul class="simple-contact">';
    // Phone #1
    if (!empty($args['phone_1'])) {
        $module .= sprintf('<li class="phone">%s</li>', $args['phone_1']);
    }
    // Phone #2
    if (!empty($args['phone_2'])) {
        $module .= sprintf('<li class="phone">%s</li>', $args['phone_2']);
    }
    // Email #1
    if (!empty($args['email_1'])) {
        $module .= sprintf('<li class="email"><a href="mailto:%s">%s</a></li>', $args['email_1'], $args['email_1']);
    }
    // Email #2
    if (!empty($args['email_2'])) {
        $module .= sprintf('<li class="email"><a href="mailto:%s">%s</a></li>', $args['email_2'], $args['email_2']);
    }
    // Contact Page
    if (!empty($args['contact'])) {
        $module .= sprintf('<li class="contact"><a href="%s">%s</a></li>', $args['contact'], themeblvd_get_local('contact_us'));
    }
    // Skype
    if (!empty($args['skype'])) {
        $module .= sprintf('<li class="skype">%s</li>', $args['skype']);
    }
    // Social Icons
    if (!empty($icons)) {
        // Social media sources
        $sources = themeblvd_get_social_media_sources();
        $module .= '<li class="link"><ul class="icons">';
        foreach ($icons as $icon => $url) {
            // Link title
            $title = '';
            if (isset($sources[$icon])) {
                $title = $sources[$icon];
            }
            $module .= sprintf('<li class="%s"><a href="%s" target="_blank" title="%s">%s</a></li>', $icon, $url, $title, $title);
        }
        $module .= '</ul></li>';
    }
    $module .= '</ul>';
    return apply_filters('themeblvd_simple_contact', $module, $args);
}
Example #2
0
/**
 * Generates option to edit social media buttons.
 *
 * This has been moved to a separate function
 * because it's a custom addition to the optionframework
 * module and it's pretty lengthy.
 *
 * @since 2.0.0
 *
 * @param $id string unique ID for option
 * @param $name string prefix for form name value
 * @param $val array currently saved data if exists
 * @return $output string HTML for option
 */
function themeblvd_social_media_option($id, $name, $val)
{
    $sources = themeblvd_get_social_media_sources();
    $counter = 1;
    $divider = round(count($sources) / 2);
    $output = '<div class="column-1">';
    foreach ($sources as $key => $source) {
        // Setup
        $checked = false;
        if (is_array($val) && array_key_exists($key, $val)) {
            $checked = true;
        }
        if (!empty($val) && !empty($val[$key])) {
            $value = $val[$key];
        } else {
            $value = 'http://';
            if ($key == 'email') {
                $value = 'mailto:';
            }
        }
        // Add to output
        $output .= '<div class="item">';
        $output .= '<span>';
        $output .= sprintf('<input class="checkbox of-input" value="%s" type="checkbox" %s name="%s" />', $key, checked($checked, true, false), esc_attr($name . '[' . $id . '][includes][]'));
        $output .= $source;
        $output .= '</span>';
        $output .= sprintf('<input class="of-input social_media-input" value="%s" type="text" name="%s" />', esc_attr($value), esc_attr($name . '[' . $id . '][sources][' . $key . ']'));
        $output .= '</div><!-- .item (end) -->';
        if ($counter == $divider) {
            // Separate options into two columns
            $output .= '</div><!-- .column-1 (end) -->';
            $output .= '<div class="column-2">';
        }
        $counter++;
    }
    $output .= '</div><!-- .column-2 (end) -->';
    return $output;
}