| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( '-1' ); |
| 4 |
} |
| 5 |
|
| 6 |
/*-----------------------------------------------------------------------------------*/ |
| 7 |
/* Alert |
| 8 |
/*-----------------------------------------------------------------------------------*/ |
| 9 |
|
| 10 |
class WPBakeryShortCode_borderless_wpbakery_alert extends WPBakeryShortCode { |
| 11 |
protected function content( $atts, $content = null ) { |
| 12 |
extract( shortcode_atts( array( |
| 13 |
'type' => 'borderless-wpbakery-alert-success', |
| 14 |
'dismissible' => '', |
| 15 |
//Static |
| 16 |
'el_id' => '', |
| 17 |
'el_class' => '', |
| 18 |
'css' => '', |
| 19 |
'css_animation' => '' |
| 20 |
), $atts ) ); |
| 21 |
$output = ''; |
| 22 |
|
| 23 |
|
| 24 |
// Retrieve data from the database. |
| 25 |
$options = get_option( 'borderless' ); |
| 26 |
|
| 27 |
|
| 28 |
// Set default values |
| 29 |
$borderless_primary_color = isset( $options['primary_color'] ) ? $options['primary_color'] : '#3379fc'; //Primary Color |
| 30 |
$borderless_secondary_color = isset( $options['secondary_color'] ) ? $options['secondary_color'] : '#3379fc'; //Secondary Color |
| 31 |
$borderless_text_color = isset( $options['text_color'] ) ? $options['text_color'] : ''; //Text Color |
| 32 |
$borderless_accent_color = isset( $options['accent_color'] ) ? $options['accent_color'] : '#3379fc'; //Accent Color |
| 33 |
|
| 34 |
|
| 35 |
// Default Extra Class, CSS and CSS animation |
| 36 |
$css = isset( $atts['css'] ) ? $atts['css'] : ''; |
| 37 |
$el_id = isset( $atts['el_id'] ) ? 'id="' . esc_attr( $el_id ) . '"' : ''; |
| 38 |
$el_class = isset( $atts['el_class'] ) ? $atts['el_class'] : ''; |
| 39 |
if ( '' !== $css_animation ) { |
| 40 |
wp_enqueue_script( 'waypoints' ); |
| 41 |
$css_animation_style = ' wpb_animate_when_almost_visible wpb_' . $css_animation; |
| 42 |
} |
| 43 |
$class_to_filter = vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $css_animation ); |
| 44 |
$css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts ); |
| 45 |
|
| 46 |
|
| 47 |
// Set custom values |
| 48 |
$quote = "'"; |
| 49 |
|
| 50 |
|
| 51 |
// Output |
| 52 |
$output .= '<div '.$el_id.' class="borderless-wpbakery-alert '.$css_class.' '.$type.'">'; |
| 53 |
$output .= $content; |
| 54 |
if(!empty($dismissible)) { $output .= '<span class="borderless-wpbakery-alert-close-button" onclick="this.parentElement.style.display='.$quote.'none'.$quote.';">×</span>'; } |
| 55 |
$output .= '</div>'; |
| 56 |
|
| 57 |
return $output; |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
return array( |
| 62 |
'name' => __( 'Alert', 'borderless' ), |
| 63 |
'base' => 'borderless_wpbakery_alert', |
| 64 |
'icon' => plugins_url('../images/alert.png', __FILE__), |
| 65 |
'show_settings_on_create' => true, |
| 66 |
'category' => __( 'Borderless', 'borderless' ), |
| 67 |
'description' => __( 'Provide contextual feedback messages', 'borderless' ), |
| 68 |
'params' => array( |
| 69 |
|
| 70 |
array( |
| 71 |
'type' => 'dropdown', |
| 72 |
'heading' => __( 'Type', 'borderless' ), |
| 73 |
'param_name' => 'type', |
| 74 |
'value' => array( |
| 75 |
__( 'Success', 'borderless' ) => 'borderless-wpbakery-alert-success', |
| 76 |
__( 'Info', 'borderless' ) => 'borderless-wpbakery-alert-info', |
| 77 |
__( 'Warning', 'borderless' ) => 'borderless-wpbakery-alert-warning', |
| 78 |
__( 'Danger', 'borderless' ) => 'borderless-wpbakery-alert-danger', |
| 79 |
), |
| 80 |
'description' => __( 'Select context type.', 'borderless' ), |
| 81 |
), |
| 82 |
|
| 83 |
array( |
| 84 |
'type' => 'textarea', |
| 85 |
'holder' => 'div', |
| 86 |
'heading' => __( 'Message', 'borderless' ), |
| 87 |
'param_name' => 'content', |
| 88 |
'description' => __( 'Enter short message.', 'borderless' ), |
| 89 |
), |
| 90 |
|
| 91 |
array( |
| 92 |
'type' => 'checkbox', |
| 93 |
'heading' => __('Dismissible Alert', 'borderless'), |
| 94 |
'param_name' => 'dismissible', |
| 95 |
'value' => array( |
| 96 |
__( 'Add close button.', 'borderless' ) => 'dismissible', |
| 97 |
), |
| 98 |
), |
| 99 |
|
| 100 |
// Animation |
| 101 |
vc_map_add_css_animation(), |
| 102 |
|
| 103 |
array( |
| 104 |
'type' => 'el_id', |
| 105 |
'heading' => __( 'Element ID', 'borderless' ), |
| 106 |
'param_name' => 'el_id', |
| 107 |
'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>' ), |
| 108 |
), |
| 109 |
|
| 110 |
array( |
| 111 |
'type' => 'textfield', |
| 112 |
'heading' => __( 'Extra class name', 'borderless' ), |
| 113 |
'param_name' => 'el_class', |
| 114 |
'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'borderless' ), |
| 115 |
), |
| 116 |
|
| 117 |
array( |
| 118 |
'type' => 'css_editor', |
| 119 |
'heading' => __( 'CSS box', 'borderless' ), |
| 120 |
'param_name' => 'css', |
| 121 |
'group' => __( 'Design Options', 'borderless' ), |
| 122 |
), |
| 123 |
), |
| 124 |
); |
| 125 |
|