PluginProbe
wp-forecast / 9.3
wp-forecast v9.3
10.0 trunk 1.4 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3..5 3..8 3.0 3.1 3.2 3.3 3.4 3.6 All 86 releases
wp-forecast / shortcodes.php

shortcodes.php in wp-forecast 9.3, at shortcodes.php

66 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Function to add the shortcodes for wp-forecast.
4 *
5 * @author Hans Matzen
6 * @copyright 2009-2024
7 * @since 2.4
8 * @description wp-forecast using WordPress shortcode for more features
9 * @Docs http://codex.wordpress.org/Shortcode_API
10 *
11 * @package wp-forecast
12 */
13
14 if ( ! function_exists( 'wpforecast' ) ) {
15 /**
16 * Function which adds the wp-forecast weather widget as shortcode.
17 *
18 * @param array $atts Parameters for the widget.
19 */
20 function wpforecast( $atts ) {
21 $lang = '';
22 $width = '';
23 $height = '';
24 $id = '';
25
26 // parameter einlesen.
27 if ( is_array( $atts ) ) {
28 $lang = ( isset( $atts['lang'] ) ? sanitize_key( $atts['lang'] ) : '' );
29 $width = ( isset( $atts['width'] ) ? intval( $atts['width'] ) : '' );
30 $height = ( isset( $atts['height'] ) ? intval( $atts['height'] ) : '' );
31 $id = ( isset( $atts['id'] ) ? sanitize_key( $atts['id'] ) : 'A' );
32 }
33
34 // iframe tag zusammen bauen.
35 $res = '<iframe class="wpf-iframe" src="' . site_url( 'wp-forecast-direct?wpfcid=' . $id . '&amp;header=1', __FILE__ );
36
37 // falls eine sprache angegeben wurde haengen wir sie hinten dran.
38 if ( '' != $lang ) {
39 $res .= '&amp;language_override=' . $lang;
40 }
41
42 $res .= '" ';
43
44 // falls eine breite angegeben wurde haengen wir sie hinten dran.
45 if ( '' != $width && 0 != $width ) {
46 $res .= "width='$width' ";
47 }
48
49 // falls eine sprache angegeben wurde haengen wir sie hinten dran.
50 if ( '' != $height && 0 != $height ) {
51 $res .= "height='$height' ";
52 }
53
54 $res .= '>' . __( 'wp-forecast shortcode: This browser does not support iframes.', 'wp-forecast' ) . '</iframe>';
55
56 return $res;
57 }
58 }
59 // shortcode bei wp anmelden.
60 if ( function_exists( 'add_shortcode' ) ) {
61 add_shortcode( 'wpforecast', 'wpforecast' );
62 add_filter( 'widget_text', 'do_shortcode' );
63 }
64
65
66