| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( '-1' ); |
| 4 |
} |
| 5 |
|
| 6 |
/*-----------------------------------------------------------------------------------*/ |
| 7 |
/* Icon |
| 8 |
/*-----------------------------------------------------------------------------------*/ |
| 9 |
|
| 10 |
class WPBakeryShortCode_borderless_wpbakery_icon extends WPBakeryShortCode { |
| 11 |
protected function content( $atts, $content = null ) { |
| 12 |
extract( shortcode_atts( array( |
| 13 |
'icon' => '', |
| 14 |
'icon_color' => '', |
| 15 |
'custom_icon_color' => '', |
| 16 |
'shape' => '', |
| 17 |
'color_shape' => '', |
| 18 |
'icon_size' => '32px', |
| 19 |
'spacing' => '', |
| 20 |
'icon_alignment' => 'left', |
| 21 |
'link' => '', |
| 22 |
//Static |
| 23 |
'el_id' => '', |
| 24 |
'el_class' => '', |
| 25 |
'css' => '', |
| 26 |
'css_animation' => '' |
| 27 |
), $atts ) ); |
| 28 |
$output = ''; |
| 29 |
|
| 30 |
|
| 31 |
// Retrieve data from the database. |
| 32 |
$options = get_option( 'borderless' ); |
| 33 |
|
| 34 |
|
| 35 |
// 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 |
// 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'] : ''; |
| 46 |
if ( '' !== $css_animation ) { |
| 47 |
wp_enqueue_script( 'waypoints' ); |
| 48 |
$css_animation_style = ' wpb_animate_when_almost_visible wpb_' . $css_animation; |
| 49 |
} |
| 50 |
$class_to_filter = vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $css_animation ); |
| 51 |
$css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts ); |
| 52 |
|
| 53 |
|
| 54 |
// Set custom values |
| 55 |
$link = vc_build_link( $link ); |
| 56 |
$color = ($icon_color == 'custom') ? 'color:'.$custom_icon_color.';' : 'color:'.$borderless_primary_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 != '') { |
| 62 |
|
| 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 |
} else { |
| 66 |
$color_shape = $color_shape ? 'border-color:'.$color_shape.';' : 'border-color:'.$borderless_primary_color.';'; //Border Color |
| 67 |
} |
| 68 |
|
| 69 |
} else { |
| 70 |
$color_shape = $default_color_shape = ''; |
| 71 |
} |
| 72 |
|
| 73 |
if($spacing != '') { |
| 74 |
$spacing = 'height:'.$spacing.'; width:'.$spacing.';'; |
| 75 |
} else { |
| 76 |
$spacing = 'height:calc('.$font_size_reference.' + 2em); width:calc('.$font_size_reference.' + 2em);'; |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
// 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>'; |
| 85 |
$output .= '</div>'; |
| 86 |
if($link['url'] != ''){$output .= '</a>';} |
| 87 |
$output .= '</div>'; |
| 88 |
|
| 89 |
return $output; |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
return array( |
| 94 |
'name' => __( 'Icon', 'borderless' ), |
| 95 |
'base' => 'borderless_wpbakery_icon', |
| 96 |
'icon' => plugins_url('../images/icon.png', __FILE__), |
| 97 |
'show_settings_on_create' => true, |
| 98 |
'category' => __( 'Borderless', 'borderless' ), |
| 99 |
'description' => __( 'Choose an icon from libraries', 'borderless' ), |
| 100 |
'params' => array( |
| 101 |
array( |
| 102 |
'type' => 'iconmanager', |
| 103 |
'heading' => __( 'Icon', 'borderless' ), |
| 104 |
'param_name' => 'icon', |
| 105 |
'description' => __( 'Select icon from library.', 'borderless' ), |
| 106 |
), |
| 107 |
array( |
| 108 |
'type' => 'dropdown', |
| 109 |
'heading' => __( 'Icon color', 'borderless' ), |
| 110 |
'param_name' => 'icon_color', |
| 111 |
'value' => array( |
| 112 |
__( 'Preset Color', 'borderless' ) => '', |
| 113 |
__( 'Custom Color', 'borderless' ) => 'custom', |
| 114 |
), |
| 115 |
'description' => __( 'Select icon color.', 'borderless' ), |
| 116 |
), |
| 117 |
array( |
| 118 |
'type' => 'colorpicker', |
| 119 |
'heading' => __( 'Custom Icon Color', 'borderless' ), |
| 120 |
'param_name' => 'custom_icon_color', |
| 121 |
'description' => __( 'Select custom icon color.', 'borderless' ), |
| 122 |
'dependency' => array( |
| 123 |
'element' => 'icon_color', |
| 124 |
'value' => array( 'custom' ), |
| 125 |
), |
| 126 |
), |
| 127 |
array( |
| 128 |
'type' => 'dropdown', |
| 129 |
'heading' => __( 'Shape', 'borderless' ), |
| 130 |
'description' => __( 'Select icon shape.', 'borderless' ), |
| 131 |
'param_name' => 'shape', |
| 132 |
'value' => array( |
| 133 |
__( 'None', 'borderless' ) => '', |
| 134 |
__( 'Rounded', 'borderless' ) => 'rounded', |
| 135 |
__( 'Square', 'borderless' ) => 'square', |
| 136 |
__( 'Round', 'borderless' ) => 'round', |
| 137 |
__( 'Outline Rounded', 'borderless' ) => 'outline-rounded', |
| 138 |
__( 'Outline Square', 'borderless' ) => 'outline-square', |
| 139 |
__( 'Outline Round', 'borderless' ) => 'outline-round', |
| 140 |
), |
| 141 |
), |
| 142 |
array( |
| 143 |
'type' => 'colorpicker', |
| 144 |
'heading' => __( 'Color Shape', 'borderless' ), |
| 145 |
'param_name' => 'color_shape', |
| 146 |
'description' => __( 'Select custom shape background color.', 'borderless' ), |
| 147 |
'dependency' => array( |
| 148 |
'element' => 'shape', |
| 149 |
'value' => array( 'rounded','square','round','outline-rounded','outline-square','outline-round', ), |
| 150 |
), |
| 151 |
), |
| 152 |
array( |
| 153 |
'type' => 'textfield', |
| 154 |
'heading' => __( 'Size', 'borderless' ), |
| 155 |
'param_name' => 'icon_size', |
| 156 |
'description' => __( 'Icon size. Default value is 32px.', 'borderless' ), |
| 157 |
'value' => '32px', |
| 158 |
), |
| 159 |
array( |
| 160 |
'type' => 'textfield', |
| 161 |
'heading' => __( 'Spacing', 'borderless' ), |
| 162 |
'param_name' => 'spacing', |
| 163 |
'description' => __( 'Select icon spacing.', 'borderless' ), |
| 164 |
), |
| 165 |
array( |
| 166 |
'type' => 'textfield', |
| 167 |
'heading' => __( 'Gap', 'borderless' ), |
| 168 |
'param_name' => 'gap', |
| 169 |
'description' => __( 'Select icon gap.', 'borderless' ), |
| 170 |
), |
| 171 |
array( |
| 172 |
'type' => 'dropdown', |
| 173 |
'heading' => __( 'Alignment', 'borderless' ), |
| 174 |
'param_name' => 'icon_alignment', |
| 175 |
'value' => array( |
| 176 |
__( 'Left', 'borderless' ) => 'left', |
| 177 |
__( 'Right', 'borderless' ) => 'right', |
| 178 |
__( 'Center', 'borderless' ) => 'center', |
| 179 |
), |
| 180 |
'description' => __( 'Select icon alignment.', 'borderless' ), |
| 181 |
), |
| 182 |
array( |
| 183 |
'type' => 'vc_link', |
| 184 |
'heading' => __( 'URL (Link)', 'borderless' ), |
| 185 |
'param_name' => 'link', |
| 186 |
'description' => __( 'Add link to icon.', 'borderless' ), |
| 187 |
), |
| 188 |
|
| 189 |
// Animation |
| 190 |
vc_map_add_css_animation(), |
| 191 |
|
| 192 |
array( |
| 193 |
'type' => 'el_id', |
| 194 |
'heading' => __( 'Element ID', 'borderless' ), |
| 195 |
'param_name' => 'el_id', |
| 196 |
'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 |
), |
| 213 |
); |
| 214 |
|