profile.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <?php
  2. if (!defined('ABSPATH'))
  3. exit;
  4. @include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
  5. $controls = new NewsletterControls();
  6. $module = NewsletterSubscription::instance();
  7. $current_language = $module->get_current_language();
  8. $is_all_languages = $module->is_all_languages();
  9. if (!$is_all_languages) {
  10. $controls->warnings[] = 'You are configuring the language "<strong>' . $current_language . '</strong>". Switch to "all languages" to see every options.';
  11. }
  12. if (!$controls->is_action()) {
  13. $controls->data = $module->get_options('profile', $current_language);
  14. } else {
  15. if ($controls->is_action('save')) {
  16. $module->save_options($controls->data, 'profile', null, $current_language);
  17. $controls->add_message_saved();
  18. }
  19. if ($controls->is_action('reset')) {
  20. $controls->data = $module->reset_options('profile');
  21. $controls->add_message_done();
  22. }
  23. }
  24. $status = array(0 => __('Private', 'newsletter'), 1 => __('Show on profile page', 'newsletter'), 2 => __('Show on subscription form', 'newsletter'));
  25. $rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newsletter'));
  26. ?>
  27. <div class="wrap" id="tnp-wrap">
  28. <?php $help_url = 'https://www.thenewsletterplugin.com/plugins/newsletter/subscription-module'; ?>
  29. <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
  30. <div id="tnp-heading">
  31. <h2><?php _e('Subscription Form Fields and Layout', 'newsletter') ?></h2>
  32. <p>
  33. This panel contains the configuration of the subscription and profile editing forms which collect the subscriber data you want to have.<br>
  34. And let you to <strong>translate</strong> every single button and label.<br>
  35. <strong>Preferences</strong> can be an important setting for your newsletter: <a href="https://www.thenewsletterplugin.com/plugins/newsletter/newsletter-preferences" target="_blank">here you can read more about them</a>.
  36. </p>
  37. </div>
  38. <div id="tnp-body">
  39. <form action="" method="post">
  40. <?php $controls->init(); ?>
  41. <div id="tabs">
  42. <ul>
  43. <li><a href="#tabs-2">Main profile fields</a></li>
  44. <li><a href="#tabs-3">Extra profile fields</a></li>
  45. <li><a href="#tabs-5">Form code</a></li>
  46. </ul>
  47. <div id="tabs-2">
  48. <p>The main subscriber fields. Only the email field is, of course, mandatory.</p>
  49. <table class="form-table">
  50. <tr>
  51. <th>Email</th>
  52. <td>
  53. <table class="newsletter-option-grid">
  54. <tr><th>Field label</th><td><?php $controls->text('email', 50); ?></td></tr>
  55. <tr><th>Error message</th><td><?php $controls->text('email_error', 50); ?></td></tr>
  56. </table>
  57. </td>
  58. </tr>
  59. <tr>
  60. <th><?php _e('First name', 'newsletter') ?></th>
  61. <td>
  62. <table class="newsletter-option-grid">
  63. <tr><th>Field label</th><td><?php $controls->text('name', 50); ?></td></tr>
  64. <?php if ($is_all_languages) { ?>
  65. <tr><th>When to show</th><td><?php $controls->select('name_status', $status); ?></td></tr>
  66. <tr><th>Rules</th><td><?php $controls->select('name_rules', $rules); ?></td></tr>
  67. <?php } ?>
  68. <tr><th>Error message</th><td><?php $controls->text('name_error', 50); ?></td></tr>
  69. </table>
  70. <p class="description">
  71. If you want to collect only a generic "name", use only this field and not the
  72. last name field.
  73. </p>
  74. </td>
  75. </tr>
  76. <tr>
  77. <th><?php _e('Last name', 'newsletter') ?></th>
  78. <td>
  79. <table class="newsletter-option-grid">
  80. <tr><th>Field label</th><td><?php $controls->text('surname', 50); ?></td></tr>
  81. <?php if ($is_all_languages) { ?>
  82. <tr><th>When to show</th><td><?php $controls->select('surname_status', $status); ?></td></tr>
  83. <tr><th>Rules</th><td><?php $controls->select('surname_rules', $rules); ?></td></tr>
  84. <?php } ?>
  85. <tr><th>Error message</th><td><?php $controls->text('surname_error', 50); ?></td></tr>
  86. </table>
  87. </td>
  88. </tr>
  89. <tr>
  90. <th><?php _e('Gender', 'newsletter') ?></th>
  91. <td>
  92. <table class="newsletter-option-grid">
  93. <tr><th>Field label</th><td><?php $controls->text('sex', 50); ?></td></tr>
  94. <?php if ($is_all_languages) { ?>
  95. <tr><th>When to show</th><td><?php $controls->select('sex_status', $status); ?></td></tr>
  96. <tr><th>Rules</th><td><?php $controls->select('sex_rules', $rules); ?></td></tr>
  97. <?php } ?>
  98. <tr><th>Value labels</th><td>
  99. female: <?php $controls->text('sex_female'); ?>
  100. male: <?php $controls->text('sex_male'); ?>
  101. not specified: <?php $controls->text('sex_none'); ?>
  102. </td></tr>
  103. <tr><th>Salutation titles</th><td>
  104. for males: <?php $controls->text('title_male'); ?> (ex. "Mr")<br>
  105. for females: <?php $controls->text('title_female'); ?> (ex. "Mrs")<br>
  106. for others: <?php $controls->text('title_none'); ?>
  107. </td></tr>
  108. </table>
  109. <p class="description">
  110. Salutation titles are inserted in emails message when the tag {title} is used. For example
  111. "Good morning {title} {surname} {name}".
  112. </p>
  113. </td>
  114. </tr>
  115. <tr>
  116. <th><?php _e('"Subscribe" label', 'newsletter') ?></th>
  117. <td>
  118. <?php $controls->text('subscribe', 40); ?>
  119. <p class="description">
  120. You can use an image URL (http://...).
  121. </p>
  122. </td>
  123. </tr>
  124. <tr>
  125. <th>Privacy checkbox/notice</th>
  126. <td>
  127. <table class="newsletter-option-grid">
  128. <?php if ($is_all_languages) { ?>
  129. <tr><th>Enabled?</th><td><?php $controls->select('privacy_status', array(0 => 'No', 1 => 'Yes', 2 => 'Only the notice')); ?></td></tr>
  130. <?php } ?>
  131. <tr><th>Label</th><td><?php $controls->text('privacy', 50); ?></td></tr>
  132. <tr>
  133. <th>Privacy URL</th>
  134. <td>
  135. <?php if (!$is_all_languages && !empty($controls->data['privacy_use_wp_url'])) { ?>
  136. The "all language" setting is set to use the WordPress default privacy page. Please translate that page.
  137. <?php } else { ?>
  138. <?php if ($is_all_languages) { ?>
  139. <?php if (function_exists('get_privacy_policy_url') && get_privacy_policy_url()) { ?>
  140. <?php $controls->checkbox('privacy_use_wp_url', __('Use WordPress privacy URL', 'newsletter')); ?>
  141. (<a href="<?php echo esc_attr(get_privacy_policy_url()) ?>"><?php echo esc_html(get_privacy_policy_url()) ?></a>)
  142. <br>OR<br>
  143. <?php } ?>
  144. <?php } ?>
  145. <?php if (!$is_all_languages) { ?>
  146. To use the WordPress privacy page, switch to "all language" and activate it.<br>
  147. <?php } ?>
  148. <?php $controls->text_url('privacy_url', 50); ?>
  149. <?php } ?>
  150. </td>
  151. </tr>
  152. <tr>
  153. <th>Error message</th>
  154. <td><?php $controls->text('privacy_error', 50); ?></td></tr>
  155. </table>
  156. <p class="description">
  157. The privacy acceptance checkbox (required in many Europen countries) force the subscriber to
  158. check it before proceeding. If an URL is specified the label become a link.
  159. </p>
  160. </td>
  161. </tr>
  162. </table>
  163. </div>
  164. <div id="tabs-3">
  165. <p>
  166. Generic textual profile fields that can be collected during the subscription. Field formats can be one line text
  167. or selection list. Fields of type "list" must be configured with a set of options, comma separated
  168. like: "first option, second option, third option".
  169. </p>
  170. <p>
  171. The placeholder works only on HTML 5 compliant browsers.
  172. </p>
  173. <table class="form-table">
  174. <tr>
  175. <th>Error message</th>
  176. <td>
  177. <?php $controls->text('profile_error', 50); ?>
  178. </td>
  179. </tr>
  180. </table>
  181. <table class="widefat">
  182. <thead>
  183. <tr>
  184. <th>Field</th><th>Name/Label</th><th>Placeholder</th><th>When/Where</th><th>Type</th><th>Rule</th><th>List values comma separated</th>
  185. </tr>
  186. </thead>
  187. <?php for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) { ?>
  188. <tr>
  189. <td><?php echo $i; ?></td>
  190. <td><?php $controls->text('profile_' . $i); ?></td>
  191. <td><?php $controls->text('profile_' . $i . '_placeholder'); ?></td>
  192. <?php if ($is_all_languages) { ?>
  193. <td><?php $controls->select('profile_' . $i . '_status', $status); ?></td>
  194. <td><?php $controls->select('profile_' . $i . '_type', array('text' => 'Text', 'select' => 'List')); ?></td>
  195. <td><?php $controls->select('profile_' . $i . '_rules', $rules); ?></td>
  196. <?php } ?>
  197. <td>
  198. <?php $controls->textarea_fixed('profile_' . $i . '_options', '200px', '50px'); ?>
  199. </td>
  200. </tr>
  201. <?php } ?>
  202. </table>
  203. </div>
  204. <div id="tabs-5">
  205. <p>This panel shows the form HTML code generated by Newsletter if you want to copy it as starting point for a custom form.</p>
  206. <h3>Standard form code</h3>
  207. <textarea readonly style="width: 100%; height: 500px; font-family: monospace"><?php echo esc_html(NewsletterSubscription::instance()->get_subscription_form()); ?></textarea>
  208. <h3>Widget form code</h3>
  209. <textarea readonly style="width: 100%; height: 500px; font-family: monospace"><?php echo htmlspecialchars(NewsletterSubscription::instance()->get_subscription_form()); ?></textarea>
  210. </div>
  211. </div>
  212. <p>
  213. <?php $controls->button_save(); ?>
  214. <?php $controls->button_reset(); ?>
  215. </p>
  216. </form>
  217. </div>
  218. <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
  219. </div>