Guest User

Untitled

a guest
Oct 30th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.35 KB | None | 0 0
  1. <?php if ( ! defined('AVIA_FW')) exit('No direct script access allowed');
  2. /**
  3. * This file holds several widgets exclusive to the framework
  4. *
  5. * @author Christian "Kriesi" Budschedl
  6. * @copyright Copyright (c) Christian Budschedl
  7. * @link http://Kriesi.at
  8. * @link http://aviathemes.com
  9. * @since Version 1.0
  10. * @package AviaFramework
  11. */
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19. /**
  20. * AVIA COMBO WIDGET
  21. *
  22. * Widget that retrieves, stores and displays the number of twitter and rss followers
  23. *
  24. * @package AviaFramework
  25. * @todo replace the widget system with a dynamic one, based on config files for easier widget creation
  26. */
  27.  
  28. if (!class_exists('avia_fb_likebox'))
  29. {
  30. class avia_fb_likebox extends WP_Widget {
  31.  
  32. function avia_fb_likebox() {
  33. //Constructor
  34. $widget_ops = array('classname' => 'avia_fb_likebox', 'description' => 'A widget that displays a facebook Likebox to a facebook page of your choice' );
  35. $this->WP_Widget( 'avia_fb_likebox', THEMENAME.' Facebook Likebox', $widget_ops );
  36. }
  37.  
  38. function widget($args, $instance)
  39. {
  40. // prints the widget
  41.  
  42. extract($args, EXTR_SKIP);
  43. if(empty($instance['url'])) return;
  44. $url = urlencode($instance['url']);
  45. $height = $instance['height'];
  46. $border = $instance['border'];
  47. $profiles = 3000; // since the height determines the number of images loaded
  48. $faces = "true";
  49. $extraClass = "";
  50. $style = "";
  51.  
  52. if(strpos($height, "%") === false && strpos($height, "px") === false) $height = $height."px";
  53.  
  54. if(strpos($height, "%") !== false)
  55. {
  56. $extraClass = "av_facebook_widget_wrap_positioner";
  57. $style = "style='padding-bottom:{$height}'";
  58. $height = "100%";
  59. }
  60.  
  61.  
  62. echo $before_widget;
  63. echo "<div class='av_facebook_widget_wrap {$extraClass} av_facebook_widget_wrap_border_{$border}' {$style}>";
  64. echo '<iframe class="av_facebook_widget" src="//www.facebook.com/plugins/likebox.php?href='.$url.'&amp;width&amp;height='.$profiles.'&amp;colorscheme=light&amp;show_faces='.$faces.'&amp;header=false&amp;stream=false&amp;show_border=false" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:'.$height.';" allowTransparency="true"></iframe>';
  65. echo "</div>";
  66. echo $after_widget;
  67. }
  68.  
  69.  
  70. function update($new_instance, $old_instance)
  71. {
  72. $instance = $old_instance;
  73. foreach($new_instance as $key=>$value)
  74. {
  75. $instance[$key] = strip_tags($new_instance[$key]);
  76. }
  77.  
  78. return $instance;
  79. }
  80.  
  81. function form($instance) {
  82. //widgetform in backend
  83.  
  84. $instance = wp_parse_args( (array) $instance, array('url' => 'https://www.facebook.com/kriesi.at', 'height' => '258px', 'border' => 'yes') );
  85. $html = new avia_htmlhelper();
  86. $elementCat = array("name" => "",
  87. "desc" => "",
  88. "id" => $this->get_field_name('border'),
  89. "type" => "select",
  90. "std" => strip_tags($instance['border']),
  91. "class" => "",
  92. "no_first" => true,
  93. "subtype" => array('Yes, display border'=>'yes', 'No, do not display border'=>'no'));
  94.  
  95. ?>
  96. <p>
  97. <label for="<?php echo $this->get_field_id('url'); ?>">Enter the url to the Page. Please note that it needs to be a link to a <strong>facebook fanpage</strong>. Personal profiles are not allowed!
  98. <input class="widefat" id="<?php echo $this->get_field_id('url'); ?>" name="<?php echo $this->get_field_name('url'); ?>" type="text" value="<?php echo esc_attr($instance['url']); ?>" /></label>
  99. </p>
  100.  
  101.  
  102. <p>
  103. <label for="<?php echo $this->get_field_id('height'); ?>">Enter the widget height in pixel or % <br/><small>(100% would create a widget of equal height and width)</small>
  104. <input class="widefat" id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo esc_attr($instance['height']); ?>" /></label>
  105. </p>
  106.  
  107.  
  108. <p><label for="<?php echo $this->get_field_id('border'); ?>">Display Border around the widget?
  109. <?php echo $html->select($elementCat); ?>
  110. </label></p>
  111.  
  112.  
  113. <?php
  114. }
  115. }
  116. }
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. /**
  134. * AVIA TWEETBOX
  135. *
  136. * Widget that creates a list of latest tweets
  137. *
  138. * @package AviaFramework
  139. * @todo replace the widget system with a dynamic one, based on config files for easier widget creation
  140. */
  141.  
  142.  
  143.  
  144. /*
  145. Twitter widget only for compatibility reasons with older themes present. no onger used since API will be shut down by twitter
  146. */
  147. if (!class_exists('avia_tweetbox'))
  148. {
  149. class avia_tweetbox extends WP_Widget {
  150.  
  151. function avia_tweetbox() {
  152. //Constructor
  153. $widget_ops = array('classname' => 'tweetbox', 'description' => 'A widget to display your latest twitter messages' );
  154. $this->WP_Widget( 'tweetbox', THEMENAME.' Twitter Widget', $widget_ops );
  155. }
  156.  
  157. function widget($args, $instance) {
  158. // prints the widget
  159.  
  160. extract($args, EXTR_SKIP);
  161. echo $before_widget;
  162.  
  163. $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
  164. $count = empty($instance['count']) ? '' : $instance['count'];
  165. $username = empty($instance['username']) ? '' : $instance['username'];
  166. $exclude_replies = empty($instance['exclude_replies']) ? '' : $instance['exclude_replies'];
  167. $time = empty($instance['time']) ? 'no' : $instance['time'];
  168. $display_image = empty($instance['display_image']) ? 'no' : $instance['display_image'];
  169.  
  170. if ( !empty( $title ) ) { echo $before_title . "<a href='http://twitter.com/$username/' title='".strip_tags($title)."'>".$title ."</a>". $after_title; };
  171.  
  172. $messages = tweetbox_get_tweet($count, $username, $widget_id, $time, $exclude_replies, $display_image);
  173. echo $messages;
  174.  
  175. echo $after_widget;
  176.  
  177.  
  178. }
  179.  
  180. function update($new_instance, $old_instance) {
  181. //save the widget
  182. $instance = $old_instance;
  183. foreach($new_instance as $key=>$value)
  184. {
  185. $instance[$key] = strip_tags($new_instance[$key]);
  186. }
  187.  
  188. delete_transient(THEMENAME.'_tweetcache_id_'.$instance['username'].'_'.$this->id_base."-".$this->number);
  189. return $instance;
  190. }
  191.  
  192. function form($instance) {
  193. //widgetform in backend
  194.  
  195. $instance = wp_parse_args( (array) $instance, array( 'title' => 'Latest Tweets', 'count' => '3', 'username' => avia_get_option('twitter') ) );
  196. $title = isset($instance['title']) ? strip_tags($instance['title']): "";
  197. $count = isset($instance['count']) ? strip_tags($instance['count']): "";
  198. $username = isset($instance['username']) ? strip_tags($instance['username']): "";
  199. $exclude_replies = isset($instance['exclude_replies']) ? strip_tags($instance['exclude_replies']): "";
  200. $time = isset($instance['time']) ? strip_tags($instance['time']): "";
  201. $display_image = isset($instance['display_image']) ? strip_tags($instance['display_image']): "";
  202. ?>
  203. <p>
  204. <label for="<?php echo $this->get_field_id('title'); ?>">Title:
  205. <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
  206.  
  207. <p><label for="<?php echo $this->get_field_id('username'); ?>">Enter your twitter username:
  208. <input class="widefat" id="<?php echo $this->get_field_id('username'); ?>" name="<?php echo $this->get_field_name('username'); ?>" type="text" value="<?php echo esc_attr($username); ?>" /></label></p>
  209.  
  210. <p>
  211. <label for="<?php echo $this->get_field_id('count'); ?>">How many entries do you want to display: </label>
  212. <select class="widefat" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>">
  213. <?php
  214. $list = "";
  215. for ($i = 1; $i <= 20; $i++ )
  216. {
  217. $selected = "";
  218. if($count == $i) $selected = 'selected="selected"';
  219.  
  220. $list .= "<option $selected value='$i'>$i</option>";
  221. }
  222. $list .= "</select>";
  223. echo $list;
  224. ?>
  225.  
  226.  
  227. </p>
  228.  
  229. <p>
  230. <label for="<?php echo $this->get_field_id('exclude_replies'); ?>">Exclude @replies: </label>
  231. <select class="widefat" id="<?php echo $this->get_field_id('exclude_replies'); ?>" name="<?php echo $this->get_field_name('exclude_replies'); ?>">
  232. <?php
  233. $list = "";
  234. $answers = array('yes','no');
  235. foreach ($answers as $answer)
  236. {
  237. $selected = "";
  238. if($answer == $exclude_replies) $selected = 'selected="selected"';
  239.  
  240. $list .= "<option $selected value='$answer'>$answer</option>";
  241. }
  242. $list .= "</select>";
  243. echo $list;
  244. ?>
  245.  
  246.  
  247. </p>
  248.  
  249. <p>
  250. <label for="<?php echo $this->get_field_id('time'); ?>">Display time of tweet</label>
  251. <select class="widefat" id="<?php echo $this->get_field_id('time'); ?>" name="<?php echo $this->get_field_name('time'); ?>">
  252. <?php
  253. $list = "";
  254. $answers = array('yes','no');
  255. foreach ($answers as $answer)
  256. {
  257. $selected = "";
  258. if($answer == $time) $selected = 'selected="selected"';
  259.  
  260. $list .= "<option $selected value='$answer'>$answer</option>";
  261. }
  262. $list .= "</select>";
  263. echo $list;
  264. ?>
  265.  
  266.  
  267. </p>
  268.  
  269. <p>
  270. <label for="<?php echo $this->get_field_id('display_image'); ?>">Display Twitter User Avatar</label>
  271. <select class="widefat" id="<?php echo $this->get_field_id('display_image'); ?>" name="<?php echo $this->get_field_name('display_image'); ?>">
  272. <?php
  273. $list = "";
  274. $answers = array('yes','no');
  275. foreach ($answers as $answer)
  276. {
  277. $selected = "";
  278. if($answer == $display_image) $selected = 'selected="selected"';
  279.  
  280. $list .= "<option $selected value='$answer'>$answer</option>";
  281. }
  282. $list .= "</select>";
  283. echo $list;
  284. ?>
  285. </p>
  286.  
  287.  
  288.  
  289. <?php
  290. }
  291. }
  292. }
  293.  
  294. if(!function_exists('tweetbox_get_tweet'))
  295. {
  296. function tweetbox_get_tweet($count, $username, $widget_id, $time='yes', $exclude_replies='yes', $avatar = 'yes')
  297. {
  298. $filtered_message = "";
  299. $output = "";
  300. $iterations = 0;
  301.  
  302. $cache = get_transient(THEMENAME.'_tweetcache_id_'.$username.'_'.$widget_id);
  303.  
  304. if($cache)
  305. {
  306. $tweets = get_option(THEMENAME.'_tweetcache_'.$username.'_'.$widget_id);
  307. }
  308. else
  309. {
  310. //$response = wp_remote_get( 'http://api.twitter.com/1/statuses/user_timeline.xml?screen_name='.$username );
  311. $response = wp_remote_get( 'http://api.twitter.com/1/statuses/user_timeline.xml?include_rts=true&screen_name='.$username );
  312. if (!is_wp_error($response))
  313. {
  314. $xml = @simplexml_load_string($response['body']);
  315. //follower: (int) $xml->status->user->followers_count
  316.  
  317. if( empty( $xml->error ) )
  318. {
  319. if ( isset($xml->status[0]))
  320. {
  321.  
  322. $tweets = array();
  323. foreach ($xml->status as $tweet)
  324. {
  325. if($iterations == $count) break;
  326.  
  327. $text = (string) $tweet->text;
  328. if($exclude_replies == 'no' || ($exclude_replies == 'yes' && $text[0] != "@"))
  329. {
  330. $iterations++;
  331. $tweets[] = array(
  332. 'text' => tweetbox_filter( $text ),
  333. 'created' => strtotime( $tweet->created_at ),
  334. 'user' => array(
  335. 'name' => (string)$tweet->user->name,
  336. 'screen_name' => (string)$tweet->user->screen_name,
  337. 'image' => (string)$tweet->user->profile_image_url,
  338. 'utc_offset' => (int) $tweet->user->utc_offset[0],
  339. 'follower' => (int) $tweet->user->followers_count
  340.  
  341. ));
  342. }
  343. }
  344.  
  345. set_transient(THEMENAME.'_tweetcache_id_'.$username.'_'.$widget_id, 'true', 60*30);
  346. update_option(THEMENAME.'_tweetcache_'.$username.'_'.$widget_id, $tweets);
  347. }
  348. }
  349. }
  350. }
  351.  
  352.  
  353.  
  354. if(!isset($tweets[0]))
  355. {
  356. $tweets = get_option(THEMENAME.'_tweetcache_'.$username.'_'.$widget_id);
  357. }
  358.  
  359. if(isset($tweets[0]))
  360. {
  361. $time_format = apply_filters( 'avia_widget_time', get_option('date_format')." - ".get_option('time_format'), 'tweetbox' );
  362.  
  363. foreach ($tweets as $message)
  364. {
  365. $output .= '<li class="tweet">';
  366. if($avatar == "yes") $output .= '<div class="tweet-thumb"><a href="http://twitter.com/'.$username.'" title=""><img src="'.$message['user']['image'].'" alt="" /></a></div>';
  367. $output .= '<div class="tweet-text avatar_'.$avatar.'">'.$message['text'];
  368. if($time == "yes") $output .= '<div class="tweet-time">'.date_i18n( $time_format, $message['created'] + $message['user']['utc_offset']).'</div>';
  369. $output .= '</div></li>';
  370. }
  371. }
  372.  
  373.  
  374. if($output != "")
  375. {
  376. $filtered_message = "<ul class='tweets'>$output</ul>";
  377. }
  378. else
  379. {
  380. $filtered_message = "<ul class='tweets'><li>No public Tweets found</li></ul>";
  381. }
  382.  
  383. return $filtered_message;
  384. }
  385. }
  386.  
  387. if(!function_exists('tweetbox_filter'))
  388. {
  389. function tweetbox_filter($text) {
  390. // Props to Allen Shaw & webmancers.com & Michael Voigt
  391. $text = preg_replace('/\b([a-zA-Z]+:\/\/[\w_.\-]+\.[a-zA-Z]{2,6}[\/\w\-~.?=&%#+$*!]*)\b/i',"<a href=\"$1\" class=\"twitter-link\">$1</a>", $text);
  392. $text = preg_replace('/\b(?<!:\/\/)(www\.[\w_.\-]+\.[a-zA-Z]{2,6}[\/\w\-~.?=&%#+$*!]*)\b/i',"<a href=\"http://$1\" class=\"twitter-link\">$1</a>", $text);
  393. $text = preg_replace("/\b([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})\b/i","<a href=\"mailto://$1\" class=\"twitter-link\">$1</a>", $text);
  394. $text = preg_replace("/#([\p{L}\p{Mn}]+)/u", "<a class=\"twitter-link\" href=\"http://search.twitter.com/search?q=\\1\">#\\1</a>", $text);
  395. $text = preg_replace("/@([\p{L}\p{Mn}]+)/u", "<a class=\"twitter-link\" href=\"http://twitter.com/\\1\">@\\1</a>", $text);
  396.  
  397. return $text;
  398. }
  399. }
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409. /**
  410. * AVIA NEWSBOX
  411. *
  412. * Widget that creates a list of latest news entries
  413. *
  414. * @package AviaFramework
  415. * @todo replace the widget system with a dynamic one, based on config files for easier widget creation
  416. */
  417.  
  418. if (!class_exists('avia_newsbox'))
  419. {
  420. class avia_newsbox extends WP_Widget {
  421.  
  422. var $avia_term = '';
  423. var $avia_post_type = '';
  424. var $avia_new_query = '';
  425.  
  426. function avia_newsbox()
  427. {
  428. $widget_ops = array('classname' => 'newsbox', 'description' => 'A Sidebar widget to display latest post entries in your sidebar' );
  429.  
  430. $this->WP_Widget( 'newsbox', THEMENAME.' Latest News', $widget_ops );
  431. }
  432.  
  433. function widget($args, $instance)
  434. {
  435.  
  436. global $avia_config;
  437.  
  438. extract($args, EXTR_SKIP);
  439. echo $before_widget;
  440.  
  441. $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
  442. $count = empty($instance['count']) ? '' : $instance['count'];
  443. $cat = empty($instance['cat']) ? '' : $instance['cat'];
  444. $excerpt = empty($instance['excerpt']) ? '' : $instance['excerpt'];
  445. $image_size = isset($avia_config['widget_image_size']) ? $avia_config['widget_image_size'] : 'widget';
  446.  
  447. if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
  448.  
  449.  
  450. if(empty($this->avia_term))
  451. {
  452. $additional_loop = new WP_Query("cat=".$cat."&posts_per_page=".$count);
  453. }
  454. else
  455. {
  456. $catarray = explode(',', $cat);
  457.  
  458.  
  459. if(empty($catarray[0]))
  460. {
  461. $new_query = array("posts_per_page"=>$count,"post_type"=>$this->avia_post_type);
  462. }
  463. else
  464. {
  465. if($this->avia_new_query)
  466. {
  467. $new_query = $this->avia_new_query;
  468. }
  469. else
  470. {
  471. $new_query = array( "posts_per_page"=>$count, 'tax_query' => array(
  472. array( 'taxonomy' => $this->avia_term,
  473. 'field' => 'id',
  474. 'terms' => explode(',', $cat),
  475. 'operator' => 'IN')
  476. )
  477. );
  478. }
  479. }
  480.  
  481. $additional_loop = new WP_Query($new_query);
  482. }
  483.  
  484. if($additional_loop->have_posts()) :
  485.  
  486.  
  487.  
  488. echo '<ul class="news-wrap image_size_'.$image_size.'">';
  489. while ($additional_loop->have_posts()) : $additional_loop->the_post();
  490.  
  491. $format = "";
  492. if(empty($this->avia_post_type)) $format = $this->avia_post_type;
  493. if(empty($format)) $format = get_post_format();
  494. if(empty($format)) $format = 'standard';
  495.  
  496. echo '<li class="news-content post-format-'.$format.'">';
  497.  
  498. //check for preview images:
  499. $image = "";
  500.  
  501. if(!current_theme_supports('force-post-thumbnails-in-widget'))
  502. {
  503. $slides = avia_post_meta(get_the_ID(), 'slideshow', true);
  504.  
  505. if( $slides != "" && !empty( $slides[0]['slideshow_image'] ) )
  506. {
  507. $image = avia_image_by_id($slides[0]['slideshow_image'], $image_size, 'image');
  508. }
  509. }
  510.  
  511. if(current_theme_supports( 'post-thumbnails' ) && !$image )
  512. {
  513. $image = get_the_post_thumbnail( get_the_ID(), $image_size );
  514. }
  515.  
  516. $time_format = apply_filters( 'avia_widget_time', get_option('date_format')." - ".get_option('time_format'), 'avia_newsbox' );
  517.  
  518.  
  519. echo "<a class='news-link' title='".get_the_title()."' href='".get_permalink()."'>";
  520.  
  521. $nothumb = (!$image) ? 'no-news-thumb' : '';
  522.  
  523. echo "<span class='news-thumb $nothumb'>";
  524. echo $image;
  525. echo "</span>";
  526. if(empty($avia_config['widget_image_size']) || 'display title and excerpt' != $excerpt)
  527. {
  528. echo "<strong class='news-headline'>".get_the_title();
  529.  
  530. if($time_format)
  531. {
  532. echo "<span class='news-time'>".get_the_time($time_format)."</span>";
  533. }
  534.  
  535. echo "</strong>";
  536. }
  537. echo "</a>";
  538.  
  539. if('display title and excerpt' == $excerpt)
  540. {
  541. echo "<div class='news-excerpt'>";
  542.  
  543. if(!empty($avia_config['widget_image_size']))
  544. {
  545. echo "<a class='news-link-inner' title='".get_the_title()."' href='".get_permalink()."'>";
  546. echo "<strong class='news-headline'>".get_the_title()."</strong>";
  547. echo "</a>";
  548. if($time_format)
  549. {
  550. echo "<span class='news-time'>".get_the_time($time_format)."</span>";
  551. }
  552.  
  553. }
  554. the_excerpt();
  555. echo "</div>";
  556. }
  557.  
  558. echo '</li>';
  559.  
  560.  
  561. endwhile;
  562. echo "</ul>";
  563. wp_reset_postdata();
  564. endif;
  565.  
  566.  
  567. echo $after_widget;
  568.  
  569. }
  570.  
  571.  
  572. function update($new_instance, $old_instance)
  573. {
  574. $instance = $old_instance;
  575. $instance['title'] = strip_tags($new_instance['title']);
  576. $instance['count'] = strip_tags($new_instance['count']);
  577. $instance['excerpt'] = strip_tags($new_instance['excerpt']);
  578. $instance['cat'] = implode(',',$new_instance['cat']);
  579. return $instance;
  580. }
  581.  
  582.  
  583.  
  584. function form($instance)
  585. {
  586. $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => '', 'cat' => '', 'excerpt'=>'' ) );
  587. $title = strip_tags($instance['title']);
  588. $count = strip_tags($instance['count']);
  589. $excerpt = strip_tags($instance['excerpt']);
  590.  
  591.  
  592. $elementCat = array("name" => "Which categories should be used for the portfolio?",
  593. "desc" => "You can select multiple categories here",
  594. "id" => $this->get_field_name('cat')."[]",
  595. "type" => "select",
  596. "std" => strip_tags($instance['cat']),
  597. "class" => "",
  598. "multiple"=>6,
  599. "subtype" => "cat");
  600. //check if a different taxonomy than the default is set
  601. if(!empty($this->avia_term))
  602. {
  603. $elementCat['taxonomy'] = $this->avia_term;
  604. }
  605.  
  606.  
  607.  
  608.  
  609. $html = new avia_htmlhelper();
  610.  
  611. ?>
  612. <p><label for="<?php echo $this->get_field_id('title'); ?>">Title:
  613. <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
  614.  
  615. <p>
  616. <label for="<?php echo $this->get_field_id('count'); ?>">How many entries do you want to display: </label>
  617. <select class="widefat" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>">
  618. <?php
  619. $list = "";
  620. for ($i = 1; $i <= 20; $i++ )
  621. {
  622. $selected = "";
  623. if($count == $i) $selected = 'selected="selected"';
  624.  
  625. $list .= "<option $selected value='$i'>$i</option>";
  626. }
  627. $list .= "</select>";
  628. echo $list;
  629. ?>
  630.  
  631.  
  632. </p>
  633.  
  634. <p><label for="<?php echo $this->get_field_id('cat'); ?>">Choose the categories you want to display (multiple selection possible):
  635. <?php echo $html->select($elementCat); ?>
  636. </label></p>
  637.  
  638. <p>
  639. <label for="<?php echo $this->get_field_id('excerpt'); ?>">Display title only or title &amp; excerpt</label>
  640. <select class="widefat" id="<?php echo $this->get_field_id('excerpt'); ?>" name="<?php echo $this->get_field_name('excerpt'); ?>">
  641. <?php
  642. $list = "";
  643. $answers = array('show title only','display title and excerpt');
  644. foreach ($answers as $answer)
  645. {
  646. $selected = "";
  647. if($answer == $excerpt) $selected = 'selected="selected"';
  648.  
  649. $list .= "<option $selected value='$answer'>$answer</option>";
  650. }
  651. $list .= "</select>";
  652. echo $list;
  653. ?>
  654.  
  655.  
  656. </p>
  657.  
  658.  
  659. <?php
  660. }
  661. }
  662. }
  663.  
  664.  
  665. /**
  666. * AVIA PORTFOLIOBOX
  667. *
  668. * Widget that creates a list of latest portfolio entries. Basically the same widget as the newsbox with some minor modifications, therefore it just extends the Newsbox
  669. *
  670. * @package AviaFramework
  671. * @todo replace the widget system with a dynamic one, based on config files for easier widget creation
  672. */
  673.  
  674. if (!class_exists('avia_portfoliobox'))
  675. {
  676. class avia_portfoliobox extends avia_newsbox
  677. {
  678. function avia_portfoliobox()
  679. {
  680. $this->avia_term = 'portfolio_entries';
  681. $this->avia_post_type = 'portfolio';
  682. $this->avia_new_query = ''; //set a custom query here
  683.  
  684.  
  685. $widget_ops = array('classname' => 'newsbox', 'description' => 'A Sidebar widget to display latest portfolio entries in your sidebar' );
  686.  
  687. $this->WP_Widget( 'portfoliobox', THEMENAME.' Latest Portfolio', $widget_ops );
  688. }
  689. }
  690. }
  691.  
  692.  
  693.  
  694. /**
  695. * AVIA SOCIALCOUNT
  696. *
  697. * Widget that retrieves, stores and displays the number of twitter and rss followers
  698. *
  699. * @package AviaFramework
  700. * @todo replace the widget system with a dynamic one, based on config files for easier widget creation
  701. */
  702.  
  703. if (!class_exists('avia_socialcount'))
  704. {
  705. class avia_socialcount extends WP_Widget {
  706.  
  707. function avia_socialcount() {
  708. //Constructor
  709. $widget_ops = array('classname' => 'avia_socialcount', 'description' => 'A widget to display a link to your twitter profile and rss feed' );
  710. $this->WP_Widget( 'avia_socialcount', THEMENAME.' RSS Link and Twitter Account', $widget_ops );
  711. }
  712.  
  713. function widget($args, $instance) {
  714. // prints the widget
  715.  
  716. extract($args, EXTR_SKIP);
  717. $twitter = empty($instance['twitter']) ? '' : $instance['twitter'];
  718. $rss = empty($instance['rss']) ? '' : $instance['rss'];
  719. $rss = preg_replace('!https?:\/\/feeds.feedburner.com\/!','',$rss);
  720.  
  721.  
  722. if(!empty($twitter) || !empty($rss))
  723. {
  724. $addClass = "asc_multi_count";
  725. if(!isset($twitter) || !isset($rss)) $addClass = 'asc_single_count';
  726.  
  727. echo $before_widget;
  728. $output = "";
  729. if(isset($twitter))
  730. {
  731. $link = 'http://twitter.com/'.$twitter.'/';
  732. $before = apply_filters('avf_social_widget', "", 'twitter');
  733. $output .= "<a href='$link' class='asc_twitter $addClass'>{$before}<strong class='asc_count'>".__('Follow','avia_framework')."</strong><span>".__('on Twitter','avia_framework')."</span></a>";
  734.  
  735. }
  736.  
  737. if($rss)
  738. {
  739. $output .= "<a href='$rss' class='asc_rss $addClass'>".apply_filters('avf_social_widget',"", 'rss')."<strong class='asc_count'>".__('Subscribe','avia_framework')."</strong><span>".__('to RSS Feed','avia_framework')."</span></a>";
  740. }
  741.  
  742. echo $output;
  743. echo $after_widget;
  744. }
  745. }
  746.  
  747.  
  748.  
  749. function update($new_instance, $old_instance) {
  750. //save the widget
  751. $instance = $old_instance;
  752. foreach($new_instance as $key=>$value)
  753. {
  754. $instance[$key] = strip_tags($new_instance[$key]);
  755. }
  756.  
  757. return $instance;
  758. }
  759.  
  760. function form($instance) {
  761. //widgetform in backend
  762.  
  763. $instance = wp_parse_args( (array) $instance, array('rss' => avia_get_option('feedburner'), 'twitter' => avia_get_option('twitter') ) );
  764. $twitter = empty($instance['twitter']) ? '' : strip_tags($instance['twitter']);
  765. $rss = empty($instance['rss']) ? '' : strip_tags($instance['rss']);
  766. ?>
  767. <p>
  768. <label for="<?php echo $this->get_field_id('twitter'); ?>">Twitter Username:
  769. <input class="widefat" id="<?php echo $this->get_field_id('twitter'); ?>" name="<?php echo $this->get_field_name('twitter'); ?>" type="text" value="<?php echo esc_attr($twitter); ?>" /></label></p>
  770.  
  771. <p><label for="<?php echo $this->get_field_id('rss'); ?>">Enter your feed url:
  772. <input class="widefat" id="<?php echo $this->get_field_id('rss'); ?>" name="<?php echo $this->get_field_name('rss'); ?>" type="text" value="<?php echo esc_attr($rss); ?>" /></label></p>
  773.  
  774.  
  775.  
  776. <?php
  777. }
  778. }
  779. }
  780.  
  781.  
  782.  
  783.  
  784. /**
  785. * AVIA ADVERTISING WIDGET
  786. *
  787. * Widget that retrieves, stores and displays the number of twitter and rss followers
  788. *
  789. * @package AviaFramework
  790. * @todo replace the widget system with a dynamic one, based on config files for easier widget creation
  791. */
  792.  
  793.  
  794. //multiple images
  795. if (!class_exists('avia_partner_widget'))
  796. {
  797. class avia_partner_widget extends WP_Widget {
  798.  
  799. function avia_partner_widget() {
  800.  
  801. $this->add_cont = 3;
  802. //Constructor
  803. $widget_ops = array('classname' => 'avia_partner_widget', 'description' => 'An advertising widget that displays 2 images with 125 x 125 px in size' );
  804. $this->WP_Widget( 'avia_partner_widget', THEMENAME.' Advertising Area', $widget_ops );
  805. }
  806.  
  807. function widget($args, $instance)
  808. {
  809. extract($args, EXTR_SKIP);
  810. echo $before_widget;
  811.  
  812. global $kriesiaddwidget, $firsttitle;
  813. $kriesiaddwidget ++;
  814.  
  815. $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
  816. $image_url = empty($instance['image_url']) ? '<span class="avia_parnter_empty"><span>'.__('Advertise here','avia_framework').'</span></span>' : '<img class="rounded" src="'.$instance['image_url'].'" title="" alt=""/>';
  817. $ref_url = empty($instance['ref_url']) ? '#' : apply_filters('widget_comments_title', $instance['ref_url']);
  818. $image_url2 = empty($instance['image_url2']) ? '<span class="avia_parnter_empty"><span>'.__('Advertise here','avia_framework').'</span></span>' : '<img class="rounded" src="'.$instance['image_url2'].'" title="" alt=""/>';
  819. $ref_url2 = empty($instance['ref_url2']) ? '#' : apply_filters('widget_comments_title', $instance['ref_url2']);
  820. $image_url3 = empty($instance['image_url3']) ? '<span class="avia_parnter_empty"><span>'.__('Advertise here','avia_framework').'</span></span>' : '<img class="rounded" src="'.$instance['image_url3'].'" title="" alt=""/>';
  821. $ref_url3 = empty($instance['ref_url3']) ? '#' : apply_filters('widget_comments_title', $instance['ref_url3']);
  822. $image_url4 = empty($instance['image_url4']) ? '<span class="avia_parnter_empty"><span>'.__('Advertise here','avia_framework').'</span></span>' : '<img class="rounded" src="'.$instance['image_url4'].'" title="" alt=""/>';
  823. $ref_url4 = empty($instance['ref_url4']) ? '#' : apply_filters('widget_comments_title', $instance['ref_url4']);
  824.  
  825. if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
  826. echo '<a target="_blank" href="'.$ref_url.'" class="preloading_background avia_partner1 link_list_item'.$kriesiaddwidget.' '.$firsttitle.'" >'.$image_url.'</a>';
  827. if($this->add_cont == 3) echo '<a target="_blank" href="'.$ref_url2.'" class="preloading_background avia_partner2 link_list_item'.$kriesiaddwidget.' '.$firsttitle.'" >'.$image_url2.'</a>';
  828. echo '<a target="_blank" href="'.$ref_url3.'" class="preloading_background avia_partner2 link_list_item'.$kriesiaddwidget.' '.$firsttitle.'" >'.$image_url3.'</a>';
  829. echo $after_widget;
  830.  
  831. if($title == '')
  832. {
  833. $firsttitle = 'no_top_margin';
  834. }
  835.  
  836. }
  837.  
  838.  
  839. function update($new_instance, $old_instance) {
  840. //save the widget
  841. $instance = $old_instance;
  842. foreach($new_instance as $key=>$value)
  843. {
  844. $instance[$key] = strip_tags($new_instance[$key]);
  845. }
  846. return $instance;
  847. }
  848.  
  849.  
  850.  
  851. function form($instance)
  852. {
  853. $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'image_url' => '', 'ref_url' => '', 'image_url2' => '', 'ref_url2' => '', 'image_url3' => '', 'ref_url3' => '' ) );
  854. $title = strip_tags($instance['title']);
  855. $image_url = strip_tags($instance['image_url']);
  856. $ref_url = strip_tags($instance['ref_url']);
  857. $image_url2 = strip_tags($instance['image_url2']);
  858. $ref_url2 = strip_tags($instance['ref_url2']);
  859. $image_url3 = strip_tags($instance['image_url3']);
  860. $ref_url3 = strip_tags($instance['ref_url3']);
  861. ?>
  862. <p><label for="<?php echo $this->get_field_id('title'); ?>">Title:
  863. <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
  864.  
  865. <p><label for="<?php echo $this->get_field_id('image_url'); ?>">Image URL: <?php if($this->add_cont == 2) echo "(125px * 125px):"; ?>
  866. <input class="widefat" id="<?php echo $this->get_field_id('image_url'); ?>" name="<?php echo $this->get_field_name('image_url'); ?>" type="text" value="<?php echo esc_attr($image_url); ?>" /></label></p>
  867.  
  868. <p><label for="<?php echo $this->get_field_id('ref_url'); ?>">Referal URL:
  869. <input class="widefat" id="<?php echo $this->get_field_id('ref_url'); ?>" name="<?php echo $this->get_field_name('ref_url'); ?>" type="text" value="<?php echo esc_attr($ref_url); ?>" /></label></p>
  870.  
  871. <?php if($this->add_cont == 3)
  872. { ?>
  873.  
  874. <p><label for="<?php echo $this->get_field_id('image_url2'); ?>">Image URL 2: (125px * 125px):
  875. <input class="widefat" id="<?php echo $this->get_field_id('image_url2'); ?>" name="<?php echo $this->get_field_name('image_url2'); ?>" type="text" value="<?php echo esc_attr($image_url2); ?>" /></label></p>
  876.  
  877. <p><label for="<?php echo $this->get_field_id('ref_url2'); ?>">Referal URL 2:
  878. <input class="widefat" id="<?php echo $this->get_field_id('ref_url2'); ?>" name="<?php echo $this->get_field_name('ref_url2'); ?>" type="text" value="<?php echo esc_attr($ref_url2); ?>" /></label></p>
  879.  
  880. <p><label for="<?php echo $this->get_field_id('image_url3'); ?>">Image URL 3: (125px * 125px):
  881. <input class="widefat" id="<?php echo $this->get_field_id('image_url3'); ?>" name="<?php echo $this->get_field_name('image_url3'); ?>" type="text" value="<?php echo esc_attr($image_url3); ?>" /></label></p>
  882.  
  883. <p><label for="<?php echo $this->get_field_id('ref_url2'); ?>">Referal URL 3:
  884. <input class="widefat" id="<?php echo $this->get_field_id('ref_url3'); ?>" name="<?php echo $this->get_field_name('ref_url3'); ?>" type="text" value="<?php echo esc_attr($ref_url3); ?>" /></label></p>
  885.  
  886. <?php }?>
  887.  
  888. <?php
  889. }
  890. }
  891. }
  892.  
  893.  
  894.  
  895. if (!class_exists('avia_one_partner_widget'))
  896. {
  897. //one image
  898. class avia_one_partner_widget extends avia_partner_widget
  899. {
  900. function avia_one_partner_widget()
  901. {
  902.  
  903. $this->add_cont = 1;
  904.  
  905. $widget_ops = array('classname' => 'avia_one_partner_widget', 'description' => 'An advertising widget that displays 1 big image' );
  906.  
  907. $this->WP_Widget( 'avia_one_partner_widget', THEMENAME.' Big Advertising Area', $widget_ops );
  908. }
  909. }
  910. }
  911.  
  912.  
  913.  
  914. /**
  915. * AVIA COMBO WIDGET
  916. *
  917. * Widget that retrieves, stores and displays the number of twitter and rss followers
  918. *
  919. * @package AviaFramework
  920. * @todo replace the widget system with a dynamic one, based on config files for easier widget creation
  921. */
  922.  
  923. if (!class_exists('avia_combo_widget'))
  924. {
  925. class avia_combo_widget extends WP_Widget {
  926.  
  927. function avia_combo_widget() {
  928. //Constructor
  929. $widget_ops = array('classname' => 'avia_combo_widget', 'description' => 'A widget that displays your popular posts, recent posts, recent comments and a tagcloud' );
  930. $this->WP_Widget( 'avia_combo_widget', THEMENAME.' Combo Widget', $widget_ops );
  931. }
  932.  
  933. function widget($args, $instance)
  934. {
  935. // prints the widget
  936.  
  937. extract($args, EXTR_SKIP);
  938. $posts = empty($instance['count']) ? 4 : $instance['count'];
  939.  
  940. echo $before_widget;
  941. echo "<div class='tabcontainer border_tabs top_tab tab_initial_open tab_initial_open__1'>";
  942.  
  943. echo '<div class="tab first_tab active_tab widget_tab_popular"><span>'.__('Popular', 'avia_framework').'</span></div>';
  944. echo "<div class='tab_content active_tab_content'>";
  945. avia_get_post_list('cat=&orderby=comment_count&posts_per_page='.$posts);
  946. echo "</div>";
  947.  
  948. echo '<div class="tab widget_tab_recent"><span>'.__('Recent', 'avia_framework').'</span></div>';
  949. echo "<div class='tab_content'>";
  950. avia_get_post_list('showposts='. $posts .'&orderby=post_date&order=desc');
  951. echo "</div>";
  952.  
  953. echo '<div class="tab widget_tab_comments"><span>'.__('Comments', 'avia_framework').'</span></div>';
  954. echo "<div class='tab_content'>";
  955. avia_get_comment_list( array('number' => $posts, 'status' => 'approve', 'order' => 'DESC') );
  956. echo "</div>";
  957.  
  958. echo '<div class="tab last_tab widget_tab_tags"><span>'.__('Tags', 'avia_framework').'</span></div>';
  959. echo "<div class='tab_content tagcloud'>";
  960. wp_tag_cloud('smallest=12&largest=12&unit=px');
  961. echo "</div>";
  962.  
  963. echo "</div>";
  964. echo $after_widget;
  965. }
  966.  
  967.  
  968. function update($new_instance, $old_instance)
  969. {
  970. $instance = $old_instance;
  971. foreach($new_instance as $key=>$value)
  972. {
  973. $instance[$key] = strip_tags($new_instance[$key]);
  974. }
  975.  
  976. return $instance;
  977. }
  978.  
  979. function form($instance) {
  980. //widgetform in backend
  981.  
  982. $instance = wp_parse_args( (array) $instance, array('count' => 4) );
  983. if(!is_numeric($instance['count'])) $instance['count'] = 4;
  984.  
  985. ?>
  986. <p>
  987. <label for="<?php echo $this->get_field_id('count'); ?>">Number of posts you want to display:
  988. <input class="widefat" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" type="text" value="<?php echo esc_attr($instance['count']); ?>" /></label></p>
  989.  
  990.  
  991. <?php
  992. }
  993. }
  994. }
  995.  
  996. /*-----------------------------------------------------------------------------------
  997. get posts posts
  998. -----------------------------------------------------------------------------------*/
  999. if (!function_exists('avia_get_post_list'))
  1000. {
  1001. function avia_get_post_list( $avia_new_query , $excerpt = false)
  1002. {
  1003. global $avia_config;
  1004. $image_size = isset($avia_config['widget_image_size']) ? $avia_config['widget_image_size'] : 'widget';
  1005. $additional_loop = new WP_Query($avia_new_query);
  1006.  
  1007. if($additional_loop->have_posts()) :
  1008. echo '<ul class="news-wrap">';
  1009. while ($additional_loop->have_posts()) : $additional_loop->the_post();
  1010.  
  1011. $format = "";
  1012. if(get_post_type() != 'post') $format = get_post_type();
  1013. if(empty($format)) $format = get_post_format();
  1014. if(empty($format)) $format = 'standard';
  1015.  
  1016. echo '<li class="news-content post-format-'.$format.'">';
  1017.  
  1018. //check for preview images:
  1019. $image = "";
  1020.  
  1021. if(!current_theme_supports('force-post-thumbnails-in-widget'))
  1022. {
  1023. $slides = avia_post_meta(get_the_ID(), 'slideshow');
  1024.  
  1025. if( $slides != "" && !empty( $slides[0]['slideshow_image'] ) )
  1026. {
  1027. $image = avia_image_by_id($slides[0]['slideshow_image'], 'widget', 'image');
  1028. }
  1029. }
  1030.  
  1031. if(!$image && current_theme_supports( 'post-thumbnails' ))
  1032. {
  1033. $image = get_the_post_thumbnail( get_the_ID(), $image_size );
  1034. }
  1035.  
  1036. $time_format = apply_filters( 'avia_widget_time', get_option('date_format')." - ".get_option('time_format'), 'avia_get_post_list' );
  1037.  
  1038. $nothumb = (!$image) ? 'no-news-thumb' : '';
  1039.  
  1040. echo "<a class='news-link' title='".get_the_title()."' href='".get_permalink()."'>";
  1041. echo "<span class='news-thumb $nothumb'>";
  1042. echo $image;
  1043. echo "</span>";
  1044. echo "<strong class='news-headline'>".avia_backend_truncate(get_the_title(), 55," ");
  1045. echo "<span class='news-time'>".get_the_time($time_format)."</span>";
  1046. echo "</strong>";
  1047. echo "</a>";
  1048.  
  1049. if('display title and excerpt' == $excerpt)
  1050. {
  1051. echo "<div class='news-excerpt'>";
  1052. the_excerpt();
  1053. echo "</div>";
  1054. }
  1055.  
  1056. echo '</li>';
  1057.  
  1058.  
  1059. endwhile;
  1060. echo "</ul>";
  1061. wp_reset_postdata();
  1062. endif;
  1063. }
  1064. }
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070. if (!function_exists('avia_get_comment_list'))
  1071. {
  1072.  
  1073. function avia_get_comment_list($avia_new_query)
  1074. {
  1075. $time_format = apply_filters( 'avia_widget_time', get_option('date_format')." - ".get_option('time_format'), 'avia_get_comment_list' );
  1076.  
  1077. global $avia_config;
  1078.  
  1079. $comments = get_comments($avia_new_query);
  1080.  
  1081. if(!empty($comments)) :
  1082. echo '<ul class="news-wrap">';
  1083. foreach($comments as $comment)
  1084. {
  1085. $gravatar_alt = esc_html($comment->comment_author);
  1086. echo '<li class="news-content">';
  1087. echo "<a class='news-link' title='".get_the_title($comment->comment_post_ID)."' href='".get_comment_link($comment)."'>";
  1088. echo "<span class='news-thumb'>";
  1089. echo get_avatar($comment,'48', '', $gravatar_alt);
  1090. echo "</span>";
  1091. echo "<strong class='news-headline'>".avia_backend_truncate($comment->comment_content, 55," ");
  1092.  
  1093. if($time_format)
  1094. {
  1095. echo "<span class='news-time'>".get_the_time($time_format, $comment->comment_post_ID)." ".__('by','avia_framework')." ".$comment->comment_author."</span>";
  1096. }
  1097. echo "</strong>";
  1098. echo "</a>";
  1099. echo '</li>';
  1100. }
  1101. echo "</ul>";
  1102. wp_reset_postdata();
  1103. endif;
  1104. }
  1105. }
  1106.  
  1107.  
  1108.  
  1109. /*
  1110. Google Maps Widget
  1111.  
  1112. Copyright 2009 Clark Nikdel Powell (email : [email protected])
  1113.  
  1114. This program is free software; you can redistribute it and/or modify
  1115. it under the terms of the GNU General Public License as published by
  1116. the Free Software Foundation; either version 2 of the License, or
  1117. (at your option) any later version.
  1118.  
  1119. This program is distributed in the hope that it will be useful,
  1120. but WITHOUT ANY WARRANTY; without even the implied warranty of
  1121. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1122. GNU General Public License for more details.
  1123.  
  1124. You should have received a copy of the GNU General Public License
  1125. along with this program; if not, write to the Free Software
  1126. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  1127. */
  1128.  
  1129. if (!class_exists('avia_google_maps'))
  1130. {
  1131. class avia_google_maps extends WP_Widget {
  1132.  
  1133. // constructor
  1134. function avia_google_maps() {
  1135. $widget_ops = array('classname' => 'avia_google_maps', 'description' => __( 'Add a google map to your blog or site') );
  1136. $this->WP_Widget('avia_google_maps', THEMENAME.' Google Maps Widget', $widget_ops);
  1137.  
  1138. add_action( 'admin_enqueue_scripts', array(&$this,'helper_print_google_maps_scripts') );
  1139. }
  1140.  
  1141. // output the content of the widget
  1142. function widget($args, $instance) {
  1143. extract( $args );
  1144.  
  1145. $title = empty($instance['title']) ? '' : apply_filters('widget_title', esc_attr($instance['title']));
  1146.  
  1147. print $before_widget;
  1148. if (!empty($instance['title'])) { print $before_title.$title.$after_title; }
  1149. print avia_printmap($instance['lat'], $instance['lng'], $instance['zoom'], $instance['type'], $instance['content'], $instance['directionsto'], $instance['width'], $instance['height'], $instance['icon']);
  1150. print $after_widget;
  1151. }
  1152.  
  1153. // process widget options to be saved
  1154. function update($new_instance, $old_instance) {
  1155. print_r($old_instance);
  1156. print_r($new_instance);
  1157. return $new_instance;
  1158. }
  1159.  
  1160. // output the options form on admin
  1161. function form($instance) {
  1162. global $wpdb;
  1163. $title = empty($instance['title']) ? '' : esc_attr($instance['title']);
  1164. $lat = empty($instance['lat']) ? '' : esc_attr($instance['lat']);
  1165. $lng = empty($instance['lng']) ? '' : esc_attr($instance['lng']);
  1166. $zoom = empty($instance['zoom']) ? '15' : esc_attr($instance['zoom']);
  1167. $type = empty($instance['type']) ? 'ROADMAP' : esc_attr($instance['type']);
  1168. $directionsto = empty($instance['directionsto']) ? '' : esc_attr($instance['directionsto']);
  1169. $content = empty($instance['content']) ? '' : esc_attr($instance['content']);
  1170. $width = empty($instance['width']) ? '' : esc_attr($instance['width']);
  1171. $height = empty($instance['height']) ? '' : esc_attr($instance['height']);
  1172. $street_address = empty($instance['street-address']) ? '' : esc_attr($instance['street-address']);
  1173. $city = empty($instance['city']) ? '' : esc_attr($instance['city']);
  1174. $state = empty($instance['state']) ? '' : esc_attr($instance['state']);
  1175. $postcode = empty($instance['postcode']) ? '' : esc_attr($instance['postcode']);
  1176. $country = empty($instance['country']) ? '' : esc_attr($instance['country']);
  1177. $icon = empty($instance['icon']) ? '' : esc_attr($instance['icon']);
  1178. ?>
  1179. <p>
  1180. <label for="<?php print $this->get_field_id('title'); ?>"><?php _e('Title:','avia_framework'); ?></label>
  1181. <input class="widefat" id="<?php print $this->get_field_id('title'); ?>" name="<?php print $this->get_field_name('title'); ?>" type="text" value="<?php print $title; ?>" />
  1182. </p>
  1183. <p>
  1184. Enter the latitude and longitude of the location you want to display. Need help finding the latitude and longitude? <a href="#" class="avia-coordinates-help-link button">Click here to enter an address.</a>
  1185. </p>
  1186. <div class="avia-find-coordinates-wrapper">
  1187. <p>
  1188. <label for="<?php print $this->get_field_id('street-address'); ?>"><?php _e('Street Address:','avia_framework'); ?></label>
  1189. <input class='widefat avia-map-street-address' id="<?php print $this->get_field_id('street-address'); ?>" name="<?php print $this->get_field_name('street-address'); ?>" type="text" value="<?php print $street_address; ?>" />
  1190. </p>
  1191. <p>
  1192. <label for="<?php print $this->get_field_id('city'); ?>"><?php _e('City:','avia_framework'); ?></label>
  1193. <input class='widefat avia-map-city' id="<?php print $this->get_field_id('city'); ?>" name="<?php print $this->get_field_name('city'); ?>" type="text" value="<?php print $city; ?>" />
  1194. </p>
  1195. <p>
  1196. <label for="<?php print $this->get_field_id('state'); ?>"><?php _e('State:','avia_framework'); ?></label>
  1197. <input class='widefat avia-map-state' id="<?php print $this->get_field_id('state'); ?>" name="<?php print $this->get_field_name('state'); ?>" type="text" value="<?php print $state; ?>" />
  1198. </p>
  1199. <p>
  1200. <label for="<?php print $this->get_field_id('postcode'); ?>"><?php _e('Postcode:','avia_framework'); ?></label>
  1201. <input class='widefat avia-map-postcode' id="<?php print $this->get_field_id('postcode'); ?>" name="<?php print $this->get_field_name('postcode'); ?>" type="text" value="<?php print $postcode; ?>" />
  1202. </p>
  1203. <p>
  1204. <label for="<?php print $this->get_field_id('country'); ?>"><?php _e('Country:','avia_framework'); ?></label>
  1205. <input class='widefat avia-map-country' id="<?php print $this->get_field_id('country'); ?>" name="<?php print $this->get_field_name('country'); ?>" type="text" value="<?php print $country; ?>" />
  1206. </p>
  1207. <p>
  1208. <a class="button avia-populate-coordinates"><?php _e('Fetch coordinates!','avia_framework'); ?></a>
  1209. <div class='avia-loading-coordinates'><?php _e('Fetching the coordinates. Please wait...','avia_framework'); ?></div>
  1210. </p>
  1211. </div>
  1212. <div class="avia-coordinates-wrapper">
  1213. <p>
  1214. <label for="<?php print $this->get_field_id('lat'); ?>"><?php _e('Latitude:','avia_framework'); ?></label>
  1215. <input class='widefat avia-map-lat' id="<?php print $this->get_field_id('lat'); ?>" name="<?php print $this->get_field_name('lat'); ?>" type="text" value="<?php print $lat; ?>" />
  1216. </p>
  1217. <p>
  1218. <label for="<?php print $this->get_field_id('lng'); ?>"><?php _e('Longitude:','avia_framework'); ?></label>
  1219. <input class='widefat avia-map-lng' id="<?php print $this->get_field_id('lng'); ?>" name="<?php print $this->get_field_name('lng'); ?>" type="text" value="<?php print $lng; ?>" />
  1220. </p>
  1221. </div>
  1222. <p>
  1223. <label for="<?php print $this->get_field_id('zoom'); ?>"><?php echo __('Zoom Level:','avia_framework').' <small>'.__('(1-19)','avia_framework').'</small>'; ?></label>
  1224. <select class="widefat" id="<?php echo $this->get_field_id('zoom'); ?>" name="<?php echo $this->get_field_name('zoom'); ?>">
  1225. <?php
  1226. $list = "";
  1227. $answers = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19);
  1228. foreach ($answers as $answer)
  1229. {
  1230. $selected = "";
  1231. if($answer == $zoom) $selected = 'selected="selected"';
  1232.  
  1233. $list .= "<option $selected value='$answer'>$answer</option>";
  1234. }
  1235. $list .= "</select>";
  1236. echo $list;
  1237. ?>
  1238.  
  1239.  
  1240. </p>
  1241.  
  1242. <p>
  1243. <label for="<?php print $this->get_field_id('type'); ?>"><?php _e('Map Type:','avia_framework'); ?></label>
  1244.  
  1245. <select class="widefat" id="<?php echo $this->get_field_id('type'); ?>" name="<?php echo $this->get_field_name('type'); ?>">
  1246. <?php
  1247. $list = "";
  1248. $answers = array('ROADMAP', 'SATELLITE', 'HYBRID', 'TERRAIN');
  1249. foreach ($answers as $answer)
  1250. {
  1251. $selected = "";
  1252. if($answer == $type) $selected = 'selected="selected"';
  1253.  
  1254. $list .= "<option $selected value='$answer'>$answer</option>";
  1255. }
  1256. $list .= "</select>";
  1257. echo $list;
  1258. ?>
  1259.  
  1260. </p>
  1261. <p>
  1262. <label for="<?php print $this->get_field_id('directionsto'); ?>"><?php _e('Display a Route by entering a address here. (If address is added Zoom will be ignored)','avia_framework'); ?></label>
  1263. <input class="widefat" id="<?php print $this->get_field_id('directionsto'); ?>" name="<?php print $this->get_field_name('directionsto'); ?>" type="text" value="<?php print $directionsto; ?>" />
  1264. </p>
  1265. <p>
  1266. <label for="<?php print $this->get_field_id('content'); ?>"><?php _e('Info Bubble Content:','avia_framework'); ?></label>
  1267. <textarea rows="7" class="widefat" id="<?php print $this->get_field_id('content'); ?>" name="<?php print $this->get_field_name('content'); ?>"><?php print $content; ?></textarea>
  1268. </p>
  1269. <p>
  1270. <label for="<?php print $this->get_field_id('icon'); ?>"><?php _e('Custom Marker Image URL:','avia_framework'); ?></label>
  1271. <input class="widefat" class="avia-marker-icon" id="<?php print $this->get_field_id('icon'); ?>" name="<?php print $this->get_field_name('icon'); ?>" type="text" value="<?php print $icon; ?>" />
  1272. </p>
  1273. <p>
  1274. <label for="<?php print $this->get_field_id('width'); ?>"><?php _e('Enter the width in px or % (100% width will be used if you leave this field empty)','avia_framework'); ?></label>
  1275. <input class="widefat" id="<?php print $this->get_field_id('width'); ?>" name="<?php print $this->get_field_name('width'); ?>" type="text" value="<?php print $width; ?>" />
  1276. </p>
  1277. <p>
  1278. <label for="<?php print $this->get_field_id('height'); ?>"><?php _e('Enter the height in px or %','avia_framework'); ?></label>
  1279. <input class="widefat" id="<?php print $this->get_field_id('height'); ?>" name="<?php print $this->get_field_name('height'); ?>" type="text" value="<?php print $height; ?>" />
  1280. </p>
  1281. <?php
  1282. }
  1283.  
  1284. function helper_print_google_maps_scripts()
  1285. {
  1286. $prefix = is_ssl() ? "https" : "http";
  1287. wp_register_script( 'avia-google-maps-api', $prefix.'://maps.google.com/maps/api/js?sensor=false', array('jquery'), '3', true);
  1288.  
  1289. $load_google_map_api = apply_filters('avf_load_google_map_api', true, 'avia_google_map_widget');
  1290.  
  1291. if($load_google_map_api) wp_enqueue_script( 'avia-google-maps-api' );
  1292.  
  1293. $is_widget_edit_page = in_array(basename($_SERVER['PHP_SELF']), array('widgets.php'));
  1294. if($is_widget_edit_page)
  1295. {
  1296. wp_register_script( 'avia-google-maps-widget', AVIA_JS_URL.'conditional_load/avia_google_maps_widget.js', array( 'jquery','media-upload','media-views' ), '1.0.0', true);
  1297. wp_enqueue_script( 'avia-google-maps-widget' );
  1298.  
  1299. $args = array(
  1300. 'toomanyrequests' => __("Too many requests at once, please refresh the page to complete geocoding",'avia_framework'),
  1301. 'latitude' => __("Latitude and longitude for",'avia_framework'),
  1302. 'notfound' => __("couldn't be found by Google, please add them manually",'avia_framework'),
  1303. 'insertaddress' => __("Please insert a valid address in the fields above",'avia_framework')
  1304. );
  1305.  
  1306. if($load_google_map_api) wp_localize_script( 'avia-google-maps-api', 'AviaMapTranslation', $args );
  1307. }
  1308. }
  1309.  
  1310.  
  1311. } // SGMwidget widget
  1312. }
  1313.  
  1314.  
  1315. if(!function_exists('avia_printmap'))
  1316. {
  1317. function avia_printmap($lat, $lng, $zoom, $type, $content, $directionsto, $width, $height, $icon) {
  1318.  
  1319. global $avia_config;
  1320.  
  1321. $SGMoptions = get_option('SGMoptions'); // get options defined in admin page
  1322.  
  1323. if (!$lat) {$lat = '0';}
  1324. if (!$lng) {$lng = '0';}
  1325. if (!$zoom) {$zoom = $SGMoptions['zoom'];} // 1-19
  1326. if (!$type) {$type = $SGMoptions['type'];} // ROADMAP, SATELLITE, HYBRID, TERRAIN
  1327. if (!$content) {$content = $SGMoptions['content'];}
  1328. $output = "";
  1329. $unique = uniqid();
  1330. $content = str_replace('&lt;', '<', $content);
  1331. $content = str_replace('&gt;', '>', $content);
  1332. $content = mysql_real_escape_string($content);
  1333. $prefix = isset($_SERVER['HTTPS'] ) ? "https" : "http";
  1334. $width = !empty($width) ? 'width:'.$width.';' : 'width:100%;';
  1335. $height = !empty($height) ? 'height:'.$height.';' : '';
  1336. $icon = !empty($icon) ? $icon : '';
  1337.  
  1338.  
  1339. $directionsForm = "";
  1340. if(empty($avia_config['g_maps_widget_active']))
  1341. {
  1342. $avia_config['g_maps_widget_active'] = 0;
  1343. }
  1344.  
  1345. if(apply_filters('avia_google_maps_widget_load_api', true, $avia_config['g_maps_widget_active']))
  1346. {
  1347. wp_register_script( 'avia-google-maps-api', $prefix.'://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array('jquery'), '1', false);
  1348. wp_enqueue_script( 'avia-google-maps-api' );
  1349. }
  1350.  
  1351. $avia_config['g_maps_widget_active'] ++;
  1352.  
  1353. $output .= "<script type='text/javascript'>
  1354. function makeMap_".$avia_config['g_maps_widget_active']."() {\n";
  1355.  
  1356. $avia_maps_config = "
  1357. var directionsDisplay;
  1358. directionsDisplay = new google.maps.DirectionsRenderer;
  1359. var directionsService = new google.maps.DirectionsService;
  1360. var map;
  1361. var latlng = new google.maps.LatLng(".$lat.", ".$lng.");
  1362. var directionsto = '".$directionsto."';
  1363. var myOptions = {
  1364. zoom:".$zoom.",
  1365. mapTypeControl:true,
  1366. mapTypeId:google.maps.MapTypeId.".$type.",
  1367. mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.DROPDOWN_MENU},
  1368. navigationControl:true,
  1369. navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL},
  1370. center:latlng
  1371. };
  1372. var map = new google.maps.Map(document.getElementById('avia_google_maps_$unique'), myOptions);
  1373.  
  1374. if(directionsto.length > 5)
  1375. {
  1376. directionsDisplay.setMap(map);
  1377. var request = {
  1378. origin:directionsto,
  1379. destination:latlng,
  1380. travelMode:google.maps.DirectionsTravelMode.DRIVING
  1381. };
  1382. directionsService.route(request, function(response, status) {
  1383. if(status == google.maps.DirectionsStatus.OK) {
  1384. directionsDisplay.setDirections(response)
  1385. }
  1386. })
  1387. }
  1388. else
  1389. {
  1390. var contentString = '".$content."';
  1391. var infowindow = new google.maps.InfoWindow({
  1392. content: contentString
  1393. });
  1394. var marker = new google.maps.Marker({
  1395. position: latlng,
  1396. map: map,
  1397. icon: '".$icon."',
  1398. title: ''
  1399. });
  1400.  
  1401. google.maps.event.addListener(marker, 'click', function() {
  1402. infowindow.open(map,marker);
  1403. });
  1404. }";
  1405.  
  1406. $output .= apply_filters('avia_google_maps_widget_config', $avia_maps_config, $lat, $lng, $directionsto, $zoom, $type, $unique, $content, $icon);
  1407.  
  1408. $output .= "\n}\n\n
  1409. jQuery(document).ready(function() {
  1410. makeMap_".$avia_config['g_maps_widget_active']."()
  1411. });
  1412. </script>
  1413. <div id='avia_google_maps_$unique' style='$height $width' class='avia_google_maps_container'></div>";
  1414.  
  1415. return $output;
  1416. }
  1417. }
Advertisement
Add Comment
Please, Sign In to add comment