PluginProbe
Borderless – Addons and Templates for Elementor / 1.6.1
Borderless – Addons and Templates for Elementor v1.6.1
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 All 78 releases
borderless / modules / wpbakery / elements / svg.php

svg.php in Borderless – Addons and Templates for Elementor 1.6.1, at modules/wpbakery/elements/svg.php

136 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( '-1' );
4 }
5
6 /*-----------------------------------------------------------------------------------*/
7 /* SVG
8 /*-----------------------------------------------------------------------------------*/
9
10 class WPBakeryShortCode_borderless_wpbakery_svg extends WPBakeryShortCode {
11 protected function content( $atts, $content = null ) {
12 extract( shortcode_atts( array(
13 'svg' => '',
14 'alignment' => 'left',
15 'height' => 'auto',
16 'width' => '100%',
17 // Static
18 'el_id' => '',
19 'el_class' => '',
20 'css' => '',
21 'css_animation' => ''
22 ), $atts ) );
23 $output = '';
24
25 // Assets.
26 wp_enqueue_style(
27 'borderless-wpbakery-style',
28 BORDERLESS__STYLES . 'wpbakery.min.css',
29 false,
30 BORDERLESS__VERSION
31 );
32
33 // Retrieve data from the database.
34 $options = get_option( 'borderless' );
35
36 // Set default values
37 $borderless_primary_color = isset( $options['primary_color'] ) ? $options['primary_color'] : '#3379fc'; // Primary Color
38 $borderless_secondary_color = isset( $options['secondary_color'] ) ? $options['secondary_color'] : '#3379fc'; // Secondary Color
39 $borderless_text_color = isset( $options['text_color'] ) ? $options['text_color'] : ''; // Text Color
40 $borderless_accent_color = isset( $options['accent_color'] ) ? $options['accent_color'] : '#3379fc'; // Accent Color
41
42 $svg_img = wp_get_attachment_image_src( $svg );
43 $svg_src = isset( $svg_img[0] ) ? $svg_img[0] : '';
44
45 // Default Extra Class, CSS and CSS animation
46 $css = isset( $atts['css'] ) ? $atts['css'] : '';
47 $el_id = isset( $atts['el_id'] ) ? $atts['el_id'] : '';
48 $el_id = ! empty( $el_id ) ? 'id="' . esc_attr( $el_id ) . '"' : '';
49 $el_class = isset( $atts['el_class'] ) ? $atts['el_class'] : '';
50 if ( '' !== $css_animation ) {
51 wp_enqueue_script( 'waypoints' );
52 $css_animation_style = ' wpb_animate_when_almost_visible wpb_' . esc_attr( $css_animation );
53 }
54 $class_to_filter = vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $css_animation );
55 $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts );
56
57 // Output
58 $alignment = esc_attr( $alignment );
59 $height = esc_attr( $height );
60 $width = esc_attr( $width );
61 $svg_src = esc_url( $svg_src );
62 $css_class = esc_attr( $css_class );
63
64 $output .= '<div ' . $el_id . ' class="borderless-wpbakery-svg ' . $css_class . ' ' . $alignment . '">';
65 $output .= '<div class="borderless-wpbakery-svg-inner" style="height:' . $height . ';width:' . $width . ';"><img class="borderless-svg-img" src="' . $svg_src . '"/></div>';
66 $output .= '</div>';
67
68 return $output;
69 }
70 }
71
72
73 return array(
74 'name' => __( 'SVG', 'borderless' ),
75 'base' => 'borderless_wpbakery_svg',
76 'icon' => plugins_url('../images/svg.png', __FILE__),
77 'show_settings_on_create' => true,
78 'category' => __( 'Borderless', 'borderless' ),
79 'description' => __( 'Animated or static SVG for your content', 'borderless' ),
80 'params' => array(
81 array(
82 'type' => 'attach_image',
83 'heading' => __( 'SVG', 'borderless' ),
84 'param_name' => 'svg',
85 'description' => __( 'Select a SVG Icon from media library.', 'borderless' ),
86 ),
87 array(
88 'type' => 'textfield',
89 'heading' => __( 'Height', 'borderless' ),
90 'param_name' => 'height',
91 'description' => __( 'Insert the SVG height.', 'borderless' ),
92 ),
93 array(
94 'type' => 'textfield',
95 'heading' => __( 'Width', 'borderless' ),
96 'param_name' => 'width',
97 'description' => __( 'Insert the SVG width.', 'borderless' ),
98 ),
99 array(
100 'type' => 'dropdown',
101 'heading' => __( 'Alignment', 'borderless' ),
102 'param_name' => 'alignment',
103 'value' => array(
104 __( 'Left', 'borderless' ) => 'borderless-wpbakery-svg-align-left',
105 __( 'Right', 'borderless' ) => 'borderless-wpbakery-svg-align-right',
106 __( 'Center', 'borderless' ) => 'borderless-wpbakery-svg-align-center',
107 ),
108 'description' => __( 'Select icon alignment.', 'borderless' ),
109 ),
110
111 // Animation
112 vc_map_add_css_animation(),
113
114 array(
115 'type' => 'el_id',
116 'heading' => __( 'Element ID', 'borderless' ),
117 'param_name' => 'el_id',
118 'description' => sprintf( __( 'Enter element ID (Note: make sure it is unique and valid according to %sw3c specification%s).', 'borderless' ), '<a href="https://www.w3schools.com/tags/att_global_id.asp" target="_blank">', '</a>' ),
119 ),
120
121 array(
122 'type' => 'textfield',
123 'heading' => __( 'Extra class name', 'borderless' ),
124 'param_name' => 'el_class',
125 'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'borderless' ),
126 ),
127
128 array(
129 'type' => 'css_editor',
130 'heading' => __( 'CSS box', 'borderless' ),
131 'param_name' => 'css',
132 'group' => __( 'Design Options', 'borderless' ),
133 ),
134 ),
135 );
136