| @@ -46,8 +46,22 @@ | ||
| 46 | 46 | 'css_animation' => '' |
| 47 | 47 | ), $atts ) ); |
| 48 | 48 | $output = ''; |
| 49 | 49 | |
| 50 | + // Assets. | |
| 51 | + wp_enqueue_style( | |
| 52 | + 'borderless-wpbakery-style', | |
| 53 | + BORDERLESS__STYLES . 'wpbakery.min.css', | |
| 54 | + false, | |
| 55 | + BORDERLESS__VERSION | |
| 56 | + ); | |
| 57 | + wp_enqueue_script( | |
| 58 | + 'borderless-wpbakery-script', | |
| 59 | + BORDERLESS__SCRIPTS . 'borderless-wpbakery.min.js', array('jquery'), | |
| 60 | + BORDERLESS__VERSION, | |
| 61 | + true | |
| 62 | + ); | |
| 63 | + | |
| 50 | 64 | // Retrieve data from the database. |
| 51 | 65 | $options = get_option( 'borderless' ); |
| 52 | 66 | |
| 53 | 67 | |
| @@ -59,112 +73,129 @@ | ||
| 59 | 73 | |
| 60 | 74 | // Start Default Extra Class, CSS and CSS animation |
| 61 | 75 | |
| 62 | 76 | $css = isset( $atts['css'] ) ? $atts['css'] : ''; |
| 63 | - $el_id = isset( $atts['el_id'] ) ? 'id="' . esc_attr( $el_id ) . '"' : ''; | |
| 77 | + $el_id = isset( $atts['el_id'] ) ? $atts['el_id'] : ''; | |
| 78 | + $el_id = ! empty( $el_id ) ? 'id="' . esc_attr( $el_id ) . '"' : ''; | |
| 64 | 79 | $el_class = isset( $atts['el_class'] ) ? $atts['el_class'] : ''; |
| 65 | 80 | |
| 66 | 81 | if ( '' !== $css_animation ) { |
| 67 | 82 | wp_enqueue_script( 'waypoints' ); |
| 68 | - $css_animation_style = ' wpb_animate_when_almost_visible wpb_' . $css_animation; | |
| 83 | + $css_animation_style = ' wpb_animate_when_almost_visible wpb_' . esc_attr( $css_animation ); | |
| 69 | 84 | } |
| 70 | 85 | |
| 71 | 86 | $class_to_filter = vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $css_animation ); |
| 72 | 87 | $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts ); |
| 73 | 88 | |
| 74 | - $uniqid = md5(uniqid(rand(), true)); | |
| 75 | - $uniqid = preg_replace('/[0-9]+/', '', $uniqid); | |
| 89 | + $uniqid = md5( uniqid( rand(), true ) ); | |
| 90 | + $uniqid = preg_replace( '/[0-9]+/', '', $uniqid ); | |
| 91 | + $uniqid = esc_attr( $uniqid ); | |
| 76 | 92 | |
| 77 | 93 | // End Default Extra Class, CSS and CSS animation |
| 78 | 94 | |
| 79 | 95 | // Start Trigger Mode |
| 80 | 96 | |
| 81 | - $output .= '<div class="borderless-wpbakery-modal-trigger '.$alignment.'">'; | |
| 97 | + $output .= '<div class="borderless-wpbakery-modal-trigger ' . esc_attr( $alignment ) . '">'; | |
| 82 | 98 | |
| 83 | - if ($trigger == 'trigger-button') { | |
| 99 | + if ( $trigger == 'trigger-button' ) { | |
| 84 | 100 | |
| 85 | - if ($button_color == 'custom') { | |
| 101 | + if ( $button_color == 'custom' ) { | |
| 86 | 102 | |
| 87 | 103 | // Button Background Color |
| 88 | 104 | |
| 89 | - $button_background_color = isset( $button_background_color ) ? 'background-color: '.$button_background_color.';' : 'background-color: '.$borderless_primary_color.';'; | |
| 105 | + $button_background_color = ! empty( $button_background_color ) ? 'background-color: ' . esc_attr( $button_background_color ) . ';' : 'background-color: ' . esc_attr( $borderless_primary_color ) . ';'; | |
| 90 | 106 | |
| 91 | 107 | // Text Color |
| 92 | 108 | |
| 93 | - $button_title_color = isset( $button_title_color ) ? 'color: '.$button_title_color.';' : 'color: '.$borderless_primary_color.';'; | |
| 109 | + $button_title_color = ! empty( $button_title_color ) ? 'color: ' . esc_attr( $button_title_color ) . ';' : 'color: ' . esc_attr( $borderless_primary_color ) . ';'; | |
| 94 | 110 | |
| 95 | 111 | // Border Color |
| 96 | 112 | |
| 97 | - $button_outline_color = isset( $button_outline_color ) ? 'border-color: '.$button_outline_color.';' : 'border-color: '.$borderless_primary_color.';'; | |
| 113 | + $button_outline_color = ! empty( $button_outline_color ) ? 'border-color: ' . esc_attr( $button_outline_color ) . ';' : 'border-color: ' . esc_attr( $borderless_primary_color ) . ';'; | |
| 98 | 114 | |
| 99 | 115 | } else { |
| 100 | 116 | |
| 101 | 117 | // Button Background Color |
| 102 | 118 | |
| 103 | - $button_background_color = empty($button_outline_shape) ? 'background-color: '.$borderless_primary_color.';' : ''; | |
| 119 | + $button_background_color = empty( $button_outline_shape ) ? 'background-color: ' . esc_attr( $borderless_primary_color ) . ';' : ''; | |
| 104 | 120 | |
| 105 | 121 | // Text Color |
| 106 | 122 | |
| 107 | - $button_title_color = !empty($button_outline_shape) ? 'color: '.$borderless_primary_color.';' : 'color:#FFF;'; | |
| 123 | + $button_title_color = ! empty( $button_outline_shape ) ? 'color: ' . esc_attr( $borderless_primary_color ) . ';' : 'color:#FFF;'; | |
| 108 | 124 | |
| 109 | 125 | // Border Color |
| 110 | 126 | |
| 111 | - $button_outline_color = !empty($button_outline_shape) ? 'border-color: '.$borderless_primary_color.';' : ''; | |
| 127 | + $button_outline_color = ! empty( $button_outline_shape ) ? 'border-color: ' . esc_attr( $borderless_primary_color ) . ';' : ''; | |
| 112 | 128 | |
| 113 | 129 | } |
| 114 | 130 | |
| 131 | + $style = $button_background_color . ' ' . $button_title_color . ' ' . $button_outline_color; | |
| 115 | 132 | |
| 116 | - $output .= '<div style="'.$button_background_color .' '.$button_title_color.' '.$button_outline_color.'" class="borderless-wpbakery-modal-button '.$button_size.' '.$trigger.' '.$button_shape.' '.$button_outline_shape.'" data-modal="'.$uniqid.'">'.$title.'</div>'; | |
| 133 | + $class_array = array( | |
| 134 | + 'borderless-wpbakery-modal-button', | |
| 135 | + sanitize_html_class( $button_size ), | |
| 136 | + sanitize_html_class( $trigger ), | |
| 137 | + sanitize_html_class( $button_shape ), | |
| 138 | + sanitize_html_class( $button_outline_shape ), | |
| 139 | + ); | |
| 140 | + $class_attribute = implode( ' ', $class_array ); | |
| 117 | 141 | |
| 118 | - } else if ($trigger == 'trigger-image') { | |
| 142 | + $output .= '<div style="' . esc_attr( $style ) . '" class="' . esc_attr( $class_attribute ) . '" data-modal="' . esc_attr( $uniqid ) . '">' . esc_html( $title ) . '</div>'; | |
| 119 | 143 | |
| 144 | + } else if ( $trigger == 'trigger-image' ) { | |
| 145 | + | |
| 120 | 146 | // Image |
| 121 | 147 | |
| 122 | - if ($icon_display == 'image_icon') { | |
| 148 | + if ( $icon_display == 'image_icon' ) { | |
| 123 | 149 | |
| 124 | 150 | $default_src = vc_asset_url( 'vc/no_image.png' ); |
| 125 | 151 | $img = wp_get_attachment_image_src( $custom_image_icon ); |
| 126 | 152 | $src = $img[0]; |
| 127 | - $custom_src = $src ? esc_attr( $src ) : $default_src; | |
| 153 | + $custom_src = $src ? esc_url( $src ) : esc_url( $default_src ); | |
| 128 | 154 | |
| 129 | - $icon_content = '<img src="'.$custom_src.'" >'; | |
| 155 | + $icon_content = '<img src="' . $custom_src . '" >'; | |
| 130 | 156 | |
| 131 | - } elseif ($icon_display == 'svg_icon') { | |
| 157 | + } elseif ( $icon_display == 'svg_icon' ) { | |
| 132 | 158 | |
| 133 | 159 | $default_src = vc_asset_url( 'vc/no_image.png' ); |
| 134 | 160 | $img = wp_get_attachment_image_src( $custom_svg_icon ); |
| 135 | 161 | $src = $img[0]; |
| 136 | - $custom_src = $src ? esc_attr( $src ) : $default_src; | |
| 162 | + $custom_src = $src ? esc_url( $src ) : esc_url( $default_src ); | |
| 137 | 163 | |
| 138 | - $icon_content = '<div class="borderless-wpbakery-modal-svg" style="height:'.$height.';width:'.$width.';"><img class="borderless-svg-img" src="'.$custom_src.'" ></div>'; | |
| 164 | + $height = esc_attr( $height ); | |
| 165 | + $width = esc_attr( $width ); | |
| 139 | 166 | |
| 167 | + $icon_content = '<div class="borderless-wpbakery-modal-svg" style="height:' . $height . ';width:' . $width . ';"><img class="borderless-svg-img" src="' . $custom_src . '" ></div>'; | |
| 168 | + | |
| 140 | 169 | } else { |
| 141 | 170 | |
| 142 | 171 | $iconClass = isset( $icon ) ? esc_attr( $icon ) : 'fa fa-adjust'; |
| 143 | 172 | |
| 144 | - $custom_icon_color = $icon_color ? 'color:'.$custom_icon_color.';' : 'color:'.$borderless_primary_color.';'; //Icon Color | |
| 173 | + $custom_icon_color_style = $custom_icon_color ? 'color:' . esc_attr( $custom_icon_color ) . ';' : 'color:' . esc_attr( $borderless_primary_color ) . ';'; //Icon Color | |
| 145 | 174 | |
| 146 | - $font_size_reference = $icon_size; | |
| 175 | + $font_size_reference = esc_attr( $icon_size ); | |
| 147 | 176 | |
| 148 | - if($icon_size != '') { | |
| 149 | - $icon_size = 'font-size:'.$icon_size.';'; | |
| 177 | + if ( $icon_size != '' ) { | |
| 178 | + $icon_size_style = 'font-size:' . esc_attr( $icon_size ) . ';'; | |
| 179 | + } else { | |
| 180 | + $icon_size_style = ''; | |
| 150 | 181 | } |
| 151 | 182 | |
| 152 | - if($shape != '') { | |
| 183 | + if ( $shape != '' ) { | |
| 153 | 184 | |
| 154 | - if($shape == 'rounded' || $shape == 'square' || $shape == 'round') { | |
| 155 | - $color_shape = $color_shape ? 'background-color:'.$color_shape.';' : 'background-color:'.$borderless_primary_color.';'; //Background Color Shape | |
| 185 | + if ( $shape == 'rounded' || $shape == 'square' || $shape == 'round' ) { | |
| 186 | + $color_shape_style = $color_shape ? 'background-color:' . esc_attr( $color_shape ) . ';' : 'background-color:' . esc_attr( $borderless_primary_color ) . ';'; //Background Color Shape | |
| 156 | 187 | } else { |
| 157 | - $color_shape = $color_shape ? 'border-color:'.$color_shape.';' : 'border-color:'.$borderless_primary_color.';'; //Border Color Shape | |
| 188 | + $color_shape_style = $color_shape ? 'border-color:' . esc_attr( $color_shape ) . ';' : 'border-color:' . esc_attr( $borderless_primary_color ) . ';'; //Border Color Shape | |
| 158 | 189 | } |
| 159 | 190 | |
| 160 | - if($icon_spacing != '') { | |
| 161 | - $icon_spacing = 'height:'.$icon_spacing.'; width:'.$icon_spacing.';'; | |
| 191 | + if ( $icon_spacing != '' ) { | |
| 192 | + $icon_spacing_style = 'height:' . esc_attr( $icon_spacing ) . '; width:' . esc_attr( $icon_spacing ) . ';'; | |
| 162 | 193 | } else { |
| 163 | - $icon_spacing = 'height:calc('.$font_size_reference.' + 2em); width:calc('.$font_size_reference.' + 2em);'; | |
| 194 | + $icon_spacing_style = 'height:calc(' . $font_size_reference . ' + 2em); width:calc(' . $font_size_reference . ' + 2em);'; | |
| 164 | 195 | } |
| 165 | 196 | |
| 166 | - $shape_render_start = '<div class="borderless-wpbakery-modal-icon-inner '.$shape.'" style="'.$color_shape.''.$icon_spacing.'">'; | |
| 197 | + $shape_render_start = '<div class="borderless-wpbakery-modal-icon-inner ' . esc_attr( $shape ) . '" style="' . $color_shape_style . $icon_spacing_style . '">'; | |
| 167 | 198 | $shape_render_finish = '</div>'; |
| 168 | 199 | |
| 169 | 200 | } else { |
| 170 | 201 | $shape_render_start = $shape_render_finish = ''; |
| @@ -169,26 +200,42 @@ | ||
| 169 | 200 | } else { |
| 170 | 201 | $shape_render_start = $shape_render_finish = ''; |
| 171 | 202 | } |
| 172 | 203 | |
| 173 | - $icon_content = ''.$shape_render_start.'<span style="'.$custom_icon_color.' '.$icon_size.'" class="borderless-wpbakery-modal-image '.$iconClass.'"></span>'.$shape_render_finish.''; | |
| 204 | + $icon_content = $shape_render_start . '<span style="' . esc_attr( $custom_icon_color_style . ' ' . $icon_size_style ) . '" class="borderless-wpbakery-modal-image ' . esc_attr( $iconClass ) . '"></span>' . $shape_render_finish; | |
| 174 | 205 | } |
| 175 | 206 | |
| 176 | - $output .= '<div data-modal="'.$uniqid.'" class="borderless-wpbakery-modal-icon '.$animations.' '.$animation_delay.' '.$animation_speed.'" '.$icon_gap.'>'; | |
| 207 | + $class_array = array( | |
| 208 | + 'borderless-wpbakery-modal-icon', | |
| 209 | + $animations, | |
| 210 | + $animation_delay, | |
| 211 | + $animation_speed, | |
| 212 | + ); | |
| 213 | + $class_attribute = implode( ' ', array_map( 'esc_attr', $class_array ) ); | |
| 214 | + | |
| 215 | + $output .= '<div data-modal="' . esc_attr( $uniqid ) . '" class="' . $class_attribute . '" ' . esc_attr( $icon_gap ) . '>'; | |
| 177 | 216 | $output .= $icon_content; |
| 178 | 217 | $output .= '</div>'; |
| 179 | 218 | |
| 180 | - } else if ($trigger == 'trigger-text') { | |
| 219 | + } else if ( $trigger == 'trigger-text' ) { | |
| 181 | 220 | |
| 182 | 221 | // Title Color |
| 183 | 222 | |
| 184 | - if (!empty($text_color)) { | |
| 185 | - $text_color = 'color: '.$text_color.';'; | |
| 223 | + if ( ! empty( $text_color ) ) { | |
| 224 | + $text_color_style = 'color: ' . esc_attr( $text_color ) . ';'; | |
| 186 | 225 | } else { |
| 187 | - $text_color = ''; | |
| 226 | + $text_color_style = ''; | |
| 188 | 227 | } |
| 189 | 228 | |
| 190 | - $output .= '<'.$title_tag.' style="'.$text_color .'" class="borderless-wpbakery-modal-text" data-modal="'.$uniqid.'">'.$title.'</'.$title_tag.'>'; | |
| 229 | + $allowed_tags = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' ); | |
| 230 | + | |
| 231 | + if ( in_array( $title_tag, $allowed_tags ) ) { | |
| 232 | + $title_tag = esc_attr( $title_tag ); | |
| 233 | + } else { | |
| 234 | + $title_tag = 'span'; | |
| 235 | + } | |
| 236 | + | |
| 237 | + $output .= '<' . $title_tag . ' style="' . esc_attr( $text_color_style ) . '" class="borderless-wpbakery-modal-text" data-modal="' . esc_attr( $uniqid ) . '">' . esc_html( $title ) . '</' . $title_tag . '>'; | |
| 191 | 238 | } |
| 192 | 239 | |
| 193 | 240 | $output .= '</div>'; |
| 194 | 241 | |
| @@ -195,18 +242,18 @@ | ||
| 195 | 242 | // End Trigger Mode |
| 196 | 243 | |
| 197 | 244 | // Start Modal Height |
| 198 | 245 | |
| 199 | - if (!empty($initial_height)) { | |
| 200 | - $initial_height = 'style="height:'.$initial_height.';"'; | |
| 246 | + if ( ! empty( $initial_height ) ) { | |
| 247 | + $initial_height = 'style="height:' . esc_attr( $initial_height ) . ';"'; | |
| 201 | 248 | } |
| 202 | 249 | |
| 203 | 250 | // End Modal Height |
| 204 | 251 | |
| 205 | - $output .= '<div id="'.$uniqid.'" class="borderless-wpbakery-modal">'; | |
| 206 | - $output .= '<div id="'.$uniqid.'" class="borderless-wpbakery-modal-inner' .$css_class.'">'; | |
| 252 | + $output .= '<div id="' . esc_attr( $uniqid ) . '" class="borderless-wpbakery-modal">'; | |
| 253 | + $output .= '<div id="' . esc_attr( $uniqid ) . '" class="borderless-wpbakery-modal-inner' . esc_attr( $css_class ) . '">'; | |
| 207 | 254 | $output .= '<a class="borderless-wpbakery-modal-close">×</a>'; |
| 208 | - $output .= '<div id="'.$el_id.'" '.$initial_height.' class="borderless-wpbakery-modal-content">'.wpb_js_remove_wpautop($content).'</div>'; | |
| 255 | + $output .= '<div ' . $el_id . ' ' . $initial_height . ' class="borderless-wpbakery-modal-content">' . wpb_js_remove_wpautop( do_shortcode( $content ) ) . '</div>'; | |
| 209 | 256 | $output .= '</div>'; |
| 210 | 257 | $output .= '</div>'; |
| 211 | 258 | |
| 212 | 259 | return $output; |
| @@ -211,8 +258,9 @@ | ||
| 211 | 258 | |
| 212 | 259 | return $output; |
| 213 | 260 | } |
| 214 | 261 | } |
| 262 | + | |
| 215 | 263 | |
| 216 | 264 | |
| 217 | 265 | vc_map( array( |
| 218 | 266 | 'name' => __( 'Modal', 'borderless' ), |