Нет описания

Templates.php 30KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. <?php
  2. /*******************************************************************************
  3. * Copyright (c) 2019, Code Atlantic LLC
  4. ******************************************************************************/
  5. if ( ! defined( 'ABSPATH' ) ) {
  6. exit;
  7. }
  8. /**
  9. * Class PUM_Admin_Templates
  10. *
  11. * @since 1.7.0
  12. */
  13. class PUM_Admin_Templates {
  14. /**
  15. *
  16. */
  17. public static function init() {
  18. if ( did_action( 'admin_footer' ) || doing_action( 'admin_footer' ) ) {
  19. self::render();
  20. } else {
  21. add_action( 'admin_footer', array( __CLASS__, 'render' ) );
  22. }
  23. }
  24. /**
  25. *
  26. */
  27. public static function render() {
  28. self::general_fields();
  29. self::html5_fields();
  30. self::custom_fields();
  31. self::misc_fields();
  32. self::helpers();
  33. self::conditions_editor();
  34. self::triggers_editor();
  35. self::cookies_editor();
  36. if ( class_exists( 'PUM_MCI' ) && version_compare( PUM_MCI::$VER, '1.3.0', '<' ) ) {
  37. ?>
  38. <script type="text/html" id="tmpl-pum-field-mc_api_key">
  39. <# var valid = data.value !== '' && <?php echo PUM_Utils_Array::safe_json_encode( pum_get_option( 'mci_api_key_is_valid', false ) ); ?>; #>
  40. <input type="{{valid ? 'password' : 'text'}}" placeholder="{{data.placeholder}}" class="{{data.size}}-text" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" {{{data.meta}}}/>
  41. <button type="button" class="pum-mci-check-api-key">
  42. <?php _e( 'Check', 'popup-maker' ); ?>
  43. <i class="dashicons dashicons-{{valid ? 'yes' : 'no'}}" style="display: {{valid ? 'inline-block' : 'none'}};"></i>
  44. </button>
  45. <?php wp_nonce_field( 'pum-mci-check-api-key', null ); ?>
  46. </script>
  47. <?php
  48. }
  49. }
  50. /**
  51. *
  52. */
  53. public static function general_fields() {
  54. ?>
  55. <script type="text/html" id="tmpl-pum-field-text">
  56. <input type="text" placeholder="{{data.placeholder}}" class="{{data.size}}-text" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" {{{data.meta}}}/>
  57. </script>
  58. <script type="text/html" id="tmpl-pum-field-password">
  59. <input type="password" placeholder="{{data.placeholder}}" class="{{data.size}}-text" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" {{{data.meta}}}/>
  60. </script>
  61. <script type="text/html" id="tmpl-pum-field-select">
  62. <select id="{{data.id}}" name="{{data.name}}" data-allow-clear="true" {{{data.meta}}}>
  63. <# _.each(data.options, function(option, key) {
  64. if (option.options !== undefined && option.options.length) { #>
  65. <optgroup label="{{{option.label}}}">
  66. <# _.each(option.options, function(option, key) { #>
  67. <option value="{{option.value}}" {{{option.meta}}}>{{option.label}}</option>
  68. <# }); #>
  69. </optgroup>
  70. <# } else { #>
  71. <option value="{{option.value}}" {{{option.meta}}}>{{{option.label}}}</option>
  72. <# }
  73. }); #>
  74. </select>
  75. </script>
  76. <script type="text/html" id="tmpl-pum-field-radio">
  77. <ul class="pum-field-radio-list">
  78. <# _.each(data.options, function(option, key) { #>
  79. <li
  80. <# print(option.value === data.value ? 'class="pum-selected"' : ''); #>>
  81. <input type="radio" id="{{data.id}}_{{key}}" name="{{data.name}}" value="{{option.value}}" {{{option.meta}}}/>
  82. <label for="{{data.id}}_{{key}}">{{{option.label}}}</label>
  83. </li>
  84. <# }); #>
  85. </ul>
  86. </script>
  87. <script type="text/html" id="tmpl-pum-field-checkbox">
  88. <input type="checkbox" id="{{data.id}}" name="{{data.name}}" value="1" {{{data.meta}}}/>
  89. </script>
  90. <script type="text/html" id="tmpl-pum-field-multicheck">
  91. <ul class="pum-field-mulitcheck-list">
  92. <# _.each(data.options, function(option, key) { #>
  93. <li>
  94. <input type="checkbox" id="{{data.id}}_{{key}}" name="{{data.name}}[{{option.value}}]" value="{{option.value}}" {{{option.meta}}}/>
  95. <label for="{{data.id}}_{{key}}">{{{option.label}}}</label>
  96. </li>
  97. <# }); #>
  98. </ul>
  99. </script>
  100. <script type="text/html" id="tmpl-pum-field-textarea">
  101. <textarea name="{{data.name}}" id="{{data.id}}" class="{{data.size}}-text" {{{data.meta}}}>{{data.value}}</textarea>
  102. </script>
  103. <script type="text/html" id="tmpl-pum-field-hidden">
  104. <input type="hidden" class="{{data.classes}}" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" {{{data.meta}}}/>
  105. </script>
  106. <?php
  107. }
  108. /**
  109. *
  110. */
  111. public static function html5_fields() {
  112. ?>
  113. <script type="text/html" id="tmpl-pum-field-range">
  114. <input type="range" placeholder="{{data.placeholder}}" class="{{data.size}}-text" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" {{{data.meta}}}/>
  115. </script>
  116. <script type="text/html" id="tmpl-pum-field-search">
  117. <input type="search" placeholder="{{data.placeholder}}" class="{{data.size}}-text" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" {{{data.meta}}}/>
  118. </script>
  119. <script type="text/html" id="tmpl-pum-field-number">
  120. <input type="number" placeholder="{{data.placeholder}}" class="{{data.size}}-text" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" {{{data.meta}}}/>
  121. </script>
  122. <script type="text/html" id="tmpl-pum-field-email">
  123. <input type="email" placeholder="{{data.placeholder}}" class="{{data.size}}-text" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" {{{data.meta}}}/>
  124. </script>
  125. <script type="text/html" id="tmpl-pum-field-url">
  126. <input type="url" placeholder="{{data.placeholder}}" class="{{data.size}}-text" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" {{{data.meta}}}/>
  127. </script>
  128. <script type="text/html" id="tmpl-pum-field-tel">
  129. <input type="tel" placeholder="{{data.placeholder}}" class="{{data.size}}-text" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" {{{data.meta}}}/>
  130. </script>
  131. <?php
  132. }
  133. /**
  134. *
  135. */
  136. public static function custom_fields() {
  137. ?>
  138. <script type="text/html" id="tmpl-pum-field-editor">
  139. <textarea name="{{data.name}}" id="{{data.id}}" class="pum-wpeditor {{data.size}}-text" {{{data.meta}}}>{{data.value}}</textarea>
  140. </script>
  141. <script type="text/html" id="tmpl-pum-field-link">
  142. <button type="button" class="dashicons dashicons-admin-generic button"></button>
  143. <input type="text" placeholder="{{data.placeholder}}" class="{{data.size}}-text" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" {{{data.meta}}}/>
  144. </script>
  145. <script type="text/html" id="tmpl-pum-field-rangeslider">
  146. <input type="text" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" class="pum-range-manual" {{{data.meta}}}/>
  147. <span class="pum-range-value-unit regular-text">{{data.unit}}</span>
  148. </script>
  149. <script type="text/html" id="tmpl-pum-field-color">
  150. <input type="text" class="pum-color-picker color-picker" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" data-default-color="{{data.std}}" {{{data.meta}}}/>
  151. </script>
  152. <script type="text/html" id="tmpl-pum-field-measure">
  153. <input type="number" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" size="5" {{{data.meta}}}/> <select id="{{data.id}}_unit" name="<# print(data.name.replace(data.id, data.id + '_unit')); #>">
  154. <# _.each(data.units, function(option, key) { #>
  155. <option value="{{option.value}}" {{{option.meta}}}>{{{option.label}}}</option>
  156. <# }); #>
  157. </select>
  158. </script>
  159. <script type="text/html" id="tmpl-pum-field-license_key">
  160. <input class="{{data.size}}-text" id="{{data.id}}" name="{{data.name}}" value="{{data.value.key}}" autocomplete="off" {{{data.meta}}}/>
  161. <# if (data.value.key !== '') { #>
  162. <?php wp_nonce_field( 'pum_license_activation', 'pum_license_activation_nonce' ); ?>
  163. <# if (data.value.status === 'valid') { #>
  164. <span class="pum-license-status"><?php _e( 'Active', 'popup-maker' ); ?></span>
  165. <input type="submit" class="button-secondary pum-license-deactivate" id="{{data.id}}_deactivate" name="pum_license_deactivate[{{data.id}}]" value="<?php _e( 'Deactivate License', 'popup-maker' ); ?>"/>
  166. <# } else { #>
  167. <span class="pum-license-status"><?php _e( 'Inactive', 'popup-maker' ); ?></span>
  168. <input type="submit" class="button-secondary pum-license-activate" id="{{data.id}}_activate" name="pum_license_activate[{{data.id}}]" value="<?php _e( 'Activate License', 'popup-maker' ); ?>"/>
  169. <# } #>
  170. <# } #>
  171. <# if (data.value.messages && data.value.messages.length) { #>
  172. <div class="pum-license-messages">
  173. <# for(var i=0; i < data.value.messages.length; i++) { #>
  174. <p>{{{data.value.messages[i]}}}</p>
  175. <# } #>
  176. </div>
  177. <# } #>
  178. </script>
  179. <script type="text/html" id="tmpl-pum-field-datetime">
  180. <div class="pum-datetime">
  181. <input placeholder="{{data.placeholder}}" data-input class="{{data.size}}-text" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" {{{data.meta}}}/>
  182. <a class="input-button" data-toggle><i class="dashicons dashicons-calendar-alt"></i></a>
  183. </div>
  184. </script>
  185. <script type="text/html" id="tmpl-pum-field-datetimerange">
  186. <div class="pum-datetime-range">
  187. <input placeholder="{{data.placeholder}}" data-input class="{{data.size}}-text" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" {{{data.meta}}}/>
  188. <a class="input-button" data-toggle><i class="dashicons dashicons-calendar-alt"></i></a>
  189. </div>
  190. </script>
  191. <script type="text/html" id="tmpl-pum-field-ga_event_labels">
  192. <# data.value = _.extend({
  193. category:'',
  194. action: '',
  195. label: '',
  196. value: 0,
  197. }, data.value); #>
  198. <table>
  199. <tbody>
  200. <tr>
  201. <td>
  202. <label for="{{data.id}}_category" style="padding-left: 3px;"><?php _e( 'Category', 'popup-maker' ); ?></label>
  203. <input type="text" style="width:100%;" id="{{data.id}}_category" name="{{data.name}}[category]" value="{{data.value.category}}"/>
  204. </td>
  205. <td>
  206. <label for="{{data.id}}_action" style="padding-left: 3px;"><?php _e( 'Action', 'popup-maker' ); ?></label>
  207. <input type="text" style="width:100%;" id="{{data.id}}_action" name="{{data.name}}[action]" value="{{data.value.action}}"/>
  208. </td>
  209. <td>
  210. <label for="{{data.id}}_label" style="padding-left: 3px;"><?php _e( 'Label', 'popup-maker' ); ?></label>
  211. <input type="text" style="width:100%;" id="{{data.id}}_label" name="{{data.name}}[label]" value="{{data.value.label}}"/>
  212. </td>
  213. <td>
  214. <label for="{{data.id}}_value" style="padding-left: 3px;"><?php _e( 'Value', 'popup-maker' ); ?></label>
  215. <input type="number" style="width:100%;height: auto;" id="{{data.id}}_value" name="{{data.name}}[value]" value="{{data.value.value}}" step="0.01" max="999999" min="0"/>
  216. </td>
  217. </tr>
  218. </tbody>
  219. </table>
  220. <hr/>
  221. </script>
  222. <?php
  223. }
  224. /**
  225. *
  226. */
  227. public static function misc_fields() {
  228. ?>
  229. <script type="text/html" id="tmpl-pum-field-section">
  230. <div class="pum-field-section {{data.classes}}">
  231. <# _.each(data.fields, function(field) { #>
  232. {{{field}}}
  233. <# }); #>
  234. </div>
  235. </script>
  236. <script type="text/html" id="tmpl-pum-field-wrapper">
  237. <div class="pum-field pum-field-{{data.type}} {{data.id}}-wrapper {{data.classes}}"
  238. data-id="{{data.id}}" <# print( data.dependencies !== '' ? "data-pum-dependencies='" + data.dependencies + "'" : ''); #> <# print( data.dynamic_desc !== '' ? "data-pum-dynamic-desc='" + data.dynamic_desc + "'" : ''); #>>
  239. <# if (typeof data.label === 'string' && data.label.length > 0) { #>
  240. <label for="{{data.id}}">
  241. {{{data.label}}}
  242. <# if (typeof data.doclink === 'string' && data.doclink !== '') { #>
  243. <a href="{{data.doclink}}" title="<?php _e( 'Documentation', 'popup-maker' ); ?>: {{data.label}}" target="_blank" class="pum-doclink dashicons dashicons-editor-help"></a>
  244. <# } #>
  245. </label>
  246. <# } else { #>
  247. <# if (typeof data.doclink === 'string' && data.doclink !== '') { #>
  248. <a href="{{data.doclink}}" title="<?php _e( 'Documentation', 'popup-maker' ); ?>: {{data.label}}" target="_blank" class="pum-doclink dashicons dashicons-editor-help"></a>
  249. <# } #>
  250. <# } #>
  251. {{{data.field}}}
  252. <# if (typeof data.desc === 'string' && data.desc.length > 0) { #>
  253. <span class="pum-desc desc">{{{data.desc}}}</span>
  254. <# } #>
  255. </div>
  256. </script>
  257. <script type="text/html" id="tmpl-pum-field-html">
  258. {{{data.content}}}
  259. </script>
  260. <script type="text/html" id="tmpl-pum-field-heading">
  261. <h3 class="pum-field-heading">{{data.desc}}</h3>
  262. </script>
  263. <script type="text/html" id="tmpl-pum-field-separator">
  264. <# if (typeof data.desc === 'string' && data.desc.length > 0 && data.desc_position === 'top') { #>
  265. <h3 class="pum-field-heading">{{data.desc}}</h3>
  266. <# } #>
  267. <hr {{{data.meta}}}/>
  268. <# if (typeof data.desc === 'string' && data.desc.length > 0 && data.desc_position === 'bottom') { #>
  269. <h3 class="pum-field-heading">{{data.desc}}</h3>
  270. <# } #>
  271. </script>
  272. <?php
  273. }
  274. /**
  275. *
  276. */
  277. public static function helpers() {
  278. ?>
  279. <script type="text/html" id="tmpl-pum-modal">
  280. <div id="{{data.id}}" class="pum-modal-background {{data.classes}}" role="dialog" aria-hidden="true" aria-labelledby="{{data.id}}-title" aria-describedby="{{data.id}}-description" {{{data.meta}}}>
  281. <div class="pum-modal-wrap">
  282. <form class="pum-form">
  283. <div class="pum-modal-header">
  284. <# if (data.title.length) { #>
  285. <span id="{{data.id}}-title" class="pum-modal-title">{{data.title}}</span>
  286. <# } #>
  287. <button type="button" class="pum-modal-close" aria-label="<?php _e( 'Close', 'popup-maker' ); ?>"></button>
  288. </div>
  289. <# if (data.description.length) { #>
  290. <span id="{{data.id}}-description" class="screen-reader-text">{{data.description}}</span>
  291. <# } #>
  292. <div class="pum-modal-content">
  293. {{{data.content}}}
  294. </div>
  295. <# if (data.save_button || data.cancel_button) { #>
  296. <div class="pum-modal-footer submitbox">
  297. <# if (data.cancel_button) { #>
  298. <div class="cancel">
  299. <button type="button" class="submitdelete no-button" href="#">{{data.cancel_button}}</button>
  300. </div>
  301. <# } #>
  302. <# if (data.save_button) { #>
  303. <div class="pum-submit">
  304. <span class="spinner"></span>
  305. <button class="button button-primary">{{data.save_button}}</button>
  306. </div>
  307. <# } #>
  308. </div>
  309. <# } #>
  310. </form>
  311. </div>
  312. </div>
  313. </script>
  314. <script type="text/html" id="tmpl-pum-tabs">
  315. <div class="pum-tabs-container {{data.classes}}" {{{data.meta}}}>
  316. <ul class="tabs">
  317. <# _.each(data.tabs, function(tab, key) { #>
  318. <li class="tab">
  319. <a href="#{{data.id + '_' + key}}">{{tab.label}}</a>
  320. </li>
  321. <# }); #>
  322. </ul>
  323. <# _.each(data.tabs, function(tab, key) { #>
  324. <div id="{{data.id + '_' + key}}" class="tab-content">
  325. {{{tab.content}}}
  326. </div>
  327. <# }); #>
  328. </div>
  329. </script>
  330. <script type="text/html" id="tmpl-pum-shortcode">
  331. [{{{data.tag}}} {{{data.meta}}}]
  332. </script>
  333. <script type="text/html" id="tmpl-pum-shortcode-w-content">
  334. [{{{data.tag}}} {{{data.meta}}}]{{{data.content}}}[/{{{data.tag}}}]
  335. </script>
  336. <?php
  337. }
  338. /**
  339. *
  340. */
  341. public static function triggers_editor() {
  342. ?>
  343. <script type="text/html" id="tmpl-pum-field-triggers">
  344. <# print(PUM_Admin.triggers.template.editor({triggers: data.value, name: data.name})); #>
  345. </script>
  346. <script type="text/html" id="tmpl-pum-trigger-editor">
  347. <div class="pum-popup-trigger-editor <# if (data.triggers && data.triggers.length) { print('has-list-items'); } #>" data-field_name="{{data.name}}">
  348. <button type="button" class="button button-primary pum-add-new no-button"><?php _e( 'Add New Trigger', 'popup-maker' ); ?></button>
  349. <p>
  350. <strong>
  351. <?php _e( 'Triggers cause a popup to open.', 'popup-maker' ); ?>
  352. <a href="<?php echo esc_url( 'https://docs.wppopupmaker.com/article/141-triggers?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=plugin-popup-editor&utm_content=triggers-option-settings' ); ?>" target="_blank"
  353. class="pum-doclink dashicons dashicons-editor-help" title="<?php esc_attr_e( sprintf( __( 'Learn more about %s', 'popup-maker' ), __( 'Triggers', 'popup-maker' ) ) ); ?>"></a>
  354. </strong>
  355. </p>
  356. <table class="list-table form-table">
  357. <thead>
  358. <tr>
  359. <th><?php _e( 'Type', 'popup-maker' ); ?></th>
  360. <th><?php _e( 'Cookie', 'popup-maker' ); ?></th>
  361. <th><?php _e( 'Settings', 'popup-maker' ); ?></th>
  362. <th><?php _e( 'Actions', 'popup-maker' ); ?></th>
  363. </tr>
  364. </thead>
  365. <tbody>
  366. <#
  367. _.each(data.triggers, function (trigger, index) {
  368. print(PUM_Admin.triggers.template.row({
  369. index: index,
  370. type: trigger.type,
  371. name: data.name,
  372. settings: trigger.settings || {}
  373. }));
  374. });
  375. #>
  376. </tbody>
  377. </table>
  378. <!-- <div class="no-triggers no-list-items">-->
  379. <!-- <div class="pum-field pum-field-select pum-field-select2">-->
  380. <!-- <label for="pum-first-trigger">--><?php //_e( 'Choose a type of trigger to get started.', 'popup-maker' ); ?><!--</label>-->
  381. <!-- <# print(PUM_Admin.triggers.template.selectbox({id: 'pum-first-trigger', name: "", placeholder: "--><?php //_e( 'Select a trigger type.', 'popup-maker' ); ?><!--"})); #>-->
  382. <!-- </div>-->
  383. <!-- </div>-->
  384. </div>
  385. </script>
  386. <script type="text/html" id="tmpl-pum-trigger-row">
  387. <tr data-index="{{data.index}}">
  388. <td class="type-column">
  389. <button type="button" class="edit no-button link-button" aria-label="<?php _e( 'Edit this trigger', 'popup-maker' ); ?>">{{PUM_Admin.triggers.getLabel(data.type)}}</button>
  390. <input class="popup_triggers_field_type" type="hidden" name="{{data.name}}[{{data.index}}][type]" value="{{data.type}}"/>
  391. <input class="popup_triggers_field_settings" type="hidden" name="{{data.name}}[{{data.index}}][settings]" value="{{JSON.stringify(data.settings)}}"/>
  392. </td>
  393. <td class="cookie-column">
  394. <code>{{PUM_Admin.triggers.cookie_column_value(data.settings.cookie_name)}}</code>
  395. </td>
  396. <td class="settings-column">{{{PUM_Admin.triggers.getSettingsDesc(data.type, data.settings)}}}</td>
  397. <td class="list-item-actions">
  398. <button type="button" class="edit dashicons dashicons-edit no-button" aria-label="<?php _e( 'Edit this trigger', 'popup-maker' ); ?>"></button>
  399. <button type="button" class="remove dashicons dashicons-no no-button" aria-label="<?php _e( 'Delete this trigger', 'popup-maker' ); ?>"></button>
  400. </td>
  401. </tr>
  402. </script>
  403. <?php
  404. $presets = apply_filters( 'pum_click_selector_presets', array(
  405. 'a[href="exact_url"]' => __( 'Link: Exact Match', 'popup-maker' ),
  406. 'a[href*="contains"]' => __( 'Link: Containing', 'popup-maker' ),
  407. 'a[href^="begins_with"]' => __( 'Link: Begins With', 'popup-maker' ),
  408. 'a[href$="ends_with"]' => __( 'Link: Ends With', 'popup-maker' ),
  409. ) );
  410. ?>
  411. <script type="text/html" id="tmpl-pum-click-selector-presets">
  412. <div class="pum-click-selector-presets">
  413. <span class="dashicons dashicons-arrow-left" title="<?php _e( 'Insert Preset', 'popup-maker' ); ?>"></span>
  414. <ul>
  415. <?php foreach ( $presets as $preset => $label ) : ?>
  416. <li data-preset='<?php echo $preset; ?>'>
  417. <span><?php echo $label; ?></span>
  418. </li>
  419. <?php endforeach; ?>
  420. </ul>
  421. </div>
  422. </script>
  423. <script type="text/html" id="tmpl-pum-trigger-add-type">
  424. <#
  425. var form_args = <?php echo PUM_Utils_Array::safe_json_encode( array(
  426. 'id' => 'pum-add-trigger',
  427. 'fields' => array(
  428. 'popup_trigger_add_type' => array(
  429. 'id' => 'popup_trigger_add_type',
  430. 'name' => "",
  431. 'label' => __( 'What kind of trigger do you want?', 'popup-maker' ),
  432. 'type' => 'select',
  433. 'options' => PUM_Triggers::instance()->dropdown_list(),
  434. ),
  435. 'popup_trigger_add_cookie' => array(
  436. 'id' => 'popup_trigger_add_cookie',
  437. 'name' => "",
  438. 'type' => 'checkbox',
  439. 'std' => true,
  440. 'label' => __( 'Prevent popup from showing to visitor again using a cookie?', 'popup-maker' ),
  441. 'meta' => array('checked' => 'checked')
  442. ),
  443. 'popup_trigger_add_cookie_event' => array(
  444. 'id' => 'popup_trigger_add_cookie_event',
  445. 'name' => "",
  446. 'type' => 'select',
  447. 'label' => __( 'Stop showing popup once visitor takes this action:', 'popup-maker' ),
  448. 'options' => PUM_Cookies::instance()->dropdown_list(),
  449. 'dependencies' => array(
  450. 'popup_trigger_add_cookie' => true,
  451. ),
  452. ),
  453. 'popup_trigger_add_cookie_info' => array(
  454. 'id' => 'popup_trigger_add_cookie_info',
  455. 'type' => 'html',
  456. 'content' => '<p>Learn more about <a href="https://docs.wppopupmaker.com/article/358-popup-settings-box-cookies-option-settings?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=plugin-popup-editor&utm_content=new-trigger-cookie-info">how Popup Maker cookies work</a>.</p>'
  457. ),
  458. ),
  459. ) ); ?>,
  460. content = PUM_Admin.forms.render(form_args, {});
  461. print(PUM_Admin.templates.modal({
  462. id: 'pum_trigger_add_type_modal',
  463. title: '<?php _e( 'New Trigger', 'popup-maker' ); ?>',
  464. content: content,
  465. save_button: pum_admin_vars.I10n.add || '<?php __( 'Add', 'popup-maker' ); ?>'
  466. }));
  467. #>
  468. </script>
  469. <?php
  470. }
  471. /**
  472. *
  473. */
  474. public static function conditions_editor() {
  475. ?>
  476. <script type="text/html" id="tmpl-pum-field-conditions">
  477. <# print(PUM_Admin.conditions.template.editor({groups: data.value})); #>
  478. </script>
  479. <script type="text/html" id="tmpl-pum-condition-editor">
  480. <div class="facet-builder <# if (data.groups && data.groups.length) { print('has-conditions'); } #>">
  481. <p>
  482. <strong>
  483. <?php _e( 'Conditions allow you to show your popup to a targeted segment of your sites users.', 'popup-maker' ); ?>
  484. <?php printf( '%2$s<i class="dashicons dashicons-editor-help" title="%1$s"></i>%3$s', sprintf( __( 'Learn more about %s', 'popup-maker' ), __( 'Targeting Conditions', 'popup-maker' ) ), '<a href="https://docs.wppopupmaker.com/article/351-popup-settings-box-targeting-option-settings?utm_medium=inline-doclink&utm_campaign=contextual-help&utm_source=plugin-popup-editor&utm_content=targeting-option-settings" target="_blank">', '</a>' ); ?>
  485. </strong>
  486. </p>
  487. <ul class="ul-disc">
  488. <li><?php _e( 'By default, this popup will be loaded on every page of your site for all users.', 'popup-maker' ); ?></li>
  489. <li><?php _e( 'Target the popup to a specific segment by adding conditions below.', 'popup-maker' ); ?></li>
  490. <li><?php printf( __( 'Click the %s button for any condition to check the opposite of the chosen condition. The button will turn red %s when active.', 'popup-maker' ), '<i style="font-size: 1em; width: 1em; height: 1em; line-height:1.5em;" class="dashicons dashicons-warning"></i>', '<i style="width: 1em; height: 1em; font-size: 1em; line-height:1.5em; color:#a00;" class="dashicons dashicons-warning"></i>' ); ?></li>
  491. </ul>
  492. <section class="pum-alert-box" style="display:none"></section>
  493. <div class="facet-groups condition-groups">
  494. <#
  495. _.each(data.groups, function (group, group_ID) {
  496. print(PUM_Admin.conditions.template.group({
  497. index: group_ID,
  498. facets: group
  499. }));
  500. });
  501. #>
  502. </div>
  503. <div class="no-facet-groups">
  504. <label for="pum-first-condition"><?php _e( 'Choose a condition to target your popup to specific content or various other segments.', 'popup-maker' ); ?></label>
  505. <div class="facet-target">
  506. <button type="button" class="pum-not-operand dashicons-before dashicons-warning no-button" aria-label="<?php _e( 'Enable the Not Operand', 'popup-maker' ); ?>">
  507. <input type="checkbox" id="pum-first-facet-operand" value="1"/>
  508. </button>
  509. <# print(PUM_Admin.conditions.template.selectbox({id: 'pum-first-condition', name: "", placeholder: "<?php _e( 'Choose a condition', 'popup-maker' ); ?>"})); #>
  510. </div>
  511. </div>
  512. </div>
  513. </script>
  514. <script type="text/html" id="tmpl-pum-condition-group">
  515. <div class="facet-group-wrap" data-index="{{data.index}}">
  516. <section class="facet-group">
  517. <div class="facet-list">
  518. <# _.each(data.facets, function (facet) {
  519. print(PUM_Admin.conditions.template.facet(facet));
  520. }); #>
  521. </div>
  522. <div class="add-or">
  523. <button type="button" class="add add-facet no-button" aria-label="<?php _ex( 'Add another OR condition', 'aria-label for add new OR condition button', 'popup-maker' ); ?>"><?php _e( 'or', 'popup-maker' ); ?></button>
  524. </div>
  525. </section>
  526. <p class="and">
  527. <button type="button" class="add-facet no-button" aria-label="<?php _ex( 'Add another AND condition group', 'aria-label for add new AND condition button', 'popup-maker' ); ?>"><?php _e( 'and', 'popup-maker' ); ?></button>
  528. </p>
  529. </div>
  530. </script>
  531. <script type="text/html" id="tmpl-pum-condition-facet">
  532. <div class="facet" data-index="{{data.index}}" data-target="{{data.target}}">
  533. <i class="or"><?php _e( 'or', 'popup-maker' ); ?></i>
  534. <div class="facet-col facet-target <# if (typeof data.not_operand !== 'undefined' && data.not_operand == '1') print('not-operand-checked'); #>">
  535. <button type="button" class="pum-not-operand dashicons-before dashicons-warning no-button" aria-label="<?php _e( 'Enable the Not Operand', 'popup-maker' ); ?>">
  536. <input type="checkbox" name="popup_settings[conditions][{{data.group}}][{{data.index}}][not_operand]" value="1"
  537. <# if (typeof data.not_operand !== 'undefined') print(PUM_Admin.utils.checked(data.not_operand, true, true)); #> />
  538. </button>
  539. <# print(PUM_Admin.conditions.template.selectbox({index: data.index, group: data.group, value: data.target, placeholder: "<?php _e( 'Choose a condition', 'popup-maker' ); ?>"})); #>
  540. </div>
  541. <div class="facet-settings facet-col">
  542. <# print(PUM_Admin.conditions.template.settings(data, data.settings)); #>
  543. </div>
  544. <div class="facet-actions">
  545. <button type="button" class="remove remove-facet dashicons dashicons-dismiss no-button" aria-label="<?php _e( 'Remove Condition', 'popup-maker' ); ?>"></button>
  546. </div>
  547. </div>
  548. </script>
  549. <?php
  550. }
  551. /**
  552. *
  553. */
  554. public static function cookies_editor() {
  555. ?>
  556. <script type="text/html" id="tmpl-pum-field-cookies">
  557. <# print(PUM_Admin.cookies.template.editor({cookies: data.value, name: data.name})); #>
  558. </script>
  559. <script type="text/html" id="tmpl-pum-cookie-editor">
  560. <div class="pum-popup-cookie-editor <# if (data.cookies && data.cookies.length) { print('has-list-items'); } #>" data-field_name="{{data.name}}">
  561. <button type="button" class="button button-primary pum-add-new no-button"><?php _e( 'Add New Cookie', 'popup-maker' ); ?></button>
  562. <p>
  563. <strong>
  564. <?php _e( 'Cookies control the repeat display of a popup.', 'popup-maker' ); ?>
  565. <a href="<?php echo esc_url( 'https://docs.wppopupmaker.com/article/358-popup-settings-box-cookies-option-settings?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=plugin-popup-editor&utm_content=cookies-option-settings' ); ?>"
  566. target="_blank" class="pum-doclink dashicons dashicons-editor-help" title="<?php esc_attr_e( sprintf( __( 'Learn more about %s', 'popup-maker' ), __( 'Cookies', 'popup-maker' ) ) ); ?>"></a>
  567. </strong>
  568. </p>
  569. <table class="list-table form-table">
  570. <thead>
  571. <tr>
  572. <th><?php _e( 'Event', 'popup-maker' ); ?></th>
  573. <th><?php _e( 'Name', 'popup-maker' ); ?></th>
  574. <th><?php _e( 'Settings', 'popup-maker' ); ?></th>
  575. <th><?php _e( 'Actions', 'popup-maker' ); ?></th>
  576. </tr>
  577. </thead>
  578. <tbody>
  579. <#
  580. _.each(data.cookies, function (cookie, index) {
  581. print(PUM_Admin.cookies.template.row({
  582. index: index,
  583. event: cookie.event,
  584. name: data.name,
  585. settings: cookie.settings || {}
  586. }));
  587. });
  588. #>
  589. </tbody>
  590. </table>
  591. <!-- <div class="no-cookies no-list-items">-->
  592. <!-- <div class="pum-field pum-field-select pum-field-select2">-->
  593. <!-- <label for="pum-first-cookie">--><?php //_e( 'Choose when you want to set a cookie to get started.', 'popup-maker' ); ?><!--</label>-->
  594. <!-- <# print(PUM_Admin.cookies.template.selectbox({id: 'pum-first-cookie', name: "", placeholder: "--><?php //_e( 'Select an event.', 'popup-maker' ); ?><!--"})); #>-->
  595. <!-- </div>-->
  596. <!-- </div>-->
  597. </div>
  598. </script>
  599. <script type="text/html" id="tmpl-pum-cookie-row">
  600. <tr data-index="{{data.index}}">
  601. <td class="event-column">
  602. <button type="button" class="edit no-button link-button" aria-label="<?php _e( 'Edit this cookie', 'popup-maker' ); ?>">{{PUM_Admin.cookies.getLabel(data.event)}}</button>
  603. <input class="popup_cookies_field_event" type="hidden" name="{{data.name}}[{{data.index}}][event]" value="{{data.event}}"/>
  604. <input class="popup_cookies_field_settings" type="hidden" name="{{data.name}}[{{data.index}}][settings]" value="{{JSON.stringify(data.settings)}}"/>
  605. </td>
  606. <td class="name-column">
  607. <code>{{data.settings.name}}</code>
  608. </td>
  609. <td class="settings-column">{{{PUM_Admin.cookies.getSettingsDesc(data.event, data.settings)}}}</td>
  610. <td class="list-item-actions">
  611. <button type="button" class="edit dashicons dashicons-edit no-button" aria-label="<?php _e( 'Edit this cookie', 'popup-maker' ); ?>"></button>
  612. <button type="button" class="remove dashicons dashicons-no no-button" aria-label="<?php _e( 'Delete this cookie', 'popup-maker' ); ?>"></button>
  613. </td>
  614. </tr>
  615. </script>
  616. <script type="text/html" id="tmpl-pum-cookie-add-event">
  617. <#
  618. print(PUM_Admin.templates.modal({
  619. id: 'pum_cookie_add_event_modal',
  620. title: '<?php _e( 'When should your cookie be created?', 'popup-maker' ); ?>',
  621. content: PUM_Admin.cookies.template.selectbox({id: 'popup_cookie_add_event', name: "", placeholder: "<?php _e( 'Select a cookie type.', 'popup-maker' ); ?>"}),
  622. save_button: pum_admin_vars.I10n.add || '<?php __( 'Add', 'popup-maker' ); ?>'
  623. }));
  624. #>
  625. </script>
  626. <script type="text/html" id="tmpl-pum-field-cookie_key">
  627. <div class="cookie-key">
  628. <button type="button" class="reset dashicons-before dashicons-image-rotate" title="<?php _e( 'Reset Cookie Key', 'popup-maker' ); ?>"></button>
  629. <input type="text" placeholder="{{data.placeholder}}" class="{{data.size}}-text dashicons-before dashicons-image-rotate" id="{{data.id}}" name="{{data.name}}" value="{{data.value}}" {{{data.meta}}}/>
  630. </div>
  631. </script>
  632. <?php
  633. }
  634. }