Skip to content

Commit

Permalink
clean-up HTML templates
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyvankooten committed Sep 17, 2024
1 parent 3df4be9 commit 5160d75
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 138 deletions.
4 changes: 2 additions & 2 deletions includes/forms/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public function show_forms_page()
*/
public function show_edit_page()
{
$form_id = ( ! empty($_GET['form_id']) ) ? (int) $_GET['form_id'] : 0;
$form_id = ! empty($_GET['form_id']) ? (int) $_GET['form_id'] : 0;
$mailchimp = new MC4WP_MailChimp();
$lists = $mailchimp->get_lists();

Expand All @@ -414,7 +414,7 @@ public function show_edit_page()
}

$opts = $form->settings;
$active_tab = ( isset($_GET['tab']) ) ? $_GET['tab'] : 'fields';
$active_tab = isset($_GET['tab']) ? trim($_GET['tab']) : 'fields';

$form_preview_url = add_query_arg(
array(
Expand Down
29 changes: 2 additions & 27 deletions includes/forms/views/add-form.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
<?php defined('ABSPATH') or exit; ?>
<div id="mc4wp-admin" class="wrap mc4wp-settings">

<div class="mc4wp-row">

<!-- Main Content -->
<div class="main-content mc4wp-col">

<h1 class="mc4wp-page-title">
<?php echo esc_html__('Add new form', 'mailchimp-for-wp'); ?>
</h1>

<h2 style="display: none;"></h2><?php // fake h2 for admin notices ?>

<div style="max-width: 480px;">

<!-- Wrap entire page in <form> -->
<form method="post">

<input type="hidden" name="_mc4wp_action" value="add_form" />
<?php wp_nonce_field('_mc4wp_action', '_wpnonce'); ?>

<div class="mc4wp-margin-s">
<h3>
<label>
Expand All @@ -28,9 +18,7 @@
</h3>
<input type="text" name="mc4wp_form[name]" class="widefat" value="" spellcheck="true" autocomplete="off" placeholder="<?php echo esc_attr__('Enter your form title..', 'mailchimp-for-wp'); ?>">
</div>

<div class="mc4wp-margin-s">

<h3>
<label>
<?php echo esc_html__('To which Mailchimp lists should this form subscribe?', 'mailchimp-for-wp'); ?>
Expand Down Expand Up @@ -63,27 +51,14 @@
<?php
}
?>

</div>

<?php submit_button(esc_html__('Add new form', 'mailchimp-for-wp')); ?>


</form><!-- Entire page form wrap -->

</form>
</div>


<?php require MC4WP_PLUGIN_DIR . '/includes/views/parts/admin-footer.php'; ?>

</div><!-- / Main content -->

<!-- Sidebar -->
</div>
<div class="mc4wp-sidebar mc4wp-col">
<?php require MC4WP_PLUGIN_DIR . '/includes/views/parts/admin-sidebar.php'; ?>
</div>


</div>

</div>
28 changes: 11 additions & 17 deletions includes/forms/views/edit-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@
<a href="<?php echo esc_url(admin_url('admin.php?page=mailchimp-for-wp')); ?>">Mailchimp for WordPress</a> &rsaquo;
<a href="<?php echo esc_url(admin_url('admin.php?page=mailchimp-for-wp-forms')); ?>"><?php echo esc_html__('Forms', 'mailchimp-for-wp'); ?></a>
&rsaquo;
<span class="current-crumb"><strong><?php echo esc_html__('Form', 'mailchimp-for-wp'); ?> <?php echo $form_id; ?>
<span class="current-crumb"><strong><?php echo esc_html__('Form', 'mailchimp-for-wp'); ?> <?php echo esc_html($form_id); ?>
| <?php echo esc_html($form->name); ?></strong></span>
</p>

<!-- Main Content -->
<div>

<h1 class="mc4wp-page-title">
<?php echo esc_html__('Edit Form', 'mailchimp-for-wp'); ?>

<!-- Form actions -->
<?php

/**
Expand All @@ -44,9 +41,10 @@
?>
</h1>

<h2 style="display: none;"></h2><?php // fake h2 for admin notices ?>
<?php // fake h2 for admin notices ?>
<h2 style="display: none;"></h2>

<!-- Wrap entire page in <form> -->
<?php // wrap entire page in <form> element ?>
<form method="post">
<?php // default submit button to prevent opening preview ?>
<input type="submit" style="display: none;" />
Expand Down Expand Up @@ -75,20 +73,18 @@
<?php
foreach ($tabs as $tab => $name) {
$class = ( $active_tab === $tab ) ? 'nav-tab-active' : '';
echo sprintf('<a class="nav-tab nav-tab-%s %s" data-tab="%s" href="%s">%s</a>', $tab, $class, $tab, esc_attr($this->tab_url($tab)), $name);
$href = esc_attr($this->tab_url($tab));
echo "<a class=\"nav-tab nav-tab-{$tab} {$class}\" data-tab=\"{$tab}\" href=\"{$href}\">{$name}</a>";
}
?>
</h2>

<div id="mc4wp-tabs">

<?php

foreach ($tabs as $tab => $name) :
foreach ($tabs as $tab => $name) {
$class = ( $active_tab === $tab ) ? 'mc4wp-tab-active' : '';

// start of .tab
echo sprintf('<div class="mc4wp-tab %s" id="mc4wp-tab-%s">', $class, $tab);
echo "<div class=\"mc4wp-tab {$class}\" id=\"mc4wp-tab-{$tab}\">";

/**
* Runs when outputting a tab section on the "edit form" screen
Expand All @@ -105,15 +101,13 @@

// end of .tab
echo '</div>';
endforeach; // foreach tabs
} // foreach tabs
?>

</div><!-- / tabs -->
</div>
</div>

</form><!-- Entire page form wrap -->
</form>

<?php require MC4WP_PLUGIN_DIR . '/includes/views/parts/admin-footer.php'; ?>

</div>
</div>
14 changes: 6 additions & 8 deletions includes/forms/views/preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<html>
<head>
<title>Mailchimp for WordPress Form Preview</title>
<meta charset="utf-8" />
<meta name="robots" content="noindex" />
<link type="text/css" rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" />
<meta charset="utf-8">
<meta name="robots" content="noindex">
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">
<?php
wp_enqueue_scripts();
wp_print_styles();
Expand All @@ -28,14 +28,12 @@
max-width: 100%;
text-align: left;
}

/* hide all other elements */
<?php // hide all other elements except the form preview ?>
body::before,
body::after,
body > *:not(#form-preview) {
display:none !important;
}

#form-preview {
display: block !important;
width: 100%;
Expand All @@ -46,10 +44,10 @@
}
</style>
</head>
<body class="page-template-default page ">
<body class="page-template-default page">
<div id="form-preview" class="page type-page status-publish hentry post post-content">
<?php mc4wp_show_form($form_id); ?>
</div>
<?php wp_footer(); ?>
<?php do_action('wp_footer'); ?>
</body>
</html>
62 changes: 27 additions & 35 deletions includes/integrations/views/integration-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@
/** @var array $opts */
?>
<div id="mc4wp-admin" class="wrap mc4wp-settings">

