function boston_tabs_func($atts, $content) { extract(shortcode_atts(array('titles' => '', 'contents' => ''), $atts)); $titles = explode("/n/", $titles); $contents = explode("/n/", $contents); $titles_html = ''; $contents_html = ''; $random = boston_random_string(); if (!empty($titles)) { for ($i = 0; $i < sizeof($titles); $i++) { $titles_html .= '<li role="presentation" class="' . ($i == 0 ? 'active' : '') . '"><a href="#tab_' . $i . '_' . $random . '" role="tab" data-toggle="tab">' . $titles[$i] . '</a></li>'; $contents_html .= '<div role="tabpanel" class="tab-pane fade ' . ($i == 0 ? 'in active' : '') . '" id="tab_' . $i . '_' . $random . '">' . (!empty($contents[$i]) ? apply_filters('the_content', $contents[$i]) : '') . '</div>'; } } return ' <!-- Nav tabs --> <ul class="nav nav-tabs" role="tablist"> ' . $titles_html . ' </ul> <!-- Tab panes --> <div class="tab-content"> ' . $contents_html . ' </div>'; }
function boston_button_func($atts, $content) { extract(shortcode_atts(array('text' => '', 'link' => '', 'target' => '', 'bg_color' => '', 'bg_color_hvr' => '', 'border_radius' => '', 'icon' => '', 'font_color' => '', 'font_color_hvr' => '', 'size' => 'normal', 'align' => '', 'btn_width' => 'normal', 'inline' => 'no', 'margin' => ''), $atts)); $rnd = boston_random_string(); $style_css = ' <style> a.' . $rnd . ', a.' . $rnd . ':active, a.' . $rnd . ':visited, a.' . $rnd . ':focus{ display: ' . ($btn_width == 'normal' ? 'inline-block' : 'block') . '; ' . (!empty($bg_color) ? 'background-color: ' . $bg_color . ';' : '') . ' ' . (!empty($font_color) ? 'color: ' . $font_color . ';' : '') . ' ' . (!empty($border_radius) ? 'border-radius: ' . $border_radius : '') . ' } a.' . $rnd . ':hover{ display: ' . ($btn_width == 'normal' ? 'inline-block' : 'block') . '; ' . (!empty($bg_color_hvr) ? 'background-color: ' . $bg_color_hvr . ';' : '') . ' ' . (!empty($font_color_hvr) ? 'color: ' . $font_color_hvr . ';' : '') . ' } </style> '; return boston_shortcode_style($style_css) . ' <div class="btn-wrap" style="margin: ' . esc_attr($margin) . '; text-align: ' . $align . '; ' . ($inline == 'yes' ? 'display: inline-block;' : '') . ' ' . ($inline == 'yes' && $align == 'right' ? 'float: right;' : '') . '"> <a href="' . esc_url($link) . '" class="btn btn-default ' . $size . ' ' . $rnd . ' ' . ($link != '#' && $link[0] == '#' ? 'slideTo' : '') . '" target="' . esc_attr($target) . '"> ' . ($icon != 'No Icon' && $icon != '' ? '<i class="fa fa-' . $icon . ' ' . (empty($text) ? 'no-margin' : '') . '"></i>' : '') . ' ' . $text . ' </a> </div>'; }
function boston_iframe_func($atts, $content) { extract(shortcode_atts(array('link' => '', 'proportion' => ''), $atts)); $random = boston_random_string(); return ' <div class="embed-responsive embed-responsive-' . $proportion . '"> <iframe class="embed-responsive-item" src="' . esc_url($link) . '"></iframe> </div>'; }
function boston_alert_func($atts, $content) { extract(shortcode_atts(array('text' => '', 'border_color' => '', 'bg_color' => '', 'font_color' => '', 'icon' => '', 'closeable' => 'no', 'close_icon_color' => '', 'close_icon_color_hvr' => ''), $atts)); $rnd = boston_random_string(); $style_css = ' <style> .' . $rnd . '.alert .close{ color: ' . $close_icon_color . '; } .' . $rnd . '.alert .close:hover{ color: ' . $close_icon_color_hvr . '; } </style> '; return boston_shortcode_style($style_css) . ' <div class="alert ' . $rnd . ' alert-default ' . ($closeable == 'yes' ? 'alert-dismissible' : '') . '" role="alert" style=" color: ' . $font_color . '; border-color: ' . $border_color . '; background-color: ' . $bg_color . ';"> ' . (!empty($icon) && $icon !== 'No Icon' ? '<i class="fa fa-' . $icon . '"></i>' : '') . ' ' . $text . ' ' . ($closeable == 'yes' ? '<button type="button" class="close" data-dismiss="alert"> <span aria-hidden="true">×</span> <span class="sr-only">' . __('Close', 'boston') . '</span> </button>' : '') . ' </div>'; }
function boston_toggle_func($atts, $content) { extract(shortcode_atts(array('title' => '', 'toggle_content' => '', 'state' => ''), $atts)); $rnd = boston_random_string(); return ' <div class="panel-group" id="accordion_' . $rnd . '" role="tablist" aria-multiselectable="true"> <div class="panel panel-default"> <div class="panel-heading" role="tab" id="heading_' . $rnd . '"> <div class="panel-title"> <a class="' . ($state == 'in' ? '' : 'collapsed') . '" data-toggle="collapse" data-parent="#accordion_' . $rnd . '" href="#coll_' . $rnd . '" aria-expanded="true" aria-controls="coll_' . $rnd . '"> ' . $title . ' <i class="fa fa-chevron-circle-down animation"></i> </a> </div> </div> <div id="coll_' . $rnd . '" class="panel-collapse collapse ' . $state . '" role="tabpanel" aria-labelledby="heading_' . $rnd . '"> <div class="panel-body"> ' . apply_filters('the_content', $toggle_content) . ' </div> </div> </div> </div>'; }
function boston_progressbar_func($atts, $content) { extract(shortcode_atts(array('label' => '', 'value' => '', 'color' => '', 'bgcolor' => '', 'label_color' => '', 'height' => '', 'font_size' => '', 'icon' => '', 'border_radius' => '', 'style' => ''), $atts)); $rnd = boston_random_string(); $style_css = ' <style> .' . $rnd . '{ ' . (!empty($label_color) ? 'color: ' . $label_color . ';' : '') . ' ' . (!empty($border_radius) ? 'border-radius: ' . $border_radius . ';' : '') . ' ' . (!empty($height) ? 'height: ' . $height . ';' : '') . ' ' . (!empty($bgcolor) ? 'background-color: ' . $bgcolor . ';' : '') . ' } .' . $rnd . ' .progress-bar{ ' . (!empty($font_size) ? 'font-size: ' . $font_size . ';' : '') . ' ' . (!empty($height) ? 'line-height: ' . $height . ';' : '') . ' ' . (!empty($color) ? 'background-color: ' . $color . ';' : '') . ' } .' . $rnd . ' .progress-bar-value{ ' . (!empty($color) ? 'background-color: ' . $color . ';' : '') . ' ' . (!empty($label_color) ? 'color: ' . $label_color . ';' : '') . ' } .' . $rnd . ' .progress-bar-value:after{ ' . (!empty($color) ? 'border-color: ' . $color . ' transparent;' : '') . ' } </style> '; return boston_shortcode_style($style_css) . ' <div class="progress ' . $rnd . '"> <div class="progress-bar ' . $style . '" style="width: ' . esc_attr($value) . '%" role="progressbar" aria-valuenow="' . $value . '" aria-valuemin="0" aria-valuemax="100"> <div class="progress-bar-value">' . $value . '%</div> ' . (!empty($icon) ? '<i class="fa fa-' . $icon . '"></i>' : '') . '' . $label . ' </div> </div>'; }
function boston_accordion_func($atts, $content) { extract(shortcode_atts(array('titles' => '', 'contents' => ''), $atts)); $titles = explode("/n/", $titles); $contents = explode("/n/", $contents); $titles_html = ''; $contents_html = ''; $rnd = boston_random_string(); $html = ''; if (!empty($titles)) { for ($i = 0; $i < sizeof($titles); $i++) { if (!empty($titles[$i])) { $html .= ' <div class="panel panel-default"> <div class="panel-heading" role="tab" id="heading_' . $i . '"> <div class="panel-title"> <a class="' . ($i !== 0 ? 'collapsed' : '') . '" data-toggle="collapse" data-parent="#accordion_' . $rnd . '" href="#coll_' . $i . '_' . $rnd . '" aria-expanded="true" aria-controls="coll_' . $i . '_' . $rnd . '"> ' . $titles[$i] . ' <i class="fa fa-chevron-circle-down animation"></i> </a> </div> </div> <div id="coll_' . $i . '_' . $rnd . '" class="panel-collapse collapse ' . ($i == 0 ? 'in' : '') . '" role="tabpanel" aria-labelledby="heading_' . $i . '"> <div class="panel-body"> ' . (!empty($contents[$i]) ? apply_filters('the_content', $contents[$i]) : '') . ' </div> </div> </div> '; } } } return ' <div class="panel-group" id="accordion_' . $rnd . '" role="tablist" aria-multiselectable="true"> ' . $html . ' </div>'; }
public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Follow Us On Instagram', 'boston') : $instance['title'], $instance, $this->id_base); $count = esc_attr($instance['count']); $username = esc_attr($instance['username']); $columns = esc_attr($instance['columns']); if (empty($count)) { $count = 9; } if (empty($columns)) { $columns = 3; } $width = 100 / $columns; $boston_random_string = boston_random_string(); $return = ''; if ($username) { $username_response = wp_remote_get('https://api.instagram.com/v1/users/search?q=' . $username . '&client_id=972fed4ff0d5444aa21645789adb0eb0'); $username_response_data = json_decode($username_response['body'], true); $username_converted = ''; foreach ($username_response_data['data'] as $data) { if ($data['username'] == $username) { $username_converted = $data['id']; } } $return = '<script>' . "\n"; $return .= 'jQuery(function($) {' . "\n"; $return .= '$(".instagram-feed-' . $boston_random_string . '").on(\'didLoadInstagram\', function(event, response) {' . "\n"; $return .= 'var data = response.data;' . "\n"; $return .= 'for( var key in data ) {' . "\n"; $return .= 'var image_src = data[key][\'images\'][\'standard_resolution\'][\'url\'];' . "\n"; $return .= 'var image_link = data[key][\'link\'];' . "\n"; $return .= 'var caption = ""' . "\n"; $return .= 'if( image_caption = data[key][\'caption\'] ){' . "\n"; $return .= 'caption = data[key][\'caption\'][\'text\'];' . "\n"; $return .= '}' . "\n"; $return .= 'var output = \'<div class="instagram-image" style="width: calc(' . $width . '% - 2px); margin-left: 2px;"><a href="\'+image_link+\'" target="_blank" class="no-preloader"><img src="\'+image_src+\'" alt="\'+caption+\'"></a></div>\';' . "\n"; $return .= '$(".instagram-feed-' . $boston_random_string . '").append(output);' . "\n"; $return .= '}' . "\n"; $return .= '});' . "\n"; $return .= '$(".instagram-feed-' . $boston_random_string . '").instagram({' . "\n"; $return .= 'clientId: \'972fed4ff0d5444aa21645789adb0eb0\',' . "\n"; $return .= 'count: \'' . $count . '\',' . "\n"; if ($username != '') { $return .= 'userId: \'' . $username_converted . '\'' . "\n"; } $return .= '});' . "\n"; $return .= '});' . "\n"; $return .= '</script>' . "\n"; $return .= '<div class="instagram-feed-' . $boston_random_string . ' clearfix"></div>' . "\n"; } echo $before_widget . $before_title . $title . $after_title . $return . $after_widget; }