function postshare($Post) { ?> <a href="http://facebook.com/sharer.php?u=<?php echo posturl($Post); ?> " target="_blank"><i class="fa fa-facebook"></i></a> <a href="<?php echo twitter_link($Post->title, posturl($Post)); ?> " target="_blank"><i class="fa fa-twitter"></i></a> <!---<a href="http://facebook.com/sharer.php?u=<?php echo posturl($Post); ?> " target="_blank"><i class="fa fa-instagram"></i></a>!---> <a href="<?php echo pinterest_link(posturl($Post), IMAGE_ROOT . $Post->mainimage, $Post->title); ?> " target="_blank"><i class="fa fa-pinterest"></i></a> <?php }
function jd_shorten_link($url, $thisposttitle, $post_ID, $testmode = false) { if (WPT_DEBUG && function_exists('wpt_pro_exists')) { wpt_mail("Initial Link Data: #{$post_ID}", "{$url}, {$thisposttitle}, {$post_ID}, {$testmode}"); // DEBUG } // filter link before sending to shortener or adding analytics $url = apply_filters('wpt_shorten_link', $url, $post_ID); if ($testmode == false) { if (get_option('use-twitter-analytics') == 1 || get_option('use_dynamic_analytics') == 1) { if (get_option('use_dynamic_analytics') == '1') { $campaign_type = get_option('jd_dynamic_analytics'); if ($campaign_type == "post_category" && $testmode != 'link') { $category = get_the_category($post_ID); $campaign = sanitize_title($category[0]->cat_name); } else { if ($campaign_type == "post_ID") { $campaign = $post_ID; } else { if ($campaign_type == "post_title" && $testmode != 'link') { $post = get_post($post_ID); $campaign = sanitize_title($post->post_title); } else { if ($testmode != 'link') { $post = get_post($post_ID); $post_author = $post->post_author; $campaign = get_the_author_meta('user_login', $post_author); } else { $post_author = ''; $campaign = ''; } } } } } else { $campaign = get_option('twitter-analytics-campaign'); } if (strpos($url, "%3F") === FALSE && strpos($url, "?") === FALSE) { $ct = "?"; } else { $ct = "&"; } $medium = apply_filters('wpt_utm_medium', 'twitter'); $source = apply_filters('wpt_utm_source', 'twitter'); $ga = "utm_campaign={$campaign}&utm_medium={$medium}&utm_source={$source}"; $url .= $ct .= $ga; } $url = urldecode(trim($url)); // prevent double-encoding $encoded = urlencode($url); } else { $url = urldecode(trim($url)); // prevent double-encoding $encoded = urlencode($url); } // custom word setting $keyword_format = get_option('jd_keyword_format') == '1' ? $post_ID : false; $keyword_format = get_option('jd_keyword_format') == '2' ? get_post_meta($post_ID, '_yourls_keyword', true) : $keyword_format; $error = ''; // Generate and grab the short url switch (get_option('jd_shortener')) { case 0: case 1: case 3: $shrink = $url; break; case 4: if (function_exists('wp_get_shortlink')) { // wp_get_shortlink doesn't natively support custom post types; but don't return an error in that case. $shrink = $post_ID != false ? wp_get_shortlink($post_ID, 'post') : $url; } if (!$shrink) { $shrink = $url; } break; case 2: // updated to v3 3/31/2010 $bitlyapi = trim(get_option('bitlyapi')); $bitlylogin = trim(strtolower(get_option('bitlylogin'))); $decoded = jd_remote_json("https://api-ssl.bitly.com/v3/shorten?longUrl=" . $encoded . "&login="******"&apiKey=" . $bitlyapi . "&format=json"); if ($decoded) { if ($decoded['status_code'] != 200) { $shrink = $decoded; $error = $decoded['status_txt']; } else { $shrink = $decoded['data']['url']; } } else { $shrink = false; } if (!is_valid_url($shrink)) { $shrink = false; } break; case 5: // local YOURLS installation global $yourls_reserved_URL; define('YOURLS_INSTALLING', true); // Pretend we're installing YOURLS to bypass test for install or upgrade define('YOURLS_FLOOD_DELAY_SECONDS', 0); // Disable flood check $opath = get_option('yourlspath'); $ypath = str_replace('user', 'includes', $opath); if (file_exists(dirname($ypath) . '/load-yourls.php')) { // YOURLS 1.4+ require_once dirname($ypath) . '/load-yourls.php'; global $ydb; if (function_exists('yourls_add_new_link')) { $yourls_result = yourls_add_new_link($url, $keyword_format, $thisposttitle); } else { $yourls_result = $url; } } else { // YOURLS 1.3 if (file_exists(get_option('yourslpath'))) { require_once get_option('yourlspath'); $yourls_db = new wpdb(YOURLS_DB_USER, YOURLS_DB_PASS, YOURLS_DB_NAME, YOURLS_DB_HOST); $yourls_result = yourls_add_new_link($url, $keyword_format, $yourls_db); } } if ($yourls_result) { $shrink = $yourls_result['shorturl']; } else { $shrink = false; } break; case 6: // remote YOURLS installation $yourlslogin = trim(get_option('yourlslogin')); $yourlsapi = stripcslashes(get_option('yourlsapi')); $api_url = sprintf(get_option('yourlsurl') . '?username=%s&password=%s&url=%s&format=json&action=shorturl&keyword=%s', $yourlslogin, $yourlsapi, $encoded, $keyword_format); $json = jd_remote_json($api_url, false); if ($json) { $shrink = $json->shorturl; } else { $shrink = false; } break; case 7: $suprapi = trim(get_option('suprapi')); $suprlogin = trim(get_option('suprlogin')); if ($suprapi != '') { $decoded = jd_remote_json("http://su.pr/api/shorten?longUrl=" . $encoded . "&login="******"&apiKey=" . $suprapi); } else { $decoded = jd_remote_json("http://su.pr/api/shorten?longUrl=" . $encoded); } if ($decoded['statusCode'] == 'OK') { $page = str_replace("&", "&", urldecode($url)); $shrink = $decoded['results'][$page]['shortUrl']; $error = $decoded['errorMessage']; } else { $shrink = false; $error = $decoded['errorMessage']; } if (!is_valid_url($shrink)) { $shrink = false; } break; case 8: // Goo.gl $target = "https://www.googleapis.com/urlshortener/v1/url?key=AIzaSyBSnqQOg3vX1gwR7y2l-40yEG9SZiaYPUQ"; $body = "{'longUrl':'{$url}'}"; //$body = json_encode($data); $json = jd_fetch_url($target, 'POST', $body, 'Content-Type: application/json'); $decoded = json_decode($json); //$url = $decoded['id']; $shrink = $decoded->id; if (!is_valid_url($shrink)) { $shrink = false; } break; case 9: // Twitter Friendly Links $shrink = $url; if (function_exists('twitter_link')) { // use twitter_link if available $shrink = twitter_link($post_ID); } break; case 10: // jotURL //jotURL, added: 2013-04-10 $joturlapi = trim(get_option('joturlapi')); $joturllogin = trim(get_option('joturllogin')); $joturl_longurl_params = trim(get_option('joturl_longurl_params')); if ($joturl_longurl_params != '') { if (strpos($url, "%3F") === FALSE && strpos($url, "?") === FALSE) { $ct = "?"; } else { $ct = "&"; } $url .= $ct . $joturl_longurl_params; $encoded = urlencode(urldecode(trim($url))); // prevent double-encoding } //\jotURL $decoded = jd_fetch_url("https://api.joturl.com/a/v1/shorten?url=" . $encoded . "&login="******"&key=" . $joturlapi . "&format=plain"); if ($decoded !== false) { $shrink = $decoded; //jotURL, added: 2013-04-10 $joturl_shorturl_params = trim(get_option('joturl_shorturl_params')); if ($joturl_shorturl_params != '') { if (strpos($shrink, "%3F") === FALSE && strpos($shrink, "?") === FALSE) { $ct = "?"; } else { $ct = "&"; } $shrink .= $ct . $joturl_shorturl_params; } //\jotURL } else { $error = $decoded; $shrink = false; } if (!is_valid_url($shrink)) { $shrink = false; } break; update_option('wpt_shortener_status', "{$shrink} : {$error}"); } if (!$testmode) { if ($shrink === false || filter_var($shrink, FILTER_VALIDATE_URL) === false) { update_option('wp_url_failure', '1'); $shrink = urldecode($url); } else { update_option('wp_url_failure', '0'); } } wpt_store_url($post_ID, $shrink); return $shrink; }
<article class="col-xs-9"> <h1 class="page-title"><?php echo $Published->title; ?> </h1> <h3 class="page-subtitle"><?php echo $Published->subtitle; ?> </h3> <div class="page-meta"> <a href="http://facebook.com/sharer.php?u=<?php echo pageurl($Published); ?> " target="_blank"><i class="fa fa-facebook"></i></a> <a href="<?php echo twitter_link($Published->title, pageurl($Published)); ?> " target="_blank"><i class="fa fa-twitter"></i></a> </div> <div class="page-content"> <?php echo $Published->data; ?> </div> <p class="page-footer">Last Updated <?php echo date('d/m/Y', $Published->updated); ?> </p> </article> <div class="col-xs-3 other-pages"> <?php
function revCanonical() { if (is_page() || is_single()) { echo '<link rev="canonical" type="text/html" href="' . twitter_link() . '" />' . "\n"; } }