<p class="mc4wp-breadcrumbs">
<span class="prefix"><?php echo esc_html__('You are here: ', 'mailchimp-for-wp'); ?></span>
<a href="<?php echo esc_url(admin_url('admin.php?page=mailchimp-for-wp')); ?>">Mailchimp for WordPress</a> &rsaquo;
<a href="<?php echo esc_url(admin_url('admin.php?page=mailchimp-for-wp-integrations')); ?>"><?php echo esc_html__('Integrations', 'mailchimp-for-wp'); ?></a> &rsaquo;
<span class="current-crumb"><strong><?php echo esc_html($integration->name); ?></strong></span>
</p>

<div class="mc4wp-row">

<!-- Main Content -->
<div class="main-content mc4wp-col">

<h1 class="mc4wp-page-title">
<?php printf(esc_html__('%s integration', 'mailchimp-for-wp'), esc_html($integration->name)); ?>
</h1>
Expand All @@ -32,7 +27,6 @@
<?php echo esc_html($integration->description); ?>
</p>

<!-- Settings form -->
<form method="post" action="<?php echo admin_url('options.php'); ?>">
<?php settings_fields('mc4wp_integrations_settings'); ?>

Expand All @@ -57,18 +51,19 @@
?>

<table class="form-table">

<?php
if ($integration->has_ui_element('enabled')) {
?>
<tr valign="top">
<th scope="row"><?php echo esc_html__('Enabled?', 'mailchimp-for-wp'); ?></th>
<td class="nowrap integration-toggles-wrap">
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][enabled]" value="1" <?php checked($opts['enabled'], 1); ?> /> <?php echo esc_html__('Yes', 'mailchimp-for-wp'); ?></label> &nbsp;
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][enabled]" value="0" <?php checked($opts['enabled'], 0); ?> /> <?php echo esc_html__('No', 'mailchimp-for-wp'); ?></label>
<p class="description"><?php echo sprintf(esc_html__('Enable the %s integration? This will add a sign-up checkbox to the form.', 'mailchimp-for-wp'), $integration->name); ?></p>
</td>
</tr>
<tbody>
<tr valign="top">
<th scope="row"><?php echo esc_html__('Enabled?', 'mailchimp-for-wp'); ?></th>
<td class="nowrap integration-toggles-wrap">
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][enabled]" value="1" <?php checked($opts['enabled'], 1); ?> /> <?php echo esc_html__('Yes', 'mailchimp-for-wp'); ?></label> &nbsp;
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][enabled]" value="0" <?php checked($opts['enabled'], 0); ?> /> <?php echo esc_html__('No', 'mailchimp-for-wp'); ?></label>
<p class="description"><?php echo sprintf(esc_html__('Enable the %s integration? This will add a sign-up checkbox to the form.', 'mailchimp-for-wp'), $integration->name); ?></p>
</td>
</tr>
</tbody>
<?php
}
?>
Expand Down Expand Up @@ -126,8 +121,10 @@
echo '<td>';
echo '<ul style="margin-bottom: 20px; max-height: 300px; overflow-y: auto;">';
foreach ($lists as $list) {
$checked = checked(in_array($list->id, $opts['lists'], true), true, false);
$value = esc_attr($list->id);
echo '<li><label>';
echo sprintf('<input type="checkbox" name="mc4wp_integrations[%s][lists][]" value="%s" class="mc4wp-list-input" %s> ', $integration->slug, $list->id, checked(in_array($list->id, $opts['lists'], true), true, false));
echo "<input type=\"checkbox\" name=\"mc4wp_integrations[{$integration->slug}][lists][]\" value=\"{$value}\" class=\"mc4wp-list-input\" {$checked}> ";
echo esc_html($list->name);
echo '</label></li>';
}
Expand Down Expand Up @@ -243,20 +240,20 @@
<?php
if ($integration->has_ui_element('update_existing')) {
?>
<tr valign="top">
<th scope="row"><?php echo esc_html__('Update existing subscribers?', 'mailchimp-for-wp'); ?></th>
<td class="nowrap">
<label>
<input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][update_existing]" value="1" <?php checked($opts['update_existing'], 1); ?> />&rlm;
<?php echo esc_html__('Yes', 'mailchimp-for-wp'); ?>
</label> &nbsp;
<label>
<input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][update_existing]" value="0" <?php checked($opts['update_existing'], 0); ?> />&rlm;
<?php echo esc_html__('No', 'mailchimp-for-wp'); ?>
</label>
<p class="description"><?php echo esc_html__('Select "yes" if you want to update existing subscribers with the data that is sent.', 'mailchimp-for-wp'); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php echo esc_html__('Update existing subscribers?', 'mailchimp-for-wp'); ?></th>
<td class="nowrap">
<label>
<input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][update_existing]" value="1" <?php checked($opts['update_existing'], 1); ?> />&rlm;
<?php echo esc_html__('Yes', 'mailchimp-for-wp'); ?>
</label> &nbsp;
<label>
<input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][update_existing]" value="0" <?php checked($opts['update_existing'], 0); ?> />&rlm;
<?php echo esc_html__('No', 'mailchimp-for-wp'); ?>
</label>
<p class="description"><?php echo esc_html__('Select "yes" if you want to update existing subscribers with the data that is sent.', 'mailchimp-for-wp'); ?></p>
</td>
</tr>
<?php
} // end if UI update_existing
?>
Expand Down Expand Up @@ -316,15 +313,10 @@
?>

</form>


</div>

<!-- Sidebar -->
<div class="mc4wp-sidebar mc4wp-col">
<?php require MC4WP_PLUGIN_DIR . '/includes/views/parts/admin-sidebar.php'; ?>
</div>

</div>

</div>
Loading

0 comments on commit 5160d75

Please sign in to comment.