ID;
if ( is_home() && ! is_front_page() ) {
// Retrive the ID of the page
$postId = get_option( 'page_for_posts' );
}
$post_option = $post ? fw_get_db_post_option( $postId, $optionName, $default_value = null ) : false;
}
if ( $post_option ) {
return $post_option;
} else {
return fw_get_db_settings_option( $optionName );
}
}
}
if ( ! function_exists( 'bluemed_get_comments_title ' ) ) {
function bluemed_get_comments_title() {
if ( ! function_exists( 'fw_get_db_settings_option' ) ) {
return null;
} // Check for Unyson
return sprintf( // WPCS: XSS OK.
esc_html( _nx( 'One thought on “%2$s”', '%1$s thoughts on “%2$s”', get_comments_number(), 'comments title', 'bluemed' ) ),
number_format_i18n( get_comments_number() ),
'' . get_the_title() . ''
);
}
}
if ( ! function_exists( 'bluemed_get_page_title' ) ) {
/**
* Used by the subheader to retrieve the correct page title to display.
*
* @return string The page title to display
*/
function bluemed_get_page_title() {
if ( bluemed_get_option( 'subheaderDisplayTitle' ) ) {
return bluemed_get_option( 'subheaderDisplayTitle' );
}
if ( is_home() || is_single()) {
if ( get_option( 'page_for_posts', true ) ) {
return get_the_title( get_option( 'page_for_posts', true ) );
} else {
return esc_html__( 'Latest Posts', "bluemed" );
}
} elseif ( is_archive() ) {
return get_the_archive_title();
} elseif ( is_search() ) {
return sprintf( esc_html__( 'Search Results for %s', "bluemed" ), get_search_query() );
} elseif ( is_404() ) {
return esc_html__( 'Not Found', "bluemed" );
} else {
return get_the_title();
}
}
}
if ( ! function_exists( 'bluemed_get_page_subtitle' ) ) {
function bluemed_get_page_subtitle() {
if (is_home() || is_single()) {
return bluemed_get_option( 'blogSubtitle' );
} elseif (is_archive()) {
return bluemed_get_option( 'archiveSubtitle' );
} elseif (is_search()) {
return bluemed_get_option( 'searchResultsSubtitle' );
} elseif (is_404()) {
return bluemed_get_option( 'pageNotFoundSubtitle' );
} elseif ( bluemed_get_option( 'subheaderSubtitle' ) ) {
return bluemed_get_option( 'subheaderSubtitle' );
} else {
return bluemed_get_option( 'subheaderDefaultSubtitle' );
}
}
}
if( !function_exists( 'bluemed_get_subheader_cta_label' )) {
function bluemed_get_subheader_cta_label() {
if (is_home()) {
return bluemed_get_option( 'subheaderBlogButtonLabel' );
} elseif (is_archive()) {
return bluemed_get_option( 'subheaderArchiveButtonLabel' );
} elseif (is_search()) {
return bluemed_get_option( 'subheaderSearchResultsButtonLabel' );
} elseif (is_404()) {
return bluemed_get_option( 'subheader404ButtonLabel' );
} elseif ( bluemed_get_option( 'subheaderButtonLabel' ) ) {
return bluemed_get_option( 'subheaderButtonLabel' );
} else {
return bluemed_get_option( 'subheaderDefaultButtonLabel' );
}
}
}
if ( ! function_exists( 'bluemed_get_subheader_cta_url' ) ) {
function bluemed_get_subheader_cta_url() {
if (is_home()) {
return bluemed_get_option( 'subheaderBlogButtonUrl' );
} elseif (is_archive()) {
return bluemed_get_option( 'subheaderArchiveButtonUrl' );
} elseif (is_search()) {
return bluemed_get_option( 'subheaderSearchResultsButtonUrl' );
} elseif (is_404()) {
return bluemed_get_option( 'subheader404ButtonUrl' );
} elseif ( bluemed_get_option( 'subheaderButtonUrl' ) ) {
return bluemed_get_option( 'subheaderButtonUrl' );
} else {
return bluemed_get_option( 'subheaderDefaultButtonUrl' );
}
}
}
if( !function_exists( 'bluemed_post_thumbnail ')) {
function bluemed_post_thumbnail( $size = 'large', $class = '') {
if(function_exists('get_the_image')) {
// Use Get The Image plugin if it exists
$defaultImage = bluemed_get_option('defaultPostImage');
$defaultImageUrl = $defaultImage && array_key_exists('url', $defaultImage) ? $defaultImage['url'] : '';
get_the_image(array(
'size' => $size,
'image_class' => $class,
'default' => $defaultImageUrl,
'itemprop' => ''
));
} else {
// Otherwise, use default WP thumbnail functionality
the_post_thumbnail($size, array('class' => $class, 'itemprop' => ''));
}
}
}
if(!function_exists('bluemed_post_thumbnail_url')) {
function bluemed_post_thumbnail_url($size = 'large') {
global $post;
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID), $size );
if(strlen($url) > 0) {
echo $url;
} else {
$defaultImage = bluemed_get_option('defaultPostImage');
$defaultImageUrl = $defaultImage && array_key_exists('url', $defaultImage) ? $defaultImage['url'] : '';
echo $defaultImageUrl;
}
}
}
if(!function_exists("bluemed_get_avatar_url")) {
function bluemed_get_author_avatar_url($size){
$get_avatar = get_avatar(get_the_author_meta('ID'), $size );
preg_match("/src='(.*?)'/i", $get_avatar, $matches);
return $matches[1];
}
}
if(!function_exists("bluemed_previous_posts_url")) {
function bluemed_previous_posts_url() {
$previous_link = get_previous_posts_link();
preg_match('/]*href="([^"]*)"[^>]*>.*<\/a>/', $previous_link, $matches);
return $matches[1];
}
}
if(!function_exists("bluemed_newer_posts_url")) {
function bluemed_newer_posts_url() {
$link = get_next_posts_link();
preg_match('/]*href="([^"]*)"[^>]*>.*<\/a>/', $link, $matches);
return $matches[1];
}
}
if(!function_exists("bluemed_get_logo_element")) {
function bluemed_get_upload_url($option_key) {
$value = bluemed_get_option($option_key);
if(isset($value['url'])) {
return $value['url'];
} else {
return '';
}
}
}
if(!function_exists('bluemed_rgbToHsl')) {
function bluemed_rgbToHsl( $r, $g, $b ) {
$oldR = $r;
$oldG = $g;
$oldB = $b;
$r /= 255;
$g /= 255;
$b /= 255;
$max = max( $r, $g, $b );
$min = min( $r, $g, $b );
$h;
$s;
$l = ( $max + $min ) / 2;
$d = $max - $min;
if ( $d == 0 ) {
$h = $s = 0; // achromatic
} else {
$s = $d / ( 1 - abs( 2 * $l - 1 ) );
switch ( $max ) {
case $r:
$h = 60 * fmod( ( ( $g - $b ) / $d ), 6 );
if ( $b > $g ) {
$h += 360;
}
break;
case $g:
$h = 60 * ( ( $b - $r ) / $d + 2 );
break;
case $b:
$h = 60 * ( ( $r - $g ) / $d + 4 );
break;
}
}
return array( round( $h, 2 ), round( $s, 2 ), round( $l, 2 ) );
}
}
if(!function_exists('bluemed_hslToRgb')) {
function bluemed_hslToRgb( $h, $s, $l ) {
$r;
$g;
$b;
$c = ( 1 - abs( 2 * $l - 1 ) ) * $s;
$x = $c * ( 1 - abs( fmod( ( $h / 60 ), 2 ) - 1 ) );
$m = $l - ( $c / 2 );
if ( $h < 60 ) {
$r = $c;
$g = $x;
$b = 0;
} else if ( $h < 120 ) {
$r = $x;
$g = $c;
$b = 0;
} else if ( $h < 180 ) {
$r = 0;
$g = $c;
$b = $x;
} else if ( $h < 240 ) {
$r = 0;
$g = $x;
$b = $c;
} else if ( $h < 300 ) {
$r = $x;
$g = 0;
$b = $c;
} else {
$r = $c;
$g = 0;
$b = $x;
}
$r = ( $r + $m ) * 255;
$g = ( $g + $m ) * 255;
$b = ( $b + $m ) * 255;
return array( floor( $r ), floor( $g ), floor( $b ) );
}
}
if(!function_exists('bluemed_hex2rgb')) {
function bluemed_hex2rgb( $hex ) {
$hex = str_replace( "#", "", $hex );
if ( strlen( $hex ) == 3 ) {
$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
$g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
$b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
} else {
$r = hexdec( substr( $hex, 0, 2 ) );
$g = hexdec( substr( $hex, 2, 2 ) );
$b = hexdec( substr( $hex, 4, 2 ) );
}
$rgb = array( $r, $g, $b );
//return implode(",", $rgb); // returns the rgb values separated by commas
return $rgb; // returns an array with the rgb values
}
}
if(!function_exists('bluemed_rgb2hex')) {
function bluemed_rgb2hex( $rgb ) {
$hex = "#";
$hex .= str_pad( dechex( $rgb[0] ), 2, "0", STR_PAD_LEFT );
$hex .= str_pad( dechex( $rgb[1] ), 2, "0", STR_PAD_LEFT );
$hex .= str_pad( dechex( $rgb[2] ), 2, "0", STR_PAD_LEFT );
return $hex; // returns the hex value including the number sign (#)
}
}
if(!function_exists('bluemed_darken_color')) {
function bluemed_darken_color($hex_color, $percent) {
// convert hex to rgb
$rgb_color = bluemed_hex2rgb($hex_color);
// convert rgb to hsl
$hsl_color = bluemed_rgbToHsl($rgb_color[0], $rgb_color[1], $rgb_color[2]);
// darken hsl
$hsl_color[2] = $hsl_color[2] - $percent/100;
// convert hsl to rgb
$new_rgb_color = bluemed_hslToRgb($hsl_color[0], $hsl_color[1], $hsl_color[2]);
// convert rgb to hex
$new_hex_color = bluemed_rgb2hex($new_rgb_color);
// return rgb
return $new_hex_color;
}
}