" . $lists_msg .":
"; $lists_table .= "\n"; foreach ( $mailinglists as $list => $val ) { $checked = ( $user_lists && in_array ( $list, $user_lists )) ? "checked='checked'" : ""; // if registered add js to ajax subscribe/unsubscribe if (is_user_logged_in()) { $checkbox_js = "onchange='alo_em_user_form(\"lists\");'"; } else { $checkbox_js = ""; } $lists_table .= "\n"; //edit : added the "label" element for better accessibility } $lists_table .= "
\n"; $lists_table .= "\n"; } $preform_msg = ( alo_em_translate_option ( alo_em_get_language (), 'alo_em_custom_preform_msg',false) !="")? alo_em_translate_option ( alo_em_get_language (), 'alo_em_custom_preform_msg',false) : false; $preform_html = ( $preform_msg ) ? "
" . $preform_msg . "
\n" : ""; $disclaimer_msg = alo_em_translate_option ( alo_em_get_language (), 'alo_em_custom_disclaimer_msg',false); if ( empty( $disclaimer_msg ) ) { $disclaimer_msg = __("I agree to my submitted data being stored and used to receive newsletters", "alo-easymail"); } if (is_user_logged_in()) { // For REGISTERED USER if ( $subscriber_id ){ $optin_checked = "checked='checked'"; $optout_checked = ""; } else{ $optin_checked = ""; $optout_checked = "checked='checked'"; } $optin_msg = ( alo_em_translate_option ( alo_em_get_language (), 'alo_em_custom_optin_msg',false) !="")? alo_em_translate_option ( alo_em_get_language (), 'alo_em_custom_optin_msg',false) : __("Yes, I would like to receive the Newsletter", "alo-easymail"); $optout_msg = ( alo_em_translate_option ( alo_em_get_language (), 'alo_em_custom_optout_msg',false) !="")? alo_em_translate_option ( alo_em_get_language (), 'alo_em_custom_optout_msg',false) : __("No, please do not email me", "alo-easymail"); $html = "\n"; $html .= "
\n"; $html .= "
\n"; $html .= $preform_html; $html .= "\n"; $html .= " \n"; $html .= " \n"; $html .= " \n"; $html .= " \n"; $html .= " \n"; $html .= " \n"; $html .= " \n"; //edit : added all the next if //global $alo_em_cf; $alo_em_cf = alo_easymail_get_custom_fields(); if( $alo_em_cf ): $subscriber = alo_em_get_subscriber ( $user_email ); foreach( $alo_em_cf as $key => $value ){ $html .= " \n"; $field_id = "alo_em_".$key; // edit-by-alo $html .= " \n"; $html .= " \n"; $html .= " \n"; } endif; $html .= "
$optin_msg
$optout_msg
\n"; //$html .= sprintf( $value['edit_html'], $subscriber->ID, $subscriber->ID, format_to_edit( $subscriber->$key ) )."\n"; $prev = isset($subscriber->$key) ? format_to_edit( $subscriber->$key ) : ''; $html .= alo_easymail_custom_field_html ( $key, $value, $field_id, $prev, true, "alo_em_user_form('cf');" ); $html .= "
\n"; $html .= $lists_table; // add lists table $html .= "
\n"; //$html .= "\n"; $html .= "
\n"; } else { // For NOT-REGISTERED, PUBBLIC SUBSCRIBER $alo_em_opt_name = ( isset($_POST['alo_em_opt_name']) ) ? esc_attr( strip_tags($_POST['alo_em_opt_name']) ) : ""; $alo_em_opt_email = ( isset($_POST['alo_em_opt_email']) ) ? esc_attr( strip_tags($_POST['alo_em_opt_email']) ) : ""; $html = "\n"; $html .= "
\n"; $html .= "
\n"; $html .= $preform_html; $html .= "\n"; $html .= " \n"; if ( get_option('alo_em_hide_name_input') != 'yes' ) { $html .= " "; //edit : added the "label" element for better accessibility $html .= " \n"; } else { //$html .= " \n"; } $html .= " \n"; $html .= " \n"; $html .= " \n"; //edit : added the "label" element for better accessibility $html .= " \n"; $html .= " \n"; //edit : added all the next if $alo_em_cf = alo_easymail_get_custom_fields(); if( $alo_em_cf ): foreach( $alo_em_cf as $key => $value ){ $html .= " \n"; $field_id = "alo_em_".$key; // edit-by-alo $html .= " \n"; $html .= " \n"; $html .= " \n"; } endif; $html .= "
\n"; $html .= alo_easymail_custom_field_html ( $key, $value, $field_id, "", true ) ."\n"; $html .= "
\n"; $html .= $lists_table; // add lists table $html .= "
\n"; $html .= "\n"; $html .= "
\n"; } // and output it return $html; } /** * Class ALO_Easymail_Widget */ class ALO_Easymail_Widget extends WP_Widget { public function __construct() { /* Widget settings. NOTE: Class name must be lower case*/ $widget_ops = array( 'classname' => 'alo_easymail_widget', 'description' => __('Allow users to opt in/out of email', 'alo-easymail') ); /* Widget control settings. */ $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'alo-easymail-widget' ); /* Create the widget. */ parent::__construct( 'alo-easymail-widget', __('ALO Easymail Widget', 'alo-easymail'), $widget_ops, $control_ops ); } /** * Display the widget on the screen. */ public function widget( $args, $instance ) { global $user_ID, $user_email, $wpdb; extract( $args ); // add ALO: hide the widget in subscriber page if ( is_page( get_option('alo_em_subsc_page') ) ) return; if ( is_page( alo_em_get_subscrpage_id( alo_em_get_language() ) ) ) return; // Hide widget to users, if required in setting if ( get_option('alo_em_hide_widget_users') == "yes" && is_user_logged_in() ) return; // Our variables from the widget settings. $title = apply_filters('widget_title', $instance['title'] ); // Before widget (defined by themes). echo $before_widget; // Display the widget title if one was input (before and after defined by themes). if ( $title ) { echo $before_title . $title . $after_title; } // add ALO: print the form echo alo_em_show_widget_form (); // After widget (defined by themes). echo $after_widget; } /** * Update the widget settings. */ public function update( $new_instance, $old_instance ) { $instance = $old_instance; // Strip tags for title and name to remove HTML $instance['title'] = strip_tags( $new_instance['title'] ); return $instance; } /** * Displays the widget settings controls on the widget panel. * Make use of the get_field_id() and get_field_name() function * This handles the confusing stuff. */ public function form( $instance ) { /* Set up some default widget settings. */ $defaults = array( 'title' => __('Newsletter', 'alo-easymail') ); $instance = wp_parse_args( (array) $instance, $defaults ); $html = ""; $html .= "\r\n"; $html .= "\r\n".'

'; $html .= "\r\n".' '; $html .= "\r\n".' '; $html .= "\r\n".'

'; echo $html; } } /** * Widget activation */ function alo_em_load_widgets() { register_widget( 'ALO_Easymail_Widget' ); } add_action( 'widgets_init', 'alo_em_load_widgets' ); /* EOF */