Ejemplo n.º 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));
}
Ejemplo n.º 2
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 $wp;
    if (!apply_filters('mashsb_load_scripts', mashsbGetActiveStatus(), $hook)) {
        mashdebug()->info("mashsb_load_script not active");
        return;
    }
    global $mashsb_options, $post;
    $url = get_permalink($post->ID);
    $title = urlencode(html_entity_decode(the_title_attribute('echo=0'), ENT_COMPAT, 'UTF-8'));
    $title = str_replace('#', '%23', $title);
    $titleclean = esc_html($title);
    $image = mashsb_get_image($post->ID);
    $desc = mashsb_get_excerpt_by_id($post->ID);
    /* Load hashshags */
    $hashtag = !empty($mashsb_options['mashsharer_hashtag']) ? $mashsb_options['mashsharer_hashtag'] : '';
    $js_dir = MASHSB_PLUGIN_URL . 'assets/js/';
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = mashsbIsDebugMode() ? '' : '.min';
    //$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.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);
    !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, '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));
}
function arrNetworks($name, $url, $title)
{
    global $mashsb_options, $post;
    $singular = isset($mashsb_options['singular']) ? $singular = true : ($singular = false);
    if (function_exists('mashsuGetShortURL')) {
        mashsuGetShortURL() !== 0 ? $urltw = mashsuGetShortURL() : ($urltw = $url);
    } else {
        $urltw = $url;
    }
    function_exists('MASHOG') ? $image = MASHOG()->MASHOG_OG_Output->_add_image() : ($image = mashsb_get_image($post->ID));
    function_exists('MASHOG') ? $desc = MASHOG()->MASHOG_OG_Output->_get_description() : ($desc = urlencode(mashsb_get_excerpt_by_id($post->ID)));
    if (function_exists('MASHOG')) {
        $twittertitle = MASHOG()->MASHOG_OG_Output->_get_tw_title();
        $twittertitle = html_entity_decode($twittertitle, ENT_QUOTES, 'UTF-8');
        $twittertitle = urlencode($twittertitle);
        $twittertitle = str_replace('#', '%23', $twittertitle);
        $twittertitle = esc_html($twittertitle);
        empty($twittertitle) ? $twittertitle = $title : $twittertitle;
    } else {
        $twittertitle = $title;
    }
    !empty($mashsb_options['mashsharer_hashtag']) ? $via = '&via=' . $mashsb_options['mashsharer_hashtag'] : ($via = '');
    $networks = apply_filters('mashsb_array_networks', array('facebook' => 'http://www.facebook.com/sharer.php?u=' . $url, 'twitter' => 'https://twitter.com/intent/tweet?text=' . $twittertitle . $via . '&url=' . $urltw, 'subscribe' => '#', 'url' => $url, 'title' => $title));
    return isset($networks[$name]) ? $networks[$name] : '';
}