public static function checkUpdate()
 {
     $version = get_option('qhshoutbox_version');
     if ($version && $version != QH_SHOUTBOX_VERSION) {
         QHShoutboxMessage::updateTable();
         QHShoutboxUser::checkUpdate();
         add_option('qhshoutbox_version', QH_SHOUTBOX_VERSION);
     }
 }
 public static function run()
 {
     $instance = self::getInstance();
     //setup
     global $wpdb;
     self::$wpdb = $wpdb;
     //table name
     self::$table = self::$wpdb->prefix . 'qhshoutbox';
     self::$option = get_option('qhSetting');
     return $instance;
 }
 public static function create($atts)
 {
     $data = QHShoutboxMessage::get();
     extract(self::$option);
     $atts = shortcode_atts(array('title' => 'QH Shoutbox', 'color' => 'red'), $atts);
     $title = apply_filters('widget_title', $atts['title']);
     wp_register_style('qhshoutbox_css', QH_PLUGIN_URL . 'scripts/style.css');
     wp_enqueue_style('qhshoutbox_css');
     wp_register_script('qhshoutbox_js', QH_PLUGIN_URL . 'scripts/function.js');
     wp_enqueue_script('qhshoutbox_js');
     echo '<style>.qh-shoutbox .widget-title{color: ' . $atts['color'] . '}</style>';
     wp_localize_script('qhshoutbox_js', 'qhshoutbox', array('url' => admin_url('admin-ajax.php'), 'refreshRate' => self::$option['qhRefreshRate']));
     require_once QH_PLUGIN_DIR . 'views/show.php';
 }
 public static function saveDataNoPriv()
 {
     // if (is_user_logged_in()) {
     //     global $current_user;
     //     $user_login = $current_user->user_login;
     // } else {
     //     $user_login = '';
     // }
     $data = array('status' => 0, 'message' => '');
     // if (isset($_POST['qhMessage']) && $_POST['qhMessage'] != '' && wp_verify_nonce($_POST['qhsecurity'], 'submit_message')) {
     //     $message = esc_attr($_POST['qhMessage']);
     //     if ($user_login != '') {
     //         QHShoutboxMessage::save($message, $user_login);
     //     } else {
     //         QHShoutboxMessage::save($message);
     //     }
     // }
     //print_r($data);die;
     if (isset($_POST['qhMessage']) && $_POST['qhMessage'] != '' && check_ajax_referer('qhshoutbox', 'qhsecurity', false)) {
         $message = esc_attr($_POST['qhMessage']);
         $validate = QHShoutboxMessage::save($message);
         if ($validate) {
             $data['status'] = 1;
             $data['message'] = QHShoutboxMessage::get('ARRAY_A');
         } else {
             $data['message'] = 'Something went wrong !';
         }
     } else {
         $data['status'] = 1;
         $data['message'] = QHShoutboxMessage::get('ARRAY_A');
     }
     wp_send_json_success($data);
 }