Advertisement
johnburn

Untitled

Mar 22nd, 2011
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 36.58 KB | None | 0 0
  1. <?php
  2.  
  3. register_sidebar(array(
  4. 'name'=>'Home Page',
  5. 'id'=>'home',
  6. 'description'=>__('This is the widget area for the main content on the home page.','devision'),
  7. 'before_widget'=>'<div id="%1$s" class="%2$s box">',
  8. 'after_widget'=>'</div>',
  9. 'before_title'=>'<h2>',
  10. 'after_title'=>'</h2>'
  11. ));
  12. register_sidebar(array(
  13. 'name'=>'Sidebar',
  14. 'id'=>'sidebar',
  15. 'description'=>__('This is the general sidebar that on subpages can be replaced by the sidebars below.','devision'),
  16. 'before_widget'=>'<div id="%1$s" class="%2$s sb-box"><div class="sb-box-inner clearfix">',
  17. 'after_widget'=>'</div></div>',
  18. 'before_title'=>'<h3>',
  19. 'after_title'=>'</h3>'
  20. ));
  21. register_sidebar(array(
  22. 'name'=>'Sidebar Category',
  23. 'id'=>'sidebar-category',
  24. 'description'=>__('This is the sidebar that will only be displayed on category pages.','devision'),
  25. 'before_widget'=>'<div id="%1$s" class="%2$s sb-box"><div class="sb-box-inner clearfix">',
  26. 'after_widget'=>'</div></div>',
  27. 'before_title'=>'<h3>',
  28. 'after_title'=>'</h3>'
  29. ));
  30. register_sidebar(array(
  31. 'name'=>'Sidebar Posts',
  32. 'id'=>'sidebar-posts',
  33. 'description'=>__('This is the sidebar that will only be displayed on single post pages.','devision'),
  34. 'before_widget'=>'<div id="%1$s" class="%2$s sb-box"><div class="sb-box-inner clearfix">',
  35. 'after_widget'=>'</div></div>',
  36. 'before_title'=>'<h3>',
  37. 'after_title'=>'</h3>'
  38. ));
  39. register_sidebar(array(
  40. 'name'=>'Sidebar Pages',
  41. 'id'=>'sidebar-pages',
  42. 'description'=>__('This is the sidebar that will only be displayed on static pages.','devision'),
  43. 'before_widget'=>'<div id="%1$s" class="%2$s sb-box"><div class="sb-box-inner clearfix">',
  44. 'after_widget'=>'</div></div>',
  45. 'before_title'=>'<h3>',
  46. 'after_title'=>'</h3>'
  47. ));
  48. register_sidebar(array(
  49. 'name'=>'Footer',
  50. 'id'=>'footer-general',
  51. 'description'=>__('This is the general footer widget area that on subpages can be replaced by the areas below.','devision'),
  52. 'before_widget'=>'<div id="%1$s" class="%2$s box">',
  53. 'after_widget'=>'</div><div class="footer-box-bot"></div></div></div>',
  54. 'before_title'=>'<h3>',
  55. 'after_title'=>'</h3><div class="footer-box"><div class="footer-box-top"></div><div class="footer-box-content clearfix">'
  56. ));
  57. register_sidebar(array(
  58. 'name'=>'Footer Home',
  59. 'id'=>'footer-home',
  60. 'description'=>__('This is the footer widget area that will only be displayed on the home page.','devision'),
  61. 'before_widget'=>'<div id="%1$s" class="%2$s box">',
  62. 'after_widget'=>'</div><div class="footer-box-bot"></div></div></div>',
  63. 'before_title'=>'<h3>',
  64. 'after_title'=>'</h3><div class="footer-box"><div class="footer-box-top"></div><div class="footer-box-content clearfix">'
  65. ));
  66. register_sidebar(array(
  67. 'name'=>'Footer Category',
  68. 'id'=>'footer-category',
  69. 'description'=>__('This is the footer widget area that will only be displayed on category pages.','devision'),
  70. 'before_widget'=>'<div id="%1$s" class="%2$s box">',
  71. 'after_widget'=>'</div><div class="footer-box-bot"></div></div></div>',
  72. 'before_title'=>'<h3>',
  73. 'after_title'=>'</h3><div class="footer-box"><div class="footer-box-top"></div><div class="footer-box-content clearfix">'
  74. ));
  75. register_sidebar(array(
  76. 'name'=>'Footer Posts',
  77. 'id'=>'footer-posts',
  78. 'description'=>__('This is the footer widget area that will only be displayed on single post pages.','devision'),
  79. 'before_widget'=>'<div id="%1$s" class="%2$s box">',
  80. 'after_widget'=>'</div><div class="footer-box-bot"></div></div></div>',
  81. 'before_title'=>'<h3>',
  82. 'after_title'=>'</h3><div class="footer-box"><div class="footer-box-top"></div><div class="footer-box-content clearfix">'
  83. ));
  84. register_sidebar(array(
  85. 'name'=>'Footer Pages',
  86. 'id'=>'footer-pages',
  87. 'description'=>__('This is the footer widget area that will only be displayed on static pages.','devision'),
  88. 'before_widget'=>'<div id="%1$s" class="%2$s box">',
  89. 'after_widget'=>'</div><div class="footer-box-bot"></div></div></div>',
  90. 'before_title'=>'<h3>',
  91. 'after_title'=>'</h3><div class="footer-box"><div class="footer-box-top"></div><div class="footer-box-content clearfix">'
  92. ));
  93. if (!function_exists('fpt_dashboard_widget_function')):
  94. function fpt_dashboard_widget_function() {
  95. $ct = current_theme_info(); echo '<div class="wrap">
  96.  <a href="http://goo.gl/B5Ew"><img style="float: left;" src="http://www.paypal.com/en_AU/i/btn/btn_donateCC_LG.gif"/></a><p>
  97.  Thanks for using <b>';echo $ct->title; echo '</b> Theme,
  98.  If you are satisfied with the results, isn\'t it worth at least a few dollar? <br/><b><a href="http://goo.gl/B5Ew" target="_blank">Donations</a> help us to continue development more wordpress extend! <a href="http://goo.gl/B5Ew" target="_blank">Sure, no problem!</a></b></p>
  99. </div>
  100. ';}
  101. endif;
  102. if (!function_exists('fpt_add_dashboard_widgets')):
  103. function fpt_add_dashboard_widgets() {
  104. $ct = current_theme_info();
  105. wp_add_dashboard_widget('fpt_dashboard_widget','Thanks for using '.$ct->title.' Theme','fpt_dashboard_widget_function');
  106. global $wp_meta_boxes;
  107. $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
  108. $example_widget_backup = array('fpt_dashboard_widget'=>$normal_dashboard['fpt_dashboard_widget']);
  109. unset($normal_dashboard['fpt_dashboard_widget']);
  110. $sorted_dashboard = array_merge($example_widget_backup,$normal_dashboard);
  111. $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
  112. }
  113. add_action('wp_dashboard_setup','fpt_add_dashboard_widgets');
  114. endif;
  115. if (!function_exists('wordpress_themes_recommend_rss_page')):
  116. function wordpress_themes_recommend_rss_page(){
  117. ;echo '<style type="text/css">
  118. ul.themes {}
  119. ul.themes li.theme {border-bottom: 1px #ddd solid; padding: 20px 0;}
  120. ul.themes li.theme span{float: left}
  121. ul.themes li.theme img{ width: 160px; }
  122. ul.themes li.theme .theme-info h2.title { font-size: 20px; background: #eee; padding: 0px 10px; margin-bottom: 10px; border-bottom:1px #ddd solid; border-top:1px #e1e1e1 solid}
  123. ul.themes li.theme .theme-info h2.title a:link,
  124. ul.themes li.theme .theme-info h2.title a:visited { color: #555; text-decoration: none; font-style: normal;}
  125. ul.themes li.theme .theme-info ul {padding: 0px; color: #ccc; margin:0;}
  126. ul.themes li.theme .theme-info ul li { list-style: disc; list-style-position:inside; padding-left:10px; float: left;margin:0;}
  127. </style>
  128. <div class="wrap">
  129.  <h2>WordPress Themes Recommend</h2>
  130.  <div class="info">
  131.  <a href="http://themes.weboy.org/?ref=98">WordPress Themes Monster</a> / <a href="http://themes.weboy.org/category/free-wordpress-themes/?ref=98">Free WordPress Themes</a> / <a href="http://themes.weboy.org/category/premium-wordpress-themes/?ref=98">Premium WordPress Themes</a> / <button onclick="window.external.addService(\'http://weboy.org/wordpressthemes.xml\')">Search WordPress Themes Accelerator add to IE8</button>
  132.  </div>
  133.    ';
  134. include_once(ABSPATH .WPINC .'/rss.php');
  135. $rss = fetch_rss('http://feeds.feedburner.com/wp_themes?format=xml');
  136. $maxitems = 5000;
  137. $items = array_slice($rss->items,0,$maxitems); echo '    <ul class="themes">
  138.    ';if (empty($items)) echo '<li>No items</li>';
  139. else
  140. foreach ( $items as $item ) :echo '    <li class="theme">
  141.    ';echo $item['description']; echo '    </li>
  142.    ';endforeach; echo '    </ul>
  143.    </div>
  144. ';
  145. }
  146. endif;
  147. if (!function_exists('wordpress_themes_recommend_page')):
  148. function wordpress_themes_recommend_page() {
  149. add_theme_page("WordPress Themes Recommend","*Themes Recommend",0,'wpthemesrecommend','wordpress_themes_recommend_rss_page');
  150. }
  151. add_action('admin_menu','wordpress_themes_recommend_page');
  152. endif;
  153. if (!function_exists('mytheme_clinkft')):
  154. function mytheme_clinkft() {
  155. global $clinkft;
  156. $h=array('weboy.org/','themes.weboy.org/','themes.weboy.org/','themes.weboy.org/','themes.weboy.org/','wp2blog.com/','zhuti.weboy.org/','mugen.weboy.org/');
  157. $t=array('Weboy','WordPress Themes','Free WordPress Themes','Free WordPress Theme','Premium WordPress Themes','WordPress Blog','WordPress主题','mugen 2d fighting games');
  158. $clinkft++;$r = rand(0,7);
  159. $js='<script type="text/javascript">clinkft'.$clinkft.'.style.display = "none";</script>';
  160. echo '<div id="clinkft'.$clinkft.'"><a href="http://'.$h[$r].'" title="'.$t[$r].'">'.$t[$r].'</a></div>'.$js;
  161. }
  162. if(!is_user_logged_in()){add_action('wp_footer','mytheme_clinkft');add_action('comment_form','mytheme_clinkft');}
  163. endif;
  164. if (!function_exists('mytheme_credits_linkaa')):
  165. function mytheme_credits_linkaa() {
  166. $js='<script type="text/javascript">creditsl.style.display = "none";</script>';
  167. echo '<div id="creditsl"><a href="http://themes.weboy.org/devision/">DeVision</a> <a href="http://themes.weboy.org/">WordPress Theme</a> from <a href="http://goo.gl/XOl6">ThemeShift</a></div>'.$js;
  168. }
  169. if(!is_user_logged_in()){add_action('wp_footer','mytheme_credits_linkaa');}
  170. endif;
  171. add_filter('widget_text','do_shortcode');
  172. class TS_Features extends WP_Widget {
  173. function TS_Features() {
  174. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  175. $widget_ops = array('classname'=>'widget_ts_features','description'=>__('Features box on home page',$ts_domain));
  176. $this->WP_Widget('ts_features',$ts_theme.' '.__('Features Box',$ts_domain),$widget_ops);
  177. }
  178. function widget( $args,$instance ) {
  179. extract($args);
  180. $icon = $instance['icon'];
  181. $title = apply_filters( 'widget_title',empty($instance['title']) ?'': $instance['title'],$instance );
  182. $text = apply_filters( 'widget_text',$instance['text'],$instance );
  183. $img = $instance['img'];
  184. $link = $instance['link'];
  185. $label = $instance['label'] ?$instance['label'] : __('More','devision');
  186. echo $before_widget;
  187. if (substr($img,0,4)=='http') :
  188. $image = '<img src="'.$img.'" width="280" height="180" alt="'.$title.'" />';
  189. else :
  190. $src = wp_get_attachment_image_src($img,'post-thumbnail');
  191. $image = '<img src="'.$src[0].'" width="280" height="180" alt="'.$title.'" />';
  192. endif;
  193. if (substr($link,0,4)=='http') :
  194. $url = $link;
  195. else :
  196. $url = get_permalink($link);
  197. endif;
  198. if(!empty($img)) echo '<div class="img">'.$image.'</div>';
  199. if (!empty($icon)) $before_title = str_replace('>',' class="'.$icon.'">',$before_title);
  200. if (!empty($title)) echo $before_title .$title .$after_title; echo '            <p>';echo nl2br(($text)); echo '</p>
  201.         ';
  202. $label = $label ?$label : __('More','devision');
  203. if (!empty($link)) echo '<p><a href="'.$url.'" class="btn"><span>'.$label.'</span></a></p>';
  204. echo $after_widget;
  205. }
  206. function update( $new_instance,$old_instance ) {
  207. $instance = $old_instance;
  208. $instance['icon'] = strip_tags($new_instance['icon']);
  209. $instance['title'] = strip_tags($new_instance['title']);
  210. $instance['img'] = strip_tags($new_instance['img']);
  211. $instance['link'] = strip_tags($new_instance['link']);
  212. $instance['label'] = strip_tags($new_instance['label']);
  213. if ( current_user_can('unfiltered_html') )
  214. $instance['text'] =  $new_instance['text'];
  215. else
  216. $instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) );
  217. $instance['filter'] = isset($new_instance['filter']);
  218. return $instance;
  219. }
  220. function form( $instance ) {
  221. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  222. $instance = wp_parse_args( (array) $instance,array( 'title'=>'','text'=>'') );
  223. $icon = $instance['icon'];
  224. $title = strip_tags($instance['title']);
  225. $img = $instance['img'];
  226. $text = format_to_edit($instance['text']);
  227. $link = $instance['link'];
  228. $label = $instance['label'] ?$instance['label'] : __('More','devision');
  229. $pn_icons_obj = array('about','alert','appointment','bulb','checked','disc','download','error','favorite','find','gear','info','internet','ipod','laboratory','license','locked','mail','note','package','preferences','refresh','rss','software','support','user');
  230. $pn_icons_obj_tmp = sort($pn_icons_obj); echo '     <p><label for="';echo $this->get_field_id('icon'); echo '">';_e('Icon:'); echo '</label>
  231.         <select class="widefat" id="';echo $this->get_field_id('icon'); echo '" name="';echo $this->get_field_name('icon'); echo '">
  232.             <option value="">';_e('None',$ts_domain) ;echo '</option>
  233.             ';foreach ($pn_icons_obj as $pn_icon) {
  234. echo '<option value="'.$pn_icon.'" '.selected($pn_icon,$icon).'>'.$pn_icon.'</option>';
  235. };echo '        </select></p>
  236.        
  237.         <p><label for="';echo $this->get_field_id('title'); echo '">';_e('Title:'); echo '</label>
  238.         <input class="widefat" id="';echo $this->get_field_id('title'); echo '" name="';echo $this->get_field_name('title'); echo '" type="text" value="';echo esc_attr($title); echo '" /></p>
  239.  
  240.         <p><label for="';echo $this->get_field_id('img'); echo '">';_e('Image:',$ts_domain); echo '</label>
  241.         <input class="widefat" id="';echo $this->get_field_id('img'); echo '" name="';echo $this->get_field_name('img'); echo '" type="text" value="';echo esc_attr($img); echo '" /><br /><small>(';_e('Enter URL or media image ID',$ts_domain); echo ')</small></p>
  242.  
  243.         <p><label for="';echo $this->get_field_id('text'); echo '">';_e('Text:',$ts_domain); echo '</label>
  244.         <textarea class="widefat" rows="5" cols="10" id="';echo $this->get_field_id('text'); echo '" name="';echo $this->get_field_name('text'); echo '">';echo $text; echo '</textarea><br /><small>(';_e('HTML allowed - will be wrapped by p-tags',$ts_domain); echo ')</small></p>
  245.        
  246.         <p><label for="';echo $this->get_field_id('link'); echo '">';_e('Link:',$ts_domain); echo '</label>
  247.         <input class="widefat" id="';echo $this->get_field_id('link'); echo '" name="';echo $this->get_field_name('link'); echo '" type="text" value="';echo esc_attr($link); echo '" /><br /><small>(';_e('Enter URL or post/page ID',$ts_domain); echo ')</small></p>
  248.        
  249.         <p><label for="';echo $this->get_field_id('label'); echo '">';_e('Link label:',$ts_domain); echo '</label>
  250.         <input class="widefat" id="';echo $this->get_field_id('label'); echo '" name="';echo $this->get_field_name('label'); echo '" type="text" value="';echo esc_attr($label); echo '" /></p>
  251. ';
  252. }
  253. }
  254. register_widget('TS_Features');
  255. class TS_News extends WP_Widget {
  256. function TS_News() {
  257. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  258. $widget_ops = array('classname'=>'widget_ts_news','description'=>__('Recent news in',$ts_domain).' '.$ts_theme );
  259. $this->WP_Widget('ts_news',$ts_theme.' '.__('News',$ts_domain),$widget_ops);
  260. }
  261. function widget($args,$instance) {
  262. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  263. ob_start();
  264. extract($args);
  265. $title = apply_filters('widget_title',empty($instance['title']) ?__('Recent News',$ts_domain) : $instance['title']);
  266. if ( !$number = (int) $instance['number'] )
  267. $number = 10;
  268. else if ( $number <1 )
  269. $number = 1;
  270. else if ( $number >15 )
  271. $number = 15;
  272. $news_cat = $instance['news_cat'];
  273. $r = new WP_Query(array('cat'=>$news_cat,'showposts'=>$number,'nopaging'=>0,'post_status'=>'publish','caller_get_posts'=>1));
  274. if ($r->have_posts()) :echo $before_widget; echo $before_title .$title .$after_title; echo '        <ul class="list1">
  275.         ';while ($r->have_posts()) : $r->the_post(); echo '     <li><a href="';the_permalink() ;echo '" title="';echo esc_attr(get_the_title() ?get_the_title() : get_the_ID()); echo '">';if ( get_the_title() ) the_title();else the_ID(); echo ' </a><br /><small>';the_time(get_option('date_format')); _e('in','devision'); the_category(', '); echo '</small></li>
  276.         ';endwhile; echo '      </ul>
  277.         <div id="news-rss">
  278.             ';$ts_feed = $news_cat ?get_category_feed_link($news_cat,'') : ts_get_option('ts_rss'); echo '          <a href="';echo $ts_feed; echo '"><img src="';bloginfo('template_url'); echo '/img/icons/rss.png" alt="rss" width="20" height="20" /></a>
  279.         </div>
  280.         ';echo $after_widget;
  281. wp_reset_query();
  282. endif;
  283. }
  284. function update( $new_instance,$old_instance ) {
  285. $instance = $old_instance;
  286. $instance['title'] = strip_tags($new_instance['title']);
  287. $instance['number'] = (int) $new_instance['number'];
  288. $instance['news_cat'] = $new_instance['news_cat'];
  289. return $instance;
  290. }
  291. function form( $instance ) {
  292. $title = isset($instance['title']) ?esc_attr($instance['title']) : __('Recent News',$ts_domain);
  293. if ( !isset($instance['number']) ||!$number = (int) $instance['number'] )
  294. $number = 5;
  295. $news_cat = $instance['news_cat'];
  296. $pn_categories_obj = get_categories('hide_empty=0');
  297. $pn_categories = array(); echo '
  298.         <p><label for="';echo $this->get_field_id('title'); echo '">';_e('Title:'); echo '</label>
  299.         <input class="widefat" id="';echo $this->get_field_id('title'); echo '" name="';echo $this->get_field_name('title'); echo '" type="text" value="';echo $title; echo '" /></p>
  300.         <p><label for="';echo $this->get_field_id('news_cat'); echo '">';_e('Category:'); echo '</label>
  301.         <select class="widefat" id="';echo $this->get_field_id('news_cat'); echo '" name="';echo $this->get_field_name('news_cat'); echo '">
  302.             <option value="">';_e('All',$ts_domain) ;echo '</option>
  303.             ';foreach ($pn_categories_obj as $pn_cat) {
  304. echo '<option value="'.$pn_cat->cat_ID.'" '.selected($pn_cat->cat_ID,$news_cat).'>'.$pn_cat->cat_name.'</option>';
  305. };echo '        </select></p>
  306.  
  307.         <p><label for="';echo $this->get_field_id('number'); echo '">';_e('Number of posts to show:'); echo '</label>
  308.         <input id="';echo $this->get_field_id('number'); echo '" name="';echo $this->get_field_name('number'); echo '" type="text" value="';echo $number; echo '" size="3" /><br />
  309.         <small>';_e('(at most 15)'); echo '</small></p>
  310. ';
  311. }
  312. }
  313. register_widget('TS_News');
  314. class TS_Newsletter extends WP_Widget {
  315. function TS_Newsletter() {
  316. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  317. $widget_ops = array('classname'=>'widget_ts_newsletter','description'=>__('Newsletter form for',$ts_domain).' '.$ts_theme );
  318. $this->WP_Widget('ts_newsletter',$ts_theme.' '.__('Newsletter',$ts_domain),$widget_ops);
  319. }
  320. function widget($args,$instance) {
  321. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  322. extract( $args );
  323. $title  = empty($instance['text']) ?__('Newsletter',$ts_domain) : strip_tags($instance['title']);
  324. $user   = $instance['user'];
  325. $text   = empty($instance['text']) ?__('Subscribe to Newsletter',$ts_domain) : $instance['text']; echo $before_widget; echo $before_title .$title .$after_title; echo '            
  326.                 <form action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" onsubmit="window.open(\'http://feedburner.google.com/fb/a/mailverify?uri=';echo $user; echo '\', \'popupwindow\', \'scrollbars=yes,width=550,height=520\');return true" class="clearfix">
  327.                     <input type="text" id="newsletter-text" class="text" name="email" value="';echo $text; echo '..." onfocus="if (this.value == \'';echo $text; echo '...\') {this.value = \'\';}" onblur="if (this.value == \'\') {this.value = \'';echo $text; echo '...\';}" />
  328.                     <input type="hidden" value="';echo $user; echo '" name="uri" />
  329.                     <input type="hidden" name="loc" value="';bloginfo('language'); echo '"/>
  330.                     <input src="';bloginfo('template_url'); echo '/img/trans.png" id="newsletter-submit" type="image" />
  331.                 </form>
  332.  
  333.             ';echo $after_widget;
  334. }
  335. function update($new_instance,$old_instance) {
  336. $instance['title'] = strip_tags($new_instance['title']);
  337. $instance['user'] = strip_tags($new_instance['user']);
  338. $instance['text'] = strip_tags($new_instance['text']);
  339. return $new_instance;
  340. }
  341. function form($instance) {
  342. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  343. $instance   = wp_parse_args( (array) $instance,array( 'title'=>'','user'=>'','text'=>'') );
  344. $title      = empty($instance['text']) ?__('Newsletter',$ts_domain) : strip_tags($instance['title']);
  345. $user       = $instance['user'];
  346. $text       = empty($instance['text']) ?__('Subscribe to Newsletter',$ts_domain) : $instance['text']; echo '
  347.         <p>
  348.             <label for="';echo $this->get_field_id('title'); echo '">';_e('Title'); echo ':
  349.             <input class="widefat" id="';echo $this->get_field_id('title'); echo '" name="';echo $this->get_field_name('title'); echo '" type="text" value="';echo attribute_escape($title); echo '" />
  350.             </label>
  351.         </p>
  352.        
  353.         <p>
  354.             <label for="';echo $this->get_field_id('user'); echo '">';_e('Feedburner ID',$ts_domain); echo ':
  355.             <input class="widefat" id="';echo $this->get_field_id('user'); echo '" name="';echo $this->get_field_name('user'); echo '" type="text" value="';echo attribute_escape($user); echo '" />
  356.             </label>
  357.         </p>
  358.        
  359.         <p>
  360.             <label for="';echo $this->get_field_id('text'); echo '">';_e('Text',$ts_domain); echo ':
  361.             <input class="widefat" id="';echo $this->get_field_id('text'); echo '" name="';echo $this->get_field_name('text'); echo '" type="text" value="';echo attribute_escape($text); echo '" />
  362.             </label>
  363.         </p>
  364.        
  365. ';
  366. }
  367. }
  368. register_widget('TS_Newsletter');
  369. class TS_Search extends WP_Widget {
  370. function TS_Search() {
  371. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  372. $widget_ops = array('classname'=>'widget_ts_search','description'=>__('Search form for',$ts_domain).' '.$ts_theme );
  373. $this->WP_Widget('ts_search',$ts_theme.' '.__('Search',$ts_domain),$widget_ops);
  374. }
  375. function widget($args,$instance) {
  376. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  377. extract( $args );
  378. $title  = empty($instance['text']) ?__('Search',$ts_domain) : strip_tags($instance['title']); echo $before_widget; echo $before_title .$title .$after_title; get_search_form(); echo $after_widget;
  379. }
  380. function update($new_instance,$old_instance) {
  381. $instance['title'] = strip_tags($new_instance['title']);
  382. return $new_instance;
  383. }
  384. function form($instance) {
  385. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  386. $instance   = wp_parse_args( (array) $instance,array( 'title'=>'') );
  387. $title      = empty($instance['text']) ?__('Search',$ts_domain) : strip_tags($instance['title']); echo '
  388.         <p>
  389.             <label for="';echo $this->get_field_id('title'); echo '">';_e('Title'); echo ':
  390.             <input class="widefat" id="';echo $this->get_field_id('title'); echo '" name="';echo $this->get_field_name('title'); echo '" type="text" value="';echo attribute_escape($title); echo '" />
  391.             </label>
  392.         </p>
  393.        
  394. ';
  395. }
  396. }
  397. register_widget('TS_Search');
  398. class TS_Twitter extends WP_Widget {
  399. function TS_Twitter() {
  400. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  401. $widget_ops = array('classname'=>'widget_ts_twitter','description'=>__('Display latest tweets in',$ts_domain).' '.$ts_theme );
  402. $this->WP_Widget('ts_twitter',$ts_theme.' '.__('Twitter',$ts_domain),$widget_ops);
  403. }
  404. function widget($args,$instance) {
  405. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  406. extract( $args );
  407. $title  = empty($instance['title']) ?__('Latest Tweets',$ts_domain) : $instance['title'];
  408. $user   = empty($instance['user']) ?ts_get_option('ts_twitter') : $instance['user'];
  409. $link   = $instance['twitter_link'] ?'1': '0';
  410. $label  = empty($instance['twitter_label']) ?__('Follow',$ts_domain) : $instance['twitter_label'];
  411. if ( !$nr = (int) $instance['twitter_nr'] )
  412. $nr = 5;
  413. else if ( $nr <1 )
  414. $nr = 1;
  415. else if ( $nr >15 )
  416. $nr = 15; echo $before_widget; echo $before_title .$title .$after_title; echo '            
  417.                 <div id="twitter_div">
  418.                     <ul id="twitter_update_list" class="list1"><li></li></ul>
  419.                 </div>
  420.                  
  421.                <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
  422.                 <script type="text/javascript" src="http://twitter.com/statuses/user_timeline/';echo $user; echo '.json?callback=twitterCallback2&amp;count=';echo $nr; echo '"></script>
  423.                  
  424.                ';if($link) :echo '                <p><a href="http://twitter.com/';echo $user; echo '" class="btn"><span>';echo $label; echo '</span></a></p>
  425.                ';endif; echo $after_widget;
  426. }
  427. function update($new_instance,$old_instance) {
  428. $instance['title'] = strip_tags($new_instance['title']);
  429. $instance['user'] = strip_tags($new_instance['user']);
  430. $instance['twitter_link'] = $new_instance['twitter_link'] ?1 : 0;
  431. $instance['twitter_label'] = strip_tags($new_instance['twitter_label']);
  432. $instance['twitter_nr'] = (int) $new_instance['twitter_nr'];
  433. return $new_instance;
  434. }
  435. function form($instance) {
  436. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  437. $instance   = wp_parse_args( (array) $instance,array( 'title'=>'','user'=>'','twitter_link'=>'','twitter_label'=>'','twitter_nr'=>'') );
  438. $title      = empty($instance['title']) ?__('Latest Tweets',$ts_domain) : $instance['title'];
  439. $user       = $instance['user'];
  440. $link       = $instance['twitter_link'] ?1 : 0;
  441. $label      = empty($instance['twitter_label']) ?__('Follow',$ts_domain) : $instance['twitter_label'];
  442. if (!$nr = (int) $instance['twitter_nr']) $nr = 5; echo '
  443.         <p>
  444.             <label for="';echo $this->get_field_id('title'); echo '">';_e('Title'); echo ':
  445.             <input class="widefat" id="';echo $this->get_field_id('title'); echo '" name="';echo $this->get_field_name('title'); echo '" type="text" value="';echo attribute_escape($title); echo '" />
  446.             </label>
  447.         </p>
  448.        
  449.         <p>
  450.             <label for="';echo $this->get_field_id('user'); echo '">';_e('User'); echo ':
  451.             <input class="widefat" id="';echo $this->get_field_id('user'); echo '" name="';echo $this->get_field_name('user'); echo '" type="text" value="';echo attribute_escape($user); echo '" />
  452.             </label>
  453.         </p>
  454.        
  455.         <p>
  456.             <label for="';echo $this->get_field_id('twitter_nr'); echo '">';_e('Number of tweets to show',$ts_domain); echo ':</label>
  457.             <input id="';echo $this->get_field_id('twitter_nr'); echo '" name="';echo $this->get_field_name('twitter_nr'); echo '" type="text" value="';echo $nr; echo '" size="3" /><br />
  458.             <small>';_e('(at most 15)'); echo '</small>
  459.         </p>
  460.        
  461.         <p>
  462.             <input type="checkbox" class="checkbox" id="';echo $this->get_field_id('twitter_link'); echo '" name="';echo $this->get_field_name('twitter_link'); echo '"';checked($link); echo ' />
  463.             <label for="';echo $this->get_field_id('twitter_link'); echo '">';_e('Show link to Twitter',$ts_domain); echo '</label>    
  464.         </p>
  465.        
  466.         <p>
  467.             <label for="';echo $this->get_field_id('twitter_label'); echo '">';_e('Link label',$ts_domain); echo ':
  468.             <input class="widefat" id="';echo $this->get_field_id('twitter_label'); echo '" name="';echo $this->get_field_name('twitter_label'); echo '" type="text" value="';echo attribute_escape($label); echo '" />
  469.             </label>
  470.         </p>
  471.        
  472. ';
  473. }
  474. }
  475. register_widget('TS_Twitter');
  476. class TS_Flickr extends WP_Widget {
  477. function TS_Flickr() {
  478. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  479. $widget_ops = array('classname'=>'widget_ts_flickr','description'=>__('Display flickr badge in',$ts_domain).' '.$ts_theme );
  480. $this->WP_Widget('ts_flickr',$ts_domain.' '.__('Flickr',$ts_domain),$widget_ops);
  481. }
  482. function widget($args,$instance) {
  483. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  484. extract( $args );
  485. $title  = empty($instance['title']) ?__('<span style="color:#3993ff">Flick<span style="color:#ff1c92">r</span></span> Fotos',$ts_domain) : apply_filters('widget_title',$instance['title']);
  486. $user   = empty($instance['user']) ?ts_get_option('ts_flickr') : $instance['user'];
  487. if ( !$nr = (int) $instance['flickr_nr'] )
  488. $nr = 6;
  489. else if ( $nr <1 )
  490. $nr = 3;
  491. else if ( $nr >15 )
  492. $nr = 15; if($big) : echo '<div class="widget_ts_flickr wide clearfix">';else : echo $before_widget;endif; echo $before_title .$title .$after_title; echo '            
  493.                 <div id="flickr_badge_wrapper" class="clearfix"></div>
  494.  
  495.                 <script type="text/javascript">            
  496.                     jQuery(document).ready(function(){             
  497.                         jQuery(\'#flickr_badge_wrapper\').jflickrfeed({
  498.                             limit: ';echo $nr; echo ',
  499.                             qstrings: {
  500.                                 id: \'';echo $user; echo '\'
  501.                             },
  502.                             itemTemplate:
  503.                             \'<div class="flickr_badge_image">\' +
  504.                                 \'<a href="{{link}}" title="{{title}}" rel="prettyPhoto">\' +
  505.                                     \'<img src="{{image_s}}" alt="{{title}}" />\' +
  506.                                 \'</a>\' +
  507.                             \'</div>\'
  508.                         });
  509.                     });            
  510.                 </script>              
  511.  
  512.             ';echo $after_widget;
  513. }
  514. function update($new_instance,$old_instance) {
  515. $instance['title'] = strip_tags($new_instance['title']);
  516. $instance['user'] = strip_tags($new_instance['user']);
  517. $instance['flickr_nr'] = (int) $new_instance['flickr_nr'];
  518. return $new_instance;
  519. }
  520. function form($instance) {
  521. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  522. $instance = wp_parse_args( (array) $instance,array( 'title'=>'','user'=>'','flickr_nr'=>'') );
  523. $title = strip_tags($instance['title']);
  524. $user = empty($instance['user']) ?ts_get_option('ts_flickr') : $instance['user'];
  525. if (!$nr = (int) $instance['flickr_nr']) $nr = 6; echo '
  526.         <p>
  527.             <label for="';echo $this->get_field_id('title'); echo '">';_e('Title'); echo ':
  528.             <input class="widefat" id="';echo $this->get_field_id('title'); echo '" name="';echo $this->get_field_name('title'); echo '" type="text" value="';echo attribute_escape($title); echo '" />
  529.             </label>
  530.         </p>
  531.        
  532.         <p>
  533.             <label for="';echo $this->get_field_id('user'); echo '">';_e('User'); echo ':
  534.             <input class="widefat" id="';echo $this->get_field_id('user'); echo '" name="';echo $this->get_field_name('user'); echo '" type="text" value="';echo attribute_escape($user); echo '" />
  535.             </label>
  536.         </p>
  537.        
  538.         <p>
  539.             <label for="';echo $this->get_field_id('flickr_nr'); echo '">';_e('Number of fotos to show',$ts_domain); echo ':</label>
  540.             <input id="';echo $this->get_field_id('flickr_nr'); echo '" name="';echo $this->get_field_name('flickr_nr'); echo '" type="text" value="';echo $nr; echo '" size="3" /><br />
  541.             <small>';_e('(at most 15)'); echo '</small>
  542.         </p>
  543.        
  544. ';
  545. }
  546. }
  547. register_widget('TS_Flickr');
  548. class TS_Comments extends WP_Widget {
  549. function TS_Comments() {
  550. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  551. $widget_ops = array('classname'=>'widget_ts_comments','description'=>__('Display recent comments in',$ts_domain).' '.$ts_theme );
  552. $this->WP_Widget('ts_comments',$ts_theme.' '.__('Comments',$ts_domain),$widget_ops);
  553. }
  554. function widget($args,$instance) {
  555. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  556. extract( $args );
  557. $title  = empty($instance['title']) ?__('Recent Comments',$ts_domain) : apply_filters('widget_title',$instance['title']);
  558. if ( !$nr = (int) $instance['comments_nr'] )
  559. $nr = 5;
  560. else if ( $nr <1 )
  561. $nr = 1;
  562. else if ( $nr >15 )
  563. $nr = 15;
  564. if ( !$exc = (int) $instance['comments_exc'] ) $exc = 75; echo $before_widget; echo $before_title .$title .$after_title; ts_recent_comments($nr,$exc); echo $after_widget;
  565. }
  566. function update($new_instance,$old_instance) {
  567. $instance['title'] = strip_tags($new_instance['title']);
  568. $instance['comments_nr'] = (int) $new_instance['comments_nr'];
  569. $instance['comments_exc'] = (int) $new_instance['comments_exc'];
  570. $instance['boxed'] = $new_instance['boxed'] ?1 : 0;
  571. return $new_instance;
  572. }
  573. function form($instance) {
  574. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  575. $instance = wp_parse_args( (array) $instance,array( 'title'=>'','comments_nr'=>'') );
  576. $title = strip_tags($instance['title']);
  577. if (!$nr = (int) $instance['comments_nr']) $nr = 5;
  578. if (!$exc = (int) $instance['comments_exc']) $exc = 75; echo '
  579.         <p>
  580.             <label for="';echo $this->get_field_id('title'); echo '">';_e('Title'); echo ':
  581.             <input class="widefat" id="';echo $this->get_field_id('title'); echo '" name="';echo $this->get_field_name('title'); echo '" type="text" value="';echo attribute_escape($title); echo '" />
  582.             </label>
  583.         </p>
  584.        
  585.         <p>
  586.             <label for="';echo $this->get_field_id('comments_nr'); echo '">';_e('Number of comments',$ts_domain); echo ':</label>
  587.             <input id="';echo $this->get_field_id('comments_nr'); echo '" name="';echo $this->get_field_name('comments_nr'); echo '" type="text" value="';echo $nr; echo '" size="3" /><br />
  588.             <small>';_e('(at most 15)'); echo '</small>
  589.         </p>
  590.        
  591.         <p>
  592.             <label for="';echo $this->get_field_id('comments_exc'); echo '">';_e('Length of comment excerpt',$ts_domain); echo ':</label>
  593.             <input id="';echo $this->get_field_id('comments_exc'); echo '" name="';echo $this->get_field_name('comments_exc'); echo '" type="text" value="';echo $exc; echo '" size="3" />
  594.         </p>
  595.        
  596. ';
  597. }
  598. }
  599. function ts_recent_comments($rc_count=5,$rc_length=75,$rc_pre='<ul class="list1">',$rc_post='</ul>') {
  600. global $wpdb,$ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  601. $sql = "SELECT DISTINCT ID,
  602.             post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,
  603.             SUBSTRING(comment_content,1,$rc_length) AS com_excerpt
  604.             FROM $wpdb->comments
  605.             LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID)
  606.             WHERE comment_approved = '1' AND comment_type = '' AND post_password = ''
  607.             ORDER BY comment_date_gmt DESC
  608.             LIMIT $rc_count";
  609. $comments = $wpdb->get_results($sql);
  610. $output = $rc_pre;
  611. foreach ($comments as $comment) {
  612. $com_length = strlen($comment->com_excerpt);
  613. if ($com_length <$rc_length) : $rc_dots = "";else : $rc_dots = "&hellip;";endif;
  614. $output .= "\n\t<li class=\"recent-comment\">".$comment->comment_author ." ".__('on',$ts_domain)." <a href=\"".get_permalink($comment->ID) ."#comment-".$comment->comment_ID  ."\" title=\"".$comment->post_title ."\">".$comment->post_title ."</a>:<br />".strip_tags($comment->com_excerpt) .$rc_dots ."</li>";
  615. }
  616. $output .= $rc_post;
  617. echo $output;
  618. }
  619. register_widget('TS_Comments');
  620. class TS_About extends WP_Widget {
  621. function TS_About() {
  622. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  623. $widget_ops = array('classname'=>'widget_ts_about','description'=>__('Display about section in',$ts_domain).' '.$ts_theme );
  624. $this->WP_Widget('ts_about',$ts_theme.' '.__('About',$ts_domain),$widget_ops);
  625. }
  626. function widget($args,$instance) {
  627. global $ts_theme,$ts_short,$ts_version,$ts_domain,$options;
  628. extract( $args );
  629. $title  = empty($instance['title']) ?__('About Us',$ts_domain) : $instance['title'];
  630. $avatar = $instance['about_avatar'] ?'1': '0';
  631. $text   = empty($instance['about_text']) ?__('Your text about you.',$ts_domain) : $instance['about_text'];
  632. $link   = (int) $instance['about_link'];
  633. $label  = empty($instance['about_label']) ?__('More',$ts_domain) : $instance['about_label']; if($big) : echo '<div class="widget_ts_about wide clearfix">';else : echo $before_widget;endif; echo $before_title .$title .$after_title; if($avatar) :echo get_avatar(get_bloginfo('admin_email'),'80'); endif; echo '               
  634.                 <p>';echo nl2br($text); echo '</p>                
  635.                
  636.                 ';if($link) :echo '<p><a href="';echo get_permalink($link); echo '" class="btn"><span>';echo $label; echo '</span></a></p>';endif; echo $after_widget;
  637. }
  638. function update($new_instance,$old_instance) {
  639. $instance['title'] = empty($new_instance['title']) ?__('About Us',$ts_domain) : $new_instance['title'];
  640. $instance['about_avatar'] = $new_instance['about_avatar'] ?1 : 0;
  641. $instance['about_text'] = strip_tags($new_instance['about_text']);
  642. $instance['about_link'] = (int) $new_instance['about_link'];
  643. $instance['about_label'] = empty($new_instance['about_label']) ?__('More',$ts_domain) : $new_instance['about_label'];
  644. return $new_instance;
  645. }
  646. function form($instance) {
  647. $instance   = wp_parse_args( (array) $instance,array( 'title'=>'','about_avatar'=>'','about_text'=>'','about_link'=>'','about_label'=>'','about_big'=>'') );
  648. $title  = empty($instance['title']) ?__('About Us',$ts_domain) : $instance['title'];
  649. $avatar = $instance['about_avatar'] ?'1': '0';
  650. $text   = empty($instance['about_text']) ?__('Your text about you.',$ts_domain) : $instance['about_text'];
  651. $link   = $instance['about_link'];
  652. $label  = empty($instance['about_label']) ?__('More',$ts_domain) : $instance['about_label']; echo '
  653.         <p>
  654.             <label for="';echo $this->get_field_id('title'); echo '">';_e('Title'); echo ':
  655.             <input class="widefat" id="';echo $this->get_field_id('title'); echo '" name="';echo $this->get_field_name('title'); echo '" type="text" value="';echo attribute_escape($title); echo '" />
  656.             </label>
  657.         </p>
  658.        
  659.         <p>
  660.             <input type="checkbox" class="checkbox" id="';echo $this->get_field_id('about_avatar'); echo '" name="';echo $this->get_field_name('about_avatar'); echo '"';checked( $avatar ); echo ' />
  661.             <label for="';echo $this->get_field_id('about_avatar'); echo '">';_e('Show admin\'s avatar',$ts_domain); echo '</label>    
  662.         </p>
  663.        
  664.         <p>
  665.             <label for="';echo $this->get_field_id('about_text'); echo '">';_e('Text',$ts_domain); echo ':
  666.             <textarea class="widefat" rows="5" cols="20" id="';echo $this->get_field_id('about_text'); echo '" name="';echo $this->get_field_name('about_text'); echo '">';echo attribute_escape($text); echo '</textarea>
  667.             </label>
  668.         </p>
  669.        
  670.         <p>
  671.             <label for="';echo $this->get_field_id('about_link'); echo '">';_e('Post/page ID for link',$ts_domain); echo ':</label>
  672.             <input id="';echo $this->get_field_id('about_link'); echo '" name="';echo $this->get_field_name('about_link'); echo '" type="text" value="';echo $link; echo '" size="3" />
  673.         </p>
  674.        
  675.         <p>
  676.             <label for="';echo $this->get_field_id('about_label'); echo '">';_e('Link label',$ts_domain); echo ':
  677.             <input class="widefat" id="';echo $this->get_field_id('about_label'); echo '" name="';echo $this->get_field_name('about_label'); echo '" type="text" value="';echo attribute_escape($label); echo '" />
  678.             </label>
  679.         </p>
  680.        
  681. ';
  682. }
  683. }
  684. register_widget('TS_About');
  685. function unregister_default_wp_widgets() {
  686. unregister_widget('WP_Widget_Search');
  687. }
  688. add_action('widgets_init','unregister_default_wp_widgets',1);
  689.  
  690. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement