function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $number = isset($instance['number']) ? $instance['number'] : null;
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        $query = new WP_Query(array('post_type' => 'orbis_task', 'posts_per_page' => $number, 'orbis_task_assignee' => get_current_user_id(), 'no_found_rows' => true));
        if ($query->have_posts()) {
            ?>

			<ul class="post-list tasks">
				<?php 
            while ($query->have_posts()) {
                $query->the_post();
                ?>

					<?php 
                $due_at = get_post_meta(get_the_ID(), '_orbis_task_due_at', true);
                if (empty($due_at)) {
                    $due_at_ouput = '&mdash;';
                } else {
                    $seconds = strtotime($due_at);
                    $delta = $seconds - time();
                    $days = round($delta / (3600 * 24));
                    if ($days > 0) {
                        $label = 'label-success';
                    } else {
                        $label = 'label-danger';
                    }
                    $due_at_ouput = sprintf(__('%d days', 'orbis_tasks'), $days);
                }
                ?>

					<li>
						<a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a> <span class="label <?php 
                echo $label;
                ?>
"><?php 
                echo $due_at_ouput;
                ?>
</span> <br />
						
						<span class="entry-meta">
							<?php 
                _e('Project:', 'orbis');
                ?>
 <?php 
                orbis_task_project();
                ?>
 | <?php 
                _e('Deadline:', 'orbis');
                ?>
 <?php 
                orbis_task_due_at();
                ?>
 | <?php 
                _e('Time:', 'orbis');
                ?>
 <?php 
                orbis_task_time();
                ?>
						</span>
					</li>

				<?php 
            }
            ?>
			</ul>

			<footer>
				<a href="<?php 
            echo add_query_arg('orbis_task_assignee', get_current_user_id(), get_post_type_archive_link('orbis_task'));
            ?>
" class="btn btn-default"><?php 
            _e('Show all tasks', 'orbis');
            ?>
</a>
			</footer>

		<?php 
        } else {
            ?>
		
			<div class="content">
				<p class="alt"><?php 
            _e('Grab a beer, no tasks for you.', 'orbis');
            ?>
</p>
			</div>
		
		<?php 
        }
        wp_reset_postdata();
        ?>

		<?php 
        echo $after_widget;
        ?>
		
		<?php 
    }
Exemplo n.º 2
0
							<dt><?php 
    _e('Posted by', 'orbis');
    ?>
</dt>
							<dd><?php 
    echo get_the_author();
    ?>
</dd>

							<dt><?php 
    _e('Project', 'orbis');
    ?>
</dt>
							<dd><?php 
    orbis_task_project();
    ?>
</dd>

							<dt><?php 
    _e('Assignee', 'orbis');
    ?>
</dt>
							<dd><?php 
    orbis_task_assignee();
    ?>
</dd>

							<dt><?php 
    _e('Deadline', 'orbis');
    ?>