/**
  * Controls output
  *
  * @return void
  */
 function widget($args, $instance)
 {
     // $before_widget, $after_widget, $before_title, $after_title
     extract($args, EXTR_SKIP);
     echo $before_widget;
     if (!empty($instance['hide_title'])) {
         echo $before_title . apply_filters('widget_title', $instance['title']) . $after_title;
     }
     wp_enqueue_script('stupid-button', plugin_dir_url(__FILE__) . 'stupid-button.js', array('jquery', 'wp-util'), '0.0.1', true);
     wp_localize_script('stupid-button', 'stupidButton', array('unknownError' => 'Unknown error.'));
     $total = intval(get_option('stupid_button_counter', 0));
     echo '<p><button id="stupid-button-increment">' . __('Button', $this->textdomain) . '</button> <button id="stupid-button-reset">' . __('Reset', $this->textdomain) . '</button></p>';
     echo '<p id="stupid-button-status">' . stupid_button_status_text($total) . '</p>';
     echo $after_widget;
 }
Example #2
0
function stupid_button_ajax_reset()
{
    update_option('stupid_button_counter', 0);
    wp_send_json_success(stupid_button_status_text(0));
}