/**
 * Outputs module to manage links to be shown using the corresponding widget
 * @param array $data
 * @return string
 * @since 1.2.7
 */
function themify_manage_links($data = array())
{
    $data = themify_get_data();
    $pre = 'setting-link_';
    $field_hash = isset($data[$pre . 'field_hash']) && $data[$pre . 'field_hash'] ? $data[$pre . 'field_hash'] : 10;
    $start = array();
    for ($i = 0; $i < $field_hash; $i++) {
        $start['themify-link-' . $i] = 'themify-link-' . $i;
    }
    //$data[$pre.'field_ids'] = json_encode($start);
    if (json_decode(themify_get($pre . 'field_ids'))) {
        $field_ids = json_decode(themify_get($pre . 'field_ids'));
    } else {
        $field_ids = $start;
        // Image Icons
        $data[$pre . 'type_themify-link-0'] = 'image-icon';
        $data[$pre . 'type_themify-link-1'] = 'image-icon';
        $data[$pre . 'type_themify-link-2'] = 'image-icon';
        $data[$pre . 'type_themify-link-3'] = 'image-icon';
        $data[$pre . 'type_themify-link-4'] = 'image-icon';
        $data[$pre . 'title_themify-link-0'] = 'Twitter';
        $data[$pre . 'title_themify-link-1'] = 'Facebook';
        $data[$pre . 'title_themify-link-2'] = 'Google+';
        $data[$pre . 'title_themify-link-3'] = 'YouTube';
        $data[$pre . 'title_themify-link-4'] = 'Pinterest';
        $data[$pre . 'link_themify-link-0'] = '';
        $data[$pre . 'link_themify-link-1'] = '';
        $data[$pre . 'link_themify-link-2'] = '';
        $data[$pre . 'link_themify-link-3'] = '';
        $data[$pre . 'link_themify-link-4'] = '';
        $data[$pre . 'img_themify-link-0'] = THEMIFY_URI . '/img/social/twitter.png';
        $data[$pre . 'img_themify-link-1'] = THEMIFY_URI . '/img/social/facebook.png';
        $data[$pre . 'img_themify-link-2'] = THEMIFY_URI . '/img/social/google-plus.png';
        $data[$pre . 'img_themify-link-3'] = THEMIFY_URI . '/img/social/youtube.png';
        $data[$pre . 'img_themify-link-4'] = THEMIFY_URI . '/img/social/pinterest.png';
        // Font Icons
        $data[$pre . 'type_themify-link-5'] = 'font-icon';
        $data[$pre . 'type_themify-link-6'] = 'font-icon';
        $data[$pre . 'type_themify-link-7'] = 'font-icon';
        $data[$pre . 'type_themify-link-8'] = 'font-icon';
        $data[$pre . 'type_themify-link-9'] = 'font-icon';
        $data[$pre . 'title_themify-link-5'] = 'Twitter';
        $data[$pre . 'title_themify-link-6'] = 'Facebook';
        $data[$pre . 'title_themify-link-7'] = 'Google+';
        $data[$pre . 'title_themify-link-8'] = 'YouTube';
        $data[$pre . 'title_themify-link-9'] = 'Pinterest';
        $data[$pre . 'link_themify-link-5'] = '';
        $data[$pre . 'link_themify-link-6'] = '';
        $data[$pre . 'link_themify-link-7'] = '';
        $data[$pre . 'link_themify-link-8'] = '';
        $data[$pre . 'link_themify-link-9'] = '';
        $data[$pre . 'ficon_themify-link-5'] = 'fa-twitter';
        $data[$pre . 'ficon_themify-link-6'] = 'fa-facebook';
        $data[$pre . 'ficon_themify-link-7'] = 'fa-google-plus';
        $data[$pre . 'ficon_themify-link-8'] = 'fa-youtube';
        $data[$pre . 'ficon_themify-link-9'] = 'fa-pinterest';
        $data[$pre . 'ficolor_themify-link-5'] = '';
        $data[$pre . 'ficolor_themify-link-6'] = '';
        $data[$pre . 'ficolor_themify-link-7'] = '';
        $data[$pre . 'ficolor_themify-link-8'] = '';
        $data[$pre . 'ficolor_themify-link-9'] = '';
        $data[$pre . 'fibgcolor_themify-link-5'] = '';
        $data[$pre . 'fibgcolor_themify-link-6'] = '';
        $data[$pre . 'fibgcolor_themify-link-7'] = '';
        $data[$pre . 'fibgcolor_themify-link-8'] = '';
        $data[$pre . 'fibgcolor_themify-link-9'] = '';
        $data = apply_filters('themify_default_social_links', $data);
    }
    $out = '<div class="themify-info-link">' . sprintf(__('To display the links: go to Appearance > <a href="%s">Widgets</a> and drop a Themify - Social Links widget in a widget area (<a href="%s">learn more</a>)', 'themify'), admin_url('widgets.php'), 'http://themify.me/docs/social-media-links') . '</div>';
    $out .= '<div id="social-link-type">';
    // Icon Font
    $out .= '<label for="' . $pre . 'font_icon">';
    $out .= '<input ' . checked(isset($data[$pre . 'icon_type']) ? $data[$pre . 'icon_type'] : '', 'font-icon', false) . ' type="radio" id="' . $pre . 'font_icon" name="' . $pre . 'icon_type" value="font-icon" data-hide="image-icon" /> ';
    $out .= __('Icon Font', 'themify') . '</label>';
    // Image
    $out .= '<label for="' . $pre . 'image_icon">';
    $out .= '<input ' . checked(isset($data[$pre . 'icon_type']) ? $data[$pre . 'icon_type'] : 'image-icon', 'image-icon', false) . ' type="radio" id="' . $pre . 'image_icon" name="' . $pre . 'icon_type" value="image-icon" data-hide="font-icon" /> ';
    $out .= __('Image', 'themify') . '</label>';
    $out .= '</p>';
    $out .= '<ul id="social-links-wrapper">';
    foreach ($field_ids as $key => $fid) {
        $out .= themify_add_link_template($fid, $data);
    }
    $out .= '</ul>';
    $out .= '<p class="add-link add-social-link"><a href="#">' . __('Add Link', 'themify') . '</a></p>';
    $out .= '<input type="hidden" id="' . $pre . 'field_ids" name="' . $pre . 'field_ids" value=\'' . json_encode($field_ids) . '\'/>';
    $out .= '<input type="hidden" id="' . $pre . 'field_hash" name="' . $pre . 'field_hash" value="' . $field_hash . '"/>';
    //$out .= '<p>Fields: '.json_encode($field_ids).'</p><p>Hash: '.$field_hash.'</p>';
    return $out;
}
/**
 * Outputs module to manage links to be shown using the corresponding widget
 * @param array $data
 * @return string
 * @since 1.2.7
 */
