コード例 #1
0
/**
 * Displays a MailChimp Signup Form
 * */
function mailchimpSF_signup_form($args = array())
{
    extract($args);
    $mv = get_option('mc_merge_vars');
    $igs = get_option('mc_interest_groups');
    // See if we have valid Merge Vars
    if (!is_array($mv)) {
        echo $before_widget;
        ?>
        <div class="mc_error_msg">
            <?php 
        esc_html_e('There was a problem loading your MailChimp details. Please re-run the setup process under Settings->MailChimp Setup', 'mailchimp_i18n');
        ?>
        </div>
        <?php 
        echo $after_widget;
        return;
    }
    // Get some options
    $uid = get_option('mc_user_id');
    $list_name = get_option('mc_list_name');
    if (!empty($before_widget)) {
        echo $before_widget;
    }
    ?>
    <style type="text/css">
        #join_revolution .main_content .content h1{
    font-family: futurabold;
    font-size: <?php 
    echo $args['headline_font_size'];
    ?>
;
    color: <?php 
    echo $args['headline_font_color'];
    ?>
;
    text-align: left;
    padding-bottom: 0px;
}
    </style>
    <div id="join_revolution">
        <div class="main_content">
            <div class="content">
                <form method="post" action="#mc_signup" id="mc_signup_form">
                    <input type="hidden" id="mc_submit_type" name="mc_submit_type" value="html" />
                    <input type="hidden" name="mcsf_action" value="mc_submit_signup_form" />
                    <?php 
    wp_nonce_field('mc_submit_signup_form', '_mc_submit_signup_form_nonce', false);
    ?>

                    <h1><?php 
    echo $args['headline'];
    ?>
</h1>
                    <p class="content"><?php 
    echo $args['content'];
    ?>
</p>
                    <div class="form">

                        <div class="updated" id="mc_message">
                            <?php 
    echo mailchimpSF_global_msg();
    ?>
                        </div><!-- /mc_message -->

                        <?php 
    //don't show the "required" stuff if there's only 1 field to display.
    $num_fields = 0;
    foreach ((array) $mv as $var) {
        $opt = 'mc_mv_' . $var['tag'];
        if ($var['req'] || get_option($opt) == 'on') {
            $num_fields++;
        }
    }
    if (is_array($mv)) {
        // head on back to the beginning of the array
        reset($mv);
    }
    // Loop over our vars, and output the ones that are set to display
    foreach ($mv as $var) {
        if (!$var['public']) {
            echo '<div style="display:none;">' . mailchimp_form_field($var, $num_fields) . '</div>';
        } else {
            echo mailchimp_form_field($var, $num_fields);
        }
    }
    // Show an explanation of the * if there's more than one field
    if ($num_fields > 1) {
        ?>
                            <div id="mc-indicates-required">
                                * = <?php 
        esc_html_e('required field', 'mailchimp_i18n');
        ?>
                            </div><!-- /mc-indicates-required -->
                            <?php 
    }
    if (is_array($igs) && !empty($igs)) {
        foreach ($igs as $ig) {
            if (is_array($ig) && isset($ig['id'])) {
                if ($igs && get_option('mc_show_interest_groups_' . $ig['id']) == 'on') {
                    if ($ig['form_field'] != 'hidden') {
                        ?>
				

                                            <div class="send_info">
                                                <span class="send_me">send me information about...</span>
                                                <?php 
                        mailchimp_interest_group_field($ig);
                        ?>
                                            </div>
                                            <?php 
                    }
                }
            }
        }
    }
    // Show our Interest groups fields if we have them, and they're set to on
    if (get_option('mc_email_type_option')) {
        ?>
                            <div class="mergeRow">
                                <label><?php 
        _e('Preferred Format', 'mailchimp_i18n');
        ?>
</label>
                                <div class="field-group groups">
                                    <ul class="mc_list">
                                        <li><input type="radio" name="email_type" id="email_type_html" value="html" checked="checked"><label for="email_type_html"><?php 
        _e('HTML', 'mailchimp_i18n');
        ?>
</label></li>
                                        <li><input type="radio" name="email_type" id="email_type_text" value="text"><label for="email_type_text"><?php 
        _e('Text', 'mailchimp_i18n');
        ?>
</label></li>
                                        <li><input type="radio" name="email_type" id="email_type_mobile" value="mobile"><label for="email_type_mobile"><?php 
        _e('Mobile', 'mailchimp_i18n');
        ?>
</label></li>
                                    </ul>
                                </div>
                            </div>	

                            <?php 
    }
    ?>

                        <a href="javascript:void(0)" onclick="jQuery('form#mc_signup_form').submit()">sign up</a>


                        <?php 
    if (get_option('mc_use_unsub_link') == 'on') {
        list($key, $dc) = explode("-", get_option('mc_apikey'), 2);
        if (!$dc) {
            $dc = "us1";
        }
        $host = 'http://' . $dc . '.list-manage.com';
        ?>
                            <div id="mc_unsub_link" align="center">
                                <a href="<?php 
        echo esc_url($host . '/unsubscribe/?u=' . get_option('mc_user_id') . '&amp;id=' . get_option('mc_list_id'));
        ?>
" target="_blank"><?php 
        esc_html_e('unsubscribe from list', 'mailchimp_i18n');
        ?>
</a>
                            </div><!-- /mc_unsub_link -->
                            <?php 
    }
    ?>

                    </div><!-- /mc_form_inside -->
                </form><!-- /mc_signup_form -->
            </div><!-- /mc_signup_container -->
        </div><!-- /mc_signup_container -->
    </div><!-- /mc_signup_container -->
    <div class="clear"></div>
    <?php 
    if (!empty($before_widget)) {
        echo $after_widget;
    }
}
コード例 #2
0
ファイル: mailchimp_widget.php プロジェクト: phpwomen/combell
/**
 * Displays a MailChimp Signup Form
 **/
