400, 'height' => 350); parent::__construct( 'dnx-countdown', // id_base __('danixland CountDown', 'dnxcd' ), // Name array( 'description' => __('Use this widget to add a simple Count Down to your Sidebar', 'dnxcd') ), $control_ops ); } /** * How to display the widget on the public side of the site. */ public function widget( $args, $instance ) { extract( $args ); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title'] ); /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ( $title ) { echo $before_title . $title . $after_title; } if ( '' != get_option('dnxcd_future_date') ) { echo '
'; $date = gmdate('U', strtotime( get_option('dnxcd_future_date') )); $diff = $date - gmdate('U'); if ( '' != get_option('dnxcd_widget_link') ) { echo ''; echo '-' . floor($diff / (24 * 60 * 60)); echo ''; } else { echo '-' . floor($diff / (24 * 60 * 60)); } echo '
'; echo '
' . __('days to go', 'dnxcd') . '
'; } else { echo "
" . __('the date is missing
configure widget', 'dnxcd') . "
"; } /* After widget (defined by themes). */ echo $after_widget; } //Update the widget public function update( $new_instance, $old_instance ) { $instance = $old_instance; //Strip tags from title and name to remove HTML $instance['title'] = sanitize_text_field( $new_instance['title'] ); $instance['date'] = strip_tags( $new_instance['date'] ); $instance['link'] = esc_url( $new_instance['link'], array('http', 'https') ); $instance['style'] = (bool) $new_instance['style']; update_option( 'dnxcd_future_date', $instance['date'] ); update_option( 'dnxcd_widget_link', $instance['link'] ); update_option( 'dnxcd_use_style', $instance['style'] ); return $instance; } /** * Displays just a quick notice with a link to the Settings page */ public function form( $instance ) { $defaults = array( 'title' => __( 'Count Down', 'dnxcd' ), 'date' => get_option( 'dnxcd_future_date' ), 'link' => get_option( 'dnxcd_widget_link' ), 'style' => get_option( 'dnxcd_use_style' ) ); $instance = wp_parse_args( (array) $instance, $defaults ); extract( $instance, EXTR_SKIP ); ?>

id="get_field_id( 'style' ); ?>" name="get_field_name( 'style' ); ?>" />