' . esc_html__( 'Read more', 'absolutte' ) . ' ';
}
} // end function_exists
add_filter( 'the_content_more_link', 'absolutte_new_content_more' );
/**
* Convert HEX colors to RGB
*/
function absolutte_hex2rgb( $colour ) {
$colour = str_replace( "#", "", $colour );
if ( strlen( $colour ) == 6 ) {
list( $r, $g, $b ) = array( $colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5] );
} elseif ( strlen( $colour ) == 3 ) {
list( $r, $g, $b ) = array( $colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2] );
} else {
return false;
}
$r = hexdec( $r );
$g = hexdec( $g );
$b = hexdec( $b );
return array( 'red' => $r, 'green' => $g, 'blue' => $b );
}
/**
* Avoid undefined functions if Meta Box is not activated
*
* @return bool
*/
if ( ! function_exists( 'rwmb_meta' ) ) {
function rwmb_meta( $key, $args = '', $post_id = null ) {
return false;
}
}
/**
* Display Portfolio or Post navigation
*
* @return html
*/
if ( ! function_exists( 'absolutte_post_navigation' ) ) {
function absolutte_post_navigation() {
$post_nav_bck = '';
$post_nav_bck_next = '';
$prev_post = get_previous_post();
if ( ! empty( $prev_post ) ):
$portfolio_image = wp_get_attachment_image_src( get_post_thumbnail_id( $prev_post->ID ), 'absolutte_portfolio' );
if ( ! empty( $portfolio_image ) ) {
$post_nav_bck = ' style="background-image: url(' . esc_url( $portfolio_image[0] ) . ');"';
}
endif;
$next_post = get_next_post();
if ( ! empty( $next_post ) ):
$portfolio_image = wp_get_attachment_image_src( get_post_thumbnail_id( $next_post->ID ), 'absolutte_portfolio' );
if ( ! empty( $portfolio_image ) ) {
$post_nav_bck_next = ' style="background-image: url(' . esc_url( $portfolio_image[0] ) . ');"';
}
endif;
if ( ! empty( $prev_post ) || ! empty( $next_post ) ):
?>
1 ) ? $darker : 1;
list( $R16, $G16, $B16 ) = str_split( $rgb, 2 );
$R = sprintf( "%02X", floor( hexdec( $R16 ) / $darker ) );
$G = sprintf( "%02X", floor( hexdec( $G16 ) / $darker ) );
$B = sprintf( "%02X", floor( hexdec( $B16 ) / $darker ) );
return $hash . $R . $G . $B;
}
/**
* Return CSS class for #content
*
* @return bool
*/
if ( ! function_exists( 'absolutte_content_css_class' ) ) {
function absolutte_content_css_class() {
if ( is_page_template( 'template-full-width.php' ) ) {
return '';
}
if ( is_page_template( 'template-narrow.php' ) ) {
return 'col-md-8 col-md-push-2';
}
if ( is_page_template( 'template-fullscreen.php' ) ) {
return '';
}
if ( absolutte_is_portfolio_type( get_post_type() ) ) {
return 'col-md-8 col-md-push-2';
}
$absolutte_site_layout = absolutte_get_theme_mod( 'absolutte_site_layout', 'default' );
switch ( $absolutte_site_layout ) {
case 'default':
if ( is_active_sidebar( 'sidebar-1' ) && ! is_singular( array( 'product' ) ) ) {
return 'col-md-8';
} else {
return 'col-md-12';
}
break;
case 'sidenav':
if ( is_active_sidebar( 'sidebar-1' ) && ! is_singular( array( 'product' ) ) ) {
return 'col-md-6 col-md-push-2';
} else {
return 'col-md-8 col-md-push-2';
}
break;
default:
return 'col-md-8 col-md-push-2';
break;
}
}
}
/**
* Return CSS class for #footer
*
* @return bool
*/
if ( ! function_exists( 'absolutte_footer_css_class' ) ) {
function absolutte_footer_css_class() {
$absolutte_site_layout = get_theme_mod( 'absolutte_site_layout', 'default' );
if ( isset( $_GET['site_layout'] ) ) {
$absolutte_site_layout = sanitize_text_field( wp_unslash( $_GET['site_layout'] ) );
}
switch ( $absolutte_site_layout ) {
case 'default':
return 'col-md-8 col-md-push-2';
break;
case 'sidenav':
return 'col-md-12';
break;
default:
return 'col-md-8 col-md-push-2';
break;
}
}
}
/**
* Return CSS class for Container
*
* @return bool
*/
if ( ! function_exists( 'absolutte_container_css_class' ) ) {
function absolutte_container_css_class() {
$absolutte_site_layout = get_theme_mod( 'absolutte_site_layout', 'default' );
if ( isset( $_GET['site_layout'] ) ) {
$absolutte_site_layout = sanitize_text_field( wp_unslash( $_GET['site_layout'] ) );
}
//Default
$container_css_class = 'container';
if ( is_page_template( 'template-full-width.php' ) ) {
$container_css_class = '';
} elseif ( ! is_singular( array( 'product' ) ) ) {
if ( 'default' == $absolutte_site_layout ) {
$absolutte_shop_page_layout = get_theme_mod( 'absolutte_shop_page_layout', 'shop-narrow' );
if ( isset( $_GET['shop_page_layout'] ) ) {
$absolutte_shop_page_layout = sanitize_text_field( wp_unslash( $_GET['shop_page_layout'] ) );
}
//If it is Shop or Shop Archive page, show as full width.
if ( function_exists( 'is_shop' ) ) {
if ( ( is_shop() || is_product_category() ) && 'shop-fullwidth' == $absolutte_shop_page_layout ) {
$container_css_class = 'container-fluid';
}
}
} elseif ( 'sidenav' == $absolutte_site_layout ) {
$container_css_class = 'container-fluid';
}
}
if ( is_page_template( 'template-fullscreen.php' ) ) {
$container_css_class = '';
}
return $container_css_class;
}
}
/**
* Return CSS class for Main
*
* @return bool
*/
if ( ! function_exists( 'absolutte_main_css_class' ) ) {
function absolutte_main_css_class() {
//Default
$main_css_class = 'row';
if ( is_page_template( 'template-fullscreen.php' ) ) {
$main_css_class = '';
} elseif ( is_page_template( 'template-full-width.php' ) ) {
$main_css_class = '';
}
return $main_css_class;
}
}
/**
* Return SVG markup.
*
* @param array $args {
* Parameters needed to display an SVG.
*
* @type string $icon Required SVG icon filename.
* @type string $title Optional SVG title.
* @type string $desc Optional SVG description.
* }
* @return string SVG markup.
*/
function absolutte_get_svg( $args = array() ) {
// Make sure $args are an array.
if ( empty( $args ) ) {
return __( 'Please define default parameters in the form of an array.', 'absolutte' );
}
// Define an icon.
if ( false === array_key_exists( 'icon', $args ) ) {
return __( 'Please define an SVG icon filename.', 'absolutte' );
}
// Set defaults.
$defaults = array(
'icon' => '',
'title' => '',
'desc' => '',
'fallback' => false,
);
// Parse args.
$args = wp_parse_args( $args, $defaults );
// Set aria hidden.
$aria_hidden = ' aria-hidden="true"';
// Set ARIA.
$aria_labelledby = '';
if ( $args['title'] ) {
$aria_hidden = '';
$unique_id = uniqid();
$aria_labelledby = ' aria-labelledby="title-' . $unique_id . '"';
if ( $args['desc'] ) {
$aria_labelledby = ' aria-labelledby="title-' . $unique_id . ' desc-' . $unique_id . '"';
}
}
// Begin SVG markup.
$svg = '';
return $svg;
}
/**
* Add dropdown icon if menu item has children.
*
* @param string $title The menu item's title.
* @param object $item The current menu item.
* @param array $args An array of wp_nav_menu() arguments.
* @param int $depth Depth of menu item. Used for padding.
* @return string $title The menu item's title with dropdown icon.
*/
function absolutte_dropdown_icon_to_menu_link( $title, $item, $args, $depth ) {
if ( 'primary' === $args->theme_location ) {
foreach ( $item->classes as $value ) {
if ( 'menu-item-has-children' === $value || 'page_item_has_children' === $value ) {
$title = $title . '';
}
}
}
return $title;
}
add_filter( 'nav_menu_item_title', 'absolutte_dropdown_icon_to_menu_link', 10, 4 );
/**
* Get a theme_mod option and replaces if existe the value on the URL as argument
* For demos
*
* @param string $option theme_mod option.
* @param string $default value .
*/
function absolutte_get_theme_mod( $option, $default ) {
$get_arg = str_replace( 'absolutte_', '', $option );
$absolutte_option = get_theme_mod( $option, $default );
if ( isset( $_GET[$get_arg] ) ) {
$absolutte_option = sanitize_text_field( wp_unslash( $_GET[$get_arg] ) );
}
return $absolutte_option;
}
/**
* Check if the post type is a Portfolio post type
*
* @return bool
*/
if ( ! function_exists( 'absolutte_is_portfolio_type' ) ) {
function absolutte_is_portfolio_type( $post_type ) {
$absolutte_portfolios_post_types = absolutte_get_portfolios_slug();
if ( ! is_wp_error( $absolutte_portfolios_post_types ) ) {
if ( in_array( $post_type, $absolutte_portfolios_post_types ) ):
return true;
else:
return false;
endif;
} else {
return false;
}
}
}
/**
* Return only slug from all portfolios CPT
*
* @return array
*/
function absolutte_get_portfolios_slug() {
if ( class_exists( 'Multiple_Portfolios' ) ) {
$absolutte_portfolio_types = Multiple_Portfolios::get_post_types();
$absolutte_portfolio_types_slugs = array();
foreach ( $absolutte_portfolio_types as $portfolio ) {
$absolutte_portfolio_types_slugs[] = $portfolio['slug'];
}
return $absolutte_portfolio_types_slugs;
} else {
return new WP_Error( 'plugin_missing', esc_html__( 'Multiple Portfolios plugin not installed', 'absolutte' ) );
}
}
/**
* Add a pingback url auto-discovery header for single posts, pages, or attachments.
*/
function absolutte_pingback_header() {
if ( is_singular() && pings_open() ) {
echo '
';
}
}
add_action( 'wp_head', 'absolutte_pingback_header' );