function mailchimpSF_signup_form($args = array())
{
    extract($args);
    $mv = get_option('mc_merge_vars');
    $igs = get_option('mc_interest_groups');
    // See if we have valid Merge Vars
    if (!is_array($mv) && MAILCHIMP_DEV_MODE == false) {
        echo $before_widget;
        ?>
		<div class="mc_error_msg">
			<?php 
        esc_html_e('There was a problem loading your MailChimp details. Please re-run the setup process under Settings->MailChimp Setup', 'mailchimp_i18n');
        ?>
		</div>
		<?php 
        echo $after_widget;
        return;
    }
    if (!is_array($mv) && MAILCHIMP_DEV_MODE == true) {
        $mv = mailchimp_get_kitchen_sink_fields();
        $igs = mailchimp_get_kitchen_sink_groups();
    }
    if (!empty($before_widget)) {
        echo $before_widget;
    }
    $header = get_option('mc_header_content');
    if (!$header && MAILCHIMP_DEV_MODE == true) {
        $header = apply_filters('mailchimp_dev_mode_header_text', 'MailChimp Developer');
    }
    // See if we have custom header content
    if (!empty($header)) {
        // See if we need to wrap the header content in our own div
        if (strlen($header) == strlen(strip_tags($header))) {
            echo !empty($before_title) ? $before_title : '<div class="mc_custom_border_hdr">';
            echo $header;
            // don't escape $header b/c it may have HTML allowed
            echo !empty($after_title) ? $after_title : '</div><!-- /mc_custom_border_hdr -->';
        } else {
            echo $header;
            // don't escape $header b/c it may have HTML allowed
        }
    }
    $sub_heading = trim(get_option('mc_subheader_content'));
    if (!$sub_heading && MAILCHIMP_DEV_MODE == true) {
        $sub_heading = apply_filters('mailchimp_dev_mode_subheading_text', 'This is the subheading text.');
    }
    ?>

<style>
	.widget_mailchimpsf_widget .widget-title {
		line-height: 1.4em;
		margin-bottom: 0.75em;
	}
	#mc_subheader {
		line-height: 1.25em;
		margin-bottom: 18px;
	}
	.mc_merge_var {
		margin-bottom: 1.0em;
	}
	.mc_var_label,
	.mc_interest_label {
		display: block;
		margin-bottom: 0.5em;
	}
	.mc_input {
		-moz-box-sizing: border-box;
		-webkit-box-sizing: border-box;
		box-sizing: border-box;
		width: 100%;
	}
	.mc_input.mc_phone {
		width: auto;
	}
	select.mc_select {
		margin-top: 0.5em;
		width: 100%;
	}
	.mc_address_label {
		margin-top: 1.0em;
		margin-bottom: 0.5em;
		display: block;
	}
	.mc_address_label ~ select {
		width: 100%;		
	}
	.mc_list li {
		list-style: none;
		background: none !important;
	}
	.mc_interests_header {
		margin-top: 1.0em;
		margin-bottom: 0.5em;
	}
	.mc_interest label,
	.mc_interest input {
		margin-bottom: 0.4em;
	}
	#mc_signup_submit {
		margin-top: 1.5em;
		width: 80%;
	}
	#mc_unsub_link a {
		font-size: 0.75em;
	}
	#mc_unsub_link {
		margin-top: 1.0em;
	}
	.mc_header_address,
	.mc_email_format {
		display: block;
		font-weight: bold;
		margin-top: 1.0em;
		margin-bottom: 0.5em;
	}
	.mc_email_options {
		margin-top: 0.5em;
	}
	.mc_email_type {
		padding-left: 4px;
	}
