Fix File
•
/
home
/
sportsfe...
/
httpdocs
/
clone
/
wp-conte...
/
themes
/
Divi
/
includes
/
builder
•
File:
functions.php
•
Content:
$saved_value = et_get_option( $setting_name ); if ( $saved_value && $saved_value === $string_value ) { return; } flush_rewrite_rules(); et_update_option( $setting_name, $string_value ); } endif; /** * Flush rewrite rules to fix the issue Layouts, not being visible on front-end and visual builder, * if pretty permalinks were enabled * @return void */ function et_pb_maybe_flush_rewrite_rules_library() { // Run flush rewrite only when et_pb_layout post type registered. if ( post_type_exists( 'et_pb_layout' ) ) { et_builder_maybe_flush_rewrite_rules( 'et_flush_rewrite_rules_library', ET_BUILDER_PRODUCT_VERSION ); } } add_action( 'init', 'et_pb_maybe_flush_rewrite_rules_library', 9 ); /** * Remove et_builder_maybe_flush_rewrite_rules flag if flush_rewrite_rules() is called while * `et_pb_layout` post type hasn't been registered * * @since 3.19.18 * * @param string|array $old_value * @param string|array $value * @param string $option */ function et_pb_maybe_remove_flush_rewrite_rules_library_flag( $old_value, $value, $option ) { // rewrite rules for CPT that are rebuilt by flush_rewrite_rules() are based on // get_post_types( array( '_builtin' => false ) ) value; Hence if flush_rewrite_rules() is // executed while `et_pb_layout` CPT hasn't been registered (usually by third party plugin) // et_pb_maybe_flush_rewrite_rules_library() flag has to be removed to trigger flush_rewrite_rules() // via et_pb_maybe_flush_rewrite_rules_library() which contains `et_pb_layout` rewrite rules // because et_pb_maybe_flush_rewrite_rules_library() checks for `et_pb_layout` first. if ( '' === $value && ! post_type_exists( 'et_pb_layout' ) ) { et_update_option( 'et_flush_rewrite_rules_library', '' ); } } add_action( 'update_option_rewrite_rules', 'et_pb_maybe_remove_flush_rewrite_rules_library_flag', 10, 3 ); /** * Get list of shortcut available on BB and FB * @param string (fb|bb) shortcut mode * @return array shortcut list */ if ( ! function_exists( 'et_builder_get_shortcuts' ) ) : function et_builder_get_shortcuts( $on = 'fb' ) { $shortcuts = apply_filters('et_builder_get_shortcuts', array( 'page' => array( 'page_title' => array( 'title' => esc_html__( 'Page Shortcuts', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'undo' => array( 'kbd' => array( 'super', 'z' ), 'desc' => esc_html__( 'Undo', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'redo' => array( 'kbd' => array( 'super', 'y' ), 'desc' => esc_html__( 'Redo', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'save' => array( 'kbd' => array( 'super', 's' ), 'desc' => esc_html__( 'Save Page', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'save_as_draft' => array( 'kbd' => array( 'super', 'shift' , 's'), 'desc' => esc_html__( 'Save Page As Draft', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'exit' => array( 'kbd' => array( 'super', 'e' ), 'desc' => esc_html__( 'Exit Visual Builder', 'et_builder' ), 'on' => array( 'fb', ), ), 'exit_to_backend_builder' => array( 'kbd' => array( 'super', 'shift', 'e' ), 'desc' => esc_html__( 'Exit To Backend Builder', 'et_builder' ), 'on' => array( 'fb', ), ), 'toggle_settings_bar' => array( 'kbd' => array( 't' ), 'desc' => esc_html__( 'Toggle Settings Bar', 'et_builder' ), 'on' => array( 'fb', ), ), 'open_page_settings' => array( 'kbd' => array( 'o' ), 'desc' => esc_html__( 'Open Page Settings', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'open_history' => array( 'kbd' => array( 'h' ), 'desc' => esc_html__( 'Open History Window', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'open_portability' => array( 'kbd' => array( 'p' ), 'desc' => esc_html__( 'Open Portability Window', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'zoom_in' => array( 'kbd' => array( 'super', '+' ), 'desc' => esc_html__( 'Responsive Zoom In', 'et_builder' ), 'on' => array( 'fb', ), ), 'zoom_out' => array( 'kbd' => array( 'super', '-' ), 'desc' => esc_html__( 'Responsive Zoom Out', 'et_builder' ), 'on' => array( 'fb', ), ), 'wireframe' => array( 'kbd' => array( 'shift', 'w' ), 'desc' => esc_html__( 'Wireframe Mode', 'et_builder' ), 'on' => array( 'fb', ), ), 'click_mode' => array( 'kbd' => array( 'super', 'shift', 'c' ), 'desc' => esc_html__( 'Click Mode', 'et_builder' ), 'on' => array( 'fb', ), ), 'grid_mode' => array( 'kbd' => array( 'super', 'shift', 'g' ), 'desc' => esc_html__( 'Grid Mode', 'et_builder' ), 'on' => array( 'fb', ), ), 'hover_mode' => array( 'kbd' => array( 'super', 'shift', 'h' ), 'desc' => esc_html__( 'Hover Mode', 'et_builder' ), 'on' => array( 'fb', ), ), 'help' => array( 'kbd' => array( '?' ), 'desc' => esc_html__( 'List All Shortcuts', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), ), 'inline' => array( 'inline_title' => array( 'title' => esc_html__( 'Inline Editor Shortcuts', 'et_builder' ), 'on' => array( 'fb', ), ), 'escape' => array( 'kbd' => array( 'esc' ), 'desc' => esc_html__( 'Exit Inline Editor', 'et_builder' ), 'on' => array( 'fb', ), ), ), 'module' => array( 'module_title' => array( 'title' => esc_html__( 'Module Shortcuts', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'module_copy' => array( 'kbd' => array( 'super', 'c' ), 'desc' => esc_html__( 'Copy Module', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'module_cut' => array( 'kbd' => array( 'super', 'x' ), 'desc' => esc_html__( 'Cut Module', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'module_paste' => array( 'kbd' => array( 'super', 'v' ), 'desc' => esc_html__( 'Paste Module', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'module_copy_styles' => array( 'kbd' => array( 'super', 'alt', 'c' ), 'desc' => esc_html__( 'Copy Module Styles', 'et_builder' ), 'on' => array( 'fb', ), ), 'module_paste_styles' => array( 'kbd' => array( 'super', 'alt', 'v' ), 'desc' => esc_html__( 'Paste Module Styles', 'et_builder' ), 'on' => array( 'fb', ), ), 'module_reset_styles' => array( 'kbd' => array( 'super', 'alt', 'r' ), 'desc' => esc_html__( 'Reset Module Styles', 'et_builder' ), 'on' => array( 'fb', ), ), 'module_lock' => array( 'kbd' => array( 'super', 'shift', 'l' ), 'desc' => esc_html__( 'Lock Module', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'module_disable' => array( 'kbd' => array( 'super', 'shift', 'd' ), 'desc' => esc_html__( 'Disable Module', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'drag_auto_copy' => array( 'kbd' => array( 'alt', 'module move' ), 'desc' => esc_html__( 'Move and copy module into dropped location', 'et_builder' ), 'on' => array( 'fb', ), ), 'column_change_structure' => array( 'kbd' => array( 'c', array( '1', '2', '3', '4', '5', '...' ) ), 'desc' => esc_html__( 'Change Column Structure', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'row_make_fullwidth' => array( 'kbd' => array( 'r', 'f' ), 'desc' => esc_html__( 'Make Row Fullwidth', 'et_builder' ), 'on' => array( 'fb', ), ), 'row_edit_gutter' => array( 'kbd' => array( 'g', array( '1', '2', '3', '4' ) ), 'desc' => esc_html__( 'Change Gutter Width', 'et_builder' ), 'on' => array( 'fb', ), ), 'add_new_row' => array( 'kbd' => array( 'r', array( '1', '2', '3', '4', '5', '...') ), 'desc' => esc_html__( 'Add New Row', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'add_new_section' => array( 'kbd' => array( 's', array( '1', '2', '3' ) ), 'desc' => esc_html__( 'Add New Section', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'resize_padding_auto_opposite' => array( 'kbd' => array( 'shift', 'Drag Padding' ), 'desc' => esc_html__( 'Restrict padding to 10px increments', 'et_builder' ), 'on' => array( 'fb', ), ), 'resize_padding_limited' => array( 'kbd' => array( 'alt', 'Drag Padding' ), 'desc' => esc_html__( 'Padding limited to opposing value', 'et_builder' ), 'on' => array( 'fb', ), ), 'resize_padding_10' => array( 'kbd' => array( 'shift', 'alt', 'Drag Padding' ), 'desc' => esc_html__( 'Mirror padding on both sides', 'et_builder' ), 'on' => array( 'fb', ), ), 'increase_padding_row' => array( 'kbd' => array( 'r', array( 'left', 'right', 'up', 'down' ) ), 'desc' => esc_html__( 'Increase Row Padding', 'et_builder' ), 'on' => array( 'fb', ), ), 'decrease_padding_row' => array( 'kbd' => array( 'r', 'alt', array( 'left', 'right', 'up', 'down' ) ), 'desc' => esc_html__( 'Decrease Row Padding', 'et_builder' ), 'on' => array( 'fb', ), ), 'increase_padding_section' => array( 'kbd' => array( 's', array( 'left', 'right', 'up', 'down' ) ), 'desc' => esc_html__( 'Increase Section Padding', 'et_builder' ), 'on' => array( 'fb', ), ), 'decrease_padding_section' => array( 'kbd' => array( 's', 'alt', array( 'left', 'right', 'up', 'down' ) ), 'desc' => esc_html__( 'Decrease Section Padding', 'et_builder' ), 'on' => array( 'fb', ), ), 'increase_padding_module' => array( 'kbd' => array( 'm', array( 'left', 'right', 'up', 'down' ) ), 'desc' => esc_html__( 'Increase Module Padding', 'et_builder' ), 'on' => array( 'fb', ), ), 'decrease_padding_module' => array( 'kbd' => array( 'm', 'alt', array( 'left', 'right', 'up', 'down' ) ), 'desc' => esc_html__( 'Decrease Module Padding', 'et_builder' ), 'on' => array( 'fb', ), ), 'increase_padding_row_10' => array( 'kbd' => array( 'r', 'shift', array( 'left', 'right', 'up', 'down' ) ), 'desc' => esc_html__( 'Increase Row Padding By 10px', 'et_builder' ), 'on' => array( 'fb', ), ), 'decrease_padding_row_10' => array( 'kbd' => array( 'r', 'alt', 'shift', array( 'left', 'right', 'up', 'down' ) ), 'desc' => esc_html__( 'Decrease Row Padding By 10px', 'et_builder' ), 'on' => array( 'fb', ), ), 'increase_padding_section_10' => array( 'kbd' => array( 's', 'shift', array( 'left', 'right', 'up', 'down' ) ), 'desc' => esc_html__( 'Increase Section Padding By 10px', 'et_builder' ), 'on' => array( 'fb', ), ), 'decrease_padding_section_10' => array( 'kbd' => array( 's', 'alt', 'shift', array( 'left', 'right', 'up', 'down' ) ), 'desc' => esc_html__( 'Decrease Section Padding By 10px', 'et_builder' ), 'on' => array( 'fb', ), ), 'increase_padding_module_10' => array( 'kbd' => array( 'm', 'shift', array( 'left', 'right', 'up', 'down' ) ), 'desc' => esc_html__( 'Increase Module Padding By 10px', 'et_builder' ), 'on' => array( 'fb', ), ), 'decrease_padding_module_10' => array( 'kbd' => array( 'm', 'alt', 'shift', array( 'left', 'right', 'up', 'down' ) ), 'desc' => esc_html__( 'Decrease Module Padding By 10px', 'et_builder' ), 'on' => array( 'fb', ), ), ), 'modal' => array( 'modal_title' => array( 'title' => esc_html__( 'Modal Shortcuts', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'escape' => array( 'kbd' => array( 'esc' ), 'desc' => esc_html__( 'Close Modal', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'save_changes' => array( 'kbd' => array( 'enter' ), 'desc' => esc_html__( 'Save Changes', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'undo' => array( 'kbd' => array( 'super', 'z' ), 'desc' => esc_html__( 'Undo', 'et_builder' ), 'on' => array( 'fb', ), ), 'redo' => array( 'kbd' => array( 'super', 'shift', 'z' ), 'desc' => esc_html__( 'Redo', 'et_builder' ), 'on' => array( 'fb', ), ), 'switch_tabs' => array( 'kbd' => array( 'shift', 'tab' ), 'desc' => esc_html__( 'Switch Tabs', 'et_builder' ), 'on' => array( 'fb', 'bb', ), ), 'toggle_expand' => array( 'kbd' => array( 'super', 'enter' ), 'desc' => esc_html__( 'Expand Modal Fullscreen', 'et_builder' ), 'on' => array( 'fb', ), ), 'toggle_snap' => array( 'kbd' => array( 'super', array( 'left', 'right' ) ), 'desc' => esc_html__( 'Snap Modal Left / Right', 'et_builder' ), 'on' => array( 'fb', ), ), 'quick_actions' => array( 'kbd' => array( 'shift', 'space' ), 'desc' => esc_html__( 'Quick Actions', 'et_builder' ), 'on' => array( 'fb', ), ), 'layers_view' => array( 'kbd' => array( 'super', 'l' ), 'desc' => esc_html__( 'Layers View', 'et_builder' ), 'on' => array( 'fb', ), ), ), ) ); // Filter shortcuts $filtered_shortcuts = array(); foreach ($shortcuts as $group_key => $group) { foreach ($group as $shortcut_key => $shortcut) { if ( in_array( $on, $shortcut['on'] ) ) { $filtered_shortcuts[ $group_key ][ $shortcut_key ] = $shortcut; } } } return $filtered_shortcuts; } endif; /** * Parsed *_last_edited value and determine wheter the passed string means it has responsive value or not * *_last_edited holds two values (responsive status and last opened tabs) in the following format: status|last_opened_tab * @param string last_edited data * @return bool */ if ( ! function_exists( 'et_pb_get_responsive_status' ) ) : function et_pb_get_responsive_status( $last_edited ) { $parsed_last_edited = is_string( $last_edited ) ? explode( '|', $last_edited ) : array( 'off', 'desktop' ); return isset( $parsed_last_edited[0] ) ? $parsed_last_edited[0] === 'on' : false; } endif; /** * Get unit of given value * @param string string with unit * @return string unit name */ if ( ! function_exists( 'et_pb_get_value_unit' ) ) : function et_pb_get_value_unit( $value, $default_unit = 'px' ) { $value = isset( $value ) ? $value : ''; $valid_one_char_units = array( "%", 'x' ); $valid_two_chars_units = array( "em", "px", "cm", "mm", "in", "pt", "pc", "ex", "vh", "vw", "ms" ); $valid_three_chars_units = array( 'deg', 'rem' ); $important = "!important"; $important_length = strlen( $important ); $value_length = strlen( $value ); if ( $value === '' || is_numeric( $value ) ) { return $default_unit; } if ( substr( $value, ( 0 - $important_length ), $important_length ) === $important ) { $value_length = $value_length - $important_length; $value = substr( $value, 0, $value_length ).trim(); } if ( in_array( substr( $value, -3, 3 ), $valid_three_chars_units ) ) { return substr( $value, -3, 3 ); } if ( in_array( substr( $value, -2, 2 ), $valid_two_chars_units ) ) { return substr( $value, -2, 2 ); } if ( in_array( substr( $value, -1, 1 ), $valid_one_char_units ) ) { return substr( $value, -1, 1 ); } return $default_unit; } endif; /** * Sanitized value and its unit * @param mixed * @param string * @param string|bool * * @return string sanitized input and its unit */ if ( ! function_exists( 'et_sanitize_input_unit' ) ) : function et_sanitize_input_unit( $value = '', $auto_important = false, $default_unit = false ) { $value = (string) $value; $valid_one_char_units = array( '%', 'x' ); $valid_two_chars_units = array( 'em', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw', 'ms' ); $valid_three_chars_units = array( 'deg', 'rem' ); $important = '!important'; $important_length = strlen( $important ); $has_important = false; $value_length = strlen( $value ); $unit_value; // Check for important if ( substr( $value, ( 0 - $important_length ), $important_length ) === $important ) { $has_important = true; $value_length = $value_length - $important_length; $value = trim( substr( $value, 0, $value_length ) ); } if ( in_array( substr( $value, -3, 3 ), $valid_three_chars_units ) ) { $unit_value = floatval( $value ) . substr( $value, -3, 3 ); // Re-add !important tag if ( $has_important && ! $auto_important ) { $unit_value = $unit_value . ' ' . $important; } return $unit_value; } if ( in_array( substr( $value, -2, 2 ), $valid_two_chars_units ) ) { $unit_value = floatval( $value ) . substr( $value, -2, 2 ); // Re-add !important tag if ( $has_important && ! $auto_important ) { $unit_value = $unit_value . ' ' . $important; } return $unit_value; } if ( in_array( substr( $value, -1, 1 ), $valid_one_char_units ) ) { $unit_value = floatval( $value ) . substr( $value, -1, 1 ); // Re-add !important tag if ( $has_important && ! $auto_important ) { $unit_value = $unit_value . ' ' . $important; } return $unit_value; } $result = floatval( $value ); if ( 'no_default_unit' === $default_unit ) { return $result; } if ( $default_unit ) { return $result . $default_unit; } if ( ! $default_unit ) { $result .= 'px'; } // Return and automatically append px (default value) return $result; } endif; /** * Get taxonomies for modules * * @return array Array of WP taxonomies splitted into the taxonomy types */ if ( ! function_exists( 'et_builder_get_taxonomies' ) ) : function et_builder_get_shop_categories( $args = array() ) { $defaults = apply_filters( 'et_builder_include_categories_shop_defaults', array ( 'use_terms' => true, 'term_name' => 'product_cat', ) ); $term_args = apply_filters( 'et_builder_include_categories_shop_args', array( 'hide_empty' => false, ) ); $args = wp_parse_args( $args, $defaults ); $product_categories = $args['use_terms'] ? get_terms( $args['term_name'], $term_args ) : get_categories( apply_filters( 'et_builder_get_categories_shop_args', 'hide_empty=0' ) ); return $product_categories; } endif; if ( ! function_exists( 'et_pb_get_spacing' ) ): function et_pb_get_spacing( $spacing, $corner, $default = '0px' ) { $corners = array( 'top', 'right', 'bottom', 'left' ); $corner_index = array_search( $corner, $corners ); $spacing_array = explode( '|', $spacing ); return isset( $spacing_array[ $corner_index ] ) && '' !== $spacing_array[ $corner_index ] ? $spacing_array[ $corner_index ] : $default; } endif; /** * Enqueue a bundle */ if ( ! function_exists( 'et_fb_enqueue_bundle' ) ) : function et_fb_enqueue_bundle( $id, $resource, $deps, $ver = false ) { $DEBUG = defined( 'ET_DEBUG' ) && ET_DEBUG; $ver = false === $ver ? ET_BUILDER_VERSION : $ver; $build = 'frontend-builder/build'; $bundle = sprintf( '%s/%s/%s', ET_BUILDER_URI, $build, $resource ); $type = pathinfo( $resource, PATHINFO_EXTENSION ); switch ( $type ) { case 'css': if ( file_exists( sprintf( '%s%s/%s', ET_BUILDER_DIR, $build, $resource ) ) || ! $DEBUG ) { wp_enqueue_style( $id, $bundle, $deps, $ver ); } elseif ( $DEBUG ) { // Style is already embedded in the bundle but we still need to enqueue its deps. foreach ( $deps as $dep ) { wp_enqueue_style( $dep ); } } break; case 'js': if ( file_exists( sprintf( '%s%s/%s', ET_BUILDER_DIR, $build, $resource ) ) || ! $DEBUG ) { // If the file exists on disk, enqueue it wp_enqueue_script( $id, $bundle, $deps, $ver, true ); } else { // Otherwise load `hot` from webpack-dev-server $site_url = wp_parse_url( get_site_url() ); $hot_bundle_url = "{$site_url['scheme']}://{$site_url['host']}:31495/$resource"; wp_enqueue_script( $id, $hot_bundle_url, $deps, $ver, true ); } wp_add_inline_script( $id, 'window.et_gb = (window.top && window.top.Cypress && window.parent === window.top && window) || (window.top && window.top.Cypress && window.parent !== window.top && window.parent) || window.top || window;', 'before' ); break; } } endif; /** * Get list of all active plugins (single, network active, and mu) * * @return array active plugins */ if ( ! function_exists( 'et_builder_get_active_plugins' ) ): function et_builder_get_active_plugins() { $active_plugins = get_option( 'active_plugins' ); // Returned format must be array if ( ! is_array( $active_plugins ) ) { $active_plugins = array(); } // Get mu-plugins (must-use) // mu-plugins data is returned in array( "plugin/name.php" => array( 'data' => 'value' ) ) format. $mu_plugins = get_mu_plugins(); if ( is_array( $mu_plugins ) ) { $active_plugins = array_merge( $active_plugins, array_keys( $mu_plugins ) ); } // Get network active plugins // Network active plugin data is returned in array( "plugin/name.php" => active_timestamp_int format. if ( is_multisite() ) { $network_active_plugins = get_site_option( 'active_sitewide_plugins' ); if ( is_array( $network_active_plugins ) ) { $active_plugins = array_merge( $active_plugins, array_keys( $network_active_plugins ) ); } } return apply_filters( 'et_builder_get_active_plugins', $active_plugins ); } endif; if ( ! function_exists( 'et_has_hover_enabled' ) ) : function et_has_hover_enabled( $props ) { $et_has_hover_enabled = false; $prop_names = array_keys( $props ); $suffix = et_pb_hover_options()->get_enabled_suffix(); foreach ( $prop_names as $prop_name ) { if ( preg_match( "~{$suffix}$~", $prop_name ) && 'on' === $props[ $prop_name ] ) { $et_has_hover_enabled = true; break; } } return $et_has_hover_enabled; } endif; if ( ! function_exists( 'et_builder_is_hover_enabled' ) ) : function et_builder_is_hover_enabled( $setting, $props ) { return et_pb_hover_options()->is_enabled( $setting, $props ); } endif; if ( ! function_exists( 'et_builder_add_prefix' ) ) { /** * Prefixes a string key with a prefix string using the provided delimiter * In case the prefix is empty, original key is returned * * @param string $prefix * @param string $key * @param string $delimiter * * @return string */ function et_builder_add_prefix( $prefix, $key, $delimiter = '_' ) { return $prefix === '' ? $key : $prefix . $delimiter . $key; } } if ( ! function_exists( 'et_builder_has_value' ) ) { /** * Check if value is not an empty value * Empty values are considered: * - null * - '' * - false * * @param $value * * @return bool */ function et_builder_has_value( $value ) { return null !== $value && '' !== $value && false !== $value; } } if ( ! function_exists( 'et_builder_get_or' ) ) { /** * Returns the value in case it is not empty * Otherwise, return the default value * * @param $value * @param string $default * * @return string */ function et_builder_get_or( $value, $default = '' ) { return et_builder_has_value( $value ) ? $value : $default; } } if ( ! function_exists( 'et_builder_module_prop' ) ) { /** * Returns props value by provided key, if the value is empty, returns the default value * * @param string $prop * @param array $props * @param mixed $default * * @return mixed|null */ function et_builder_module_prop( $prop, $props, $default ) { return et_builder_get_or( et_()->array_get( $props, $prop ), $default ); } } if ( ! function_exists( 'et_pb_get_column_svg' ) ) { /** * Returns svg which represents the requried columns type * * @param string $type * * @return string svg code. */ function et_pb_get_column_svg( $type ) { $svg = ''; switch ( $type ) { case '4_4': $svg = '<rect width="100%" height="20" y="5" rx="5" ry="5" />'; break; case '1_2,1_2': $svg = '<rect width="48.5%" height="20" y="5" rx="5" ry="5" /> <rect width="48.5%" height="20" y="5" rx="5" ry="5" x="51.5%" />'; break; case '1_3,1_3,1_3': $svg = '<rect width="31.3%" height="20" y="5" rx="5" ry="5" /> <rect width="31.3%" height="20" y="5" rx="5" ry="5" x="34.3%" /> <rect width="31.3%" height="20" y="5" rx="5" ry="5" x="68.6%" />'; break; case '1_4,1_4,1_4,1_4': $svg = '<rect width="22.75%" height="20" y="5" rx="5" ry="5" /> <rect width="22.75%" height="20" y="5" rx="5" ry="5" x="25.75%" /> <rect width="22.75%" height="20" y="5" rx="5" ry="5" x="51.5%" /> <rect width="22.75%" height="20" y="5" rx="5" ry="5" x="77.25%" />'; break; case '1_5,1_5,1_5,1_5,1_5': $svg = '<rect width="17.6%" height="20" y="5" rx="5" ry="5" /> <rect width="17.6%" height="20" y="5" rx="5" ry="5" x="20.6%" /> <rect width="17.6%" height="20" y="5" rx="5" ry="5" x="41.2%" /> <rect width="17.6%" height="20" y="5" rx="5" ry="5" x="61.8%" /> <rect width="17.6%" height="20" y="5" rx="5" ry="5" x="82.4%" />'; break; case '1_6,1_6,1_6,1_6,1_6,1_6': $svg = '<rect width="14.16%" height="20" y="5" rx="5" ry="5" /> <rect width="14.16%" height="20" y="5" rx="5" ry="5" x="17.16%" /> <rect width="14.16%" height="20" y="5" rx="5" ry="5" x="34.32%" /> <rect width="14.16%" height="20" y="5" rx="5" ry="5" x="51.48%" /> <rect width="14.16%" height="20" y="5" rx="5" ry="5" x="68.64%" /> <rect width="14.16%" height="20" y="5" rx="5" ry="5" x="85.8%" />'; break; case '2_5,3_5' : $svg = '<rect width="38.5%" height="20" y="5" rx="5" ry="5" /> <rect width="58.5%" height="20" y="5" rx="5" ry="5" x="41.5%" />'; break; case '3_5,2_5' : $svg = '<rect width="58.5%" height="20" y="5" rx="5" ry="5" /> <rect width="38.5%" height="20" y="5" rx="5" ry="5" x="61.5%" />'; break; case '1_3,2_3' : $svg = '<rect width="31.5%" height="20" y="5" rx="5" ry="5" /> <rect width="65.5%" height="20" y="5" rx="5" ry="5" x="34.5%" />'; break; case '2_3,1_3' : $svg = '<rect width="65.5%" height="20" y="5" rx="5" ry="5" /> <rect width="31.5%" height="20" y="5" rx="5" ry="5" x="68.5%" />'; break; case '1_4,3_4' : $svg = '<rect width="23.5%" height="20" y="5" rx="5" ry="5" /> <rect width="73.5%" height="20" y="5" rx="5" ry="5" x="26.5%" />'; break; case '3_4,1_4' : $svg = '<rect width="73.5%" height="20" y="5" rx="5" ry="5" /> <rect width="23.5%" height="20" y="5" rx="5" ry="5" x="76.5%" />'; break; case '1_4,1_2,1_4': $svg = '<rect width="23.5%" height="20" y="5" rx="5" ry="5" /> <rect width="47%" height="20" y="5" rx="5" ry="5" x="26.5%" /> <rect width="23.5%" height="20" y="5" rx="5" ry="5" x="76.5%" />'; break; case '1_5,3_5,1_5': $svg = '<rect width="18.5%" height="20" y="5" rx="5" ry="5" /> <rect width="57%" height="20" y="5" rx="5" ry="5" x="21.5%" /> <rect width="18.5%" height="20" y="5" rx="5" ry="5" x="81.5%" />'; break; case '1_4,1_4,1_2': $svg = '<rect width="23.5%" height="20" y="5" rx="5" ry="5" /> <rect width="23.5%" height="20" y="5" rx="5" ry="5" x="26.5%" /> <rect width="47%" height="20" y="5" rx="5" ry="5" x="53%" />'; break; case '1_2,1_4,1_4': $svg = '<rect width="47%" height="20" y="5" rx="5" ry="5" /> <rect width="23.5%" height="20" y="5" rx="5" ry="5" x="50%" /> <rect width="23.5%" height="20" y="5" rx="5" ry="5" x="76.5%" />'; break; case '1_5,1_5,3_5': $svg = '<rect width="18.5%" height="20" y="5" rx="5" ry="5" /> <rect width="18.5%" height="20" y="5" rx="5" ry="5" x="21.5%" /> <rect width="57%" height="20" y="5" rx="5" ry="5" x="43%" />'; break; case '3_5,1_5,1_5': $svg = '<rect width="57%" height="20" y="5" rx="5" ry="5" /> <rect width="18.5%" height="20" y="5" rx="5" ry="5" x="60%" /> <rect width="18.5%" height="20" y="5" rx="5" ry="5" x="81.5%" />'; break; case '1_6,1_6,1_6,1_2': $svg = '<rect width="14.6%" height="20" y="5" rx="5" ry="5" /> <rect width="14.6%" height="20" y="5" rx="5" ry="5" x="18.1%" /> <rect width="14.6%" height="20" y="5" rx="5" ry="5" x="36.2%" /> <rect width="45.7%" height="20" y="5" rx="5" ry="5" x="54.3%" />'; break; case '1_2,1_6,1_6,1_6': $svg = '<rect width="47%" height="20" y="5" rx="5" ry="5" /> <rect width="14.6%" height="20" y="5" rx="5" ry="5" x="50%" /> <rect width="14.6%" height="20" y="5" rx="5" ry="5" x="67.6%" /> <rect width="14.6%" height="20" y="5" rx="5" ry="5" x="85.2%" />'; break; } return $svg; } } /** * Get image metadata responsive sizes * * @since 3.27.3 * * @param string $image_src The 'src' of the image. * @param array $image_meta The image meta data as returned by 'wp_get_attachment_metadata()'. * @param array $size Array of width and height values in pixels (in that order). * * @return array|bool */ function et_builder_responsive_image_metadata( $image_src, $image_meta = null, $size = null ) { $cache = ET_Core_Cache_File::get( 'image_responsive_metadata' ); // Normalize image URL. $normalized_url = et_attachment_normalize_url( $image_src ); if ( isset( $cache[ $normalized_url ] ) ) { if ( et_core_is_uploads_dir_url( $normalized_url ) ) { return $cache[ $normalized_url ]; } unset( $cache[ $normalized_url ] ); ET_Core_Cache_File::set( 'image_responsive_metadata', $cache ); } $responsive_sizes = array(); $image_id = is_numeric( $image_src ) ? intval( $image_src ) : et_get_attachment_id_by_url( $image_src ); if ( ! $image_id ) { return array(); } if ( is_null( $image_meta ) ) { $image_meta = wp_get_attachment_metadata( $image_id ); } if ( ! $image_meta || empty( $image_meta['sizes'] ) ) { return array(); } if ( is_null( $size ) ) { $size = et_get_attachment_size_by_url( $image_src ); } if ( 'full' === $size && isset( $image_meta['width'] ) && isset( $image_meta['height'] ) ) { $size = array( absint( $image_meta['width'] ), absint( $image_meta['height'] ), ); } else if ( is_string( $size ) && ! empty( $image_meta['sizes'][ $size ] ) ) { $size = array( absint( $image_meta['sizes'][ $size ]['width'] ), absint( $image_meta['sizes'][ $size ]['height'] ), ); } if ( ! $size || ! is_array( $size ) ) { return array(); } foreach ( $image_meta['sizes'] as $size_key => $size_data ) { if ( strpos( $size_key, 'et-pb-image--responsive--' ) !== 0 ) { continue; } if ( is_array( $size ) && $size[0] < $size_data['width'] ) { $responsive_sizes[ $size_data['width'] ] = false; } else { $responsive_sizes[ $size_data['width'] ] = $size_data; } } if ( $responsive_sizes ) { ksort( $responsive_sizes ); // Cache the responsive sizes data. if ( et_core_is_uploads_dir_url( $normalized_url ) ) { $cache[ $normalized_url ] = $responsive_sizes; ET_Core_Cache_File::set( 'image_responsive_metadata', $cache ); } } return $responsive_sizes; } /** * Filters an image's 'srcset' sources. * * @since 3.27 * * @param array $sources { * One or more arrays of source data to include in the 'srcset'. * * @type array $width { * @type string $url The URL of an image source. * @type string $descriptor The descriptor type used in the image candidate string, * either 'w' or 'x'. * @type int $value The source width if paired with a 'w' descriptor, or a * pixel density value if paired with an 'x' descriptor. * } * } * @param array $size_array Array of width and height values in pixels (in that order). * @param string $image_src The 'src' of the image. * @param array $image_meta The image meta data as returned by 'wp_get_attachment_metadata()'. * * @return array */ if ( ! function_exists( 'et_filter_wp_calculate_image_srcset' ) ): function et_filter_wp_calculate_image_srcset( $sources, $size_array, $image_src, $image_meta ) { // Do not filter when in wp-admin area. if ( is_admin() ) { return $sources; } $responsive_sources = array(); if ( ! et_is_responsive_images_enabled() ) { return $responsive_sources; } if ( is_string( $size_array ) ) { $size_array = et_get_attachment_size_by_url( $image_src ); } if ( is_string( $size_array ) && $image_meta ) { if ( $size_array === 'full' ) { $size_array = array( absint( $image_meta['width'] ), absint( $image_meta['height'] ), ); } else if ( ! empty( $image_meta['sizes'][ $size_array ] ) ) { $size_array = array( absint( $image_meta['sizes'][ $size_array ]['width'] ), absint( $image_meta['sizes'][ $size_array ]['height'] ), ); } } if ( ! is_array( $size_array ) ) { return $responsive_sources; } $responsive_metadata = et_builder_responsive_image_metadata( $image_src, $image_meta, $size_array ); if ( $responsive_metadata ) { foreach ( $responsive_metadata as $max_width => $size_data ) { if ( ! $size_data ) { continue; } $responsive_sources[ $max_width ] = array( 'url' => str_replace( basename( $image_src ), $size_data['file'], $image_src ), 'descriptor' => 'w', 'value' => $max_width, ); } if ( $responsive_sources && $size_array[0] > $max_width ) { $responsive_sources[ $size_array[0] ] = array( 'url' => $image_src, 'descriptor' => 'w', 'value' => $size_array[0], ); } if ( $responsive_sources ) { krsort( $responsive_sources ); } } else { $responsive_sources = $sources; } return $responsive_sources; } endif; add_filter( 'wp_calculate_image_srcset', 'et_filter_wp_calculate_image_srcset', 10, 4 ); /** * Filters the output of 'wp_calculate_image_sizes()'. * * @since 3.27.3 * * @param string $sizes A source size value for use in a 'sizes' attribute. * @param array|string $size Requested size. Image size or array of width and height values * in pixels (in that order). * @param string|null $image_src The URL to the image file or null. * @param array|null $image_meta The image meta data as returned by wp_get_attachment_metadata() or null. * * @return string|bool A valid source size value for use in a 'sizes' attribute or false. */ if ( ! function_exists( 'et_filter_wp_calculate_image_sizes' ) ): function et_filter_wp_calculate_image_sizes( $sizes, $size, $image_src, $image_meta ) { // Do not filter when in wp-admin area. if ( is_admin() ) { return $sizes; } $responsive_sizes = ''; if ( ! et_is_responsive_images_enabled() ) { return $responsive_sizes; } if ( is_string( $size ) ) { $size = et_get_attachment_size_by_url( $image_src ); } if ( is_string( $size ) && $image_meta ) { if ( $size === 'full' ) { $size = array( absint( $image_meta['width'] ), absint( $image_meta['height'] ), ); } else if ( ! empty( $image_meta['sizes'][ $size ] ) ) { $size = array( absint( $image_meta['sizes'][ $size ]['width'] ), absint( $image_meta['sizes'][ $size ]['height'] ), ); } } if ( ! is_array( $size ) ) { return $responsive_sizes; } $responsive_metadata = et_builder_responsive_image_metadata( $image_src, $image_meta, $size ); if ( $responsive_metadata ) { $max_width = 0; $prev_width = 0; $sizes_temp = array(); foreach ( $responsive_metadata as $max_width => $size_data ) { if ( ! $size_data ) { continue; } if ( $prev_width ) { $sizes_temp[$max_width] = sprintf( '(min-width: %2$dpx) and (max-width: %1$dpx) %1$dpx', $max_width, ( $prev_width + 1 ) ); } else { $sizes_temp[$max_width] = sprintf( '(min-width: %2$dpx) and (max-width: %1$dpx) %1$dpx', $max_width, $prev_width ); } $prev_width = $max_width; } if ( $sizes_temp && $size[0] > $prev_width ) { $sizes_temp[$size[0]] = sprintf( '(min-width: %2$dpx) %1$dpx', $size[0], ( $prev_width + 1 ) ); } if ( $sizes_temp ) { $sizes_temp[] = '100vw'; } $responsive_sizes = implode( ', ', $sizes_temp ); } else { $responsive_sizes = $sizes; } return $responsive_sizes; } endif; add_filter( 'wp_calculate_image_sizes', 'et_filter_wp_calculate_image_sizes', 10, 4 ); /** * Register and localize assets early enough to avoid conflicts * with third party plugins that use the same assets. * * @since 4.0.9 */ function et_builder_register_assets() { global $wp_version; $root = ET_BUILDER_URI; $wp_major_version = substr( $wp_version, 0, 3 ); wp_register_script( 'iris', admin_url( 'js/iris.min.js' ), array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), false, 1 ); wp_register_script( 'wp-color-picker', admin_url( 'js/color-picker.min.js' ), array( 'iris' ), false, 1 ); $wp_color_picker_l10n = array( 'clear' => esc_html__( 'Clear', 'et_builder' ), 'defaultString' => et_builder_i18n( 'Default' ), 'pick' => esc_html__( 'Select Color', 'et_builder' ), ); if ( version_compare( $wp_major_version, '4.9', '>=' ) ) { wp_register_script( 'wp-color-picker-alpha', "{$root}/scripts/ext/wp-color-picker-alpha.min.js", array( 'jquery', 'wp-color-picker' ), ET_BUILDER_VERSION, true ); } else { wp_register_script( 'wp-color-picker-alpha', "{$root}/scripts/ext/wp-color-picker-alpha-48.min.js", array( 'jquery', 'wp-color-picker' ), ET_BUILDER_VERSION, true ); $wp_color_picker_l10n['current'] = esc_html__( 'Current Color', 'et_builder' ); } wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', $wp_color_picker_l10n ); } add_action( 'init', 'et_builder_register_assets', 11 ); /** * Set border radius to parallax background wrapper. * * @since 4.4.8 * * @param array $props * @param string $module * @param string $order_class * * @return void */ if ( ! function_exists( 'et_set_parallax_bg_wrap_border_radius' ) ): function et_set_parallax_bg_wrap_border_radius( $props, $module, $order_class ) { $border_radius_values = et_pb_responsive_options()->get_property_values( $props, 'border_radii' ); $border_radius_hover_enabled = et_builder_module_prop( 'border_radii__hover_enabled', $props, '' ); $border_radius_hover_values = et_builder_module_prop( 'border_radii__hover', $props, '' ); foreach ( et_pb_responsive_options()->get_modes() as $device ) { if ( $border_radius_values[$device] === 'on||||' ) { $border_radius_values[$device] = ''; continue; } $border_radius_values[$device] = et_format_parallax_bg_wrap_radius_values( $border_radius_values[$device] ); } et_pb_responsive_options()->generate_responsive_css( $border_radius_values, $order_class . ' .et_parallax_bg_wrap', 'border-radius', $module, '', 'border' ); if ( $border_radius_hover_enabled === 'on|hover' ) { $radius_hover_values = et_format_parallax_bg_wrap_radius_values( $border_radius_hover_values ); } else { $radius_hover_values = $border_radius_values['desktop']; } if ( $radius_hover_values ) { ET_Builder_Element::set_style( $module, array( 'selector' => $order_class . ':hover .et_parallax_bg_wrap', 'declaration' => esc_html( sprintf( 'border-radius: %1$s;', $radius_hover_values ) ), ) ); } } endif; /** * Get formatted border radius of parallax background wrapper * * @since 4.4.8 * * @param string $border_radius_values * * @return string */ if ( ! function_exists( 'et_format_parallax_bg_wrap_radius_values' ) ): function et_format_parallax_bg_wrap_radius_values( $border_radius_values ) { $radius_values = array(); $radius_array = explode( '|', $border_radius_values ); for ( $i = 1; $i < count( $radius_array ); $i++ ) { $radius_values[] = $radius_array[$i] ? $radius_array[$i] : 0; } return trim( implode( ' ', $radius_values ) ); } endif;
•
Search:
•
Replace:
1
2
Function
Edit by line
Download
Information
Rename
Copy
Move
Delete
Chmod
List