function hocwp_setup_theme_add_facebook_javascript_sdk()
{
    $load_sdk = hocwp_use_facebook_javascript_sdk();
    if ($load_sdk) {
        $args = array();
        $app_id = hocwp_get_wpseo_social_value('fbadminapp');
        if (empty($app_id)) {
            $app_id = hocwp_option_get_value('hocwp_option_social', 'fbadminapp');
        }
        if (!empty($app_id)) {
            $args['app_id'] = $app_id;
        }
        hocwp_facebook_javascript_sdk($args);
    }
}
$option->add_section(array('id' => 'google', 'title' => __('Google', 'hocwp-theme'), 'description' => __('All information about Google account and Google console.', 'hocwp-theme')));
$option->add_field(array('id' => 'facebook_site', 'title' => __('Facebook page URL', 'hocwp-theme'), 'value' => hocwp_get_wpseo_social_value('facebook_site')));
$twitter_account = hocwp_get_wpseo_social_value('twitter_site');
if (!empty($twitter_account) && !hocwp_url_valid($twitter_account)) {
    $twitter_account = 'http://twitter.com/' . $twitter_account;
}
$option->add_field(array('id' => 'twitter_site', 'title' => __('Twitter URL', 'hocwp-theme'), 'value' => $twitter_account));
$option->add_field(array('id' => 'instagram_url', 'title' => __('Instagram URL', 'hocwp-theme'), 'value' => hocwp_get_wpseo_social_value('instagram_url')));
$option->add_field(array('id' => 'linkedin_url', 'title' => __('LinkedIn URL', 'hocwp-theme'), 'value' => hocwp_get_wpseo_social_value('linkedin_url')));
$option->add_field(array('id' => 'myspace_url', 'title' => __('Myspace URL', 'hocwp-theme'), 'value' => hocwp_get_wpseo_social_value('myspace_url')));
$option->add_field(array('id' => 'pinterest_url', 'title' => __('Pinterest URL', 'hocwp-theme'), 'value' => hocwp_get_wpseo_social_value('pinterest_url')));
$option->add_field(array('id' => 'youtube_url', 'title' => __('YouTube URL', 'hocwp-theme'), 'value' => hocwp_get_wpseo_social_value('youtube_url')));
$option->add_field(array('id' => 'google_plus_url', 'title' => __('Google+ URL', 'hocwp-theme'), 'value' => hocwp_get_wpseo_social_value('google_plus_url')));
$option->add_field(array('id' => 'rss_url', 'title' => __('RSS URL', 'hocwp-theme')));
$option->add_field(array('id' => 'addthis_id', 'title' => __('AddThis ID', 'hocwp-theme'), 'section' => 'account'));
$option->add_field(array('id' => 'fbadminapp', 'title' => __('Facebook App ID', 'hocwp-theme'), 'section' => 'facebook', 'value' => hocwp_get_wpseo_social_value('fbadminapp')));
$option->add_field(array('id' => 'google_api_key', 'title' => __('Google API Key', 'hocwp-theme'), 'section' => 'google'));
$option->add_field(array('id' => 'google_client_id', 'title' => __('Google Client ID', 'hocwp-theme'), 'section' => 'google'));
$option->add_option_tab($hocwp_tos_tabs);
$option->set_page_header_callback('hocwp_theme_option_form_before');
$option->set_page_footer_callback('hocwp_theme_option_form_after');
$option->set_page_sidebar_callback('hocwp_theme_option_sidebar_tab');
$option->init();
hocwp_option_add_object_to_list($option);
function hocwp_option_social_update($input)
{
    $key = 'facebook_site';
    if (isset($input[$key])) {
        hocwp_update_wpseo_social($key, $input[$key]);
    }
    $key = 'twitter_site';
function hocwp_get_wpseo_social_facebook_app_id()
{
    return hocwp_get_wpseo_social_value('fbadminapp');
}
Example #4
0
function hocwp_get_social_share_url($args = array())
{
    $result = '';
    $title = hocwp_get_value_by_key($args, 'title', get_the_title());
    $permalink = hocwp_get_value_by_key($args, 'permalink', get_the_permalink());
    $social_name = hocwp_get_value_by_key($args, 'social_name');
    $thumbnail = hocwp_get_value_by_key($args, 'thumbnail');
    $excerpt = hocwp_get_value_by_key($args, 'excerpt', get_the_excerpt());
    $language = hocwp_get_value_by_key($args, 'language', hocwp_get_language());
    $twitter_account = hocwp_get_value_by_key($args, 'twitter_account', 'skylarkcob');
    $permalink = urlencode($permalink);
    if (empty($twitter_account)) {
        $twitter_account = hocwp_get_wpseo_social_value('twitter_site');
        $twitter_account = basename($twitter_account);
    }
    switch ($social_name) {
        case 'email':
            $result = 'mailto:email@hocwp.net?subject=' . $title . '&body=' . $permalink;
            break;
        case 'facebook':
            $url = 'https://www.facebook.com/sharer/sharer.php';
            $url = add_query_arg('u', $permalink, $url);
            if (!empty($title)) {
                $url = add_query_arg('t', $title, $url);
            }
            $result = $url;
            break;
        case 'gplus':
        case 'googleplus':
            $url = 'http://plusone.google.com/_/+1/confirm';
            $url = add_query_arg('hl', $language, $url);
            $url = add_query_arg('url', $permalink, $url);
            $result = $url;
            break;
        case 'twitter':
            $url = 'http://twitter.com/share';
            $url = add_query_arg('url', $permalink, $url);
            if (!empty($title)) {
                $url = add_query_arg('text', $title, $url);
            }
            $url = add_query_arg('via', $twitter_account, $url);
            $result = $url;
            break;
        case 'pinterest':
            $url = 'http://www.pinterest.com/pin/create/button';
            if (!empty($thumbnail)) {
                $url = add_query_arg('media', $thumbnail, $url);
            }
            $url = add_query_arg('url', $permalink, $url);
            if (!empty($title)) {
                $url = add_query_arg('description', $title . ' ' . $permalink, $url);
            }
            $result = $url;
            break;
        case 'zingme':
            $url = 'http://link.apps.zing.vn/share';
            if (!empty($title)) {
                $url = add_query_arg('t', $title, $url);
            }
            $url = add_query_arg('u', $permalink, $url);
            if (!empty($excerpt)) {
                $url = add_query_arg('desc', $excerpt, $url);
            }
            $result = $url;
            break;
    }
    return $result;
}