/**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     if ($instance['template'] == 2 || $instance['template'] == 3) {
         $birthdays = birthdays_widget_check_for_birthdays(true);
     } else {
         $birthdays = birthdays_widget_check_for_birthdays();
     }
     if (count($birthdays) >= 1) {
         $title = apply_filters('widget_title', $instance['title']);
         echo $args['before_widget'];
         if (!empty($title)) {
             echo $args['before_title'] . $title . $args['after_title'];
         }
         echo self::birthdays_code($instance, $birthdays);
         /* TODO make again ajax support?
                wp_enqueue_script('birthdays-widget-script', plugins_url('script.js', __FILE__ ), array('jquery'));
                wp_localize_script('birthdays-widget-script', 'ratingsL10n', array( 'admin_ajax_url' => admin_url('admin-ajax.php')));
            */
         echo $args['after_widget'];
     }
 }
function birthdays_widget_callback()
{
    @header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    @header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
    // Date in the past
    @header("Content-Type: text/html; charset=utf-8");
    //date_default_timezone_set( 'Europe/Athens' );
    $birthdays = birthdays_widget_check_for_birthdays();
    echo count($birthdays) . ";";
    $flag = true;
    foreach ($birthdays as $row) {
        if ($flag) {
            $flag = false;
        } else {
            echo ", ";
        }
        echo $row->name;
    }
    die;
}
예제 #3
0
function birthdays_shortcode($atts)
{
    $attr = shortcode_atts(array('class' => '', 'img_width' => '0', 'template' => '0'), $atts);
    if ($attr['template'] == 'default') {
        $attr['template'] = 0;
    } else {
        if ($attr['template'] == 'list') {
            $attr['template'] = 1;
        } else {
            if ($attr['template'] == 'calendar') {
                $attr['template'] = 2;
            } else {
                $attr['template'] = 0;
            }
        }
    }
    $instance = array('class' => $attr['class'], 'img_width' => $attr['img_width'], 'template' => $attr['template']);
    if ($attr['template'] == 2) {
        $birthdays = birthdays_widget_check_for_birthdays(true);
    } else {
        $birthdays = birthdays_widget_check_for_birthdays();
    }
    if (count($birthdays) >= 1) {
        return Birthdays_Widget::birthdays_code($instance, $birthdays);
    }
}