/presswork/admin/inc/widget-flickr.php

https://github.com/tjankov/PressWork · PHP · 60 lines · 46 code · 9 blank · 5 comment · 1 complexity · 94e6c259d2ad42b8a82bc92714de914e MD5 · raw file

  1. <?php
  2. /**
  3. * Functionality for Flickr widget
  4. *
  5. * @since PressWork 1.0
  6. */
  7. class PW_Flickr_Widget extends WP_Widget {
  8. function PW_Flickr_Widget() {
  9. $widget_ops = array('classname' => 'pw_flickr_feed', 'description' => __('Displays your flickr photos', "presswork") );
  10. $this->WP_Widget('pw_flickr_feed', __('PW - Flickr Feed', "presswork"), $widget_ops);
  11. }
  12. function widget($args, $instance) {
  13. extract($args, EXTR_SKIP);
  14. $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
  15. $UserID = $instance['UserID'];
  16. $NumPics = $instance['NumPics'];
  17. $link = $instance['link'];
  18. echo $before_widget;
  19. if(!empty($title)) { echo $before_title . $title . $after_title; };
  20. $feed = "http://www.flickr.com/badge_code_v2.gne?count=" . $NumPics . "&display=latest&size=s&layout=x&source=user&user=" .$UserID;
  21. echo '<div id="flickr_tab">';
  22. echo '<script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?count=' . $NumPics . '&display=latest&size=s&layout=x&source=user&user=' .$UserID .'"></script>';
  23. echo '</div>';
  24. ?>
  25. <p class="clear flickr-link"><a href="http://flickr.com/photos/<?php echo $UserID; ?>"><?php echo $link; ?></a></p>
  26. <?php
  27. echo $after_widget;
  28. }
  29. function form($instance) {
  30. $instance = wp_parse_args( (array) $instance, array( 'title' => 'Flickr Photos', 'UserID' => '', 'link' => 'Find Me on Flickr', 'NumPics' => '9' ) );
  31. $title = strip_tags($instance['title']);
  32. $UserID = strip_tags($instance['UserID']);
  33. $NumPics = strip_tags($instance['NumPics']);
  34. $link = strip_tags($instance['link']);
  35. ?>
  36. <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', "presswork"); ?>: <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>
  37. <p><label for="<?php echo $this->get_field_id('UserID'); ?>"><?php _e('UserID', "presswork"); ?>: <input class="widefat" id="<?php echo $this->get_field_id('UserID'); ?>" name="<?php echo $this->get_field_name('UserID'); ?>" type="text" value="<?php echo esc_attr($UserID); ?>" /></label><br /><a href="http://idgettr.com/" target="_blank"><?php _e('Flickr idGettr', "presswork"); ?></a></p>
  38. <p><label for="<?php echo $this->get_field_id('NumPics'); ?>"><?php _e('Number of Photos', "presswork"); ?>: <input class="widefat" id="<?php echo $this->get_field_id('NumPics'); ?>" name="<?php echo $this->get_field_name('NumPics'); ?>" type="text" value="<?php echo esc_attr($NumPics); ?>" /></label></p>
  39. <p><label for="<?php echo $this->get_field_id('link'); ?>"><?php _e('Link Text', "presswork"); ?>: <input class="widefat" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" type="text" value="<?php echo esc_attr($link); ?>" /></label></p>
  40. <?php
  41. }
  42. function update($new_instance, $old_instance) {
  43. $instance = $old_instance;
  44. $instance['title'] = strip_tags($new_instance['title']);
  45. $instance['UserID'] = strip_tags($new_instance['UserID']);
  46. $instance['link'] = strip_tags($new_instance['link']);
  47. $instance['NumPics'] = strip_tags($new_instance['NumPics']);
  48. return $instance;
  49. }
  50. }
  51. register_widget('PW_Flickr_Widget');