Exemplo n.º 1
0
/**
 * Maybe submit a popup
 *
 * If a popup has been submitted we process the submission
 * and then redirect the user based on the submission result.
 *
 * @since 2.0
 * @return bool|void
 */
function wpbo_maybe_submit()
{
    if (!isset($_POST['wpbo_nonce']) || !wp_verify_nonce($_POST['wpbo_nonce'], 'subscribe')) {
        return;
    }
    if (!isset($_POST['wpbo_email']) || !isset($_POST['wpbo_id'])) {
        return;
    }
    $popup_id = filter_input(INPUT_POST, 'wpbo_id', FILTER_SANITIZE_NUMBER_INT);
    if (!WPBO_Popup::popup_exists($popup_id)) {
        return;
    }
    $popup = new WPBO_Popup($popup_id);
    $popup->submit();
}
Exemplo n.º 2
0
/**
 * Record popup impression.
 *
 * @since  1.0.0
 *
 * @param int $popup_id ID of the popup to increment
 *
 * @return integer Total number of impressions
 */
function wpbo_new_impression($popup_id = 0)
{
    if (empty($popup_id) && isset($_POST['popup_id'])) {
        $popup_id = (int) filter_input(INPUT_POST, 'popup_id', FILTER_SANITIZE_NUMBER_INT);
    }
    if (0 === $popup_id || empty($popup_id)) {
        echo 'Incorrect popup ID';
        die;
    }
    if (!WPBO_Popup::popup_exists($popup_id)) {
        echo 'Not a popup';
        die;
    }
    $popup = new WPBO_Popup($popup_id);
    echo $popup->new_impression();
    die;
}