예제 #1
0
 public function init()
 {
     global $wpbo_analytics;
     $popup_id = intval($_POST['wpbo_id']);
     $options = get_post_meta($popup_id, '_wpbo_settings', true);
     $cookie_life = isset($options['cookie_lifetime']) ? intval($options['cookie_lifetime']) : 30;
     /* Yay! We have a submission! */
     if ($this->is_submission()) {
         /* Log the convertion */
         $log = $wpbo_analytics->insert_data(array('popup_id' => $popup_id, 'data_type' => 'conversion', 'ip_address' => Better_Optin::get_ip_address(), 'referer' => esc_url($_SERVER['HTTP_REFERER']), 'user_agent' => $_SERVER['HTTP_USER_AGENT']), false);
         /* Set the cookie */
         $cookie = setcookie('wpbo_' . $popup_id, strtotime(date('Y-m-d H:i:s')), time() + 60 * 60 * $cookie_life, '/');
     }
 }
예제 #2
0
/**
 * Manually triggers a popup.
 *
 * @since  1.0.1
 * @param  array $atts Shortcode attributes
 * @return string      HTML link
 */
function wpbo_trigger_popup($atts = array())
{
    $defaults = array('popup_id' => Better_Optin::is_popup_available(), 'type' => 'button', 'label' => __('Show Popup', 'wpbo'), 'bypass_cookie' => true, 'btn_class' => '');
    extract(shortcode_atts($defaults, $atts));
    /* No popup ID? Bye bye... */
    if (false === $popup_id) {
        return false;
    }
    /* Do NOT bypass the cookie */
    if (isset($_COOKIE["wpbo_{$popup_id}"]) && false === boolval($bypass_cookie)) {
        return false;
    }
    if ('button' == $type) {
        $sc = "<button class='wpbo-trigger {$btn_class}'>{$label}</button>";
    } else {
        $sc = "<a href='#' class='wpbo-trigger {$btn_class}'>{$label}</a>";
    }
    return $sc;
}
예제 #3
0
<?php

$popup_id = isset($_GET['wpbo_popup']) ? intval($_GET['wpbo_popup']) : false;
$popup = Better_Optin::get_popup_markup($popup_id);
?>
<div class="wrap">

	<?php 
require_once WPBO_PATH . 'admin/views/customizer-controls.php';
if (false === $popup_id) {
    // Ask which popup to customize
    require_once WPBO_PATH . 'admin/views/customizer-template-selector.php';
} elseif (false === $popup) {
    // Template does not exist. Please edit popup.
    echo '<p class="wpbo-warning">';
    $link = $popup_id ? add_query_arg(array('post' => $popup_id, 'action' => 'edit'), admin_url('post.php')) : add_query_arg(array('post_type' => 'wpbo-popup'), admin_url('edit.php'));
    printf(__('There is no template selected for this popup. Please <a href="%s">edit the popup settings</a>.', 'wpbo'), $link);
    echo '</p>';
} else {
    $options = get_post_meta($popup_id, '_wpbo_settings', true);
    $bg_color = isset($options['overlay_color']) ? $options['overlay_color'] : '#000';
    $opacity = isset($options['overlay_opacity']) ? $options['overlay_opacity'] : '0.5';
    printf('<div class="wpbo"><div class="taed-admin-overlay" style="background-color: %s; opacity: %s;"></div><div class="taed-webfontload">Please be patient<br><img src="%s" alt="%s"></div>%s</div>', $bg_color, $opacity, WPBO_URL . 'admin/assets/images/ajax-loader.gif', __('Loading', 'wpbo'), $popup);
    ?>
<a href="<?php 
    echo $cancel;
    ?>
" class="button-secondary wpbo-back-btn">&larr; <?php 
    _e('Back to popup settings', 'wpbo');
    ?>
</a><?php 
 /**
  * Initialize the plugin by loading admin scripts & styles and adding a
  * settings page and menu.
  *
  * @since     1.0.0
  */
 private function __construct()
 {
     $plugin = Better_Optin::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     $plugin_basename = WPBO_BASENAME;
     $activated = get_option('wpbo_just_activated', false);
     /**
      * First thing we check if the plugin has just been activated.
      * If so, we take the user to the about page and delete the
      * option we used for the check.
      */
     if ($activated) {
         /* Delete the option */
         delete_option('wpbo_just_activated');
         /* Redirect to about page */
         wp_redirect(add_query_arg(array('post_type' => 'wpbo-popup', 'page' => 'wpbo-about'), admin_url('edit.php')));
         /* Don't do anything else */
         exit;
     }
     /* Check posts associations */
     add_action('wp_ajax_wpbo_check_page_availability', array($this, 'check_page_availability'));
     add_action('wp_ajax_wpbo_get_graph_data', array($this, 'get_graph_data'));
     add_action('wp_ajax_wpbo_tour_completed', array($this, 'tour_completed'));
     add_action('wp_ajax_wpbo_get_doc', array($this, 'get_documentation'));
     /* The following shouldn't be loaded during Ajax requests */
     if (!defined('DOING_AJAX') || !DOING_AJAX) {
         // Load admin style sheet and JavaScript.
         add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles'));
         add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
         add_action('admin_init', array($this, 'disable_autosave'));
         /* Remote dashboard notifications */
         add_action('plugins_loaded', array($this, 'remote_notices'), 11);
         // Add the options page and menu item.
         add_action('admin_menu', array($this, 'add_plugin_settings_page'));
         /* Add plugin and post actions. */
         add_filter('plugin_action_links_' . $plugin_basename, array($this, 'add_action_links'));
         add_filter('post_row_actions', array($this, 'row_action'), 10, 2);
         /* Prevent from publishing right away */
         add_filter('wp_insert_post_data', array($this, 'save_before_publish'), 99, 2);
         /* Change Publish label to Save for new popups */
         add_filter('gettext', array($this, 'change_publish_button_label'), 10, 2);
         /* Draft notice */
         add_action('admin_notices', array($this, 'unpublished_popup_notice'));
         /* Save complex custom fields */
         add_action('save_post', array($this, 'save_custom_fields'));
         /* Save the customized templates */
         if (isset($_GET['wpbo_popup']) && isset($_POST['wpbo_nonce'])) {
             add_action('init', array($this, 'save_templates'));
         }
         /* Reset to default template */
         if (isset($_GET['wpbo_reset']) && isset($_GET['wpbo_popup']) && wp_verify_nonce($_GET['wpbo_reset'], 'reset_template')) {
             add_action('init', array($this, 'reset_template'));
         }
         /* Register metaboxes */
         add_action('add_meta_boxes', array($this, 'register_metabox_steps'));
         /* Delete post relationships */
         add_action('before_delete_post', array($this, 'delete_post_relationships'));
         /* Customize footer text */
         add_filter('admin_footer_text', array($this, 'copyright'), 10, 2);
         /* Add custom column */
         add_filter('manage_wpbo-popup_posts_columns', array($this, 'relationships'), 10, 2);
         add_action('manage_wpbo-popup_posts_custom_column', array($this, 'relationships_content'), 10, 2);
     }
 }
예제 #5
0
 /**
  * Get popup ID.
  *
  * @since  1.0.0
  * @return integer ID of the popup
  */
 public static function get_popup_id()
 {
     if (is_admin()) {
         if (isset($_GET['wpbo_popup'])) {
             return $_GET['wpbo_popup'];
         }
     } else {
         return Better_Optin::is_popup_available();
     }
 }