%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/shaban/laviva/wp-content/plugins/levelup-core/inc/
Upload File :
Create Path :
Current File : /var/www/html/shaban/laviva/wp-content/plugins/levelup-core/inc/less-functions.php

<?php

// File Security Check
if ( ! defined( 'ABSPATH' ) ) { exit; }

//use Mexitek\PHPColors\Rdy_Color;


function levelup_stylesheet_is_not_writable() {

    if ( get_option( 'levelup_less_css_is_writable' ) ) {

        update_option( 'levelup_less_css_is_writable', 0 );
    }
}
add_action( 'wp-less_save_stylesheet_error', 'levelup_stylesheet_is_not_writable' );


function levelup_stylesheet_is_writable() {

    update_option( 'levelup_less_css_is_writable', 1 );
}
add_action( 'wp-less_stylesheet_save_post', 'levelup_stylesheet_is_writable' );


function levelup_compile_less_vars() {
    if ( !class_exists('WPLessPlugin') ) {
        return array();
    }

    $image_defaults = array(
        'image'			=> '',
        'repeat'		=> 'repeat',
        'position'	    => 'center',
    );

    $font_family_falloff = ', Helvetica, Arial, Verdana, sans-serif';
    $font_family_defaults = array('family' => 'Open Sans');

    do_action( 'levelup_before_compile_less_vars' );

    $options = array();

    $options_inteface = apply_filters( 'levelup_less_options_interface', array() );


    if ( $options_inteface ) {

        foreach( $options_inteface as $data ) {

            if ( empty($data) || empty($data['type']) || empty($data['less_vars']) || empty($data['php_vars']) ) continue;

            $type = $data['type'];
            $less_vars = $data['less_vars'];
            $php_vars = $data['php_vars'];
            $wrap = isset($data['wrap']) ? $data['wrap'] : false;
            $interface = isset($data['interface']) ? $data['interface'] : false;
            $isLight = array_key_exists('isLight', $data) ? $data['isLight'] : '';
            $color_type = array_key_exists('color_type', $data) ? $data['color_type'] : '';
            $color_type_val = array_key_exists('color_type_val', $data) ? $data['color_type_val'] : '';

            $hover_type_val = $hover_type = $ie_color = '';

            extract($php_vars);

            switch( $type ) {

                case 'rgba_color':

                    $color_option = levelup_get_options( $color[0], $color[1] );
                    $opacity_option = levelup_get_options( $opacity[0], $opacity[1] );

                    if ( !$color_option ) {
                        $color_option = $color[1];
                    }

                    if($isLight){
                        $myColor = new Rdy_Color($color_option);

                        if($myColor->isLight()){
                            $options[ $less_var ] = 1;
                        }else{
                            $options[ $less_var ] = 0;
                        }

                    }

                    $computed_color = levelup_stylesheet_make_ie_compat_rgba(
                        $color_option,
                        $ie_color,
                        $opacity_option
                    );

                    $options[ current($less_vars) ] = $computed_color['rgba'];

                    if ( $ie_color ) {

                        if ( !empty($ie_color[2]) && function_exists($ie_color[2]) ) {
                            $computed_color['ie_color'] = call_user_func( $ie_color[2], $computed_color['ie_color'] );
                        }

                        if ( empty($computed_color['ie_color']) ) {
                            $computed_color['ie_color'] = '~"transparent"';
                        }
                        $options[ next($less_vars) ] = $computed_color['ie_color'];
                    }

                    break;

                case 'rgba_color2':
                    $color_option = levelup_get_options( $color[0], $color[1], 'rgba' );

                    if ( !$color_option ) {
                        $color_option = $color[1];
                    }

                    $options[ current($less_vars) ] = $color_option;

                    break;

                case 'rgb_color':
                    $color_option = levelup_get_option( $color[0], $color[1] );

                    $computed_color = levelup_stylesheet_color_hex2rgb( $color_option ? $color_option : $color[1] );

                    if ( $computed_color && false !== $wrap ) {

                        if ( is_array($wrap) ) {

                            $computed_color = current($wrap) . $computed_color . next($wrap);
                        } else {

                            $computed_color = $wrap . $computed_color . $wrap;
                        }
                    }

                    $options[ current($less_vars) ] = $computed_color;

                    break;

                case 'hex_color':
                    $computed_color = levelup_get_options( $color[0], $color[1] );
                    if($color_type && !$color_type_val){
                        $color_type_val = levelup_get_options( $color_type, '' );
                    }
                    if($hover_type){
                        $hover_type_val = levelup_get_options( $hover_type, '' );
                    }

                    if($color_type_val){
                        $computed_color = levelup_get_accent_color($color_type_val, $computed_color);
                    }

                    if($hover_type_val == 'disable'){
                        $computed_color = '-';
                    }

                    if ( !$computed_color ) {
                        $computed_color = $color[1];
                    }

                    if (!empty($isLight) && $isLight) {
                        $myColor = new Rdy_Color($computed_color);

                        if ($myColor->isLight()) {
                            $options[$less_var] = 1;
                        } else {
                            $options[$less_var] = 0;
                        }

                    }

                    $options[ current($less_vars) ] = $computed_color;

                    break;

                case 'bg_hex_color':
                    $computed_color = levelup_get_options( $color[0], $color[1], 'bg-color' );

                    if ( !$computed_color ) {
                        $computed_color = $color[1];
                    }

                    $options[ current($less_vars) ] = $computed_color;
                    break;

                case 'media':
                    $computed_image = levelup_get_options($image[0], $image[1]);

                    if ( !$computed_image ) {
                        $computed_image = $image[1];
                    }

                    $options[ current($less_vars) ] = $computed_image['url'];

                    break;

                case 'image':

                    if ( !isset($image) ) {
                        break;
                    }

                    $computed_image = levelup_get_options($image[0], $image[1], 'background');

                    $computed_image['image'] = levelup_stylesheet_get_image($computed_image['background-image']);

                    $options[ current($less_vars) ] = $computed_image['image'];

                    if ( false != next($less_vars) && current($less_vars) ) {
                        $options[ current($less_vars) ] = isset($computed_image['background-repeat']) ? $computed_image['background-repeat'] : 'no-repeat';
                    }

                    if ( false != next($less_vars) && current($less_vars) ) {
                        $options[ current($less_vars) ] = isset($computed_image['background-position']) ? $computed_image['background-position'] : 'center';
                    }

                    break;

                case 'image_bg':

                    if ( !isset($image) ) {
                        break;
                    }

                    $computed_image = levelup_get_options($image[0], $image[1]);

//	                if ( ! is_array( $computed_image['image'] ) ) {
//						break;
//					}

                    $computed_image['image'] = 'none';
                    if ( array_key_exists( 'background-image', $computed_image ) ) {
                        $computed_image['image'] = levelup_stylesheet_get_image( $computed_image['background-image'] );
                    }

                    $options[ current($less_vars) ] = $computed_image['image'];

                    if ( false != next($less_vars) && current($less_vars) ) {
                        $options[ current($less_vars) ] = isset($computed_image['background-repeat']) && $computed_image['background-repeat'] ? $computed_image['background-repeat'] : 'no-repeat';
                    }

                    if ( false != next($less_vars) && current($less_vars) ) {
                        $options[ current($less_vars) ] = isset($computed_image['background-size']) && $computed_image['background-size'] ? $computed_image['background-size'] : 'inherit';
                    }

                    if ( false != next($less_vars) && current($less_vars) ) {
                        $options[ current($less_vars) ] = isset($computed_image['background-attachment']) && $computed_image['background-attachment'] ? $computed_image['background-attachment'] : 'inherit';
                    }

                    if ( false != next($less_vars) && current($less_vars) ) {
                        $options[ current($less_vars) ] = isset($computed_image['background-position']) && $computed_image['background-position'] ? $computed_image['background-position'] : 'center';
                    }

                    if ( false != next($less_vars) && current($less_vars) ) {
                        $options[ current($less_vars) ] = isset($computed_image['background-color']) && $computed_image['background-color'] ? $computed_image['background-color'] : 'center';
                    }
                    break;

                case 'number':

                    if ( !isset($number) ) {
                        break;
                    }

                    if(!$number[0] && $number[1]){
                        $options[ current($less_vars) ] = $number[1];
                        break;
                    }

                    $computed_number = intval( levelup_get_options($number[0], $number[1]) );

                    if ( false !== $wrap ) {

                        if ( is_array($wrap) ) {

                            $computed_number = current($wrap) . $computed_number . next($wrap);
                        } else {

                            $computed_number = $wrap . $computed_number . $wrap;
                        }
                    }

                    $options[ current($less_vars) ] = $computed_number;

                    break;

                case 'number_half':

                    if ( !isset($number) ) {
                        break;
                    }

                    if(!$number[0] && $number[1]){
                        $options[ current($less_vars) ] = $number[1];
                        break;
                    }

                    $computed_number = intval( levelup_get_options($number[0], $number[1]) );

	                try{
		                $computed_number = $computed_number / 2;
	                }
	                catch(Exception $e){
		                $computed_number = 0;
	                }

                    if ( false !== $wrap ) {

                        if ( is_array($wrap) ) {

                            $computed_number = current($wrap) . $computed_number . next($wrap);
                        } else {

                            $computed_number = $wrap . $computed_number . $wrap;
                        }
                    }

                    $options[ current($less_vars) ] = $computed_number;

                    break;

                case 'keyword':

                    if ( !isset($keyword) ) {
                        break;
                    }

                    $computed_keyword = (string) levelup_get_options($keyword[0], $keyword[1]);

                    if ( false !== $interface ) {

                        if ( isset( $interface[ $computed_keyword ] ) ) {

                            $computed_keyword = $interface[ $computed_keyword ];
                        } else {

                            $computed_keyword = current($interface);
                        }
                    }

                    $options[ current($less_vars) ] = $computed_keyword;

                    break;

                case 'font':

                    if ( !isset($font) ) {
                        break;
                    }

                    $option_font = levelup_get_options($font[0]);

                    $computed_font = levelup_stylesheet_make_web_font_object( $option_font , $font[1] );

                    if ( !$computed_font ) {
                        break;
                    }

                    if ( false !== $wrap ) {

                        if ( is_array($wrap) ) {

                            $computed_font->family = current($wrap) . $computed_font->family . next($wrap);
                        } else {

                            $computed_font->family = $wrap . $computed_font->family . $wrap;
                        }
                    }

                    $options[ current($less_vars) ] = $computed_font->family;

                    if ( false != next($less_vars) ) {
                        $options[ current($less_vars) ] = $computed_font->weight;
                    }

                    if ( false != next($less_vars) ) {
                        $options[ current($less_vars) ] = $computed_font->style;
                    }

                    if ( false != next($less_vars) ) {
                        $options[ current($less_vars) ] = $computed_font->size;
                    }

                    if ( false != next($less_vars) ) {
                        $options[ current($less_vars) ] = $computed_font->transform;
                    }

                    if ( false != next($less_vars) ) {
                        $options[ current($less_vars) ] = $computed_font->line;
                    }

                    if ( false != next($less_vars) ) {
                        $options[ current($less_vars) ] = $computed_font->spacing;
                    }

                    if ( false != next($less_vars) ) {
                        $options[ current($less_vars) ] = $computed_font->color;
                    }
                    
                    break;
            }
        }
    }

    return apply_filters( 'levelup_compiled_less_vars', $options );
}

/**
 * Escape color for svg objects.
 *
 */
function levelup_less_escape_color( $color = '' ) {
    return '~"' . implode( ',%20', array_map( 'urlencode', explode( ',', $color ) ) ) . '"';
}

/**
 * Escape function for lessphp.
 *
 */
function levelup_lessphp_escape( $value ) {
    $v = &$value[2][1][1];
    $v = rawurlencode( $v );

    return $value;
}

/**
 * Register escape function in lessphp.
 *
 */
function levelup_register_escape_function_for_lessphp() {
    if ( !class_exists('WPLessPlugin') || !function_exists('levelup_lessphp_escape') ) {
        return;
    }

    $less = WPLessPlugin::getInstance();
    $less->registerFunction('escape', 'levelup_lessphp_escape');
}
add_action( 'levelup_before_compile_less_vars', 'levelup_register_escape_function_for_lessphp', 15 );

Zerion Mini Shell 1.0