public function handle_optin_forms()
 {
     // Honeypot
     if (!empty($_POST['email']) || !empty($_POST['web'])) {
         echo json_encode(array('error' => 'honeypot'));
         die;
     }
     $box_id = $_POST['box_id'];
     $box_opts = apply_filters('spu/metaboxes/get_box_options', $this->helper->get_box_options($box_id), $box_id);
     // If not box opts or wrong id
     if (empty($box_opts)) {
         echo json_encode(array('error' => 'nobox'));
         die;
     }
     $sender_class = 'SPU_' . $box_opts['optin'];
     // Create provider class
     $sender = new $sender_class();
     // Map lead
     $lead = array('email' => $_POST['spu-email'], 'name' => !empty($_POST['spu-name']) ? $_POST['spu-name'] : '');
     $result = $sender->subscribe($lead, $box_opts);
     if ($result === true) {
         if (!empty($box_opts['optin_redirect'])) {
             echo json_encode(array('redirect' => $box_opts['optin_redirect'], 'lead' => $lead));
             die;
         }
         if (!empty($box_opts['optin_success'])) {
             echo json_encode(array('success_msg' => $box_opts['optin_success']));
             die;
         }
         echo json_encode(array('success' => 'true'));
     } else {
         echo json_encode(array('error' => $result));
     }
     die;
 }
Ejemplo n.º 2
0
 * @license   GPL-2.0+
 * @link      https://timersys.com
 * @copyright 2014 Timersys
 */
?>
<!-- Popups v<?php 
echo self::VERSION;
?>
 - http://wordpress.org/plugins/social-popup/--><?php 
$box = get_post($spu_id);
$helper = new Spu_Helper();
// has box with this id been found?
if (!$box instanceof WP_Post || $box->post_status !== 'publish') {
    return;
}
$opts = $helper->get_box_options($box->ID);
$css = $opts['css'];
$content = $box->post_content;
$data_attrs = '';
$box_class = '';
$width = !empty($css['width']) ? $css['width'] : '';
// run filters on content
$content = apply_filters('spu/popup/content', $content, $box);
// Qtranslate support
if (function_exists('qtrans_useCurrentLanguageIfNotFoundShowAvailable')) {
    $content = qtrans_useCurrentLanguageIfNotFoundShowAvailable($content);
}
// WPGlobus support
if (class_exists('WPGlobus')) {
    $content = WPGlobus_Core::text_filter($content, WPGlobus::Config()->language);
}