</style>

<div id="mc_signup">
	<form method="post" action="#mc_signup" id="mc_signup_form">
		<input type="hidden" id="mc_submit_type" name="mc_submit_type" value="html" />
		<input type="hidden" name="mcsf_action" value="mc_submit_signup_form" />
		<?php 
    wp_nonce_field('mc_submit_signup_form', '_mc_submit_signup_form_nonce', false);
    ?>
		
	<?php 
    if ($sub_heading) {
        ?>
		<div id="mc_subheader">
			<?php 
        echo $sub_heading;
        ?>
		</div><!-- /mc_subheader -->
		<?php 
    }
    ?>
	
	<div class="mc_form_inside">
		
		<div class="updated" id="mc_message">
			<?php 
    echo mailchimpSF_global_msg();
    ?>
		</div><!-- /mc_message -->

		<?php 
    //don't show the "required" stuff if there's only 1 field to display.
    $num_fields = 0;
    foreach ((array) $mv as $var) {
        $opt = 'mc_mv_' . $var['tag'];
        if ($var['req'] || get_option($opt) == 'on') {
            $num_fields++;
        }
    }
    if (is_array($mv)) {
        // head on back to the beginning of the array
        reset($mv);
    }
    // Loop over our vars, and output the ones that are set to display
    foreach ($mv as $var) {
        if (!$var['public']) {
            echo '<div style="display:none;">' . mailchimp_form_field($var, $num_fields) . '</div>';
        } else {
            echo mailchimp_form_field($var, $num_fields);
        }
    }
    // Show an explanation of the * if there's more than one field
    if ($num_fields > 1) {
        ?>
			<div id="mc-indicates-required">
				* = <?php 
        esc_html_e('required field', 'mailchimp_i18n');
        ?>
			</div><!-- /mc-indicates-required -->
			<?php 
    }
    // Show our Interest groups fields if we have them, and they're set to on
    if (is_array($igs) && !empty($igs)) {
        foreach ($igs as $ig) {
            if (is_array($ig) && isset($ig['id'])) {
                if ($igs && get_option('mc_show_interest_groups_' . $ig['id']) == 'on' || MAILCHIMP_DEV_MODE == true) {
                    if ($ig['form_field'] != 'hidden') {
                        ?>
				
							<div class="mc_interests_header">
								<?php 
                        echo esc_html($ig['name']);
                        ?>
							</div><!-- /mc_interests_header -->
							<div class="mc_interest">
						<?php 
                    } else {
                        ?>
							<div class="mc_interest" style="display: none;">
						<?php 
                    }
                    ?>
			

					<?php 
                    mailchimp_interest_group_field($ig);
                    ?>
				
					</div><!-- /mc_interest -->
			
					<?php 
                }
            }
        }
    }
    if (get_option('mc_email_type_option') || MAILCHIMP_DEV_MODE == true) {
        ?>
		<div class="mergeRow">
			<label class="mc_email_format"><?php 
        _e('Preferred Format', 'mailchimp_i18n');
        ?>
</label>
		    <div class="field-group groups mc_email_options">
		        <ul class="mc_list">
			        <li><input type="radio" name="email_type" id="email_type_html" value="html" checked="checked"><label for="email_type_html" class="mc_email_type"><?php 
        _e('HTML', 'mailchimp_i18n');
        ?>
</label></li>
			        <li><input type="radio" name="email_type" id="email_type_text" value="text"><label for="email_type_text" class="mc_email_type"><?php 
        _e('Text', 'mailchimp_i18n');
        ?>
</label></li>
		        </ul>
			</div>
		</div>	

		<?php 
    }
    $submit_text = get_option('mc_submit_text');
    if (!$submit_text && MAILCHIMP_DEV_MODE == true) {
        $submit_text = apply_filters('mailchimp_dev_mode_submit_text', 'Subscribe');
    }
    ?>

		<div class="mc_signup_submit">
			<input type="submit" name="mc_signup_submit" id="mc_signup_submit" value="<?php 
    echo esc_attr($submit_text);
    ?>
