예제 #1
0
    function widget($args, $instance)
    {
        $me = wp_get_current_user();
        if ($me->ID == 0) {
            return;
        }
        $recent_use = get_recent_use_for_user($me->ID);
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        if (sizeof($recent_use) == 0) {
            ?>
		<p>You have no recorded tool use yet. Do more stuff!</p>
		<?php 
        } else {
            echo "<table><thead><tr><th>Time</th><th>Tool</th><th>Use</th></tr></thead><tbody>";
            foreach ($recent_use as $use) {
                echo "<tr><td>" . $use['timestamp'] . "</td><td>" . $use['name'] . "</td><td>" . $use['amount_used'] . " " . $use['unit'] . " (\$" . $use['amount_to_charge'] . ")</td></tr>";
            }
            echo "</tbody></table>";
        }
        ?>
        <?php 
        echo $after_widget;
    }
예제 #2
0
function machines_my_account()
{
    $result = "<h2>My Tool Activity</h2>";
    $me = wp_get_current_user();
    if ($me->ID == 0) {
        return;
    }
    $recent_use = get_recent_use_for_user($me->ID, 50);
    if (sizeof($recent_use) == 0) {
        $result .= "<p>You have no recorded tool use yet. Do more stuff!</p>";
    } else {
        $result .= "<table><thead><tr><th>Time</th><th>Tool</th><th>Use</th></tr></thead><tbody>";
        foreach ($recent_use as $use) {
            $result .= "<tr><td>" . $use['timestamp'] . "</td><td>" . $use['name'] . "</td><td>" . $use['amount_used'] . " " . $use['unit'] . " (\$" . $use['amount_to_charge'] . ")</td></tr>";
        }
        $result .= "</tbody></table>";
    }
    return $result;
}