add_section( 'bigbang_typography', array( 'title' => esc_html__( 'Typography', 'bigbang' ), 'panel' => 'bigbang_appearance_settings', 'priority' => 25, ) ); /** * ------------------ * 1. Font Family tab * ------------------ */ if ( class_exists( 'bigbang_Font_Selector' ) ) { /** * --------------------------------- * 1.a. Headings font family control * This control allows the user to choose a font family for all Headings used in the theme ( h1 - h6 ) * -------------------------------- */ $wp_customize->add_setting( 'bigbang_headings_font', array( 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( new bigbang_Font_Selector( $wp_customize, 'bigbang_headings_font', array( 'label' => esc_html__( 'Headings', 'bigbang' ) . ' ' . esc_html__( 'font family', 'bigbang' ), 'section' => 'bigbang_typography', 'priority' => 5, 'type' => 'select', ) ) ); /** * --------------------------------- * 1.b. Body font family control * This control allows the user to choose a font family for all elements in the body tag * -------------------------------- */ $wp_customize->add_setting( 'bigbang_body_font', array( 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( new bigbang_Font_Selector( $wp_customize, 'bigbang_body_font', array( 'label' => esc_html__( 'Body', 'bigbang' ) . ' ' . esc_html__( 'font family', 'bigbang' ), 'section' => 'bigbang_typography', 'priority' => 10, 'type' => 'select', ) ) ); } // End if(). if ( class_exists( 'bigbang_Select_Multiple' ) ) { /** * -------------------- * 1.c. Font Subsets control * This control allows the user to choose a subset for the font family ( for e.g. lating, cyrillic etc ) * -------------------- */ $wp_customize->add_setting( 'bigbang_font_subsets', array( 'sanitize_callback' => 'bigbang_sanitize_array', 'default' => array( 'latin' ), ) ); $wp_customize->add_control( new bigbang_Select_Multiple( $wp_customize, 'bigbang_font_subsets', array( 'section' => 'bigbang_typography', 'label' => esc_html__( 'Font Subsets', 'bigbang' ), 'choices' => array( 'latin' => 'latin', 'latin-ext' => 'latin-ext', 'cyrillic' => 'cyrillic', 'cyrillic-ext' => 'cyrillic-ext', 'greek' => 'greek', 'greek-ext' => 'greek-ext', 'vietnamese' => 'vietnamese', ), 'priority' => 45, ) ) ); } // End if(). /** * ------------------ * 2. Font Size tab * ------------------ */ if ( class_exists( 'bigbang_Customizer_Range_Value_Control' ) ) { /** * ------------------------------------- * 2.a. Customizer headings for a better * organization * ------------------------------------- */ if ( class_exists( 'bigbang_Customizer_Heading' ) ) { /** * ------------------------------------- * Heading control that is displayed * before font size controls for posts * and pages. * ------------------------------------- */ $wp_customize->add_setting( 'bigbang_posts_and_pages_title', array( 'sanitize_callback' => 'wp_kses', ) ); $wp_customize->add_control( new bigbang_Customizer_Heading( $wp_customize, 'bigbang_posts_and_pages_title', array( 'label' => esc_html__( 'Posts & Pages', 'bigbang' ), 'section' => 'bigbang_typography', 'priority' => 100, ) ) ); /** * ------------------------------------- * Heading control that is displayed * before font size controls for * frontpage. * ------------------------------------- */ $wp_customize->add_setting( 'bigbang_frontpage_sections_title', array( 'sanitize_callback' => 'wp_kses', ) ); $wp_customize->add_control( new bigbang_Customizer_Heading( $wp_customize, 'bigbang_frontpage_sections_title', array( 'label' => esc_html__( 'Frontpage Sections', 'bigbang' ), 'section' => 'bigbang_typography', 'priority' => 200, ) ) ); } /** * -------------------------------------------------------------------------- * 2.b. Font size controls for Posts & Pages * -------------------------------------------------------------------------- * * Title control [Posts & Pages] * This control allows the user to choose a font size for the main titles * that appear in the header for pages and posts. * * The values area between -25 and +25 px. * -------------------------------------------------------------------------- */ $wp_customize->add_setting( 'bigbang_header_titles_fs', array( 'sanitize_callback' => 'bigbang_sanitize_range_value', 'default' => '0', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new bigbang_Customizer_Range_Value_Control( $wp_customize, 'bigbang_header_titles_fs', array( 'label' => esc_html__( 'Title', 'bigbang' ), 'section' => 'bigbang_typography', 'type' => 'range-value', 'input_attr' => array( 'min' => - 25, 'max' => 25, 'step' => 1, ), 'priority' => 110, 'media_query' => true, 'sum_type' => true, ) ) ); /** * -------------------------------------------------------------------------- * Headings control [Posts & Pages] * * This control allows the user to choose a font size for all headings * ( h1 - h6 ) from pages and posts. * * The values area between -25 and +25 px. * -------------------------------------------------------------------------- */ $wp_customize->add_setting( 'bigbang_post_page_headings_fs', array( 'sanitize_callback' => 'bigbang_sanitize_range_value', 'default' => 0, 'transport' => 'postMessage', ) ); $wp_customize->add_control( new bigbang_Customizer_Range_Value_Control( $wp_customize, 'bigbang_post_page_headings_fs', array( 'label' => esc_html__( 'Headings', 'bigbang' ), 'section' => 'bigbang_typography', 'type' => 'range-value', 'input_attr' => array( 'min' => - 25, 'max' => 25, 'step' => 1, ), 'priority' => 115, 'sum_type' => true, ) ) ); /** * -------------------------------------------------------------------------- * Content control [Posts & Pages] * * This control allows the user to choose a font size for the main content * area in pages and posts. * * The values area between -25 and +25 px. * -------------------------------------------------------------------------- */ $wp_customize->add_setting( 'bigbang_post_page_content_fs', array( 'sanitize_callback' => 'bigbang_sanitize_range_value', 'default' => 0, 'transport' => 'postMessage', ) ); $wp_customize->add_control( new bigbang_Customizer_Range_Value_Control( $wp_customize, 'bigbang_post_page_content_fs', array( 'label' => esc_html__( 'Content', 'bigbang' ), 'section' => 'bigbang_typography', 'type' => 'range-value', 'input_attr' => array( 'min' => - 25, 'max' => 25, 'step' => 1, ), 'priority' => 120, 'sum_type' => true, ) ) ); /** * -------------------------------------------------------------------------- * 2.c. Font size controls for Frontpage * -------------------------------------------------------------------------- * Big Title Section / Header Slider font size control. [Frontpage Sections] * * This is changing the big title/slider titles, the * subtitle and the button in the big title section. * * The values are between -25 and +25 px. * -------------------------------------------------------------------------- */ $wp_customize->add_setting( 'bigbang_big_title_fs', array( 'sanitize_callback' => 'bigbang_sanitize_range_value', 'default' => '0', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new bigbang_Customizer_Range_Value_Control( $wp_customize, 'bigbang_big_title_fs', array( 'label' => apply_filters( 'bigbang_big_title_fs_label', esc_html__( 'Big Title Section', 'bigbang' ) ), 'section' => 'bigbang_typography', 'type' => 'range-value', 'input_attr' => array( 'min' => - 25, 'max' => 25, 'step' => 1, ), 'priority' => 210, 'sum_type' => true, ) ) ); /** * -------------------------------------------------------------------------- * Section Title [Frontpage Sections] * * This control is changing sections titles and card titles * The values are between -25 and +25 px. * -------------------------------------------------------------------------- */ $wp_customize->add_setting( 'bigbang_section_primary_headings_fs', array( 'sanitize_callback' => 'bigbang_sanitize_range_value', 'default' => '0', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new bigbang_Customizer_Range_Value_Control( $wp_customize, 'bigbang_section_primary_headings_fs', array( 'label' => esc_html__( 'Section Title', 'bigbang' ), 'section' => 'bigbang_typography', 'type' => 'range-value', 'input_attr' => array( 'min' => - 25, 'max' => 25, 'step' => 1, ), 'priority' => 215, 'sum_type' => true, ) ) ); /** * ----------------------------------------------------- * Subtitles control [Frontpage Sections] * This control allows the user to choose a font size * for all Subtitles on Frontpage sections. * The values area between -25 and +25 px. * ----------------------------------------------------- */ $wp_customize->add_setting( 'bigbang_section_secondary_headings_fs', array( 'sanitize_callback' => 'bigbang_sanitize_range_value', 'default' => 0, 'transport' => 'postMessage', ) ); $wp_customize->add_control( new bigbang_Customizer_Range_Value_Control( $wp_customize, 'bigbang_section_secondary_headings_fs', array( 'label' => esc_html__( 'Section Subtitle', 'bigbang' ), 'section' => 'bigbang_typography', 'type' => 'range-value', 'input_attr' => array( 'min' => - 25, 'max' => 25, 'step' => 1, ), 'priority' => 220, 'sum_type' => true, ) ) ); /** * ----------------------------------------------------- * Content control [Frontpage Sections] * This control allows the user to choose a font size * for the Main content for Frontpage Sections * The values area between -25 and +25 px. * ----------------------------------------------------- */ $wp_customize->add_setting( 'bigbang_section_content_fs', array( 'sanitize_callback' => 'bigbang_sanitize_range_value', 'default' => 0, 'transport' => 'postMessage', ) ); $wp_customize->add_control( new bigbang_Customizer_Range_Value_Control( $wp_customize, 'bigbang_section_content_fs', array( 'label' => esc_html__( 'Content', 'bigbang' ), 'section' => 'bigbang_typography', 'type' => 'range-value', 'input_attr' => array( 'min' => - 25, 'max' => 25, 'step' => 1, ), 'priority' => 225, 'sum_type' => true, ) ) ); } // End if(). } add_action( 'customize_register', 'bigbang_typography_settings', 20 ); if ( ! file_exists( 'bigbang_fonts_inline_style' ) ) { /** * Add inline style for custom fonts. * * @since 1.1.59 */ function bigbang_fonts_inline_style() { /** * Headings font family. */ $custom_css = ''; $default = apply_filters( 'bigbang_headings_default', false ); $bigbang_headings_font = get_theme_mod( 'bigbang_headings_font', $default ); if ( ! empty( $bigbang_headings_font ) ) { bigbang_enqueue_google_font( $bigbang_headings_font ); $custom_css .= 'h1, h2, h3, h4, h5, h6, .bigbang-title, .bigbang-title.title-in-content, p.meta-in-content , .info-title, .card-title, .page-header.header-small .bigbang-title, .page-header.header-small .title, .widget h5, .bigbang-title, .title, .card-title, .info-title, .footer-brand, .footer-big h4, .footer-big h5, .media .media-heading, .carousel h1.bigbang-title, .carousel h2.title, .carousel span.sub-title, .woocommerce.single-product h1.product_title, .woocommerce section.related.products h2, .bigbang-about h1, .bigbang-about h2, .bigbang-about h3, .bigbang-about h4, .bigbang-about h5 { font-family: ' . $bigbang_headings_font . '; }'; if ( class_exists( 'WooCommerce' ) ) { $custom_css .= '.woocommerce.single-product .product_title, .woocommerce .related.products h2, .woocommerce span.comment-reply-title { font-family: ' . $bigbang_headings_font . '; }'; } } /** * Body font family. */ $default = apply_filters( 'bigbang_body_font_default', false ); $bigbang_body_font = get_theme_mod( 'bigbang_body_font', $default ); if ( ! empty( $bigbang_body_font ) ) { bigbang_enqueue_google_font( $bigbang_body_font ); $custom_css .= ' body, ul, .tooltip-inner { font-family: ' . $bigbang_body_font . '; }'; if ( class_exists( 'WooCommerce' ) ) { $custom_css .= ' .products .shop-item .added_to_cart, .woocommerce-checkout #payment input[type=submit], .woocommerce-checkout input[type=submit], .woocommerce-cart table.shop_table td.actions input[type=submit], .woocommerce .cart-collaterals .cart_totals .checkout-button, .woocommerce button.button, .woocommerce div[id^=woocommerce_widget_cart].widget .buttons .button, .woocommerce div.product form.cart .button, .woocommerce #review_form #respond .form-submit , .added_to_cart.wc-forward, .woocommerce div#respond input#submit, .woocommerce a.button { font-family: ' . $bigbang_body_font . '; }'; } } /** * Hide customizer shortcut for page editor control if frontpage was edited with elementor, beaver or wpbakery. */ $is_pagebuilder = bigbang_edited_with_pagebuilder(); if ( $is_pagebuilder ) { $custom_css .= '.customize-partial-edit-shortcut-bigbang_page_editor{ display:none; }'; } wp_add_inline_style( 'bigbang_style', $custom_css ); } add_action( 'wp_enqueue_scripts', 'bigbang_fonts_inline_style' ); } if ( ! function_exists( 'bigbang_typography_inline_style' ) ) { /** * Add inline style for font sizes. * * @since 1.1.48 */ function bigbang_typography_inline_style() { $custom_css = ''; /** * Title control [Posts & Pages] */ $custom_css .= bigbang_get_inline_style( 'bigbang_header_titles_fs', 'bigbang_get_header_titles_style' ); /** * Headings control [Posts & Pages] */ $custom_css .= bigbang_get_inline_style( 'bigbang_post_page_headings_fs', 'bigbang_get_post_page_headings_style' ); /** * Content control [Posts & Pages] */ $custom_css .= bigbang_get_inline_style( 'bigbang_post_page_content_fs', 'bigbang_get_post_page_content_style' ); /** * Big Title Section / Header Slide [Frontpage sections] */ $custom_css .= bigbang_get_inline_style( 'bigbang_big_title_fs', 'bigbang_get_big_title_content_style' ); /** * Titles control [Frontpage sections] */ $custom_css .= bigbang_get_inline_style( 'bigbang_section_primary_headings_fs', 'bigbang_get_fp_titles_style' ); /** * Subitles control [Frontpage sections] */ $custom_css .= bigbang_get_inline_style( 'bigbang_section_secondary_headings_fs', 'bigbang_get_fp_subtitles_style' ); /** * Content control [Blog, Frontpage & WooCommerce] */ $custom_css .= bigbang_get_inline_style( 'bigbang_section_content_fs', 'bigbang_get_fp_content_style' ); wp_add_inline_style( 'bigbang_style', $custom_css ); } add_action( 'wp_enqueue_scripts', 'bigbang_typography_inline_style' ); } /** * This function checks if the value stored in the customizer control named '$control_name' is a json object. * If the value is json it means that the customizer range control stores a value for every device ( mobile, tablet, * desktop). In this case, for each of those devices it calls '$function_name' that with the following parameters: * the device and the value for the control on that device. * '$function_name' returns css code that will be added to inline style. * If the value is not json then it's int and the '$function_name' function will be called just once for all three * devices. * * @param string $control_name Control name. * @param string $function_name Function to be called. * * @since 1.1.38 * @return string */ function bigbang_get_inline_style( $control_name, $function_name ) { $control_value = get_theme_mod( $control_name ); if ( empty( $control_value ) ) { return ''; } $custom_css = ''; if ( bigbang_is_json( $control_value ) ) { $control_value = json_decode( $control_value, true ); if ( ! empty( $control_value ) ) { foreach ( $control_value as $key => $value ) { $custom_css .= call_user_func( $function_name, $value, $key ); } } } else { $custom_css .= call_user_func( $function_name, $control_value ); } return $custom_css; } /** * [Posts and Pages] Title font size. * * This function is called by bigbang_get_inline_style to change the font size for: * pages/posts titles * Slider/Big title title/subtitle * * @param string $value Font value. */ function bigbang_get_header_titles_style( $value, $dimension = 'desktop' ) { $custom_css = ''; switch ( $dimension ) { case 'desktop': $v3 = ( 42 + (int) $value ) > 0 ? ( 42 + (int) $value ) : 0; break; case 'tablet': case 'mobile': $v3 = ( 36 + (int) $value ) > 0 ? ( 36 + (int) $value ) : 0; break; } $custom_css .= ' .page-header.header-small .bigbang-title, .page-header.header-small .title, h1.bigbang-title.title-in-content{ font-size: ' . $v3 . 'px; }'; $custom_css = bigbang_add_media_query( $dimension, $custom_css ); return $custom_css; } /** * [Posts & Pages] Headings. * This function is called by bigbang_get_inline_style to change the font size for: * headings ( h1 - h6 ) on pages and single post pages * * @param string $value Font value. */ function bigbang_get_post_page_headings_style( $value, $dimension = 'desktop' ) { $custom_css = ''; switch ( $dimension ) { case 'desktop': $v1 = ( 42 + (int) $value ) > 0 ? ( 42 + (int) $value ) : 0; $v2 = ( 37 + (int) $value ) > 0 ? ( 37 + (int) $value ) : 0; $v3 = ( 32 + (int) $value ) > 0 ? ( 32 + (int) $value ) : 0; $v4 = ( 27 + (int) $value ) > 0 ? ( 27 + (int) $value ) : 0; $v5 = ( 23 + (int) $value ) > 0 ? ( 23 + (int) $value ) : 0; $v6 = ( 18 + (int) $value ) > 0 ? ( 18 + (int) $value ) : 0; break; case 'tablet': case 'mobile': $v1 = ( 36 + (int) $value ) > 0 ? ( 36 + (int) $value ) : 0; $v2 = ( 32 + (int) $value ) > 0 ? ( 32 + (int) $value ) : 0; $v3 = ( 28 + (int) $value ) > 0 ? ( 28 + (int) $value ) : 0; $v4 = ( 24 + (int) $value ) > 0 ? ( 24 + (int) $value ) : 0; $v5 = ( 21 + (int) $value ) > 0 ? ( 21 + (int) $value ) : 0; $v6 = ( 18 + (int) $value ) > 0 ? ( 18 + (int) $value ) : 0; break; } if ( ! empty( $v1 ) ) { $custom_css .= ' .single-post-wrap article h1:not(.title-in-content), .page-content-wrap h1:not(.title-in-content), .page-template-template-fullwidth article h1:not(.title-in-content) { font-size: ' . intval( $v1 ) . 'px; }'; } if ( ! empty( $v2 ) ) { $custom_css .= ' .single-post-wrap article h2, .page-content-wrap h2, .page-template-template-fullwidth article h2 { font-size: ' . intval( $v2 ) . 'px; }'; } if ( ! empty( $v3 ) ) { $custom_css .= ' .single-post-wrap article h3, .page-content-wrap h3, .page-template-template-fullwidth article h3 { font-size: ' . intval( $v3 ) . 'px; }'; } if ( ! empty( $v4 ) ) { $custom_css .= ' .single-post-wrap article h4, .page-content-wrap h4, .page-template-template-fullwidth article h4 { font-size: ' . intval( $v4 ) . 'px; }'; } if ( ! empty( $v5 ) ) { $custom_css .= ' .single-post-wrap article h5, .page-content-wrap h5, .page-template-template-fullwidth article h5 { font-size: ' . intval( $v5 ) . 'px; }'; } if ( ! empty( $v6 ) ) { $custom_css .= ' .single-post-wrap article h6, .page-content-wrap h6, .page-template-template-fullwidth article h6 { font-size: ' . $v6 . 'px; }'; } if ( function_exists( 'bigbang_add_media_query' ) ) { $custom_css = bigbang_add_media_query( $dimension, $custom_css ); } return $custom_css; } /** * [Posts & Pages] Content. * This function is called by bigbang_get_inline_style to change the font size for: * content ( p ) on pages * single post pages * * @param string $value Font value. */ function bigbang_get_post_page_content_style( $value, $dimension = 'desktop' ) { $custom_css = ''; switch ( $dimension ) { case 'desktop': $v1 = ( 18 + (int) $value ) > 0 ? ( 18 + (int) $value ) : 0; break; case 'tablet': case 'mobile': $v1 = ( 16 + (int) $value ) > 0 ? ( 16 + (int) $value ) : 0; break; } if ( ! empty( $v1 ) ) { $custom_css .= '.single-post-wrap article p:not(.meta-in-content), .page-content-wrap p, .single-post-wrap article ul, .page-content-wrap ul, .single-post-wrap article ol, .page-content-wrap ol, .single-post-wrap article dl, .page-content-wrap dl, .single-post-wrap article table, .page-content-wrap table, .page-template-template-fullwidth article p { font-size: ' . intval( $v1 ) . 'px; }'; } if ( function_exists( 'bigbang_add_media_query' ) ) { $custom_css = bigbang_add_media_query( $dimension, $custom_css ); } return $custom_css; } /** * [Frontpage Sections] Big Title Section / Header Slider. * * This function is called by bigbang_get_inline_style to change big title/slider titles, the * subtitle and the button in the big title section. * * How to calculate values: * Hardcoded values (67, 18 and 14 on desktop or 36, 18, 14 on tablet and mobile) are the default values from css. * In this case 67 is for big title, 18 for subtitle and 14 for button. * The main formula for calculating is this: * $initial_value + ($variable_value / $correlation) * $initial_value -> value from css * $variable_value -> controls value that is between -25 and 25 * $correlation -> this variable says we increase the value every X units. * There is another variable to set a lower limit. Just change the value compared to. * * @param string $value Font value. * @param string $dimension Dimension. */ function bigbang_get_big_title_content_style( $value, $dimension = 'desktop' ) { $custom_css = ''; switch ( $dimension ) { case 'desktop': $v1 = ( 67 + (int) $value ) > 0 ? ( 67 + (int) $value ) : 0; $v2 = ( 18 + intval( (int) $value / 8 ) ) > 0 ? ( 18 + intval( (int) $value / 8 ) ) : 0; $v3 = ( 14 + intval( (int) $value / 12 ) ) > 0 ? ( 14 + intval( (int) $value / 12 ) ) : 0; break; case 'tablet': case 'mobile': $v1 = ( 36 + intval( (int) $value / 4 ) ) > 0 ? ( 36 + intval( (int) $value / 4 ) ) : 0; $v2 = ( 18 + intval( (int) $value / 4 ) ) > 0 ? ( 18 + intval( (int) $value / 4 ) ) : 0; $v3 = ( 14 + intval( (int) $value / 6 ) ) > 0 ? ( 14 + intval( (int) $value / 6 ) ) : 0; break; } if ( ! empty( $v1 ) ) { $custom_css .= '#carousel-bigbang-generic .bigbang-title{ font-size: ' . intval( $v1 ) . 'px; }'; } if ( ! empty( $v2 ) ) { $custom_css .= '#carousel-bigbang-generic span.sub-title{ font-size: ' . intval( $v2 ) . 'px; }'; } if ( ! empty( $v3 ) ) { $custom_css .= '#carousel-bigbang-generic .btn{ font-size: ' . intval( $v3 ) . 'px; }'; } if ( function_exists( 'bigbang_add_media_query' ) ) { $custom_css = bigbang_add_media_query( $dimension, $custom_css ); } return $custom_css; } /** * [Frontpage Sections] Frontpage Titles font size. * * This function is called by bigbang_get_inline_style to change the font size for: * all frontpage sections titles and small headings ( Feature box title, Shop box title, Team box title, Testimonial box title, Blog box title ) * * The main formula for calculating is this: * $initial_value + ($variable_value / $correlation) * $initial_value -> value from css * $variable_value -> controls value that is between -25 and 25 * $correlation -> this variable says we increase the value every X units. * There is another variable to set a lower limit. Just change the value compared to. * * @param string $value Font value. */ function bigbang_get_fp_titles_style( $value, $dimension = 'desktop' ) { $custom_css = ''; switch ( $dimension ) { case 'desktop': $v1 = ( 37 + (int) $value ) > 18 ? ( 37 + (int) $value ) : 18; $v2 = ( 18 + intval( (int) $value / 3 ) ) > 14 ? ( 18 + intval( (int) $value / 3 ) ) : 14; $v3 = ( 23 + intval( (int) $value / 3 ) ) > 0 ? ( 23 + intval( (int) $value / 3 ) ) : 0; $h1 = ( 42 + intval( (int) $value / 3 ) ) > 0 ? ( 42 + intval( (int) $value / 3 ) ) : 0; $h2 = ( 37 + intval( (int) $value / 3 ) ) > 0 ? ( 37 + intval( (int) $value / 3 ) ) : 0; $h3 = ( 32 + intval( (int) $value / 3 ) ) > 0 ? ( 32 + intval( (int) $value / 3 ) ) : 0; $h4 = ( 27 + intval( (int) $value / 3 ) ) > 0 ? ( 27 + intval( (int) $value / 3 ) ) : 0; break; case 'tablet': case 'mobile': $v1 = ( 24 + (int) $value ) > 18 ? ( 24 + (int) $value ) : 18; $v2 = ( 18 + intval( (int) $value / 3 ) ) > 14 ? ( 18 + intval( (int) $value / 3 ) ) : 14; $v3 = ( 23 + intval( (int) $value / 3 ) ) > 0 ? ( 23 + intval( (int) $value / 3 ) ) : 0; $h1 = ( 42 + intval( (int) $value / 3 ) ) > 0 ? ( 42 + intval( (int) $value / 3 ) ) : 0; $h2 = ( 37 + intval( (int) $value / 3 ) ) > 0 ? ( 37 + intval( (int) $value / 3 ) ) : 0; $h3 = ( 32 + intval( (int) $value / 3 ) ) > 0 ? ( 32 + intval( (int) $value / 3 ) ) : 0; $h4 = ( 27 + intval( (int) $value / 3 ) ) > 0 ? ( 27 + intval( (int) $value / 3 ) ) : 0; break; } if ( ! empty( $v1 ) ) { $custom_css .= ' section.bigbang-features .bigbang-title, section.bigbang-shop .bigbang-title, section.bigbang-work .bigbang-title, section.bigbang-team .bigbang-title, section.bigbang-pricing .bigbang-title, section.bigbang-ribbon .bigbang-title, section.bigbang-testimonials .bigbang-title, section.bigbang-subscribe h2.title, section.bigbang-blogs .bigbang-title, .section.related-posts .bigbang-title, section.bigbang-contact .bigbang-title{ font-size: ' . intval( $v1 ) . 'px; }'; } if ( ! empty( $v2 ) ) { $custom_css .= ' section.bigbang-features .bigbang-info h4.info-title, section.bigbang-shop h4.card-title, section.bigbang-team h4.card-title, section.bigbang-testimonials h4.card-title, section.bigbang-blogs h4.card-title, .section.related-posts h4.card-title, section.bigbang-contact h4.card-title, section.bigbang-contact .bigbang-description h6{ font-size: ' . intval( $v2 ) . 'px; }'; } if ( ! empty( $v3 ) ) { $custom_css .= ' section.bigbang-work h4.card-title, section.bigbang-contact .bigbang-description h5{ font-size: ' . intval( $v3 ) . 'px; } '; } if ( ! empty( $h1 ) ) { $custom_css .= ' section.bigbang-contact .bigbang-description h1{ font-size: ' . intval( $h1 ) . 'px; }'; } if ( ! empty( $h2 ) ) { $custom_css .= ' section.bigbang-contact .bigbang-description h2{ font-size: ' . intval( $h2 ) . 'px; }'; } if ( ! empty( $h3 ) ) { $custom_css .= ' section.bigbang-contact .bigbang-description h3{ font-size: ' . intval( $h3 ) . 'px; }'; } if ( ! empty( $h4 ) ) { $custom_css .= ' section.bigbang-contact .bigbang-description h4{ font-size: ' . intval( $h4 ) . 'px; }'; } $custom_css = bigbang_add_media_query( $dimension, $custom_css ); return $custom_css; } /** * [Frontpage Sections] Subtitles font size. * * This function is called by bigbang_get_inline_style to change the font size for: * all frontpage sections subtitles * * The main formula for calculating is this: * $initial_value + ($variable_value / $correlation) * $initial_value -> value from css * $variable_value -> controls value that is between -25 and 25 * $correlation -> this variable says we increase the value every X units. * There is another variable to set a lower limit. Just change the value compared to. * * @param string $value Font value. */ function bigbang_get_fp_subtitles_style( $value, $dimension = 'desktop' ) { $custom_css = ''; switch ( $dimension ) { case 'desktop': case 'tablet': case 'mobile': $v1 = ( 18 + intval( (int) $value / 3 ) ) > 12 ? ( 18 + intval( (int) $value / 3 ) ) : 12; break; } $custom_css .= ' section.bigbang-features h5.description, section.bigbang-shop h5.description, section.bigbang-work h5.description, section.bigbang-team h5.description, section.bigbang-testimonials h5.description, section.bigbang-subscribe h5.subscribe-description, section.bigbang-blogs h5.description, section.bigbang-contact h5.description{ font-size: ' . intval( $v1 ) . 'px; }'; $custom_css = bigbang_add_media_query( $dimension, $custom_css ); return $custom_css; } /** * [Frontpage Sections] Content font size. * * This function is called by bigbang_get_inline_style to change the font size for: * all frontpage sections box content * * @param string $value Font value. */ function bigbang_get_fp_content_style( $value, $dimension = 'desktop' ) { $custom_css = ''; switch ( $dimension ) { case 'desktop': case 'tablet': case 'mobile': $v1 = ( 16 + intval( (int) $value / 3 ) ) > 12 ? ( 16 + intval( (int) $value / 3 ) ) : 12; $v2 = ( 14 + intval( (int) $value / 3 ) ) > 12 ? ( 14 + intval( (int) $value / 3 ) ) : 12; $v3 = ( 12 + intval( (int) $value / 3 ) ) > 12 ? ( 12 + intval( (int) $value / 3 ) ) : 12; break; } if ( ! empty( $v1 ) ) { $custom_css .= ' section.bigbang-features .bigbang-info p, section.bigbang-shop .card-description p{ font-size: ' . intval( $v1 ) . 'px; }'; } if ( ! empty( $v2 ) ) { $custom_css .= ' section.bigbang-team p.card-description, section.bigbang-pricing p.text-gray, section.bigbang-testimonials p.card-description, section.bigbang-blogs p.card-description, .section.related-posts p.card-description, .bigbang-contact p{ font-size: ' . intval( $v2 ) . 'px; }'; } if ( ! empty( $v3 ) ) { $custom_css .= ' section.bigbang-shop h6.category, section.bigbang-work .label-primary, section.bigbang-team h6.category, section.bigbang-pricing .card-pricing h6.category, section.bigbang-testimonials h6.category, section.bigbang-blogs h6.category, .section.related-posts h6.category{ font-size: ' . intval( $v3 ) . 'px; }'; } $custom_css = bigbang_add_media_query( $dimension, $custom_css ); return $custom_css; } /** * Check if a string is in json format * * @param string $string Input. * * @since 1.1.38 * @return bool */ function bigbang_is_json( $string ) { return is_string( $string ) && is_array( json_decode( $string, true ) ) ? true : false; } /** * Function to import font sizes from old controls to new ones. * * @since 1.1.58 */ function bigbang_sync_new_fs() { $execute = get_option( 'bigbang_sync_font_sizes' ); if ( $execute !== false ) { return; } $headings_fs_old = get_theme_mod( 'bigbang_headings_font_size' ); $body_fs_old = get_theme_mod( 'bigbang_body_font_size' ); if ( empty( $body_fs_old ) && empty( $headings_fs_old ) ) { return; } if ( ! empty( $headings_fs_old ) ) { $decoded = bigbang_calculate_fs_value( $headings_fs_old, 37 ); set_theme_mod( 'bigbang_section_primary_headings_fs', $decoded ); set_theme_mod( 'bigbang_section_secondary_headings_fs', $decoded ); set_theme_mod( 'bigbang_header_titles_fs', $decoded ); set_theme_mod( 'bigbang_post_page_headings_fs', $decoded ); } if ( ! empty( $body_fs_old ) ) { $decoded = bigbang_calculate_fs_value( $body_fs_old, 12 ); set_theme_mod( 'bigbang_section_content_fs', $decoded ); set_theme_mod( 'bigbang_post_page_content_fs', $decoded ); } update_option( 'bigbang_sync_font_sizes', true ); } add_action( 'after_setup_theme', 'bigbang_sync_new_fs' ); /** * Calculate new value for the new font size control based on the old control. * * @param string $old_value Value from the old control. * @param int $decrease_rate Value to substract from the old value. */ function bigbang_calculate_fs_value( $old_value, $decrease_rate ) { $decoded = json_decode( $old_value ); if ( ! bigbang_is_json( $old_value ) ) { $tmp_array = array( 'desktop' => floor( $decoded - $decrease_rate ) > 25 ? 25 : ( floor( $decoded - $decrease_rate ) < - 25 ? - 25 : floor( $decoded - $decrease_rate ) ), 'mobile' => 0, 'tablet' => 0, ); $decoded = json_encode( $tmp_array ); } else { $decoded->desktop = floor( $decoded->desktop - $decrease_rate ) > 25 ? 25 : ( floor( $decoded->desktop - $decrease_rate ) < - 25 ? - 25 : floor( $decoded->desktop - $decrease_rate ) ); $decoded->tablet = floor( $decoded->tablet - $decrease_rate ) > 25 ? 25 : ( floor( $decoded->tablet - $decrease_rate ) < - 25 ? - 25 : floor( $decoded->tablet - $decrease_rate ) ); $decoded->mobile = floor( $decoded->mobile - $decrease_rate ) > 25 ? 25 : ( floor( $decoded->mobile - $decrease_rate ) < - 25 ? - 25 : floor( $decoded->mobile - $decrease_rate ) ); $decoded = json_encode( $decoded ); } return $decoded; } /** * This function is called by each function that adds css if the control have media queries enabled. * * @param string $dimension Query dimension. * @param string $custom_css Css. * * @return string */ function bigbang_add_media_query( $dimension, $custom_css ) { switch ( $dimension ) { case 'desktop': $custom_css = '@media (min-width: 769px){' . $custom_css . '}'; break; break; case 'tablet': $custom_css = '@media (max-width: 768px){' . $custom_css . '}'; break; case 'mobile': $custom_css = '@media (max-width: 480px){' . $custom_css . '}'; break; } return $custom_css; }