function themify_manage_links($data = array())
{
    $data = themify_get_data();
    $pre = 'setting-link_';
    $field_hash = $data[$pre . 'field_hash'] ? $data[$pre . 'field_hash'] : 5;
    $start = array();
    for ($i = 0; $i < $field_hash; $i++) {
        $start['themify-link-' . $i] = 'themify-link-' . $i;
    }
    //$data[$pre.'field_ids'] = json_encode($start);
    if (json_decode($data[$pre . 'field_ids'])) {
        $field_ids = json_decode($data[$pre . 'field_ids']);
    } else {
        $field_ids = $start;
        $data[$pre . 'title_themify-link-0'] = 'Twitter';
        $data[$pre . 'title_themify-link-1'] = 'Facebook';
        $data[$pre . 'title_themify-link-2'] = 'Google+';
        $data[$pre . 'title_themify-link-3'] = 'YouTube';
        $data[$pre . 'title_themify-link-4'] = 'Pinterest';
        $data[$pre . 'link_themify-link-0'] = '';
        $data[$pre . 'link_themify-link-1'] = '';
        $data[$pre . 'link_themify-link-2'] = '';
        $data[$pre . 'link_themify-link-3'] = '';
        $data[$pre . 'link_themify-link-4'] = '';
        $data[$pre . 'img_themify-link-0'] = THEMIFY_URI . '/img/social/twitter.png';
        $data[$pre . 'img_themify-link-1'] = THEMIFY_URI . '/img/social/facebook.png';
        $data[$pre . 'img_themify-link-2'] = THEMIFY_URI . '/img/social/google-plus.png';
        $data[$pre . 'img_themify-link-3'] = THEMIFY_URI . '/img/social/youtube.png';
        $data[$pre . 'img_themify-link-4'] = THEMIFY_URI . '/img/social/pinterest.png';
    }
    $out = '<ul id="social-links-wrapper">';
    foreach ($field_ids as $key => $fid) {
        $out .= themify_add_link_template($fid, $data);
    }
    $out .= '</ul>';
    $out .= '<p class="add-social-link"><a href="#">' . __('Add Link', 'themify') . '</a></p>';
    $out .= '<p><small>' . sprintf(__('To display the links: go to Appearance > <a href="%s">Widgets</a> and drop a Themify - Social Links widget in a widget area (<a href="%s">learn more</a>)', 'themify'), admin_url('widgets.php'), 'http://themify.me/docs/social-media-links') . '</small></p>';
    $out .= '<input type="hidden" id="' . $pre . 'field_ids" name="' . $pre . 'field_ids" value=\'' . json_encode($field_ids) . '\'/>';
    $out .= '<input type="hidden" id="' . $pre . 'field_hash" name="' . $pre . 'field_hash" value="' . $field_hash . '"/>';
    //$out .= '<p>Fields: '.json_encode($field_ids).'</p><p>Hash: '.$field_hash.'</p>';
    return $out;
}
function themify_add_link_field()
{
    check_ajax_referer('ajax-nonce', 'nonce');
    if (isset($_POST['fid'])) {
        $hash = $_POST['fid'];
        $type = isset($_POST['type']) ? $_POST['type'] : 'image-icon';
        $field = themify_add_link_template('themify-link-' . $hash, array(), true, $type);
        echo $field;
        exit;
    }
}
Beispiel #4
0
function themify_add_link_field()
{
    check_ajax_referer('ajax-nonce', 'nonce');
    if (isset($_POST['fid'])) {
        $hash = $_POST['fid'];
        $field = themify_add_link_template('themify-link-' . $hash);
        echo $field;
        exit;
    }
}