map_params(); $maps = apply_filters( 'thinkai_vc_map', $this->maps ); foreach ( $maps as $value) { $file = $this->get_file( $value ); if ( file_exists( $file ) ) { $data = include $file; vc_map( $data ); if ( function_exists( 'wpthinkai_shortcode' ) ) { $tag = esc_attr( thinkai_set( $data, 'base' ) ); wpthinkai_shortcode( $tag, array( $this, 'output' ) ); } } } } function output( $atts, $content = null, $tag ) { $params = $this->shortcodeParams( $tag ); ob_start(); thinkai_template_load( 'shortcodes/' . $tag . '.php', compact( 'atts', 'content', 'tag' ) ); return ob_get_clean(); } function get_file( $tag ) { $file = thinkai_template( 'includes/resource/vc_map/'.$tag . '.php' ); $file = apply_filters( "thinkai_vc_map_file_{$tag}", $file ); return $file; } /** * shortcode params from vc array. * * @param string $tag shortcode tag * @return array params */ function shortcodeParams( $tag ) { $file = $this->get_file( $tag ); if ( file_exists( $file ) ) { $data = include $file; return thinkai_set( $data, 'params' ); } return array(); } function map_params() { $array = array( 'vc_row', ); foreach( $array as $file ) { $file = $this->get_file( $file ); if ( file_exists( $file ) ) { $data = include $file; foreach ( $data as $key => $value) { foreach( $value as $param ) { vc_add_param( $key, $param ); } } } } } /** * Checkbox shortcode attribute type generator. * * @param $settings * @param string $value * * @since 4.4 * @return string - html string. */ function toggle( $settings, $value ) { $output = ''; if ( is_array( $value ) ) { $value = ''; } $current_value = strlen( $value ) > 0 ? explode( ',', $value ) : array(); $values = isset( $settings['value'] ) && is_array( $settings['value'] ) ? $settings['value'] : array( esc_html__( 'Yes', 'thinkai' ) => 'true' ); if ( ! empty( $values ) ) { foreach ( $values as $label => $v ) { $checked = count( $current_value ) > 0 && in_array( $v, $current_value ) ? ' checked' : ''; $output .= ' '; } } return $output; } }