Created
May 19, 2016 18:15
-
-
Save jordanmaslyn/2f0892fb27c4bc4e8a8d8e841deeb5c2 to your computer and use it in GitHub Desktop.
Filter a Wordpress URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_site_url( $url ) { | |
if( is_admin() ) { | |
return $url; | |
} // you probably don't want this in admin side | |
$replaced = array("buzzed", "blogspot."); | |
foreach ($replaced as $replace) { | |
if (strpos( parse_url($url, PHP_URL_HOST), $replace ) !== false) { | |
return str_replace($replaced, "", $url); | |
} | |
} | |
return $url; | |
} | |
if (!is_admin() && !in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))) { | |
add_filter('bloginfo_url', 'custom_site_url'); | |
add_filter('theme_root_uri', 'custom_site_url'); | |
add_filter('stylesheet_directory_uri', 'custom_site_url'); | |
add_filter('template_directory_uri', 'custom_site_url'); | |
add_filter('script_loader_src', 'custom_site_url'); | |
add_filter('style_loader_src', 'custom_site_url'); | |
add_filter('plugins_url', 'custom_site_url'); | |
add_filter('the_permalink', 'custom_site_url'); | |
add_filter('wp_list_pages', 'custom_site_url'); | |
add_filter('wp_list_categories', 'custom_site_url'); | |
add_filter('wp_nav_menu', 'custom_site_url'); | |
add_filter('the_content_more_link', 'custom_site_url'); | |
add_filter('the_tags', 'custom_site_url'); | |
add_filter('get_pagenum_link', 'custom_site_url'); | |
add_filter('get_comment_link', 'custom_site_url'); | |
add_filter('month_link', 'custom_site_url'); | |
add_filter('day_link', 'custom_site_url'); | |
add_filter('year_link', 'custom_site_url'); | |
add_filter('tag_link', 'custom_site_url'); | |
add_filter('the_author_posts_link', 'custom_site_url'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment