Changeset 1544877
- Timestamp:
- 12/02/2016 10:36:55 PM (9 years ago)
- Location:
- traffic-lights
- Files:
-
- 12 added
- 4 edited
-
tags/0.13 (added)
-
tags/0.13/bilder (added)
-
tags/0.13/bilder/green-off.png (added)
-
tags/0.13/bilder/green.png (added)
-
tags/0.13/bilder/red-off.png (added)
-
tags/0.13/bilder/red.png (added)
-
tags/0.13/bilder/yellow-off.png (added)
-
tags/0.13/bilder/yellow.png (added)
-
tags/0.13/draw-traffic-lights.php (added)
-
tags/0.13/readme.txt (added)
-
tags/0.13/traffic-lights-widget.php (added)
-
tags/0.13/traffic-lights.php (added)
-
trunk/draw-traffic-lights.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/traffic-lights-widget.php (modified) (5 diffs)
-
trunk/traffic-lights.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
traffic-lights/trunk/draw-traffic-lights.php
r810729 r1544877 2 2 3 3 4 if( function_exists('user_begins_to_work')){5 $all_users=get_users();6 $somebody_is_green=false;7 $green=false;8 foreach($all_users as $user){9 4 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); 5 if 6 ( function_exists('user_begins_to_work')) 7 { 8 $all_users=get_users(); 9 $somebody_is_green=false; 10 $green=false; 11 foreach 12 ($all_users as $user) 13 { 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); 13 17 14 if ($in_office=="yes" && $in_pause=="no") 15 { 16 update_option('ampel','gruen'); 17 $green=true; 18 break; 19 }else if($in_pause=="yes" && $green==false){ 20 update_option('ampel','gelb'); 21 break; 22 23 }else{ 24 update_option('ampel','rot'); 25 26 27 }} 18 if ($in_office=="yes" && $in_pause=="no") 19 { 20 update_option('ampel', 'gruen'); 21 $green=true; 22 break; 23 }else if 24 ($in_pause=="yes" && $green==false) 25 { 26 update_option('ampel', 'gelb'); 27 break; 28 28 29 }else 30 { 31 update_option('ampel', 'rot'); 32 33 }} 29 34 30 35 } 36 // Eine Funktion um eine Ampel anzuzeigen 37 function draw_traffic_light() 38 { 39 echo "<div style=\"line-height:0px;padding:0;text-decoration:none;\">"; 40 $ampel_url=plugins_url( 'bilder/' , __FILE__ ); 31 41 42 if 43 (isset($_GET['ampel']) && current_user_can( 'change_traffic_light',0 ) ) 44 { 45 update_option('ampel', $_GET['ampel']); 46 } 47 $farbe=get_option('ampel'); 32 48 33 34 // Eine Funktion um eine Ampel anzuzeigen 35 function draw_traffic_light(){ 36 echo "<div style=\"line-height:0px;padding:0;text-decoration:none;\">"; 37 $ampel_url=plugins_url( 'bilder/' , __FILE__ ); 38 39 if(isset($_GET['ampel']) && is_user_logged_in() ){ 40 update_option('ampel',$_GET['ampel']); 41 } 42 43 $farbe=get_option('ampel'); 44 45 if ($farbe=="rot"){ 46 echo "<img src=\"".$ampel_url."red.png\" /><br />"; 47 }else{ 48 if ( is_user_logged_in() ){echo "<a href=\"?ampel=rot\">";}else{} 49 echo "<img src=\"".$ampel_url."red-off.png\" />"; 50 if ( is_user_logged_in() ){echo "</a>";} 51 echo "<br />"; 52 } 53 54 if ($farbe=="gelb"){ 55 echo "<img src=\"".$ampel_url."yellow.png\" /><br />"; 56 }else{ 57 if ( is_user_logged_in() ){echo "<a href=\"?ampel=gelb\">";} 58 echo "<img src=\"".$ampel_url."yellow-off.png\" />"; 59 if ( is_user_logged_in() ){echo "</a>";} 60 echo "<br />"; 61 } 62 63 if ($farbe=="gruen"){ 64 echo "<img src=\"".$ampel_url."green.png\" /><br />"; 65 }else{ 66 if ( is_user_logged_in() ){echo "<a href=\"?ampel=gruen\">";} 67 echo "<img src=\"".$ampel_url."green-off.png\" />"; 68 if ( is_user_logged_in() ){echo "</a>";} 69 echo "<br />"; 70 } 71 72 echo "</div>"; 73 49 if ($farbe=="rot") 50 { 51 echo "<img src=\"".$ampel_url."red.png\" /><br />"; 52 }else 53 { 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>"; 61 } 62 echo "<br />"; 63 } 64 if ($farbe=="gelb") 65 { 66 echo "<img src=\"".$ampel_url."yellow.png\" /><br />"; 67 }else 68 { 69 if ( current_user_can( 'change_traffic_light',0 ) ) 70 {echo "<a href=\"?ampel=gelb\">"; 71 } 72 echo "<img src=\"".$ampel_url."yellow-off.png\" />"; 73 if ( current_user_can( 'change_traffic_light',0 ) ) 74 {echo "</a>"; 75 } 76 echo "<br />"; 77 } 78 if ($farbe=="gruen") 79 { 80 echo "<img src=\"".$ampel_url."green.png\" /><br />"; 81 }else 82 { 83 if ( current_user_can( 'change_traffic_light',0 ) ) 84 {echo "<a href=\"?ampel=gruen\">"; 85 } 86 echo "<img src=\"".$ampel_url."green-off.png\" />"; 87 if ( current_user_can( 'change_traffic_light',0 ) ) 88 {echo "</a>"; 89 } 90 echo "<br />"; 91 } 92 echo "</div>"; 74 93 75 94 } -
traffic-lights/trunk/readme.txt
r1302538 r1544877 4 4 Tags: traffic,lights,status 5 5 Requires at least: 3.0 6 Tested up to: 4. 57 Stable tag: 0. 136 Tested up to: 4.7 7 Stable tag: 0.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 39 39 == Changelog == 40 40 41 = 0.2 = capabilities added 41 42 = 0.1 = Initial release -
traffic-lights/trunk/traffic-lights-widget.php
r809637 r1544877 1 1 <?php 2 3 2 class traffic_light_Widget extends WP_Widget { 4 5 3 /** 6 4 * Register widget with WordPress. 7 5 */ 8 function __construct() { 6 function __construct() 7 { 9 8 parent::__construct( 10 9 'traffic_light_Widget', // Base ID … … 22 21 * @param array $instance Saved values from database. 23 22 */ 24 public function widget( $args, $instance ) { 23 public function widget( $args, $instance ) 24 { 25 25 $title = apply_filters( 'widget_title', $instance['title'] ); 26 26 … … 39 39 * @param array $instance Previously saved values from database. 40 40 */ 41 public function form( $instance ) { 42 if ( isset( $instance[ 'title' ] ) ) { 41 public function form( $instance ) 42 { 43 if ( isset( $instance[ 'title' ] ) ) 44 { 43 45 $title = $instance[ 'title' ]; 44 46 } 45 else { 47 else 48 { 46 49 $title = __( 'New title', 'text_domain' ); 47 50 } 48 ?>51 ?> 49 52 <p> 50 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> 51 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> 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 ?>" /> 52 60 </p> 53 <?php 61 <?php 54 62 } 55 63 … … 64 72 * @return array Updated safe values to be saved. 65 73 */ 66 public function update( $new_instance, $old_instance ) { 74 public function update( $new_instance, $old_instance ) 75 { 67 76 $instance = array(); 68 77 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; … … 72 81 73 82 } // class traffic_light_Widget 74 75 76 77 83 ?> -
traffic-lights/trunk/traffic-lights.php
r898144 r1544877 4 4 Plugin URI: http://www.wp-plugin-dev.com 5 5 Description: A simple Traffic Light to show some state for visitor 6 Version: 0. 136 Version: 0.2 7 7 Author: wp-plugin-dev.com 8 8 Author URI: http://www.wp-plugin-dev.com 9 9 License: GPLv2 or later 10 11 10 Graphic from http://www.openclipart.org/ 12 13 11 Dies ist eine einfache Ampel. Hauptsächlich ein Lernprojekt. 14 12 Jedes WordPress Plugin hat die oben gemachten Angaben 15 16 13 */ 17 18 14 // um das Haupt Plugin File nicht so sehr mit Code voll zu machen 19 15 // rufen wir nur die anderen Files auf. 16 // Das Dokument was die Ampel malt 17 include 'draw-traffic-lights.php'; 18 include 'traffic-lights-widget.php'; 20 19 21 // Das Dokument was die Ampel malt 22 include('draw-traffic-lights.php'); 23 include('traffic-lights-widget.php'); 20 register_activation_hook( __FILE__, 'add_traffic_lights_caps' ); 21 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' ); 30 } 31 } 32 24 33 25 34 // register traffic_light_Widget widget 26 function register_traffic_light_Widget() { 27 register_widget( 'traffic_light_Widget' ); 35 function register_traffic_light_Widget() 36 { 37 register_widget( 'traffic_light_Widget' ); 28 38 } 39 29 40 add_action( 'widgets_init', 'register_traffic_light_Widget' ); 30 41 31 42 // Function that outputs the contents of the dashboard widget 32 function dashboard_widget_function_traffic_light() { 43 function dashboard_widget_function_traffic_light() 44 { 33 45 draw_traffic_light(); 34 46 } 35 47 36 48 // Function used in the action hook 37 function add_dashboard_widgets_tl() { 49 function add_dashboard_widgets_tl() 50 { 38 51 wp_add_dashboard_widget('dashboard_widget', 'Traffic Light Dashboard Widget', 'dashboard_widget_function_traffic_light'); 39 52 } … … 42 55 add_action('wp_dashboard_setup', 'add_dashboard_widgets_tl' ); 43 56 44 add_shortcode("trafficlights", "trafficlight_shorty");57 add_shortcode("trafficlights", "trafficlight_shorty"); 45 58 46 function trafficlight_shorty(){ 47 ob_start(); 48 draw_traffic_light(); 49 return ob_get_clean(); 59 function trafficlight_shorty() 60 { 61 ob_start(); 62 draw_traffic_light(); 63 return ob_get_clean(); 50 64 } 51 65
Note: See TracChangeset
for help on using the changeset viewer.