if ( empty( $cats_array ) ) {
$taxonomy_type = $args['use_terms'] ? $args['term_name'] : 'category';
$taxonomy = get_taxonomy( $taxonomy_type );
$labels = get_taxonomy_labels( $taxonomy );
$output = sprintf( '<p>%1$s</p>', esc_html( $labels->not_found ) );
foreach ( $cats_array as $category ) {
"<%%= _.contains( {$args['field_name']}_temp, '%1\$s' ) ? checked='checked' : '' %%>",
is_array( $category ) ? esc_html( $category['term_id'] ) : esc_html( $category->term_id )
'%4$s<label><input type="checkbox" name="%5$s" value="%1$s"%3$s> %2$s</label><br/>',
is_array( $category ) ? esc_html( $category['term_id'] ) : esc_html( $category->term_id ),
is_array( $category ) ? esc_html( $category['name'] ) : esc_html( $category->name ),
$output = "<div id='{$args['field_name']}'>" . $output . '</div>';
return apply_filters( 'et_builder_include_categories_option_html', $output );
if ( ! function_exists( 'et_builder_include_categories_shop_option' ) ) :
* Generate output string for `include_shop_categories` option used in backbone template.
* @param array $args arguments to get shop categories.
function et_builder_include_categories_shop_option( $args = array() ) {
if ( ! class_exists( 'WooCommerce' ) ) {
$output = "\t<% var et_pb_include_categories_shop_temp = typeof data !== 'undefined' && typeof data.et_pb_include_categories !== 'undefined' ? data.et_pb_include_categories.split( ',' ) : []; et_pb_include_categories_shop_temp = typeof data === 'undefined' && typeof et_pb_include_categories !== 'undefined' ? et_pb_include_categories.split( ',' ) : et_pb_include_categories_shop_temp; %>\n";
$product_categories = et_builder_get_shop_categories( $args );
$output .= '<div id="et_pb_include_categories">';
if ( is_array( $product_categories ) && ! empty( $product_categories ) ) {
foreach ( $product_categories as $category ) {
if ( is_object( $category ) && is_a( $category, 'WP_Term' ) ) {
'<%%= _.contains( et_pb_include_categories_shop_temp, "%1$s" ) ? checked="checked" : "" %%>',
esc_html( $category->term_id )
'%4$s<label><input type="checkbox" name="et_pb_include_categories" value="%1$s"%3$s> %2$s</label><br/>',
esc_attr( $category->term_id ),
esc_html( $category->name ),
return apply_filters( 'et_builder_include_categories_option_html', $output );
if ( ! function_exists( 'et_divi_get_projects' ) ) :
* @param array $args WP_Query arguments.
function et_divi_get_projects( $args = array() ) {
'post_type' => 'project',
$args = wp_parse_args( $args, $default_args );
return new WP_Query( $args );
if ( ! function_exists( 'et_pb_extract_items' ) ) :
* Return pricing table items html.
* @param string $content Content.
function et_pb_extract_items( $content ) {
$lines = array_filter( explode( "\n", str_replace( array( '<p>', '</p>', '<br />' ), "\n", $content ) ) );
foreach ( $lines as $line ) {
if ( '–' === substr( $line, 0, 7 ) ) {
$line = '-' . substr( $line, 7 );
$first_character = $line[0];
if ( in_array( $first_character, array( '-', '+' ), true ) ) {
$line = trim( substr( $line, 1 ) );
'[et_pb_pricing_item available="%2$s"]%1$s[/et_pb_pricing_item]',
( '-' === $first_character ? 'off' : 'on' )
return do_shortcode( $output );
* Get all acceptable string value for given CSS property
* @param string $property property name.
* @return array of acceptable CSS string values of given property name.
function et_builder_get_acceptable_css_string_values( $property = 'all' ) {
$css_string_values = array(
'font-size' => array( '%', 'em', 'rem', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw' ),
$acceptable_strings = apply_filters( 'et_builder_acceptable_css_string_values', $css_string_values );
if ( 'all' === $property ) {
return $acceptable_strings;
return isset( $acceptable_strings[ $property ] ) ? $acceptable_strings[ $property ] : array();
if ( ! function_exists( 'et_builder_process_range_value' ) ) :
* Process range setting field value.
* @param string $range Range value.
* @param string $option_type CSS property.
function et_builder_process_range_value( $range, $option_type = '' ) {
if ( 'none' !== $range ) {
$range_digit = floatval( $range );
$range_string = str_replace( et_()->to_css_decimal( $range_digit ), '', (string) $range );
if ( '' !== $option_type && in_array( $range, et_builder_get_acceptable_css_string_values( $option_type ), true ) ) {
if ( '' === $range_string ) {
$range_string = 'line_height' === $option_type && 3 >= $range_digit ? 'em' : 'px';
$result = et_()->to_css_decimal( $range_digit ) . $range_string;
return apply_filters( 'et_builder_processed_range_value', $result, $range, $range_string );
if ( ! function_exists( 'et_builder_get_border_styles' ) ) :
* Return border styles options list.
function et_builder_get_border_styles() {
'solid' => esc_html__( 'Solid', 'et_builder' ),
'dashed' => esc_html__( 'Dashed', 'et_builder' ),
'dotted' => esc_html__( 'Dotted', 'et_builder' ),
'double' => esc_html__( 'Double', 'et_builder' ),
'groove' => esc_html__( 'Groove', 'et_builder' ),
'ridge' => esc_html__( 'Ridge', 'et_builder' ),
'inset' => esc_html__( 'Inset', 'et_builder' ),
'outset' => esc_html__( 'Outset', 'et_builder' ),
'none' => et_builder_i18n( 'None' ),
return apply_filters( 'et_builder_border_styles', $styles );
if ( ! function_exists( 'et_builder_font_options' ) ) :
* Return an array of font options.
function et_builder_font_options() {
$default_options = array(
'name' => et_builder_i18n( 'Default' ),
$fonts = array_merge( $default_options, et_builder_get_fonts() );
foreach ( $fonts as $font_name => $font_settings ) {
$options[ $font_name ] = 'default' !== $font_name ? $font_name : $font_settings['name'];
if ( ! function_exists( 'et_builder_get_google_font_items' ) ) :
* Return google font list items.
function et_builder_get_google_font_items() {
$font_options = et_builder_font_options();
foreach ( $font_options as $key => $value ) {
'<li class="select-option-item select-option-item-%3$s" data-value="%1$s">%2$s</li>',
str_replace( ' ', '_', esc_attr( $key ) )
if ( ! function_exists( 'et_builder_set_element_font' ) ) :
* Return element font style.
* @param string $font Font style value.
* @param bool $use_important Whether use !important.
* @param bool $default Default font style value. e.x global font value.
function et_builder_set_element_font( $font, $use_important = false, $default = false ) {
$font_values = explode( '|', $font );
$default = ! $default ? '||||||||' : $default;
$font_values_default = explode( '|', $default );
if ( ! empty( $font_values ) ) {
// backward compatibility with old version of theme.
if ( isset( $font_values[1] ) ) {
$font_values[1] = 'on' === $font_values[1] ? '700' : $font_values[1];
$font_values = array_map( 'trim', $font_values );
$font_name = $font_values[0];
$font_weight = isset( $font_values[1] ) && '' !== $font_values[1] ? $font_values[1] : '';
$is_font_italic = isset( $font_values[2] ) && 'on' === $font_values[2] ? true : false;
$is_font_uppercase = isset( $font_values[3] ) && 'on' === $font_values[3] ? true : false;
$is_font_underline = isset( $font_values[4] ) && 'on' === $font_values[4] ? true : false;
$is_font_small_caps = isset( $font_values[5] ) && 'on' === $font_values[5] ? true : false;
$is_font_line_through = isset( $font_values[6] ) && 'on' === $font_values[6] ? true : false;
$font_line_color = isset( $font_values[7] ) ? $font_values[7] : '';
$font_line_style = isset( $font_values[8] ) ? $font_values[8] : '';
$font_name_default = $font_values_default[0];
$font_weight_default = isset( $font_values_default[1] ) && '' !== $font_values_default[1] ? $font_values_default[1] : '';
$is_font_italic_default = isset( $font_values_default[2] ) && 'on' === $font_values_default[2] ? true : false;
$is_font_uppercase_default = isset( $font_values_default[3] ) && 'on' === $font_values_default[3] ? true : false;
$is_font_underline_default = isset( $font_values_default[4] ) && 'on' === $font_values_default[4] ? true : false;
$is_font_small_caps_default = isset( $font_values_default[5] ) && 'on' === $font_values_default[5] ? true : false;
$is_font_line_through_default = isset( $font_values_default[6] ) && 'on' === $font_values_default[6] ? true : false;
$font_line_color_default = isset( $font_values_default[7] ) ? $font_values_default[7] : '';
$font_line_style_default = isset( $font_values_default[8] ) ? $font_values_default[8] : '';
if ( '' !== $font_name && $font_name_default !== $font_name && 'Default' !== $font_name ) {
if ( empty( $cache[ $font_name ] ) ) {
et_builder_enqueue_font( $font_name );
$font_family = et_builder_get_font_family( $font_name );
$cache[ $font_name ] = $font_family;
$font_family = $cache[ $font_name ];
$font_family = rtrim( $font_family, ';' ) . ' !important;';
$style .= "$font_family ";
$style .= et_builder_set_element_font_style( 'font-weight', ( '' !== $font_weight_default && ( '' === $font_weight || $font_weight_default === $font_weight ) ), ( '' !== $font_weight ), 'normal', $font_weight, $use_important );
$style .= et_builder_set_element_font_style( 'font-style', $is_font_italic_default, $is_font_italic, 'normal', 'italic', $use_important );
$style .= et_builder_set_element_font_style( 'text-transform', $is_font_uppercase_default, $is_font_uppercase, 'none', 'uppercase', $use_important );
$style .= et_builder_set_element_font_style( 'text-decoration', $is_font_underline_default, $is_font_underline, 'none', 'underline', $use_important );
$style .= et_builder_set_element_font_style( 'font-variant', $is_font_small_caps_default, $is_font_small_caps, 'none', 'small-caps', $use_important );
$style .= et_builder_set_element_font_style( 'text-decoration', $is_font_line_through_default, $is_font_line_through, 'none', 'line-through', $use_important );
$style .= et_builder_set_element_font_style( 'text-decoration-style', ( '' !== $font_line_style_default ), ( '' !== $font_line_style ), 'solid', $font_line_style, $use_important );
$style .= et_builder_set_element_font_style( '-webkit-text-decoration-color', ( '' !== $font_line_color_default ), ( '' !== $font_line_color ), '', $font_line_color, $use_important );
$style .= et_builder_set_element_font_style( 'text-decoration-color', ( '' !== $font_line_color_default ), ( '' !== $font_line_color ), '', $font_line_color, $use_important );
$style = rtrim( $style );
if ( ! function_exists( 'et_builder_set_element_font_style' ) ) :
* Set element font style.
* @param string $property CSS property.
* @param bool $default @todo Add parameter doc.
* @param bool $value @todo Add parameter doc.
* @param string $property_default @todo Add parameter doc.
* @param string $property_value Property value.
* @param string $use_important Whether use !important specificity.
function et_builder_set_element_font_style( $property, $default, $value, $property_default, $property_value, $use_important ) {
if ( $value && ! $default ) {
( $use_important ? ' !important' : '' )
} elseif ( ! $value && $default ) {
( $use_important ? ' !important' : '' )
if ( ! function_exists( 'et_builder_set_reset_font_style' ) ) :
* Set reset CSS style declaration to normalize the existing font styles value from another font
* @param string $current_value Current font option value.
* @param string $compared_value Compared or parent font option value.
* @param boolean $use_important Imporant status.
* @return string Generated reset font styles.
function et_builder_set_reset_font_style( $current_value, $compared_value, $use_important = false ) {
// Being save, ensure current and compared values are valid string.
if ( ! is_string( $current_value ) || ! is_string( $compared_value ) ) {
$current_pieces = explode( '|', $current_value );
$compared_pieces = explode( '|', $compared_value );
if ( empty( $current_pieces ) || empty( $compared_pieces ) ) {
// Current value font style status.
$is_current_italic = isset( $current_pieces[2] ) && 'on' === $current_pieces[2];
$is_current_uppercase = isset( $current_pieces[3] ) && 'on' === $current_pieces[3];
$is_current_underline = isset( $current_pieces[4] ) && 'on' === $current_pieces[4];
$is_current_small_caps = isset( $current_pieces[5] ) && 'on' === $current_pieces[5];
$is_current_line_through = isset( $current_pieces[6] ) && 'on' === $current_pieces[6];
// Compated value font style status.
$is_compared_italic = isset( $compared_pieces[2] ) && 'on' === $compared_pieces[2];
$is_compared_uppercase = isset( $compared_pieces[3] ) && 'on' === $compared_pieces[3];
$is_compared_underline = isset( $compared_pieces[4] ) && 'on' === $compared_pieces[4];
$is_compared_small_caps = isset( $compared_pieces[5] ) && 'on' === $compared_pieces[5];
$is_compared_line_through = isset( $compared_pieces[6] ) && 'on' === $compared_pieces[6];
$important = $use_important ? ' !important' : '';
if ( ! $is_current_italic && $is_compared_italic ) {
$style .= "font-style: normal{$important};";
if ( ! $is_current_uppercase && $is_compared_uppercase ) {
$style .= "text-transform: none{$important};";
if ( ! $is_current_small_caps && $is_compared_small_caps ) {
$style .= "font-variant: none{$important};";
if ( ! $is_current_underline && $is_compared_underline ) {
$underline_value = $is_current_line_through || $is_compared_line_through ? 'line-through' : 'none';
$style .= "text-decoration: {$underline_value}{$important};";
if ( ! $is_current_line_through && $is_compared_line_through ) {
$line_through_value = $is_current_underline || $is_compared_underline ? 'underline' : 'none';
$style .= "text-decoration: {$line_through_value}{$important};";
if ( ! function_exists( 'et_builder_get_element_style_css' ) ) :
* Return element css style.
* @param string $value Property value.
* @param string $property Css property.
* @param bool $use_important Whether add !important specificity.
function et_builder_get_element_style_css( $value, $property = 'margin', $use_important = false ) {
$values = explode( '|', $value );
if ( ! empty( $values ) ) {
$values = array_map( 'trim', $values );
foreach ( $positions as $i => $position ) {
if ( ! isset( $values[ $i ] ) || '' === $values[ $i ] ) {