File manager - Edit - /home/theblueo/tv/fb4e3b/helpers.tar
Back
helpers.php 0000666 00000103573 15214053256 0006737 0 ustar 00 <?php if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } /** * WPBakery Visual Composer helpers functions * * @package WPBakeryVisualComposer * */ // Check if this file is loaded in js_composer if ( ! defined( 'WPB_VC_VERSION' ) ) { die( '-1' ); } /** * @param array $params * * @since 4.2 * vc_filter: vc_wpb_getimagesize - to override output of this function * @return array|bool */ function wpb_getImageBySize( $params = array() ) { $params = array_merge( array( 'post_id' => null, 'attach_id' => null, 'thumb_size' => 'thumbnail', 'class' => '', ), $params ); if ( ! $params['thumb_size'] ) { $params['thumb_size'] = 'thumbnail'; } if ( ! $params['attach_id'] && ! $params['post_id'] ) { return false; } $post_id = $params['post_id']; $attach_id = $post_id ? get_post_thumbnail_id( $post_id ) : $params['attach_id']; $attach_id = apply_filters( 'vc_object_id', $attach_id ); $thumb_size = $params['thumb_size']; $thumb_class = ( isset( $params['class'] ) && '' !== $params['class'] ) ? $params['class'] . ' ' : ''; global $_wp_additional_image_sizes; $thumbnail = ''; if ( is_string( $thumb_size ) && ( ( ! empty( $_wp_additional_image_sizes[ $thumb_size ] ) && is_array( $_wp_additional_image_sizes[ $thumb_size ] ) ) || in_array( $thumb_size, array( 'thumbnail', 'thumb', 'medium', 'large', 'full', ) ) ) ) { $attributes = array( 'class' => $thumb_class . 'attachment-' . $thumb_size ); $thumbnail = wp_get_attachment_image( $attach_id, $thumb_size, false, $attributes ); } elseif ( $attach_id ) { if ( is_string( $thumb_size ) ) { preg_match_all( '/\d+/', $thumb_size, $thumb_matches ); if ( isset( $thumb_matches[0] ) ) { $thumb_size = array(); if ( count( $thumb_matches[0] ) > 1 ) { $thumb_size[] = $thumb_matches[0][0]; // width $thumb_size[] = $thumb_matches[0][1]; // height } elseif ( count( $thumb_matches[0] ) > 0 && count( $thumb_matches[0] ) < 2 ) { $thumb_size[] = $thumb_matches[0][0]; // width $thumb_size[] = $thumb_matches[0][0]; // height } else { $thumb_size = false; } } } if ( is_array( $thumb_size ) ) { // Resize image to custom size $p_img = wpb_resize( $attach_id, null, $thumb_size[0], $thumb_size[1], true ); $alt = trim( strip_tags( get_post_meta( $attach_id, '_wp_attachment_image_alt', true ) ) ); $attachment = get_post( $attach_id ); if ( ! empty( $attachment ) ) { $title = trim( strip_tags( $attachment->post_title ) ); if ( empty( $alt ) ) { $alt = trim( strip_tags( $attachment->post_excerpt ) ); // If not, Use the Caption } if ( empty( $alt ) ) { $alt = $title; } // Finally, use the title if ( $p_img ) { $attributes = vc_stringify_attributes( array( 'class' => $thumb_class, 'src' => $p_img['url'], 'width' => $p_img['width'], 'height' => $p_img['height'], 'alt' => $alt, 'title' => $title, ) ); $thumbnail = '<img ' . $attributes . ' />'; } } } } $p_img_large = wp_get_attachment_image_src( $attach_id, 'large' ); return apply_filters( 'vc_wpb_getimagesize', array( 'thumbnail' => $thumbnail, 'p_img_large' => $p_img_large, ), $attach_id, $params ); } /** * @param $width * * @deprecated 4.5 * @since 4.2 * @return string */ function wpb_getColumnControls( $width ) { _deprecated_function( 'wpb_getColumnControls', '4.5 (will be removed in 5.1)' ); switch ( $width ) { case 'vc_col-md-2' : $w = '1/6'; break; case 'vc_col-sm-2' : $w = '1/6'; break; case 'vc_col-sm-3' : $w = '1/4'; break; case 'vc_col-sm-4' : $w = '1/3'; break; case 'vc_col-sm-6' : $w = '1/2'; break; case 'vc_col-sm-8' : $w = '2/3'; break; case 'vc_col-sm-9' : $w = '3/4'; break; case 'vc_col-sm-12' : $w = '1/1'; break; default : $w = $width; } return $w; } /* Convert vc_col-sm-3 to 1/4 ---------------------------------------------------------- */ /** * @param $width * * @since 4.2 * @return string */ function wpb_translateColumnWidthToFractional( $width ) { switch ( $width ) { case 'vc_col-sm-2' : $w = '1/6'; break; case 'vc_col-sm-3' : $w = '1/4'; break; case 'vc_col-sm-4' : $w = '1/3'; break; case 'vc_col-sm-6' : $w = '1/2'; break; case 'vc_col-sm-8' : $w = '2/3'; break; case 'vc_col-sm-9' : $w = '3/4'; break; case 'vc_col-sm-12' : $w = '1/1'; break; default : $w = is_string( $width ) ? $width : '1/1'; } return $w; } /** * @param $width * * @since 4.2 * @return bool|string */ function wpb_translateColumnWidthToSpan( $width ) { preg_match( '/(\d+)\/(\d+)/', $width, $matches ); if ( ! empty( $matches ) ) { $part_x = (int) $matches[1]; $part_y = (int) $matches[2]; if ( $part_x > 0 && $part_y > 0 ) { $value = ceil( $part_x / $part_y * 12 ); if ( $value > 0 && $value <= 12 ) { $width = 'vc_col-sm-' . $value; } } } return $width; } /** * @param $content * @param bool $autop * * @since 4.2 * @return string */ function wpb_js_remove_wpautop( $content, $autop = false ) { if ( $autop ) { // Possible to use !preg_match('('.WPBMap::getTagsRegexp().')', $content) $content = wpautop( preg_replace( '/<\/?p\>/', "\n", $content ) . "\n" ); } return do_shortcode( shortcode_unautop( $content ) ); } if ( ! function_exists( 'shortcode_exists' ) ) { /** * Check if a shortcode is registered in WordPress. * * Examples: shortcode_exists( 'caption' ) - will return true. * shortcode_exists( 'blah' ) - will return false. * * @param bool $shortcode * * @since 4.2 * @return bool */ function shortcode_exists( $shortcode = false ) { global $shortcode_tags; if ( ! $shortcode ) { return false; } if ( array_key_exists( $shortcode, $shortcode_tags ) ) { return true; } return false; } } /* Helper function which returns list of site attached images, and if image is attached to the current post it adds class 'added' ---------------------------------------------------------- */ if ( ! function_exists( 'vc_siteAttachedImages' ) ) { /** * @param array $att_ids * * @since 4.11 * @return string */ function vc_siteAttachedImages( $att_ids = array() ) { $output = ''; $limit = (int) apply_filters( 'vc_site_attached_images_query_limit', - 1 ); $media_images = get_posts( 'post_type=attachment&orderby=ID&numberposts=' . $limit ); foreach ( $media_images as $image_post ) { $thumb_src = wp_get_attachment_image_src( $image_post->ID, 'thumbnail' ); $thumb_src = $thumb_src[0]; $class = ( in_array( $image_post->ID, $att_ids ) ) ? ' class="added"' : ''; $output .= '<li' . $class . '> <img rel="' . esc_attr( $image_post->ID ) . '" src="' . esc_url( $thumb_src ) . '" /> <span class="img-added">' . __( 'Added', 'js_composer' ) . '</span> </li>'; } if ( '' !== $output ) { $output = '<ul class="gallery_widget_img_select">' . $output . '</ul>'; } return $output; } } /** * @param array $images IDs or srcs of images * * @since 4.2 * @return string */ function fieldAttachedImages( $images = array() ) { $output = ''; foreach ( $images as $image ) { if ( is_numeric( $image ) ) { $thumb_src = wp_get_attachment_image_src( $image, 'thumbnail' ); $thumb_src = isset( $thumb_src[0] ) ? $thumb_src[0] : ''; } else { $thumb_src = $image; } if ( $thumb_src ) { $output .= ' <li class="added"> <img rel="' . esc_attr( $image ) . '" src="' . esc_url( $thumb_src ) . '" /> <a href="#" class="vc_icon-remove"><i class="vc-composer-icon vc-c-icon-close"></i></a> </li>'; } } return $output; } /** * @param $param_value * * @since 4.2 * @return array */ function wpb_removeNotExistingImgIDs( $param_value ) { $tmp = explode( ',', $param_value ); $return_ar = array(); foreach ( $tmp as $id ) { if ( wp_get_attachment_image( $id ) ) { $return_ar[] = $id; } } $tmp = implode( ',', $return_ar ); return $tmp; } /* * Resize images dynamically using wp built in functions * Victor Teixeira * * php 5.2+ * * Exemplo de uso: * * <?php * $thumb = get_post_thumbnail_id(); * $image = vt_resize( $thumb, '', 140, 110, true ); * ?> * <img src="<?php echo $image[url]; ?>" width="<?php echo $image[width]; ?>" height="<?php echo $image[height]; ?>" /> * */ if ( ! function_exists( 'wpb_resize' ) ) { /** * @param int $attach_id * @param string $img_url * @param int $width * @param int $height * @param bool $crop * * @since 4.2 * @return array */ function wpb_resize( $attach_id = null, $img_url = null, $width, $height, $crop = false ) { // this is an attachment, so we have the ID $image_src = array(); if ( $attach_id ) { $image_src = wp_get_attachment_image_src( $attach_id, 'full' ); $actual_file_path = get_attached_file( $attach_id ); // this is not an attachment, let's use the image url } elseif ( $img_url ) { $file_path = parse_url( $img_url ); $actual_file_path = rtrim( ABSPATH, '/' ) . $file_path['path']; $orig_size = getimagesize( $actual_file_path ); $image_src[0] = $img_url; $image_src[1] = $orig_size[0]; $image_src[2] = $orig_size[1]; } if ( ! empty( $actual_file_path ) ) { $file_info = pathinfo( $actual_file_path ); $extension = '.' . $file_info['extension']; // the image path without the extension $no_ext_path = $file_info['dirname'] . '/' . $file_info['filename']; $cropped_img_path = $no_ext_path . '-' . $width . 'x' . $height . $extension; // checking if the file size is larger than the target size // if it is smaller or the same size, stop right here and return if ( $image_src[1] > $width || $image_src[2] > $height ) { // the file is larger, check if the resized version already exists (for $crop = true but will also work for $crop = false if the sizes match) if ( file_exists( $cropped_img_path ) ) { $cropped_img_url = str_replace( basename( $image_src[0] ), basename( $cropped_img_path ), $image_src[0] ); $vt_image = array( 'url' => $cropped_img_url, 'width' => $width, 'height' => $height, ); return $vt_image; } if ( false == $crop ) { // calculate the size proportionaly $proportional_size = wp_constrain_dimensions( $image_src[1], $image_src[2], $width, $height ); $resized_img_path = $no_ext_path . '-' . $proportional_size[0] . 'x' . $proportional_size[1] . $extension; // checking if the file already exists if ( file_exists( $resized_img_path ) ) { $resized_img_url = str_replace( basename( $image_src[0] ), basename( $resized_img_path ), $image_src[0] ); $vt_image = array( 'url' => $resized_img_url, 'width' => $proportional_size[0], 'height' => $proportional_size[1], ); return $vt_image; } } // no cache files - let's finally resize it $img_editor = wp_get_image_editor( $actual_file_path ); if ( is_wp_error( $img_editor ) || is_wp_error( $img_editor->resize( $width, $height, $crop ) ) ) { return array( 'url' => '', 'width' => '', 'height' => '', ); } $new_img_path = $img_editor->generate_filename(); if ( is_wp_error( $img_editor->save( $new_img_path ) ) ) { return array( 'url' => '', 'width' => '', 'height' => '', ); } if ( ! is_string( $new_img_path ) ) { return array( 'url' => '', 'width' => '', 'height' => '', ); } $new_img_size = getimagesize( $new_img_path ); $new_img = str_replace( basename( $image_src[0] ), basename( $new_img_path ), $image_src[0] ); // resized output $vt_image = array( 'url' => $new_img, 'width' => $new_img_size[0], 'height' => $new_img_size[1], ); return $vt_image; } // default output - without resizing $vt_image = array( 'url' => $image_src[0], 'width' => $image_src[1], 'height' => $image_src[2], ); return $vt_image; } return false; } } if ( ! function_exists( 'wpb_debug' ) ) { /** * Returns bool if wpb_debug is provided in url - set visual composer debug mode. * Used for example in shortcodes (end block comment for example) * @since 4.2 * @return bool */ function wpb_debug() { if ( ( isset( $_GET['wpb_debug'] ) && 'true' === $_GET['wpb_debug'] ) || ( isset( $_GET['vc_debug'] ) && 'true' === $_GET['vc_debug'] ) ) { return true; } else { return false; } } } /** * Method adds css class to body tag. * * Hooked class method by body_class WP filter. Method adds custom css class to body tag of the page to help * identify and build design specially for VC shortcodes. * Used in wp-content/plugins/js_composer/include/classes/core/class-vc-base.php\Vc_Base\bodyClass * * @param $classes * * @since 4.2 * @return array */ function js_composer_body_class( $classes ) { $classes[] = 'wpb-js-composer js-comp-ver-' . WPB_VC_VERSION; $disable_responsive = vc_settings()->get( 'not_responsive_css' ); if ( '1' !== $disable_responsive ) { $classes[] = 'vc_responsive'; } else { $classes[] = 'vc_non_responsive'; } return $classes; } /** * @param $m * * @since 4.2 * @return string */ function vc_convert_shortcode( $m ) { list( $output, $m_one, $tag, $attr_string, $m_four, $content ) = $m; if ( 'vc_row' === $tag || 'vc_section' === $tag ) { return $output; } $result = $width = $el_position = ''; $shortcode_attr = shortcode_parse_atts( $attr_string ); extract( shortcode_atts( array( 'width' => '1/1', 'el_class' => '', 'el_position' => '', ), $shortcode_attr ) ); // Start if ( preg_match( '/first/', $el_position ) || empty( $shortcode_attr['width'] ) || '1/1' === $shortcode_attr['width'] ) { $result = '[vc_row]'; } if ( 'vc_column' !== $tag ) { $result .= '[vc_column width="' . $width . '"]'; } // Tag $pattern = get_shortcode_regex(); if ( 'vc_column' === $tag ) { $result .= "[{$m_one}{$tag} {$attr_string}]" . preg_replace_callback( "/{$pattern}/s", 'vc_convert_inner_shortcode', $content ) . "[/{$tag}{$m_four}]"; } elseif ( 'vc_tabs' === $tag || 'vc_accordion' === $tag || 'vc_tour' === $tag ) { $result .= "[{$m_one}{$tag} {$attr_string}]" . preg_replace_callback( "/{$pattern}/s", 'vc_convert_tab_inner_shortcode', $content ) . "[/{$tag}{$m_four}]"; } else { $result .= preg_replace( '/(\"\d\/\d\")/', '"1/1"', $output ); } // End if ( 'vc_column' !== $tag ) { $result .= '[/vc_column]'; } if ( preg_match( '/last/', $el_position ) || empty( $shortcode_attr['width'] ) || '1/1' === $shortcode_attr['width'] ) { $result .= '[/vc_row]' . "\n"; } return trim( $result ); } /** * @param $m * * @since 4.2 * @return string */ function vc_convert_tab_inner_shortcode( $m ) { list( $output, $m_one, $tag, $attr_string, $m_four, $content ) = $m; $result = $width = $el_position = ''; extract( shortcode_atts( array( 'width' => '1/1', 'el_class' => '', 'el_position' => '', ), shortcode_parse_atts( $attr_string ) ) ); $pattern = get_shortcode_regex(); $result .= "[{$m_one}{$tag} {$attr_string}]" . preg_replace_callback( "/{$pattern}/s", 'vc_convert_inner_shortcode', $content ) . "[/{$tag}{$m_four}]"; return $result; } /** * @param $m * * @since 4.2 * @return string */ function vc_convert_inner_shortcode( $m ) { list( $output, $m_one, $tag, $attr_string, $m_four, $content ) = $m; $result = $width = $el_position = ''; extract( shortcode_atts( array( 'width' => '1/1', 'el_class' => '', 'el_position' => '', ), shortcode_parse_atts( $attr_string ) ) ); if ( '1/1' !== $width ) { if ( preg_match( '/first/', $el_position ) ) { $result .= '[vc_row_inner]'; } $result .= "\n" . '[vc_column_inner width="' . esc_attr( $width ) . '" el_position="' . esc_attr( $el_position ) . '"]'; $attr = ''; foreach ( shortcode_parse_atts( $attr_string ) as $key => $value ) { if ( 'width' === $key ) { $value = '1/1'; } elseif ( 'el_position' === $key ) { $value = 'first last'; } $attr .= ' ' . $key . '="' . $value . '"'; } $result .= "[{$m_one}{$tag} {$attr}]" . $content . "[/{$tag}{$m_four}]"; $result .= '[/vc_column_inner]'; if ( preg_match( '/last/', $el_position ) ) { $result .= '[/vc_row_inner]' . "\n"; } } else { $result = $output; } return $result; } global $vc_row_layouts; $vc_row_layouts = array( /* * How to count mask? * mask = column_count . sum of all numbers. Example layout 12_12 mask = (column count=2)(1+2+1+2=6)= 26 */ array( 'cells' => '11', 'mask' => '12', 'title' => '1/1', 'icon_class' => '1-1', ), array( 'cells' => '12_12', 'mask' => '26', 'title' => '1/2 + 1/2', 'icon_class' => '1-2_1-2', ), array( 'cells' => '23_13', 'mask' => '29', 'title' => '2/3 + 1/3', 'icon_class' => '2-3_1-3', ), array( 'cells' => '13_13_13', 'mask' => '312', 'title' => '1/3 + 1/3 + 1/3', 'icon_class' => '1-3_1-3_1-3', ), array( 'cells' => '14_14_14_14', 'mask' => '420', 'title' => '1/4 + 1/4 + 1/4 + 1/4', 'icon_class' => '1-4_1-4_1-4_1-4', ), array( 'cells' => '14_34', 'mask' => '212', 'title' => '1/4 + 3/4', 'icon_class' => '1-4_3-4', ), array( 'cells' => '14_12_14', 'mask' => '313', 'title' => '1/4 + 1/2 + 1/4', 'icon_class' => '1-4_1-2_1-4', ), array( 'cells' => '56_16', 'mask' => '218', 'title' => '5/6 + 1/6', 'icon_class' => '5-6_1-6', ), array( 'cells' => '16_16_16_16_16_16', 'mask' => '642', 'title' => '1/6 + 1/6 + 1/6 + 1/6 + 1/6 + 1/6', 'icon_class' => '1-6_1-6_1-6_1-6_1-6_1-6', ), array( 'cells' => '16_23_16', 'mask' => '319', 'title' => '1/6 + 4/6 + 1/6', 'icon_class' => '1-6_2-3_1-6', ), array( 'cells' => '16_16_16_12', 'mask' => '424', 'title' => '1/6 + 1/6 + 1/6 + 1/2', 'icon_class' => '1-6_1-6_1-6_1-2', ), ); /** * @param $width * * @since 4.2 * @return string */ function wpb_vc_get_column_width_indent( $width ) { $identy = '11'; if ( 'vc_col-sm-6' === $width ) { $identy = '12'; } elseif ( 'vc_col-sm-3' === $width ) { $identy = '14'; } elseif ( 'vc_col-sm-4' === $width ) { $identy = '13'; } elseif ( 'vc_col-sm-8' === $width ) { $identy = '23'; } elseif ( 'vc_col-sm-9' === $width ) { $identy = '34'; } elseif ( 'vc_col-sm-2' === $width ) { $identy = '16'; // TODO: check why there is no "vc_col-sm-1, -5, -6, -7, -11, -12. } elseif ( 'vc_col-sm-10' === $width ) { $identy = '56'; } return $identy; } /* Make any HEX color lighter or darker ---------------------------------------------------------- */ /** * @param $colour * @param $per * * @since 4.2 * @return string */ function vc_colorCreator( $colour, $per = 10 ) { require_once 'class-vc-color-helper.php'; $color = $colour; if ( stripos( $colour, 'rgba(' ) !== false ) { $rgb = str_replace( array( 'rgba', 'rgb', '(', ')', ), '', $colour ); $rgb = explode( ',', $rgb ); $rgb_array = array( 'R' => $rgb[0], 'G' => $rgb[1], 'B' => $rgb[2], ); $alpha = $rgb[3]; try { $color = Vc_Color_Helper::rgbToHex( $rgb_array ); $color_obj = new Vc_Color_Helper( $color ); if ( $per >= 0 ) { $color = $color_obj->lighten( $per ); } else { $color = $color_obj->darken( abs( $per ) ); } $rgba = $color_obj->hexToRgb( $color ); $rgba[] = $alpha; $css_rgba_color = 'rgba(' . implode( ', ', $rgba ) . ')'; return $css_rgba_color; } catch ( Exception $e ) { // In case of error return same as given return $colour; } } else if ( stripos( $colour, 'rgb(' ) !== false ) { $rgb = str_replace( array( 'rgba', 'rgb', '(', ')', ), '', $colour ); $rgb = explode( ',', $rgb ); $rgb_array = array( 'R' => $rgb[0], 'G' => $rgb[1], 'B' => $rgb[2], ); try { $color = Vc_Color_Helper::rgbToHex( $rgb_array ); } catch ( Exception $e ) { // In case of error return same as given return $colour; } } try { $color_obj = new Vc_Color_Helper( $color ); if ( $per >= 0 ) { $color = $color_obj->lighten( $per ); } else { $color = $color_obj->darken( abs( $per ) ); } return '#' . $color; } catch ( Exception $e ) { return $colour; } } /* HEX to RGB converter ---------------------------------------------------------- */ /** * @param $color * * @since 4.2 * @return array|bool */ function vc_hex2rgb( $color ) { $color = str_replace( '#', '', $color ); if ( strlen( $color ) === 6 ) { list( $r, $g, $b ) = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5], ); } elseif ( strlen( $color ) === 3 ) { list( $r, $g, $b ) = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2], ); } else { return false; } $r = hexdec( $r ); $g = hexdec( $g ); $b = hexdec( $b ); return array( $r, $g, $b, ); } /** * Parse string like "title:Hello world|weekday:Monday" to array('title' => 'Hello World', 'weekday' => 'Monday') * * @param $value * @param array $default * * @since 4.2 * @return array */ function vc_parse_multi_attribute( $value, $default = array() ) { $result = $default; $params_pairs = explode( '|', $value ); if ( ! empty( $params_pairs ) ) { foreach ( $params_pairs as $pair ) { $param = preg_split( '/\:/', $pair ); if ( ! empty( $param[0] ) && isset( $param[1] ) ) { $result[ $param[0] ] = rawurldecode( $param[1] ); } } } return $result; } /** * @param $string * * @deprecated 4.5 * @since 4.2 * @return string */ function wpb_stripslashes_if_gpc_magic_quotes( $string ) { _deprecated_function( 'wpb_stripslashes_if_gpc_magic_quotes', '4.5 (will be removed in 5.1)', 'stripslashes' ); if ( get_magic_quotes_gpc() ) { return stripslashes( $string ); } else { return $string; } } /** * @param $v * * @since 4.2 * @return string */ function vc_param_options_parse_values( $v ) { return rawurldecode( $v ); } /** * @param $name * @param $settings * * @since 4.2 * @return bool */ function vc_param_options_get_settings( $name, $settings ) { if ( is_array( $settings ) ) { foreach ( $settings as $params ) { if ( isset( $params['name'] ) && $params['name'] === $name && isset( $params['type'] ) ) { return $params; } } } return false; } /** * @param $atts * * @since 4.2 * @return string */ function vc_convert_atts_to_string( $atts ) { $output = ''; foreach ( $atts as $key => $value ) { $output .= ' ' . $key . '="' . $value . '"'; } return $output; } /** * @param $string * @param $tag * @param $param * * @since 4.2 * @return array */ function vc_parse_options_string( $string, $tag, $param ) { $options = $option_settings_list = array(); $settings = WPBMap::getParam( $tag, $param ); foreach ( preg_split( '/\|/', $string ) as $value ) { if ( preg_match( '/\:/', $value ) ) { $split = preg_split( '/\:/', $value ); $option_name = $split[0]; $option_settings = $option_settings_list[ $option_name ] = vc_param_options_get_settings( $option_name, $settings['options'] ); if ( isset( $option_settings['type'] ) && 'checkbox' === $option_settings['type'] ) { $option_value = array_map( 'vc_param_options_parse_values', preg_split( '/\,/', $split[1] ) ); } else { $option_value = rawurldecode( $split[1] ); } $options[ $option_name ] = $option_value; } } if ( isset( $settings['options'] ) ) { foreach ( $settings['options'] as $setting_option ) { if ( 'separator' !== $setting_option['type'] && isset( $setting_option['value'] ) && empty( $options[ $setting_option['name'] ] ) ) { $options[ $setting_option['name'] ] = 'checkbox' === $setting_option['type'] ? preg_split( '/\,/', $setting_option['value'] ) : $setting_option['value']; } if ( isset( $setting_option['name'] ) && isset( $options[ $setting_option['name'] ] ) && isset( $setting_option['value_type'] ) ) { if ( 'integer' === $setting_option['value_type'] ) { $options[ $setting_option['name'] ] = (int) $options[ $setting_option['name'] ]; } elseif ( 'float' === $setting_option['value_type'] ) { $options[ $setting_option['name'] ] = (float) $options[ $setting_option['name'] ]; } elseif ( 'boolean' === $setting_option['value_type'] ) { $options[ $setting_option['name'] ] = (boolean) $options[ $setting_option['name'] ]; } } } } return $options; } /** * @since 4.2 * @deprecated 4.2 */ function wpb_js_composer_check_version_schedule_deactivation() { _deprecated_function( 'wpb_js_composer_check_version_schedule_deactivation', '4.2 (will be removed in 5.1)' ); wp_clear_scheduled_hook( 'wpb_check_for_update' ); delete_option( 'wpb_js_composer_show_new_version_message' ); } /** * Helper function to add new third-party adaptation class. * @deprecated 4.4 * @since 4.3 * * @param Vc_Vendor_Interface $vendor - instance of class. */ function vc_add_vendor( Vc_Vendor_Interface $vendor ) { _deprecated_function( 'vc_add_vendor', '4.4 (will be removed in 5.1)', 'autoload logic' ); visual_composer()->vendorsManager()->add( $vendor ); } /** * Convert string to a valid css class name. * * @since 4.3 * * @param string $class * * @return string */ function vc_build_safe_css_class( $class ) { return preg_replace( '/\W+/', '', strtolower( str_replace( ' ', '_', strip_tags( $class ) ) ) ); } /** * Include template from templates dir. * * @since 4.3 * * @param $template * @param array $variables - passed variables to the template. * * @param bool $once * * @return mixed */ function vc_include_template( $template, $variables = array(), $once = false ) { is_array( $variables ) && extract( $variables ); if ( $once ) { return require_once vc_template( $template ); } else { return require vc_template( $template ); } } /** * Output template from templates dir. * * @since 4.4 * * @param $template * @param array $variables - passed variables to the template. * * @param bool $once * * @return string */ function vc_get_template( $template, $variables = array(), $once = false ) { ob_start(); vc_include_template( $template, $variables, $once ); return ob_get_clean(); } /** * if php version < 5.3 this function is required. */ if ( ! function_exists( 'lcfirst' ) ) { /** * @param $str * * @since 4.3, fix #1093 * @return mixed */ function lcfirst( $str ) { $str[0] = function_exists( 'mb_strtolower' ) ? mb_strtolower( $str[0] ) : strtolower( $str[0] ); return $str; } } /** * VC Convert a value to studly caps case. * * @since 4.3 * * @param string $value * * @return string */ function vc_studly( $value ) { $value = ucwords( str_replace( array( '-', '_', ), ' ', $value ) ); return str_replace( ' ', '', $value ); } /** * VC Convert a value to camel case. * * @since 4.3 * * @param string $value * * @return string */ function vc_camel_case( $value ) { return lcfirst( vc_studly( $value ) ); } /** * Enqueue icon element font * @todo move to separate folder * @since 4.4 * * @param $font */ function vc_icon_element_fonts_enqueue( $font ) { switch ( $font ) { case 'fontawesome': wp_enqueue_style( 'font-awesome' ); break; case 'openiconic': wp_enqueue_style( 'vc_openiconic' ); break; case 'typicons': wp_enqueue_style( 'vc_typicons' ); break; case 'entypo': wp_enqueue_style( 'vc_entypo' ); break; case 'linecons': wp_enqueue_style( 'vc_linecons' ); break; case 'monosocial': wp_enqueue_style( 'vc_monosocialiconsfont' ); break; case 'material': wp_enqueue_style( 'vc_material' ); break; default: do_action( 'vc_enqueue_font_icon_element', $font ); // hook to custom do enqueue style } } /** * Function merges defaults attributes in attributes by keeping it values * * Example * array defaults | array attributes | result array * 'color'=>'black', - 'color'=>'black', * 'target'=>'_self', 'target'=>'_blank', 'target'=>'_blank', * - 'link'=>'google.com' 'link'=>'google.com' * * @since 4.4 * * @param array $defaults * @param array $attributes * * @return array - merged attributes * * @see vc_map_get_attributes */ function vc_shortcode_attribute_parse( $defaults = array(), $attributes = array() ) { $atts = $attributes + shortcode_atts( $defaults, $attributes ); return $atts; } function vc_get_shortcode_regex( $tagregexp = '' ) { if ( 0 === strlen( $tagregexp ) ) { return get_shortcode_regex(); } return '\\[' // Opening bracket . '(\\[?)' // 1: Optional second opening bracket for escaping shortcodes: [[tag]] . "($tagregexp)" // 2: Shortcode name . '(?![\\w-])' // Not followed by word character or hyphen . '(' // 3: Unroll the loop: Inside the opening shortcode tag . '[^\\]\\/]*' // Not a closing bracket or forward slash . '(?:' . '\\/(?!\\])' // A forward slash not followed by a closing bracket . '[^\\]\\/]*' // Not a closing bracket or forward slash . ')*?' . ')' . '(?:' . '(\\/)' // 4: Self closing tag ... . '\\]' // ... and closing bracket . '|' . '\\]' // Closing bracket . '(?:' . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing shortcode tags . '[^\\[]*+' // Not an opening bracket . '(?:' . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag . '[^\\[]*+' // Not an opening bracket . ')*+' . ')' . '\\[\\/\\2\\]' // Closing shortcode tag . ')?' . ')' . '(\\]?)'; } /** * Used to send warning message * * @since 4.5 * * @param $message * * @return string */ function vc_message_warning( $message ) { return '<div class="wpb_element_wrapper"><div class="vc_message_box vc_message_box-standard vc_message_box-rounded vc_color-warning"> <div class="vc_message_box-icon"><i class="fa fa-exclamation-triangle"></i> </div><p class="messagebox_text">' . $message . '</p> </div></div>'; } /** * Extract video ID from youtube url * * @param string $url Youtube url * * @return string */ function vc_extract_youtube_id( $url ) { parse_str( parse_url( $url, PHP_URL_QUERY ), $vars ); if ( ! isset( $vars['v'] ) ) { return ''; } return $vars['v']; } function vc_taxonomies_types() { global $vc_taxonomies_types; if ( is_null( $vc_taxonomies_types ) ) { $vc_taxonomies_types = get_taxonomies( array( 'public' => true ), 'objects' ); } return $vc_taxonomies_types; } /** * Since * * @since 4.5.3 * * @param $term * * @return array */ function vc_get_term_object( $term ) { $vc_taxonomies_types = vc_taxonomies_types(); return array( 'label' => $term->name, 'value' => $term->term_id, 'group_id' => $term->taxonomy, 'group' => isset( $vc_taxonomies_types[ $term->taxonomy ], $vc_taxonomies_types[ $term->taxonomy ]->labels, $vc_taxonomies_types[ $term->taxonomy ]->labels->name ) ? $vc_taxonomies_types[ $term->taxonomy ]->labels->name : __( 'Taxonomies', 'js_composer' ), ); } /** * Extract width/height from string * * @param string $dimensions WxH * * @since 4.7 * * @return mixed array(width, height) or false */ function vcExtractDimensions( $dimensions ) { $dimensions = str_replace( ' ', '', $dimensions ); $matches = null; if ( preg_match( '/(\d+)x(\d+)/', $dimensions, $matches ) ) { return array( $matches[1], $matches[2], ); } return false; } /** * Check if element has specific class * * E.g. f('foo', 'foo bar baz') -> true * * @param string $class Class to check for * @param string $classes Classes separated by space(s) * * @return bool */ function vc_has_class( $class, $classes ) { return in_array( $class, explode( ' ', strtolower( $classes ) ) ); } /** * Remove specific class from classes string * * E.g. f('foo', 'foo bar baz') -> 'bar baz' * * @param string $class Class to remove * @param string $classes Classes separated by space(s) * * @return string */ function vc_remove_class( $class, $classes ) { $list_classes = explode( ' ', strtolower( $classes ) ); $key = array_search( $class, $list_classes, true ); if ( false === $key ) { return $classes; } unset( $list_classes[ $key ] ); return implode( ' ', $list_classes ); } /** * Convert array of named params to string version * All values will be escaped * * E.g. f(array('name' => 'foo', 'id' => 'bar')) -> 'name="foo" id="bar"' * * @param $attributes * * @return string */ function vc_stringify_attributes( $attributes ) { $atts = array(); foreach ( $attributes as $name => $value ) { $atts[] = $name . '="' . esc_attr( $value ) . '"'; } return implode( ' ', $atts ); } function vc_is_responsive_disabled() { $disable_responsive = vc_settings()->get( 'not_responsive_css' ); return '1' === $disable_responsive; } /** * @deprecated 4.2 * @since 4.2 * @return mixed|string|void */ function get_row_css_class() { _deprecated_function( 'get_row_css_class', '4.2 (will be removed in 5.1)' ); $custom = vc_settings()->get( 'row_css_class' ); return ! empty( $custom ) ? $custom : 'vc_row-fluid'; } /** * @deprecated and will be removed * @since 4.2 * @return int */ function vc_get_interface_version() { _deprecated_function( 'vc_get_interface_version', '4.2 (will be removed in 5.1)' ); return 2; } /** * @deprecated and will be removed. * @since 4.2 * @return int */ function vc_get_initerface_version() { _deprecated_function( 'vc_get_initerface_version', '4.2 (will be removed in 5.1)' ); return vc_get_interface_version(); } /** * Do shortcode single render point * * @param $atts * @param null $content * @param null $tag * * @return string */ function vc_do_shortcode( $atts, $content = null, $tag = null ) { return Vc_Shortcodes_Manager::getInstance()->getElementClass( $tag )->output( $atts, $content ); } /** * Return random string * * @param int $length * * @return string */ function vc_random_string( $length = 10 ) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $len = strlen( $characters ); $str = ''; for ( $i = 0; $i < $length; $i ++ ) { $str .= $characters[ rand( 0, $len - 1 ) ]; } return $str; } function vc_slugify( $str ) { $str = strtolower( $str ); $str = html_entity_decode( $str ); $str = preg_replace( '/[^\w ]+/', '', $str ); $str = preg_replace( '/ +/', '-', $str ); return $str; } helpers_api.php 0000666 00000043511 15214053256 0007563 0 ustar 00 <?php if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } /** * Lean map shortcodes * * @since 4.9 * * @param $tag * @param null $settings_function * @param null $settings_file */ function vc_lean_map( $tag, $settings_function = null, $settings_file = null ) { WPBMap::leanMap( $tag, $settings_function, $settings_file ); } /** * @param $attributes * * @since 4.2 */ function vc_map( $attributes ) { if ( ! isset( $attributes['base'] ) ) { trigger_error( __( 'Wrong vc_map object. Base attribute is required', 'js_composer' ), E_USER_ERROR ); die(); } WPBMap::map( $attributes['base'], $attributes ); } /* Backwards compatibility **/ /** * @param $attributes * * @deprecated, use vc_map instead */ function wpb_map( $attributes ) { _deprecated_function( 'wpb_map', '4.2 (will be removed in 5.1)', 'vc_map' ); vc_map( $attributes ); } /** * @param $shortcode * * @since 4.2 */ function vc_remove_element( $shortcode ) { WPBMap::dropShortcode( $shortcode ); } /* Backwards compatibility **/ /** * @param $shortcode * * @since 4.2 * @deprecated use vc_remove_element instead */ function wpb_remove( $shortcode ) { _deprecated_function( 'wpb_remove', '4.2 (will be removed in 5.1)', 'vc_remove_element' ); vc_remove_element( $shortcode ); } /** * Add new shortcode param. * * @since 4.2 * * @param $shortcode - tag for shortcode * @param $attributes - attribute settings */ function vc_add_param( $shortcode, $attributes ) { WPBMap::addParam( $shortcode, $attributes ); } /** * Mass shortcode params adding function * * @since 4.3 * * @param $shortcode - tag for shortcode * @param $attributes - list of attributes arrays */ function vc_add_params( $shortcode, $attributes ) { if ( is_array( $attributes ) ) { foreach ( $attributes as $attr ) { vc_add_param( $shortcode, $attr ); } } } /** * Backwards compatibility * * @param $shortcode * @param $attributes * * @since 4.2 * @deprecated */ function wpb_add_param( $shortcode, $attributes ) { _deprecated_function( 'wpb_add_param', '4.2 (will be removed in 5.1)', 'vc_add_param' ); vc_add_param( $shortcode, $attributes ); } /** * Shorthand function for WPBMap::modify * * @param $name * @param $setting * @param string $value * * @since 4.2 * @return array|bool */ function vc_map_update( $name = '', $setting = '', $value = '' ) { return WPBMap::modify( $name, $setting, $value ); } /** * Shorthand function for WPBMap::mutateParam * * @param $name * @param array $attribute * * @since 4.2 * @return bool */ function vc_update_shortcode_param( $name, $attribute = array() ) { return WPBMap::mutateParam( $name, $attribute ); } /** * Shorthand function for WPBMap::dropParam * * @param $name * @param $attribute_name * * @since 4.2 * @return bool */ function vc_remove_param( $name = '', $attribute_name = '' ) { return WPBMap::dropParam( $name, $attribute_name ); } if ( ! function_exists( 'vc_set_as_theme' ) ) { /** * Sets plugin as theme plugin. * * @internal param bool $disable_updater - If value is true disables auto updater options. * * @since 4.2 */ function vc_set_as_theme() { vc_manager()->setIsAsTheme( true ); } } if ( ! function_exists( 'vc_is_as_theme' ) ) { /** * Is VC as-theme-plugin. * @since 4.2 * @return bool */ function vc_is_as_theme() { return vc_manager()->isAsTheme(); } } if ( ! function_exists( 'vc_is_updater_disabled' ) ) { /** * @since 4.2 * @return bool */ function vc_is_updater_disabled() { return vc_manager()->isUpdaterDisabled(); } } if ( ! function_exists( 'vc_default_editor_post_types' ) ) { /** * Returns list of default post type. * @since 4.2 * @return array */ function vc_default_editor_post_types() { return vc_manager()->editorDefaultPostTypes(); } } if ( ! function_exists( 'vc_set_default_editor_post_types' ) ) { /** * Set post types for VC editor. * @since 4.2 * * @param array $list - list of valid post types to set */ function vc_set_default_editor_post_types( array $list ) { vc_manager()->setEditorDefaultPostTypes( $list ); } } if ( ! function_exists( ( 'vc_editor_post_types' ) ) ) { /** * Returns list of post types where VC editor is enabled. * @since 4.2 * @return array */ function vc_editor_post_types() { return vc_manager()->editorPostTypes(); } } if ( ! function_exists( ( 'vc_editor_set_post_types' ) ) ) { /** * Set list of post types where VC editor is enabled. * @since 4.4 * * @param array $post_types * */ function vc_editor_set_post_types( array $post_types ) { vc_manager()->setEditorPostTypes( $post_types ); } } if ( ! function_exists( 'vc_mode' ) ) { /** * Return current VC mode. * @since 4.2 * @see Vc_Mapper::$mode * @return string */ function vc_mode() { return vc_manager()->mode(); } } if ( ! function_exists( 'vc_set_shortcodes_templates_dir' ) ) { /** * Sets directory where Visual Composer should look for template files for content elements. * @since 4.2 * * @param string - full directory path to new template directory with trailing slash */ function vc_set_shortcodes_templates_dir( $dir ) { vc_manager()->setCustomUserShortcodesTemplateDir( $dir ); } } if ( ! function_exists( 'vc_shortcodes_theme_templates_dir' ) ) { /** * Get custom theme template path * @since 4.2 * * @param $template - filename for template * * @return string */ function vc_shortcodes_theme_templates_dir( $template ) { return vc_manager()->getShortcodesTemplateDir( $template ); } } if ( ! function_exists( 'vc_set_template_dir' ) ) { /** * Sets directory where Visual Composer should look for template files for content elements. * @since 4.2 * @deprecated 4.2 * * @param string - full directory path to new template directory with trailing slash */ function vc_set_template_dir( $dir ) { _deprecated_function( 'vc_set_template_dir', '4.2 (will be removed in 5.1)', 'vc_set_shortcodes_templates_dir' ); vc_set_shortcodes_templates_dir( $dir ); } } /** * @param bool $value * * @todo check usage. * * @since 4.3 */ function set_vc_is_inline( $value = true ) { global $vc_is_inline; $vc_is_inline = $value; } /** * Disable frontend editor for VC * @since 4.3 * * @param bool $disable */ function vc_disable_frontend( $disable = true ) { vc_frontend_editor()->disableInline( $disable ); } /** * Check is front end enabled. * @since 4.3 * @return bool */ function vc_enabled_frontend() { return vc_frontend_editor()->frontendEditorEnabled(); } if ( ! function_exists( 'vc_add_default_templates' ) ) { /** * Add custom template in default templates list * * @param array $data | template data (name, content, custom_class, image_path) * * @since 4.3 * @return bool */ function vc_add_default_templates( $data ) { return visual_composer() ->templatesPanelEditor() ->addDefaultTemplates( $data ); } } function vc_map_integrate_shortcode( $shortcode, $field_prefix = '', $group_prefix = '', $change_fields = null, $dependency = null ) { if ( is_string( $shortcode ) ) { $shortcode_data = WPBMap::getShortCode( $shortcode ); } else { $shortcode_data = $shortcode; } if ( is_array( $shortcode_data ) && ! empty( $shortcode_data ) ) { /** * @var $shortcode WPBakeryShortCodeFishBones */ $params = isset( $shortcode_data['params'] ) && ! empty( $shortcode_data['params'] ) ? $shortcode_data['params'] : false; if ( is_array( $params ) && ! empty( $params ) ) { $keys = array_keys( $params ); for ( $i = 0; $i < count( $keys ); $i ++ ) { $param = &$params[ $keys[ $i ] ]; // Note! passed by reference to automatically update data if ( isset( $change_fields ) ) { $param = vc_map_integrate_include_exclude_fields( $param, $change_fields ); if ( empty( $param ) ) { continue; } } if ( ! empty( $group_prefix ) ) { if ( isset( $param['group'] ) ) { $param['group'] = $group_prefix . ': ' . $param['group']; } else { $param['group'] = $group_prefix; } } if ( ! empty( $field_prefix ) && isset( $param['param_name'] ) ) { $param['param_name'] = $field_prefix . $param['param_name']; if ( isset( $param['dependency'] ) && is_array( $param['dependency'] ) && isset( $param['dependency']['element'] ) ) { $param['dependency']['element'] = $field_prefix . $param['dependency']['element']; } $param = vc_map_integrate_add_dependency( $param, $dependency ); } elseif ( ! empty( $dependency ) ) { $param = vc_map_integrate_add_dependency( $param, $dependency ); } $param['integrated_shortcode'] = is_array( $shortcode ) ? $shortcode['base'] : $shortcode; $param['integrated_shortcode_field'] = $field_prefix; } } return is_array( $params ) ? array_filter( $params ) : array(); } return array(); } /** * Used to filter params (include/exclude) * * @internal * * @param $param * @param $change_fields * * @return array|null */ function vc_map_integrate_include_exclude_fields( $param, $change_fields ) { if ( is_array( $change_fields ) ) { if ( isset( $change_fields['exclude'] ) && in_array( $param['param_name'], $change_fields['exclude'] ) ) { $param = null; return $param; // to prevent group adding to $param } elseif ( isset( $change_fields['exclude_regex'] ) ) { if ( is_array( $change_fields['exclude_regex'] ) && ! empty( $change_fields['exclude_regex'] ) ) { $break_foreach = false; foreach ( $change_fields['exclude_regex'] as $regex ) { if ( false === @preg_match( $regex, null ) ) { // Regular expression is invalid, (don't remove @). } else { if ( preg_match( $regex, $param['param_name'] ) ) { $param = null; $break_foreach = true; } } if ( $break_foreach ) { break; } } if ( $break_foreach ) { return $param; // to prevent group adding to $param } } elseif ( is_string( $change_fields['exclude_regex'] ) && strlen( $change_fields['exclude_regex'] ) > 0 ) { if ( false === @preg_match( $change_fields['exclude_regex'], null ) ) { // Regular expression is invalid, (don't remove @). } else { if ( preg_match( $change_fields['exclude_regex'], $param['param_name'] ) ) { $param = null; return $param; // to prevent group adding to $param } } } } if ( isset( $change_fields['include_only'] ) && ! in_array( $param['param_name'], $change_fields['include_only'] ) ) { // if we want to enclude only some fields $param = null; return $param; // to prevent group adding to $param } elseif ( isset( $change_fields['include_only_regex'] ) ) { if ( is_array( $change_fields['include_only_regex'] ) && ! empty( $change_fields['include_only_regex'] ) ) { $break_foreach = false; foreach ( $change_fields['include_only_regex'] as $regex ) { if ( false === @preg_match( $regex, null ) ) { // Regular expression is invalid, (don't remove @). } else { if ( ! preg_match( $regex, $param['param_name'] ) ) { $param = null; $break_foreach = true; } } if ( $break_foreach ) { break; } } if ( $break_foreach ) { return $param; // to prevent group adding to $param } } elseif ( is_string( $change_fields['include_only_regex'] ) && strlen( $change_fields['include_only_regex'] ) > 0 ) { if ( false === @preg_match( $change_fields['include_only_regex'], null ) ) { // Regular expression is invalid, (don't remove @). } else { if ( ! preg_match( $change_fields['include_only_regex'], $param['param_name'] ) ) { $param = null; return $param; // to prevent group adding to $param } } } } } return $param; } /** * @internal used to add dependency to existed param * * @param $param * @param $dependency * * @return array */ function vc_map_integrate_add_dependency( $param, $dependency ) { // activator must be used for all elements who doesn't have 'dependency' if ( ! empty( $dependency ) && ( ! isset( $param['dependency'] ) || empty( $param['dependency'] ) ) ) { if ( is_array( $dependency ) ) { $param['dependency'] = $dependency; } } return $param; } function vc_map_integrate_get_params( $base_shortcode, $integrated_shortcode, $field_prefix = '' ) { $shortcode_data = WPBMap::getShortCode( $base_shortcode ); $params = array(); if ( is_array( $shortcode_data ) && is_array( $shortcode_data['params'] ) && ! empty( $shortcode_data['params'] ) ) { foreach ( $shortcode_data['params'] as $param ) { if ( is_array( $param ) && isset( $param['integrated_shortcode'] ) && $integrated_shortcode === $param['integrated_shortcode'] ) { if ( ! empty( $field_prefix ) ) { if ( isset( $param['integrated_shortcode_field'] ) && $field_prefix === $param['integrated_shortcode_field'] ) { $params[] = $param; } } else { $params[] = $param; } } } } return $params; } function vc_map_integrate_get_atts( $base_shortcode, $integrated_shortcode, $field_prefix = '' ) { $params = vc_map_integrate_get_params( $base_shortcode, $integrated_shortcode, $field_prefix ); $atts = array(); if ( is_array( $params ) && ! empty( $params ) ) { foreach ( $params as $param ) { $value = ''; if ( isset( $param['value'] ) ) { if ( isset( $param['std'] ) ) { $value = $param['std']; } elseif ( is_array( $param['value'] ) ) { reset( $param['value'] ); $value = current( $param['value'] ); } else { $value = $param['value']; } } $atts[ $param['param_name'] ] = $value; } } return $atts; } function vc_map_integrate_parse_atts( $base_shortcode, $integrated_shortcode, $atts, $field_prefix = '' ) { $params = vc_map_integrate_get_params( $base_shortcode, $integrated_shortcode, $field_prefix ); $data = array(); if ( is_array( $params ) && ! empty( $params ) ) { foreach ( $params as $param ) { if ( isset( $atts[ $param['param_name'] ] ) ) { $value = $atts[ $param['param_name'] ]; } if ( isset( $value ) ) { $key = $param['param_name']; if ( strlen( $field_prefix ) > 0 ) { $key = substr( $key, strlen( $field_prefix ) ); } $data[ $key ] = $value; } } } return $data; } function vc_map_add_css_animation( $label = true ) { $data = array( 'type' => 'animation_style', 'heading' => __( 'CSS Animation', 'js_composer' ), 'param_name' => 'css_animation', 'admin_label' => $label, 'value' => '', 'settings' => array( 'type' => 'in', 'custom' => array( array( 'label' => __( 'Default', 'js_composer' ), 'values' => array( __( 'Top to bottom', 'js_composer' ) => 'top-to-bottom', __( 'Bottom to top', 'js_composer' ) => 'bottom-to-top', __( 'Left to right', 'js_composer' ) => 'left-to-right', __( 'Right to left', 'js_composer' ) => 'right-to-left', __( 'Appear from center', 'js_composer' ) => 'appear', ), ), ), ), 'description' => __( 'Select type of animation for element to be animated when it "enters" the browsers viewport (Note: works only in modern browsers).', 'js_composer' ), ); /* array( 'label' => __( 'Slide Exits', 'js_composer' ), 'values' => array( __( 'slideOutDown', 'js_composer' ) => array( 'value' => 'slideOutDown', 'type' => 'out', ), __( 'slideOutLeft', 'js_composer' ) => array( 'value' => 'slideOutLeft', 'type' => 'out', ), __( 'slideOutRight', 'js_composer' ) => array( 'value' => 'slideOutRight', 'type' => 'out', ), __( 'slideOutUp', 'js_composer' ) => array( 'value' => 'slideOutUp', 'type' => 'out', ), ), ) */ return apply_filters( 'vc_map_add_css_animation', $data, $label ); } /** * Get settings of the mapped shortcode. * * @param $tag * * @since 4.4.3 * @return array|null - settings or null if shortcode not mapped */ function vc_get_shortcode( $tag ) { return WPBMap::getShortCode( $tag ); } /** * Remove all mapped shortcodes and the moment when function is called. * * @since 4.5 */ function vc_remove_all_elements() { WPBMap::dropAllShortcodes(); } /** * Function to get defaults values for shortcode. * @since 4.6 * * @param $tag - shortcode tag * * @return array - list of param=>default_value */ function vc_map_get_defaults( $tag ) { $shortcode = vc_get_shortcode( $tag ); $params = array(); if ( is_array( $shortcode ) && isset( $shortcode['params'] ) && ! empty( $shortcode['params'] ) ) { $params = vc_map_get_params_defaults( $shortcode['params'] ); } return $params; } /** * @param $params * * @since 4.12 * @return array */ function vc_map_get_params_defaults( $params ) { $resultParams = array(); foreach ( $params as $param ) { if ( isset( $param['param_name'] ) && 'content' !== $param['param_name'] ) { $value = ''; if ( isset( $param['std'] ) ) { $value = $param['std']; } elseif ( isset( $param['value'] ) ) { if ( is_array( $param['value'] ) ) { $value = current( $param['value'] ); if ( is_array( $value ) ) { // in case if two-dimensional array provided (vc_basic_grid) $value = current( $value ); } // return first value from array (by default) } else { $value = $param['value']; } } $resultParams[ $param['param_name'] ] = apply_filters( 'vc_map_get_param_defaults', $value, $param ); } } return $resultParams; } /** * @param $tag - shortcode tag3 * @param $atts - shortcode attributes * * @return array - return merged values with provided attributes ( * 'a'=>1,'b'=>2 + 'b'=>3,'c'=>4 --> 'a'=>1,'b'=>3 ) * * @see vc_shortcode_attribute_parse - return union of provided attributes ( * 'a'=>1,'b'=>2 + 'b'=>3,'c'=>4 --> 'a'=>1, * 'b'=>3, 'c'=>4 ) */ function vc_map_get_attributes( $tag, $atts = array() ) { return shortcode_atts( vc_map_get_defaults( $tag ), $atts, $tag ); } /** * New Vc now called Frontend editor * @deprecated 4.7 * @return Vc_Frontend_Editor * @since 4.3 */ function new_vc() { _deprecated_function( 'new_vc', '4.7 (will be removed in 5.1)', 'vc_frontend_editor' ); return vc_frontend_editor(); } class-vc-color-helper.php 0000666 00000026141 15214053256 0011374 0 ustar 00 <?php if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } /** * Author: Arlo Carreon <http://arlocarreon.com> * Info: http://mexitek.github.io/phpColors/ * License: http://arlo.mit-license.org/ * * @modified by js_composer * @since 4.8 */ class Vc_Color_Helper { /** * A color utility that helps manipulate HEX colors */ private $_hex; private $_hsl; private $_rgb; /** * Auto darkens/lightens by 10% for sexily-subtle gradients. * Set this to FALSE to adjust automatic shade to be between given color * and black (for darken) or white (for lighten) */ const DEFAULT_ADJUST = 10; /** * Instantiates the class with a HEX value * * @param string $hex * * @throws Exception "Bad color format" */ function __construct( $hex ) { // Strip # sign is present $color = str_replace( '#', '', $hex ); // Make sure it's 6 digits if ( strlen( $color ) === 3 ) { $color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2]; } else if ( strlen( $color ) != 6 ) { throw new Exception( 'HEX color needs to be 6 or 3 digits long' ); } $this->_hsl = self::hexToHsl( $color ); $this->_hex = $color; $this->_rgb = self::hexToRgb( $color ); } public static function clamp( $val, $max = 1 ) { return min( max( $val, 0 ), $max ); } // ==================== // = Public Interface = // ==================== /** * Given a HEX string returns a HSL array equivalent. * * @param string $color * * @return array HSL associative array */ public static function hexToHsl( $color ) { // Sanity check $color = self::_checkHex( $color ); // Convert HEX to DEC $R = hexdec( $color[0] . $color[1] ); $G = hexdec( $color[2] . $color[3] ); $B = hexdec( $color[4] . $color[5] ); $HSL = array(); $var_R = ( $R / 255.0 ); $var_G = ( $G / 255.0 ); $var_B = ( $B / 255.0 ); $var_Min = min( $var_R, $var_G, $var_B ); $var_Max = max( $var_R, $var_G, $var_B ); $del_Max = floatval( $var_Max - $var_Min ); $L = ( $var_Max + $var_Min ) / 2.0; $H = 0.0; $S = 0.0; if ( 0 != $del_Max ) { if ( $L < 0.5 ) { $S = $del_Max / ( $var_Max + $var_Min ); } else { $S = $del_Max / ( 2 - $var_Max - $var_Min ); } switch ( $var_Max ) { case $var_R: $H = ( $var_G - $var_B ) / $del_Max + ( $var_G < $var_B ? 6 : 0 ); break; case $var_G: $H = ( $var_B - $var_R ) / $del_Max + 2; break; case $var_B: $H = ( $var_R - $var_G ) / $del_Max + 4; break; } $H /= 6; } $HSL['H'] = ( $H * 360.0 ); $HSL['S'] = $S; $HSL['L'] = $L; return $HSL; } /** * Given a HSL associative array returns the equivalent HEX string * * @param array $hsl * * @return string HEX string * @throws Exception "Bad HSL Array" */ public static function hslToHex( $hsl = array() ) { // Make sure it's HSL if ( empty( $hsl ) || ! isset( $hsl['H'] ) || ! isset( $hsl['S'] ) || ! isset( $hsl['L'] ) ) { throw new Exception( 'Param was not an HSL array' ); } list( $H, $S, $L ) = array( fmod( $hsl['H'], 360 ) / 360.0, $hsl['S'], $hsl['L'], ); if ( 0 == $S ) { $r = $L * 255.0; $g = $L * 255.0; $b = $L * 255.0; } else { if ( $L < 0.5 ) { $var_2 = $L * ( 1.0 + $S ); } else { $var_2 = ( $L + $S ) - ( $S * $L ); } $var_1 = 2.0 * $L - $var_2; $r = self::clamp( round( 255.0 * self::_huetorgb( $var_1, $var_2, $H + ( 1 / 3 ) ) ), 255 ); $g = self::clamp( round( 255.0 * self::_huetorgb( $var_1, $var_2, $H ) ), 255 ); $b = self::clamp( round( 255.0 * self::_huetorgb( $var_1, $var_2, $H - ( 1 / 3 ) ) ), 255 ); } // Convert to hex $r = dechex( $r ); $g = dechex( $g ); $b = dechex( $b ); // Make sure we get 2 digits for decimals $r = ( strlen( '' . $r ) === 1 ) ? '0' . $r : $r; $g = ( strlen( '' . $g ) === 1 ) ? '0' . $g : $g; $b = ( strlen( '' . $b ) === 1 ) ? '0' . $b : $b; return $r . $g . $b; } /** * Given a HEX string returns a RGB array equivalent. * * @param string $color * * @return array RGB associative array */ public static function hexToRgb( $color ) { // Sanity check $color = self::_checkHex( $color ); // Convert HEX to DEC $R = hexdec( $color[0] . $color[1] ); $G = hexdec( $color[2] . $color[3] ); $B = hexdec( $color[4] . $color[5] ); $RGB['R'] = $R; $RGB['G'] = $G; $RGB['B'] = $B; return $RGB; } /** * Given an RGB associative array returns the equivalent HEX string * * @param array $rgb * * @return string RGB string * @throws Exception "Bad RGB Array" */ public static function rgbToHex( $rgb = array() ) { // Make sure it's RGB if ( empty( $rgb ) || ! isset( $rgb['R'] ) || ! isset( $rgb['G'] ) || ! isset( $rgb['B'] ) ) { throw new Exception( 'Param was not an RGB array' ); } // Convert RGB to HEX $hex[0] = dechex( $rgb['R'] ); if ( 1 === strlen( $hex[0] ) ) { $hex[0] .= $hex[0]; } $hex[1] = dechex( $rgb['G'] ); if ( 1 === strlen( $hex[1] ) ) { $hex[1] .= $hex[1]; } $hex[2] = dechex( $rgb['B'] ); if ( 1 === strlen( $hex[2] ) ) { $hex[2] .= $hex[2]; } return implode( '', $hex ); } /** * Given a HEX value, returns a darker color. If no desired amount provided, then the color halfway between * given HEX and black will be returned. * * @param int $amount * * @return string Darker HEX value */ public function darken( $amount = self::DEFAULT_ADJUST ) { // Darken $darkerHSL = $this->_darken( $this->_hsl, $amount ); // Return as HEX return self::hslToHex( $darkerHSL ); } /** * Given a HEX value, returns a lighter color. If no desired amount provided, then the color halfway between * given HEX and white will be returned. * * @param int $amount * * @return string Lighter HEX value */ public function lighten( $amount = self::DEFAULT_ADJUST ) { // Lighten $lighterHSL = $this->_lighten( $this->_hsl, $amount ); // Return as HEX return self::hslToHex( $lighterHSL ); } /** * Given a HEX value, returns a mixed color. If no desired amount provided, then the color mixed by this ratio * * @param string $hex2 Secondary HEX value to mix with * @param int $amount = -100..0..+100 * * @return string mixed HEX value */ public function mix( $hex2, $amount = 0 ) { $rgb2 = self::hexToRgb( $hex2 ); $mixed = $this->_mix( $this->_rgb, $rgb2, $amount ); // Return as HEX return self::rgbToHex( $mixed ); } /** * Creates an array with two shades that can be used to make a gradient * * @param int $amount Optional percentage amount you want your contrast color * * @return array An array with a 'light' and 'dark' index */ public function makeGradient( $amount = self::DEFAULT_ADJUST ) { // Decide which color needs to be made if ( $this->isLight() ) { $lightColor = $this->_hex; $darkColor = $this->darken( $amount ); } else { $lightColor = $this->lighten( $amount ); $darkColor = $this->_hex; } // Return our gradient array return array( 'light' => $lightColor, 'dark' => $darkColor ); } /** * Returns whether or not given color is considered "light" * * @param string|Boolean $color * * @return boolean */ public function isLight( $color = false ) { // Get our color $color = ( $color ) ? $color : $this->_hex; // Calculate straight from rbg $r = hexdec( $color[0] . $color[1] ); $g = hexdec( $color[2] . $color[3] ); $b = hexdec( $color[4] . $color[5] ); return ( ( $r * 299 + $g * 587 + $b * 114 ) / 1000 > 130 ); } /** * Returns whether or not a given color is considered "dark" * * @param string|Boolean $color * * @return boolean */ public function isDark( $color = false ) { // Get our color $color = ( $color ) ? $color : $this->_hex; // Calculate straight from rbg $r = hexdec( $color[0] . $color[1] ); $g = hexdec( $color[2] . $color[3] ); $b = hexdec( $color[4] . $color[5] ); return ( ( $r * 299 + $g * 587 + $b * 114 ) / 1000 <= 130 ); } /** * Returns the complimentary color * @return string Complementary hex color * */ public function complementary() { // Get our HSL $hsl = $this->_hsl; // Adjust Hue 180 degrees $hsl['H'] += ( $hsl['H'] > 180 ) ? - 180 : 180; // Return the new value in HEX return self::hslToHex( $hsl ); } /** * Returns your color's HSL array */ public function getHsl() { return $this->_hsl; } /** * Returns your original color */ public function getHex() { return $this->_hex; } /** * Returns your color's RGB array */ public function getRgb() { return $this->_rgb; } // =========================== // = Private Functions Below = // =========================== /** * Darkens a given HSL array * * @param array $hsl * @param int $amount * * @return array $hsl */ private function _darken( $hsl, $amount = self::DEFAULT_ADJUST ) { // Check if we were provided a number if ( $amount ) { $hsl['L'] = ( $hsl['L'] * 100 ) - $amount; $hsl['L'] = ( $hsl['L'] < 0 ) ? 0 : $hsl['L'] / 100; } else { // We need to find out how much to darken $hsl['L'] = $hsl['L'] / 2; } return $hsl; } /** * Lightens a given HSL array * * @param array $hsl * @param int $amount * * @return array $hsl */ private function _lighten( $hsl, $amount = self::DEFAULT_ADJUST ) { // Check if we were provided a number if ( $amount ) { $hsl['L'] = ( $hsl['L'] * 100.0 ) + $amount; $hsl['L'] = ( $hsl['L'] > 100.0 ) ? 1.0 : $hsl['L'] / 100.0; } else { // We need to find out how much to lighten $hsl['L'] += ( 1.0 - $hsl['L'] ) / 2.0; } return $hsl; } /** * Mix 2 rgb colors and return an rgb color * * @param array $rgb1 * @param array $rgb2 * @param int $amount ranged -100..0..+100 * * @return array $rgb * * ported from http://phpxref.pagelines.com/nav.html?includes/class.colors.php.source.html */ private function _mix( $rgb1, $rgb2, $amount = 0 ) { $r1 = ( $amount + 100 ) / 100; $r2 = 2 - $r1; $rmix = ( ( $rgb1['R'] * $r1 ) + ( $rgb2['R'] * $r2 ) ) / 2; $gmix = ( ( $rgb1['G'] * $r1 ) + ( $rgb2['G'] * $r2 ) ) / 2; $bmix = ( ( $rgb1['B'] * $r1 ) + ( $rgb2['B'] * $r2 ) ) / 2; return array( 'R' => $rmix, 'G' => $gmix, 'B' => $bmix ); } /** * Given a Hue, returns corresponding RGB value * * @param int $v1 * @param int $v2 * @param int $vH * * @return int */ private static function _huetorgb( $v1, $v2, $vH ) { if ( $vH < 0 ) { $vH += 1; } if ( $vH > 1 ) { $vH -= 1; } if ( ( 6 * $vH ) < 1 ) { return ( $v1 + ( $v2 - $v1 ) * 6 * $vH ); } if ( ( 2 * $vH ) < 1 ) { return $v2; } if ( ( 3 * $vH ) < 2 ) { return ( $v1 + ( $v2 - $v1 ) * ( ( 2 / 3 ) - $vH ) * 6 ); } return $v1; } /** * You need to check if you were given a good hex string * * @param string $hex * * @return string Color * @throws Exception "Bad color format" */ private static function _checkHex( $hex ) { // Strip # sign is present $color = str_replace( '#', '', $hex ); // Make sure it's 6 digits if ( strlen( $color ) == 3 ) { $color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2]; } else if ( strlen( $color ) != 6 ) { throw new Exception( 'HEX color needs to be 6 or 3 digits long' ); } return $color; } } helpers_factory.php 0000666 00000032261 15214053256 0010461 0 ustar 00 <?php if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } /** * WPBakery Visual Composer Main manager. * * @package WPBakeryVisualComposer * @since 4.2 */ if ( ! function_exists( 'vc_manager' ) ) { /** * Visual Composer manager. * @since 4.2 * @return Vc_Manager */ function vc_manager() { return Vc_Manager::getInstance(); } } if ( ! function_exists( 'visual_composer' ) ) { /** * Visual Composer instance. * @since 4.2 * @return Vc_Base */ function visual_composer() { return vc_manager()->vc(); } } if ( ! function_exists( 'vc_mapper' ) ) { /** * Shorthand for Vc Mapper. * @since 4.2 * @return Vc_Mapper */ function vc_mapper() { return vc_manager()->mapper(); } } if ( ! function_exists( 'vc_settings' ) ) { /** * Shorthand for Visual composer settings. * @since 4.2 * @return Vc_Settings */ function vc_settings() { return vc_manager()->settings(); } } if ( ! function_exists( 'vc_license' ) ) { /** * Get License manager * @since 4.2 * @return Vc_License */ function vc_license() { return vc_manager()->license(); } } if ( ! function_exists( 'vc_automapper' ) ) { /** * @since 4.2 * @return Vc_Automapper */ function vc_automapper() { return vc_manager()->automapper(); } } if ( ! function_exists( 'vc_frontend_editor' ) ) { /** * Shorthand for VC frontend editor * @since 4.2 * @return Vc_Frontend_Editor */ function vc_frontend_editor() { return vc_manager()->frontendEditor(); } } if ( ! function_exists( 'vc_backend_editor' ) ) { /** * Shorthand for VC frontend editor * @since 4.2 * @return Vc_Backend_Editor */ function vc_backend_editor() { return vc_manager()->backendEditor(); } } if ( ! function_exists( 'vc_updater' ) ) { /** * @since 4.2 * @return Vc_Updater */ function vc_updater() { return vc_manager()->updater(); } } if ( ! function_exists( 'vc_is_network_plugin' ) ) { /** * Vc is network plugin or not. * @since 4.2 * @return bool */ function vc_is_network_plugin() { return vc_manager()->isNetworkPlugin(); } } if ( ! function_exists( 'vc_path_dir' ) ) { /** * Get file/directory path in Vc. * * @param string $name - path name * @param string $file * * @since 4.2 * @return string */ function vc_path_dir( $name, $file = '' ) { return vc_manager()->path( $name, $file ); } } if ( ! function_exists( 'vc_asset_url' ) ) { /** * Get full url for assets. * * @param string $file * * @since 4.2 * @return string */ function vc_asset_url( $file ) { return vc_manager()->assetUrl( $file ); } } if ( ! function_exists( 'vc_upload_dir' ) ) { /** * Temporary files upload dir; * @since 4.2 * @return string */ function vc_upload_dir() { return vc_manager()->uploadDir(); } } if ( ! function_exists( 'vc_template' ) ) { /** * @param $file * * @since 4.2 * @return string */ function vc_template( $file ) { return vc_path_dir( 'TEMPLATES_DIR', $file ); } } if ( ! function_exists( 'vc_post_param' ) ) { /** * Get param value from $_POST if exists. * * @param $param * @param $default * * @since 4.2 * @return null|string - null for undefined param. */ function vc_post_param( $param, $default = null ) { return isset( $_POST[ $param ] ) ? $_POST[ $param ] : $default; } } if ( ! function_exists( 'vc_get_param' ) ) { /** * Get param value from $_GET if exists. * * @param string $param * @param $default * * @since 4.2 * @return null|string - null for undefined param. */ function vc_get_param( $param, $default = null ) { return isset( $_GET[ $param ] ) ? $_GET[ $param ] : $default; } } if ( ! function_exists( 'vc_request_param' ) ) { /** * Get param value from $_REQUEST if exists. * * @param $param * @param $default * * @since 4.4 * @return null|string - null for undefined param. */ function vc_request_param( $param, $default = null ) { return isset( $_REQUEST[ $param ] ) ? $_REQUEST[ $param ] : $default; } } if ( ! function_exists( 'vc_is_frontend_editor' ) ) { /** * @since 4.2 * @return bool */ function vc_is_frontend_editor() { return 'admin_frontend_editor' === vc_mode(); } } if ( ! function_exists( 'vc_is_page_editable' ) ) { /** * @since 4.2 * @return bool */ function vc_is_page_editable() { return 'page_editable' === vc_mode(); } } if ( ! function_exists( 'vc_action' ) ) { /** * Get VC special action param. * @since 4.2 * @return string|null */ function vc_action() { $vc_action = null; if ( isset( $_GET['vc_action'] ) ) { $vc_action = $_GET['vc_action']; } elseif ( isset( $_POST['vc_action'] ) ) { $vc_action = $_POST['vc_action']; } return $vc_action; } } if ( ! function_exists( 'vc_is_inline' ) ) { /** * Get is inline or not. * @since 4.2 * @return bool */ function vc_is_inline() { global $vc_is_inline; if ( is_null( $vc_is_inline ) ) { $vc_is_inline = ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && 'vc_inline' === vc_action() || ! is_null( vc_request_param( 'vc_inline' ) ) || 'true' === vc_request_param( 'vc_editable' ); } return $vc_is_inline; } } if ( ! function_exists( 'vc_is_frontend_ajax' ) ) { /** * @since 4.2 * @return bool */ function vc_is_frontend_ajax() { return 'true' === vc_post_param( 'vc_inline' ) || vc_get_param( 'vc_inline' ); } } /** * @depreacted since 4.8 ( use vc_is_frontend_editor ) * @since 4.2 * @return bool */ function vc_is_editor() { return vc_is_frontend_editor(); } /** * @param $value * @param bool $encode * * @since 4.2 * @return string */ function vc_value_from_safe( $value, $encode = false ) { $value = preg_match( '/^#E\-8_/', $value ) ? rawurldecode( base64_decode( preg_replace( '/^#E\-8_/', '', $value ) ) ) : $value; if ( $encode ) { $value = htmlentities( $value, ENT_COMPAT, 'UTF-8' ); } return $value; } /** * @since 4.2 * * @param bool $disable */ function vc_disable_automapper( $disable = true ) { vc_automapper()->setDisabled( $disable ); } /** * @since 4.2 * @return bool */ function vc_automapper_is_disabled() { return vc_automapper()->disabled(); } /** * @param $param * @param $value * * @since 4.2 * @return mixed|string */ function vc_get_dropdown_option( $param, $value ) { if ( '' === $value && is_array( $param['value'] ) ) { $value = array_shift( $param['value'] ); } if ( is_array( $value ) ) { reset( $value ); $value = isset( $value['value'] ) ? $value['value'] : current( $value ); } $value = preg_replace( '/\s/', '_', $value ); return ( '' !== $value ? $value : '' ); } /** * @param $prefix * @param $color * * @since 4.2 * @return string */ function vc_get_css_color( $prefix, $color ) { $rgb_color = preg_match( '/rgba/', $color ) ? preg_replace( array( '/\s+/', '/^rgba\((\d+)\,(\d+)\,(\d+)\,([\d\.]+)\)$/', ), array( '', 'rgb($1,$2,$3)', ), $color ) : $color; $string = $prefix . ':' . $rgb_color . ';'; if ( $rgb_color !== $color ) { $string .= $prefix . ':' . $color . ';'; } return $string; } /** * @param $param_value * @param string $prefix * * @since 4.2 * @return string */ function vc_shortcode_custom_css_class( $param_value, $prefix = '' ) { $css_class = preg_match( '/\s*\.([^\{]+)\s*\{\s*([^\}]+)\s*\}\s*/', $param_value ) ? $prefix . preg_replace( '/\s*\.([^\{]+)\s*\{\s*([^\}]+)\s*\}\s*/', '$1', $param_value ) : ''; return $css_class; } /** * @param $subject * @param $property * @param bool|false $strict * * @since 4.9 * @return bool */ function vc_shortcode_custom_css_has_property( $subject, $property, $strict = false ) { $styles = array(); $pattern = '/\{([^\}]*?)\}/i'; preg_match( $pattern, $subject, $styles ); if ( array_key_exists( 1, $styles ) ) { $styles = explode( ';', $styles[1] ); } $new_styles = array(); foreach ( $styles as $val ) { $val = explode( ':', $val ); if ( is_array( $property ) ) { foreach ( $property as $prop ) { $pos = strpos( $val[0], $prop ); $full = ( $strict ) ? ( 0 === $pos && strlen( $val[0] ) === strlen( $prop ) ) : true; if ( false !== $pos && $full ) { $new_styles[] = $val; } } } else { $pos = strpos( $val[0], $property ); $full = ( $strict ) ? ( 0 === $pos && strlen( $val[0] ) === strlen( $property ) ) : true; if ( false !== $pos && $full ) { $new_styles[] = $val; } } } return ! empty( $new_styles ); } /** * Plugin name for VC. * * @since 4.2 * @return string */ function vc_plugin_name() { return vc_manager()->pluginName(); } /** * @since 4.4.3 used in vc_base when getting an custom css output * * @param $filename * * @param bool $partial * @return bool|mixed|string */ function vc_file_get_contents( $filename, $partial = false ) { global $wp_filesystem; if ( empty( $wp_filesystem ) ) { require_once( ABSPATH . '/wp-admin/includes/file.php' ); WP_Filesystem(); } /** @var $wp_filesystem WP_Filesystem_Base */ if ( ! is_object( $wp_filesystem ) || ! $output = $wp_filesystem->get_contents( $filename ) ) { /*if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { } elseif ( ! $wp_filesystem->connect() ) { } elseif ( ! $wp_filesystem->is_writable( $filename ) ) { } else { }*/ $output = file_get_contents( $filename ); } return $output; } /** * HowTo: vc_role_access()->who('administrator')->with('editor')->can('frontend_editor'); * @since 4.8 * @return Vc_Role_Access; */ function vc_role_access() { return vc_manager()->getRoleAccess(); } /** * Get access manager for current user. * HowTo: vc_user_access()->->with('editor')->can('frontend_editor'); * @since 4.8 * @return Vc_Current_User_Access; */ function vc_user_access() { return vc_manager()->getCurrentUserAccess(); } function vc_user_roles_get_all() { require_once vc_path_dir( 'SETTINGS_DIR', 'class-vc-roles.php' ); $vc_roles = new Vc_Roles(); $capabilities = array(); foreach ( $vc_roles->getParts() as $part ) { $partObj = vc_user_access()->part( $part ); $capabilities[ $part ] = array( 'state' => $partObj->getState(), 'state_key' => $partObj->getStateKey(), 'capabilities' => $partObj->getAllCaps(), ); } return $capabilities; } /** * Return a $_GET action param for ajax * @since 4.8 * @return bool */ function vc_wp_action() { return isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : false; } /** * @param $data * * @return string */ function vc_generate_nonce( $data ) { return wp_create_nonce( is_array( $data ) ? ( 'vc-nonce-' . implode( '|', $data ) ) : ( 'vc-nonce-' . $data ) ); } /** * @param $nonce * @param $data * * @return bool */ function vc_verify_nonce( $nonce, $data ) { return (bool) wp_verify_nonce( $nonce, ( is_array( $data ) ? ( 'vc-nonce-' . implode( '|', $data ) ) : ( 'vc-nonce-' . $data ) ) ); } /** * @param $nonce * * @return bool */ function vc_verify_admin_nonce( $nonce = '' ) { return (bool) vc_verify_nonce( ! empty( $nonce ) ? $nonce : vc_request_param( '_vcnonce' ), 'vc-admin-nonce' ); } /** * @param $nonce * * @return bool */ function vc_verify_public_nonce( $nonce = '' ) { return (bool) vc_verify_nonce( ( ! empty( $nonce ) ? $nonce : vc_request_param( '_vcnonce' ) ), 'vc-public-nonce' ); } function vc_check_post_type( $type ) { if ( empty( $type ) ) { $type = get_post_type(); } $valid = apply_filters( 'vc_check_post_type_validation', null, $type ); if ( is_null( $valid ) ) { if ( is_multisite() && is_super_admin() ) { return true; } $state = vc_user_access()->part( 'post_types' )->getState(); if ( null === $state ) { return in_array( $type, vc_default_editor_post_types() ); } else if ( true === $state && ! in_array( $type, vc_default_editor_post_types() ) ) { $valid = false; } else { $valid = vc_user_access()->part( 'post_types' )->can( $type )->get(); } } return $valid; } function vc_user_access_check_shortcode_edit( $shortcode ) { $do_check = apply_filters( 'vc_user_access_check-shortcode_edit', null, $shortcode ); if ( is_null( $do_check ) ) { $state_check = vc_user_access()->part( 'shortcodes' )->checkStateAny( true, 'edit', null )->get(); if ( $state_check ) { return true; } else { return vc_user_access()->part( 'shortcodes' )->canAny( $shortcode . '_all', $shortcode . '_edit' )->get(); } } else { return $do_check; } } function vc_user_access_check_shortcode_all( $shortcode ) { $do_check = apply_filters( 'vc_user_access_check-shortcode_all', null, $shortcode ); if ( is_null( $do_check ) ) { return vc_user_access()->part( 'shortcodes' )->checkStateAny( true, 'custom', null )->can( $shortcode . '_all' )->get(); } else { return $do_check; } } /** * htmlspecialchars_decode_deep * Call the htmlspecialchars_decode to a gived multilevel array * * @since 4.8 * * @param mixed $value The value to be stripped. * * @return mixed Stripped value. */ function vc_htmlspecialchars_decode_deep( $value ) { if ( is_array( $value ) ) { $value = array_map( 'vc_htmlspecialchars_decode_deep', $value ); } elseif ( is_object( $value ) ) { $vars = get_object_vars( $value ); foreach ( $vars as $key => $data ) { $value->{$key} = vc_htmlspecialchars_decode_deep( $data ); } } elseif ( is_string( $value ) ) { $value = htmlspecialchars_decode( $value ); } return $value; } function vc_str_remove_protocol( $str ) { return str_replace( array( 'https://', 'http://', ), '//', $str ); } filters.php 0000666 00000002665 15214053256 0006745 0 ustar 00 <?php if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } /** * WPBakery Visual Composer filter functions * * @package WPBakeryVisualComposer * * http://kb.wpbakery.com/index.php?title=Visual_Composer_Filters */ /** * This filter should be applied to all content elements titles * * $params['extraclass'] Extra class name will be added * * * To override content element title default html markup, paste this code in your theme's functions.php file * vc_filter: wpb_widget_title * add_filter('wpb_widget_title', 'override_widget_title', 10, 2); * function override_widget_title($output = '', $params = array('')) { * $extraclass = (isset($params['extraclass'])) ? " ".$params['extraclass'] : ""; * return '<h1 class="entry-title'.$extraclass.'">'.$params['title'].'</h1>'; * } * * @param array $params * * @return mixed|string|void */ function wpb_widget_title( $params = array( 'title' => '' ) ) { if ( '' === $params['title'] ) { return ''; } $extraclass = ( isset( $params['extraclass'] ) ) ? ' ' . $params['extraclass'] : ''; $output = '<h2 class="wpb_heading' . $extraclass . '">' . $params['title'] . '</h2>'; return apply_filters( 'wpb_widget_title', $output, $params ); } /* Available filters in default.php wpb_toggle_heading Available filters in buttons.php wpb_cta_text Available filters in teaser_grid.php vc_teaser_grid_title vc_teaser_grid_thumbnail vc_teaser_grid_content vc_teaser_grid_carousel_arrows */
| ver. 1.4 |
Github
|
.
| PHP 7.0.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings