document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2.  
  3. /*** Theme setup ***/
  4.  
  5. add_theme_support( 'post-thumbnails' );
  6. add_theme_support( 'automatic-feed-links' );
  7.  
  8. function sight_setup() {
  9. update_option('thumbnail_size_w', 290);
  10. update_option('thumbnail_size_h', 290);
  11. add_image_size( 'mini-thumbnail', 50, 50, true );
  12. add_image_size( 'slide', 640, 290, true );
  13. register_nav_menu('Navigation', __('Navigation'));
  14. register_nav_menu('Top menu', __('Top menu'));
  15. }
  16. add_action( 'init', 'sight_setup' );
  17.  
  18. if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php' ) {
  19. update_option( 'posts_per_page', 12 );
  20. update_option( 'paging_mode', 'default' );
  21. }
  22.  
  23. /*** Navigation ***/
  24.  
  25. if ( !is_nav_menu('Navigation') || !is_nav_menu('Top menu') ) {
  26. $menu_id1 = wp_create_nav_menu('Navigation');
  27. $menu_id2 = wp_create_nav_menu('Top menu');
  28. wp_update_nav_menu_item($menu_id1, 1);
  29. wp_update_nav_menu_item($menu_id2, 1);
  30. }
  31.  
  32. class extended_walker extends Walker_Nav_Menu{
  33. function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
  34.  
  35. if ( !$element )
  36. return;
  37.  
  38. $id_field = $this->db_fields['id'];
  39.  
  40. //display this element
  41. if ( is_array( $args[0] ) )
  42. $args[0]['has_children'] = ! empty( $children_elements[$element->$id_field] );
  43.  
  44. //Adds the 'parent' class to the current item if it has children
  45. if( ! empty( $children_elements[$element->$id_field] ) )
  46. array_push($element->classes,'parent');
  47.  
  48. $cb_args = array_merge( array(&$output, $element, $depth), $args);
  49.  
  50. call_user_func_array(array(&$this, 'start_el'), $cb_args);
  51.  
  52. $id = $element->$id_field;
  53.  
  54. // descend only when the depth is right and there are childrens for this element
  55. if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) {
  56.  
  57. foreach( $children_elements[ $id ] as $child ){
  58.  
  59. if ( !isset($newlevel) ) {
  60. $newlevel = true;
  61. //start the child delimiter
  62. $cb_args = array_merge( array(&$output, $depth), $args);
  63. call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
  64. }
  65. $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
  66. }
  67. unset( $children_elements[ $id ] );
  68. }
  69.  
  70. if ( isset($newlevel) && $newlevel ){
  71. //end the child delimiter
  72. $cb_args = array_merge( array(&$output, $depth), $args);
  73. call_user_func_array(array(&$this, 'end_lvl'), $cb_args);
  74. }
  75.  
  76. //end this element
  77. $cb_args = array_merge( array(&$output, $element, $depth), $args);
  78. call_user_func_array(array(&$this, 'end_el'), $cb_args);
  79. }
  80. }
  81.  
  82. /*** Slideshow ***/
  83.  
  84. $prefix = 'sgt_';
  85.  
  86. $meta_box = array(
  87. 'id' => 'slide',
  88. 'title' => 'Slideshow Options',
  89. 'page' => 'post',
  90. 'context' => 'side',
  91. 'priority' => 'low',
  92. 'fields' => array(
  93. array(
  94. 'name' => 'Show in slideshow',
  95. 'id' => $prefix . 'slide',
  96. 'type' => 'checkbox'
  97. )
  98. )
  99. );
  100. add_action('admin_menu', 'sight_add_box');
  101.  
  102. // Add meta box
  103. function sight_add_box() {
  104. global $meta_box;
  105.  
  106. add_meta_box($meta_box['id'], $meta_box['title'], 'sight_show_box', $meta_box['page'], $meta_box['context'], $meta_box['priority']);
  107. }
  108.  
  109. // Callback function to show fields in meta box
  110. function sight_show_box() {
  111. global $meta_box, $post;
  112.  
  113. // Use nonce for verification
  114. echo '<input type="hidden" name="sight_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
  115.  
  116. echo '<table class="form-table">';
  117.  
  118. foreach ($meta_box['fields'] as $field) {
  119. // get current post meta data
  120. $meta = get_post_meta($post->ID, $field['id'], true);
  121.  
  122. echo '<tr>',
  123. '<th style="width:50%"><label for="', $field['id'], '">', $field['name'], '</label></th>',
  124. '<td>';
  125. echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';
  126. echo '<td>',
  127. '</tr>';
  128. }
  129.  
  130. echo '</table>';
  131. }
  132.  
  133. add_action('save_post', 'sight_save_data');
  134.  
  135. // Save data from meta box
  136. function sight_save_data($post_id) {
  137. global $meta_box;
  138.  
  139. // verify nonce
  140. if (!wp_verify_nonce($_POST['sight_meta_box_nonce'], basename(__FILE__))) {
  141. return $post_id;
  142. }
  143.  
  144. // check autosave
  145. if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
  146. return $post_id;
  147. }
  148.  
  149. // check permissions
  150. if ('page' == $_POST['post_type']) {
  151. if (!current_user_can('edit_page', $post_id)) {
  152. return $post_id;
  153. }
  154. } elseif (!current_user_can('edit_post', $post_id)) {
  155. return $post_id;
  156. }
  157.  
  158. foreach ($meta_box['fields'] as $field) {
  159. $old = get_post_meta($post_id, $field['id'], true);
  160. $new = $_POST[$field['id']];
  161.  
  162. if ($new && $new != $old) {
  163. update_post_meta($post_id, $field['id'], $new);
  164. } elseif ('' == $new && $old) {
  165. delete_post_meta($post_id, $field['id'], $old);
  166. }
  167. }
  168. }
  169.  
  170. /*** Options ***/
  171.  
  172. function options_admin_menu() {
  173. // here's where we add our theme options page link to the dashboard sidebar
  174. add_theme_page("Sight Theme Options", "Theme Options", 'edit_themes', basename(__FILE__), 'options_page');
  175. }
  176. add_action('admin_menu', 'options_admin_menu');
  177.  
  178. function options_page() {
  179. if ( $_POST['update_options'] == 'true' ) { options_update(); } //check options update
  180. ?>
  181. <div class="wrap">
  182. <div id="icon-options-general" class="icon32"><br /></div>
  183. <h2>Sight Theme Options</h2>
  184.  
  185. <form method="post" action="">
  186. <input type="hidden" name="update_options" value="true" />
  187.  
  188. <table class="form-table">
  189. <tr valign="top">
  190. <th scope="row"><label for="logo_url"><?php _e('Custom logo URL:'); ?></label></th>
  191. <td><input type="text" name="logo_url" id="logo_url" size="50" value="<?php echo get_option('logo_url'); ?>"/><br/><span
  192. class="description"> <a href="<?php bloginfo("url"); ?>/wp-admin/media-new.php" target="_blank">Upload your logo</a> (max 290px x 128px) using WordPress Media Library and insert its URL here </span><br/><br/><img src="<?php echo (get_option('logo_url')) ? get_option('logo_url') : get_bloginfo('template_url') . '/images/logo.png' ?>"
  193. alt=""/></td>
  194. </tr>
  195. <tr valign="top">
  196. <th scope="row"><label for="bg_color"><?php _e('Custom background color:'); ?></label></th>
  197. <td><input type="text" name="bg_color" id="bg_color" size="20" value="<?php echo get_option('bg_color'); ?>"/><span
  198. class="description"> e.g., <strong>#27292a</strong> or <strong>black</strong></span></td>
  199. </tr>
  200. <tr valign="top">
  201. <th scope="row"><label for="ss_disable"><?php _e('Disable slideshow:'); ?></label></th>
  202. <td><input type="checkbox" name="ss_disable" id="ss_disable" <?php echo (get_option('ss_disable'))? 'checked="checked"' : ''; ?>/></td>
  203. </tr>
  204. <tr valign="top">
  205. <th scope="row"><label for="ss_timeout"><?php _e('Timeout for slideshow (ms):'); ?></label></th>
  206. <td><input type="text" name="ss_timeout" id="ss_timeout" size="20" value="<?php echo get_option('ss_timeout'); ?>"/><span
  207. class="description"> e.g., <strong>7000</strong></span></td>
  208. </tr>
  209. <tr valign="top">
  210. <th scope="row"><label><?php _e('Pagination:'); ?></label></th>
  211. <td>
  212. <input type="radio" name="paging_mode" value="default" <?php echo (get_option('paging_mode') == 'default')? 'checked="checked"' : ''; ?>/><span class="description">Default + WP Page-Navi support</span><br/>
  213. <input type="radio" name="paging_mode" value="ajax" <?php echo (get_option('paging_mode') == 'ajax')? 'checked="checked"' : ''; ?>/><span class="description">AJAX-fetching posts</span><br/>
  214. </td>
  215. </tr>
  216. <tr valign="top">
  217. <th scope="row"><label for="ga"><?php _e('Google Analytics code:'); ?></label></th>
  218. <td><textarea name="ga" id="ga" cols="48" rows="18"><?php echo get_option('ga'); ?></textarea></td>
  219. </tr>
  220. </table>
  221.  
  222. <p><input type="submit" value="Save Changes" class="button button-primary" /></p>
  223. </form>
  224. </div>
  225. <?php
  226. }
  227.  
  228. // Update options
  229.  
  230. function options_update() {
  231. update_option('logo_url', $_POST['logo_url']);
  232. update_option('bg_color', $_POST['bg_color']);
  233. update_option('ss_disable', $_POST['ss_disable']);
  234. update_option('ss_timeout', $_POST['ss_timeout']);
  235. update_option('paging_mode', $_POST['paging_mode']);
  236. update_option('ga', stripslashes_deep($_POST['ga']));
  237. }
  238.  
  239. /*** Widgets ***/
  240.  
  241. if (function_exists('register_sidebar')) {
  242. register_sidebar(array(
  243. 'name'=>'Site description',
  244. 'before_widget' => '<div class="site-description">',
  245. 'after_widget' => '</div>'
  246. ));
  247. register_sidebar(array(
  248. 'name'=>'Sidebar',
  249. 'before_widget' => '<div id="%1$s" class="%2$s widget">',
  250. 'after_widget' => '</div></div>',
  251. 'before_title' => '<h3>',
  252. 'after_title' => '</h3><div class="widget-body clear">'
  253. ));
  254. }
  255.  
  256. class GetConnected extends WP_Widget {
  257.  
  258. function GetConnected() {
  259. parent::WP_Widget(false, $name = 'Sight Social Links');
  260. }
  261.  
  262. function widget($args, $instance) {
  263. extract( $args );
  264. $title = apply_filters('widget_title', $instance['title']);
  265. ?>
  266. <?php echo $before_widget; ?>
  267. <?php if ( $title )
  268. echo $before_title . $title . $after_title; else echo '<div class="widget-body clear">'; ?>
  269.  
  270. <!-- RSS -->
  271. <div class="getconnected_rss">
  272. <a href="<?php echo ( get_option('feedburner_url') )? get_option('feedburner_url') : get_bloginfo('rss2_url'); ?>">RSS Feed</a>
  273. <?php echo (get_option('feedburner_url') && function_exists('feedcount'))? feedcount( get_option('feedburner_url') ) : ''; ?>
  274. </div>
  275. <!-- /RSS -->
  276.  
  277. <!-- Twitter -->
  278. <?php if ( get_option('twitter_url') ) : ?>
  279. <div class="getconnected_twitter">
  280. <a href="<?php echo get_option('twitter_url'); ?>">Twitter</a>
  281. <span><?php if ( function_exists('twittercount') ) twittercount( get_option('twitter_url') ); ?> followers</span>
  282. </div>
  283. <?php endif; ?>
  284. <!-- /Twitter -->
  285.  
  286. <!-- Facebook -->
  287. <?php if ( get_option('fb_url') ) : ?>
  288. <div class="getconnected_fb">
  289. <a href="<?php echo get_option('fb_url'); ?>">Facebook</a>
  290. <span><?php echo get_option('fb_text'); ?></span>
  291. </div>
  292. <?php endif; ?>
  293. <!-- /Facebook -->
  294.  
  295. <!-- Flickr -->
  296. <?php if ( get_option('flickr_url') ) : ?>
  297. <div class="getconnected_flickr">
  298. <a href="<?php echo get_option('flickr_url'); ?>">Flickr group</a>
  299. <span><?php echo get_option('flickr_text'); ?></span>
  300. </div>
  301. <?php endif; ?>
  302. <!-- /Flickr -->
  303.  
  304. <!-- Behance -->
  305. <?php if ( get_option('behance_url') ) : ?>
  306. <div class="getconnected_behance">
  307. <a href="<?php echo get_option('behance_url'); ?>">Behance</a>
  308. <span><?php echo get_option('behance_text'); ?></span>
  309. </div>
  310. <?php endif; ?>
  311. <!-- /Behance -->
  312.  
  313. <!-- Delicious -->
  314. <?php if ( get_option('delicious_url') ) : ?>
  315. <div class="getconnected_delicious">
  316. <a href="<?php echo get_option('delicious_url'); ?>">Delicious</a>
  317. <span><?php echo get_option('delicious_text'); ?></span>
  318. </div>
  319. <?php endif; ?>
  320. <!-- /Delicious -->
  321.  
  322. <!-- Stumbleupon -->
  323. <?php if ( get_option('stumbleupon_url') ) : ?>
  324. <div class="getconnected_stumbleupon">
  325. <a href="<?php echo get_option('stumbleupon_url'); ?>">Stumbleupon</a>
  326. <span><?php echo get_option('stumbleupon_text'); ?></span>
  327. </div>
  328. <?php endif; ?>
  329. <!-- /Stumbleupon -->
  330.  
  331. <!-- Tumblr -->
  332. <?php if ( get_option('tumblr_url') ) : ?>
  333. <div class="getconnected_tumblr">
  334. <a href="<?php echo get_option('tumblr_url'); ?>">Tumblr</a>
  335. <span><?php echo get_option('tumblr_text'); ?></span>
  336. </div>
  337. <?php endif; ?>
  338. <!-- /Tumblr -->
  339.  
  340. <!-- Vimeo -->
  341. <?php if ( get_option('vimeo_url') ) : ?>
  342. <div class="getconnected_vimeo">
  343. <a href="<?php echo get_option('vimeo_url'); ?>">Vimeo</a>
  344. <span><?php echo get_option('vimeo_text'); ?></span>
  345. </div>
  346. <?php endif; ?>
  347. <!-- /Vimeo -->
  348.  
  349. <!-- Youtube -->
  350. <?php if ( get_option('youtube_url') ) : ?>
  351. <div class="getconnected_youtube">
  352. <a href="<?php echo get_option('youtube_url'); ?>">Youtube</a>
  353. <span><?php echo get_option('youtube_text'); ?></span>
  354. </div>
  355. <?php endif; ?>
  356. <!-- /Youtube -->
  357.  
  358. <?php echo $after_widget; ?>
  359. <?php
  360. }
  361.  
  362. function update($new_instance, $old_instance) {
  363. $instance = $old_instance;
  364. $instance['title'] = strip_tags($new_instance['title']);
  365.  
  366. update_option('feedburner_url', $_POST['feedburner_url']);
  367. update_option('twitter_url', $_POST['twitter_url']);
  368. update_option('fb_url', $_POST['fb_url']);
  369. update_option('flickr_url', $_POST['flickr_url']);
  370. update_option('behance_url', $_POST['behance_url']);
  371. update_option('delicious_url', $_POST['delicious_url']);
  372. update_option('stumbleupon_url', $_POST['stumbleupon_url']);
  373. update_option('tumblr_url', $_POST['tumblr_url']);
  374. update_option('vimeo_url', $_POST['vimeo_url']);
  375. update_option('youtube_url', $_POST['youtube_url']);
  376.  
  377. update_option('fb_text', $_POST['fb_text']);
  378. update_option('flickr_text', $_POST['flickr_text']);
  379. update_option('behance_text', $_POST['behance_text']);
  380. update_option('delicious_text', $_POST['delicious_text']);
  381. update_option('stumbleupon_text', $_POST['stumbleupon_text']);
  382. update_option('tumblr_text', $_POST['tumblr_text']);
  383. update_option('vimeo_text', $_POST['vimeo_text']);
  384. update_option('youtube_text', $_POST['youtube_text']);
  385.  
  386. return $instance;
  387. }
  388.  
  389. function form($instance) {
  390.  
  391. $title = esc_attr($instance['title']);
  392. ?>
  393. <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
  394.  
  395. <script type="text/javascript">
  396. (function($) {
  397. $(function() {
  398. $('.social_options').hide();
  399. $('.social_title').toggle(
  400. function(){ $(this).next().slideDown(100) },
  401. function(){ $(this).next().slideUp(100) }
  402. );
  403. })
  404. })(jQuery)
  405. </script>
  406.  
  407. <div style="margin-bottom: 5px;">
  408. <a href="javascript: void(0);" class="social_title" style="font-size: 13px; display: block; margin-bottom: 5px;">FeedBurner</a>
  409. <p class="social_options">
  410. <label for="feedburner_url"><?php _e('FeedBurner feed url:'); ?></label>
  411. <input type="text" name="feedburner_url" id="feedburner_url" class="widefat"
  412. value="<?php echo get_option('feedburner_url'); ?>"/>
  413. </p>
  414. </div>
  415.  
  416. <div style="margin-bottom: 5px;">
  417. <a href="javascript: void(0);" class="social_title" style="font-size: 13px; display: block; margin-bottom: 5px;">Twitter</a>
  418. <p class="social_options">
  419. <label for="twitter_url">Profile url:</label>
  420. <input type="text" name="twitter_url" id="twitter_url" class="widefat" value="<?php echo get_option('twitter_url'); ?>"/>
  421. </p>
  422. </div>
  423.  
  424. <div style="margin-bottom: 5px;">
  425. <a href="javascript: void(0);" class="social_title" style="font-size: 13px; display: block; margin-bottom: 5px;">Facebook</a>
  426. <p class="social_options">
  427. <label for="fb_url">Profile url:</label>
  428. <input type="text" name="fb_url" id="fb_url" class="widefat" value="<?php echo get_option('fb_url'); ?>"/>
  429. <label for="fb_text">Description:</label>
  430. <input type="text" name="fb_text" id="fb_text" class="widefat" value="<?php echo get_option('fb_text'); ?>"/>
  431. </p>
  432. </div>
  433.  
  434. <div style="margin-bottom: 5px;">
  435. <a href="javascript: void(0);" class="social_title" style="font-size: 13px; display: block; margin-bottom: 5px;">Flickr</a>
  436. <p class="social_options">
  437. <label for="flickr_url">Profile url:</label>
  438. <input type="text" name="flickr_url" id="flickr_url" class="widefat" value="<?php echo get_option('flickr_url'); ?>"/>
  439. <label for="flickr_text">Description:</label>
  440. <input type="text" name="flickr_text" id="flickr_text" class="widefat" value="<?php echo get_option('flickr_text'); ?>"/>
  441. </p>
  442. </div>
  443.  
  444. <div style="margin-bottom: 5px;">
  445. <a href="javascript: void(0);" class="social_title" style="font-size: 13px; display: block; margin-bottom: 5px;">Behance</a>
  446. <p class="social_options">
  447. <label for="behance_url">Profile url:</label>
  448. <input type="text" name="behance_url" id="behance_url" class="widefat" value="<?php echo get_option('behance_url'); ?>"/>
  449. <label for="behance_text">Description:</label>
  450. <input type="text" name="behance_text" id="behance_text" class="widefat" value="<?php echo get_option('behance_text'); ?>"/>
  451. </p>
  452. </div>
  453.  
  454. <div style="margin-bottom: 5px;">
  455. <a href="javascript: void(0);" class="social_title" style="font-size: 13px; display: block; margin-bottom: 5px;">Delicious</a>
  456. <p class="social_options">
  457. <label for="delicious_url">Profile url:</label>
  458. <input type="text" name="delicious_url" id="delicious_url" class="widefat" value="<?php echo get_option('delicious_url'); ?>"/>
  459. <label for="delicious_text">Description:</label>
  460. <input type="text" name="delicious_text" id="delicious_text" class="widefat" value="<?php echo get_option('delicious_text'); ?>"/>
  461. </p>
  462. </div>
  463.  
  464. <div style="margin-bottom: 5px;">
  465. <a href="javascript: void(0);" class="social_title" style="font-size: 13px; display: block; margin-bottom: 5px;">Stumbleupon</a>
  466. <p class="social_options">
  467. <label for="stumbleupon_url">Profile url:</label>
  468. <input type="text" name="stumbleupon_url" id="stumbleupon_url" class="widefat" value="<?php echo get_option('stumbleupon_url'); ?>"/>
  469. <label for="stumbleupon_text">Description:</label>
  470. <input type="text" name="stumbleupon_text" id="stumbleupon_text" class="widefat" value="<?php echo get_option('stumbleupon_text'); ?>"/>
  471. </p>
  472. </div>
  473.  
  474. <div style="margin-bottom: 5px;">
  475. <a href="javascript: void(0);" class="social_title" style="font-size: 13px; display: block; margin-bottom: 5px;">Tumblr</a>
  476. <p class="social_options">
  477. <label for="tumblr_url">Profile url:</label>
  478. <input type="text" name="tumblr_url" id="tumblr_url" class="widefat" value="<?php echo get_option('tumblr_url'); ?>"/>
  479. <label for="tumblr_text">Description:</label>
  480. <input type="text" name="tumblr_text" id="tumblr_text" class="widefat" value="<?php echo get_option('tumblr_text'); ?>"/>
  481. </p>
  482. </div>
  483.  
  484. <div style="margin-bottom: 5px;">
  485. <a href="javascript: void(0);" class="social_title" style="font-size: 13px; display: block; margin-bottom: 5px;">Vimeo</a>
  486. <p class="social_options">
  487. <label for="vimeo_url">Profile url:</label>
  488. <input type="text" name="vimeo_url" id="vimeo_url" class="widefat" value="<?php echo get_option('vimeo_url'); ?>"/>
  489. <label for="vimeo_text">Description:</label>
  490. <input type="text" name="vimeo_text" id="vimeo_text" class="widefat" value="<?php echo get_option('vimeo_text'); ?>"/>
  491. </p>
  492. </div>
  493.  
  494. <div style="margin-bottom: 5px;">
  495. <a href="javascript: void(0);" class="social_title" style="font-size: 13px; display: block; margin-bottom: 5px;">Youtube</a>
  496. <p class="social_options">
  497. <label for="youtube_url">Profile url:</label>
  498. <input type="text" name="youtube_url" id="youtube_url" class="widefat" value="<?php echo get_option('youtube_url'); ?>"/>
  499. <label for="youtube_text">Description:</label>
  500. <input type="text" name="youtube_text" id="youtube_text" class="widefat" value="<?php echo get_option('youtube_text'); ?>"/>
  501. </p>
  502. </div>
  503. <?php
  504. }
  505.  
  506. }
  507. add_action('widgets_init', create_function('', 'return register_widget("GetConnected");'));
  508.  
  509. class Recentposts_thumbnail extends WP_Widget {
  510.  
  511. function Recentposts_thumbnail() {
  512. parent::WP_Widget(false, $name = 'Sight Recent Posts');
  513. }
  514.  
  515. function widget($args, $instance) {
  516. extract( $args );
  517. $title = apply_filters('widget_title', $instance['title']);
  518. ?>
  519. <?php echo $before_widget; ?>
  520. <?php if ( $title ) echo $before_title . $title . $after_title; else echo '<div class="widget-body clear">'; ?>
  521.  
  522. <?php
  523. global $post;
  524. if (get_option('rpthumb_qty')) $rpthumb_qty = get_option('rpthumb_qty'); else $rpthumb_qty = 5;
  525. $q_args = array(
  526. 'numberposts' => $rpthumb_qty,
  527. );
  528. $rpthumb_posts = get_posts($q_args);
  529. foreach ( $rpthumb_posts as $post ) :
  530. setup_postdata($post);
  531. ?>
  532.  
  533. <a href="<?php the_permalink(); ?>" class="rpthumb clear">
  534. <?php if ( has_post_thumbnail() && !get_option('rpthumb_thumb') ) {
  535. the_post_thumbnail('mini-thumbnail');
  536. $offset = 'style="padding-left: 65px;"';
  537. }
  538. ?>
  539. <span class="rpthumb-title" <?php echo $offset; ?>><?php the_title(); ?></span>
  540. <span class="rpthumb-date" <?php echo $offset; unset($offset); ?>><?php the_time(__('M j, Y')) ?></span>
  541. </a>
  542.  
  543. <?php endforeach; ?>
  544.  
  545. <?php echo $after_widget; ?>
  546. <?php
  547. }
  548.  
  549. function update($new_instance, $old_instance) {
  550. $instance = $old_instance;
  551. $instance['title'] = strip_tags($new_instance['title']);
  552. update_option('rpthumb_qty', $_POST['rpthumb_qty']);
  553. update_option('rpthumb_thumb', $_POST['rpthumb_thumb']);
  554. return $instance;
  555. }
  556.  
  557. function form($instance) {
  558. $title = esc_attr($instance['title']);
  559. ?>
  560. <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
  561. <p><label for="rpthumb_qty">Number of posts: </label><input type="text" name="rpthumb_qty" id="rpthumb_qty" size="2" value="<?php echo get_option('rpthumb_qty'); ?>"/></p>
  562. <p><label for="rpthumb_thumb">Hide thumbnails: </label><input type="checkbox" name="rpthumb_thumb" id="rpthumb_thumb" <?php echo (get_option('rpthumb_thumb'))? 'checked="checked"' : ''; ?>/></p>
  563. <?php
  564. }
  565.  
  566. }
  567. add_action('widgets_init', create_function('', 'return register_widget("Recentposts_thumbnail");'));
  568.  
  569. /*** Comments ***/
  570.  
  571. function commentslist($comment, $args, $depth) {
  572. $GLOBALS['comment'] = $comment; ?>
  573. <li>
  574. <div id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
  575. <table>
  576. <tr>
  577. <td>
  578. <?php echo get_avatar($comment, 70, get_bloginfo('template_url').'/images/no-avatar.png'); ?>
  579. </td>
  580. <td>
  581. <div class="comment-meta">
  582. <?php printf(__('<p class="comment-author"><span>%s</span> says:</p>'), get_comment_author_link()) ?>
  583. <?php printf(__('<p class="comment-date">%s</p>'), get_comment_date('M j, Y')) ?>
  584. <?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
  585. </div>
  586. </td>
  587. <td>
  588. <div class="comment-text">
  589. <?php if ($comment->comment_approved == '0') : ?>
  590. <p><?php _e('Your comment is awaiting moderation.') ?></p>
  591. <br/>
  592. <?php endif; ?>
  593. <?php comment_text() ?>
  594. </div>
  595. </td>
  596. </tr>
  597. </table>
  598. </div>
  599. <?php
  600. }
  601.  
  602. /*** Misc ***/
  603.  
  604. function feedcount($feedurl='http://feeds.feedburner.com/wpshower') {
  605. $feedid = explode('/', $feedurl);
  606. $feedid = end($feedid);
  607. $twodayago = date('Y-m-d', strtotime('-2 days', time()));
  608. $onedayago = date('Y-m-d', strtotime('-1 days', time()));
  609. $today = date('Y-m-d');
  610.  
  611. $api = "https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=$feedid&dates=$twodayago,$onedayago";
  612.  
  613. //Initialize a cURL session
  614. $ch = curl_init();
  615. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  616. curl_setopt($ch, CURLOPT_URL, $api);
  617. $data = curl_exec($ch);
  618. $base_code = curl_getinfo($ch);
  619. curl_close($ch);
  620.  
  621. if ($base_code['http_code']=='401'){
  622. $burner_count_circulation = 'This feed does not permit Awareness API access';
  623. $burner_date = $today;
  624. } else {
  625.  
  626. $xml = new SimpleXMLElement($data); //Parse XML via SimpleXML Class
  627. $bis = $xml->attributes(); //Bis Contain first attribute, It usually is ok or fail in FeedBurner
  628.  
  629. if ($bis=='ok'){
  630. foreach ($xml->feed as $feed) {
  631. if ($feed->entry[1]['circulation']=='0'){
  632. $burner_count_circulation = $feed->entry[0]['circulation'];
  633. $burner_date = $feed->entry[0]['date'];
  634. } else {
  635. $burner_count_circulation = $feed->entry[1]['circulation'];
  636. $burner_date = $feed->entry[1]['date'];
  637. }
  638. }
  639. }
  640.  
  641. if ($bis=='fail'){
  642. switch ($xml->err['code']) {
  643. case 1:
  644. $burner_count_circulation = 'Feed Not Found';
  645. break;
  646. case 5:
  647. $burner_count_circulation = 'Missing required parameter (URI)';
  648. break;
  649. case 6:
  650. $burner_count_circulation = 'Malformed parameter (DATES)';
  651. break;
  652. }
  653. $burner_date = $today;
  654. }
  655.  
  656. }
  657. if ( $bis != 'fail' && $burner_count_circulation != '' ) {
  658. echo '<span>'.$burner_count_circulation.' readers</span>';
  659. } else {
  660. echo '<span>'.$burner_count_circulation.'</span>';
  661. }
  662. }
  663.  
  664. function twittercount($twitter_url='http://twitter.com/wpshower') {
  665. $twitterid = explode('/', $twitter_url);
  666. $twitterid = end($twitterid);
  667. $xml = @simplexml_load_file("http://twitter.com/users/show.xml?screen_name=$twitterid");
  668. echo $xml[0]->followers_count;
  669. }
  670.  
  671. function seo_title() {
  672. global $page, $paged;
  673. $sep = " | "; # delimiter
  674. $newtitle = get_bloginfo('name'); # default title
  675.  
  676. # Single & Page ##################################
  677. if (is_single() || is_page())
  678. $newtitle = single_post_title("", false);
  679.  
  680. # Category ######################################
  681. if (is_category())
  682. $newtitle = single_cat_title("", false);
  683.  
  684. # Tag ###########################################
  685. if (is_tag())
  686. $newtitle = single_tag_title("", false);
  687.  
  688. # Search result ################################
  689. if (is_search())
  690. $newtitle = "Search Result " . $s;
  691.  
  692. # Taxonomy #######################################
  693. if (is_tax()) {
  694. $curr_tax = get_taxonomy(get_query_var('taxonomy'));
  695. $curr_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); # current term data
  696. # if it's term
  697. if (!empty($curr_term)) {
  698. $newtitle = $curr_tax->label . $sep . $curr_term->name;
  699. } else {
  700. $newtitle = $curr_tax->label;
  701. }
  702. }
  703.  
  704. # Page number
  705. if ($paged >= 2 || $page >= 2)
  706. $newtitle .= $sep . sprintf('Page %s', max($paged, $page));
  707.  
  708. # Home & Front Page ########################################
  709. if (is_home() || is_front_page()) {
  710. $newtitle = get_bloginfo('name') . $sep . get_bloginfo('description');
  711. } else {
  712. $newtitle .= $sep . get_bloginfo('name');
  713. }
  714. return $newtitle;
  715. }
  716. add_filter('wp_title', 'seo_title');
  717.  
  718. function new_excerpt_length($length) {
  719. return 200;
  720. }
  721. add_filter('excerpt_length', 'new_excerpt_length');
  722.  
  723.  
  724. function getTinyUrl($url) {
  725. $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
  726. return $tinyurl;
  727. }
  728.  
  729. function smart_excerpt($string, $limit) {
  730. $words = explode(" ",$string);
  731. if ( count($words) >= $limit) $dots = '...';
  732. echo implode(" ",array_splice($words,0,$limit)).$dots;
  733. }
  734.  
  735. function comments_link_attributes(){
  736. return 'class="comments_popup_link"';
  737. }
  738. add_filter('comments_popup_link_attributes', 'comments_link_attributes');
  739.  
  740. function next_posts_attributes(){
  741. return 'class="nextpostslink"';
  742. }
  743. add_filter('next_posts_link_attributes', 'next_posts_attributes');
  744.  
  745. ?>
');