| @@ -26,67 +26,72 @@ | ||
| 26 | 26 | 'css_animation' => '' |
| 27 | 27 | ), $atts ) ); |
| 28 | 28 | $output = ''; |
| 29 | 29 | |
| 30 | + // Assets. | |
| 31 | + wp_enqueue_style( | |
| 32 | + 'borderless-wpbakery-style', | |
| 33 | + BORDERLESS__STYLES . 'wpbakery.min.css', | |
| 34 | + false, | |
| 35 | + BORDERLESS__VERSION | |
| 36 | + ); | |
| 30 | 37 | |
| 31 | 38 | // Retrieve data from the database. |
| 32 | 39 | $options = get_option( 'borderless' ); |
| 33 | 40 | |
| 34 | - | |
| 35 | 41 | // Set default values |
| 36 | - $borderless_primary_color = isset( $options['primary_color'] ) ? $options['primary_color'] : '#3379fc'; //Primary Color | |
| 37 | - $borderless_secondary_color = isset( $options['secondary_color'] ) ? $options['secondary_color'] : '#3379fc'; //Secondary Color | |
| 38 | - $borderless_text_color = isset( $options['text_color'] ) ? $options['text_color'] : ''; //Text Color | |
| 39 | - $borderless_accent_color = isset( $options['accent_color'] ) ? $options['accent_color'] : '#3379fc'; //Accent Color | |
| 40 | - | |
| 41 | - | |
| 42 | + $borderless_primary_color = isset( $options['primary_color'] ) ? esc_attr( $options['primary_color'] ) : '#3379fc'; //Primary Color | |
| 43 | + $borderless_secondary_color = isset( $options['secondary_color'] ) ? esc_attr( $options['secondary_color'] ) : '#3379fc'; //Secondary Color | |
| 44 | + $borderless_text_color = isset( $options['text_color'] ) ? esc_attr( $options['text_color'] ) : ''; //Text Color | |
| 45 | + $borderless_accent_color = isset( $options['accent_color'] ) ? esc_attr( $options['accent_color'] ) : '#3379fc'; //Accent Color | |
| 46 | + | |
| 42 | 47 | // Default Extra Class, CSS and CSS animation |
| 43 | - $css = isset( $atts['css'] ) ? $atts['css'] : ''; | |
| 44 | - $el_id = isset( $atts['el_id'] ) ? 'id="' . esc_attr( $el_id ) . '"' : ''; | |
| 45 | - $el_class = isset( $atts['el_class'] ) ? $atts['el_class'] : ''; | |
| 48 | + $css = isset( $atts['css'] ) ? esc_attr( $atts['css'] ) : ''; | |
| 49 | + $el_id = isset( $atts['el_id'] ) ? 'id="' . esc_attr( $atts['el_id'] ) . '"' : ''; | |
| 50 | + $el_class = isset( $atts['el_class'] ) ? esc_attr( $atts['el_class'] ) : ''; | |
| 46 | 51 | if ( '' !== $css_animation ) { |
| 47 | 52 | wp_enqueue_script( 'waypoints' ); |
| 48 | - $css_animation_style = ' wpb_animate_when_almost_visible wpb_' . $css_animation; | |
| 53 | + $css_animation_style = ' wpb_animate_when_almost_visible wpb_' . esc_attr( $css_animation ); | |
| 49 | 54 | } |
| 50 | 55 | $class_to_filter = vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $css_animation ); |
| 51 | 56 | $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts ); |
| 52 | - | |
| 53 | - | |
| 57 | + | |
| 54 | 58 | // Set custom values |
| 55 | 59 | $link = vc_build_link( $link ); |
| 56 | - $color = ($icon_color == 'custom') ? 'color:'.$custom_icon_color.';' : 'color:'.$ve_global_color.';'; //Icon Color | |
| 57 | - $font_size_reference = $icon_size; | |
| 58 | - $icon_size = $icon_size ? 'font-size:'.$icon_size.';' : ' font-size:4rem;'; //Font Size | |
| 59 | - $icon_alignment = $icon_alignment ? 'text-align:'.$icon_alignment.';' : ''; //Icon Alignment | |
| 60 | - | |
| 61 | - if($shape != '') { | |
| 60 | + $color = ($icon_color == 'custom') ? 'color:' . esc_attr( $custom_icon_color ) . ';' : 'color:' . esc_attr( $borderless_primary_color ) . ';'; //Icon Color | |
| 61 | + $font_size_reference = esc_attr( $icon_size ); | |
| 62 | + $icon_size = $icon_size ? 'font-size:' . esc_attr( $icon_size ) . ';' : ' font-size:4rem;'; //Font Size | |
| 63 | + $icon_alignment = $icon_alignment ? 'text-align:' . esc_attr( $icon_alignment ) . ';' : ''; //Icon Alignment | |
| 62 | 64 | |
| 63 | - if($shape == 'rounded' || $shape == 'square' || $shape == 'round') { | |
| 64 | - $color_shape = $color_shape ? 'background-color:'.$color_shape.';' : 'background-color:'.$borderless_primary_color.';'; //Background Color | |
| 65 | + if ( $shape != '' ) { | |
| 66 | + if ( $shape == 'rounded' || $shape == 'square' || $shape == 'round' ) { | |
| 67 | + $color_shape = $color_shape ? 'background-color:' . esc_attr( $color_shape ) . ';' : 'background-color:' . esc_attr( $borderless_primary_color ) . ';'; //Background Color | |
| 65 | 68 | } else { |
| 66 | - $color_shape = $color_shape ? 'border-color:'.$color_shape.';' : 'border-color:'.$borderless_primary_color.';'; //Border Color | |
| 69 | + $color_shape = $color_shape ? 'border-color:' . esc_attr( $color_shape ) . ';' : 'border-color:' . esc_attr( $borderless_primary_color ) . ';'; //Border Color | |
| 67 | 70 | } |
| 68 | - | |
| 69 | 71 | } else { |
| 70 | 72 | $color_shape = $default_color_shape = ''; |
| 71 | 73 | } |
| 72 | - | |
| 73 | - if($spacing != '') { | |
| 74 | - $spacing = 'height:'.$spacing.'; width:'.$spacing.';'; | |
| 74 | + | |
| 75 | + if ( $spacing != '' ) { | |
| 76 | + $spacing = 'height:' . esc_attr( $spacing ) . '; width:' . esc_attr( $spacing ) . ';'; | |
| 75 | 77 | } else { |
| 76 | - $spacing = 'height:calc('.$font_size_reference.' + 2em); width:calc('.$font_size_reference.' + 2em);'; | |
| 78 | + $spacing = 'height:calc(' . esc_attr( $font_size_reference ) . ' + 2em); width:calc(' . esc_attr( $font_size_reference ) . ' + 2em);'; | |
| 77 | 79 | } |
| 78 | - | |
| 79 | - | |
| 80 | + | |
| 80 | 81 | // Output |
| 81 | - $output .= '<div '.$el_id.' class="borderless-wpbakery-icon background-shape '.$css_class.'" style="'.$icon_alignment.'">'; | |
| 82 | - if($link['url'] != ''){$output .= '<a href="'.esc_attr( $link['url'] ).'">';} | |
| 83 | - $output .= '<div style="'.$color_shape.''.$spacing.'" class="single-icon '.$shape.'">'; | |
| 84 | - $output .= '<i class="'.$icon.'" style="'.$color.$icon_size.'" aria-hidden="true"></i>'; | |
| 82 | + $output .= '<div ' . $el_id . ' class="borderless-wpbakery-icon background-shape ' . esc_attr( $css_class ) . '" style="' . esc_attr( $icon_alignment ) . '">'; | |
| 83 | + if ( ! empty( $link['url'] ) ) { | |
| 84 | + $output .= '<a href="' . esc_url( $link['url'] ) . '">'; | |
| 85 | + } | |
| 86 | + $output .= '<div style="' . esc_attr( $color_shape ) . '' . esc_attr( $spacing ) . '" class="single-icon ' . esc_attr( $shape ) . '">'; | |
| 87 | + $output .= '<i class="' . esc_attr( $icon ) . '" style="' . esc_attr( $color ) . esc_attr( $icon_size ) . '" aria-hidden="true"></i>'; | |
| 85 | 88 | $output .= '</div>'; |
| 86 | - if($link['url'] != ''){$output .= '</a>';} | |
| 89 | + if ( ! empty( $link['url'] ) ) { | |
| 90 | + $output .= '</a>'; | |
| 91 | + } | |
| 87 | 92 | $output .= '</div>'; |
| 88 | - | |
| 93 | + | |
| 89 | 94 | return $output; |
| 90 | 95 | } |
| 91 | 96 | } |
| 92 | 97 | |
| @@ -145,9 +150,9 @@ | ||
| 145 | 150 | 'param_name' => 'color_shape', |
| 146 | 151 | 'description' => __( 'Select custom shape background color.', 'borderless' ), |
| 147 | 152 | 'dependency' => array( |
| 148 | 153 | 'element' => 'shape', |
| 149 | - 'value' => array( 'rounded','square','round','outline-rounded','outline-square','outline-round', ), | |
| 154 | + 'value' => array( 'rounded', 'square', 'round', 'outline-rounded', 'outline-square', 'outline-round' ), | |
| 150 | 155 | ), |
| 151 | 156 | ), |
| 152 | 157 | array( |
| 153 | 158 | 'type' => 'textfield', |
| @@ -184,31 +189,25 @@ | ||
| 184 | 189 | 'heading' => __( 'URL (Link)', 'borderless' ), |
| 185 | 190 | 'param_name' => 'link', |
| 186 | 191 | 'description' => __( 'Add link to icon.', 'borderless' ), |
| 187 | 192 | ), |
| 188 | - | |
| 189 | - // Animation | |
| 190 | 193 | vc_map_add_css_animation(), |
| 191 | - | |
| 192 | 194 | array( |
| 193 | 195 | 'type' => 'el_id', |
| 194 | 196 | 'heading' => __( 'Element ID', 'borderless' ), |
| 195 | 197 | 'param_name' => 'el_id', |
| 196 | 198 | '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>' ), |
| 197 | - ), | |
| 198 | - | |
| 199 | - array( | |
| 200 | - 'type' => 'textfield', | |
| 201 | - 'heading' => __( 'Extra class name', 'borderless' ), | |
| 202 | - 'param_name' => 'el_class', | |
| 203 | - 'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'borderless' ), | |
| 204 | - ), | |
| 205 | - | |
| 206 | - array( | |
| 207 | - 'type' => 'css_editor', | |
| 208 | - 'heading' => __( 'CSS box', 'borderless' ), | |
| 209 | - 'param_name' => 'css', | |
| 210 | - 'group' => __( 'Design Options', 'borderless' ), | |
| 211 | - ), | |
| 212 | 199 | ), |
| 213 | - ); | |
| 214 | - | |
| 200 | + array( | |
| 201 | + 'type' => 'textfield', | |
| 202 | + 'heading' => __( 'Extra class name', 'borderless' ), | |
| 203 | + 'param_name' => 'el_class', | |
| 204 | + 'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'borderless' ), | |
| 205 | + ), | |
| 206 | + array( | |
| 207 | + 'type' => 'css_editor', | |
| 208 | + 'heading' => __( 'CSS box', 'borderless' ), | |
| 209 | + 'param_name' => 'css', | |
| 210 | + 'group' => __( 'Design Options', 'borderless' ), | |
| 211 | + ), | |
| 212 | + ), | |
| 213 | +); | |