%PDF- %PDF-
Direktori : /var/www/html/shaban/laviva/wp-content/themes/levelup/inc/helpers/ |
Current File : /var/www/html/shaban/laviva/wp-content/themes/levelup/inc/helpers/stylesheet.php |
<?php // File Security Check if ( ! defined( 'ABSPATH' ) ) { exit; } function levelup_get_of_uploaded_image( $src ) { if ( ! $src ) { return ''; } $uri = $src; if ( ! parse_url( $src, PHP_URL_SCHEME ) ) { if ( levelup_maybe_uploaded_image_url( $src ) ) { $uri = site_url( $src ); } } return $uri; } function levelup_maybe_uploaded_image_url( $url ) { $uploads = wp_upload_dir(); $baseurl = str_replace( site_url(), '', $uploads['baseurl'] ); $pattern = '/' . trailingslashit( basename( WP_CONTENT_URL ) ); return ( strpos( $url, $baseurl ) !== false || strpos( $url, $pattern ) !== false ); } function levelup_stylesheet_get_image( $img_1, $img_2 = '', $use_second_img = false ) { if( (!$img_1 || 'none' == $img_1) && (!$img_2 || 'none' == $img_2) ) return 'none'; if( (!$img_1 || 'none' == $img_1) && !$use_second_img ) { return "none"; } $output = levelup_get_of_uploaded_image( $img_1 ); if( $use_second_img && $img_2 ) { if( !parse_url($img_2, PHP_URL_SCHEME) ) { $output = levelup_get_of_uploaded_image($img_2); }else { $output = $img_2; } } $output = sprintf( "url('%s')", esc_url($output) ); return $output; } function levelup_hex2rgb($hex) { $hex = str_replace("#", "", $hex); if(strlen($hex) == 3) { $r = hexdec(substr($hex,0,1).substr($hex,0,1)); $g = hexdec(substr($hex,1,1).substr($hex,1,1)); $b = hexdec(substr($hex,2,1).substr($hex,2,1)); } else { $r = hexdec(substr($hex,0,2)); $g = hexdec(substr($hex,2,2)); $b = hexdec(substr($hex,4,2)); } $rgb = array($r, $g, $b); return $rgb; // returns an array with the rgb values } function levelup_gradient_style($color1, $color2, $direction){ $g_type = 'linear'; $color1 = esc_attr( $color1 ); $color2 = esc_attr( $color2 ); if ( $direction == 'lr' ) { $g_direction = 'left'; $g_direction2 = 'to right'; } elseif ( $direction == 'br' ) { $g_direction = '-45deg'; $g_direction2 = '135deg'; } elseif ( $direction == 'bl' ) { $g_direction = '45deg'; $g_direction2 = '45deg'; } elseif ( $direction == 'rd' ) { $g_type = 'radial'; $g_direction = 'center, ellipse cover'; $g_direction2 = 'ellipse at center'; } else { $g_direction = 'top'; $g_direction2 = 'to bottom'; } return "background: {$color1};background: -moz-{$g_type}-gradient({$g_direction}, {$color1} 0%, {$color2} 100%);background: -webkit-{$g_type}-gradient({$g_direction}, {$color1} 0%, {$color2} 100%);background: {$g_type}-gradient({$g_direction2}, {$color1} 0%, {$color2} 100%);"; } function levelup_get_css_text_gradient( $color1, $color2, $color3 ) { if ( empty( $color1 ) && ( empty( $color2 ) || empty( $color3 ) ) ) { return; } $buff = '-webkit-linear-gradient(left,'; if ( $color1 ) { $buff .= esc_attr($color1) . ' 0%,'; } if ( $color2 && $color3 ) { $buff .= esc_attr($color2) . ' 50%,'; $buff .= esc_attr($color3) . ' 100%'; } else if ( $color2 ) { $buff .= esc_attr($color2) . ' 100%'; } else if ( $color3 ) { $buff .= esc_attr($color3) . ' 100%'; } $buff .= ');'; return $buff; }