171 changes: 170 additions & 1 deletion public/assets/css/prettyPhoto.css

Large diffs are not rendered by default.

34 changes: 27 additions & 7 deletions public/assets/js/public.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
jQuery(document).ready(function ( ) {
"use strict";
//Append the inline content to the body
jQuery(woo_popup['popup_content']).appendTo('body');
(function($){
$(function(){
"use strict";

//Open that content on load with prettyPhoto
jQuery.prettyPhoto.open('#woopopup');
//Append the inline content to the body
$(woo_popup['popup_content']).appendTo('body');

var popupTheme = plugin_options_vars.theme;

// Init Lightbox
$().prettyPhoto({
opacity: 0.80, /* Value between 0 and 1 */
show_title: true, /* true/false */
allow_resize: true, /* Resize the photos bigger than viewport. true/false */
theme: popupTheme, /* light_rounded / dark_rounded / light_square / dark_square / facebook */
horizontal_padding: 20, /* The padding on each side of the picture */
autoplay: true, /* Automatically start videos: True/False */
modal: false, /* If set to true, only the close button will close the window */
deeplinking: true, /* Allow prettyPhoto to update the url to enable deeplinking. */
keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
callback: function(){}, /* Called when prettyPhoto is closed */
social_tools: '<div class="pp_social"><div class="twitter"><a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="facebook"><iframe src="http://www.facebook.com/plugins/like.php?locale=en_US&href='+location.href+'&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:23px;" allowTransparency="true"></iframe></div></div>' /* html or false to disable */
});

//Open that content on load with prettyPhoto
$.prettyPhoto.open('#woopopup');
});
})(jQuery);

});
31 changes: 18 additions & 13 deletions public/class-woo-popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class WooPopup {
*
* @var string
*/
const VERSION = '1.2.0';
const VERSION = '1.3.0';

/**
* Unique identifier for your plugin.
Expand Down Expand Up @@ -280,7 +280,7 @@ private static function get_blog_ids() {
* @since 1.0.0
*/
private static function single_activate() {
update_option('woo-popup_options', array( 'popup_content' => 'This will be your pop up content', 'popup_page' => ' ', 'popup_class' => 'notice', 'popup_permanent' => '0', 'start_date' => date('Y-m-d', time()), 'end_date' => date('Y-m-d', time()), 'popup_timezone' => 'Europe/Paris' ));
update_option('woo-popup_options', array( 'popup_content' => 'This will be your pop up content', 'popup_page' => ' ', 'popup_class' => 'notice', 'popup_theme' => 'pp_default', 'popup_permanent' => '0', 'start_date' => date('Y-m-d', time()), 'end_date' => date('Y-m-d', time()), 'popup_timezone' => 'Europe/Paris' ));
}

/**
Expand Down Expand Up @@ -308,7 +308,7 @@ public function load_plugin_textdomain() {
}

public function trigger_plugin(){
global $post;
global $post, $popup_theme;
$options = get_option($this->options_slug);
$tz = $options['popup_timezone'];
date_default_timezone_set($tz);
Expand All @@ -317,6 +317,7 @@ public function trigger_plugin(){
$permanent = $options['popup_permanent'];
$start_date = $options['start_date'];
$end_date = $options['end_date'];
$popup_theme = $options['popup_theme'];
$diff_start = strtotime($today) - strtotime($start_date);
$diff_end = strtotime($end_date) - strtotime($today);
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) && is_shop()){
Expand All @@ -337,13 +338,11 @@ public function activated_woocommerce(){
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
global $woocommerce;
$pp_dir['base'] = $woocommerce->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js';
$pp_dir['init'] = $woocommerce->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js';
$pp_dir['base'] = $woocommerce->plugin_url() . '/assets/js/jquery.prettyPhoto.js';
$pp_dir['style'] = $woocommerce->plugin_url() . '/assets/css/prettyPhoto.css';
$pp_dir['ver'] = $woocommerce->version;
}else{
$pp_dir['base'] = plugins_url( '/assets/js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', __FILE__ );
$pp_dir['init'] = plugins_url( '/assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', __FILE__ );
$pp_dir['base'] = plugins_url( '/assets/js/jquery.prettyPhoto.js', __FILE__ );
$pp_dir['style'] = plugins_url( '/assets/css/prettyPhoto.css', __FILE__ );
$pp_dir['ver'] = '';
}
Expand All @@ -358,8 +357,8 @@ public function activated_woocommerce(){
public function enqueue_styles() {
if($this->trigger_plugin() == true){
$pp_dir = $this->activated_woocommerce();
wp_enqueue_style( $this->plugin_slug . '-plugin-styles', plugins_url( 'assets/css/public.css', __FILE__ ), array(), self::VERSION );
wp_enqueue_style( 'woocommerce_prettyPhoto_css', $pp_dir['style'] );
wp_enqueue_style( 'prettyPhoto_css', $pp_dir['style']);
wp_enqueue_style( $this->plugin_slug . '-plugin-styles', plugins_url( 'assets/css/public.css', __FILE__ ), array('prettyPhoto_css'), self::VERSION );
}
}

Expand All @@ -370,12 +369,18 @@ public function enqueue_styles() {
*/
public function enqueue_scripts() {
if($this->trigger_plugin() == true){
global $woocommerce;
global $woocommerce, $popup_theme;
$pp_dir = $this->activated_woocommerce();
wp_enqueue_script( 'prettyPhoto', $pp_dir['base'] , array( 'jquery' ), $pp_dir['ver'], true );
wp_enqueue_script( 'prettyPhoto-init', $pp_dir['init'], array( 'jquery' ), $pp_dir['ver'], true );
wp_enqueue_script( 'prettyPhoto', $pp_dir['base'] , array( 'jquery' ), $pp_dir['ver'] );

wp_enqueue_script( $this->plugin_slug . '-plugin-script', plugins_url( 'assets/js/public.js', __FILE__ ), array( 'prettyPhoto' ), self::VERSION, true );


wp_enqueue_script( $this->plugin_slug . '-plugin-script', plugins_url( 'assets/js/public.js', __FILE__ ), array( 'prettyPhoto-init' ), self::VERSION );
// Passing Plugin Options to js
$plugin_data = array(
'theme' => $popup_theme,
);
wp_localize_script( $this->plugin_slug . '-plugin-script', 'plugin_options_vars', $plugin_data );
}
}

Expand Down
6 changes: 4 additions & 2 deletions public/views/public.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
<!-- This file is used to markup the public facing aspect of the plugin. -->
<?php
$woo_popup_vars = get_option($this->options_slug);
$popup_content = do_shortcode($woo_popup_vars['popup_content']);
$formatted_popup = wpautop(stripslashes($popup_content));
// $popup_content = do_shortcode($woo_popup_vars['popupcontent']);

// $formatted_popup = wpautop(stripslashes($popup_content));
$formatted_popup = apply_filters( 'the_content', $woo_popup_vars['popup_content'] );
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ){
$class = 'woocommerce-'.$woo_popup_vars['popup_class'];
}else{
Expand Down
2 changes: 1 addition & 1 deletion woo-popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Plugin Name: woo-popup
* Plugin URI: http://wordpress.org/plugins/woo-popup/
* Description: Display a pop up window on the page of your choice.
* Version: 1.2.2
* Version: 1.3.0
* Author: Guillaume Kanoufi
* Author URI: https://github.com/g-kanoufi
* Text Domain: woo-popup-locale
Expand Down