/** * Parse fields data and generate styles output. * * @package Canvas */ require_once CNVS_PATH . 'gutenberg/utils/is-field-visible/index.php'; if ( ! class_exists( 'CNVS_Gutenberg_Fields_CSS_Output' ) ) { /** * Class Gutenberg Fields CSS Output. */ class CNVS_Gutenberg_Fields_CSS_Output { /** * Prepare CSS for selected fields. * * @param string $selector CSS selector. * @param array $fields Fields data. * @param array $attributes Block attributes. * * @return string */ public static function get( $selector, $fields = array(), $attributes = array() ) { $schemes = cnvs_gutenberg()->get_schemes_data(); $breakpoints = cnvs_gutenberg()->get_breakpoints_data(); $all_breakpoints = cnvs_gutenberg()->get_all_breakpoints_data(); $result = ''; foreach ( $fields as $field ) { if ( ! isset( $field['type'] ) || ! isset( $field['output'] ) ) { continue; } // check if field visible. if ( ! CNVS_Gutenberg_Utils_Is_Field_Visible::check( $field, $attributes, $fields ) ) { continue; } foreach ( $field['output'] as $data ) { $result .= self::prepare_styles_from_params( $selector, self::get_field_value( $field, $attributes ), $data ); if ( $schemes && ( 'color' === $field['type'] ) ) { foreach ( $schemes as $name => $scheme ) { $rule = sprintf( '[data-scheme="%s"] %s', $name, $selector ); if ( $name && 'default' !== $name ) { $result .= self::prepare_styles_from_params( $rule, self::get_field_value( $field, $attributes, $name ), $data ); } } } if ( isset( $field['responsive'] ) && $field['responsive'] ) { foreach ( $all_breakpoints as $name => $breakpoint ) { if ( $name && 'desktop' !== $name ) { $rule = $selector; // If exist scheme. if ( isset( $breakpoint['scheme'] ) ) { $rule = sprintf( '[data-scheme="%s"] %s', $breakpoint['scheme'], $selector ); } $result .= self::prepare_styles_from_params( $rule, self::get_field_value( $field, $attributes, $name ), array_merge( $data, array( 'media_query' => '@media (max-width: ' . apply_filters( 'canvas_blocks_dynamic_breakpoint_width', $breakpoint['width'], $field ) . 'px)', ) ) ); } } } } } return $result; } /** * Get current field value. If value doesn't exist, use default value. * * @param array $field Field data. * @param array $attributes Field attributes. * @param string $breakpoint Breakpoint name. * * @return mixed Field value. */ public static function get_field_value( $field, $attributes, $breakpoint = '' ) { $suffix = ''; if ( $breakpoint ) { $suffix = '_' . $breakpoint; } if ( isset( $attributes[ $field['key'] . $suffix ] ) ) { return $attributes[ $field['key'] . $suffix ]; } elseif ( isset( $field[ 'default' . $suffix ] ) ) { return $field[ 'default' . $suffix ]; } return null; } /** * Prepare styles from params * Params example: array( 'element' => '$', 'property' => 'height', 'value_pattern' => 'linear-gradient(to bottom, $ 14%,#7db9e8 77%)', 'media_query' => '@media ( min-width: 760px )', 'units' => 'px', 'prefix' => 'calc(1px + ', 'suffix' => ') !important', ) * * @param string $selector CSS selector. * @param mixed $value Property value. * @param array $params Output params. * * @return string */ public static function prepare_styles_from_params( $selector, $value, $params ) { $result = ''; if ( ! $selector || ! isset( $value ) || '' === $value || null === $value || ! isset( $params['property'] ) ) { return $result; } // Check for context. if ( isset( $params['context'] ) && ! in_array( 'front', $params['context'], true ) ) { return $result; } // Value pattern. if ( isset( $params['value_pattern'] ) ) { $value = str_replace( '$', $value, $params['value_pattern'] ); } // Custom selector pattern. if ( isset( $params['element'] ) ) { $selector = str_replace( '$', $selector, $params['element'] ); } // Prefix. if ( isset( $params['prefix'] ) ) { $value = $params['prefix'] . $value; } // Units. if ( isset( $params['units'] ) ) { $value = $value . $params['units']; } // Suffix. if ( isset( $params['suffix'] ) ) { $value = $value . $params['suffix']; } $property = $params['property']; // Prepare CSS. $result = "${selector} { ${property}: ${value}; }"; // Add media query. if ( isset( $params['media_query'] ) ) { $media_query = $params['media_query']; $result = "${media_query} { ${result} }"; } return $result; } } } /** * Check if field visible. * * @package Canvas */ if ( ! class_exists( 'CNVS_Gutenberg_Utils_Is_Field_Visible' ) ) { /** * Class Gutenberg Utils Is Field Visible. */ class CNVS_Gutenberg_Utils_Is_Field_Visible { /** * Check active_callback in custom controls. * * @param array $fieldData field data. * @param array $attributes block attributes. * @param array $allFields all fields. * @param array $prepareAttrs prepare attributes for server render. * * @return boolean */ public static function check( $fieldData, $attributes, $allFields, $prepareAttrs = true ) { $result = true; // if ( $prepareAttrs ) { // $attributes = apply_filters( 'canvas_block_prepare_server_render_attributes', $attributes, array( 'fields' => $allFields ) ); // } if ( isset( $fieldData['active_callback'] ) ) { $result = self::checkCondition( $fieldData['active_callback'], $attributes, 'AND' ); } return $result; } /** * Compare 2 values * * @param mixed $lval Left value. * @param string $operator Operator. * @param mixed $rval Right value. * * @return boolean */ public static function compare( $lval, $operator, $rval ) { $check_result = true; switch ( $operator ) { case '==': $check_result = $lval == $rval; break; case '===': $check_result = $lval === $rval; break; case '!=': $check_result = $lval != $rval; break; case '!==': $check_result = $lval !== $rval; break; case '>=': $check_result = $lval >= $rval; break; case '<=': $check_result = $lval <= $rval; break; case '>': $check_result = $lval > $rval; break; case '<': $check_result = $lval < $rval; break; case 'AND': $check_result = $lval && $rval; break; case 'OR': $check_result = $lval || $rval; break; default: $check_result = $lval; break; } return $check_result; } /** * Check condition * * @param array $conditions - Conditions array. * @param array $attributes - Available block attributes. * @param string $relation - Can be one of 'AND' or 'OR'. * * @return boolean */ public static function checkCondition( $conditions, $attributes, $relation ) { $childRelation = ( 'AND' === $relation ) ? 'OR' : 'AND'; // By default result will be TRUE for relation AND and FALSE for relation OR. $result = $relation === 'AND'; foreach ( $conditions as $data ) { if ( is_array( $data ) && ! isset( $data['field'] ) ) { $result = self::compare( $result, $relation, self::checkCondition( $data, $attributes, $childRelation ) ); } elseif ( isset( $data['field'] ) ) { $splitValName = explode( '.', $data['field'] ); $fieldVal = null; // Check for array values like: toggleListName['option1']. if ( 2 === count( $splitValName ) && isset( $attributes[ $splitValName[0] ] ) && isset( $attributes[ $splitValName[0] ][ $splitValName[1] ] ) ) { $fieldVal = $attributes[ $splitValName[0] ][ $splitValName[1] ]; } // Check for normal values. if ( null === $fieldVal && isset( $attributes[ $data['field'] ] ) ) { $fieldVal = $attributes[ $data['field'] ]; } // Check count. if ( isset( $data['count'] ) ) { $count = explode( $data['count'], $fieldVal ); $fieldVal = count( $count ) - 1; } if ( null !== $fieldVal ) { $result = self::compare( $result, $relation, self::compare( $fieldVal, isset( $data['operator'] ) ? $data['operator'] : '===', isset( $data['value'] ) ? $data['value'] : true ) ); } } } return $result; } } } Página no encontrada – Bitnarios.
Fatal error: Class 'CNVS_Gutenberg_Fields_CSS_Output' not found in /home/lemonify/bitnarios/wp-content/plugins/canvas/gutenberg/custom-blocks/index.php on line 813