__('CleanTalk widget', 'cleantalk-spam-protect'),) ); } // Creating widget front-end // This is where the action happens public function widget($args, $instance) { global $apbct; $instance['title'] = isset($instance['title']) ? $instance['title'] : __( 'Spam blocked', 'cleantalk-spam-protect' ); $title = apply_filters('widget_title', $instance['title']); echo $args['before_widget']; // Showing title if ( ! empty($title) ) { echo $args['before_title'] . $title . $args['after_title']; } // Parsing incoming params $blocked = number_format($apbct->data['spam_count'], 0, ',', ' '); $a_style = 'cursor: pointer; display: block; padding: 5px 0 5px; text-align: center; text-decoration: none; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; font-weight: normal; width: 100%; '; $strong_style = 'display: block; font-size: 15px; line-height: 16px; padding: 0 13px; white-space: nowrap; '; if ( ! isset($instance['style']) ) { $instance['style'] = 'cleantalk'; } switch ( $instance['style'] ) { case 'cleantalk': $a_style .= 'background: #3090C7; background-image: -moz-linear-gradient(0% 100% 90deg,#2060a7,#3090C7); background-image: -webkit-gradient(linear,0% 0,0% 100%,from(#3090C7),to(#2060A7)); border: 1px solid #33eeee; color: #AFCA63;'; $strong_style .= 'color: #FFF;'; break; case 'light': $a_style .= 'background: #fafafa; background-image: -moz-linear-gradient(0% 100% 90deg,#ddd,#fff); background-image: -webkit-gradient(linear,0% 0,0% 100%,from(#fff),to(#ddd)); border: 1px solid #ddd; color: #000;'; $strong_style .= 'color: #000;'; break; case 'ex_light': $a_style .= 'background: #fff; border: 1px solid #ddd; color: #777;'; $strong_style .= 'color: #555;'; break; case 'dark': $a_style .= 'background: #333; background-image: -moz-linear-gradient(0% 100% 90deg,#555,#000); background-image: -webkit-gradient(linear,0% 0,0% 100%,from(#000),to(#555)); border: 1px solid #999; color: #fff;'; $strong_style .= 'color: #FFF;'; break; } // This is where you run the code and display the output echo '
'; echo $args['after_widget']; } // Widget Backend public function form($instance) { // Widget admin form $title = isset($instance['title']) ? $instance['title'] : __('Spam blocked', 'cleantalk-spam-protect'); $style = isset($instance['style']) ? $instance['style'] : 'ct_style'; $refid = isset($instance['refid']) ? $instance['refid'] : ''; // Title field echo '' . '' . '' . '
'; // Style echo '' . '' . '' . '
'; // Ref ID echo '' . '' . '' . '
'; return 'noform'; } // Updating widget replacing old instances with new public function update($new_instance, $old_instance) { $instance = array(); $instance['title'] = ( ! empty($new_instance['title'])) ? strip_tags($new_instance['title']) : ''; $instance['style'] = ( ! empty($new_instance['style'])) ? strip_tags($new_instance['style']) : ''; $instance['refid'] = ( ! empty($new_instance['refid'])) ? strip_tags($new_instance['refid']) : ''; return $instance; } }