| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | /** |
| 3 | 4 | * CoolClock Widget Class |
| 4 | 5 | */ |
| 5 | 6 | |
| @@ -7,123 +8,90 @@ | ||
| 7 | 8 | |
| 8 | 9 | /** PHP5+ constructor */ |
| 9 | 10 | public function __construct() { |
| 10 | 11 | parent::__construct( |
| 11 | - 'coolclock-widget', | |
| 12 | - __('Analog Clock', 'coolclock'), | |
| 13 | - array( | |
| 14 | - 'classname' => 'coolclock', | |
| 15 | - 'description' => __('Add an analog clock to your sidebar.', 'coolclock') | |
| 16 | - ), | |
| 17 | - array( | |
| 18 | - 'width' => 300, | |
| 19 | - 'id_base' => 'coolclock-widget' | |
| 20 | - ) | |
| 21 | - ); | |
| 12 | + 'coolclock-widget', | |
| 13 | + __('Analog Clock', 'coolclock'), | |
| 14 | + array( | |
| 15 | + 'classname' => 'coolclock', | |
| 16 | + 'description' => __('Add an analog clock to your sidebar.', 'coolclock') | |
| 17 | + ), | |
| 18 | + array( | |
| 19 | + 'width' => 300, | |
| 20 | + 'id_base' => 'coolclock-widget' | |
| 21 | + ) | |
| 22 | + ); | |
| 22 | 23 | } |
| 23 | 24 | |
| 24 | 25 | /** @see WP_Widget::widget -- do not rename this */ |
| 25 | 26 | public function widget( $args, $instance ) { |
| 26 | 27 | extract( $args ); |
| 27 | - | |
| 28 | - $defaults = array_merge( array('title'=>'','custom_skin'=>''), CoolClock::$defaults, CoolClock::$advanced_defaults ); | |
| 29 | - | |
| 30 | - // backward compat | |
| 31 | - if ( isset($instance['digitalcolor']) && !isset($instance['fontcolor']) ) $instance['fontcolor'] = $instance['digitalcolor']; | |
| 32 | - | |
| 33 | 28 | $title = !empty($instance['title']) ? apply_filters( 'widget_title', $instance['title'] ) : ''; |
| 34 | - //$number = $this->number; | |
| 29 | + $number = $this->number; | |
| 35 | 30 | |
| 36 | - // set footer script flags | |
| 37 | - CoolClock::$add_script = true; | |
| 38 | - | |
| 39 | 31 | // Print output |
| 40 | - echo wp_kses_post( $before_widget ); | |
| 32 | + echo $before_widget; | |
| 41 | 33 | |
| 42 | - if ( $title ) { | |
| 43 | - echo wp_kses_post( $before_title ) . esc_html( $title ) . wp_kses_post( $after_title ); | |
| 44 | - } | |
| 34 | + if ( $title ) | |
| 35 | + echo $before_title . $title . $after_title; | |
| 45 | 36 | |
| 46 | 37 | // set skin |
| 47 | - $instance['skin'] = CoolClock::parse_skin( | |
| 48 | - ! empty( $instance['skin'] ) ? $instance['skin'] : $defaults['skin'], | |
| 49 | - ! empty( $instance['custom_skin'] ) ? $instance['custom_skin'] : '' | |
| 50 | - ); | |
| 38 | + $skin = ( isset( $instance['skin'] ) ) | |
| 39 | + ? $instance['skin'] : CoolClock::$defaults['skin']; | |
| 51 | 40 | |
| 52 | - // radius, used in wrapper style and coolclock fields | |
| 53 | - $instance['radius'] = !empty( $instance['radius'] ) && is_numeric( $instance['radius'] ) ? (int) $instance['radius'] : $defaults['radius']; | |
| 54 | - if ( 10 > $instance['radius'] ) $instance['radius'] = 10; // absolute minimum size 20x20 | |
| 41 | + // add custom skin parameters to the plugin skins array | |
| 42 | + if ( 'custom_'.$number == $skin ) | |
| 43 | + CoolClock::$advanced_skins_config[$skin] = wp_strip_all_tags( $instance['custom_skin'], true ); | |
| 55 | 44 | |
| 56 | - $align = !empty( $instance['align'] ) ? $instance['align'] : $defaults['align']; | |
| 57 | - $styles = array( | |
| 58 | - 'width' => 2 * $instance['radius'] . 'px', | |
| 59 | - 'height' => 'auto', | |
| 60 | - ); | |
| 61 | - if ( in_array( $align, array('left','center') ) ) { | |
| 62 | - $styles['margin-right'] = 'auto'; | |
| 63 | - if ( 'left' == $align ) $styles['margin-left'] = '0'; | |
| 64 | - } | |
| 65 | - if ( in_array( $align, array('right','center') ) ) { | |
| 66 | - $styles['margin-left'] = 'auto'; | |
| 67 | - if ( 'right' == $align ) $styles['margin-right'] = '0'; | |
| 68 | - } | |
| 69 | - $styles = apply_filters( 'coolclock_container_styles', $styles, $instance, $defaults ); | |
| 45 | + // set footer script flags | |
| 46 | + CoolClock::$add_script = true; | |
| 70 | 47 | |
| 71 | - // Build output | |
| 72 | - // begin wrapper | |
| 73 | - $output = '<div class="coolclock-container"' . CoolClock::inline_style( $styles ) . '>'; | |
| 74 | - // add canvas | |
| 75 | - $output .= CoolClock::canvas( $instance ); | |
| 76 | - // end wrapper | |
| 77 | - $output .= '</div>'; | |
| 48 | + if ( in_array( $skin, CoolClock::$more_skins ) ) | |
| 49 | + CoolClock::$add_moreskins = true; | |
| 78 | 50 | |
| 79 | - // Print filtered output. wp_kses_post() strips <canvas>, so extend its | |
| 80 | - // allowed tags rather than using it directly (which would silently | |
| 81 | - // remove the clock). | |
| 82 | - $allowed_html = array_merge( | |
| 83 | - wp_kses_allowed_html( 'post' ), | |
| 84 | - array( | |
| 85 | - 'canvas' => array( | |
| 86 | - 'class' => true, | |
| 87 | - 'style' => true, | |
| 88 | - 'width' => true, | |
| 89 | - 'height' => true, | |
| 90 | - ), | |
| 91 | - ) | |
| 92 | - ); | |
| 93 | - echo wp_kses( apply_filters( 'coolclock_widget', $output, $args, $instance ), $allowed_html ); | |
| 51 | + $output = CoolClock::canvas( array( | |
| 52 | + 'skin' => $skin, | |
| 53 | + 'radius' => !empty($instance['radius']) && is_numeric($instance['radius']) ? (int) $instance['radius'] : 100, | |
| 54 | + 'noseconds' => !empty($instance['radius']) ? $instance['noseconds'] : '', | |
| 55 | + 'gmtoffset' => !empty($instance['gmtoffset']) ? $instance['gmtoffset'] : '', | |
| 56 | + 'showdigital' => !empty($instance['showdigital']) ? $instance['showdigital'] : '', | |
| 57 | + 'digitalcolor' => !empty($instance['digitalcolor']) ? $instance['digitalcolor'] : '', | |
| 58 | + 'scale' => !empty($instance['scale']) ? $instance['scale'] : 'linear', | |
| 59 | + 'align' => !empty($instance['align']) ? $instance['align'] : 'center', | |
| 60 | + 'subtext' => !empty($instance['subtext']) ? apply_filters('widget_text', $instance['subtext'], $instance) : '' | |
| 61 | + ) ); | |
| 94 | 62 | |
| 95 | - echo wp_kses_post( $after_widget ); | |
| 63 | + echo apply_filters( 'coolclock_widget_advanced', $output, $args, $instance ); | |
| 64 | + | |
| 65 | + echo $after_widget; | |
| 96 | 66 | } |
| 97 | 67 | |
| 98 | 68 | /** @see WP_Widget::update -- do not rename this */ |
| 99 | 69 | public function update( $new_instance, $old_instance ) { |
| 100 | - // parse custom skin code | |
| 101 | - $skin_array = !empty($new_instance['custom_skin']) ? CoolClock::skin_array( wp_strip_all_tags( $new_instance['custom_skin'] ) ) : array(); | |
| 102 | - | |
| 103 | - $instance['title'] = !empty($new_instance['title']) ? wp_strip_all_tags( $new_instance['title'] ) : ''; | |
| 104 | - $instance['skin'] = !empty($new_instance['skin']) ? wp_strip_all_tags( $new_instance['skin'] ) : ''; | |
| 105 | - $instance['custom_skin'] = !empty($skin_array) ? wp_json_encode( $skin_array ) : ''; | |
| 70 | + $instance['title'] = !empty($new_instance['title']) ? strip_tags( $new_instance['title'] ) : ''; | |
| 71 | + $instance['skin'] = !empty($new_instance['skin']) ? strip_tags( $new_instance['skin'] ) : ''; | |
| 72 | + $instance['custom_skin'] = !empty($new_instance['custom_skin']) ? strip_tags( $new_instance['custom_skin'] ) : ''; | |
| 106 | 73 | $instance['radius'] = ( empty($new_instance['radius']) || (int) $new_instance['radius'] < 5 ) ? 5 : (int) $new_instance['radius']; |
| 107 | 74 | $instance['noseconds'] = !empty($new_instance['noseconds']) ? '1' : ''; |
| 108 | - $instance['gmtoffset'] = isset($new_instance['gmtoffset']) && $new_instance['gmtoffset'] !== '' ? (float) $new_instance['gmtoffset'] : ''; | |
| 109 | - $instance['showdigital'] = !empty($new_instance['showdigital']) ? wp_strip_all_tags( $new_instance['showdigital'] ) : ''; | |
| 110 | - $instance['fontcolor'] = !empty($new_instance['fontcolor']) ? CoolClock::colorval( $new_instance['fontcolor'] ) : ''; | |
| 111 | - $instance['scale'] = !empty($new_instance['scale']) ? wp_strip_all_tags( $new_instance['scale'] ) : ''; | |
| 112 | - $instance['align'] = !empty($new_instance['align']) ? wp_strip_all_tags( $new_instance['align'] ) : ''; | |
| 113 | - $instance['subtext'] = wp_kses( $new_instance['subtext'], CoolClock::$allowed_tags ); | |
| 75 | + $instance['gmtoffset'] = !empty($new_instance['gmtoffset']) ? (float) $new_instance['gmtoffset'] : ''; | |
| 76 | + $instance['showdigital'] = !empty($new_instance['showdigital']) ? strip_tags( $new_instance['showdigital'] ) : ''; | |
| 77 | + $instance['digitalcolor'] = !empty($new_instance['digitalcolor']) ? CoolClock::colorval( $new_instance['digitalcolor'] ) : ''; | |
| 78 | + $instance['scale'] = !empty($new_instance['scale']) ? strip_tags( $new_instance['scale'] ) : ''; | |
| 79 | + $instance['align'] = !empty($new_instance['align']) ? strip_tags( $new_instance['align'] ) : ''; | |
| 114 | 80 | |
| 115 | - return apply_filters( 'coolclock_widget_update_advanced', $instance, $new_instance ); | |
| 81 | + if ( current_user_can('unfiltered_html') ) | |
| 82 | + $instance['subtext'] = $new_instance['subtext']; | |
| 83 | + else | |
| 84 | + // wp_filter_post_kses() expects slashed | |
| 85 | + $instance['subtext'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['subtext']) ) ); | |
| 86 | + | |
| 87 | + return apply_filters( 'coolclock_widget_update_advanced', $instance, $new_instance ); | |
| 116 | 88 | } |
| 117 | 89 | |
| 118 | 90 | /** @see WP_Widget::form -- do not rename this */ |
| 119 | 91 | public function form( $instance ) { |
| 120 | - $output = ''; | |
| 121 | - $advanced = ''; | |
| 122 | - | |
| 123 | - // backward compat | |
| 124 | - if ( isset($instance['digitalcolor']) && !isset($instance['fontcolor']) ) $instance['fontcolor'] = $instance['digitalcolor']; | |
| 125 | - | |
| 92 | + // Print output | |
| 93 | + //echo CoolClock::form( $this, $instance ); | |
| 126 | 94 | $defaults = array_merge( array('title'=>'','custom_skin'=>''), CoolClock::$defaults, CoolClock::$advanced_defaults ); |
| 127 | 95 | |
| 128 | 96 | $instance = wp_parse_args( (array) $instance, $defaults ); |
| 129 | 97 | |
| @@ -132,83 +100,78 @@ | ||
| 132 | 100 | $custom_skin = esc_attr( $instance['custom_skin'] ); |
| 133 | 101 | |
| 134 | 102 | // Translatable skin names go here |
| 135 | 103 | $skin_names = array ( |
| 136 | - 'swissrail' => __('Swiss Rail','coolclock'), | |
| 137 | - 'chunkyswiss' => __('Chunky Swiss','coolclock'), | |
| 138 | - 'chunkyswissonblack' => __('Chunky Swiss White','coolclock'), | |
| 139 | - 'fancy' => __('Fancy','coolclock'), | |
| 140 | - 'machine' => __('Machine','coolclock'), | |
| 141 | - 'simonbaird_com' => __('SimonBaird.com','coolclock'), | |
| 142 | - 'classic' => __('Classic by Bonstio','coolclock'), | |
| 143 | - 'modern' => __('Modern by Bonstio','coolclock'), | |
| 144 | - 'simple' => __('Simple by Bonstio','coolclock'), | |
| 145 | - 'securephp' => __('SecurePHP','coolclock'), | |
| 146 | - 'tes2' => __('Tes2','coolclock'), | |
| 147 | - 'lev' => __('Lev','coolclock'), | |
| 148 | - 'sand' => __('Sand','coolclock'), | |
| 149 | - 'sun' => __('Sun','coolclock'), | |
| 150 | - 'tor' => __('Tor','coolclock'), | |
| 151 | - 'cold' => __('Cold','coolclock'), | |
| 152 | - 'babosa' => __('Babosa','coolclock'), | |
| 153 | - 'tumb' => __('Tumb','coolclock'), | |
| 154 | - 'stone' => __('Stone','coolclock'), | |
| 155 | - 'disc' => __('Disc','coolclock'), | |
| 156 | - 'watermelon' => __('Watermelon by Yoo Nhe','coolclock'), | |
| 157 | - 'mister' => __('Mister by Carl Lister','coolclock'), | |
| 158 | - 'minimal' => __('Minimal','coolclock') | |
| 159 | - ); | |
| 104 | + 'swissRail' => __('Swiss Rail','coolclock'), | |
| 105 | + 'chunkySwiss' => __('Chunky Swiss','coolclock'), | |
| 106 | + 'chunkySwissOnBlack' => __('Chunky Swiss White','coolclock'), | |
| 107 | + 'fancy' => __('Fancy','coolclock'), | |
| 108 | + 'machine' => __('Machine','coolclock'), | |
| 109 | + 'simonbaird_com' => __('SimonBaird.com','coolclock'), | |
| 110 | + 'classic' => __('Classic by Bonstio','coolclock'), | |
| 111 | + 'modern' => __('Modern by Bonstio','coolclock'), | |
| 112 | + 'simple' => __('Simple by Bonstio','coolclock'), | |
| 113 | + 'securephp' => __('SecurePHP','coolclock'), | |
| 114 | + 'Tes2' => __('Tes2','coolclock'), | |
| 115 | + 'Lev' => __('Lev','coolclock'), | |
| 116 | + 'Sand' => __('Sand','coolclock'), | |
| 117 | + 'Sun' => __('Sun','coolclock'), | |
| 118 | + 'Tor' => __('Tor','coolclock'), | |
| 119 | + 'Cold' => __('Cold','coolclock'), | |
| 120 | + 'Babosa' => __('Babosa','coolclock'), | |
| 121 | + 'Tumb' => __('Tumb','coolclock'), | |
| 122 | + 'Stone' => __('Stone','coolclock'), | |
| 123 | + 'Disc' => __('Disc','coolclock'), | |
| 124 | + 'watermelon' => __('Watermelon by Yoo Nhe','coolclock'), | |
| 125 | + 'mister' => __('Mister by Carl Lister','coolclock'), | |
| 126 | + 'minimal' => __('Minimal','coolclock') | |
| 127 | + ); | |
| 160 | 128 | |
| 129 | + $skins = array_merge( CoolClock::$default_skins, CoolClock::$more_skins, CoolClock::$advanced_skins ); | |
| 130 | + | |
| 161 | 131 | // Translatable type names go here |
| 162 | 132 | $type_names = array ( |
| 163 | - 'linear' => __('Linear','coolclock'), | |
| 164 | - 'logclock' => __('Logarithmic','coolclock'), | |
| 165 | - 'logclockrev' => __('Logarithmic reversed','coolclock') | |
| 166 | - ); | |
| 133 | + 'linear' => __('Linear','coolclock'), | |
| 134 | + 'logClock' => __('Logarithmic','coolclock'), | |
| 135 | + 'logClockRev' => __('Logarithmic reversed','coolclock') | |
| 136 | + ); | |
| 167 | 137 | |
| 168 | 138 | // Translatable show digital options go here |
| 169 | 139 | $showdigital_names = array ( |
| 170 | - '' => __( 'No', 'coolclock' ), | |
| 171 | - 'digital12' => __('time (am/pm)','coolclock'), | |
| 172 | - 'digital24' => __('time (24h)','coolclock'), | |
| 173 | - 'date' => __('date','coolclock'), | |
| 174 | - 'digital12+' => __('time + seconds (am/pm)','coolclock'), | |
| 175 | - 'digital24+' => __('time + seconds (24h)','coolclock'), | |
| 176 | - 'text' => __('custom text','coolclock') | |
| 140 | + '' => __('none','coolclock'), | |
| 141 | + 'digital12' => __('time (am/pm)','coolclock'), | |
| 142 | + 'digital24' => __('time (24h)','coolclock'), | |
| 143 | + 'date' => __('date','coolclock') | |
| 177 | 144 | ); |
| 178 | 145 | |
| 146 | + // Misc translations | |
| 147 | + $stray = array( | |
| 148 | + 'extra_settings' => __('Extra settings for the CoolClock widget.', 'coolclock') | |
| 149 | + ); | |
| 150 | + | |
| 179 | 151 | // Title |
| 180 | - $output .= '<style type="text/css">#available-widgets [class*=clock] .widget-title:before{content:"\f469"}</style> | |
| 181 | - <p><label for="' . $this->get_field_id('title') . '">' . __( 'Title:', 'coolclock' ) . '</label> '; | |
| 152 | + $output = '<style type="text/css">#available-widgets [class*=clock] .widget-title:before{content:"\f469"}</style> | |
| 153 | + <p><label for="' . $this->get_field_id('title') . '">' . __('Title:') . '</label> '; | |
| 182 | 154 | $output .= '<input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></p>'; |
| 183 | 155 | |
| 184 | 156 | // Clock settings |
| 185 | - $output .= '<fieldset><legend>' . __('Clock', 'coolclock') . '</legend>'; | |
| 186 | - $output .= '<p class="description"><a href="https://premium.status301.com/coolclock-widget-settings/" target="_blank">' . __('CoolClock widget instructions »', 'coolclock') . '</a></p>'; | |
| 187 | - | |
| 157 | + $output .= '<p><strong>' . __('Clock', 'coolclock') . '</strong></p>'; | |
| 188 | 158 | $output .= '<p><label for="' . $this->get_field_id('skin') . '">' . __('Skin:', 'coolclock') . '</label> '; |
| 189 | 159 | $output .= '<select class="select" id="' . $this->get_field_id('skin') . '" name="' . $this->get_field_name('skin') . '">'; |
| 190 | - $output .= '<option value="' . $defaults['skin'] . '" ' . selected( $defaults['skin'], $instance['skin'], false ) . '>'; | |
| 191 | - $output .= ( isset($skin_names[$defaults['skin']]) ) ? $skin_names[$defaults['skin']] : $defaults['skin']; | |
| 192 | - $output .= '</option>'; | |
| 193 | - foreach ( CoolClock::get_all_skins() as $skin => $parms ) { | |
| 194 | - $output .= '<option value="' . $skin . '" ' . selected( $skin, $instance['skin'], false ) . '>'; | |
| 195 | - $output .= ( isset($skin_names[$skin]) ) ? $skin_names[$skin] : $skin; | |
| 160 | + foreach ($skins as $value) { | |
| 161 | + $output .= '<option value="' . $value . '"'; | |
| 162 | + $output .= ( $value == $instance['skin'] ) ? ' selected="selected">' : '>'; | |
| 163 | + $output .= ( isset($skin_names[$value]) ) ? $skin_names[$value] : $value; | |
| 196 | 164 | $output .= '</option>'; |
| 197 | - } | |
| 198 | - $output .= '<option value="custom_' . $this->number . '" ' . selected( 'custom_'.$this->number, $instance['skin'], false ) . '>'; | |
| 165 | + } unset($value); | |
| 166 | + $output .= '<option value="custom_' . $this->number . '"'; | |
| 167 | + $output .= ( 'custom_'.$this->number == $instance['skin'] ) ? ' selected="selected">' : '>'; | |
| 199 | 168 | $output .= __('Custom (define below)', 'coolclock') . '</option></select></p>'; |
| 200 | 169 | |
| 201 | 170 | // Custom skin field |
| 202 | 171 | $output .= '<p><label for="' . $this->get_field_id('custom_skin') . '">' . __('Custom skin parameters:', 'coolclock') . '</label> '; |
| 203 | - $output .= '<textarea class="widefat" id="' . $this->get_field_id('custom_skin') . '" name="' . $this->get_field_name('custom_skin') . '">' . $custom_skin . '</textarea></p>'; | |
| 172 | + $output .= '<textarea class="widefat" id="' . $this->get_field_id('custom_skin') . '" name="' . $this->get_field_name('custom_skin') . '">' . $custom_skin . '</textarea> <em>' . __('(set Skin to Custom above)', 'coolclock') . '</em></p>'; | |
| 204 | 173 | |
| 205 | - $output .= '<p class="description"><em>' . sprintf( | |
| 206 | - /* translators: %s: link to the JSON parameters documentation */ | |
| 207 | - __( '(set Skin to Custom above, then add %s here)', 'coolclock' ), | |
| 208 | - '<a href="https://premium.status301.com/coolclock-custom-skin/" target="_blank">' . __( 'parameters in JSON format', 'coolclock' ) . '</a>' | |
| 209 | - ) . '</em></p>'; | |
| 210 | - | |
| 211 | 174 | // Radius |
| 212 | 175 | $output .= '<p><label for="' . $this->get_field_id('radius') . '">' . __('Radius:', 'coolclock') . '</label> '; |
| 213 | 176 | $output .= '<input class="small-text" id="' . $this->get_field_id('radius') . '" name="' . $this->get_field_name('radius') . '" type="number" min="10" value="' . $instance['radius'] . '" /></p>'; |
| 214 | 177 | |
| @@ -216,43 +179,44 @@ | ||
| 216 | 179 | $output .= '<p><input id="' . $this->get_field_id('noseconds') . '" name="' . $this->get_field_name('noseconds') . '" type="checkbox" value='; |
| 217 | 180 | $output .= ( $instance['noseconds'] ) ? '"true" checked="checked" />' : '"false" />'; |
| 218 | 181 | $output .= ' <label for="' . $this->get_field_id('noseconds') . '">' . __('Hide second hand', 'coolclock') . '</label></p>'; |
| 219 | 182 | |
| 183 | + // Scale | |
| 184 | + $output .= '<p><label for="' . $this->get_field_id('scale') . '">' . __('Scale:', 'coolclock') . '</label> '; | |
| 185 | + $output .= '<select class="select" id="' . $this->get_field_id('scale') . '" name="' . $this->get_field_name('scale') . '">'; | |
| 186 | + foreach ( CoolClock::$clock_types as $key => $value ) { | |
| 187 | + $output .= '<option value="' . $key . '"'; | |
| 188 | + $output .= ( $key == $instance['scale'] ) ? ' selected="selected">' : '>'; | |
| 189 | + $output .= ( isset($type_names[$key]) ) ? $type_names[$key] : $value; | |
| 190 | + $output .= '</option>'; | |
| 191 | + } | |
| 192 | + $output .= '</select></p>'; | |
| 193 | + | |
| 220 | 194 | // Align |
| 221 | 195 | $output .= '<p><label for="' . $this->get_field_id('align') . '">' . __('Align:', 'coolclock') . '</label> '; |
| 222 | 196 | $output .= '<select class="select" id="' . $this->get_field_id('align') . '" name="' . $this->get_field_name('align') . '">'; |
| 223 | - $output .= '<option value="">'; | |
| 224 | - $output .= __( 'none', 'coolclock' ) . '</option>'; | |
| 225 | - $output .= '<option value="left" ' . selected( $instance['align'], 'left', false ) . '>'; | |
| 197 | + $output .= '<option value=""'; | |
| 198 | + $output .= ( $instance['align'] == '' ) ? ' selected="selected">' : '>'; | |
| 199 | + $output .= __('none', 'coolclock') . '</option>'; | |
| 200 | + $output .= '<option value="left"'; | |
| 201 | + $output .= ( $instance['align'] == 'left' ) ? ' selected="selected">' : '>'; | |
| 226 | 202 | $output .= __('left', 'coolclock') . '</option>'; |
| 227 | - $output .= '<option value="right" ' . selected( $instance['align'], 'right', false ) . '>'; | |
| 203 | + $output .= '<option value="right"'; | |
| 204 | + $output .= ( $instance['align'] == 'right' ) ? ' selected="selected">' : '>'; | |
| 228 | 205 | $output .= __('right', 'coolclock') . '</option>'; |
| 229 | - $output .= '<option value="center" ' . selected( $instance['align'], 'center', false ) . '>'; | |
| 206 | + $output .= '<option value="center"'; | |
| 207 | + $output .= ( $instance['align'] == 'center' ) ? ' selected="selected">' : '>'; | |
| 230 | 208 | $output .= __('center', 'coolclock') . '</option>'; |
| 231 | 209 | $output .= '</select></p>'; |
| 232 | 210 | |
| 233 | 211 | // Subtext |
| 234 | 212 | $output .= '<p><label for="' . $this->get_field_id('subtext') . '">' . __('Subtext:', 'coolclock') . '</label> '; |
| 235 | - $output .= '<input class="widefat" id="' . $this->get_field_id('subtext') . '" name="' . $this->get_field_name('subtext') . '" type="text" value="' . $subtext . '" /> <span class="description"><em>' . __('(basic HTML allowed)', 'coolclock') . '</em></span></p>'; | |
| 213 | + $output .= '<input class="widefat" id="' . $this->get_field_id('subtext') . '" name="' . $this->get_field_name('subtext') . '" type="text" value="' . $subtext . '" /> <em>' . __('(basic HTML allowed)', 'coolclock') . '</em></p>'; | |
| 236 | 214 | |
| 237 | - $output .= '</fieldset>'; //<div class="coolclock-advanced" style="background-color:rgba(0,0,0,.03);padding:1px 7px;border-radius:5px;margin-bottom:10px">'; | |
| 238 | - | |
| 239 | - $output .= '<fieldset><legend>' . __( 'Advanced', 'coolclock' ) . '</legend>'; | |
| 240 | - | |
| 241 | 215 | // Use GMT offset |
| 242 | 216 | $output .= '<p><label for="' . $this->get_field_id('gmtoffset') . '">' . __('GMT offset:', 'coolclock') . '</label> '; |
| 243 | - $output .= '<input class="small-text" id="' . $this->get_field_id('gmtoffset') . '" name="' . $this->get_field_name('gmtoffset') . '" type="number" step="0.5" value="' . $instance['gmtoffset'] . '" /> <span class="description"><em>' . __('(leave blank for visitor local time)', 'coolclock') . '</em></span></p>'; | |
| 217 | + $output .= '<input class="small-text" id="' . $this->get_field_id('gmtoffset') . '" name="' . $this->get_field_name('gmtoffset') . '" type="number" step="0.5" value="' . $instance['gmtoffset'] . '" /> <em>' . __('(leave blank for visitor local time)', 'coolclock') . '</em></p>'; | |
| 244 | 218 | |
| 245 | - // Scale | |
| 246 | - $output .= '<p><label for="' . $this->get_field_id('scale') . '">' . __('Scale:', 'coolclock') . '</label> '; | |
| 247 | - $output .= '<select class="select" id="' . $this->get_field_id('scale') . '" name="' . $this->get_field_name('scale') . '">'; | |
| 248 | - foreach ( CoolClock::$clock_types as $key => $value ) { | |
| 249 | - $output .= '<option value="' . $key . '" ' . selected( $key, strtolower($instance['scale']), false ) . '">'; | |
| 250 | - $output .= ( isset($type_names[$key]) ) ? $type_names[$key] : $value; | |
| 251 | - $output .= '</option>'; | |
| 252 | - } | |
| 253 | - $output .= '</select></p>'; | |
| 254 | - | |
| 255 | 219 | // Show digital |
| 256 | 220 | if ( $instance['showdigital'] == 'true' || $instance['showdigital'] == '1' ) |
| 257 | 221 | $instance['showdigital'] = 'digital12'; // backward compat |
| 258 | 222 | |
| @@ -258,62 +222,28 @@ | ||
| 258 | 222 | |
| 259 | 223 | $output .= '<p><label for="' . $this->get_field_id('showdigital') . '">' . __('Show digital:', 'coolclock') . '</label> '; |
| 260 | 224 | $output .= '<select class="select" id="' . $this->get_field_id('showdigital') . '" name="' . $this->get_field_name('showdigital') . '">'; |
| 261 | 225 | foreach ( CoolClock::$showdigital_options as $key => $value ) { |
| 262 | - $output .= '<option value="' . $key . '" ' . selected( $key, $instance['showdigital'], false ) . '>'; | |
| 226 | + $output .= '<option value="' . $key . '"'; | |
| 227 | + $output .= ( $key == $instance['showdigital'] ) ? ' selected="selected">' : '>'; | |
| 263 | 228 | $output .= ( isset($showdigital_names[$key]) ) ? $showdigital_names[$key] : $value; |
| 264 | 229 | $output .= '</option>'; |
| 265 | 230 | } |
| 266 | 231 | $output .= '</select></p>'; |
| 267 | 232 | |
| 268 | - $output .= '<p><label for="' . $this->get_field_id('fontcolor') . '">' . __('Digital font color:', 'coolclock') . '</label> '; | |
| 269 | - $output .= '<input id="' . $this->get_field_id('fontcolor') . '" name="' . $this->get_field_name('fontcolor') . '" type="text" value="' . $instance['fontcolor'] . '" /> <span class="description"><em>' . __('(use a valid HTML color code or name)', 'coolclock') . '</em></span></p>'; | |
| 270 | - $output .= '</fieldset>'; | |
| 233 | + $advanced = '<p><label for="' . $this->get_field_id('digitalcolor') . '">' . __('Digital color:', 'coolclock') . '</label> '; | |
| 234 | + $advanced .= '<input id="' . $this->get_field_id('digitalcolor') . '" name="' . $this->get_field_name('digitalcolor') . '" type="text" value="' . $instance['digitalcolor'] . '" /> <em>' . __('(use a valid HTML color code or name)', 'coolclock') . '</em></p>'; | |
| 271 | 235 | |
| 272 | - $advanced .= '<p class="description"><a href="https://premium.status301.com/downloads/coolclock-advanced/">' . __('More digital font options »', 'coolclock') . '</a></p> | |
| 273 | - <fieldset><legend>' . __( 'Background', 'coolclock' ) . '</legend><p class="description"><a href="https://premium.status301.com/downloads/coolclock-advanced/">' . __('Available in the Advanced extension »', 'coolclock') . '</a></p></fieldset>'; | |
| 236 | + $advanced .= '<p><a href="http://premium.status301.net/downloads/coolclock-advanced/">' . __('More digital font options »', 'coolclock') . '</a></p> | |
| 237 | + <p><strong>' . __('Background') . '</strong></p><p><a href="http://premium.status301.net/downloads/coolclock-advanced/">' . __('Available in the Advanced extension »', 'coolclock') . '</a></p>'; | |
| 274 | 238 | |
| 275 | 239 | // Advanced filter |
| 276 | 240 | $output .= apply_filters( 'coolclock_widget_form_advanced', $advanced, $this, $instance, $defaults ); |
| 277 | 241 | |
| 278 | - $output .= '</div>'; | |
| 279 | - | |
| 280 | 242 | if ( class_exists( 'CoolClockAdvanced' ) && isset(CoolClockAdvanced::$plugin_version) && version_compare( CoolClockAdvanced::$plugin_version, '7.1', '<' ) ) { // add an upgrade notice |
| 281 | - $output .= '<div class="update-nag"><strong>' . __('Please upgrade the CoolClock - Advanced extension.', 'coolclock') . '</strong> '. ' <a href="https://premium.status301.com/account/" target="_blank">' . __('Please log in with your account credentials here.', 'coolclock') . '</a>' . __('You can download the new version using the link in the downloads list.', 'coolclock') . '</div>'; | |
| 243 | + $output .= '<div class="update-nag"><strong>' . __('Please upgrade the CoolClock - Advanced extension.', 'coolclock') . '</strong> '. ' <a href="http://premium.status301.net/account/" target="_blank">' . __('Please log in with your account credentials here.', 'coolclock') . '</a>' . __('You can download the new version using the link in the downloads list.', 'coolclock') . '</div>'; | |
| 282 | 244 | } |
| 283 | 245 | |
| 284 | - // wp_kses_post() strips form controls (input/select/option/textarea/style), | |
| 285 | - // which would silently break this settings screen. Extend the allowed | |
| 286 | - // tags with what an admin settings form actually needs instead. | |
| 287 | - $allowed_html = array_merge( | |
| 288 | - wp_kses_allowed_html( 'post' ), | |
| 289 | - array( | |
| 290 | - 'style' => array( 'type' => true ), | |
| 291 | - 'input' => array( | |
| 292 | - 'id' => true, | |
| 293 | - 'class' => true, | |
| 294 | - 'name' => true, | |
| 295 | - 'type' => true, | |
| 296 | - 'value' => true, | |
| 297 | - 'min' => true, | |
| 298 | - 'step' => true, | |
| 299 | - 'checked' => true, | |
| 300 | - ), | |
| 301 | - 'select' => array( | |
| 302 | - 'id' => true, | |
| 303 | - 'class' => true, | |
| 304 | - 'name' => true, | |
| 305 | - ), | |
| 306 | - 'option' => array( | |
| 307 | - 'value' => true, | |
| 308 | - 'selected' => true, | |
| 309 | - ), | |
| 310 | - 'textarea' => array( | |
| 311 | - 'id' => true, | |
| 312 | - 'class' => true, | |
| 313 | - 'name' => true, | |
| 314 | - ), | |
| 315 | - ) | |
| 316 | - ); | |
| 317 | - echo wp_kses( $output, $allowed_html ); | |
| 246 | + echo $output; | |
| 247 | + | |
| 318 | 248 | } |
| 319 | 249 | } |