ajayver

Untitled

Aug 25th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.29 KB | None | 0 0
  1. add_action( 'after_setup_theme', 'child_theme_setup', 20 );
  2.  
  3. function child_theme_setup() {
  4.     remove_shortcode( 'vc_contacts' );
  5.     add_shortcode( 'vc_contacts', 'my_contacts' );
  6. }
  7.  
  8. function my_contacts($attributes, $content = null) {
  9.  
  10.     $attributes = shortcode_atts(
  11.         array(
  12.             'phone' => '',
  13.             'email' => '',
  14.             'address' => '',
  15.             'layout' => '',
  16.             'mobile' => '',
  17.             'website' => ''
  18.         ), $attributes);
  19.  
  20.     $layout_class = ($attributes['layout'] == 'with_icons')?' with_icons':'';
  21.  
  22.  
  23.     $output =   '<div class="w-contacts'.$layout_class.'">
  24.                     <div class="w-contacts-h">
  25.                         <div class="w-contacts-list">';
  26.     if ($attributes['address'] != ''){
  27.         $output .=          '<div class="w-contacts-item for_address">
  28.                                 <i class="fa fa-map-marker"></i>
  29.                                 <span class="w-contacts-item-name">'.__('Address', 'us').':</span>
  30.                                 <span class="w-contacts-item-value">'.$attributes['address'].'</span>
  31.                             </div>';
  32.     }
  33.     if ($attributes['phone'] != ''){
  34.         $output .=          '<div class="w-contacts-item for_phone">
  35.                                 <i class="fa fa-phone"></i>
  36.                                 <span class="w-contacts-item-name">'.__('Phone', 'us').':</span>
  37.                                 <span class="w-contacts-item-value">'.$attributes['phone'].'</span>
  38.                             </div>';
  39.     }
  40.     if ($attributes['email'] != ''){
  41.         $output .=          '<div class="w-contacts-item for_email">
  42.                                 <i class="fa fa-envelope"></i>
  43.                                 <span class="w-contacts-item-name">'.__('Email', 'us').':</span>
  44.                                 <span class="w-contacts-item-value"><a href="mailto:'.$attributes['email'].'">'.$attributes['email'].'</a></span>
  45.                             </div>';
  46.     }
  47.     if ($attributes['mobile'] != ''){
  48.         $output .=          '<div class="w-contacts-item for_mobile">
  49.                                 <i class="fa fa-mobile"></i>
  50.                                 <span class="w-contacts-item-name">'.__('Mobile', 'us').':</span>
  51.                                 <span class="w-contacts-item-value"><a href="tel:'.$attributes['mobile'].'">'.$attributes['mobile'].'</a></span>
  52.                             </div>';
  53.     }
  54.     if ($attributes['website'] != ''){
  55.         $output .=          '<div class="w-contacts-item for_website">
  56.                                 <i class="fa fa-external-link"></i>
  57.                                 <span class="w-contacts-item-name">'.__('Website', 'us').':</span>
  58.                                 <span class="w-contacts-item-value"><a href="'.$attributes['website'].'">'.$attributes['website'].'</a></span>
  59.                             </div>';
  60.     }
  61.  
  62.     $output .=          '</div>
  63.                     </div>
  64.                 </div>';
  65.  
  66.     return $output;
  67. }
  68.  
  69. add_action('init', function()
  70. {
  71.     //Get VC gallery shortcode config
  72.     $shortcode_vc_contacts_tmp = WPBMap::getShortCode('vc_contacts');
  73.  
  74.     //print_r($shortcode_vc_contacts_tmp);
  75.  
  76.     $shortcode_vc_contacts_tmp['params'][] = array(
  77.             "type" => 'textfield',
  78.             "heading" => __("Mobile", "js_composer"),
  79.             "param_name" => "mobile",
  80.             "description" => "",
  81.             "value" => ""
  82.         );
  83.     $shortcode_vc_contacts_tmp['params'][] = array(
  84.             "type" => 'textfield',
  85.             "heading" => __("Website", "js_composer"),
  86.             "param_name" => "website",
  87.             "description" => "",
  88.             "value" => ""
  89.         );
  90.  
  91.     //VC doesn't like even the thought of you changing the shortcode base, and errors out, so we unset it.
  92.     unset($shortcode_vc_contacts_tmp['base']);
  93.  
  94.     //Update the actual parameter
  95.     vc_map_update('vc_contacts', $shortcode_vc_contacts_tmp);
  96. }, 100);
Advertisement
Add Comment
Please, Sign In to add comment