Are you sure you want to do this?'); }
// First check if ID exist with requested ID
$sSql = $wpdb->prepare(
"SELECT COUNT(*) AS `count` FROM ".WP_g_aths_TABLE."
WHERE `g_aths_id` = %d",
array($did)
);
$result = '0';
$result = $wpdb->get_var($sSql);
if ($result != '1')
{
?>prepare("
SELECT *
FROM `".WP_g_aths_TABLE."`
WHERE `g_aths_id` = %d
LIMIT 1
",
array($did)
);
$data = array();
$data = $wpdb->get_row($sSql, ARRAY_A);
// Preset the form fields
$form = array(
'g_aths_text' => $data['g_aths_text'],
'g_aths_status' => $data['g_aths_status'],
'g_aths_order' => $data['g_aths_order']
);
}
// Form submitted, check the data
if (isset($_POST['g_aths_form_submit']) && $_POST['g_aths_form_submit'] == 'yes')
{
// Just security thingy that wordpress offers us
check_admin_referer('g_aths_form_edit');
$form['g_aths_text'] = isset($_POST['g_aths_text']) ? wp_filter_post_kses($_POST['g_aths_text']) : '';
if ($form['g_aths_text'] == '')
{
$g_aths_errors[] = __('Please enter the announcement.', 'announcement-ticker-highlighter-scroller');
$g_aths_error_found = TRUE;
}
$form['g_aths_status'] = isset($_POST['g_aths_status']) ? sanitize_text_field($_POST['g_aths_status']) : '';
if ($form['g_aths_status'] == '')
{
$g_aths_errors[] = __('Please select the display status.', 'announcement-ticker-highlighter-scroller');
$g_aths_error_found = TRUE;
}
$form['g_aths_order'] = isset($_POST['g_aths_order']) ? intval($_POST['g_aths_order']) : '';
if ($form['g_aths_order'] == '')
{
$g_aths_errors[] = __('Please enter the display order, only number.', 'announcement-ticker-highlighter-scroller');
$g_aths_error_found = TRUE;
}
// No errors found, we can add this Group to the table
if ($g_aths_error_found == FALSE)
{
$sSql = $wpdb->prepare(
"UPDATE `".WP_g_aths_TABLE."`
SET `g_aths_text` = %s,
`g_aths_status` = %s,
`g_aths_order` = %s
WHERE g_aths_id = %d
LIMIT 1",
array($form['g_aths_text'], $form['g_aths_status'], $form['g_aths_order'], $did)
);
$wpdb->query($sSql);
$g_aths_success = __('Details was successfully updated.', 'announcement-ticker-highlighter-scroller');
}
}
if ($g_aths_error_found == TRUE && isset($g_aths_errors[0]) == TRUE)
{
?>
0)
{
?>