Added login request
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
$active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'api_key';
|
||||
$is_mailchimp_post = isset($_POST['mailchimp_woocommerce_settings_hidden']) && $_POST['mailchimp_woocommerce_settings_hidden'] === 'Y';
|
||||
|
||||
$handler = MailChimp_WooCommerce_Admin::connect();
|
||||
|
||||
//Grab all options for this particular tab we're viewing.
|
||||
$options = get_option($this->plugin_name, array());
|
||||
|
||||
if (!isset($_GET['tab']) && isset($options['active_tab'])) {
|
||||
$active_tab = $options['active_tab'];
|
||||
}
|
||||
|
||||
$show_sync_tab = isset($_GET['resync']) ? $_GET['resync'] === '1' : false;;
|
||||
$show_campaign_defaults = true;
|
||||
$has_valid_api_key = false;
|
||||
$allow_new_list = true;
|
||||
|
||||
$clicked_sync_button = $is_mailchimp_post&& $active_tab == 'sync';
|
||||
|
||||
if (isset($options['mailchimp_api_key']) && $handler->hasValidApiKey()) {
|
||||
$has_valid_api_key = true;
|
||||
// if we don't have a valid api key we need to redirect back to the 'api_key' tab.
|
||||
if (($mailchimp_lists = $handler->getMailChimpLists()) && is_array($mailchimp_lists)) {
|
||||
$show_campaign_defaults = false;
|
||||
$allow_new_list = false;
|
||||
}
|
||||
|
||||
// only display this button if the data is not syncing and we have a valid api key
|
||||
if ((bool) $this->getData('sync.started_at', false)) {
|
||||
$show_sync_tab = true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<style>
|
||||
#sync-status-message strong {
|
||||
font-weight:inherit;
|
||||
}
|
||||
#log-viewer {
|
||||
background: #fff;
|
||||
border: 1px solid #e5e5e5;
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
||||
padding: 5px 20px;
|
||||
}
|
||||
#log-viewer-select {
|
||||
padding: 10px 0 8px;
|
||||
line-height: 28px;
|
||||
}
|
||||
#log-viewer pre {
|
||||
font-family: monospace;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
user agent stylesheet
|
||||
pre, xmp, plaintext, listing {
|
||||
display: block;
|
||||
font-family: monospace;
|
||||
white-space: pre;
|
||||
margin: 1em 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<?php if (!defined('PHP_VERSION_ID') || (PHP_VERSION_ID < 70000)): ?>
|
||||
<div data-dismissible="notice-php-version" class="error notice notice-error is-dismissible">
|
||||
<p><?php _e('MailChimp says: Please upgrade your PHP version to a minimum of 7.0', 'mailchimp-woocommerce'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Create a header in the default WordPress 'wrap' container -->
|
||||
<div class="wrap">
|
||||
<div id="icon-themes" class="icon32"></div>
|
||||
<h2>MailChimp Settings</h2>
|
||||
|
||||
<h2 class="nav-tab-wrapper">
|
||||
<a href="?page=mailchimp-woocommerce&tab=api_key" class="nav-tab <?php echo $active_tab == 'api_key' ? 'nav-tab-active' : ''; ?>">Connect</a>
|
||||
<?php if($has_valid_api_key): ?>
|
||||
<a href="?page=mailchimp-woocommerce&tab=store_info" class="nav-tab <?php echo $active_tab == 'store_info' ? 'nav-tab-active' : ''; ?>">Store Settings</a>
|
||||
<?php if ($handler->hasValidStoreInfo()) : ?>
|
||||
<?php if($show_campaign_defaults): ?>
|
||||
<a href="?page=mailchimp-woocommerce&tab=campaign_defaults" class="nav-tab <?php echo $active_tab == 'campaign_defaults' ? 'nav-tab-active' : ''; ?>">List Defaults</a>
|
||||
<?php endif; ?>
|
||||
<a href="?page=mailchimp-woocommerce&tab=newsletter_settings" class="nav-tab <?php echo $active_tab == 'newsletter_settings' ? 'nav-tab-active' : ''; ?>">List Settings</a>
|
||||
<?php if($show_sync_tab): ?>
|
||||
<a href="?page=mailchimp-woocommerce&tab=sync" class="nav-tab <?php echo $active_tab == 'sync' ? 'nav-tab-active' : ''; ?>">Sync</a>
|
||||
<a href="?page=mailchimp-woocommerce&tab=logs" class="nav-tab <?php echo $active_tab == 'logs' ? 'nav-tab-active' : ''; ?>">Logs</a>
|
||||
<?php endif; ?>
|
||||
<?php endif;?>
|
||||
<?php endif; ?>
|
||||
</h2>
|
||||
|
||||
<form method="post" name="cleanup_options" action="options.php">
|
||||
|
||||
<input type="hidden" name="mailchimp_woocommerce_settings_hidden" value="Y">
|
||||
|
||||
<?php
|
||||
if (!$clicked_sync_button) {
|
||||
settings_fields($this->plugin_name);
|
||||
do_settings_sections($this->plugin_name);
|
||||
include('tabs/notices.php');
|
||||
}
|
||||
?>
|
||||
|
||||
<input type="hidden" name="<?php echo $this->plugin_name; ?>[mailchimp_active_tab]" value="<?php echo esc_attr($active_tab); ?>"/>
|
||||
|
||||
<?php if ($active_tab == 'api_key' ): ?>
|
||||
<?php include_once 'tabs/api_key.php'; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($active_tab == 'store_info' && $has_valid_api_key): ?>
|
||||
<?php include_once 'tabs/store_info.php'; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($active_tab == 'campaign_defaults' ): ?>
|
||||
<?php include_once 'tabs/campaign_defaults.php'; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($active_tab == 'newsletter_settings' ): ?>
|
||||
<?php include_once 'tabs/newsletter_settings.php'; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($active_tab == 'sync' && $show_sync_tab): ?>
|
||||
<?php include_once 'tabs/store_sync.php'; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($active_tab == 'logs' && $show_sync_tab): ?>
|
||||
<?php include_once 'tabs/logs.php'; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($active_tab !== 'sync' && $active_tab !== 'logs') submit_button('Save all changes', 'primary','submit', TRUE); ?>
|
||||
|
||||
</form>
|
||||
|
||||
<?php if ($active_tab == 'sync'): ?>
|
||||
<h2 style="padding-top: 1em;">More Information</h2>
|
||||
<ul>
|
||||
<li>Have a larger store or having issues syncing? Consider using <a href="https://github.com/mailchimp/mc-woocommerce/issues/158" target="_blank">WP-CLI</a>.</li>
|
||||
<li>Order and customer information will not sync if they contain an Amazon or generic email address.</li>
|
||||
<li>Need help to connect your store? Visit the MailChimp <a href="http://kb.mailchimp.com/integrations/e-commerce/connect-or-disconnect-mailchimp-for-woocommerce/" target="_blank">Knowledge Base</a>.</li>
|
||||
<li>Want to tell us how we're doing? <a href="https://wordpress.org/support/plugin/mailchimp-for-woocommerce/reviews/" target="_blank">Leave a review on Wordpress.org</a>.</li>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
||||
</div><!-- /.wrap -->
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
if (isset($options['mailchimp_api_key']) && !$handler->hasValidApiKey()) {
|
||||
include_once __DIR__.'/errors/missing_api_key.php';
|
||||
}
|
||||
|
||||
?>
|
||||
<input type="hidden" name="mailchimp_active_settings_tab" value="api_key"/>
|
||||
|
||||
<h2 style="padding-top: 1em;">API Information</h2>
|
||||
<p>To find your MailChimp API key, log into your account settings > Extras > API keys. From there, either grab an existing key or generate a new one for your WooCommerce store. </p>
|
||||
|
||||
<!-- remove some meta and generators from the <head> -->
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>MailChimp API Key</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-mailchimp-api-key">
|
||||
<input style="width: 30%;" type="password" id="<?php echo $this->plugin_name; ?>-mailchimp-api-key" name="<?php echo $this->plugin_name; ?>[mailchimp_api_key]" value="<?php echo isset($options['mailchimp_api_key']) ? $options['mailchimp_api_key'] : '' ?>" />
|
||||
<span><?php esc_attr_e('Enter your MailChimp API key.', $this->plugin_name); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
$handler = MailChimp_WooCommerce_Admin::connect();
|
||||
|
||||
// if we don't have valid campaign defaults we need to redirect back to the 'campaign_defaults' tab.
|
||||
if (!$handler->hasValidApiKey()) {
|
||||
wp_redirect('options-general.php?page=mailchimp-woocommerce&tab=api_key&error_notice=missing_api_key');
|
||||
}
|
||||
if (!$handler->hasValidStoreInfo()) {
|
||||
wp_redirect('options-general.php?page=mailchimp-woocommerce&tab=store_info&error_notice=missing_store');
|
||||
}
|
||||
?>
|
||||
|
||||
<input type="hidden" name="mailchimp_active_settings_tab" value="campaign_defaults"/>
|
||||
|
||||
<h2 style="padding-top: 1em;">List Defaults</h2>
|
||||
<p>Please fill out the default campaign information.</p>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Contact Name</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-campaign-from-name-label">
|
||||
<input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-campaign-from-name-label" name="<?php echo $this->plugin_name; ?>[campaign_from_name]" value="<?php echo isset($options['campaign_from_name']) ? $options['campaign_from_name'] : '' ?>" />
|
||||
<span><?php esc_attr_e('Default from name', $this->plugin_name); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>From Email</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-campaign-from-email-label">
|
||||
<input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-campaign-from-email-label" name="<?php echo $this->plugin_name; ?>[campaign_from_email]" value="<?php echo isset($options['campaign_from_email']) ? $options['campaign_from_email'] : get_option('admin_email') ?>" />
|
||||
<span><?php esc_attr_e('Default from email', $this->plugin_name); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Default Subject</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-campaign-subject-label">
|
||||
<input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-campaign-subject-label" name="<?php echo $this->plugin_name; ?>[campaign_subject]" value="<?php echo isset($options['campaign_subject']) ? $options['campaign_subject'] : get_option('blogname') ?>" />
|
||||
<span><?php esc_attr_e('Default subject', $this->plugin_name); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Default Language</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-campaign-language-label">
|
||||
<select id="<?php echo $this->plugin_name; ?>-campaign-language-label" name="<?php echo $this->plugin_name; ?>[campaign_language]" style="width:30%" required>
|
||||
<?php $selected_locale = isset($options['campaign_language']) && !empty($options['campaign_language']) ? $options['campaign_language'] : 'en'; ?>
|
||||
<?php
|
||||
foreach(MailChimp_Api_Locales::simple() as $locale_key => $local_value) {
|
||||
echo '<option value="' . esc_attr( $locale_key ) . '" ' . selected($locale_key === $selected_locale, true, false ) . '>' . esc_html( $local_value ) . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<span><?php esc_attr_e('Default language', $this->plugin_name); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Permission Reminder</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-campaign-permission-reminder-label">
|
||||
<textarea style="width: 30%;" id="<?php echo $this->plugin_name; ?>-campaign-permission-reminder-label" name="<?php echo $this->plugin_name; ?>[campaign_permission_reminder]"><?php echo isset($options['campaign_permission_reminder']) ? $options['campaign_permission_reminder'] : 'You were subscribed to the newsletter from '.get_option('blogname') ?></textarea>
|
||||
<span><?php esc_attr_e('Permission reminder message', $this->plugin_name); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
if (!empty( $_REQUEST['handle'])) {
|
||||
if (!empty($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'remove_log')) {
|
||||
$log_handler = new WC_Log_Handler_File();
|
||||
$log_handler->remove($_REQUEST['handle']);
|
||||
wp_redirect('options-general.php?page=mailchimp-woocommerce&tab=logs');
|
||||
}
|
||||
}
|
||||
$files = defined('WC_LOG_DIR') ? @scandir( WC_LOG_DIR ) : array();
|
||||
$logs = array();
|
||||
if (!empty($files)) {
|
||||
foreach ($files as $key => $value) {
|
||||
if (!in_array( $value, array( '.', '..' ))) {
|
||||
if (!is_dir($value) && mailchimp_string_contains($value, 'mailchimp_woocommerce')) {
|
||||
$logs[sanitize_title($value)] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($_REQUEST['log_file']) && isset($logs[sanitize_title( $_REQUEST['log_file'])])) {
|
||||
$viewed_log = $logs[sanitize_title($_REQUEST['log_file'])];
|
||||
} elseif (!empty($logs)) {
|
||||
$viewed_log = current( $logs );
|
||||
}
|
||||
$handle = !empty($viewed_log) ? substr($viewed_log, 0, strlen($viewed_log) > 37 ? strlen($viewed_log) - 37 : strlen($viewed_log) - 4) : '';
|
||||
?>
|
||||
|
||||
<h2 style="padding-top: 1em;">Logging Preference</h2>
|
||||
<p>
|
||||
Advanced troubleshooting can be conducted with the logging capability turned on.
|
||||
By default, it’s set to “none” and you may toggle to either “standard” or “debug” as needed.
|
||||
With standard logging, you can see basic information about the data submission to MailChimp including any errors.
|
||||
“Debug” gives a much deeper insight that is useful to share with support if problems arise.
|
||||
</p>
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Logging Preference</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-logging">
|
||||
<select name="<?php echo $this->plugin_name; ?>[mailchimp_logging]" style="width:30%" required>
|
||||
<?php $logging_preference = mailchimp_environment_variables()->logging; ?>
|
||||
<?php
|
||||
foreach(array('none' => 'None', 'debug' => 'Debug', 'standard' => 'Standard',) as $log_value => $log_label) {
|
||||
echo '<option value="'.esc_attr($log_value).'" '.selected($log_value === $logging_preference, true, false ) . '>' . esc_html($log_label) . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<?php submit_button('Save all changes', 'primary','submit', TRUE);?>
|
||||
|
||||
<?php if (isset($logs) && isset($viewed_log)) : ?>
|
||||
<div id="log-viewer-select">
|
||||
<div class="alignleft">
|
||||
<h2>
|
||||
<?php echo esc_html( $viewed_log ); ?>
|
||||
<?php if ( ! empty( $handle ) ) : ?>
|
||||
<a class="page-title-action" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'handle' => $handle ), admin_url( 'options-general.php?page=mailchimp-woocommerce&tab=logs&mc_action=remove_log' ) ), 'remove_log' ) ); ?>" class="button"><?php esc_html_e( 'Delete log', 'woocommerce' );?></a>
|
||||
<?php endif; ?>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="alignright">
|
||||
<form action="<?php echo admin_url( 'options-general.php?page=mailchimp-woocommerce&tab=logs&mc_action=view_log' ); ?>" method="post">
|
||||
<input type="hidden" name="<?php echo $this->plugin_name; ?>[mailchimp_active_tab]" value="logs"/>
|
||||
<select name="log_file">
|
||||
<?php foreach ( $logs as $log_key => $log_file ) : ?>
|
||||
<option value="<?php echo esc_attr( $log_key ); ?>" <?php selected( sanitize_title( $viewed_log ), $log_key ); ?>><?php echo esc_html( $log_file ); ?> (<?php echo date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), filemtime( WC_LOG_DIR . $log_file ) ); ?>)</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<input type="submit" class="button" value="<?php esc_attr_e( 'View', 'woocommerce' ); ?>" />
|
||||
</form>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div id="log-viewer">
|
||||
<pre><?php echo esc_html( file_get_contents( WC_LOG_DIR . $viewed_log ) ); ?></pre>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="updated woocommerce-message inline"><p><?php _e( 'There are currently no logs to view.', 'woocommerce' ); ?></p></div>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
// if we don't have valid campaign defaults we need to redirect back to the 'campaign_defaults' tab.
|
||||
if (!$handler->hasValidApiKey()) {
|
||||
wp_redirect('options-general.php?page=mailchimp-woocommerce&tab=api_key&error_notice=missing_api_key');
|
||||
}
|
||||
|
||||
// if we don't have valid store information, we need to redirect back to the 'store_info' tab.
|
||||
if (!$handler->hasValidStoreInfo()) {
|
||||
wp_redirect('options-general.php?page=mailchimp-woocommerce&tab=store_info&error_notice=missing_store');
|
||||
}
|
||||
|
||||
// if we don't have a valid api key we need to redirect back to the 'api_key' tab.
|
||||
if (!isset($mailchimp_lists) && ($mailchimp_lists = $handler->getMailChimpLists()) === false) {
|
||||
wp_redirect('options-general.php?page=mailchimp-woocommerce&tab=api_key&error_notice=missing_api_key');
|
||||
}
|
||||
|
||||
// if we don't have valid campaign defaults we need to redirect back to the 'campaign_defaults' tab.
|
||||
if (empty($mailchimp_lists) && !$handler->hasValidCampaignDefaults()) {
|
||||
wp_redirect('options-general.php?page=mailchimp-woocommerce&tab=campaign_defaults&error_notice=missing_campaign_defaults');
|
||||
}
|
||||
|
||||
$list_is_configured = isset($options['mailchimp_list']) && (!empty($options['mailchimp_list'])) && array_key_exists($options['mailchimp_list'], $mailchimp_lists);
|
||||
|
||||
?>
|
||||
|
||||
<?php if(($newsletter_settings_error = $this->getData('errors.mailchimp_list', false))) : ?>
|
||||
<div class="error notice is-dismissable">
|
||||
<p><?php _e($newsletter_settings_error, 'mailchimp-woocommerce'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<input type="hidden" name="mailchimp_active_settings_tab" value="newsletter_settings"/>
|
||||
|
||||
<h2 style="padding-top: 1em;">List Settings</h2>
|
||||
<p>Please apply your list settings. If you don't have a list, you can choose to create one.</p>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>List Name</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-mailchimp-list-label">
|
||||
<select name="<?php echo $this->plugin_name; ?>[mailchimp_list]" style="width:30%" required <?php if($list_is_configured): ?> disabled <?php endif; ?>>
|
||||
|
||||
<?php if(!isset($allow_new_list) || $allow_new_list === true): ?>
|
||||
<option value="create_new">Create New List</option>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if(isset($allow_new_list) && $allow_new_list === false): ?>
|
||||
<option value="">-- Select List --</option>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
if (is_array($mailchimp_lists)) {
|
||||
$selected_list = isset($options['mailchimp_list']) ? $options['mailchimp_list'] : null;
|
||||
foreach ($mailchimp_lists as $key => $value ) {
|
||||
echo '<option value="' . esc_attr( $key ) . '" ' . selected(((string) $key === (string) $selected_list), true, false) . '>' . esc_html( $value ) . '</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<span><?php esc_attr_e('Choose a list to sync with your store.', $this->plugin_name); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Auto Subscribe On Initial Sync</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-mailchimp-auto-subscribe">
|
||||
<select name="<?php echo $this->plugin_name; ?>[mailchimp_auto_subscribe]" style="width:30%" required <?php if($list_is_configured): ?> disabled <?php endif; ?>>
|
||||
|
||||
<?php
|
||||
$enable_auto_subscribe = (array_key_exists('mailchimp_auto_subscribe', $options) && !is_null($options['mailchimp_auto_subscribe'])) ? $options['mailchimp_auto_subscribe'] : '1';
|
||||
|
||||
foreach (array('0' => 'No', '1' => 'Yes') as $key => $value ) {
|
||||
echo '<option value="' . esc_attr( $key ) . '" ' . selected($key == $enable_auto_subscribe, true, false ) . '>' . esc_html( $value ) . '</option>';
|
||||
}
|
||||
?>
|
||||
|
||||
</select>
|
||||
<span><?php esc_attr_e('During initial sync, auto subscribe the existing customers.', $this->plugin_name); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<h2 style="padding-top: 1em;">Opt-in Settings</h2>
|
||||
<p>Add text to go along with the opt-in checkbox, and choose a default display option. Customers can click a box at checkout to opt in to your newsletter. Write a signup message and choose how you want this checkbox to appear. </p>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Newsletter Label</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-newsletter-checkbox-label">
|
||||
<input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-newsletter-checkbox-label" name="<?php echo $this->plugin_name; ?>[newsletter_label]" value="<?php echo isset($options['newsletter_label']) ? $options['newsletter_label'] : 'Subscribe to our newsletter' ?>" />
|
||||
<span><?php esc_attr_e('Enter text for the opt-in checkbox', $this->plugin_name); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<h4 style="padding-top: 1em;font-weight:normal;">Checkbox Display Options</h4>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Checkbox Display Options</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-newsletter-checkbox-defaults">
|
||||
<?php $checkbox_default_settings = (array_key_exists('mailchimp_checkbox_defaults', $options) && !is_null($options['mailchimp_checkbox_defaults'])) ? $options['mailchimp_checkbox_defaults'] : 'check'; ?>
|
||||
<input type="radio" name="<?php echo $this->plugin_name; ?>[mailchimp_checkbox_defaults]" value="check"<?php if($checkbox_default_settings === 'check') echo ' checked="checked" '; ?>>Visible, checked by default<br>
|
||||
<input type="radio" name="<?php echo $this->plugin_name; ?>[mailchimp_checkbox_defaults]" value="uncheck"<?php if($checkbox_default_settings === 'uncheck') echo ' checked="checked" '; ?>>Visible, unchecked by default<br/>
|
||||
<input type="radio" name="<?php echo $this->plugin_name; ?>[mailchimp_checkbox_defaults]" value="hide"<?php if($checkbox_default_settings === 'hide') echo ' checked="checked" '; ?>>Hidden, unchecked by default<br/>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<h4 style="padding-top: 1em;font-weight:normal;">Advanced Checkbox Settings</h4>
|
||||
<p>
|
||||
To change the location of the opt-in checkbox at checkout, input one of the
|
||||
<a href="https://docs.woocommerce.com/wc-apidocs/hook-docs.html" target="_blank">
|
||||
available WooCommerce form actions.
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Newsletter Checkbox Action</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-newsletter-checkbox-action">
|
||||
<input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-newsletter-checkbox-action" name="<?php echo $this->plugin_name; ?>[mailchimp_checkbox_action]" value="<?php echo isset($options['mailchimp_checkbox_action']) ? $options['mailchimp_checkbox_action'] : 'woocommerce_after_checkout_billing_form' ?>" />
|
||||
<span><?php esc_attr_e('Enter a WooCommerce form action', $this->plugin_name); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<h2 style="padding-top: 1em;">Product Image Size</h2>
|
||||
<p>Define the product image size used by abandoned carts, order notifications, and product recommendations.</p>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Product Image Size</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-mailchimp-product_image_key">
|
||||
<select name="<?php echo $this->plugin_name; ?>[mailchimp_product_image_key]" style="width:30%">
|
||||
<?php
|
||||
$enable_auto_subscribe = (array_key_exists('mailchimp_product_image_key', $options) && !is_null($options['mailchimp_product_image_key'])) ? $options['mailchimp_product_image_key'] : 'medium';
|
||||
foreach (mailchimp_woocommerce_get_all_image_sizes_list() as $key => $value ) {
|
||||
echo '<option value="' . esc_attr( $key ) . '" ' . selected($key == $enable_auto_subscribe, true, false ) . '>' . esc_html( $value ) . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<span><?php esc_attr_e('Select an image size', $this->plugin_name); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php if(isset($_GET['error_notice'])): ?>
|
||||
<div class="error notice is-dismissable">
|
||||
<?php
|
||||
switch($_GET['error_notice']) {
|
||||
case 'missing_api_key':
|
||||
_e('MailChimp says: You must enter in a valid API key.', 'mailchimp-woocommerce');
|
||||
break;
|
||||
case 'missing_campaign_defaults':
|
||||
_e('MailChimp says: Sorry you must set up your campaign defaults before you proceed!', 'mailchimp-woocommerce');
|
||||
break;
|
||||
case 'missing_list':
|
||||
_e('MailChimp says: You must select a marketing list.', 'mailchimp-woocommerce');
|
||||
break;
|
||||
case 'missing_store':
|
||||
_e('MailChimp says: Sorry you must set up your store before you proceed!', 'mailchimp-woocommerce');
|
||||
break;
|
||||
case 'not_ready_for_sync':
|
||||
_e('MailChimp says: You are not fully ready to run the Store Sync, please verify your settings before proceeding.', 'mailchimp-woocommerce');
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($_GET['success_notice'])): ?>
|
||||
<div class="success notice is-dismissable">
|
||||
<?php
|
||||
switch($_GET['error_notice']) {
|
||||
case 're-sync-started':
|
||||
_e('MailChimp says: Your re-sync has been started!', 'mailchimp-woocommerce');
|
||||
break;
|
||||
default:
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
$handler = MailChimp_WooCommerce_Admin::connect();
|
||||
|
||||
// if we don't have valid campaign defaults we need to redirect back to the 'campaign_defaults' tab.
|
||||
if (!$handler->hasValidApiKey()) {
|
||||
wp_redirect('options-general.php?page=mailchimp-woocommerce&tab=api_key&error_notice=missing_api_key');
|
||||
}
|
||||
|
||||
?>
|
||||
<input type="hidden" name="mailchimp_active_settings_tab" value="store_info"/>
|
||||
|
||||
<h2 style="padding-top: 1em;">Store Settings</h2>
|
||||
<p>Please provide the following information about your WooCommerce store.</p>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Store Name</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-store-name-label">
|
||||
<input required style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-name-label" name="<?php echo $this->plugin_name; ?>[store_name]" value="<?php echo isset($options['store_name']) ? $options['store_name'] : get_option('blogname') ?>" />
|
||||
<span>
|
||||
<?php
|
||||
if (!empty($options['store_name']) ) {
|
||||
esc_attr_e('Name', $this->plugin_name);
|
||||
} else {
|
||||
esc_attr_e('Name', $this->plugin_name); echo '<span style="color:red;">*</span>';
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Email</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-admin-email-label">
|
||||
<input required style="width: 30%;" type="email" id="<?php echo $this->plugin_name; ?>-admin-email-label" name="<?php echo $this->plugin_name; ?>[admin_email]" value="<?php echo isset($options['admin_email']) ? $options['admin_email'] : get_option('admin_email') ?>" />
|
||||
<span>
|
||||
<?php
|
||||
if (!empty($options['admin_email']) ) {
|
||||
esc_attr_e('Email', $this->plugin_name);
|
||||
} else {
|
||||
esc_attr_e('Email', $this->plugin_name); echo '<span style="color:red;">*</span>';
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Street Address</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-store-address-label">
|
||||
<input required style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-address-label" name="<?php echo $this->plugin_name; ?>[store_street]" value="<?php echo isset($options['store_street']) ? $options['store_street'] : '' ?>" />
|
||||
<span>
|
||||
<?php
|
||||
if (!empty($options['store_street']) ) {
|
||||
esc_attr_e('Street address', $this->plugin_name);
|
||||
} else {
|
||||
esc_attr_e('Street address', $this->plugin_name); echo '<span style="color:red;">*</span>';
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>City</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-store-city-label">
|
||||
<input required style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-city-label" name="<?php echo $this->plugin_name; ?>[store_city]" value="<?php echo isset($options['store_city']) ? $options['store_city'] : '' ?>" />
|
||||
<span>
|
||||
<?php
|
||||
if (!empty($options['store_city']) ) {
|
||||
esc_attr_e('City', $this->plugin_name);
|
||||
} else {
|
||||
esc_attr_e('City', $this->plugin_name); echo '<span style="color:red;">*</span>';
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>State</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-store-state-label">
|
||||
<input required style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-state-label" name="<?php echo $this->plugin_name; ?>[store_state]" value="<?php echo isset($options['store_state']) ? $options['store_state'] : '' ?>" />
|
||||
<span>
|
||||
<?php
|
||||
if (!empty($options['store_state']) ) {
|
||||
esc_attr_e('State', $this->plugin_name);
|
||||
} else {
|
||||
esc_attr_e('State', $this->plugin_name); echo '<span style="color:red;">*</span>';
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Postal Code</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-store-state-label">
|
||||
<input required style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-postal-code-label" name="<?php echo $this->plugin_name; ?>[store_postal_code]" value="<?php echo isset($options['store_postal_code']) ? $options['store_postal_code'] : '' ?>" />
|
||||
<span>
|
||||
<?php
|
||||
if (!empty($options['store_postal_code']) ) {
|
||||
esc_attr_e('Postal Code', $this->plugin_name);
|
||||
} else {
|
||||
esc_attr_e('Postal Code', $this->plugin_name); echo '<span style="color:red;">*</span>';
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Country</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-store-country-label">
|
||||
<input required style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-country-label" name="<?php echo $this->plugin_name; ?>[store_country]" value="<?php echo isset($options['store_country']) ? $options['store_country'] : 'US' ?>" />
|
||||
<span>
|
||||
<?php
|
||||
if (!empty($options['store_country'])) {
|
||||
esc_attr_e('Country', $this->plugin_name);
|
||||
} else {
|
||||
esc_attr_e('Country', $this->plugin_name); echo '<span style="color:red;">*</span>';
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Phone</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-store-phone-label">
|
||||
<input required style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-phone-label" name="<?php echo $this->plugin_name; ?>[store_phone]" value="<?php echo isset($options['store_phone']) ? $options['store_phone'] : '' ?>" />
|
||||
<span>
|
||||
<?php
|
||||
if (!empty($options['store_phone']) ) {
|
||||
esc_attr_e('Phone Number', $this->plugin_name);
|
||||
} else {
|
||||
esc_attr_e('Phone Number', $this->plugin_name); echo '<span style="color:red;">*</span>';
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<h2 style="padding-top: 1em;">Locale Settings</h2>
|
||||
|
||||
<p>Please apply your locale settings. If you're unsure about these, use the defaults.</p>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Locale</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-store-locale-label">
|
||||
<select name="<?php echo $this->plugin_name; ?>[store_locale]" style="width:30%" required>
|
||||
<?php $selected_locale = isset($options['store_locale']) && !empty($options['store_locale']) ? $options['store_locale'] : 'en'; ?>
|
||||
<?php
|
||||
foreach(MailChimp_Api_Locales::simple() as $locale_key => $local_value) {
|
||||
echo '<option value="' . esc_attr( $locale_key ) . '" ' . selected($locale_key === $selected_locale, true, false ) . '>' . esc_html( $local_value ) . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<span><?php esc_attr_e('Locale', $this->plugin_name); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Currency Code</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-store-currency-code-label">
|
||||
<select name="<?php echo $this->plugin_name; ?>[store_currency_code]" style="width:30%" required>
|
||||
<?php
|
||||
$selected_currency_code = isset($options['store_currency_code']) && !empty($options['store_currency_code']) ? $options['store_currency_code'] : 'USD';
|
||||
foreach (MailChimp_WooCommerce_CurrencyCodes::lists() as $key => $value ) {
|
||||
echo '<option value="' . esc_attr( $key ) . '" ' . selected($key === $selected_currency_code, true, false ) . '>' . esc_html( $value ) . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<span><?php esc_attr_e('Currency', $this->plugin_name); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span>Timezone</span>
|
||||
</legend>
|
||||
<label for="<?php echo $this->plugin_name; ?>-store-timezone-label">
|
||||
<select name="<?php echo $this->plugin_name; ?>[store_timezone]" style="width:30%" required>
|
||||
<?php $selected_timezone = isset($options['store_timezone']) && !empty($options['store_timezone']) ? $options['store_timezone'] : 'America/New_York'; ?>
|
||||
<?php
|
||||
foreach(mailchimp_get_timezone_list() as $t) {
|
||||
echo '<option value="' . esc_attr( $t['zone'] ) . '" ' . selected($t['zone'] === $selected_timezone, true, false ) . '>' . esc_html( $t['diff_from_GMT'] . ' - ' . $t['zone'] ) . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<span><?php esc_attr_e('Timezone', $this->plugin_name); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
$mailchimp_total_products = $mailchimp_total_orders = 0;
|
||||
$store_id = mailchimp_get_store_id();
|
||||
$product_count = mailchimp_get_product_count();
|
||||
$order_count = mailchimp_get_order_count();
|
||||
$store_syncing = false;
|
||||
$last_updated_time = get_option('mailchimp-woocommerce-resource-last-updated');
|
||||
$sync_started_at = get_option('mailchimp-woocommerce-sync.started_at');
|
||||
if (!empty($sync_started_at)) {
|
||||
$sync_started_at = mailchimp_date_local($sync_started_at);
|
||||
} else {
|
||||
$sync_started_at = new \DateTime();
|
||||
}
|
||||
|
||||
$sync_completed_at = get_option('mailchimp-woocommerce-sync.completed_at');
|
||||
if (!empty($sync_completed_at)) {
|
||||
$sync_completed_at = mailchimp_date_local($sync_completed_at);
|
||||
} else {
|
||||
$sync_completed_at = false;
|
||||
}
|
||||
|
||||
$account_name = 'n/a';
|
||||
$mailchimp_list_name = 'n/a';
|
||||
if (!empty($last_updated_time)) {
|
||||
$last_updated_time = mailchimp_date_local($last_updated_time);
|
||||
}
|
||||
if (($mailchimp_api = mailchimp_get_api()) && ($store = $mailchimp_api->getStore($store_id))) {
|
||||
$store_syncing = $store->isSyncing();
|
||||
if (($account_details = $handler->getAccountDetails())) {
|
||||
$account_name = $account_details['account_name'];
|
||||
}
|
||||
try {
|
||||
$products = $mailchimp_api->products($store_id, 1, 1);
|
||||
$mailchimp_total_products = $products['total_items'];
|
||||
if ($mailchimp_total_products > $product_count) $mailchimp_total_products = $product_count;
|
||||
} catch (\Exception $e) { $mailchimp_total_products = 0; }
|
||||
try {
|
||||
$orders = $mailchimp_api->orders($store_id, 1, 1);
|
||||
$mailchimp_total_orders = $orders['total_items'];
|
||||
if ($mailchimp_total_orders > $order_count) $mailchimp_total_orders = $order_count;
|
||||
} catch (\Exception $e) { $mailchimp_total_orders = 0; }
|
||||
$mailchimp_list_name = $handler->getListName();
|
||||
}
|
||||
?>
|
||||
|
||||
<input type="hidden" name="mailchimp_active_settings_tab" value="store_sync"/>
|
||||
|
||||
<h2 style="padding-top: 1em;">Sync Information</h2>
|
||||
|
||||
<?php if ($sync_started_at): ?>
|
||||
<p><strong>Started:</strong> <i><?php echo $sync_started_at->format('D, M j, Y g:i A'); ?></i></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($sync_completed_at): ?>
|
||||
<p><strong>Finished:</strong> <i><?php echo $sync_completed_at->format('D, M j, Y g:i A'); ?></i></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($last_updated_time): ?>
|
||||
<p><strong>Last Updated:</strong> <i><?php echo $last_updated_time->format('D, M j, Y g:i A'); ?></i></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<p><strong>Account Connected:</strong> <?php echo $account_name; ?></p>
|
||||
<p><strong>List Connected:</strong> <?php echo $mailchimp_list_name; ?></p>
|
||||
<p><strong>Products Synced:</strong> <?php echo $mailchimp_total_products; ?></p>
|
||||
<p><strong>Orders Synced:</strong> <?php echo $mailchimp_total_orders; ?></p>
|
||||
|
||||
<?php if($mailchimp_api && (!$store_syncing || isset($_GET['resync']) && $_GET['resync'] === '1')): ?>
|
||||
<h2 style="padding-top: 1em;">Advanced</h2>
|
||||
<p>
|
||||
You can resync your list at any time without losing any of your e-commerce data.
|
||||
</p>
|
||||
<?php submit_button('Resync', 'primary','submit', TRUE); ?>
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user