Plugin Directory

Changeset 1826576


Ignore:
Timestamp:
02/21/2018 11:46:46 PM (8 years ago)
Author:
theode
Message:

WordPress 5.0 Update

Location:
traffic-lights/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • traffic-lights/trunk/draw-traffic-lights.php

    r1544877 r1826576  
    11<?php
    22
    3 
    4 
    5 if
    6 ( function_exists('user_begins_to_work'))
     3if (function_exists('user_begins_to_work'))
    74{
    8     $all_users=get_users();
    9     $somebody_is_green=false;
    10     $green=false;
    11     foreach
    12     ($all_users as $user)
     5    $all_users = get_users();
     6    $somebody_is_green = false;
     7    $green = false;
     8    foreach($all_users as $user)
    139    {
    14         $the_user_id=$user->data->ID;
    15         $in_office=get_user_meta($the_user_id, "in_office", true);
    16         $in_pause=get_user_meta($the_user_id, "in_pause", true);
    17 
    18         if ($in_office=="yes" && $in_pause=="no")
     10        $the_user_id = $user->data->ID;
     11        $in_office = get_user_meta($the_user_id, "in_office", true);
     12        $in_pause = get_user_meta($the_user_id, "in_pause", true);
     13        if ($in_office == "yes" && $in_pause == "no")
    1914        {
    2015            update_option('ampel', 'gruen');
    21             $green=true;
     16            $green = true;
    2217            break;
    23         }else if
    24             ($in_pause=="yes" && $green==false)
    25             {
    26                 update_option('ampel', 'gelb');
    27                 break;
    28 
    29             }else
     18        }
     19        else
     20        if ($in_pause == "yes" && $green == false)
     21        {
     22            update_option('ampel', 'gelb');
     23            break;
     24        }
     25        else
    3026        {
    3127            update_option('ampel', 'rot');
     28        }
     29    }
     30}
    3231
    33         }}
     32// Eine Funktion um eine Ampel anzuzeigen
    3433
    35 }
    36 // Eine Funktion um eine Ampel anzuzeigen
    3734function draw_traffic_light()
    3835{
    3936    echo "<div style=\"line-height:0px;padding:0;text-decoration:none;\">";
    40     $ampel_url=plugins_url( 'bilder/' , __FILE__ );
    41 
    42     if
    43     (isset($_GET['ampel']) && current_user_can( 'change_traffic_light',0 ) )
     37    $ampel_url = plugins_url('bilder/', __FILE__);
     38    if (isset($_GET['ampel']) && current_user_can('change_traffic_light', 0))
    4439    {
    4540        update_option('ampel', $_GET['ampel']);
    4641    }
    47     $farbe=get_option('ampel');
    4842
    49     if ($farbe=="rot")
     43    $farbe = get_option('ampel');
     44    if ($farbe == "rot")
    5045    {
    51         echo "<img src=\"".$ampel_url."red.png\" /><br />";
    52     }else
     46        echo "<img src=\"" . $ampel_url . "red.png\" /><br />";
     47    }
     48    else
    5349    {
    54         if ( current_user_can( 'change_traffic_light',0 ) )
    55             {echo "<a href=\"?ampel=rot\">";
    56         }else
    57             {}
    58         echo "<img src=\"".$ampel_url."red-off.png\" />";
    59         if ( current_user_can( 'change_traffic_light',0 ) )
    60             {echo "</a>";
     50        if (current_user_can('change_traffic_light', 0))
     51        {
     52            echo "<a href=\"?ampel=rot\">";
    6153        }
     54        else
     55        {
     56        }
     57
     58        echo "<img src=\"" . $ampel_url . "red-off.png\" />";
     59        if (current_user_can('change_traffic_light', 0))
     60        {
     61            echo "</a>";
     62        }
     63
    6264        echo "<br />";
    6365    }
    64     if ($farbe=="gelb")
     66
     67    if ($farbe == "gelb")
    6568    {
    66         echo "<img src=\"".$ampel_url."yellow.png\" /><br />";
    67     }else
     69        echo "<img src=\"" . $ampel_url . "yellow.png\" /><br />";
     70    }
     71    else
    6872    {
    69         if ( current_user_can( 'change_traffic_light',0 ) )
    70             {echo "<a href=\"?ampel=gelb\">";
     73        if (current_user_can('change_traffic_light', 0))
     74        {
     75            echo "<a href=\"?ampel=gelb\">";
    7176        }
    72         echo "<img src=\"".$ampel_url."yellow-off.png\" />";
    73         if ( current_user_can( 'change_traffic_light',0 ) )
    74             {echo "</a>";
     77
     78        echo "<img src=\"" . $ampel_url . "yellow-off.png\" />";
     79        if (current_user_can('change_traffic_light', 0))
     80        {
     81            echo "</a>";
    7582        }
     83
    7684        echo "<br />";
    7785    }
    78     if ($farbe=="gruen")
     86
     87    if ($farbe == "gruen")
    7988    {
    80         echo "<img src=\"".$ampel_url."green.png\" /><br />";
    81     }else
     89        echo "<img src=\"" . $ampel_url . "green.png\" /><br />";
     90    }
     91    else
    8292    {
    83         if ( current_user_can( 'change_traffic_light',0 ) )
    84             {echo "<a href=\"?ampel=gruen\">";
     93        if (current_user_can('change_traffic_light', 0))
     94        {
     95            echo "<a href=\"?ampel=gruen\">";
    8596        }
    86         echo "<img src=\"".$ampel_url."green-off.png\" />";
    87         if ( current_user_can( 'change_traffic_light',0 ) )
    88             {echo "</a>";
     97
     98        echo "<img src=\"" . $ampel_url . "green-off.png\" />";
     99        if (current_user_can('change_traffic_light', 0))
     100        {
     101            echo "</a>";
    89102        }
     103
    90104        echo "<br />";
    91105    }
     106
    92107    echo "</div>";
    93 
    94108}
    95109
  • traffic-lights/trunk/readme.txt

    r1544880 r1826576  
    44Tags: traffic,lights,status
    55Requires at least: 3.0
    6 Tested up to: 4.7
    7 Stable tag: 1.0
     6Tested up to: 5.0
     7Stable tag: 1.01
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1717As traffic light function for projects every logged in user can choose between red, amber and green.
    1818
    19 You have it as dashboard widget, as sidebar widget and shortcode [trafficlights].
     19You have it as dashboard widget, as sidebar widget and shortcode [trafficlights] or [traffic-lights].
    2020
    2121This Version can be connected with "HRM Work Tracking" and is showing Green for somebody is present, yellow somebody is there but in pause and red nobody is there.
  • traffic-lights/trunk/traffic-lights-widget.php

    r1544877 r1826576  
    11<?php
    2 class traffic_light_Widget extends WP_Widget {
     2class traffic_light_Widget extends WP_Widget
     3
     4{
    35    /**
    46     * Register widget with WordPress.
     
    68    function __construct()
    79    {
    8         parent::__construct(
    9             'traffic_light_Widget', // Base ID
    10             __('Traffic Lights', 'text_domain'), // Name
    11             array( 'description' => __( 'A traffic Light Widget', 'text_domain' ), ) // Args
     10        parent::__construct('traffic_light_Widget', // Base ID
     11        __('Traffic Lights', 'text_domain') , // Name
     12        array(
     13            'description' => __('A traffic Light Widget', 'text_domain') ,
     14        ) // Args
    1215        );
    1316    }
     
    2124     * @param array $instance Saved values from database.
    2225     */
    23     public function widget( $args, $instance )
     26    public function widget($args, $instance)
    2427    {
    25         $title = apply_filters( 'widget_title', $instance['title'] );
    26 
     28        if (! empty( $instance['title'] ) )
     29        {
     30            $title = apply_filters('widget_title', $instance['title'] );
     31        }
     32       
    2733        echo $args['before_widget'];
    28         if ( ! empty( $title ) )
    29             echo $args['before_title'] . $title . $args['after_title'];
     34        if (!empty($title)) echo $args['before_title'] . $title . $args['after_title'];
    3035        draw_traffic_light();
    3136        echo $args['after_widget'];
     
    3944     * @param array $instance Previously saved values from database.
    4045     */
    41     public function form( $instance )
     46    public function form($instance)
    4247    {
    43         if ( isset( $instance[ 'title' ] ) )
     48        if (isset($instance['title']))
    4449        {
    45             $title = $instance[ 'title' ];
     50            $title = $instance['title'];
    4651        }
    4752        else
    4853        {
    49             $title = __( 'New title', 'text_domain' );
     54            $title = __('New title', 'text_domain');
    5055        }
     56
    5157?>
    5258        <p>
    53         <label for="<?php echo $this->get_field_id( 'title' );
    54         ?>"><?php _e( 'Title:' );
    55         ?></label>
    56         <input class="widefat" id="<?php echo $this->get_field_id( 'title' );
    57         ?>" name="<?php echo $this->get_field_name( 'title' );
    58         ?>" type="text" value="<?php echo esc_attr( $title );
    59         ?>" />
     59        <label for="<?php
     60        echo $this->get_field_id('title');
     61?>"><?php
     62        _e('Title:');
     63?></label>
     64        <input class="widefat" id="<?php
     65        echo $this->get_field_id('title');
     66?>" name="<?php
     67        echo $this->get_field_name('title');
     68?>" type="text" value="<?php
     69        echo esc_attr($title);
     70?>" />
    6071        </p>
    6172        <?php
     
    7283     * @return array Updated safe values to be saved.
    7384     */
    74     public function update( $new_instance, $old_instance )
     85    public function update($new_instance, $old_instance)
    7586    {
    7687        $instance = array();
    77         $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
    78 
     88        $instance['title'] = (!empty($new_instance['title'])) ? strip_tags($new_instance['title']) : '';
    7989        return $instance;
    8090    }
     91} // class traffic_light_Widget
    8192
    82 } // class traffic_light_Widget
    8393?>
  • traffic-lights/trunk/traffic-lights.php

    r1544880 r1826576  
    44Plugin URI: http://www.wp-plugin-dev.com
    55Description: A simple Traffic Light to show some state for visitor
    6 Version: 1.0
     6Version: 1.01
    77Author: wp-plugin-dev.com
    8 Author URI: http://www.wp-plugin-dev.com
     8Author URI: https://www.wp-plugin-dev.com
    99License: GPLv2 or later
    1010Graphic from http://www.openclipart.org/
     
    1212Jedes WordPress Plugin hat die oben gemachten Angaben
    1313*/
     14
    1415// um das Haupt Plugin File nicht so sehr mit Code voll zu machen
    1516// rufen wir nur die anderen Files auf.
    1617// Das Dokument was die Ampel malt
     18
    1719include 'draw-traffic-lights.php';
     20
    1821include 'traffic-lights-widget.php';
    1922
    20 register_activation_hook( __FILE__, 'add_traffic_lights_caps' );
     23register_activation_hook(__FILE__, 'add_traffic_lights_caps');
    2124
    22 function add_traffic_lights_caps() {
    23        
    24        $roles = array ('subscriber','author','editor','contributor','administrator');
    25        
    26     foreach ($roles as $role)
    27     {
    28         $role = get_role( $role );
    29         $role->add_cap( 'change_traffic_light' );
     25function add_traffic_lights_caps()
     26{
     27    $roles = array(
     28        'subscriber',
     29        'author',
     30        'editor',
     31        'contributor',
     32        'administrator'
     33    );
     34    foreach($roles as $role)
     35    {
     36        $role = get_role($role);
     37        $role->add_cap('change_traffic_light');
    3038    }
    3139}
    3240
     41// register traffic_light_Widget widget
    3342
    34 // register traffic_light_Widget widget
    3543function register_traffic_light_Widget()
    3644{
    37     register_widget( 'traffic_light_Widget' );
     45    register_widget('traffic_light_Widget');
    3846}
    3947
    40 add_action( 'widgets_init', 'register_traffic_light_Widget' );
     48add_action('widgets_init', 'register_traffic_light_Widget');
    4149
    4250// Function that outputs the contents of the dashboard widget
     51
    4352function dashboard_widget_function_traffic_light()
    4453{
     
    4756
    4857// Function used in the action hook
     58
    4959function add_dashboard_widgets_tl()
    5060{
     
    5363
    5464// Register the new dashboard widget with the 'wp_dashboard_setup' action
    55 add_action('wp_dashboard_setup', 'add_dashboard_widgets_tl' );
    5665
     66add_action('wp_dashboard_setup', 'add_dashboard_widgets_tl');
    5767add_shortcode("trafficlights", "trafficlight_shorty");
     68add_shortcode("traffic-lights", "trafficlight_shorty");
    5869
    5970function trafficlight_shorty()
Note: See TracChangeset for help on using the changeset viewer.