/** * Return the current main url * * @return mixed string|bool current url or false */ function mashsb_get_main_url() { global $wp; $url = home_url(add_query_arg(array(), $wp->request)); if (!empty($url)) { return mashsb_sanitize_url($url); } }
function mashsb_get_url() { global $post; if (isset($post->ID)) { // The permalink for singular pages! // Do not check here for is_singular() (like e.g. the sharebar addon does.) // Need to check for post id because on category and archiv pages // we want the pageID within the loop instead the first appearing one. $url = mashsb_sanitize_url(get_permalink($post->ID)); } else { // The main URL $url = mashsb_get_main_url(); } return apply_filters('mashsb_get_url', $url); }