function widget($args, $instance) { $title = $instance['title']; $bio = $instance['bio']; $custom_email = $instance['custom_email']; $avatar_size = preg_replace("/[^0-9]/", "", $instance['avatar_size']); if (!$avatar_size) { $avatar_size = 48; } $avatar_align = $instance['avatar_align']; if (!$avatar_align) { $avatar_align = 'left'; } $read_more_text = $instance['read_more_text'] ? $instance['read_more_text'] : 'Read more'; $read_more_url = $instance['read_more_url']; echo ts_essentials_escape($args['before_widget']); if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } echo '<div class="blog-author clearfix">'; $avatar = $custom_email ? '<span class="align' . esc_attr($avatar_align) . '">' . get_avatar($custom_email, $avatar_size) . '</span>' : ''; ?> <p><?php echo wp_kses_post($avatar . $bio); ?> </p> <?php if ($read_more_url) { echo '<div class="mimic-smaller read-more uppercase"><a href="' . esc_url($read_more_url) . '">' . esc_html($read_more_text) . '</a></div>'; } echo '</div>'; echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { $title = $instance['title']; $flickrid = $instance['flickrid']; $number = $instance['number']; echo ts_essentials_escape($args['before_widget']); if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } ?> <div class="flickr ts-mfp-gallery"> <ul id="<?php echo esc_attr($args['widget_id']); ?> -ul" class="flickr-widget clearfix"></ul> <div><script type="text/javascript">jQuery(document).ready(function($){if ($.fn.jflickrfeed){jQuery('#<?php echo esc_js($args['widget_id']); ?> -ul').jflickrfeed({limit: <?php echo absint($number); ?> ,qstrings: { id: '<?php echo esc_js($flickrid); ?> ' }}, function(data){if(typeof(ts_magnificPopup)=="function"){ ts_magnificPopup()}})}});</script></div> </div> <?php echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { $facebook = $instance['facebook']; $title = $instance['label']; $twitter = $instance['twitter']; $consumer_key = isset($instance['consumer_key']) ? $instance['consumer_key'] : ''; $consumer_secret = isset($instance['consumer_secret']) ? $instance['consumer_secret'] : ''; $access_token = isset($instance['access_token']) ? $instance['access_token'] : ''; $access_token_secret = isset($instance['access_token_secret']) ? $instance['access_token_secret'] : ''; $last_twitter_save = get_option('ts_last_twitter_follower_count_save_' . $twitter); $last_twitter_reponse = get_option('ts_last_twitter_follower_count_response_' . $twitter); $last_twitter_reponse = $last_twitter_reponse ? json_decode($last_twitter_reponse, true) : ''; if ($last_twitter_save && time() - $last_twitter_save < 600 && $last_twitter_reponse && count($last_twitter_reponse) > 0) { //$last_twitter_reponse = json_decode($last_twitter_reponse, true); } else { $twitter_config = array('consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret, 'token' => $access_token, 'secret' => $access_token_secret); $tmhOAuth = new tmhOAuth($twitter_config); $params = array('screen_name' => $twitter); $code = $tmhOAuth->user_request(array('method' => 'GET', 'url' => $tmhOAuth->url("1.1/users/show"), 'params' => $params)); if ($code == 200) { $last_twitter_reponse = $tmhOAuth->response['response']; $last_twitter_reponse_error = $last_twitter_reponse; update_option('ts_last_twitter_follower_count_save_' . $twitter, time()); update_option('ts_last_twitter_follower_count_response_' . $twitter, $last_twitter_reponse); $last_twitter_reponse = json_decode($last_twitter_reponse, true); } } echo ts_essentials_escape($args['before_widget']); echo '<div class="inner clearfix">'; if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } if ($facebook) { $data = wp_remote_get('https://api.facebook.com/method/links.getStats?urls=' . urlencode('https://www.facebook.com/' . $facebook) . '&format=json'); $fb_error = is_object($data) && get_class($data) == 'WP_Error' ? true : false; if (!$fb_error && isset($data['body'])) { $data = json_decode($data['body']); $data = isset($data[0]) && is_object($data[0]) ? $data[0] : $data; if (isset($data->like_count)) { echo '<div class="inline-block"><a href="https://facebook.com/' . esc_attr($facebook) . '" class="facebook">'; echo '<i class="fa fa-facebook facebook-bg-color"></i>'; echo '<h4 class="sp1" title="' . esc_attr($data->like_count) . '">' . ts_essentials_num2str($data->like_count) . '</h4>'; echo '<span class="sp2 small">Likes</span>'; echo '</a></div>'; } } } if ($twitter && is_array($last_twitter_reponse)) { $data = $last_twitter_reponse; if (isset($data['followers_count'])) { echo '<div class="inline-block"><a href="https://twitter.com/' . esc_attr($twitter) . '" class="twitter">'; echo '<i class="fa fa-twitter twitter-bg-color"></i>'; echo '<h4 class="sp1" title="' . esc_attr($data['followers_count']) . '">' . ts_essentials_num2str($data['followers_count']) . '</h4>'; echo '<span class="sp2 small">Followers</span>'; echo '</a></div>'; } } echo '</div>'; echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { $title = $instance['title']; $contact = $instance['contact']; echo ts_essentials_escape($args['before_widget']); if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } echo '<div class="contact-form-7">' . do_shortcode('[contact-form-7 id="' . esc_attr($contact) . '" title="' . esc_attr($title) . '"]') . '</div>'; echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { $title = $instance['title']; $limit = $instance['limit']; $orderby = isset($instance['orderby']) ? $instance['orderby'] : ''; echo ts_essentials_escape($args['before_widget']); if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } echo '<div class="portfolio-mini-widget-inner clearfix">'; echo do_shortcode('[portfolio layout="mini" limit="' . esc_attr($limit) . '" called_via="widget" orderby="' . esc_attr($orderby) . '"][/portfolio]'); echo '</div>'; echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { $title = $instance['title']; $num = $instance['num']; echo ts_essentials_escape($args['before_widget']); if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } echo '<ul>'; $recentPosts = ''; $temp = $recentPosts; $recentPosts = new WP_Query(array('showposts' => $num)); while ($recentPosts->have_posts()) { $recentPosts->the_post(); $img_url = false; $img_id = get_post_thumbnail_id($recentPosts->post->ID); $photo = wp_get_attachment_image_src($img_id, 'thumbnail'); $img_url = isset($photo[0]) ? $photo[0] : ''; $has_img = $img_url ? 'has-img' : ''; if ($img_url) { ?> <li class="portfolio-post-widget clearfix"> <div class="portfolio-post-widget-thumbnail"> <a href="<?php echo get_permalink($recentPosts->post->ID); ?> " class="thumb-link"> <img width="75" src="<?php echo esc_url($img_url); ?> " alt="<?php echo esc_attr(get_the_title()); ?> "/> </a> </div><!-- / div.widget-thumbnail --> </li><!-- end div.post-widget --> <?php } } $recentPosts = $temp; echo '</ul>'; echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { $title = $instance['title']; $style = $instance['style']; $menu = $instance['menu']; if ($menu) { echo ts_essentials_escape($args['before_widget']); if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } echo '<div class="ts-custom-menu-wrap ts-menu-style-' . esc_attr($style) . '">'; $nav_menu_options = array('menu' => $menu); wp_nav_menu($nav_menu_options); echo '</div>'; echo ts_essentials_escape($args['after_widget']); } }
function widget($args, $instance) { $label = $instance['label']; $facebook = $instance['facebook']; $twitter = $instance['twitter']; $pinterest = $instance['pinterest']; $google_plus = $instance['google_plus']; $github = $instance['github']; $linkedin = $instance['linkedin']; $instagram = $instance['instagram']; $flickr = $instance['flickr']; $youtube = $instance['youtube']; $vimeo = $instance['vimeo']; $tumblr = $instance['tumblr']; $vk = isset($instance['vk']) ? $instance['vk'] : ''; $behance = $instance['behance']; $dribbble = $instance['dribbble']; $soundcloud = $instance['soundcloud']; $rss = $instance['rss']; echo ts_essentials_escape($args['before_widget']); echo '<div class="inner social-icons-widget-style">'; if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } echo '<div class="social social-fa-icons">'; echo ts_essentials_output_social_icon('facebook', '', $facebook); echo ts_essentials_output_social_icon('twitter', '', $twitter); echo ts_essentials_output_social_icon('pinterest', '', $pinterest); echo ts_essentials_output_social_icon('google_plus', '', $google_plus); echo ts_essentials_output_social_icon('github', '', $github); echo ts_essentials_output_social_icon('linkedin', '', $linkedin); echo ts_essentials_output_social_icon('instagram', '', $instagram); echo ts_essentials_output_social_icon('flickr', '', $flickr); echo ts_essentials_output_social_icon('youtube', '', $youtube); echo ts_essentials_output_social_icon('vimeo', '', $vimeo); echo ts_essentials_output_social_icon('vk', '', $vk); echo ts_essentials_output_social_icon('tumblr', '', $tumblr); echo ts_essentials_output_social_icon('behance', '', $behance); echo ts_essentials_output_social_icon('dribbble', '', $dribbble); echo ts_essentials_output_social_icon('soundcloud', '', $soundcloud); echo ts_essentials_output_social_icon('rss', '', $rss); echo '</div>'; echo '</div>'; echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { $title = trim($instance['title']) ? $instance['title'] : __('Follow Our RSS Feed', 'ThemeStockyard'); $label = $instance['label']; $description = trim($instance['description']) ? $instance['description'] : __('Stay up to date with the latest news by following our feed.', 'ThemeStockyard'); $feedurl = trim($instance['feedurl']) ? $instance['feedurl'] : get_bloginfo('rss2_url'); echo ts_essentials_escape($args['before_widget']); echo '<div class="inner">'; if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } echo '<a href="' . esc_url($feedurl) . '">'; echo '<i class="fa fa-rss rss-bg-color"></i>'; echo '<h4 class="sp1">' . esc_html($title) . '</h4>'; echo '<span class="sp2 small">' . esc_html($description) . '</span>'; echo '</a>'; echo '</div>'; echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { $map_ok = true; wp_enqueue_script('googlemaps'); $title = $instance['title']; $address = $instance['address']; $coordinates = $instance['coordinates']; $zoom = $instance['zoom']; $height = preg_replace("/[^0-9]/", "", $instance['height']); if (!$height) { $height = 250; } if (trim($address) || trim($coordinates)) { echo ts_essentials_escape($args['before_widget']); if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } if (!$address) { _e('Address was not specified', 'ThemeStockyard'); return false; } if (!$coordinates) { $coordinates = ts_essentials_get_map_coordinates($address); if (is_array($coordinates)) { $coordinates = $coordinates['lat'] . ',' . $coordinates['lng']; } else { $map_ok = false; echo esc_html($coordinates); //return false; } } if ($map_ok) { $map_id_num = rand(1, 100); echo '<div id="map_canvas_' . esc_attr($map_id_num) . '_wrap" class="flexible-map" style="width:100%;height:' . esc_attr($height) . 'px" data-height="' . $height . 'px">'; echo '<input class="location" type="hidden" value="' . esc_attr($address) . '" />'; echo '<input class="coordinates" type="hidden" value="' . esc_attr($coordinates) . '" />'; echo '<input class="zoom" type="hidden" value="' . esc_attr($zoom) . '" />'; echo '<div id="map_canvas_' . esc_attr($map_id_num) . '" class="map_canvas" style="width:100%;height:' . esc_attr($height) . 'px"> </div>'; echo '</div>'; } echo ts_essentials_escape($args['after_widget']); } }
function widget($args, $instance) { $url = isset($instance['url']) && trim($instance['url']) ? $instance['url'] : ts_essentials_full_url(); $label = $instance['label']; $description = $instance['description']; echo ts_essentials_escape($args['before_widget']); echo '<div class="inner">'; if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } echo '<div><iframe src="//www.facebook.com/plugins/like.php?href=' . urlencode($url); echo '&send=false&layout=standard&width=300&show_faces=false'; echo '&font&colorscheme=light&action=like&height=35"'; echo ' style="border:none; overflow:hidden; width:300px; height:35px;"'; echo '></iframe></div>'; echo isset($description) && trim($description) ? '<p class="description">' . wp_kses_post($description) . '</p>' : ''; echo '</div>'; echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { $label = $instance['label']; $facebook = trim($instance['facebook_username']); $twitter = trim($instance['twitter_username']); $pinterest = trim($instance['pinterest_username']); $gplus = isset($instance['gplus_username']) ? trim($instance['gplus_username']) : ''; $orientation = $instance['orientation']; $align = $instance['align']; $align = in_array($align, array('left', 'center', 'right')) ? 'text-' . $align : 'text-left'; $align = $orientation == 'horizontal' ? $align : 'text-left'; echo ts_essentials_escape($args['before_widget']); echo '<div class="inner ' . esc_attr($align) . '">'; if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } echo '<div class="stuff">'; $orientation_class = $orientation == 'horizontal' ? 'inline-block' : 'block'; if ($facebook) { $pre = is_numeric($facebook) ? 'https://www.facebook.com/profile.php?id=' : 'https://www.facebook.com/'; $facebook = substr($facebook, 0, 4) == 'http' ? $facebook : $pre . $facebook; echo '<div class="fb ' . esc_attr($orientation_class) . '">'; echo '<iframe src="//www.facebook.com/plugins/like.php?href=' . urlencode($facebook); echo '&send=false&layout=button_count&width=70&show_faces=false'; echo '&font&colorscheme=light&action=like&height=21"'; echo ' style="border:none; overflow:hidden; width:300px; height:35px;"'; echo '></iframe></div>'; } if ($twitter) { echo '<div class="tw ' . esc_attr($orientation_class) . '">'; echo '<a href="https://twitter.com/' . esc_attr($twitter) . '" class="twitter-follow-button"'; echo ' data-show-count="false">Follow @' . esc_html($twitter) . '</a>'; echo "<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script></div>"; } if ($pinterest) { echo '<div class="pn ' . esc_attr($orientation_class) . '">'; echo '<a href="http://www.pinterest.com/' . esc_attr($pinterest) . '/" target="_blank">'; echo esc_html($pinterest) . '<b></b><i></i></a></div>'; } echo '</div>'; echo '</div>'; echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { $title = isset($instance['title']) ? $instance['title'] : ''; $adcode = isset($instance['adcode']) ? $instance['adcode'] : ''; $image = isset($instance['image']) ? $instance['image'] : ''; $href = isset($instance['href']) ? $instance['href'] : ''; $alt = isset($instance['alt']) ? $instance['alt'] : ''; echo ts_essentials_escape($args['before_widget']); if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } if (trim($adcode)) { echo '<div class="adspace">' . balanceTags($adcode) . '</div>'; // need some flexibility here due to google ad codes } else { $open = trim($href) ? '<a href="' . esc_url($href) . '">' : ''; $close = trim($href) ? '</a>' : ''; echo strip_tags('<div class="adspace">' . $open . '<img src="' . esc_url($image) . '" alt="' . esc_attr($alt) . '" />' . $close . '</div>', '<div><a><img>'); } echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { $title = $instance['title']; $limit = $instance['limit']; $category_name = $instance['category_name']; $exclude_previous_posts = $instance['exclude_previous_posts']; $exclude_these_later = $instance['exclude_these_later']; $text_align = $instance['text_align']; $show_meta = $instance['show_meta']; $allow_videos = $instance['allow_videos']; $image_size = $instance['image_size']; $title_size = $instance['title_size']; echo ts_essentials_escape($args['before_widget']); if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } echo '<div class="blog-slider-widget-inner clearfix">'; echo do_shortcode('[blog_slider limit="' . esc_attr($limit) . '" category_name="' . esc_attr($category_name) . '" exclude_previous_posts="' . esc_attr($exclude_previous_posts) . '" exclude_these_later="' . esc_attr($exclude_these_later) . '" text_align="' . esc_attr($text_align) . '" allow_videos="' . esc_attr($allow_videos) . '" show_excerpt="no" show_meta="' . esc_attr($show_meta) . '" title_size="' . esc_attr($title_size) . '" image_size="' . esc_attr($image_size) . '"][/blog_slider]'); echo '</div>'; echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { $icon = isset($instance['icon']) ? $instance['icon'] : ''; $icon_color = isset($instance['icon_color']) ? $instance['icon_color'] : ''; $label = isset($instance['label']) ? $instance['label'] : ''; $title = isset($instance['title']) ? $instance['title'] : ''; $description = isset($instance['description']) ? $instance['description'] : ''; $url = isset($instance['url']) ? $instance['url'] : ''; echo ts_essentials_escape($args['before_widget']); if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } $infobox_class = $url ? 'has-url' : 'has-no-url'; $infobox_class .= $icon ? ' has-icon' : ' has-icon'; echo '<div class="infobox ' . esc_attr($infobox_class) . '">'; echo trim($url) ? '<a href="' . esc_url($url) . '" class="link">' : '<div class="link">'; echo trim($icon) ? '<i class="' . ts_essentials_fontawesome_class($icon) . '" style="background:' . esc_attr($icon_color) . '"></i>' : ''; echo trim($title) ? '<h4 class="sp1">' . esc_html($title) . '</h4>' : ''; echo trim($description) ? '<span class="sp2 small">' . esc_html($description) . '</span>' : ''; echo trim($url) ? '</a>' : '</div>'; echo '</div>'; echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { $title = $instance['title']; $title_link = isset($instance['title_link']) ? $instance['title_link'] : ''; $widget_layout = $instance['widget_layout']; $limit = $instance['limit']; $category_name = isset($instance['category_name']) ? $instance['category_name'] : ''; $category_name = is_array($category_name) ? implode(',', $category_name) : $category_name; $cat = isset($instance['cat']) ? $instance['cat'] : ''; $cat = is_array($cat) ? implode(',', $cat) : $cat; $exclude_previous_posts = $instance['exclude_previous_posts']; $exclude_these_later = $instance['exclude_these_later']; $show_excerpt = $instance['show_excerpt']; $show_meta = $instance['show_meta']; $show_media = $instance['show_media']; $allow_videos = $instance['allow_videos']; $allow_galleries = $instance['allow_galleries']; $orderby = isset($instance['orderby']) ? $instance['orderby'] : ''; echo ts_essentials_escape($args['before_widget']); if (!empty($title)) { echo ts_essentials_escape($args['before_title']); echo trim($title_link) ? '<a href="' . esc_attr($title_link) . '">' : ''; echo apply_filters('widget_title', $title); echo trim($title_link) ? '<i class="fa fa-angle-right"></i></a>' : ''; echo ts_essentials_escape($args['after_title']); } echo '<div class="blog-mini-widget-inner clearfix">'; if (isset($instance['cat'])) { // backwords compatibility echo do_shortcode('[blog_widget widget_layout="' . esc_attr($widget_layout) . '" limit="' . esc_attr($limit) . '" cat="' . esc_attr($cat) . '" override_widget_heading="no" exclude_previous_posts="' . esc_attr($exclude_previous_posts) . '" exclude_these_later="' . esc_attr($exclude_these_later) . '" show_excerpt="' . esc_attr($show_excerpt) . '" show_meta="' . esc_attr($show_meta) . '" show_media="' . esc_attr($show_media) . '" allow_videos="' . esc_attr($allow_videos) . '" allow_galleries="' . esc_attr($allow_galleries) . '" called_via="widget" orderby="' . esc_attr($orderby) . '"][/blog_widget]'); } else { echo do_shortcode('[blog_widget widget_layout="' . esc_attr($widget_layout) . '" limit="' . esc_attr($limit) . '" category_name="' . esc_attr($category_name) . '" override_widget_heading="no" exclude_previous_posts="' . esc_attr($exclude_previous_posts) . '" exclude_these_later="' . esc_attr($exclude_these_later) . '" show_excerpt="' . esc_attr($show_excerpt) . '" show_meta="' . esc_attr($show_meta) . '" show_media="' . esc_attr($show_media) . '" allow_videos="' . esc_attr($allow_videos) . '" allow_galleries="' . esc_attr($allow_galleries) . '" called_via="widget" orderby="' . esc_attr($orderby) . '"][/blog_widget]'); } echo '</div>'; echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { global $wpdb, $post; $tab1 = $instance['tab1']; $tab2 = $instance['tab2']; $tab3 = $instance['tab3']; $crop_thumbs = isset($instance['crop_thumbs']) ? $instance['crop_thumbs'] : 1; $count = ctype_digit($instance['count']) && ts_essentials_number_within_range($instance['count'], 1, 20) ? $instance['count'] : 5; echo ts_essentials_escape($args['before_widget']); echo '<div class="ts-tabs-widget tabs-widget shortcode-tabs simple-tabs horizontal-tabs">'; $tab = array(); ?> <div class="tab-widget"> <ul class="tab-header clearfix"> <li class="active"><?php echo esc_html($tab1); ?> </li> <li><?php echo esc_html($tab2); ?> </li> <li class="last"><?php echo esc_html($tab3); ?> </li> </ul> <div class="tab-contents"> <div class="tab-context visible"> <ul> <?php $popular_posts = ''; $temp = $popular_posts; $popular_posts = new WP_Query(array('showposts' => intval($count), 'orderby' => 'comment_count')); while ($popular_posts->have_posts()) { $popular_posts->the_post(); ?> <li class="post-widget clearfix"> <?php $img_url = false; $size = 'thumbnail'; $img_id = get_post_thumbnail_id($popular_posts->post->ID); $photo = wp_get_attachment_image_src($img_id, $size); $img_url = isset($photo[0]) ? $photo[0] : ''; $has_img = $img_url ? 'has-img' : ''; if ($img_url) { ?> <div class="widget-thumbnail"> <a href="<?php echo get_permalink($popular_posts->post->ID); ?> " class="thumb-link"> <img width="60" src="<?php echo esc_url($img_url); ?> " alt="<?php echo esc_attr(get_the_title()); ?> "/> </a> </div><!-- / div.widget-thumbnail --> <?php } ?> <div class="widget-context <?php echo esc_attr($has_img); ?> "> <h4><a href="<?php echo get_permalink($popular_posts->post->ID); ?> "><?php the_title(); ?> </a></h4> <small><?php the_time('F j, Y'); ?> </small> </div><!-- / div.widget-context --> </li><!-- / div.post-widget --> <?php } $popular_posts = $temp; echo '</ul></div>'; echo '<div class="tab-context"><ul>'; $recentPosts = ''; $temp = $recentPosts; $recentPosts = new WP_Query(array('showposts' => intval($count))); while ($recentPosts->have_posts()) { $recentPosts->the_post(); ?> <li class="post-widget clearfix"> <?php $img_url = false; $size = 'thumbnail'; $img_id = get_post_thumbnail_id($recentPosts->post->ID); $photo = wp_get_attachment_image_src($img_id, $size); $img_url = isset($photo[0]) ? $photo[0] : ''; $has_img = $img_url ? 'has-img' : ''; if ($img_url) { ?> <div class="widget-thumbnail"> <a href="<?php echo get_permalink($recentPosts->post->ID); ?> " class="thumb-link"> <img width="60" src="<?php echo esc_url($img_url); ?> " alt="<?php echo esc_attr(get_the_title()); ?> "/> </a> </div><!-- / div.widget-thumbnail --> <?php } ?> <div class="widget-context <?php echo esc_attr($has_img); ?> "> <h4><a href="<?php echo get_permalink($recentPosts->post->ID); ?> "><?php the_title(); ?> </a></h4> <small><?php the_time('F j, Y'); ?> </small> </div><!-- / div.widget-context --> </li><!-- / div.post-widget --> <?php } $recentPosts = $temp; echo '</ul></div>'; echo '<div class="tab-context"><ul>'; $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_author_email, comment_date_gmt, comment_approved, comment_type, comment_author_url, SUBSTRING(comment_content,1,70) AS com_excerpt FROM {$wpdb->comments} LEFT OUTER JOIN {$wpdb->posts} ON ({$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT " . intval($count); $comments = $wpdb->get_results($sql); foreach ($comments as $comment) { ?> <li class="post-widget post-widget-comment clearfix"> <div class="widget-thumbnail"> <a href="<?php echo get_permalink($comment->ID); ?> #comment-<?php echo esc_attr($comment->comment_ID); ?> " title="<?php echo esc_attr(strip_tags($comment->comment_author)); ?> <?php _e('on ', 'ThemeStockyard'); echo esc_attr($comment->post_title); ?> " class="thumb-link"><?php echo get_avatar($comment, '60'); ?> </a> </div> <div class="widget-context"> <a href="<?php echo get_permalink($comment->ID); ?> #comment-<?php echo esc_attr($comment->comment_ID); ?> " class="comm_link"> <h4><?php echo esc_html(strip_tags($comment->comment_author)); ?> </h4> <p>“<?php echo ts_essentials_trim_text($comment->com_excerpt, 50); ?> ”</p> </a> <p class="small"><?php _e('on', 'ThemeStockyard'); ?> <a href="<?php echo get_permalink($comment->comment_post_ID); ?> " class="post-link"><?php echo ts_essentials_trim_text(get_the_title($comment->comment_post_ID), 36); ?> </a></p> </div> </li> <?php } echo '</ul></div>'; wp_reset_postdata(); echo '</div>'; echo '</div>'; echo '</div>'; echo ts_essentials_escape($args['after_widget']); }
function form($instance) { $defaults = array('title' => __('Video', 'ThemeStockyard'), 'video' => '', 'url' => ''); $instance = wp_parse_args((array) $instance, $defaults); $video = esc_textarea($instance['video']); $url = esc_url($instance['url']); ?> <p> <label for="<?php echo esc_attr($this->get_field_id('title')); ?> "><?php echo _e('Title:', 'ThemeStockyard'); ?> </label> <input type="text" class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?> " name="<?php echo esc_attr($this->get_field_name('title')); ?> " value="<?php echo esc_attr($instance['title']); ?> " /> </p> <p><label for="<?php echo esc_attr($this->get_field_id('url')); ?> "><?php echo _e('Video URL:', 'ThemeStockyard'); ?> </label> <input type="text" class="widefat" id="<?php echo esc_attr($this->get_field_id('url')); ?> " name="<?php echo esc_attr($this->get_field_name('url')); ?> " value="<?php echo esc_attr($instance['url']); ?> " /></p> <p><strong><?php _e('-OR-', 'ThemeStockyard'); ?> </strong></p> <p><label for="<?php echo esc_attr($this->get_field_id('video')); ?> "><?php echo _e('Video Embed Code:', 'ThemeStockyard'); ?> </label> <textarea class="widefat" rows="5" cols="20" id="<?php echo esc_attr($this->get_field_id('video')); ?> " name="<?php echo esc_attr($this->get_field_name('video')); ?> "><?php echo ts_essentials_escape($video); ?> </textarea></p> <?php }
function widget($args, $instance) { $title = $instance['title']; $num = $instance['num']; echo ts_essentials_escape($args['before_widget']); if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } echo '<ul>'; $popular_posts = ''; $temp = $popular_posts; $popular_posts = new WP_Query(array('showposts' => intval($num), 'orderby' => 'comment_count')); while ($popular_posts->have_posts()) { $popular_posts->the_post(); ?> <li class="post-widget clearfix"> <?php $img_url = false; $size = 'thumbnail'; $img_id = get_post_thumbnail_id($popular_posts->post->ID); $photo = wp_get_attachment_image_src($img_id, $size); $img_url = isset($photo[0]) ? $photo[0] : ''; $has_img = $img_url ? 'has-img' : ''; if ($img_url) { ?> <div class="widget-thumbnail"> <a href="<?php echo get_permalink($popular_posts->post->ID); ?> " class="thumb-link"> <img width="60" src="<?php echo esc_url($img_url); ?> " alt="<?php echo esc_attr($popular_posts->post->post_title); ?> "/> </a> </div><!-- / div.widget-thumbnail --> <?php } ?> <div class="widget-context <?php echo esc_attr($has_img); ?> "> <h4><a href="<?php echo get_permalink($popular_posts->post->ID); ?> "><?php echo the_title(); ?> </a></h4> <small><?php echo get_the_time('F j, Y', $popular_posts->post->ID); ?> </small> </div><!-- / div.widget-context --> </li><!-- / div.post-widget --> <?php } $popular_posts = $temp; echo '</ul>'; echo ts_essentials_escape($args['after_widget']); }
function widget($args, $instance) { $title = $instance['title']; $username = isset($instance['username']) ? preg_replace("/[^a-zA-Z0-9\\-_]+/", "", $instance['username']) : ''; $number = isset($instance['number']) ? $instance['number'] : 3; $consumer_key = isset($instance['consumer_key']) ? $instance['consumer_key'] : ''; $consumer_secret = isset($instance['consumer_secret']) ? $instance['consumer_secret'] : ''; $access_token = isset($instance['access_token']) ? $instance['access_token'] : ''; $access_token_secret = isset($instance['access_token_secret']) ? $instance['access_token_secret'] : ''; $links_in_new_tab = isset($instance['links_in_new_tab']) && $instance['links_in_new_tab'] == 1 ? true : false; $exclude_replies = isset($instance['exclude_replies']) && $instance['exclude_replies'] == 1 ? 1 : 0; $include_retweets = isset($instance['include_retweets']) && $instance['include_retweets'] == 1 ? 1 : 0; $follow_us_text = isset($instance['follow_us_text']) ? $instance['follow_us_text'] : ''; echo ts_essentials_escape($args['before_widget']); if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } $last_twitter_save = get_option('ts_last_twitter_save_' . $username); $last_twitter_reponse = get_option('ts_last_twitter_response_' . $username); $last_twitter_reponse = $last_twitter_reponse ? json_decode($last_twitter_reponse, true) : ''; if ($last_twitter_save && time() - $last_twitter_save < 120 && $last_twitter_reponse && count($last_twitter_reponse) > 0) { //$last_twitter_reponse = json_decode($last_twitter_reponse, true); } else { $twitter_config = array('consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret, 'token' => $access_token, 'secret' => $access_token_secret); $tmhOAuth = new tmhOAuth($twitter_config); $params = array('count' => $number, 'screen_name' => $username, 'exclude_replies' => $exclude_replies, 'include_rts' => $include_retweets); $code = $tmhOAuth->user_request(array('method' => 'GET', 'url' => $tmhOAuth->url("1.1/statuses/user_timeline"), 'params' => $params)); if ($code == 200) { $last_twitter_reponse = $tmhOAuth->response['response']; $last_twitter_reponse_error = $last_twitter_reponse; update_option('ts_last_twitter_save_' . $username, time()); update_option('ts_last_twitter_response_' . $username, $last_twitter_reponse); $last_twitter_reponse = json_decode($last_twitter_reponse, true); } else { //echo '<div><pre>'.$tmhOAuth->response['raw'].'</pre></div>'; } } echo '<div class="ts-twitter-widget">'; echo count($last_twitter_reponse) ? '<ul>' : ''; $i = 1; if (is_array($last_twitter_reponse)) { foreach ($last_twitter_reponse as $tweet) { $tweet['text'] = trim($tweet['text']); $actual_tweet = ts_essentials_clean_tweet($tweet['text'], $links_in_new_tab); $multi_line_class = $tweet['text'] == nl2br($tweet['text']) ? '' : 'white-space-pre-wrap'; $urls = $tweet['entities']['urls']; foreach ($urls as $url) { $seek = $url['url']; $replace = $url['expanded_url']; $replace_display = $url['display_url']; $actual_tweet = str_replace($seek, $replace, $actual_tweet); $actual_tweet = str_replace('>' . $replace . '<', '>' . $replace_display . '<', $actual_tweet); } echo '<li><p class="' . esc_attr($multi_line_class) . '">' . strip_tags($actual_tweet, '<a>') . '</p>'; $target = $links_in_new_tab ? 'target="_blank"' : ''; echo '<small class="small"><a href="' . esc_url('https://twitter.com/' . $tweet['user']['screen_name'] . '/status/' . $tweet['id_str']) . '" ' . $target . '>' . ts_essentials_time2str($tweet['created_at']) . '</a></small><i class="fa fa-twitter color-primary"></i></li>'; $i++; if ($i > $number) { break; } } } echo count($last_twitter_reponse) ? '</ul>' : ''; if (trim($follow_us_text)) { echo '<div class="follow-link mimic-smaller uppercase"><a href="' . esc_url('https://twitter.com/' . $username) . '" target="_blank">' . $follow_us_text . '</a></div>'; } echo '</div><!-- end: .ts-twitter-widget -->'; echo ts_essentials_escape($args['after_widget']) . '<!-- end: .widget -->'; }