Created
May 29, 2014 07:17
-
-
Save groucho75/983f1bfebcc1e08b72eb to your computer and use it in GitHub Desktop.
Prompt ALO EasyMail in a dialog: put this php into /wp-content/mu-plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
// ------------------------------------------------------------------------------- | |
// EXTRA: add the "open-easymail-popup" class to have a link that opens newsletter dialog | |
// ------------------------------------------------------------------------------- | |
<a href="" class="open-easymail-popup">Newsletter</a> | |
*/ | |
function alo_easymail_dialog_enqueue_scripts() { | |
global $wp_scripts; | |
wp_enqueue_script( 'jquery' ); | |
wp_enqueue_script( 'jquery-ui-core'); | |
wp_enqueue_script ( 'jquery-ui-dialog' ); | |
wp_enqueue_script ( 'jquery-ui-resizable' ); | |
wp_enqueue_script ( 'jquery-ui-draggable' ); | |
$queryui = $wp_scripts->query('jquery-ui-core'); | |
// Choose a theme: http://jqueryui.com/themeroller/ | |
$ui_theme = 'blitzer'; | |
$url = "http://ajax.googleapis.com/ajax/libs/jqueryui/".$queryui->ver."/themes/".$ui_theme."/jquery-ui.css"; | |
wp_enqueue_style('jquery-ui-'.$ui_theme, $url, false, null); | |
} | |
add_action( 'wp_enqueue_scripts', 'alo_easymail_dialog_enqueue_scripts' ); | |
function alo_easymail_dialog_footer_scripts() { | |
global $alo_easymail_dialog_hide; | |
if ( $alo_easymail_dialog_hide ) return; | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($) { | |
if ( $('.widget.alo_easymail_widget' ).length > 0 ) | |
{ | |
$('.widget.alo_easymail_widget' ).dialog({ | |
title: "<?php esc_html_e( 'Newsletter', "alo-easymail")?>", | |
autoOpen: true, | |
zIndex: 999999, | |
modal: true | |
}); | |
$('.open-easymail-popup').click( function(e) { | |
e.preventDefault(); | |
$( ".widget.alo_easymail_widget" ).dialog( "open" ); | |
}); | |
} | |
}); | |
</script> | |
<style type="text/css"> | |
/* Input del form newsletter */ | |
.alo_easymail_form_table input { | |
color: #000000; | |
background-color: #eeeeee; | |
} | |
</style> | |
<?php | |
} | |
add_action( 'wp_footer', 'alo_easymail_dialog_footer_scripts' ); | |
/** | |
* Set cookie | |
*/ | |
function alo_easymail_dialog_set_cookie () { | |
global $alo_easymail_dialog_hide; | |
$alo_easymail_dialog_hide = true; | |
$alo_dialog_cookie = "alo_bh_hide_popup"; | |
if ( !isset($_COOKIE[ $alo_dialog_cookie ]) ) { | |
// Set a cookie to hide the newsletter untill tomorrow | |
setcookie ( $alo_dialog_cookie, "hide", time()+(60*60*24*1)); | |
$alo_easymail_dialog_hide = false; | |
} | |
} | |
add_action('init', 'alo_easymail_dialog_set_cookie' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment