コード例 #1
0
ファイル: scripts.php プロジェクト: a-i-ko93/ipl-foodblog
/**
 * 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));
}
コード例 #2
0
ファイル: scripts.php プロジェクト: netmagik/netmagik
/**
 * 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));
}
コード例 #3
0
function mashsb_hide_shares()
{
    global $mashsb_options, $post, $wp;
    $url = get_permalink(isset($post->ID));
    $sharelimit = isset($mashsb_options['hide_sharecount']) ? $mashsb_options['hide_sharecount'] : 0;
    if ($sharelimit > 0) {
        //mashdebug()->error( "getsharedcount: " . getSharedcount($url) . "sharelimit " . $sharelimit);
        if (getSharedcount($url) > $sharelimit) {
            return false;
        } else {
            return true;
        }
    }
    return false;
}
コード例 #4
0
/**
 * Render the sharecount template
 * 
 * @param string $customurl default empty
 * @param string alignment default left
 * @return string html
 */
function mashsb_render_sharecounts($customurl = '', $align = 'left')
{
    global $mashsb_options;
    if (isset($mashsb_options['disable_sharecount']) || !mashsb_curl_installed() || !mashsb_is_enabled_permalinks()) {
        return;
    }
    $url = empty($customurl) ? mashsb_get_url() : $customurl;
    $sharetitle = isset($mashsb_options['sharecount_title']) ? $mashsb_options['sharecount_title'] : __('SHARES', 'mashsb');
    $shares = getSharedcount($url);
    $sharecount = isset($mashsb_options['mashsharer_round']) ? roundshares($shares) : $shares;
    // do not show shares after x shares
    if (mashsb_hide_shares($shares)) {
        return;
    }
    // Get class names for buttons size
    $class_size = isset($mashsb_options['buttons_size']) ? ' ' . $mashsb_options['buttons_size'] : '';
    $html = '<div class="mashsb-count' . $class_size . '" style="float:' . $align . ';"><div class="counts mashsbcount">' . $sharecount . '</div><span class="mashsb-sharetext">' . $sharetitle . '</span></div>';
    return apply_filters('mashsb_share_count', $html);
}