Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // =============================== Drink Specials Widget ======================================================
- class drinkSpecials extends WP_Widget {
- function drinkSpecials() {
- //Constructor
- $widget_ops = array('classname' => 'drinkSpecials', 'description' => __('List of Drink Specials') );
- $this->WP_Widget('drinkSpecials', __('Drink Specials'), $widget_ops);
- }
- function widget($args, $instance) {
- // prints the widget
- extract($args, EXTR_SKIP);
- echo $before_widget;
- $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
- ?>
- <?php
- $current_day = date('l').'_drinks';
- // The Query
- add_filter('posts_where','yoursite_posts_where',10,2);
- query_posts('meta_key='.$current_day.'&orderby=rand&showposts=3');
- echo '<div class="widget">';
- echo '<h3 class="clearfix">';
- echo '<span class="f1">';
- echo 'Today\'s Specials';
- echo '</span></h3></div>';
- echo '<div class="company_info">';
- // The Loop
- while ( have_posts() ) : the_post();
- echo '<p> <span class="i_drink">';
- echo '<a href=';
- echo get_permalink();
- echo '>';
- echo the_title();
- echo '</a><br>';
- echo 'Special: ';
- echo get_post_meta(get_the_id(), $current_day, $single=true);
- echo '</span> </p>';
- endwhile;
- echo '</div>';
- echo '<br><br>';
- // Reset Query
- remove_filter('posts_where','yoursite_posts_where');
- wp_reset_query();
- echo $after_widget;
- }
- function update($new_instance, $old_instance) {
- //save the widget
- $instance = $old_instance;
- $instance['title'] = strip_tags($new_instance['title']);
- return $instance;
- }
- function form($instance)
- {
- $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
- $title = $instance['title'];
- ?>
- <p><label for="<?php echo $this->get_field_id('title'); ?>">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 attribute_escape($title); ?>" /></label></p>
- <?php
- }
- }
- register_widget('drinkSpecials');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement