EA Share Count – Use Production URL

<?php
/**
* Production URL
* @author Bill Erickson
* @link http://www.billerickson.net/code/ea-share-count-use-production-url/
*
* @param string $url (optional), URL to convert to production.
* @return string $url, converted to production. Uses home_url() if no url provided
*
*/
function ea_production_url( $url = false ) {
$url = $url ? esc_url( $url ) : home_url();
$production = 'http://www.billerickson.net';
$url = str_replace( home_url(), $production, $url );
return esc_url( $url );
}
/**
* Use Production URL for Share Count API
* @author Bill Erickson
* @link http://www.billerickson.net/code/ea-share-count-use-production-url/
*
* @param array $params, API parameters used when fetching share counts
* @return array
*/
function ea_production_url_share_count_api( $params ) {
$params['url'] = ea_production_url( $params['url'] );
return $params;
}
add_filter( 'ea_share_count_api_params', 'ea_production_url_share_count_api' );
/**
* Use Production URL for Share Count link
* @author Bill Erickson
* @link http://www.billerickson.net/code/ea-share-count-use-production-url/
*
* @param array $link, elements of the link
* @return array
*/
function ea_production_url_share_count_link( $link ) {
$link['link'] = ea_production_url( $link['link'] );
return $link;
}
add_filter( 'ea_share_count_link', 'ea_production_url_share_count_link' );
view raw functions.php hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk