array(), 'sm' => array(), 'md' => array() ); public function __construct(){ add_action( 'wp_head', array( __CLASS__, 'print_styles' ), 99 ); } /** * Add styes to the array * * @static * @access public * @since 1.0.0 * @return null * * @package BizSmart WordPress Theme */ public static function add_styles( $style, $device = 'md' ){ self::$styles[ $device ][] = $style; } protected static function get_css_unit( $prop ){ switch( $prop ){ case 'font-size': case 'margin-top': case 'margin-bottom': case 'margin-left': case 'margin-right': case 'padding-top': case 'padding-bottom': case 'padding-left': case 'padding-right': case 'border-radius': case 'border-width': case 'border-top-width': case 'min-height': case 'max-height': case 'letter-spacing': return 'px'; case 'max-width': return 'px !important'; default: return; } } /** * Generates the css for theme * * @static * @access protected * @since 1.0.0 * @return null * * @package BizSmart WordPress Theme */ protected static function generate_css( $dynamic_css ){ if( count( $dynamic_css ) <= 0 ) return; foreach( $dynamic_css as $css ){ echo ( $css[ 'selector' ] ); ?>{ $setting ){ $unit = false; if( is_array( $setting ) ){ $customizer = isset( $setting[ 'customizer' ] ) && $setting[ 'customizer' ] ? true : false; if( $customizer ){ $value = bizsmart_get( $setting[ 'value' ] ); }else{ $value = $setting[ 'value' ] ? $setting[ 'value' ] : ''; } $unit = $setting[ 'unit' ]; }else{ $value = bizsmart_get( $setting ); if( 'font-family' == $prop ){ $value = esc_attr( self::get_font( $value ) ).", sans-serif"; }elseif( 'content' == $prop ){ $value = '"\\'. esc_attr( $value ).'"'; }else{ $value = esc_attr( $value ); } } if( '' !== $value ){ $unit = $unit ? $unit : self::get_css_unit( $prop ); echo $prop . ': ' . $value . $unit . ';'; } } ?> } 0 ){ foreach( $styles as $style ){ self::generate_css( $style ); } } } /** * Print all the styes scripts * * @static * @access public * @since 1.0.0 * @return null * * @package BizSmart WordPress Theme */ public static function print_styles(){ ?>