%PDF- %PDF-
| Direktori : /home2/rezakur1/packages.rezakurnia.com/wp-content/themes/newsmatic/inc/ |
| Current File : //home2/rezakur1/packages.rezakurnia.com/wp-content/themes/newsmatic/inc/styles.php |
<?php
/**
* Includes the inline css
*
* @package Newsmatic
* @since 1.0.0
*/
use Newsmatic\CustomizerDefault as ND;
if( ! function_exists( 'newsmatic_assign_preset_var' ) ) :
/**
* Generate css code for top header color options
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_assign_preset_var( $selector, $control) {
$decoded_control = ND\newsmatic_get_customizer_option( $control );
if( ! $decoded_control ) return;
echo " body.newsmatic_font_typography{ " . $selector . ": ".esc_html( $decoded_control ). ";}\n";
}
endif;
if( ! function_exists( 'newsmatic_assign_var' ) ) :
/**
* Generate css code for top header color options
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_assign_var( $selector, $control) {
$decoded_control = json_decode(ND\newsmatic_get_customizer_option( $control ),true);
if( ! $decoded_control[$decoded_control['type']] ) return;
echo " body.newsmatic_font_typography{ " . $selector . ": ".newsmatic_get_color_format($decoded_control[$decoded_control['type']]). ";}\n";
}
endif;
if( ! function_exists( 'newsmatic_get_background_style' ) ) :
/**
* Generate css code for background control.
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_get_background_style( $selector, $control, $var = '' ) {
$decoded_control = json_decode( ND\newsmatic_get_customizer_option( $control ), true );
if( ! $decoded_control ) return;
if( isset( $decoded_control['type'] ) ) :
$type = $decoded_control['type'];
switch( $type ) {
case 'image' : if( isset( $decoded_control[$type]['media_id'] ) ) echo $selector . " { background-image: url(" .esc_url( wp_get_attachment_url( $decoded_control[$type]['media_id'] ) ). ") }";
if( isset( $decoded_control['repeat'] ) ) echo $selector . "{ background-repeat: " .esc_html( $decoded_control['repeat'] ). "}";
if( isset( $decoded_control['position'] ) ) echo $selector . "{ background-position:" .esc_html( $decoded_control['position'] ). "}";
if( isset( $decoded_control['attachment'] ) ) echo $selector . "{ background-attachment: " .esc_html( $decoded_control['attachment'] ). "}";
if( isset( $decoded_control['size'] ) ) echo $selector . "{ background-size: " .esc_html( $decoded_control['size'] ). "}";
break;
default: if( isset( $decoded_control[$type] ) ) echo $selector . "{ background: " .newsmatic_get_color_format( $decoded_control[$type] ). "}";
}
endif;
}
endif;
if( ! function_exists( 'newsmatic_get_background_style_var' ) ) :
/**
* Generate css code for background control.
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_get_background_style_var( $selector, $control) {
$decoded_control = json_decode( ND\newsmatic_get_customizer_option( $control ), true );
if( ! $decoded_control ) return;
if( isset( $decoded_control['type'] ) ) :
$type = $decoded_control['type'];
if( isset( $decoded_control[$type] ) ) echo ".newsmatic_main_body { ".$selector.": " .newsmatic_get_color_format( $decoded_control[$type] ). "}";
endif;
}
endif;
if( ! function_exists( 'newsmatic_get_background_style_responsive' ) ) :
/**
* Generate css code for background control.
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_get_background_style_responsive( $selector, $control, $var = '' ) {
$decoded_control = json_decode( ND\newsmatic_get_customizer_option( $control ), true );
if( ! $decoded_control ) return;
if( isset( $decoded_control['type'] ) ) :
$type = $decoded_control['type'];
switch( $type ) {
case 'image' : if( isset( $decoded_control[$type]['media_id'] ) ) echo $selector . " { background-image: url(" .esc_url( wp_get_attachment_url( $decoded_control[$type]['media_id'] ) ). ") }";
if( isset( $decoded_control['repeat'] ) ) echo $selector . "{ background-repeat: " .esc_html( $decoded_control['repeat'] ). "}";
if( isset( $decoded_control['position'] ) ) echo $selector . "{ background-position:" .esc_html( $decoded_control['position'] ). "}";
if( isset( $decoded_control['attachment'] ) ) echo $selector . "{ background-attachment: " .esc_html( $decoded_control['attachment'] ). "}";
if( isset( $decoded_control['size'] ) ) echo $selector . "{ background-size: " .esc_html( $decoded_control['size'] ). "}";
break;
default: if( isset( $decoded_control[$type] ) ) echo "@media(max-width: 768px){ ". $selector . "{ background: " .newsmatic_get_color_format( $decoded_control[$type] ). "} }";
}
endif;
}
endif;
if( ! function_exists( 'newsmatic_get_responsive_spacing_style' ) ) :
/**
* Generate css code for spacing control.
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_get_responsive_spacing_style( $selector, $control, $property = 'margin') {
$decoded_control = ND\newsmatic_get_customizer_option( $control );
if( ! $decoded_control ) return;
if( isset( $decoded_control['desktop'] ) ) :
$desktop = $decoded_control['desktop'];
echo $selector . "{ " . esc_html( $property ). ": ".esc_html( implode( " ", $desktop ) ). "; }";
endif;
if( isset( $decoded_control['tablet'] ) ) :
$desktop = $decoded_control['tablet'];
echo "@media(max-width: 940px) { " .$selector . "{ " . esc_html( $property ). ": ".esc_html( implode( " ", $desktop ) ). "; } }\n";
endif;
if( isset( $decoded_control['smartphone'] ) ) :
$desktop = $decoded_control['smartphone'];
echo "@media(max-width: 610px) { " .$selector . "{ " . esc_html( $property ). ": ".esc_html( implode( " ", $desktop ) ). "; } }\n";
endif;
}
endif;
if( ! function_exists( 'newsmatic_get_typo_style' ) ) :
/**
* Generate css code for typography control.
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_get_typo_style( $selector, $control ) {
$decoded_control = ND\newsmatic_get_customizer_option( $control );
if( ! $decoded_control ) return;
if( isset( $decoded_control['font_family'] ) ) :
echo ".newsmatic_font_typography { ".$selector."-family : " .esc_html( $decoded_control['font_family']['value'] ). "; }\n";
endif;
if( isset( $decoded_control['font_weight'] ) ) :
echo ".newsmatic_font_typography { ".$selector."-weight : " .esc_html( $decoded_control['font_weight']['value'] ). "; }\n";
endif;
if( isset( $decoded_control['text_transform'] ) ) :
echo ".newsmatic_font_typography { ".$selector."-texttransform : " .esc_html( $decoded_control['text_transform'] ). "; }\n";
endif;
if( isset( $decoded_control['text_decoration'] ) ) :
echo ".newsmatic_font_typography { ".$selector."-textdecoration : " .esc_html( $decoded_control['text_decoration'] ). "; }\n";
endif;
if( isset( $decoded_control['font_size'] ) ) :
if( isset( $decoded_control['font_size']['desktop'] ) ) echo ".newsmatic_font_typography { ".$selector."-size : " .absint( $decoded_control['font_size']['desktop'] ). "px; }\n";
if( isset( $decoded_control['font_size']['tablet'] ) ) echo ".newsmatic_font_typography { ".$selector."-size-tab : " .absint( $decoded_control['font_size']['tablet'] ). "px; }\n";
if( isset( $decoded_control['font_size']['smartphone'] ) ) echo ".newsmatic_font_typography { ".$selector."-size-mobile : " .absint( $decoded_control['font_size']['smartphone'] ). "px; }\n";
endif;
if( isset( $decoded_control['line_height'] ) ) :
if( isset( $decoded_control['line_height']['desktop'] ) ) echo ".newsmatic_font_typography { ".$selector."-lineheight : " .absint( $decoded_control['line_height']['desktop'] ). "px; }\n";
if( isset( $decoded_control['line_height']['tablet'] ) ) echo ".newsmatic_font_typography { ".$selector."-lineheight-tab : " .absint( $decoded_control['line_height']['tablet'] ). "px; }\n";
if( isset( $decoded_control['line_height']['smartphone'] ) ) echo ".newsmatic_font_typography { ".$selector."-lineheight-mobile : " .absint( $decoded_control['line_height']['smartphone'] ). "px; }\n";
endif;
if( isset( $decoded_control['letter_spacing'] ) ) :
if( isset( $decoded_control['letter_spacing']['desktop'] ) ) echo ".newsmatic_font_typography { ".$selector."-letterspacing : " .absint( $decoded_control['letter_spacing']['desktop'] ). "px; }\n";
if( isset( $decoded_control['letter_spacing']['tablet'] ) ) echo ".newsmatic_font_typography { ".$selector."-letterspacing-tab : " .absint( $decoded_control['letter_spacing']['tablet'] ). "px; }\n";
if( isset( $decoded_control['letter_spacing']['smartphone'] ) ) echo ".newsmatic_font_typography { ".$selector."-letterspacing-mobile : " .absint( $decoded_control['letter_spacing']['smartphone'] ). "px; }\n";
endif;
}
endif;
/** site logo width **/
if( ! function_exists( 'newsmatic_site_logo_width_fnc' ) ) :
/**
* Generate css code for Logo Width
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_site_logo_width_fnc( $selector, $control, $property = 'width' ) {
$decoded_control = ND\newsmatic_get_customizer_option( $control );
if( ! $decoded_control ) return;
if( isset( $decoded_control['desktop'] ) ) :
$desktop = $decoded_control['desktop'];
echo $selector . "{ " . esc_html( $property ). ": ".esc_html( $desktop ). "px; }";
endif;
if( isset( $decoded_control['tablet'] ) ) :
$tablet = $decoded_control['tablet'];
echo "@media(max-width: 940px) { " .$selector . "{ " . esc_html( $property ). ": ".esc_html( $tablet ). "px; } }\n";
endif;
if( isset( $decoded_control['smartphone'] ) ) :
$smartphone = $decoded_control['smartphone'];
echo "@media(max-width: 610px) { " .$selector . "{ " . esc_html( $property ). ": ".esc_html($smartphone). "px; } }\n";
endif;
}
endif;
if( ! function_exists( 'newsmatic_top_border_color' ) ) :
/**
* Generate css code for top header color options
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_top_border_color( $selector, $control, $property = 'border-color' ) {
$decoded_control = json_decode( ND\newsmatic_get_customizer_option( $control ), true );
if( ! $decoded_control ) return;
if( isset( $decoded_control['type'] ) ) :
$type = $decoded_control['type'];
if( isset( $decoded_control[$type] ) ) echo $selector . "{ " . esc_html( $property ). ": ".esc_html( $decoded_control[$type] ). "}";
if($type == 'solid'){
if( isset( $decoded_control[$type] ) ) echo $selector . "{ border-color: ". newsmatic_get_color_format( $decoded_control[$type] ) .";}";
if( isset( $decoded_control[$type] ) ) echo $selector . " li{ border-color: ". newsmatic_get_color_format( $decoded_control[$type] ) .";}";
}
if($type == 'gradient'){
echo $selector . " li{ border: none;}";
}
endif;
}
endif;
if( ! function_exists( 'newsmatic_color_options_one' ) ) :
/**
* Generate css code for Top header Text Color
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_color_options_one( $selector, $control, $property = 'color' ) {
$decoded_control = ND\newsmatic_get_customizer_option( $control );
if( ! $decoded_control ) return;
echo $selector . " { " . esc_html( $property ). ": ".newsmatic_get_color_format($decoded_control ). " }";
}
endif;
//menu color and hover
// header color(no-img)
if( ! function_exists( 'newsmatic_menu_text_color' ) ) :
/**
* Generate css code for top header color options
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_text_color_var( $selector, $control) {
$decoded_control = ND\newsmatic_get_customizer_option( $control );
if( ! $decoded_control ) return;
if( isset( $decoded_control['color'] ) ) :
$color = $decoded_control['color'];
echo ".newsmatic_font_typography { " . $selector . ": ".newsmatic_get_color_format($color). ";}";
endif;
if( isset( $decoded_control['hover'] ) ) :
$color_hover = $decoded_control['hover'];
echo ".newsmatic_font_typography { " . $selector . "-hover : ".newsmatic_get_color_format($color_hover). "; }";
endif;
}
endif;
// Visibility function
if(! function_exists('newsmatic_visibility_options')):
/**
* Generate css code for top header color options
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_visibility_options( $selector, $control ) {
$decoded_control = ND\newsmatic_get_customizer_option( $control );
if( ! $decoded_control ) return;
if( isset( $decoded_control['desktop'] ) ) :
if($decoded_control['desktop'] == false) echo $selector . "{ display : none;}";
if($decoded_control['desktop'] == true) echo $selector . "{ display : block;}";
endif;
if( isset( $decoded_control['tablet'] ) ) :
if($decoded_control['tablet'] == false) echo "@media(max-width: 940px) and (min-width:611px) { " .$selector . "{ display : none;} }";
if($decoded_control['tablet'] == true) echo "@media(max-width: 940px) and (min-width:611px) { " .$selector . "{ display : block;} }";
endif;
if( isset( $decoded_control['mobile'] ) ) :
if($decoded_control['mobile'] == false) echo "@media(max-width: 610px) { " .$selector . "{ display : none;} }";
if($decoded_control['mobile'] == true) echo "@media(max-width: 610px) { " .$selector . "{ display : block;} }";
endif;
}
endif;
/* move to top */
if( ! function_exists( 'newsmatic_border_option' ) ) :
/**
* Generate css code for Top header Text Color
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_border_option( $selector, $control, $property="border" ) {
$decoded_control = ND\newsmatic_get_customizer_option( $control );
if( ! $decoded_control ) return;
if( isset( $decoded_control['type'] ) || isset( $decoded_control['width'] ) || isset( $decoded_control['color'] ) ) :
echo $selector. "{ ".$property.": ". $decoded_control['width'] ."px ".$decoded_control['type']." ". newsmatic_get_color_format($decoded_control['color']) .";}";
endif;
}
endif;
//Theme color
if( ! function_exists( 'newsmatic_theme_color' ) ) :
/**
* Generate css code for top header color options
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_theme_color( $selector, $control) {
$decoded_control = ND\newsmatic_get_customizer_option( $control );
if( ! $decoded_control ) return;
echo " body.newsmatic_main_body{ " . $selector . ": ".newsmatic_get_color_format($decoded_control). ";}";
echo " body.newsmatic_dark_mode{ " . $selector . ": ".newsmatic_get_color_format($decoded_control). ";}";
}
endif;
/** padding newsmatic **/
if( ! function_exists( 'newsmatic_header_padding' ) ) :
/**
* Generate css code for Top header Text Color
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_header_padding( $selector, $control ) {
$decoded_control = ND\newsmatic_get_customizer_option( $control );
if( ! $decoded_control ) return;
if( isset( $decoded_control['desktop'] ) ):
echo ".newsmatic_font_typography { ".$selector.": ". $decoded_control['desktop'] ."px;}";
endif;
if( isset( $decoded_control['tablet'] ) ):
echo " .newsmatic_font_typography { ".$selector."-tablet: ". $decoded_control['tablet'] ."px;}";
endif;
if( isset( $decoded_control['smartphone'] ) ):
echo " .newsmatic_font_typography { ".$selector."-smartphone: ". $decoded_control['smartphone'] ."px;}";
endif;
}
endif;
if( ! function_exists( 'newsmatic_font_size_style' ) ) :
/**
* Generates css code for font size
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_font_size_style( $selector, $control ) {
$decoded_control = ND\newsmatic_get_customizer_option( $control );
if( ! $decoded_control ) return;
if( isset( $decoded_control['desktop'] ) ) :
$desktop = $decoded_control['desktop'];
echo "body.newsmatic_main_body{ " . $selector . ": ".esc_html( $desktop ). "px;}\n";
endif;
if( isset( $decoded_control['tablet'] ) ) :
$tablet = $decoded_control['tablet'];
echo "body.newsmatic_main_body{ " . $selector . "-tablet: ".esc_html( $tablet ). "px;}\n";
endif;
if( isset( $decoded_control['smartphone'] ) ) :
$smartphone = $decoded_control['smartphone'];
echo "body.newsmatic_main_body{ " . $selector . "-smartphone: ".esc_html( $smartphone ). "px;}\n";
endif;
}
endif;
if( ! function_exists( 'newsmatic_category_colors_styles' ) ) :
/**
* Generates css code for font size
*
* @package Newsmatic
* @since 1.0.0
*/
function newsmatic_category_colors_styles() {
$totalCats = get_categories();
if( $totalCats ) :
foreach( $totalCats as $singleCat ) :
echo "body .post-categories .cat-item.cat-" . absint($singleCat->term_id) . " { background-color : " .newsmatic_get_color_format( ND\newsmatic_get_customizer_option( 'category_' .absint($singleCat->term_id). '_color' ) ). "} ";
echo "body .newsmatic-category-no-bk .post-categories .cat-item.cat-" . absint($singleCat->term_id) . " a" ." { color : " .newsmatic_get_color_format( ND\newsmatic_get_customizer_option( 'category_' .absint($singleCat->term_id). '_color' ) ). "} ";
echo "body.single .post-categories .cat-item.cat-" . absint($singleCat->term_id) . " { background-color : " .newsmatic_get_color_format( ND\newsmatic_get_customizer_option( 'category_' .absint($singleCat->term_id). '_color' ) ). "} ";
endforeach;
endif;
}
endif;
if( ! function_exists( 'newsmatic_adjust_builder_border' ) ) :
/**
* Adjust border of 2nd and 3rd row in header builder
*
* @since 1.4.0
*/
function newsmatic_adjust_builder_border( $builder_id ) {
$css = [];
$prefix_class = ( $builder_id !== 'responsive_header_builder' ) ? '.bb-bldr--normal' : '.bb-bldr--responsive';
$header_builder = ND\newsmatic_get_customizer_option( $builder_id );
$custom_button_make_absolute = ND\newsmatic_get_customizer_option( 'custom_button_make_absolute' );
$row_padding_control_id = '';
// Logic to find which row the 'button' widget is located in
if( $custom_button_make_absolute ) :
if( ! empty( $header_builder ) && is_array( $header_builder ) ) :
$first_row = [ '00', '01', '02', '03' ];
$second_row = [ '10', '11', '12', '13' ];
$third_row = [ '20', '21', '22', '23' ];
foreach( $header_builder as $column => $widgets ) :
if( in_array( 'button', $widgets ) && in_array( $column, $first_row ) ) :
$row_padding_control_id = 'header_first_row_padding';
break;
endif;
if( in_array( 'button', $widgets ) && in_array( $column, $second_row ) ) :
$row_padding_control_id = 'header_second_row_padding';
break;
endif;
if( in_array( 'button', $widgets ) && in_array( $column, $third_row ) ) :
$row_padding_control_id = 'header_third_row_padding';
break;
endif;
endforeach;
endif;
endif;
// First Row
if( $custom_button_make_absolute && ( $row_padding_control_id === 'header_first_row_padding' ) ) :
$first_row_padding = ND\newsmatic_get_customizer_option( 'header_first_row_padding' );
$first_row_padding_desktop = $first_row_padding[ 'desktop' ][ 'bottom' ];
$first_row_padding_tablet = $first_row_padding[ 'tablet' ][ 'bottom' ];
$first_row_padding_smartphone = $first_row_padding[ 'smartphone' ][ 'bottom' ];
$selector = 'body '. esc_html( $prefix_class ) .' .custom-button-absolute';
$css[] = "$selector{ bottom: -$first_row_padding_desktop; }";
$css[] = "@media(max-width: 940px){ $selector{ bottom: -$first_row_padding_tablet; } }";
$css[] = "@media(max-width: 610px){ $selector{ bottom: -$first_row_padding_smartphone; } }";
endif;
// Second Row
$second_row_border = ND\newsmatic_get_customizer_option( 'header_menu_top_border' );
if( ( $second_row_border[ 'type' ] !== 'none' ) || ( $custom_button_make_absolute && ( $row_padding_control_id === 'header_second_row_padding' ) ) ) :
$second_row_padding = ND\newsmatic_get_customizer_option( 'header_second_row_padding' );
$second_row_padding_desktop = $second_row_padding[ 'desktop' ][ 'bottom' ];
$second_row_padding_tablet = $second_row_padding[ 'tablet' ][ 'bottom' ];
$second_row_padding_smartphone = $second_row_padding[ 'smartphone' ][ 'bottom' ];
$selector = esc_html( $prefix_class ) . ' .row-two .bb-bldr-row:before, '. esc_html( $prefix_class ) .' .custom-button-absolute';
$css[] = "$selector{ bottom: -$second_row_padding_desktop; }";
$css[] = "@media(max-width: 940px){ $selector{ bottom: -$second_row_padding_tablet; } }";
$css[] = "@media(max-width: 610px){ $selector{ bottom: -$second_row_padding_smartphone; } }";
endif;
// Third row
$third_row_border = ND\newsmatic_get_customizer_option( 'header_menu_bottom_border' );
if( ( $third_row_border[ 'type' ] !== 'none' ) || ( $custom_button_make_absolute && ( $row_padding_control_id === 'header_third_row_padding' ) ) ) :
$third_row_padding = ND\newsmatic_get_customizer_option( 'header_third_row_padding' );
$third_row_padding_desktop = $third_row_padding[ 'desktop' ][ 'bottom' ];
$third_row_padding_tablet = $third_row_padding[ 'tablet' ][ 'bottom' ];
$third_row_padding_smartphone = $third_row_padding[ 'smartphone' ][ 'bottom' ];
$selector = esc_html( $prefix_class ) . ' .row-three .bb-bldr-row:before, '. esc_html( $prefix_class ) .' .custom-button-absolute';
$css[] = "$selector{ bottom: -$third_row_padding_desktop; }";
$css[] = "@media(max-width: 940px){ $selector{ bottom: -$third_row_padding_tablet; } }";
$css[] = "@media(max-width: 610px){ $selector{ bottom: -$third_row_padding_smartphone; } }";
endif;
echo implode( "\n", $css );
}
endif;
// box shadow
if( ! function_exists( 'newsmatic_box_shadow_styles' ) ) :
/**
* Generates css code for box shadow
*
* @package Newsmatic Pro
* @since 1.4.0
*/
function newsmatic_box_shadow_styles( $control, $selector ) {
$newsmatic_box_shadow = ND\newsmatic_get_customizer_option( $control );
if( ! $newsmatic_box_shadow['option'] ) {
echo $selector."{ box-shadow: 0px 0px 0px 0px;
}\n";
} else {
if( $newsmatic_box_shadow['type'] == 'outset') $newsmatic_box_shadow['type'] = '';
$box_shadow_value = esc_html( $newsmatic_box_shadow['type'] ) ." ".esc_html( $newsmatic_box_shadow['hoffset'] ). "px ". esc_html( $newsmatic_box_shadow['voffset'] ). "px ".esc_html( $newsmatic_box_shadow['blur'] ). "px ".esc_html( $newsmatic_box_shadow['spread'] ). "px ".newsmatic_get_color_format( $newsmatic_box_shadow['color'] );
echo $selector."{ box-shadow : " . $box_shadow_value . "; -webkit-box-shadow: ". $box_shadow_value ."; -moz-box-shadow: " . $box_shadow_value . " }\n";
}
}
endif;