get_primary_color();
$primary_color_rgb = $this->hex2rgb( $primary_color, true );
$secondary_color = $this->get_secondary_color();
$secondary_color_rgb = $this->hex2rgb( $secondary_color, true );
ob_start();
?>
sanitize_codes( ob_get_contents() );
ob_end_clean();
wp_add_inline_style( 'aesblo-style', $custom_css );
}
/**
* Get header background image.
*
* @since 1.0.0
* @access private
*
* @return string
*/
function get_header_image() {
return get_header_image();
}
/**
* Get the primary color.
*
* @since 1.0.0
* @access private
*
* @return string
*/
private function get_primary_color() {
$mod = get_theme_mod( 'aesblo_customizer' );
return isset( $mod[ 'primary_color' ] ) ? $mod[ 'primary_color' ] : '#D90000';
}
/**
* Get the secondary color.
*
* @since 1.0.0
* @access private
*
* @return string
*/
private function get_secondary_color() {
$mod = get_theme_mod( 'aesblo_customizer' );
return isset( $mod[ 'secondary_color' ] ) ? $mod[ 'secondary_color' ] : '#04756F';
}
/**
* Get prev/next post thumbnail.
*
* @since 1.0.0
* @access private
*
* @return string
*/
private function get_post_nav_background() {
if ( ! is_single() ) {
return;
}
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
$css = '';
if ( is_attachment() && 'attachment' == $previous->post_type ) {
return;
}
$thumb = array();
if ( $previous && has_post_thumbnail( $previous->ID ) ) {
$prevthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $previous->ID ), 'post-thumbnail' );
$thumb['prev'] = esc_url( $prevthumb[0] );
}
if ( $next && has_post_thumbnail( $next->ID ) ) {
$nextthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $next->ID ), 'post-thumbnail' );
$thumb['next'] = esc_url( $nextthumb[0] );
}
return $thumb;
}
/**
* Sanitize cee codes.
*
* Remove break line, tab, extra whitespace.
*
* @since 1.0.0
* @access private
*
* @parm string $buffer
* @return striung
*/
private function sanitize_codes( $buffer ) {
$output = str_replace( array( '' ), '', $buffer );
$output = preg_replace( '/(\/\*)(.*)(\*\/)/', '', $output );
$output = preg_replace( '/[\s]+/', ' ', $output );
$output = trim( $output );
return $output;
}
/**
* Convert a hexa decimal color code to its RGB equivalent
*
* @since 1.0.0
* @access private
*
* @link http://us2.php.net/manual/en/function.hexdec.php#99478
*
* @param string $hexStr (hexadecimal color value)
* @param boolean $returnAsString (if set true, returns the value separated by the separator character. Otherwise returns associative array)
* @param string $seperator (to separate RGB values. Applicable only if second parameter is true.)
* @return array or string (depending on second parameter. Returns False if invalid hex color value)
*/
private function hex2rgb($hexStr, $returnAsString = false, $seperator = ',') {
$hexStr = preg_replace("/[^0-9A-Fa-f]/", '', $hexStr); // Gets a proper hex string
$rgbArray = array();
if (strlen($hexStr) == 6) { //If a proper hex code, convert using bitwise operation. No overhead... faster
$colorVal = hexdec($hexStr);
$rgbArray['red'] = 0xFF & ($colorVal >> 0x10);
$rgbArray['green'] = 0xFF & ($colorVal >> 0x8);
$rgbArray['blue'] = 0xFF & $colorVal;
} elseif (strlen($hexStr) == 3) { //if shorthand notation, need some string manipulations
$rgbArray['red'] = hexdec(str_repeat(substr($hexStr, 0, 1), 2));
$rgbArray['green'] = hexdec(str_repeat(substr($hexStr, 1, 1), 2));
$rgbArray['blue'] = hexdec(str_repeat(substr($hexStr, 2, 1), 2));
} else {
return false; //Invalid hex color code
}
return $returnAsString ? implode($seperator, $rgbArray) : $rgbArray; // returns the rgb string or the associative array
}
}
new Aesblo_Custom_Style;