/home/fortodpl/forhairstylesinspo.com/wp-content/themes/birch-trellis
Edit: /home/fortodpl/forhairstylesinspo.com/wp-content/themes/birch-trellis/functions.php (15717B)
'Birch',
'child_slug' => 'birch-trellis',
'child_version' => wp_get_theme()->get( 'Version' ),
'child_css' => get_stylesheet_directory_uri() . '/assets/dist/css/main.' . wp_get_theme()->get( 'Version' ) . '.css',
'theme_style' => null,
'menus' => array(
'primary' => __( 'Primary Navigation', 'mediavine' ),
),
'default_image_ratio' => array(
'featured' => 'mv_trellis_1x1',
'excerpt' => 'mv_trellis_1x1',
'single' => 'mv_trellis_1x1',
),
)
);
add_theme_support( 'mv_trellis_background_accent_color' );
add_theme_support( 'mv_trellis_headings_control' );
add_theme_support( 'mvt_hooks', [ 'mvt_content_header_after' ] );
add_theme_support( 'mv_trellis_hide_page_title' );
}
add_action( 'mv_trellis_parent_loaded', 'mv_trellis_child_set_options', 1 );
/**
* Disable base Trellis CSS
*/
add_filter( 'mv_trellis_enqueue_main_style', '__return_false' );
/**
* pagination specific to this theme
*/
function mv_birch_the_posts_pagination() {
?>
12,
'Comfortable' => 24,
);
}
add_filter( 'mv_trellis_base_gutters', 'mv_birch_set_base_gutters' );
/**
* Change the gutter size
*
* @param array $css_vars custom css vars from Trellis.
*
* @return mixed
*/
function mv_birch_adjust_large_gutter_value( $css_vars ) {
if ( empty( $css_vars['gutter'] ) ) {
return $css_vars;
}
$gutter = $css_vars['gutter'];
settype( $gutter, 'float' );
$css_vars['gutter-large'] = $gutter * 2 . 'px';
return $css_vars;
}
add_filter( 'mv_trellis_css_vars', 'mv_birch_adjust_large_gutter_value' );
/**
* Use local model of footer .footer-copy
*
* @param array $local_model local model values to be filtered.
*
* @return mixed
*/
function mv_birch_adjust_local_model( $local_model ) {
$local_model['footer_selector'] = 'footer .footer-copy';
return $local_model;
}
add_filter( 'mv_trellis_local_script_model', 'mv_birch_adjust_local_model' );
/**
* Add trellis settings that are specific to Birch
* @param array $theme_settings Trellis Settings to be filtered.
*
* @return array
*/
function mv_birch_add_variation_support( array $theme_settings ) {
$birch_style = [
[
'slug' => 'birch_variation',
'value' => true,
'group' => 'display',
'order' => 1,
'data' => [
'type' => 'select',
'label' => __( 'Select Birch variation', 'mediavine' ),
'instructions' => __( 'This will toggle between a square or round design.', 'mediavine' ),
'default' => __( 'Square Design', 'mediavine' ),
'theme_default' => 'Square Design',
'options' => [
[
'label' => __( 'Square design', 'mediavine' ),
'value' => 'square_design',
],
[
'label' => __( 'Round design', 'mediavine' ),
'value' => 'round_design',
],
],
],
],
[
'slug' => 'birch_menu_width',
'value' => true,
'group' => 'display',
'order' => 2,
'data' => [
'type' => 'select',
'label' => __( 'Select the header width', 'mediavine' ),
'instructions' => __( 'This will adjust the width of the header at the top of the page.', 'mediavine' ),
'default' => __( 'Wide Header', 'mediavine' ),
'theme_default' => 'Wide Header',
'options' => [
[
'label' => __( 'Full Width Header', 'mediavine' ),
'value' => 'birch-header-wide',
],
[
'label' => __( 'Regular Header', 'mediavine' ),
'value' => 'birch-header-regular',
],
[
'label' => __( 'Narrow Header', 'mediavine' ),
'value' => 'birch-header-narrow',
],
],
],
],
];
$theme_settings = array_merge( $theme_settings, $birch_style );
return $theme_settings;
}
add_filter( 'mv_trellis_settings', 'mv_birch_add_variation_support' );
/**
* Add a body class for the birch variation for square (default) or round design
*
* @param array $classes Classes to be filtered.
*
* @return mixed
*/
function mv_birch_add_variation_class( $classes ) {
$birch_variation = \Mediavine\Trellis\Settings::read_value( 'birch_variation' );
// exit early if the setting is empty
if ( empty( $birch_variation ) ) {
return $classes;
}
$classes[] = $birch_variation;
return $classes;
}
add_filter( 'body_class', 'mv_birch_add_variation_class');
/**
* Adds a body class based on the image orientation setting in Trellis settings
*
*
* @param array $classes Classes to be filtered.
*
* @return mixed
*
* *
*/
function mv_birch_trellis_image_class( $classes ) {
// get the setting value, use false if the setting isn't set
$featured_image_size = \Mediavine\Trellis\Settings::read_value( 'featured_image_size', false );
// exit early if the setting is empty
if ( empty( $featured_image_size ) ) {
return $classes;
}
$classes[] = $featured_image_size;
return $classes;
}
add_filter( 'body_class', 'mv_birch_trellis_image_class');
/**
* Add a body class for the birch variation for header width
*
* @param array $classes Classes to be filtered.
*
* @return mixed
*/
function mv_birch_add_header_width_setting( $classes ) {
$birch_variation = \Mediavine\Trellis\Settings::read_value( 'birch_menu_width' );
// exit early if the setting is empty
if ( empty( $birch_variation ) ) {
return $classes;
}
$classes[] = $birch_variation;
return $classes;
}
add_filter( 'body_class', 'mv_birch_add_header_width_setting');
/**
* Add birch_variation & birch_menu_width setting to the License Required Settings
*
* @param array $lr_settings The license required setting.
*
* @return array $lr_settings
*/
function mv_birch_add_to_license_required( $lr_settings ) {
$lr_settings[] = 'birch_variation';
$lr_settings[] = 'birch_menu_width';
return $lr_settings;
}
add_filter('mv_trellis_license_required_settings', 'mv_birch_add_to_license_required');
/**
* Adjust the Grow styles from Trellis core
*
* @param string $grow_sidebar_styles The inline style applied when the Grow sidebar present.
*
* @return string
*/
function mv_birch_update_grow_styles( $grow_sidebar_styles ) {
$sidebar_margin_css = '';
$grow_sidebar_margin_space = 0;
$padding_side = '';
$dpsp_sidebar_settings = get_option( 'dpsp_location_sidebar', 'not_set' );
$sidebar_location = ( ! empty($dpsp_sidebar_settings['display']['position']) ) ? $dpsp_sidebar_settings['display']['position'] : null;
$button_size = ( ! empty($dpsp_sidebar_settings['display']['size']) ) ? $dpsp_sidebar_settings['display']['size'] : null;
$sidebar_break_with_grow = 0;
$max_width_apply_grow_styles = 0;
//Check the button size so we know how much margin to add
//it defaults to the biggest margin
if ( 'medium' === strtolower( $button_size ) ) {
$grow_sidebar_margin_space = 65;
} elseif ( 'small' === strtolower( $button_size ) ) {
$grow_sidebar_margin_space = 60;
} else {
$grow_sidebar_margin_space = 70;
}
//Check which side the button is on so we can apply to the correct side
if ( 'left' === strtolower( $sidebar_location ) ) {
$sidebar_margin_css = 'margin-left:' . $grow_sidebar_margin_space . 'px;';
$padding_side = 'padding-left';
} elseif ( 'right' === strtolower( $sidebar_location ) ) {
$sidebar_margin_css = 'margin-right:' . $grow_sidebar_margin_space . 'px;';
$padding_side = 'padding-right';
} else {
return '';
}
//Sidebar break = Desktop content area 728 + sidebar area 330 + grow margin variable + two gutters
$sidebar_break_with_grow = 728 + 360 + $grow_sidebar_margin_space + 48;
//calculate the max-width to apply grow styles. When destkop large, don't need them anymore
$max_width_apply_grow_styles = $grow_sidebar_margin_space + 1200 + ( 24 * 2 );
//apply calculated max-width to Trellis filter max width
$media_query_max_width = apply_filters( 'mv_trellis_grow_sidebar_media_query_max_width', $max_width_apply_grow_styles . 'px');
//We don't do anything to the theme right now if <= 700px;
$media_query_min_width = apply_filters( 'mv_trellis_grow_sidebar_media_query_min_width', '701px' );
//Now apply the appropriate style based on the button size, the side it is positioned, and whether it should apply to posts and pages.
$grow_sidebar_styles = '@media only screen and (min-width:' . $media_query_min_width . ') and (max-width: ' . $media_query_max_width . ') {';
$grow_sidebar_styles .= '.has-grow-sidebar .content {' . $sidebar_margin_css . $padding_side . ':0px;}';
$grow_sidebar_styles .= '.has-grow-sidebar .footer-container {' . $sidebar_margin_css . $padding_side . ':0px;}';
$grow_sidebar_styles .= '}';
//Change .wrapper-content from display:grid to display:block when under calculated Grow sidebar breakpoint width
$grow_sidebar_styles .= '@media only screen and (max-width:' . $sidebar_break_with_grow . 'px){
.has-grow-sidebar #content{
display:flex;
flex-direction: column;
justify-content: center;
align-items: center;
max-width: 728px;
}
.sidebar-primary{border:none!important;}';
$grow_sidebar_styles .= '.has-grow-sidebar .widget-container.mv_trellis_mobile_hide{display:none;}';
$grow_sidebar_styles .= '}';
return $grow_sidebar_styles;
}
add_filter('mv_trellis_grow_sidebar_compatibility_styles', 'mv_birch_update_grow_styles');
/**
* removes "Tag" title from post tag display
*/
function mv_birch_entry_tags() {
mv_trellis_entry_tags( '', '' );
}
add_action( 'mv_trellis_parent_loaded', function() {
remove_action( 'tha_entry_footer_bottom', [ \Mediavine\Trellis\Post::get_instance(), 'display_post_tags' ], 15 );
add_action( 'tha_entry_footer_bottom', 'mv_birch_entry_tags', 15 );
});
/**
* Adjust image resolution based on the image size selected in settings
* largest image needed is high resolution
*
*
* @return string
*/
function mv_birch_filter_excerpt_image_resolution() {
return 'high';
};
add_filter( 'mv_trellis_featured_post_image_res', 'mv_birch_filter_excerpt_image_resolution' );
/**
* Adjust image resolution based on the image size selected in settings
* largest image needed is high resolution
*
*
* @return string
*/
function mv_birch_filter_featured_image_resolution() {
$featured_img_size = \Mediavine\Trellis\Settings::read_value( 'featured_image_size', 'mv_trellis_1x1' );
if ( 'mv_trellis_1x1' === $featured_img_size || 'mv_trellis_3x4' === $featured_img_size ) {
return 'med';
}
return 'high';
};
add_filter( 'mv_trellis_excerpt_image_res', 'mv_birch_filter_featured_image_resolution' );
/**
* Modify featured post and excerpt image size attribute
*
* @param string $sizes The featured image size from Trellis settings.
*
* @return string
*/
function mv_birch_excerpt_image_sizes( $sizes ) {
$featured_image_size = \Mediavine\Trellis\Settings::read_value('featured_image_size', 'mv_trellis_1x1');
switch ( $featured_image_size ) {
case 'mv_trellis_16x9':
case 'mv_trellis_4x3':
case 'full':
$sizes = '(max-width: 1153px) calc(100vw - 67px), (max-width: 1200px) calc(100vw - 451px), (max-width: 1249px) 749px, 797px';
break;
case 'mv_trellis_3x4':
case 'mv_trellis_1x1':
$sizes = '(max-width: 599px) calc(100vw - 67px), (max-width: 1153px) calc(50vw - 33.5px), (max-width: 1200px) calc((100vw - 451px)/2), (max-width: 1249px) 374.5px, 398.5px';
break;
}
return $sizes;
}
add_filter( 'mv_trellis_excerpt_image_sizes', 'mv_birch_excerpt_image_sizes' );
/**
* Modify featured post image size attribute
*
* @param string $sizes image sizes attribute value being filtered.
*
* @return string
*/
function mv_birch_featured_post_image_sizes( $sizes ) {
$featured_image_size = \Mediavine\Trellis\Settings::read_value('featured_image_size', 'mv_trellis_1x1');
switch ( $featured_image_size ) {
case 'mv_trellis_16x9':
case 'mv_trellis_4x3':
case 'full':
$sizes = '(max-width: 1249px) calc(100vw - 67px), 1181px';
break;
case 'mv_trellis_3x4':
case 'mv_trellis_1x1':
$sizes = '(max-width: 1129px) calc(100vw - 67px), (max-width: 1200px) calc(50vw - 33.5px), (max-width: 1249px) 566.5px, 590.5px';
break;
}
return $sizes;
}
add_filter( 'mv_trellis_featured_post_image_sizes', 'mv_birch_featured_post_image_sizes' );
/**
* Modify the web story Trellis enqueue
*
* @param string $story_archive_styles Web stories inline styles specific to the child theme.
*
* @return string
*/
function mv_birch_web_stories_inline_styles( $story_archive_styles ) {
$story_archive_styles .= '.post-type-archive-web-story .excerpt{min-width: 728px;}';
$story_archive_styles .= '@media only screen and (max-width:800px){.post-type-archive-web-story .excerpt{min-width: unset; padding: 0px;}}';
return $story_archive_styles;
}
add_filter( 'mv_trellis_web_stories_compatibility_styles', 'mv_birch_web_stories_inline_styles');
/**
* Include the Trellis 0.14.0 transitional code if current Trellis version is less than 0.14.0
*/
function mv_birch_semantic_transition_check() {
$trellis_versions = \Mediavine\Trellis\Options::get_versions();
if ( empty( $trellis_versions ) || version_compare( $trellis_versions[0], '0.14.0', 'lt' ) ) {
require_once get_stylesheet_directory() . '/_inc_semantic_transition.php';
}
}
add_action( 'mv_trellis_parent_loaded', 'mv_birch_semantic_transition_check', 1 );
/**
* filters the breakpoint when the sidebar moves below the content so ads are not served and not displayed
*
* @param string $breakpoint local model value for the sidebar breakpoint being filtered.
*
* @return string
*/
function mv_birch_set_local_model_sidebar_breakpoint( $breakpoint ) {
if ( ! function_exists( 'dpsp_is_location_displayable' ) || ! dpsp_is_location_displayable( 'sidebar' ) ) {
return '1160';
}
$dpsp_sidebar_settings = get_option( 'dpsp_location_sidebar', 'not_set' );
$button_size = ( ! empty( $dpsp_sidebar_settings['display']['size'] ) ) ? $dpsp_sidebar_settings['display']['size'] : null;
$sidebar_size = '';
switch ( strtolower( $button_size ) ) {
case 'medium':
$sidebar_size = '1202';
break;
case 'small':
$sidebar_size = '1197';
break;
default:
$sidebar_size = '1207';
break;
}
return $sidebar_size;
}
add_filter( 'mv_trellis_model_sidebar_breakpoint', 'mv_birch_set_local_model_sidebar_breakpoint', 11 );