/wp-content/themes/thematic/library/extensions/widgets.php

https://github.com/digitalstrategyworks/Reese-WordPress · PHP · 179 lines · 126 code · 30 blank · 23 comment · 7 complexity · e7e73f104967d560d09b3691f010a85a MD5 · raw file

  1. <?php
  2. // CSS markup before the widget
  3. function thematic_before_widget() {
  4. $content = '<li id="%1$s" class="widgetcontainer %2$s">';
  5. return apply_filters('thematic_before_widget', $content);
  6. }
  7. // CSS markup after the widget
  8. function thematic_after_widget() {
  9. $content = '</li>';
  10. return apply_filters('thematic_after_widget', $content);
  11. }
  12. // CSS markup before the widget title
  13. function thematic_before_title() {
  14. $content = "<h3 class=\"widgettitle\">";
  15. return apply_filters('thematic_before_title', $content);
  16. }
  17. // CSS markup after the widget title
  18. function thematic_after_title() {
  19. $content = "</h3>\n";
  20. return apply_filters('thematic_after_title', $content);
  21. }
  22. /**
  23. * Search widget class
  24. *
  25. * @since 0.9.6.3
  26. */
  27. class THM_Widget_Search extends WP_Widget {
  28. function THM_Widget_Search() {
  29. $widget_ops = array('classname' => 'widget_search', 'description' => __( "A search form for your blog") );
  30. $this->WP_Widget('search', __('Search', 'thematic'), $widget_ops);
  31. }
  32. function widget( $args, $instance ) {
  33. extract($args);
  34. $title = apply_filters('widget_title', empty($instance['title']) ? __('Search', 'thematic') : $instance['title']);
  35. echo $before_widget;
  36. if ( $title )
  37. echo $before_title ?><label for="s"><?php echo $title ?></label><?php echo $after_title;
  38. // Use current theme search form if it exists
  39. get_search_form();
  40. echo $after_widget;
  41. }
  42. function form( $instance ) {
  43. $instance = wp_parse_args( (array) $instance, array( 'title' => '') );
  44. $title = $instance['title'];
  45. ?>
  46. <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 esc_attr($title); ?>" /></label></p>
  47. <?php
  48. }
  49. function update( $new_instance, $old_instance ) {
  50. $instance = $old_instance;
  51. $new_instance = wp_parse_args((array) $new_instance, array( 'title' => ''));
  52. $instance['title'] = strip_tags($new_instance['title']);
  53. return $instance;
  54. }
  55. }
  56. /**
  57. * Meta widget class
  58. *
  59. * Displays log in/out
  60. *
  61. * @since 0.9.6.3
  62. */
  63. class THM_Widget_Meta extends WP_Widget {
  64. function THM_Widget_Meta() {
  65. $widget_ops = array('classname' => 'widget_meta', 'description' => __( "Log in/out and admin", 'thematic') );
  66. $this->WP_Widget('meta', __('Meta', 'thematic'), $widget_ops);
  67. }
  68. function widget( $args, $instance ) {
  69. extract($args);
  70. $title = apply_filters('widget_title', empty($instance['title']) ? __('Meta', 'thematic') : $instance['title']);
  71. echo $before_widget;
  72. if ( $title )
  73. echo $before_title . $title . $after_title;
  74. ?>
  75. <ul>
  76. <?php wp_register(); ?>
  77. <li><?php wp_loginout(); ?></li>
  78. <?php wp_meta(); ?>
  79. </ul>
  80. <?php
  81. echo $after_widget;
  82. }
  83. function update( $new_instance, $old_instance ) {
  84. $instance = $old_instance;
  85. $instance['title'] = strip_tags($new_instance['title']);
  86. return $instance;
  87. }
  88. function form( $instance ) {
  89. $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
  90. $title = strip_tags($instance['title']);
  91. ?>
  92. <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <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); ?>" /></p>
  93. <?php
  94. }
  95. }
  96. /**
  97. * RSS links widget class
  98. *
  99. * @since 0.9.6.3
  100. */
  101. class THM_Widget_RSSlinks extends WP_Widget {
  102. function THM_Widget_RSSlinks() {
  103. $widget_ops = array( 'description' => __('Links to your posts and comments feed', 'thematic') );
  104. $this->WP_Widget( 'rss-links', __('RSS Links', 'thematic'), $widget_ops);
  105. }
  106. function widget($args, $instance) {
  107. extract($args);
  108. $title = apply_filters('widget_title', empty($instance['title']) ? __('RSS Links', 'thematic') : $instance['title']);
  109. echo $before_widget;
  110. if ( $title )
  111. echo $before_title . $title . $after_title;
  112. ?>
  113. <ul>
  114. <li><a href="<?php bloginfo('rss2_url') ?>" title="<?php echo esc_html(get_bloginfo('name')) ?> <?php _e('Posts RSS feed', 'thematic'); ?>" rel="alternate nofollow" type="application/rss+xml"><?php _e('All posts', 'thematic') ?></a></li>
  115. <li><a href="<?php bloginfo('comments_rss2_url') ?>" title="<?php echo esc_html(get_bloginfo('name')) ?> <?php _e('Comments RSS feed', 'thematic'); ?>" rel="alternate nofollow" type="application/rss+xml"><?php _e('All comments', 'thematic') ?></a></li>
  116. </ul>
  117. <?php
  118. echo $after_widget;
  119. }
  120. function update( $new_instance, $old_instance ) {
  121. $instance = $old_instance;
  122. $instance['title'] = strip_tags($new_instance['title']);
  123. return $instance;
  124. }
  125. function form( $instance ) {
  126. $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
  127. $title = strip_tags($instance['title']);
  128. ?>
  129. <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <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); ?>" /></p>
  130. <?php
  131. }
  132. }
  133. // Widget: RSS links; element controls for customizing text within Widget plugin
  134. function widget_thematic_rsslinks_control() {
  135. $options = $newoptions = get_option('widget_thematic_rsslinks');
  136. if ( $_POST["rsslinks-submit"] ) {
  137. $newoptions['title'] = strip_tags(stripslashes($_POST["rsslinks-title"]));
  138. }
  139. if ( $options != $newoptions ) {
  140. $options = $newoptions;
  141. update_option('widget_thematic_rsslinks', $options);
  142. }
  143. $title = htmlspecialchars($options['title'], ENT_QUOTES);
  144. ?>
  145. <p><label for="rsslinks-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="rsslinks-title" name="rsslinks-title" type="text" value="<?php echo $title; ?>" /></label></p>
  146. <input type="hidden" id="rsslinks-submit" name="rsslinks-submit" value="1" />
  147. <?php
  148. }
  149. ?>