" class="button" />
		</div><!-- /mc_signup_submit -->
	
	
		<?php 
    $user = get_option('mc_sopresto_user');
    if ($user && get_option('mc_use_unsub_link') == 'on') {
        $dc = get_option('mc_sopresto_dc', 'us1');
        $host = 'http://' . $dc . '.list-manage.com';
        ?>
			<div id="mc_unsub_link" align="center">
				<a href="<?php 
        echo esc_url($host . '/unsubscribe/?u=' . $user['user_id'] . '&amp;id=' . get_option('mc_list_id'));
        ?>
" target="_blank"><?php 
        esc_html_e('unsubscribe from list', 'mailchimp_i18n');
        ?>
</a>
			</div><!-- /mc_unsub_link -->
			<?php 
    }
    if ($user && get_option('mc_rewards') == 'on') {
        ?>
			<br/>
			<div id="mc_display_rewards" align="center">
				<?php 
        esc_html_e('powered by', 'mailchimp_i18n');
        ?>
 <a href="<?php 
        echo esc_url('http://www.mailchimp.com/affiliates/?aid=' . $user['user_id'] . '&amp;afl=1');
        ?>
">MailChimp</a>!
			</div><!-- /mc_display_rewards -->
			<?php 
    }
    ?>
		
	</div><!-- /mc_form_inside -->
	</form><!-- /mc_signup_form -->
</div><!-- /mc_signup_container -->
	<?php 
    if (!empty($after_widget)) {
        echo $after_widget;
    }
}
コード例 #3
0
ファイル: mailchimp_widget.php プロジェクト: josh73/docker
/**
 * Displays a MailChimp Signup Form
 **/
