PluginProbe
CoolClock / 4.2
CoolClock v4.2
4.3.8 trunk 0.1 2.0 2.9.8 3.0 3.1 3.2 3.3 4.0 4.1 4.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7
coolclock / includes / class-coolclock-shortcode.php

class-coolclock-shortcode.php in CoolClock 4.2, at includes/class-coolclock-shortcode.php

77 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * CoolClock Shortcode Class
5 */
6
7 class CoolClock_Shortcode {
8
9 public static function handle_shortcode( $atts, $content = null )
10 {
11 if ( is_feed() )
12 return '';
13
14 $atts = shortcode_atts( array_merge( CoolClock::$defaults, CoolClock::$advanced_defaults ), $atts, 'coolclock' );
15
16 /**
17 * skin Must be one of these: 'swissRail' (default skin), 'chunkySwiss', 'chunkySwissOnBlack', 'fancy', 'machine', 'simonbaird_com', 'classic', 'modern', 'simple', 'securephp', 'Tes2', 'Lev', 'Sand', 'Sun', 'Tor', 'Cold', 'Babosa', 'Tumb', 'Stone', 'Disc', 'watermelon' or 'mister'.
18 * If the Advanced extension is activated, there is also 'minimal' available.
19 * radius A number to define the clock radius. Do not add 'px' or any other measure descriptor.
20 * noseconds Set to true (or 1) to hide the second hand
21 * gmtoffset A number to define a timezone relative the Greenwhich Mean Time. Do not set this parameter to default to local time.
22 * showdigital Set to 'digital12' to show the time in 12h digital format (with am/pm) too
23 * digitalcolor Set to a color value to change the digital time color
24 * scale Must be one of these: 'linear' (default scale), 'logClock' or 'logClockRev'. Linear is our normal clock scale, the other two show a logarithmic time scale
25 * subtext Optional text, centered below the clock
26 * align Sets floating of the clock: 'left', 'right' or 'center'
27 */
28
29 // set footer script flags
30 CoolClock::$add_script = true;
31
32 $atts['skin'] = !empty($atts['skin']) ? self::parse_skin( $atts['skin'], $content ) : CoolClock::$defauls['skin'];
33
34 // get output
35 $output = CoolClock::canvas( $atts );
36
37 return apply_filters( 'coolclock_shortcode_advanced', $output, $atts, $content );
38 }
39
40 private static function parse_skin( $skin_name, $content )
41 {
42 // look trhough the default skins first
43 foreach ( CoolClock::$default_skins as $skin ) {
44 if ( strtolower($skin_name) == strtolower($skin) )
45 // return the matching skin
46 return $skin;
47 }
48
49 // still here? then search in the $more_skins array
50 foreach ( CoolClock::$more_skins as $skin ) {
51 if ( strtolower($skin_name) == strtolower($skin) ) {
52 // set more_skins flag
53 CoolClock::$add_moreskins = true;
54 // return the matching skin
55 return $skin;
56 }
57 }
58
59 // still here? then skin is a custom skin
60
61 // add custom skin parameters to the advanced skins array
62 if ( !in_array( $skin_name, CoolClock::$advanced_skins ) && !empty( $content ) ) {
63 CoolClock::$advanced_skins[] = $skin_name;
64 CoolClock::$advanced_skins_config[$skin_name] = wp_strip_all_tags( $content, true );
65 }
66
67 return $skin_name;
68 }
69
70 public static function no_wptexturize( $shortcodes )
71 {
72 $shortcodes[] = 'coolclock';
73 return $shortcodes;
74 }
75
76 }
77