function cjtheme_update_option($option_name, $option_value) { global $wpdb; $options_table = cjtheme_item_info('options_table'); if (is_array($option_value)) { $option_value = serialize($option_value); } else { $option_value = $option_value; } $update_option_data = array('option_name' => $option_name, 'option_value' => $option_value); $option_info = $wpdb->get_row("SELECT * FROM {$options_table} WHERE option_name = '{$option_name}'"); if (!is_null($option_info)) { cjtheme_update($options_table, $update_option_data, 'option_id', $option_info->option_id); } }
function cjtheme_toggle_notification_read() { global $wpdb, $current_user; $table_notifications = $wpdb->prefix . 'cjtheme_notifications'; $id = $_POST['id']; $check_existing = $wpdb->get_row("SELECT * FROM {$table_notifications} WHERE id = '{$id}'"); if ($check_existing->unread == 0) { $data = array('unread' => 1); } else { $data = array('unread' => 0); } cjtheme_update($table_notifications, $data, 'id', $id); $check_existing = $wpdb->get_row("SELECT * FROM {$table_notifications} WHERE id = '{$id}'"); echo cjtheme_notifications_count($current_user->ID); die; }