<?php

/**
 * Newsletter custom template
 *
 * @author Yithemes
 * @package YITH WooCommerce Popup
 * @version 1.0.0
 */
if (!defined('YITH_YPOP_INIT')) {
    exit;
}
// Exit if accessed directly
$type_label = YITH_Popup()->get_meta($theme . '_label_position', $popup_id);
$email_label = YITH_Popup()->get_meta('_mailchimp-email-label', $popup_id);
$submit_label = YITH_Popup()->get_meta('_mailchimp-submit-label', $popup_id);
$placeholder_email = $type_label == 'placeholder' ? 'placeholder="' . $email_label . '"' : '';
$submit_icon = '';
?>
<div class="ypop-form-newsletter-wrapper">
<div class="message-box"></div>
<form method="post" action="#">
    <fieldset>
        <ul class="group">
            <li>
                <?php 
if ($type_label == 'label') {
    echo '<label for="yit_mailchimp_newsletter_form_email">' . $email_label . '</label>';
}
?>
                <div class="newsletter_form_email">
switch ($content_type) {
    case 'newsletter':
        $newsletter_integration = YITH_Popup()->get_meta('_newsletter-integration', $popup_id);
        $template_part = '/newsletters/' . $newsletter_integration . '.php';
        break;
    case 'woocommerce':
        $template_part = '/misc/woocommerce.php';
        $args['product_from'] = 'product';
        $args['products'] = YITH_Popup()->get_meta('_ypop_products', $popup_id);
        $args['category'] = YITH_Popup()->get_meta('_ypop_category', $popup_id);
        $args['show_title'] = YITH_Popup()->get_meta('_show_title', $popup_id);
        $args['show_thumbnail'] = YITH_Popup()->get_meta('_show_thumbnail', $popup_id);
        $args['show_price'] = YITH_Popup()->get_meta('_show_price', $popup_id);
        $args['show_add_to_cart'] = YITH_Popup()->get_meta('_show_add_to_cart', $popup_id);
        $args['add_to_cart_label'] = YITH_Popup()->get_meta('_add_to_cart_label', $popup_id);
        $args['show_summary'] = YITH_Popup()->get_meta('_show_summary', $popup_id);
        break;
    default:
}
?>
<style>
    .ypop-overlay{
        background-color: #000;
        opacity: <?php 
echo $overlay_opacity / 100;
?>
;
    }

    .ypop-wrapper{
        width: <?php 
<?php

$list = YITH_Popup()->get_popups_list();
if (empty($list)) {
    $desc = sprintf(__('Attention: You should create a new popup to set this option. <a href="%s">Create a new popup</a>', 'ypop'), admin_url('post-new.php?post_type=yith_popup'));
} else {
    $desc = __('Select the popup that you want to show as default', 'ypop');
}
$settings = array('settings' => array('header' => array(array('name' => __('General Settings', 'ypop'), 'type' => 'title'), array('type' => 'close')), 'general' => array(array('type' => 'open'), array('id' => 'ypop_enable', 'name' => __('Enable Popup', 'ypop'), 'desc' => '', 'type' => 'on-off', 'std' => 'yes'), array('id' => 'ypop_enable_in_mobile', 'name' => __('Enable Popup in Mobile Device', 'ypop'), 'desc' => '', 'type' => 'on-off', 'std' => 'yes'), array('name' => __('Show on all pages', 'ypop'), 'desc' => __('Enable newsletter popup in all pages.', 'ypop'), 'id' => 'ypop_enabled_everywhere', 'type' => 'on-off', 'std' => 'yes'), array('name' => __('Select where you want to show the popup', 'ypop'), 'desc' => __('Select in which pages you want to show the popup. ', 'ypop'), 'id' => 'ypop_popup_pages', 'type' => 'chosen', 'multiple' => true, 'options' => ypop_get_available_pages(), 'std' => array(), 'deps' => array('ids' => 'ypop_enabled_everywhere', 'values' => 'no')), array('name' => __('Cookie Variable', 'ypop'), 'desc' => __('Set the name for the cookie generated after closing the link of the popup. In this way, as soon as you\'ll change this value, all your visitors will see the link again even if they have disabled it. Don\'t abuse of this function!', 'ypop'), 'id' => 'ypop_cookie_var', 'type' => 'text', 'std' => __('yithpopup', 'ypop')), array('name' => __('Hide policy', 'ypop'), 'desc' => __('Select when popup should be hidden. By default, it will be hidden only when the hiding checkbox is flagged) ', 'ypop'), 'id' => 'ypop_hide_policy', 'type' => 'select', 'options' => array('always' => __('Hide when the "Hiding checkbox" is flagged', 'ypop'), 'session' => __('Show only once per session', 'ypop')), 'std' => 'always'), array('name' => __('How many days should the popup be hidden for?', 'ypop'), 'desc' => __('Set how many days have to pass before showing again the lightbox', 'ypop'), 'id' => 'ypop_hide_days', 'css' => 'width:50px;', 'type' => 'text', 'std' => '3', 'deps' => array('ids' => 'ypop_hide_policy', 'values' => 'always')), array('name' => __('Hiding text', 'ypop'), 'desc' => __('The title displayed next to the checkbox that lets users hide the popup forever. You can also use HTML code', 'ypop'), 'id' => 'ypop_hide_text', 'type' => 'text', 'std' => __('Do not show it anymore.', 'ypop')), array('name' => __('Select the default popup', 'ypop'), 'desc' => __('Attention: You should create a new popup to set this option', 'ypop'), 'desc' => $desc, 'id' => 'ypop_popup_default', 'type' => 'select', 'multiple' => false, 'options' => YITH_Popup()->get_popups_list(), 'std' => ''), array('type' => 'close'))));
return apply_filters('yith_ypop_panel_settings_options', $settings);
Esempio n. 4
0
function yith_ypop_free_constructor()
{
    // Woocommerce installation check _________________________
    if (!function_exists('WC')) {
        function yith_ypop_install_woocommerce_admin_notice()
        {
            ?>
            <div class="error">
                <p><?php 
            _e('YITH WooCommerce Popup is enabled but not effective. It requires WooCommerce in order to work.', 'ywrac');
            ?>
</p>
            </div>
            <?php 
        }
        add_action('admin_notices', 'yith_ypop_install_woocommerce_admin_notice');
        return;
    }
    // Load YWSL text domain ___________________________________
    load_plugin_textdomain('ypop', false, dirname(plugin_basename(__FILE__)) . '/languages/');
    require_once YITH_YPOP_INC . 'functions.yith-popup.php';
    require_once YITH_YPOP_INC . 'class-yith-popup-icon.php';
    require_once YITH_YPOP_INC . 'class-yith-popup-newsletter.php';
    require_once YITH_YPOP_INC . 'newsletter-integration/Mailchimp.php';
    require_once YITH_YPOP_INC . 'class-yith-popup.php';
    if (is_admin()) {
        require_once YITH_YPOP_INC . 'class-yith-popup-admin.php';
        YITH_Popup_Admin();
    } else {
        require_once YITH_YPOP_INC . 'class-yith-popup-frontend.php';
        YITH_Popup_Frontend();
    }
    YITH_Popup();
}
 /**
  * Subscribe Mailchimp user
  *
  * Add user to a mailchinmp list posted via AJAX-Request to wp_ajax_subscribe_mailchimp_user action
  *
  * @return void
  * @since 1.0.0
  * @author Antonio La Rocca <antonio.larocca@yithemes.it>
  */
 public function subscribe_mailchimp_user()
 {
     $post_id = $_REQUEST['yit_mailchimp_newsletter_form_id'];
     $mail = $_REQUEST['yit_mailchimp_newsletter_form_email'];
     $apikey = "";
     $list = "";
     if (isset($post_id) && strcmp($post_id, '') != 0) {
         $apikey = YITH_Popup()->get_meta('_mailchimp-apikey', $post_id);
         $list = YITH_Popup()->get_meta('_mailchimp-list', $post_id);
     }
     if (isset($mail) && is_email($mail)) {
         if (isset($list) && strcmp($list, '-1') != 0 && isset($apikey) && strcmp($apikey, '') != 0 && check_ajax_referer('yit_mailchimp_newsletter_form_nonce', 'yit_mailchimp_newsletter_form_nonce', false)) {
             if (!class_exists('Mailchimp')) {
                 include_once YITH_YPOP_INC . 'vendor/mailchimp/Mailchimp.php';
             }
             $mailchimp_wrapper = new Mailchimp($apikey, array('ssl_verifypeer' => false));
             $result = $mailchimp_wrapper->call('lists/batch-subscribe', array('apikey' => $apikey, 'id' => $list, 'batch' => array(array('email' => array('email' => $mail, 'email_type' => 'html'))), 'double_optin' => true));
             if ($result['error_count'] != 0) {
                 $message = '<span class="error">Something went wrong:';
                 $message .= '<ul>';
                 foreach ($result['errors'] as $error) {
                     $code = $error['code'];
                     $message .= '<li>';
                     if ($code <= 0) {
                         $message .= __('Mailchimp server error', 'ypop');
                     } elseif ($code >= 100 && $code < 120) {
                         $message .= __('Mailchimp user related error', 'ypop');
                     } elseif ($code >= 120 && $code < 200) {
                         $message .= __('Mailchimp user related error (action)', 'ypop');
                     } elseif ($code >= 200 && $code < 210) {
                         $message .= __('Mailchimp list related error', 'ypop');
                     } elseif ($code >= 210 && $code < 220) {
                         $message .= __('Mailchimp list related error (basic action)', 'ypop');
                     } elseif ($code >= 220 && $code < 230) {
                         $message .= __('Mailchimp list related error (import)', 'ypop');
                     } elseif ($code >= 230 && $code < 250) {
                         $message .= __('Mailchimp list related error (email)', 'ypop');
                     } elseif ($code >= 250 && $code < 270) {
                         $message .= __('Mailchimp list related error (merge)', 'ypop');
                     } elseif ($code >= 270 && $code < 300) {
                         $message .= __('Mailchimp list related error (interest group)', 'ypop');
                     } else {
                         $message .= __('Mailchimp general error', 'ypop');
                     }
                     $message .= '</li>';
                 }
                 $message .= '</ul></span>';
                 echo $message;
             } else {
                 _e('<span class="success">Email successfully registered</span>', 'ypop');
             }
             die;
         } else {
             _e('<span class="error">Ops! Something went wrong</span>', 'ypop');
             die;
         }
     } else {
         _e('<span class="notice">Ops! You have to use a valid email address</span>', 'ypop');
         die;
     }
 }
 public function get_current_popup()
 {
     $everywhere = YITH_Popup()->get_option('ypop_enabled_everywhere') == 'yes' ? true : false;
     $pages = array();
     if (!$everywhere) {
         $pages = YITH_Popup()->get_option('ypop_popup_pages');
     }
     $default_popup = YITH_Popup()->get_option('ypop_popup_default');
     if ($this->_current_post) {
         $welcome = get_post_meta($this->_current_post, '_welcome_popup', true);
         $post_type = get_post_type($this->_current_post);
         //for preview
         if ($post_type == YITH_Popup()->post_type_name) {
             $this->_current_popup = $this->_current_post;
             return $this->_current_popup;
         }
         if ($everywhere) {
             if ($welcome == 'disable') {
                 $this->_current_popup = 0;
             } elseif ($welcome == 'default' || $welcome == '') {
                 $this->_current_popup = $default_popup;
             } else {
                 $this->_current_popup = $welcome;
             }
         } else {
             if (!empty($pages) && in_array($this->_current_post, $pages)) {
                 if ($welcome == 'default' || $welcome == '') {
                     $this->_current_popup = $default_popup;
                 } else {
                     $this->_current_popup = $welcome;
                 }
             } else {
                 if ($welcome != 'default' && $welcome != '') {
                     $this->_current_popup = $welcome;
                 } else {
                     $this->_current_popup = 0;
                 }
             }
         }
     } else {
         $this->_current_popup = $default_popup;
     }
     return $this->_current_popup;
 }
 /**
  * Change value in a metabox
  *
  * Modify the metabox value in a textarea-editor when the value is empty
  *
  * @since  1.0
  * @author Emanuela Castorina
  */
 function textarea_metabox($args)
 {
     if (!isset($_REQUEST['post'])) {
         return $args;
     }
     $post_id = $_REQUEST['post'];
     if ($args['type'] == 'textarea-editor') {
         $meta_value = YITH_Popup()->get_meta($args['args']['args']['id'], $post_id);
         $args['args']['args']['value'] = $meta_value;
     }
     return $args;
 }
<?php

/**
 * Created by PhpStorm.
 * User: Your Inspiration
 * Date: 20/01/2015
 * Time: 12:04
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
$template_metabox = array('label' => __('Popup Template', 'ypop'), 'pages' => 'yith_popup', 'context' => 'normal', 'priority' => 'high', 'tabs' => array('template' => array('label' => __('Template', 'ypop'), 'fields' => apply_filters('ypop_template_metabox', array('template_name' => array('label' => __('Template', 'ypop'), 'type' => 'select', 'desc' => '', 'options' => YITH_Popup()->template_list, 'std' => 'none'))))));
foreach (YITH_Popup()->template_list as $key => $template) {
    $template_metabox['tabs']['template']['fields']['preview_' . $key] = array('label' => '', 'type' => 'preview', 'std' => YITH_YPOP_TEMPLATE_URL . '/themes/' . $key . '/preview/preview.jpg', 'deps' => array('ids' => '_template_name', 'values' => $key));
}
return $template_metabox;
<?php

/**
 * Created by PhpStorm.
 * User: Your Inspiration
 * Date: 20/01/2015
 * Time: 12:04
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
$post_types = get_post_types();
$esclude_post_types = apply_filters('ypop_hide_metabox_ctp', array('attachment' => 'attachment', 'revision' => 'revision', 'nav_menu_item' => 'nav_menu_item', 'yith_popup' => 'yith_popup', 'shop_order' => 'shop_order', 'shop_order_refund' => 'shop_order_refund', 'shop_coupon' => 'shop_coupon', 'shop_webhook' => 'shop_webhook', 'product_variation' => 'product_variation', 'contact-form' => 'contact-form'));
$popup_list = array('default' => __('Global setting options', 'ypop'), 'disable' => __('Disable', 'ypop')) + YITH_Popup()->get_popups_list();
$cpt_metabox = array('label' => __('YITH WooCommerce Popup ', 'ypop'), 'pages' => array_diff($post_types, $esclude_post_types), 'context' => 'normal', 'priority' => 'high', 'tabs' => array('options' => array('label' => __('Template', 'ypop'), 'fields' => apply_filters('ypop_cpt_metabox', array('welcome_popup' => array('label' => __('Popup', 'ypop'), 'type' => 'select', 'desc' => '', 'options' => $popup_list, 'std' => 'default'))))));
return $cpt_metabox;
Esempio n. 10
0
    exit;
}
// Exit if accessed directly
$type_label = YITH_Popup()->get_meta($theme . '_label_position', $popup_id);
$show_name = YITH_Popup()->get_meta('_newsletter-show-name', $popup_id);
$method = YITH_Popup()->get_meta('_newsletter-method', $popup_id);
$action = YITH_Popup()->get_meta('_newsletter-action', $popup_id);
$name_label = YITH_Popup()->get_meta('_newsletter-name-label', $popup_id);
$name_name = YITH_Popup()->get_meta('_newsletter-name-name', $popup_id);
$email_label = YITH_Popup()->get_meta('_newsletter-email-label', $popup_id);
$email_name = YITH_Popup()->get_meta('_newsletter-email-name', $popup_id);
$hidden_fields = YITH_Popup()->get_meta('_newsletter-hidden-fields', $popup_id);
$submit_label = YITH_Popup()->get_meta('_newsletter-submit-label', $popup_id);
$placeholder_name = $type_label == 'placeholder' ? 'placeholder="' . $name_label . '"' : '';
$placeholder_email = $type_label == 'placeholder' ? 'placeholder="' . $email_label . '"' : '';
$icon = YITH_Popup()->get_meta('_submit_button_icon', $popup_id);
$submit_icon = '';
if (!empty($icon)) {
    switch ($icon['select']) {
        case 'icon':
            $submit_icon = '<span class="icon" ' . ypop_get_icon_data($icon['icon']) . ' style="padding-right:10px; "></span>';
            break;
        case 'custom':
            $submit_icon = '<span class="custom_icon"><img src="' . $icon['custom'] . '" style="max-width :27px;max-height: 25px;"/></span>';
            break;
    }
}
?>
<div class="ypop-form-newsletter-wrapper">
    <form method="<?php 
echo $method;