Beispiel #1
0
/**
 * Load Scripts
 *
 * Enqueues the required scripts.
 *
 * @since 1.0
 * @global $mashsb_options
 * @global $post
 * @return void
 * @param string $hook Page hook
 */
function mashsb_load_scripts($hook)
{
    global $mashsb_options, $post, $mashsb_sharecount;
    if (!apply_filters('mashsb_load_scripts', mashsbGetActiveStatus(), $hook)) {
        mashdebug()->info("mashsb_load_script not active");
        return;
    }
    $url = mashsb_get_url();
    $title = urlencode(html_entity_decode(the_title_attribute('echo=0'), ENT_COMPAT, 'UTF-8'));
    $title = str_replace('#', '%23', $title);
    $titleclean = esc_html($title);
    $image = "";
    $desc = "";
    if (isset($post->ID)) {
        $image = mashsb_get_image($post->ID);
        $desc = mashsb_get_excerpt_by_id($post->ID);
    }
    // Rest API Not used any longer
    //$restapi = mashsb_allow_rest_api() ? "1" : "0";
    /* Load hashshags */
    $hashtag = !empty($mashsb_options['mashsharer_hashtag']) ? $mashsb_options['mashsharer_hashtag'] : '';
    $js_dir = MASHSB_PLUGIN_URL . 'assets/js/';
    // Use minified libraries if Mashshare debug mode is turned off
    $suffix = mashsbIsDebugMode() ? '' : '.min';
    isset($mashsb_options['load_scripts_footer']) ? $in_footer = true : ($in_footer = false);
    wp_enqueue_script('mashsb', $js_dir . 'mashsb' . $suffix . '.js', array('jquery'), MASHSB_VERSION, $in_footer);
    //wp_enqueue_script( 'element-queries', $js_dir . 'ElementQueries' . '.js', array('jquery'), MASHSB_VERSION, $in_footer );
    //wp_enqueue_script( 'resize-sensor', $js_dir . 'ResizeSensor' . '.js', array('jquery'), MASHSB_VERSION, $in_footer );
    !isset($mashsb_options['disable_sharecount']) ? $shareresult = getSharedcount($url) : ($shareresult = 0);
    wp_localize_script('mashsb', 'mashsb', array('shares' => $shareresult, 'round_shares' => isset($mashsb_options['mashsharer_round']), 'animate_shares' => isset($mashsb_options['animate_shares']) && is_singular() ? 1 : 0, 'dynamic_buttons' => isset($mashsb_options['dynamic_button_resize']) ? 1 : 0, 'share_url' => $url, 'title' => $titleclean, 'image' => $image, 'desc' => $desc, 'hashtag' => $hashtag, 'subscribe' => !empty($mashsb_options['subscribe_behavior']) && $mashsb_options['subscribe_behavior'] === 'content' ? 'content' : 'link', 'subscribe_url' => isset($mashsb_options['subscribe_link']) ? $mashsb_options['subscribe_link'] : '', 'activestatus' => mashsbGetActiveStatus(), 'singular' => is_singular() ? 1 : 0, 'twitter_popup' => isset($mashsb_options['twitter_popup']) ? 0 : 1, 'refresh' => mashsb_is_cache_refresh() ? 1 : 0));
}
function mashsb_get_twitter_url()
{
    global $wp, $post, $numpages;
    if (function_exists('mashsuGetShortURL')) {
        $url = mashsb_get_url();
        mashsuGetShortURL($url) !== 0 ? $url = mashsuGetShortURL($url) : ($url = mashsb_get_url());
    } else {
        $url = mashsb_get_url();
    }
    return apply_filters('mashsb_get_twitter_url', $url);
}
function mashsharer()
{
    global $content;
    global $atts;
    //global $url;
    //global $title;
    global $post;
    global $wp;
    //is_singular() ? $url = urlencode(home_url( $wp->request )) : $url = urlencode(get_permalink($post->ID));
    $url = mashsb_get_url();
    function_exists('MASHOG') ? $title = MASHOG()->MASHOG_OG_Output->_get_title() : ($title = the_title_attribute('echo=0'));
    //$title = html_entity_decode(the_title_attribute('echo=0'), ENT_QUOTES, 'UTF-8');
    $title = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
    $title = urlencode($title);
    $title = str_replace('#', '%23', $title);
    $title = esc_html($title);
    echo mashshareShow($atts, '', $url, $title);
}
function mashsb_get_twitter_url()
{
    if (function_exists('mashsb_get_shorturl_singular')) {
        $url = mashsb_get_shorturl_singular(mashsb_get_url());
    } else {
        if (function_exists('mashsuGetShortURL')) {
            // compatibility mode for MashShare earlier than 3.0
            $get_url = mashsb_get_url();
            $url = mashsuGetShortURL($get_url);
        } else {
            $url = mashsb_get_url();
        }
    }
    return apply_filters('mashsb_get_twitter_url', $url);
}