Security check failed.
'); } ?>
'',
'pop_height' => '',
'pop_headercolor' => '',
'pop_bordercolor' => '',
'pop_header_fontcolor' => '',
'pop_title' => '',
'pop_content' => '',
'pop_caption' => '',
'pop_id' => ''
);
// Form submitted, check the data
if (isset($_POST['pop_form_submit']) && $_POST['pop_form_submit'] == 'yes')
{
// Just security thingy that wordpress offers us
check_admin_referer('pop_form_add');
$form['pop_width'] = isset($_POST['pop_width']) ? sanitize_text_field($_POST['pop_width']) : '';
if ($form['pop_width'] == '')
{
$pop_errors[] = __('Please enter the popup window width, only number.', 'anything-popup');
$pop_error_found = TRUE;
}
if(!is_numeric($form['pop_width'])) { $form['pop_width'] = 300; }
$form['pop_height'] = isset($_POST['pop_height']) ? sanitize_text_field($_POST['pop_height']) : '';
if ($form['pop_height'] == '')
{
$pop_errors[] = __('Please enter the popup window height, only number.', 'anything-popup');
$pop_error_found = TRUE;
}
if(!is_numeric($form['pop_height'])) { $form['pop_height'] = 250; }
$form['pop_headercolor'] = isset($_POST['pop_headercolor']) ? sanitize_text_field($_POST['pop_headercolor']) : '';
if ($form['pop_headercolor'] == '')
{
$pop_errors[] = __('Please enter the header color.', 'anything-popup');
$pop_error_found = TRUE;
}
if(!preg_match('/^#[a-f0-9]{6}$/i',$form['pop_headercolor']))
{
$pop_errors[] = __('Please enter valid header color.', 'anything-popup');
$pop_error_found = TRUE;
}
$form['pop_bordercolor'] = isset($_POST['pop_bordercolor']) ? sanitize_text_field($_POST['pop_bordercolor']) : '';
if ($form['pop_headercolor'] == '')
{
$pop_errors[] = __('Please enter the border color.', 'anything-popup');
$pop_error_found = TRUE;
}
if(!preg_match('/^#[a-f0-9]{6}$/i',$form['pop_bordercolor']))
{
$pop_errors[] = __('Please enter valid border color.', 'anything-popup');
$pop_error_found = TRUE;
}
$form['pop_header_fontcolor'] = isset($_POST['pop_header_fontcolor']) ? sanitize_text_field($_POST['pop_header_fontcolor']) : '';
if ($form['pop_header_fontcolor'] == '')
{
$pop_errors[] = __('Please enter the heder font color.', 'anything-popup');
$pop_error_found = TRUE;
}
if(!preg_match('/^#[a-f0-9]{6}$/i',$form['pop_header_fontcolor']))
{
$pop_errors[] = __('Please enter valid heder font color.', 'anything-popup');
$pop_error_found = TRUE;
}
$form['pop_title'] = isset($_POST['pop_title']) ? sanitize_text_field($_POST['pop_title']) : '';
if ($form['pop_title'] == '')
{
$pop_errors[] = __('Please enter the popup title.', 'anything-popup');
$pop_error_found = TRUE;
}
$form['pop_content'] = isset($_POST['pop_content']) ? wp_filter_post_kses($_POST['pop_content']) : '';
if ($form['pop_content'] == '')
{
$pop_errors[] = __('Please enter the popup link text/image.', 'anything-popup');
$pop_error_found = TRUE;
}
$form['pop_caption'] = isset($_POST['pop_caption']) ? wp_filter_post_kses($_POST['pop_caption']) : '';
if ($form['pop_caption'] == '')
{
$pop_errors[] = __('Please enter the popup content.', 'anything-popup');
$pop_error_found = TRUE;
}
// No errors found, we can add this Group to the table
if ($pop_error_found == FALSE)
{
$sql = $wpdb->prepare(
"INSERT INTO `".AnythingPopupTable."`
(`pop_width`, `pop_height`, `pop_headercolor`, `pop_bordercolor`, `pop_header_fontcolor`, `pop_title`, `pop_content`, `pop_caption`)
VALUES(%s, %s, %s, %s, %s, %s, %s, %s)",
array($form['pop_width'], $form['pop_height'], $form['pop_headercolor'], $form['pop_bordercolor'], $form['pop_header_fontcolor'],
$form['pop_title'], $form['pop_content'], $form['pop_caption'])
);
$wpdb->query($sql);
$pop_success = __('New details was successfully added.', 'anything-popup');
// Reset the form fields
$form = array(
'pop_width' => '',
'pop_height' => '',
'pop_headercolor' => '',
'pop_bordercolor' => '',
'pop_header_fontcolor' => '',
'pop_title' => '',
'pop_content' => '',
'pop_caption' => '',
'pop_id' => ''
);
}
}
if ($pop_error_found == TRUE && isset($pop_errors[0]) == TRUE)
{
?>
0)
{
?>