ID ) ) ) {
$blog_page = get_post( $page_for_posts );
}
}
return $blog_page;
}
/**
* @param string $location
* @param string $title
* @param string $anchor
* @param string $target
* @param string $class
* @param string $id
*
* @return string
*/
static function get_upgrade_hyperlink( $location = '', $title = '', $anchor = '', $target = '', $class = '', $id = 'aio-pro-update' ) {
$affiliate_id = '';
// call during plugins_loaded
$affiliate_id = apply_filters( 'aiosp_aff_id', $affiliate_id );
// build URL
$url = 'https://semperplugins.com/all-in-one-seo-pack-pro-version/';
if ( $location ) {
$url .= '?loc=' . $location;
}
if ( $affiliate_id ) {
$url .= "?ap_id=$affiliate_id";
}
// build hyperlink
$hyperlink = '$anchor";
return $hyperlink;
}
/**
* Gets the upgrade to Pro version URL.
*/
static function get_upgrade_url() {
// put build URL stuff in here
}
/**
* Check whether a url is relative and if it is, make it absolute.
*
* @param string $url URL to check.
*
* @return string
*/
static function absolutize_url( $url ) {
if ( 0 !== strpos( $url, 'http' ) && '/' !== $url ) {
if ( 0 === strpos( $url, '//' ) ) {
// for ///resource type urls.
$scheme = parse_url( home_url(), PHP_URL_SCHEME );
$url = $scheme . ':' . $url;
} else {
// for /resource type urls.
$url = home_url( $url );
}
}
return $url;
}
/**
* Check whether a url is relative (does not contain a . before the first /) or absolute and makes it a valid url.
*
* @param string $url URL to check.
*
* @return string
*/
static function make_url_valid_smartly( $url ) {
$scheme = parse_url( home_url(), PHP_URL_SCHEME );
if ( 0 !== strpos( $url, 'http' ) ) {
if ( 0 === strpos( $url, '//' ) ) {
// for ///resource type urls.
$url = $scheme . ':' . $url;
} elseif ( strpos( $url, '.' ) !== false && strpos( $url, '/' ) !== false && strpos( $url, '.' ) < strpos( $url, '/' ) ) {
// if the . comes before the first / then this is absolute.
$url = $scheme . '://' . $url;
} else {
// for /resource type urls.
$url = home_url( $url );
}
} else if ( strpos( $url, 'http://' ) === false ) {
if ( 0 === strpos( $url, 'http:/' ) ) {
$url = $scheme . '://' . str_replace( 'http:/', '', $url );
} else if ( 0 === strpos( $url, 'http:' ) ) {
$url = $scheme . '://' . str_replace( 'http:', '', $url );
}
}
return $url;
}
/**
* Check whether a url is valid.
*
* @param string $url URL to check.
*
* @return bool
*/
public static function is_url_valid( $url ) {
return filter_var( filter_var( $url, FILTER_SANITIZE_URL ), FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED ) !== false;
}
}