function mashshareShortcodeShow($atts, $place) { global $wpdb, $mashsb_options, $post, $wp, $mashsb_custom_url, $mashsb_custom_text; //$mainurl = mashsb_get_url(); !empty($mashsb_options['sharecount_title']) ? $sharecount_title = $mashsb_options['sharecount_title'] : ($sharecount_title = __('SHARES', 'mashsb')); $sharecount = ''; extract(shortcode_atts(array('cache' => '3600', 'shares' => 'true', 'buttons' => 'true', 'align' => 'left', 'text' => '', 'url' => ''), $atts)); /* Load hashshag*/ if (!empty($mashsb_options['mashsharer_hashtag'])) { $via = '&via=' . $mashsb_options['mashsharer_hashtag']; } else { $via = ''; } // Define custom url var to share $mashsb_custom_url = empty($url) ? false : $url; // Define custom text to share $mashsb_custom_text = empty($text) ? false : $text; //$sharecount_url = empty($url) ? mashsb_get_url() : $url; if ($shares != 'false') { /* get totalshares of the current page with sharedcount.com */ $totalshares = getSharedcount($mashsb_custom_url); //$totalshares = getSharedcount($mainurl); //$totalshares = $mashsb_custom_url; /* Round total shares when enabled */ $roundenabled = isset($mashsb_options['mashsharer_round']) ? $mashsb_options['mashsharer_round'] : null; if ($roundenabled) { $totalshares = roundshares($totalshares); } $sharecount = '<div class="mashsb-count" style="float:' . $align . ';"><div class="counts">' . $totalshares . '</div><span class="mashsb-sharetext">' . $sharecount_title . '</span></div>'; /*If shortcode [mashshare shares="true" onlyshares="true"] * return shares and exit; */ if ($shares === "true" && $buttons === 'false') { return $sharecount; } if ($shares === "false" && $buttons === 'true') { $sharecount = ''; } } $return = '<aside class="mashsb-container">' . mashsb_content_above() . '<div class="mashsb-box">' . $sharecount . '<div class="mashsb-buttons">' . getNetworks() . '</div></div> <div style="clear:both;"></div>' . mashsb_subscribe_content() . mashsb_content_below() . '</aside> <!-- Share buttons made by mashshare.net - Version: ' . MASHSB_VERSION . '-->'; // Do not execute filter for excerpts //if(in_array('get_the_excerpt', $GLOBALS['wp_current_filter'])) apply_filters( 'mashsb_output_buttons', '' ); return apply_filters('mashsb_output_buttons', $return); }
function mashshareShortcodeShow($atts, $place) { global $wpdb, $mashsb_options, $post, $wp; $mainurl = mashsb_get_url(); !empty($mashsb_options['sharecount_title']) ? $sharecount_title = $mashsb_options['sharecount_title'] : ($sharecount_title = __('SHARES', 'mashsb')); function_exists('MASHOG') ? $title = MASHOG()->MASHOG_OG_Output->_get_title() : ($title = the_title_attribute('echo=0')); $title = html_entity_decode($title, ENT_QUOTES, 'UTF-8'); $title = urlencode($title); $title = str_replace('#', '%23', $title); $title = esc_html($title); $sharecount = ''; extract(shortcode_atts(array('cache' => '3600', 'shares' => 'true', 'buttons' => 'true', 'align' => 'left', 'url' => ''), $atts)); /* Load hashshag*/ if ($mashsb_options['mashsharer_hashtag'] != '') { $via = '&via=' . $mashsb_options['mashsharer_hashtag']; } else { $via = ''; } // Define url to share $url = !empty($url) ? $url : $mainurl; if ($shares != 'false') { /* get totalshares of the current page with sharedcount.com */ $totalshares = getSharedcount($mainurl); /* Round total shares when enabled */ $roundenabled = isset($mashsb_options['mashsharer_round']) ? $mashsb_options['mashsharer_round'] : null; if ($roundenabled) { $totalshares = roundshares($totalshares); } $sharecount = '<div class="mashsb-count" style="float:' . $align . ';"><div class="counts">' . $totalshares . '</div><span class="mashsb-sharetext">' . $sharecount_title . '</span></div>'; /*If shortcode [mashshare shares="true" onlyshares="true"] * return shares and exit; */ if ($shares === "true" && $buttons === 'false') { return $sharecount; } if ($shares === "false" && $buttons === 'true') { $sharecount = ''; } } $return = '<aside class="mashsb-container">' . mashsb_content_above() . '<div class="mashsb-box">' . $sharecount . '<div class="mashsb-buttons">' . getNetworks($url, $title) . '</div></div> <div style="clear:both;"></div>' . mashsb_subscribe_content() . mashsb_content_below() . '</aside> <!-- Share buttons made by mashshare.net - Version: ' . MASHSB_VERSION . '-->'; return apply_filters('mashsb_output_buttons', $return); }
public function widget($args, $instance) { // extract widget options extract($args); $title = apply_filters('widget_title', $instance['title']); $count = $instance['count']; $excerpt_length = !empty($instance['excerpt_length']) ? esc_attr($instance['excerpt_length']) : 0; $title_length = !empty($instance['title_length']) ? esc_attr($instance['title_length']) : 70; $image_size = !empty($instance['image_size']) ? esc_attr($instance['image_size']) : 0; $showShares = $instance['showShares']; $countLabel = $instance['countLabel']; $period = !empty($instance['period']) ? $instance['period'] : '7'; echo '<!-- MashShare Most Popular Widget //-->'; echo $before_widget; // Display the widget // Check if title is set if ($title) { echo $before_title . $title . $after_title; } // Check if text is set $args = array('posts_per_page' => $count, 'post_type' => 'post', 'post_status' => 'publish', 'meta_key' => 'mashsb_shares', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'date_query' => array(array('after' => $period . ' days ago', 'inclusive' => true))); //$wpq = new WP_Query( $args ); $wpq = $this->get_qry_from_cache($args); //var_dump($wpq); if ($wpq->have_posts()) { echo '<ul class="mashsb-share-widget">'; while ($wpq->have_posts()) { $wpq->the_post(); $postID = get_the_ID(); $image_url = wp_get_attachment_url(get_post_thumbnail_id($postID)); if (!empty($image_url)) { $css = 'background-image: url(' . wp_get_attachment_url(get_post_thumbnail_id($postID)) . ');background-size: cover;background-repeat: no-repeat;background-position: 50% 50%;width:' . $image_size . 'px;height:' . $image_size . 'px;'; $image = !empty($image_size) ? '<div class="mashsb-widget-img" style="' . $css . '"><a class="mashsb-widget-link" href="' . get_the_permalink() . '" style="display:block;width:' . $image_size . 'px;height:' . $image_size . 'px;"> </a></div>' : ''; } else { $css = 'display:block;width:' . $image_size . 'px;height:' . $image_size . 'px;'; $image = !empty($image_size) ? '<div class="mashsb-widget-img" style="' . $css . '"><a class="mashsb-widget-link" href="' . get_the_permalink() . '"> </a></div>' : ''; } $title_result = '<div class="mashsb-widget-post-title"><a class="mashsb-widget-link" href="' . get_the_permalink() . '">' . $this->limit_title(get_the_title(), $title_length) . '</a></div>'; $excerpt = !empty($excerpt_length) ? '<div class="mashsb-excerpt">' . $this->limit_excerpt(get_the_excerpt($postID), $excerpt_length) . '</div>' : ''; if ($showShares === 'true') { $shares = get_post_meta($postID, 'mashsb_shares', true) + getFakecount(); echo '<li>' . $image . $title_result . $excerpt . ' <span class="mashicon-share">' . roundshares($shares) . ' ' . $countLabel . '</span></li>'; } else { echo '<li>' . $image . $title_result . $excerpt . '</li>'; } } echo '</ul>'; } wp_reset_postdata(); echo $after_widget; echo '<!-- MashShare Most Popular Widget End //-->'; }
/** * 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); }