Plugin Directory

Changeset 1649763


Ignore:
Timestamp:
05/02/2017 03:35:05 PM (9 years ago)
Author:
bleeptrack
Message:

shortcodes

Location:
live-widget-luftdaten
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • live-widget-luftdaten/trunk/live-widget-luftdaten.php

    r1649150 r1649763  
    44Plugin URI: http://www.bleeptrack.de/feinstaub-widget/
    55Description: Plugin with widget to show live data from a luftdaten.info sensor
    6 Version: 1.1.0
     6Version: 1.2.0
    77Author: Bleeptrack
    88Author URI: http://www.bleeptrack.de/
     
    387387                   
    388388            $name=$values->value_type;
    389             if (!array_key_exists($name, $instance)) {
     389            //if (!array_key_exists($name, $instance)) {
    390390                $this->items[$name]=$name;
    391             }
     391            //}
    392392           
    393393        }
     
    423423
    424424
     425///shortcodes
     426
     427// [feinstaublive title="Titel" sensorIDs="260,262"]
     428function feinstaublive($atts) {
     429   
     430    $widget_name = "LuftdatenWidget";
     431
     432    if(isset($atts['title'])){
     433        $title = $atts['title'];
     434    }else{
     435        $title = "Feinstaub Live Info";
     436    }
     437
     438
     439    $attr = array(
     440        'title' => $title,
     441        );
     442
     443    if(isset($atts['sensorids'])){
     444        $comma_separated = explode(",", $atts['sensorids'] );
     445           
     446        foreach ($comma_separated as $value) {
     447            $attr[trim($value)] = new Sensor( trim($value) );
     448        }
     449
     450    }
     451
     452   
     453    ob_start();
     454    the_widget($widget_name,$attr);
     455    $output = ob_get_contents();
     456    ob_end_clean();
     457    return $output;
     458   
     459}
     460add_shortcode('feinstaublive','feinstaublive');
     461
     462function feinstaubampel($atts) {
     463   
     464    $widget_name = "LuftdatenAmpel";
     465
     466    if(isset($atts['title'])){
     467        $title = $atts['title'];
     468    }else{
     469        $title = "Feinstaubampel";
     470    }
     471
     472
     473    $attr = array(
     474        'title' => $title,
     475        );
     476
     477    if(isset($atts['sensorids'])){
     478        $comma_separated = explode(",", $atts['sensorids'] );
     479           
     480        foreach ($comma_separated as $value) {
     481            $attr[trim($value)] = new Sensor( trim($value) );
     482        }
     483
     484    }
     485
     486   
     487    ob_start();
     488    the_widget($widget_name,$attr);
     489    $output = ob_get_contents();
     490    ob_end_clean();
     491    return $output;
     492   
     493}
     494add_shortcode('feinstaubampel','feinstaubampel');
     495
     496
    425497?>
  • live-widget-luftdaten/trunk/readme.txt

    r1649153 r1649763  
    33Tags: widget,civic tech,live
    44Tested up to: 4.7.4
    5 Stable tag: 1.1.0
     5Stable tag: 1.2.0
    66Requires at least: 3.0
    77
     
    1212Choose a Widget title and provide a sensor ID. After saving this information, you can customize
    1313the text shown for each sensor value.
     14
     15Widgets can be used with shortcodes, too! Examples:
     16[feinstaublive title="Titel" sensorIDs="260,262"]
     17[feinstaubampel title="Titel" sensorIDs="260"]
    1418
    1519Thank you for testing: networx,alexschnapper!
     
    2327= 1.1 =
    2428*new Widget: colorful widget for showing the current PM values. Turns red if over EU threshold.
     29
     30= 1.2 =
     31*new Shortcodes: widgets can now be used with shortcodes. See description
Note: See TracChangeset for help on using the changeset viewer.