), '_1_5_3_5_1_5' => sprintf( esc_html__( '%1$s Columns', 'Divi' ), '1/5 + 3/5 + 1/5' ), ) ); } endif; if ( ! function_exists( 'et_divi_yes_no_choices' ) ) : /** * Returns yes no choices * @return array */ function et_divi_yes_no_choices() { return apply_filters( 'et_divi_yes_no_choices', array( 'yes' => esc_html__( 'Yes', 'Divi' ), 'no' => esc_html__( 'No', 'Divi' ) ) ); } endif; if ( ! function_exists( 'et_divi_left_right_choices' ) ) : /** * Returns left or right choices * @return array */ function et_divi_left_right_choices() { return apply_filters( 'et_divi_left_right_choices', array( 'right' => esc_html__( 'Right', 'Divi' ), 'left' => esc_html__( 'Left', 'Divi' ) ) ); } endif; if ( ! function_exists( 'et_divi_image_animation_choices' ) ) : /** * Returns image animation choices * @return array */ function et_divi_image_animation_choices() { return apply_filters( 'et_divi_image_animation_choices', array( 'left' => esc_html__( 'Left to Right', 'Divi' ), 'right' => esc_html__( 'Right to Left', 'Divi' ), 'top' => esc_html__( 'Top to Bottom', 'Divi' ), 'bottom' => esc_html__( 'Bottom to Top', 'Divi' ), 'fade_in' => esc_html__( 'Fade In', 'Divi' ), 'off' => esc_html__( 'No Animation', 'Divi' ), ) ); } endif; if ( ! function_exists( 'et_divi_divider_style_choices' ) ) : /** * Returns divider style choices * @return array */ function et_divi_divider_style_choices() { return apply_filters( 'et_divi_divider_style_choices', array( 'solid' => esc_html__( 'Solid', 'Divi' ), 'dotted' => esc_html__( 'Dotted', 'Divi' ), 'dashed' => esc_html__( 'Dashed', 'Divi' ), 'double' => esc_html__( 'Double', 'Divi' ), 'groove' => esc_html__( 'Groove', 'Divi' ), 'ridge' => esc_html__( 'Ridge', 'Divi' ), 'inset' => esc_html__( 'Inset', 'Divi' ), 'outset' => esc_html__( 'Outset', 'Divi' ), ) ); } endif; if ( ! function_exists( 'et_divi_divider_position_choices' ) ) : /** * Returns divider position choices * @return array */ function et_divi_divider_position_choices() { return apply_filters( 'et_divi_divider_position_choices', array( 'top' => esc_html__( 'Top', 'Divi' ), 'center' => esc_html__( 'Vertically Centered', 'Divi' ), 'bottom' => esc_html__( 'Bottom', 'Divi' ), ) ); } endif; if ( ! function_exists( 'et_divi_background_repeat_choices' ) ) : /** * Returns background repeat choices * @return array */ function et_divi_background_repeat_choices() { return apply_filters( 'et_divi_background_repeat_choices', array( 'no-repeat' => esc_html__( 'No Repeat', 'Divi' ), 'repeat' => esc_html__( 'Tile', 'Divi' ), 'repeat-x' => esc_html__( 'Tile Horizontally', 'Divi' ), 'repeat-y' => esc_html__( 'Tile Vertically', 'Divi' ), ) ); } endif; if ( ! function_exists( 'et_divi_background_attachment_choices' ) ) : /** * Returns background attachment choices * @return array */ function et_divi_background_attachment_choices() { return apply_filters( 'et_divi_background_attachment_choices', array( 'scroll' => esc_html__( 'Scroll', 'Divi' ), 'fixed' => esc_html__( 'Fixed', 'Divi' ), ) ); } endif; , $blue ); if ( ( $red >= 0 && $red <= 255 ) && ( $green >= 0 && $green <= 255 ) && ( $blue >= 0 && $blue <= 255 ) ) { return "rgb({$red},{$green},{$blue})"; } } // If this is rgba, validate and return it elseif ( 'rgba(' === substr( $color, 0, 5 ) ) { sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha ); if ( ( $red >= 0 && $red <= 255 ) && ( $green >= 0 && $green <= 255 ) && ( $blue >= 0 && $blue <= 255 ) && $alpha >= 0 && $alpha <= 1 ) { return "rgba({$red},{$green},{$blue},{$alpha})"; } } elseif ( preg_match( '/^(?:var\(--gcid-[\w\d-]+(?:,\s*[^)]+)?\)|gcid-[\w\d-]+)$/', $color ) ) { // above regex test: https://regex101.com/r/jIhZwg/1. return $color; } elseif ( preg_match( '/^\$variable\((.+)\)\$$/', $color, $matches ) ) { // If this is a Divi 5 dynamic content variable, validate structure and return it. // Regex test: https://regex101.com/r/M0uLa8/1 // Additional security: Validate JSON structure inside $variable(...)$. $json_content = $matches[1]; // Extract content between $variable( and )$. $decoded = json_decode( $json_content, true ); // Ensure it's valid JSON with expected structure for color variables. if ( null !== $decoded && is_array( $decoded ) && isset( $decoded['type'] ) && 'color' === $decoded['type'] && isset( $decoded['value'] ) && is_array( $decoded['value'] ) && isset( $decoded['value']['name'] ) && is_string( $decoded['value']['name'] ) && preg_match( '/^gcid-[\w\d-]+$/', $decoded['value']['name'] ) // Validate gcid format. ) { return $color; } } return false; } /** * Sanitize font icon * @param string * @param string * @return string */ function et_sanitize_font_icon( $font_icon, $symbols_function = 'default' ) { // Convert symbols into strings $font_icon = trim( $font_icon ); // @phpcs:ignore Generic.PHP.ForbiddenFunctions.Found $icon_symbols = is_callable( $symbols_function ) ? call_user_func( $symbols_function ) : et_pb_get_font_icon_symbols(); $icon_symbols = array_map( 'et_sanitize_font_icon_convert_icon_to_string', $icon_symbols ); // the exact font icon value is saved if ( 1 !== preg_match( "/^%%/", $font_icon ) ) { return in_array( $font_icon, $icon_symbols ) ? $font_icon : ''; } // the font icon value is saved in the following format: %%index_number%% // strip the %'s to get to end result: index_number $icon_index = (int) str_replace( '%', '', $font_icon ); return isset( $icon_symbols[ $icon_index ] ) ? $icon_symbols[ $icon_index ] : ''; } /** * Convert font hex-code font icons into strings so it can be compared * @param string * @return string */ function et_sanitize_font_icon_convert_icon_to_string( $icon ) { // Replace & with &. Otherwise, it'll incorrectly decoded $icon = str_replace( '&', '&', $icon ); // Decode return html_entity_decode( $icon ); } /** * Array of allowed html tags on short block * @return array */ function et_allowed_html_tags_short_block() { $allowed_tags = array( 'div' => array( 'class' => array(), 'id' => array(), ), 'span' => array( 'class' => array(), 'id' => array(), ), 'ol' => array( 'class' => array(), 'id' => array(), ), 'ul' => array( 'class' => array(), 'id' => array(), ), 'li' => array( 'class' => array(), 'id' => array(), ), 'p' => array( 'class' => array(), 'id' => array(), ), 'a' => array( 'href' => array(), 'class' => array(), 'id' => array(), 'rel' => array(), 'title' => array(), 'target' => array(), ), 'br' => array(), 'em' => array(), 'strong' => array(), ); return apply_filters( 'et_allowed_html_tags_short_block', $allowed_tags ); } /** * Sanitize short block html input * @return string */ function et_sanitize_html_input_text( $string ) { return wp_kses( $string, et_allowed_html_tags_short_block() ); } /** * Sanitize background repeat value * @return string */ function et_sanitize_background_repeat( $choosen ) { return et_sanitize_key_based_option( $ https://cesi.umbria.it/