]*>|#x3[ce];|<|>/i', '', $sanitized_properties ); return $attr . '="' . $clean_properties . '"'; } return ''; } } if ( ! function_exists( 'qi_addons_for_elementor_framework_inline_attr' ) ) { /** * Function that generates html attribute * * @param string|array $value value of html attribute * @param string $attr - name of html attribute to generate * @param string $glue - glue with which to implode $attr. Used only when $attr is array */ function qi_addons_for_elementor_framework_inline_attr( $value, $attr, $glue = '' ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo qi_addons_for_elementor_framework_get_inline_attr( $value, $attr, $glue ); } } if ( ! function_exists( 'qi_addons_for_elementor_framework_get_inline_attrs' ) ) { /** * Generate multiple inline attributes * * @param array $attrs * @param bool $allow_zero_values * * @return string */ function qi_addons_for_elementor_framework_get_inline_attrs( $attrs, $allow_zero_values = false ) { $output = ''; if ( is_array( $attrs ) && count( $attrs ) ) { if ( $allow_zero_values ) { foreach ( $attrs as $attr => $value ) { $output .= ' ' . qi_addons_for_elementor_framework_get_inline_attr( $value, $attr, '', true ); } } else { foreach ( $attrs as $attr => $value ) { $output .= ' ' . qi_addons_for_elementor_framework_get_inline_attr( $value, $attr ); } } } $output = ltrim( $output ); return $output; } } if ( ! function_exists( 'qi_addons_for_elementor_framework_inline_attrs' ) ) { /** * Echo multiple inline attributes * * @param array $attrs * @param bool $allow_zero_values */ function qi_addons_for_elementor_framework_inline_attrs( $attrs, $allow_zero_values = false ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo qi_addons_for_elementor_framework_get_inline_attrs( $attrs, $allow_zero_values ); } } if ( ! function_exists( 'qi_addons_for_elementor_framework_string_ends_with' ) ) { /** * Checks if $haystack ends with $needle and returns proper bool value * * @param string $haystack - to check * @param string $needle - on end to match * * @return bool */ function qi_addons_for_elementor_framework_string_ends_with( $haystack, $needle ) { if ( '' !== $haystack && '' !== $needle ) { return ( substr( $haystack, - strlen( $needle ), strlen( $needle ) ) == $needle ); } return false; } } if ( ! function_exists( 'qi_addons_for_elementor_framework_string_ends_with_typography_units' ) ) { /** * Checks if $haystack ends with predefined needles and returns proper bool value * * @param string $haystack - to check * * @return bool */ function qi_addons_for_elementor_framework_string_ends_with_typography_units( $haystack ) { $result = false; $needles = array( 'px', 'em', 'rem' ); if ( '' !== $haystack ) { foreach ( $needles as $needle ) { if ( qi_addons_for_elementor_framework_string_ends_with( $haystack, $needle ) ) { $result = true; } } } return $result; } } if ( ! function_exists( 'qi_addons_for_elementor_framework_string_ends_with_space_units' ) ) { /** * Checks if $haystack ends with predefined needles and returns proper bool value * * @param string $haystack - to check * @param bool $additional_units - add additional needles * * @return bool */ function qi_addons_for_elementor_framework_string_ends_with_space_units( $haystack, $additional_units = false ) { $result = false; $needles = array( 'px', '%' ); if ( $additional_units ) { array_push( $needles, 'em', 'rem', ')', 'vh', 'vw' ); } if ( '' !== $haystack ) { foreach ( $needles as $needle ) { if ( qi_addons_for_elementor_framework_string_ends_with( $haystack, $needle ) ) { $result = true; } } } return $result; } } if ( ! function_exists( 'qi_addons_for_elementor_framework_wp_kses_html' ) ) { /** * Function that does escaping of specific html. * It uses wp_kses function with predefined attributes array. * * @param string $type - type of html element * @param string $content - string to escape * * @return string escaped output * @see wp_kses() */ function qi_addons_for_elementor_framework_wp_kses_html( $type, $content ) { switch ( $type ) { case 'img': $atts = array( 'img' => apply_filters( 'qi_addons_for_elementor_filter_framework_wp_kses_img_atts', array( 'itemprop' => true, 'id' => true, 'class' => true, 'width' => true, 'height' => true, 'src' => true, 'srcset' => true, 'sizes' => true, 'alt' => true, 'title' => true, ) ), ); break; case 'svg': $atts = apply_filters( 'qi_addons_for_elementor_filter_framework_wp_kses_svg_atts', array( 'svg' => array( 'xmlns' => true, 'version' => true, 'id' => true, 'class' => true, 'x' => true, 'y' => true, 'aria-hidden' => true, 'aria-labelledby' => true, 'role' => true, 'width' => true, 'height' => true, 'viewbox' => true, 'enable-background' => true, 'focusable' => true, 'data-prefix' => true, 'data-icon' => true, ), 'g' => array( 'stroke' => true, 'stroke-width' => true, 'fill' => true, 'fill-opacity' => true, ), 'rect' => array( 'x' => true, 'y' => true, 'width' => true, 'height' => true, ), 'title' => array( 'title' => true, ), 'path' => array( 'd' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'fill' => true, 'fill-opacity' => true, 'transform' => true, ), 'polygon' => array( 'points' => true, ), ) ); break; case 'content': $atts = apply_filters( 'qi_addons_for_elementor_filter_framework_wp_kses_content_atts', array( 'div' => array( 'id' => true, 'class' => true, 'style' => true, 'aria-hidden' => true, 'data-tf-widget' => true, ), 'ol' => array( 'class' => true, 'style' => true, ), 'ul' => array( 'class' => true, 'style' => true, ), 'li' => array( 'class' => true, 'style' => true, ), 'br' => true, 'strong' => array( 'class' => true, ), 'b' => array( 'class' => true, ), 'em' => array( 'class' => true, ), 'h1' => array( 'class' => true, 'style' => true, ), 'h2' => array( 'class' => true, 'style' => true, ), 'h3' => array( 'class' => true, 'style' => true, ), 'h4' => array( 'class' => true, 'style' => true, ), 'h5' => array( 'class' => true, 'style' => true, ), 'h6' => array( 'class' => true, 'style' => true, ), 'p' => array( 'id' => true, 'class' => true, 'style' => true, ), 'a' => array( 'itemprop' => true, 'id' => true, 'class' => true, 'href' => true, 'target' => true, 'style' => true, 'rel' => true, 'data-rel' => true, ), 'span' => array( 'id' => true, 'class' => true, 'style' => true, ), 'i' => array( 'class' => true, ), 'img' => array( 'itemprop' => true, 'id' => true, 'class' => true, 'width' => true, 'height' => true, 'src' => true, 'srcset' => true, 'sizes' => true, 'alt' => true, 'title' => true, ), 'form' => array( 'action' => true, 'method' => true, 'id' => true, 'name' => true, 'class' => true, 'target' => true, ), 'input' => array( 'type' => true, 'value' => true, 'id' => true, 'name' => true, 'class' => true, 'pattern' => true, 'placeholder' => true, 'size' => true, 'minlength' => true, 'maxlength' => true, ), 'label' => array( 'for' => true, ), 'select' => array( 'id' => true, 'name' => true, 'class' => true, ), 'option' => array( 'value' => true, ), 'sup' => array( 'class' => true, ), ) ); break; case 'script': $atts = apply_filters( 'qi_addons_for_elementor_filter_framework_wp_kses_script_atts', array( 'script' => array( 'src' => true, ), ) ); break; default: return apply_filters( 'qi_addons_for_elementor_filter_framework_wp_kses_custom', $content, $type ); } return wp_kses( $content, $atts ); } } if ( ! function_exists( 'qi_addons_for_elementor_framework_sanitize_tags' ) ) { /** * Function that does escaping of specific html tag. * * @param string $tag - string to escape * @param string $type - type of html element * * @return string escaped output * @see wp_kses() */ function qi_addons_for_elementor_framework_sanitize_tags( $tag, $type = 'title', $exclude = array(), $include = array() ) { $allowed_tags = array(); switch ( $type ) { case 'list': $allowed_tags['ul'] = 'ul'; $allowed_tags['ol'] = 'ol'; break; case 'title': default: $allowed_tags['h1'] = 'h1'; $allowed_tags['h2'] = 'h2'; $allowed_tags['h3'] = 'h3'; $allowed_tags['h4'] = 'h4'; $allowed_tags['h5'] = 'h5'; $allowed_tags['h6'] = 'h6'; $allowed_tags['p'] = 'p'; $allowed_tags['span'] = 'span'; break; } if ( ! empty( $exclude ) ) { foreach ( $exclude as $e ) { if ( array_key_exists( $e, $allowed_tags ) ) { unset( $allowed_tags[ $e ] ); } } } if ( ! empty( $include ) ) { foreach ( $include as $key => $value ) { if ( ! array_key_exists( $key, $allowed_tags ) ) { $allowed_tags[ $key ] = $value; } } } $tag = strtolower( sanitize_key( $tag ) ); if ( in_array( $tag, $allowed_tags, true ) ) { return $tag; } return ''; } } if ( ! function_exists( 'qi_addons_for_elementor_framework_dynamic_style' ) ) { /** * Outputs css based on passed selectors and properties * * @param array|string $selector * @param array $properties * * @return string */ function qi_addons_for_elementor_framework_dynamic_style( $selector, $properties ) { $output = ''; // Check if selector and rules are valid data. if ( ! empty( $selector ) && ( is_array( $properties ) && count( $properties ) ) ) { if ( is_array( $selector ) && count( $selector ) ) { $output .= implode( ', ', $selector ); } else { $output .= $selector; } $output .= ' { '; foreach ( $properties as $prop => $value ) { if ( '' !== $prop ) { $output .= $prop . ': ' . esc_attr( $value ) . ';'; } } $output .= '}'; } return $output; } } if ( ! function_exists( 'qi_addons_for_elementor_framework_dynamic_style_responsive' ) ) { /** * Outputs css based on passed selectors and properties * * @param array|string $selector * @param array $properties * @param string $min_width * @param string $max_width * * @return string */ function qi_addons_for_elementor_framework_dynamic_style_responsive( $selector, $properties, $min_width = '', $max_width = '' ) { $output = ''; // Check if min width or max width is set. if ( ! empty( $min_width ) || ! empty( $max_width ) ) { $output .= '@media only screen'; if ( ! empty( $min_width ) ) { $output .= ' and (min-width: ' . $min_width . 'px)'; } if ( ! empty( $max_width ) ) { $output .= ' and (max-width: ' . $max_width . 'px)'; } $output .= ' { '; $output .= qi_addons_for_elementor_framework_dynamic_style( $selector, $properties ); $output .= '}'; } return $output; } } if ( ! function_exists( 'qi_addons_for_elementor_framework_is_installed' ) ) { /** * Function check is some plugin/theme is installed * * @param string $plugin name * * @return bool */ function qi_addons_for_elementor_framework_is_installed( $plugin ) { switch ( $plugin ) : case 'elementor': return defined( 'ELEMENTOR_VERSION' ); case 'woocommerce': return class_exists( 'WooCommerce' ); case 'contact_form_7': return defined( 'WPCF7_VERSION' ); case 'wp_forms': return defined( 'WPFORMS_VERSION' ); case 'wpml': return defined( 'ICL_SITEPRESS_VERSION' ); default: return apply_filters( 'qi_addons_for_elementor_filter_framework_is_plugin_installed', false, $plugin ); endswitch; } } if ( ! function_exists( 'qi_addons_for_elementor_framework_is_shortcode_on_page' ) ) { /** * Function that checks does some shortcode appears in some field on page * * @param string $shortcode * @param string $content . If content is empty, check current page content * * @return bool */ function qi_addons_for_elementor_framework_is_shortcode_on_page( $shortcode, $content = '' ) { $is_shortcode_on_page = false; if ( $shortcode ) { if ( '' == $content ) { // Get content from current page. $page_id = qi_addons_for_elementor_framework_get_page_id(); if ( ! empty( $page_id ) ) { $current_post = get_post( $page_id ); if ( is_object( $current_post ) && property_exists( $current_post, 'post_content' ) ) { $content = $current_post->post_content; } } } if ( has_shortcode( $content, $shortcode ) ) { $is_shortcode_on_page = true; } } return $is_shortcode_on_page; } } if ( ! function_exists( 'qi_addons_for_elementor_framework_is_shortcode_on_page_elementor' ) ) { /** * Function that checks does some shortcode appears in some field on page * * @param string $shortcode * @param string $content . If content is empty, check current page content * * @return bool */ function qi_addons_for_elementor_framework_is_shortcode_on_page_elementor( $shortcode, $content = '' ) { $is_shortcode_on_page = false; if ( $shortcode ) { if ( '' == $content ) { // Get content from current page. $page_id = qi_addons_for_elementor_framework_get_page_id(); if ( ! empty( $page_id ) ) { $current_elementor_page = get_post_meta( $page_id, '_elementor_data', true ); $content = json_decode( $current_elementor_page ); } } if ( is_array( $content ) && count( $content ) ) { foreach ( $content as $section ) { foreach ( $section->elements as $column ) { foreach ( $column->elements as $item ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase if ( 'widget' === $item->elType && $item->widgetType == $shortcode ) { return true; } elseif ( 'section' === $item->el_type ) { foreach ( $item->elements as $inner_column ) { foreach ( $inner_column->elements as $inner_item ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase if ( 'widget' === $inner_item->elType && $inner_item->widgetType == $shortcode ) { return true; } } } } } } } } } return $is_shortcode_on_page; } } if ( ! function_exists( 'qi_addons_for_elementor_framework_call_shortcode' ) ) { /** * Function that render shortcode * * @param $base - shortcode base * @param $params - shortcode parameters * @param null $content - shortcode content * * @return mixed|string */ function qi_addons_for_elementor_framework_call_shortcode( $base, $params, $content = null ) { global $shortcode_tags; if ( ! isset( $shortcode_tags[ $base ] ) ) { return false; } if ( is_array( $shortcode_tags[ $base ] ) ) { $shortcode = $shortcode_tags[ $base ]; return call_user_func( array( $shortcode[0], $shortcode[1], ), $params, $content, $base ); } return call_user_func( $shortcode_tags[ $base ], $params, $content, $base ); } } if ( ! function_exists( 'qi_addons_for_elementor_framework_map_shortcode_fields' ) ) { /** * Function that map shortcode fields * * @param array $default_options - default supported options * @param array $params - params set * * @return array - formatted array with merge default and passed options */ function qi_addons_for_elementor_framework_map_shortcode_fields( $default_options, $params ) { $atts = (array) $params; $out = array(); foreach ( $default_options as $name => $default ) { if ( array_key_exists( $name, $atts ) ) { $out[ $name ] = $atts[ $name ]; } else { $out[ $name ] = $default; } } return $out; } } if ( ! function_exists( 'qi_addons_for_elementor_framework_get_ajax_status' ) ) { /** * Function that return status from ajax functions * * @param string $status - success or error * @param string $message - ajax message value * @param string|array $data - returned value * @param string $redirect - url address */ function qi_addons_for_elementor_framework_get_ajax_status( $status, $message, $data = null, $redirect = '' ) { $response = array( 'status' => esc_attr( $status ), 'message' => esc_html( $message ), 'data' => $data, 'redirect' => $redirect, ); $response = apply_filters( 'qi_addons_for_elementor_filter_framework_ajax_status', $response ); $output = wp_json_encode( $response ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped exit( $output ); } } if ( ! function_exists( 'qi_addons_for_elementor_framework_get_pages' ) ) { /** * Returns array of pages item * * @param bool $enable_default - add first element empty for default value * * @return array */ function qi_addons_for_elementor_framework_get_pages( $enable_default = false ) { $options = array(); $pages = get_pages(); if ( ! empty( $pages ) ) { if ( $enable_default ) { $options[''] = esc_html__( 'Default', 'qi-addons-for-elementor' ); } foreach ( $pages as $page ) { $options[ $page->ID ] = $page->post_title; } } return $options; } } if ( ! function_exists( 'qi_addons_for_elementor_framework_svg_icon' ) ) { /** * Function that echo svg html icon * * @param string $name - icon name * @param string $class_name - custom html tag class name */ function qi_addons_for_elementor_framework_svg_icon( $name, $class_name = '' ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo qi_addons_for_elementor_framework_get_svg_icon( $name, $class_name ); } } if ( ! function_exists( 'qi_addons_for_elementor_framework_get_svg_icon' ) ) { /** * Returns svg html * * @param string $name - icon name * @param string $class_name - custom html tag class name * * @return string|html */ function qi_addons_for_elementor_framework_get_svg_icon( $name, $class_name = '' ) { $html = ''; $class = isset( $class_name ) && ! empty( $class_name ) ? $class_name : ''; switch ( $name ) { case 'expand': $html = ''; break; case 'trash': $html = ''; break; case 'search': $html = ''; break; case 'spinner': $html = ''; break; } return $html; } } if ( ! function_exists( 'qi_addons_for_elementor_extend_plugin_info' ) ) { /** * Function that extended global plugin links on plugins page * * @param array $plugin_meta * @param string $plugin_file * * @return array */ function qi_addons_for_elementor_extend_plugin_info( $plugin_meta, $plugin_file ) { if ( QI_ADDONS_FOR_ELEMENTOR_PLUGIN_BASE_FILE === $plugin_file ) { $additioanal_plugin_meta = array( 'documentation' => '' . esc_html__( 'Help Center', 'qi-addons-for-elementor' ) . '', 'video' => '' . esc_html__( 'Video Tutorials', 'qi-addons-for-elementor' ) . '', ); $plugin_meta = array_merge( $plugin_meta, $additioanal_plugin_meta ); } return $plugin_meta; } add_filter( 'plugin_row_meta', 'qi_addons_for_elementor_extend_plugin_info', 10, 2 ); } if ( ! function_exists( 'qi_addons_for_elementor_extend_plugin_actions' ) ) { function qi_addons_for_elementor_extend_plugin_actions( $links ) { $links['upgrade'] = '' . esc_html__( 'Upgrade', 'qi-addons-for-elementor' ) . ''; return apply_filters( 'qi_addons_for_elementor_filter_extend_plugin_actions', $links ); } add_filter( 'plugin_action_links_' . QI_ADDONS_FOR_ELEMENTOR_PLUGIN_BASE_FILE, 'qi_addons_for_elementor_extend_plugin_actions' ); }