function mailchimpSF_signup_form($args = array())
{
    extract($args);
    $mv = get_option('mc_merge_vars');
    $igs = get_option('mc_interest_groups');
    // See if we have valid Merge Vars
    if (!is_array($mv)) {
        echo $before_widget;
        ?>
		<div class="mc_error_msg">
			<?php 
        esc_html_e('There was a problem loading your MailChimp details. Please re-run the setup process under Settings->MailChimp Setup', 'mailchimp_i18n');
        ?>
		</div>
		<?php 
        echo $after_widget;
        return;
    }
    // Get some options
    $uid = get_option('mc_user_id');
    $list_name = get_option('mc_list_name');
    if (!empty($before_widget)) {
        echo $before_widget;
    }
    $header = get_option('mc_header_content');
    // See if we have custom header content
    if (!empty($header)) {
        // See if we need to wrap the header content in our own div
        if (strlen($header) == strlen(strip_tags($header))) {
            echo !empty($before_title) ? $before_title : '<div class="mc_custom_border_hdr">';
            echo $header;
            // don't escape $header b/c it may have HTML allowed
            echo !empty($after_title) ? $after_title : '</div><!-- /mc_custom_border_hdr -->';
        } else {
            echo $header;
            // don't escape $header b/c it may have HTML allowed
        }
    }
    $sub_heading = trim(get_option('mc_subheader_content'));
    ?>
	
<div id="mc_signup">
	<form method="post" action="#mc_signup" id="mc_signup_form">
		<input type="hidden" id="mc_submit_type" name="mc_submit_type" value="html" />
		<input type="hidden" name="mcsf_action" value="mc_submit_signup_form" />
		<?php 
    wp_nonce_field('mc_submit_signup_form', '_mc_submit_signup_form_nonce', false);
    ?>
		
	<?php 
    if ($sub_heading) {
        ?>
		<div id="mc_subheader">
			<?php 
        echo $sub_heading;
        ?>
		</div><!-- /mc_subheader -->
		<?php 
    }
    ?>
	
	<div class="mc_form_inside">
		
		<div class="updated" id="mc_message">
			<?php 
    echo mailchimpSF_global_msg();
    ?>
		</div><!-- /mc_message -->

		<?php 
    //don't show the "required" stuff if there's only 1 field to display.
    $num_fields = 0;
    foreach ((array) $mv as $var) {
        $opt = 'mc_mv_' . $var['tag'];
        if ($var['req'] || get_option($opt) == 'on') {
            $num_fields++;
        }
    }
    if (is_array($mv)) {
        // head on back to the beginning of the array
        reset($mv);
    }
    // Loop over our vars, and output the ones that are set to display
    foreach ($mv as $var) {
        if (!$var['public']) {
            echo '<div style="display:none;">' . mailchimp_form_field($var, $num_fields) . '</div>';
        } else {
            echo mailchimp_form_field($var, $num_fields);
        }
    }
    // Show an explanation of the * if there's more than one field
    if ($num_fields > 1) {
        ?>
			<div id="mc-indicates-required">
				* = <?php 
        esc_html_e('required field', 'mailchimp_i18n');
        ?>
			</div><!-- /mc-indicates-required -->
			<?php 
    }
    // Show our Interest groups fields if we have them, and they're set to on
    if (is_array($igs) && !empty($igs)) {
        foreach ($igs as $ig) {
            if (is_array($ig) && isset($ig['id'])) {
                if ($igs && get_option('mc_show_interest_groups_' . $ig['id']) == 'on') {
                    if ($ig['form_field'] != 'hidden') {
                        ?>
				
							<div class="mc_interests_header">
								<?php 
                        echo esc_html($ig['name']);
                        ?>
							</div><!-- /mc_interests_header -->
							<div class="mc_interest">
						<?php 
                    } else {
                        ?>
							<div class="mc_interest" style="display: none;">
						<?php 
                    }
                    ?>
			

					<?php 
                    mailchimp_interest_group_field($ig);
                    ?>
				
					</div><!-- /mc_interest -->
			
					<?php 
                }
            }
        }
    }
    if (get_option('mc_email_type_option')) {
        ?>
		<div class="mergeRow">
			<label><?php 
        _e('Preferred Format', 'mailchimp_i18n');
        ?>
</label>
		    <div class="field-group groups">
		        <ul class="mc_list">
			        <li><input type="radio" name="email_type" id="email_type_html" value="html" checked="checked"><label for="email_type_html"><?php 
        _e('HTML', 'mailchimp_i18n');
        ?>
</label></li>
			        <li><input type="radio" name="email_type" id="email_type_text" value="text"><label for="email_type_text"><?php 
        _e('Text', 'mailchimp_i18n');
        ?>
</label></li>
			        <li><input type="radio" name="email_type" id="email_type_mobile" value="mobile"><label for="email_type_mobile"><?php 
        _e('Mobile', 'mailchimp_i18n');
        ?>
</label></li>
		        </ul>
			</div>
		</div>	

		<?php 
    }
    ?>

		<div class="mc_signup_submit">
			<input type="submit" name="mc_signup_submit" id="mc_signup_submit" value="<?php 
    echo esc_attr(get_option('mc_submit_text'));
    ?>
" class="button" />
		</div><!-- /mc_signup_submit -->
	
	
		<?php 
    if (get_option('mc_use_unsub_link') == 'on') {
        list($key, $dc) = explode("-", get_option('mc_apikey'), 2);
        if (!$dc) {
            $dc = "us1";
        }
        $host = 'http://' . $dc . '.list-manage.com';
        ?>
			<div id="mc_unsub_link" align="center">
				<a href="<?php 
        echo esc_url($host . '/unsubscribe/?u=' . get_option('mc_user_id') . '&amp;id=' . get_option('mc_list_id'));
        ?>
" target="_blank"><?php 
        esc_html_e('unsubscribe from list', 'mailchimp_i18n');
        ?>
</a>
			</div><!-- /mc_unsub_link -->
			<?php 
    }
    if (get_option('mc_rewards') == 'on') {
        ?>
			<br/>
			<div id="mc_display_rewards" align="center">
				<?php 
        esc_html_e('powered by', 'mailchimp_i18n');
        ?>
 <a href="<?php 
        echo esc_url('http://www.mailchimp.com/affiliates/?aid=' . get_option('mc_user_id') . '&amp;afl=1');
        ?>
">MailChimp</a>!
			</div><!-- /mc_display_rewards -->
			<?php 
    }
    ?>
		
	</div><!-- /mc_form_inside -->
	</form><!-- /mc_signup_form -->
</div><!-- /mc_signup_container -->
	<?php 
    if (!empty($before_widget)) {
        echo $after_widget;
    }
}