Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'after_setup_theme', 'child_theme_setup', 20 );
- function child_theme_setup() {
- remove_shortcode( 'vc_actionbox' );
- add_shortcode( 'vc_actionbox', 'my_actionbox' );
- }
- function my_actionbox ($attributes, $content)
- {
- $attributes = shortcode_atts(
- array(
- 'type' => 'grey',
- 'controls' => 'right',
- 'title' => 'ActionBox title',
- 'title_size' => 'h2',
- 'message' => '',
- 'button1' => '',
- 'link1' => '',
- 'style1' => 'default',
- 'size1' => '',
- 'button2' => '',
- 'link2' => '',
- 'style2' => 'default',
- 'size2' => '',
- 'animate' => '',
- 'target1' => '',
- 'target2' => '',
- ), $attributes);
- $animate_class = ($attributes['animate'] != '')?' animate_'.$attributes['animate']:'';
- $controls_position_class = ($attributes['controls'] != 'bottom')?' at_right':'';
- $actionbox_controls_position_class = ($attributes['controls'] != 'bottom')?' controls_aside':'';
- $output = '<div class="w-actionbox color_'.$attributes['type'].$actionbox_controls_position_class.$animate_class.'">'.
- '<div class="w-actionbox-h">'.
- '<div class="w-actionbox-text">';
- if ($attributes['title'] != '')
- {
- $output .= '<h3>'.html_entity_decode($attributes['title']).'</h3>';
- }
- if ($attributes['message'] != '')
- {
- $output .= '<p>'.html_entity_decode($attributes['message']).'</p>';
- }
- $output .= '</div>'.
- '<div class="w-actionbox-controls'.$controls_position_class.'">';
- if ($attributes['button1'] != '' AND $attributes['link1'] != '')
- {
- $colour_class = ($attributes['style1'] != '')?' type_'.$attributes['style1']:'';
- $size_class = ($attributes['size1'] != '')?' size_'.$attributes['size1']:'';
- $output .= '<a class="w-actionbox-button g-btn'.$size_class.$colour_class.'" href="'.$attributes['link1'].'"';
- if ($attributes['target1'] != '') {
- $output .= ' target="'.$attributes['target1'].'"';
- }
- $output .= '><span>'.$attributes['button1'].'</span></a>';
- }
- if ($attributes['button2'] != '' AND $attributes['link2'] != '')
- {
- $colour_class = ($attributes['style2'] != '')?' type_'.$attributes['style2']:'';
- $size_class = ($attributes['size2'] != '')?' size_'.$attributes['size2']:'';
- $output .= '<a class="w-actionbox-button g-btn'.$size_class.$colour_class.'" href="'.$attributes['link2'].'"';
- if ($attributes['target2'] != '') {
- $output .= ' target="'.$attributes['target2'].'"';
- }
- $output .= '><span>'.$attributes['button2'].'</span></a>';
- }
- $output .= '</div>'.
- '</div>'.
- '</div>';
- return $output;
- }
- add_action('init', function()
- {
- $shortcode_vc_actionbox_tmp = WPBMap::getShortCode('vc_actionbox');
- $target_arr = array(__("Same tab", "js_composer") => "", __("New tab", "js_composer") => "_blank");
- $shortcode_vc_actionbox_tmp['params'] = array(
- array(
- "type" => "dropdown",
- "heading" => __("ActionBox Color", "js_composer"),
- "param_name" => "type",
- "value" => array(__('Primary Color', "js_composer") => "primary", __('Alternate Color', "js_composer") => "alternate",),
- "description" => ''
- ),
- array(
- "type" => "dropdown",
- "heading" => __("Buttons Position", "js_composer"),
- "param_name" => "controls",
- "value" => array(__('Right', "js_composer") => "right", __('Bottom', "js_composer") => "bottom",),
- "description" => '',
- ),
- array(
- "type" => "textfield",
- "heading" => __("ActionBox Title", "js_composer"),
- "param_name" => "title",
- "holder" => "div",
- "value" => __("This is ActionBox", "js_composer"),
- "description" => ''
- ),
- array(
- "type" => "textarea",
- "heading" => __("ActionBox Text", "js_composer"),
- "param_name" => "message",
- "value" => '',
- "description" => ''
- ),
- array(
- "type" => "textfield",
- "heading" => __("Button 1 Label", "js_composer"),
- "param_name" => "button1",
- "value" => "",
- "description" => ''
- ),
- array(
- "type" => "textfield",
- "heading" => __("Button 1 Link", "js_composer"),
- "param_name" => "link1",
- "value" => "",
- "description" => ''
- ),
- array(
- "type" => "dropdown",
- "heading" => __("Button 1 Color", "js_composer"),
- "param_name" => "style1",
- "value" => array(__("Default (theme color)", "js_composer") => "default", __("Primary (theme color)", "js_composer") => "primary", __("Secondary (theme color)", "js_composer") => "secondary", __("Outlined with Transparent Background", "js_composer") => "outline", __("Pink", "js_composer") => "pink", __("Blue", "js_composer") => "blue", __("Green", "js_composer") => "green", __("Yellow", "js_composer") => "yellow", __("Purple", "js_composer") => "purple", __("Red", "js_composer") => "red", __("Lime", "js_composer") => "lime", __("Navy", "js_composer") => "navy", __("Cream", "js_composer") => "cream", __("Brown", "js_composer") => "brown", __("Midnight", "js_composer") => "midnight", __("Teal", "js_composer") => "teal"),
- "description" => '',
- ),
- array(
- "type" => "dropdown",
- "heading" => __("Button 1 Size", "js_composer"),
- "param_name" => "size1",
- "value" => array(__("Normal", "js_composer") => "", __("Small", "js_composer") => "small", __("Big", "js_composer") => "big"),
- ),
- array(
- "type" => "dropdown",
- "heading" => __("Button 1 Target", "js_composer"),
- "param_name" => "target1",
- "value" => $target_arr,
- ),
- array(
- "type" => "textfield",
- "heading" => __("Button 2 Label", "js_composer"),
- "param_name" => "button2",
- "value" => "",
- "description" => ''
- ),
- array(
- "type" => "textfield",
- "heading" => __("Button 2 Link", "js_composer"),
- "param_name" => "link2",
- "value" => "",
- "description" => ''
- ),
- array(
- "type" => "dropdown",
- "heading" => __("Button 2 Color", "js_composer"),
- "param_name" => "style2",
- "value" => array(__("Default (theme color)", "js_composer") => "default", __("Primary (theme color)", "js_composer") => "primary", __("Secondary (theme color)", "js_composer") => "secondary", __("Outlined with Transparent Background", "js_composer") => "outline", __("Pink", "js_composer") => "pink", __("Blue", "js_composer") => "blue", __("Green", "js_composer") => "green", __("Yellow", "js_composer") => "yellow", __("Purple", "js_composer") => "purple", __("Red", "js_composer") => "red", __("Lime", "js_composer") => "lime", __("Navy", "js_composer") => "navy", __("Cream", "js_composer") => "cream", __("Brown", "js_composer") => "brown", __("Midnight", "js_composer") => "midnight", __("Teal", "js_composer") => "teal"),
- "description" => '',
- ),
- array(
- "type" => "dropdown",
- "heading" => __("Button 2 Size", "js_composer"),
- "param_name" => "size2",
- "value" => array(__("Normal", "js_composer") => "", __("Small", "js_composer") => "small", __("Big", "js_composer") => "big"),
- ),
- array(
- "type" => "dropdown",
- "heading" => __("Button 2 Target", "js_composer"),
- "param_name" => "target2",
- "value" => $target_arr,
- ),
- );
- unset($shortcode_vc_actionbox_tmp['base']);
- vc_map_update('vc_actionbox', $shortcode_vc_actionbox_tmp);
- }, 100);
Advertisement
Add Comment
Please, Sign In to add comment