| 1 |
<?php |
| 2 |
|
| 3 |
namespace forge12\contactform7\CF7DoubleOptIn { |
| 4 |
|
| 5 |
use forge12\plugins\ContactForm7; |
| 6 |
use Forge12\Shared\LoggerInterface; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Class Backend |
| 14 |
* Responsible to handle the admin settings for the double opt-in field |
| 15 |
* |
| 16 |
* @package forge12\contactform7\CF7OptIn |
| 17 |
*/ |
| 18 |
class CF7Backend { |
| 19 |
private LoggerInterface $logger; |
| 20 |
|
| 21 |
/** |
| 22 |
* Admin constructor. |
| 23 |
*/ |
| 24 |
public function __construct( LoggerInterface $logger ) { |
| 25 |
$this->logger = $logger; |
| 26 |
|
| 27 |
$this->get_logger()->debug( 'Admin constructor called', [ |
| 28 |
'plugin' => 'double-opt-in', |
| 29 |
'class' => __CLASS__, |
| 30 |
'method' => __METHOD__, |
| 31 |
] ); |
| 32 |
|
| 33 |
add_action( 'admin_init', [ $this, 'addHooks' ] ); |
| 34 |
$this->get_logger()->debug( 'Hook admin_init registered', [ |
| 35 |
'plugin' => 'double-opt-in', |
| 36 |
] ); |
| 37 |
|
| 38 |
add_action( 'admin_enqueue_scripts', [ $this, 'addStyles' ] ); |
| 39 |
$this->get_logger()->debug( 'Hook admin_enqueue_scripts registered', [ |
| 40 |
'plugin' => 'double-opt-in', |
| 41 |
] ); |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
public function get_logger() { |
| 46 |
return $this->logger; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Add the styles for the form |
| 51 |
*/ |
| 52 |
public function addStyles( $hook ) { |
| 53 |
$this->get_logger()->debug( 'Enqueuing admin styles and scripts', [ |
| 54 |
'plugin' => 'double-opt-in', |
| 55 |
'class' => __CLASS__, |
| 56 |
'method' => __METHOD__, |
| 57 |
'hook' => $hook, |
| 58 |
] ); |
| 59 |
|
| 60 |
wp_enqueue_script( |
| 61 |
'f12-cf7-doubleoptin-admin', |
| 62 |
plugins_url( 'assets/f12-cf7-popup.js', __FILE__ ), |
| 63 |
[ 'jquery' ] |
| 64 |
); |
| 65 |
$this->get_logger()->debug( 'Admin popup script enqueued', [ |
| 66 |
'plugin' => 'double-opt-in', |
| 67 |
] ); |
| 68 |
|
| 69 |
wp_localize_script( |
| 70 |
'f12-cf7-doubleoptin-admin', |
| 71 |
'doi', |
| 72 |
[ |
| 73 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 74 |
'nonce' => wp_create_nonce( 'f12_doi_details' ), |
| 75 |
] |
| 76 |
); |
| 77 |
$this->get_logger()->debug( 'Admin popup script localized', [ |
| 78 |
'plugin' => 'double-opt-in', |
| 79 |
] ); |
| 80 |
|
| 81 |
wp_enqueue_script( |
| 82 |
'f12-cf7-doubleoptin-templateloader', |
| 83 |
plugins_url( 'assets/f12-cf7-templateloader.js', __FILE__ ), |
| 84 |
[ 'jquery' ] |
| 85 |
); |
| 86 |
$this->get_logger()->debug( 'Template loader script enqueued', [ |
| 87 |
'plugin' => 'double-opt-in', |
| 88 |
] ); |
| 89 |
|
| 90 |
wp_localize_script( |
| 91 |
'f12-cf7-doubleoptin-templateloader', |
| 92 |
'templateloader', |
| 93 |
[ |
| 94 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 95 |
'nonce' => wp_create_nonce( 'f12_doi_templateloader' ), |
| 96 |
'label_placeholder' => __( 'Please wait while we load the template...', 'double-opt-in' ), |
| 97 |
] |
| 98 |
); |
| 99 |
$this->get_logger()->debug( 'Template loader script localized', [ |
| 100 |
'plugin' => 'double-opt-in', |
| 101 |
] ); |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
/** |
| 106 |
* Add the hooks responsible to handle wordpress functions |
| 107 |
*/ |
| 108 |
public function addHooks() { |
| 109 |
$this->get_logger()->debug( 'Registering CF7 admin hooks', [ |
| 110 |
'plugin' => 'double-opt-in', |
| 111 |
'class' => __CLASS__, |
| 112 |
'method' => __METHOD__, |
| 113 |
] ); |
| 114 |
|
| 115 |
add_filter( 'wpcf7_editor_panels', [ $this, 'addPanel' ], 10, 1 ); |
| 116 |
$this->get_logger()->debug( 'Filter wpcf7_editor_panels registered', [ |
| 117 |
'plugin' => 'double-opt-in', |
| 118 |
] ); |
| 119 |
|
| 120 |
add_action( 'wpcf7_save_contact_form', [ $this, 'save' ], 10, 3 ); |
| 121 |
$this->get_logger()->debug( 'Action wpcf7_save_contact_form registered', [ |
| 122 |
'plugin' => 'double-opt-in', |
| 123 |
] ); |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
/** |
| 128 |
* Add a custom panel to the contact form 7 options |
| 129 |
*/ |
| 130 |
public function addPanel( array $panels ) { |
| 131 |
$this->get_logger()->debug( 'Adding CF7 editor panel', [ |
| 132 |
'plugin' => 'double-opt-in', |
| 133 |
'class' => __CLASS__, |
| 134 |
'method' => __METHOD__, |
| 135 |
] ); |
| 136 |
|
| 137 |
$panels['optin'] = [ |
| 138 |
'title' => __( 'Double-Opt-in', 'double-opt-in' ), |
| 139 |
'callback' => [ $this, 'render' ], |
| 140 |
]; |
| 141 |
|
| 142 |
$this->get_logger()->debug( 'CF7 editor panel added', [ |
| 143 |
'plugin' => 'double-opt-in', |
| 144 |
] ); |
| 145 |
|
| 146 |
return $panels; |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
/** |
| 151 |
* On Contact Form save store the information in the database |
| 152 |
* |
| 153 |
* @param \WPCF7_ContactForm $contact_form |
| 154 |
* @param $args |
| 155 |
* @param $context |
| 156 |
*/ |
| 157 |
public function save( $contact_form, $args, $context ) { |
| 158 |
$postID = $contact_form->id(); |
| 159 |
|
| 160 |
$this->get_logger()->debug( 'Saving CF7 Double Opt-In settings', [ |
| 161 |
'plugin' => 'double-opt-in', |
| 162 |
'class' => __CLASS__, |
| 163 |
'method' => __METHOD__, |
| 164 |
'post_id' => $postID, |
| 165 |
] ); |
| 166 |
|
| 167 |
// Validate nonce |
| 168 |
if ( ! isset( $_POST['f12_cf7_doubleoptin_save_form_nonce'] ) || ! wp_verify_nonce( $_POST['f12_cf7_doubleoptin_save_form_nonce'], 'f12_cf7_doubleoptin_save_form_action' ) ) { |
| 169 |
$this->get_logger()->warning( 'Nonce validation failed during save', [ |
| 170 |
'plugin' => 'double-opt-in', |
| 171 |
'post_id' => $postID, |
| 172 |
] ); |
| 173 |
return; |
| 174 |
} |
| 175 |
|
| 176 |
// Check if the double opt-in settings is set |
| 177 |
if ( ! $postID || ! isset( $_POST['doubleoptin'] ) ) { |
| 178 |
update_post_meta( $postID, 'f12-cf7-doubleoptin', [] ); |
| 179 |
$this->get_logger()->debug( 'No doubleoptin data found, cleared settings', [ |
| 180 |
'plugin' => 'double-opt-in', |
| 181 |
'post_id' => $postID, |
| 182 |
] ); |
| 183 |
return; |
| 184 |
} |
| 185 |
|
| 186 |
$parameter = SanitizeHelper::sanitize_array( $_POST['doubleoptin'] ); |
| 187 |
$metadata = CF7DoubleOptIn::getInstance()->getParameter( $postID ); |
| 188 |
|
| 189 |
foreach ( $metadata as $key => $value ) { |
| 190 |
if ( isset( $parameter[ $key ] ) ) { |
| 191 |
if ( $key === 'body' ) { |
| 192 |
$metadata[ $key ] = $parameter[ $key ]; |
| 193 |
} elseif ( $key === 'enable' ) { |
| 194 |
$metadata[ $key ] = (int) $parameter[ $key ]; |
| 195 |
} elseif ( $key === 'sender' ) { |
| 196 |
$metadata[ $key ] = $parameter[ $key ]; |
| 197 |
} else { |
| 198 |
$metadata[ $key ] = $parameter[ $key ]; |
| 199 |
} |
| 200 |
} elseif ( $key === 'enable' ) { |
| 201 |
$metadata[ $key ] = 0; |
| 202 |
} |
| 203 |
} |
| 204 |
|
| 205 |
$metadata = apply_filters( 'f12_cf7_doubleoptin_metadata_cf7', $metadata ); |
| 206 |
$metadata = apply_filters( 'f12_cf7_doubleoptin_save_form', $metadata ); |
| 207 |
|
| 208 |
update_post_meta( $postID, 'f12-cf7-doubleoptin', $metadata ); |
| 209 |
|
| 210 |
$this->get_logger()->info( 'Double Opt-In settings saved', [ |
| 211 |
'plugin' => 'double-opt-in', |
| 212 |
'post_id' => $postID, |
| 213 |
'data' => $metadata, |
| 214 |
] ); |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
/** |
| 219 |
* Return an option list containing all tags for the condition and a default field to disable the condition. |
| 220 |
* |
| 221 |
* @param \WPCF7_ContactForm $post |
| 222 |
* |
| 223 |
* @return array |
| 224 |
*/ |
| 225 |
private function getTags( $post ) { |
| 226 |
$this->get_logger()->debug( 'Fetching CF7 form tags', [ |
| 227 |
'plugin' => 'double-opt-in', |
| 228 |
'class' => __CLASS__, |
| 229 |
'method' => __METHOD__, |
| 230 |
'post_id' => $post->id() ?? null, |
| 231 |
] ); |
| 232 |
|
| 233 |
$tags = []; |
| 234 |
$arrayTags = $post->scan_form_tags(); |
| 235 |
|
| 236 |
foreach ( $arrayTags as $formTag /** @var \WPCF7_FormTag $formTag */ ) { |
| 237 |
if ( ! empty( $formTag->name ) ) { |
| 238 |
$tags[ $formTag->name ] = $formTag->name; |
| 239 |
} |
| 240 |
} |
| 241 |
|
| 242 |
$this->get_logger()->debug( 'Form tags fetched', [ |
| 243 |
'plugin' => 'double-opt-in', |
| 244 |
'count' => count( $tags ), |
| 245 |
] ); |
| 246 |
|
| 247 |
return $tags; |
| 248 |
} |
| 249 |
|
| 250 |
|
| 251 |
/** |
| 252 |
* Show the backend double opt in options |
| 253 |
* |
| 254 |
* @param \WPCF7_ContactForm $post |
| 255 |
*/ |
| 256 |
public function render( $post ) { |
| 257 |
if ( ! $post ) { |
| 258 |
return; |
| 259 |
} |
| 260 |
|
| 261 |
$metadata = CF7DoubleOptIn::getInstance()->getParameter( $post->id() ); |
| 262 |
$id = "doubleoptin"; |
| 263 |
?> |
| 264 |
<div class="forge12-plugin" style="padding-top:0;"> |
| 265 |
<div class="forge12-plugin-content" style="margin-top:0;"> |
| 266 |
<div class="forge12-plugin-content-main"> |
| 267 |
<div class="box" style="width:100%;"> |
| 268 |
<h2><?php _e( 'Opt-In Formular Settings', 'double-opt-in' ); ?></h2> |
| 269 |
<div class="option"> |
| 270 |
<div class="label"> |
| 271 |
<label for="doubleoptin[enable]"> |
| 272 |
<?php _e( 'Enable', 'double-opt-in' ); ?> |
| 273 |
</label> |
| 274 |
</div> |
| 275 |
<div class="input"> |
| 276 |
<input type="checkbox" name="doubleoptin[enable]" id="doubleoptin" |
| 277 |
value="1" <?php echo isset( $metadata['enable'] ) && $metadata['enable'] == 1 ? 'checked = "checked"' : ''; ?> > |
| 278 |
<span> |
| 279 |
<?php _e( 'Yes', 'double-opt-in' ); ?> |
| 280 |
</span> |
| 281 |
<p><?php _e( 'Enable this checkox to activate the Double-Opt-In Mail for this formular.', 'double-opt-in' ); ?></p> |
| 282 |
</div> |
| 283 |
</div> |
| 284 |
|
| 285 |
<div class="option"> |
| 286 |
<div class="label"> |
| 287 |
<label for="doubleoptin[category]"> |
| 288 |
<?php _e( 'Category', 'double-opt-in' ); ?> |
| 289 |
</label> |
| 290 |
</div> |
| 291 |
<div class="input"> |
| 292 |
<?php |
| 293 |
$atts = array( |
| 294 |
'perPage' => - 1, |
| 295 |
'orderBy' => 'name', |
| 296 |
'order' => 'ASC' |
| 297 |
); |
| 298 |
|
| 299 |
$list = Category::get_list( $atts, $numberOfPages ); |
| 300 |
|
| 301 |
$response = '<option value="0">' . __( 'Please select', 'double-opt-in' ) . '</option>'; |
| 302 |
foreach ( $list as $Category /** @var Category $Category */ ) { |
| 303 |
$selected = ""; |
| 304 |
if ( $Category->get_id() == $metadata['category'] ) { |
| 305 |
$selected = 'selected="selected"'; |
| 306 |
} |
| 307 |
$response .= '<option value="' . esc_attr( $Category->get_id() ) . '" ' . $selected . '>' . esc_attr( $Category->get_name() ) . '</option>'; |
| 308 |
} |
| 309 |
?> |
| 310 |
<select name="doubleoptin[category]"><?php echo wp_kses( $response, array( |
| 311 |
'option' => array( |
| 312 |
'value' => array(), |
| 313 |
'selected' => array() |
| 314 |
) |
| 315 |
) ); ?></select> |
| 316 |
<span> |
| 317 |
<?php _e( 'Assign the Opt-In to a Category for an easier administration.', 'double-opt-in' ); ?> |
| 318 |
</span> |
| 319 |
</div> |
| 320 |
</div> |
| 321 |
|
| 322 |
<div class="option"> |
| 323 |
<div class="label"> |
| 324 |
<label for="doubleoptin[page]"> |
| 325 |
<?php _e( 'Dynamic Condition', 'double-opt-in' ); ?> |
| 326 |
</label> |
| 327 |
</div> |
| 328 |
<div class="input"> |
| 329 |
<span> |
| 330 |
<?php _e( 'Enable the Opt-In only when the field ', 'double-opt-in' ); ?> |
| 331 |
</span> |
| 332 |
<?php |
| 333 |
$ConditionList = new HTMLSelect( $id . '[conditions]', array_merge( array( 'disable' => __( 'Disabled', 'double-opt-in' ) ), $this->getTags( $post ) ), array( |
| 334 |
'id' => array( $id . '-conditions' ), |
| 335 |
'class' => array( |
| 336 |
'large-text', |
| 337 |
'code' |
| 338 |
) |
| 339 |
) ); |
| 340 |
$ConditionList->setOptionSelectedByKey( $metadata['conditions'] ); |
| 341 |
echo wp_kses( $ConditionList->get(), array( |
| 342 |
'select' => array( 'name' => array() ), |
| 343 |
'option' => array( |
| 344 |
'value' => array(), |
| 345 |
'selected' => array() |
| 346 |
) |
| 347 |
) ); |
| 348 |
?> |
| 349 |
<span> |
| 350 |
<?php _e( 'has been filled/checked by the visitor.', 'double-opt-in' ); ?> |
| 351 |
</span> |
| 352 |
</div> |
| 353 |
</div> |
| 354 |
|
| 355 |
<div class="option"> |
| 356 |
<div class="label"> |
| 357 |
<label for="doubleoptin[page]"> |
| 358 |
<?php _e( 'Confirmation Page', 'double-opt-in' ); ?> |
| 359 |
</label> |
| 360 |
</div> |
| 361 |
<div class="input"> |
| 362 |
<?php wp_dropdown_pages( array( |
| 363 |
'show_option_none' => __( 'default', 'double-opt-in' ), |
| 364 |
'name' => 'doubleoptin[page]', |
| 365 |
'selected' => $metadata['page'] |
| 366 |
) ); ?> |
| 367 |
<p> |
| 368 |
<?php _e( 'Select the page that should be displayed after the user clicks on the confirmation link', 'double-opt-in' ); ?> |
| 369 |
</p> |
| 370 |
</div> |
| 371 |
</div> |
| 372 |
|
| 373 |
<?php |
| 374 |
/** |
| 375 |
* Used to render settings for CF7 |
| 376 |
* |
| 377 |
* @param string $output |
| 378 |
* @param array $metadata |
| 379 |
* |
| 380 |
* @since 3.0.0 |
| 381 |
*/ |
| 382 |
echo apply_filters( 'f12_cf7_formular_settings_after_cf7', '', $metadata ); |
| 383 |
|
| 384 |
/** |
| 385 |
* Deprecated - Used to add settings for cf7. |
| 386 |
* |
| 387 |
* @param string $type |
| 388 |
* @param array $metadata |
| 389 |
*/ |
| 390 |
do_action( 'f12_cf7_formular_settings_after', 'cf7', $metadata ); |
| 391 |
?> |
| 392 |
</div> |
| 393 |
|
| 394 |
<div class="box" style="width:100%;"> |
| 395 |
<h2><?php _e( 'Customize your Opt-In Mail', 'double-opt-in' ); ?></h2> |
| 396 |
<div class="option"> |
| 397 |
<div class="label"> |
| 398 |
<label for="doubleoptin-recipient"> |
| 399 |
<label for="<?php echo esc_attr( $id ); ?>-recipient"><?php echo __( 'To', 'double-opt-in' ); ?></label> |
| 400 |
</label> |
| 401 |
</div> |
| 402 |
<div class="input"> |
| 403 |
<input type="text" id="<?php echo esc_attr( $id ); ?>-recipient" |
| 404 |
name="<?php echo esc_attr( $id ); ?>[recipient]" |
| 405 |
class="large-text code" size="70" |
| 406 |
value="<?php echo esc_attr( $metadata['recipient'] ); ?>"/> |
| 407 |
<p> |
| 408 |
<?php _e( 'This field defines who will receive the Double-Opt-In mail. Enter one of the following tags that represents the mail for the customer:', 'double-opt-in' ); ?> |
| 409 |
</p> |
| 410 |
<p> |
| 411 |
<code> |
| 412 |
<?php |
| 413 |
$arrayTags = $this->getTags( $post ); |
| 414 |
foreach ( $arrayTags as $key => $value ) { |
| 415 |
$arrayTags[ $key ] = "[" . esc_html( $value ) . "]"; |
| 416 |
} |
| 417 |
echo esc_html( implode( ",", array_filter( $arrayTags ) ) ); |
| 418 |
?> |
| 419 |
</code> |
| 420 |
</p> |
| 421 |
</div> |
| 422 |
</div> |
| 423 |
|
| 424 |
<div class="option"> |
| 425 |
<div class="label"> |
| 426 |
<label for="<?php echo esc_attr( $id ); ?>-sender"> |
| 427 |
<?php echo esc_html( __( 'From', 'double-opt-in' ) ); ?> |
| 428 |
</label> |
| 429 |
</div> |
| 430 |
<div class="input"> |
| 431 |
<input type="text" id="<?php echo esc_attr( $id ); ?>-sender" |
| 432 |
name="<?php echo esc_attr( $id ); ?>[sender]" |
| 433 |
class="large-text code" size="70" |
| 434 |
value="<?php echo esc_attr( $metadata['sender'] ); ?>"/> |
| 435 |
<p> |
| 436 |
<?php _e( 'This field defines who will sent the mail. You can either enter the e-Mail (e.g.: [email protected]) or use a placeholder (e.g.: [_site_admin_email]).', 'double-opt-in' ); ?> |
| 437 |
</p> |
| 438 |
</div> |
| 439 |
</div> |
| 440 |
|
| 441 |
<div class="option"> |
| 442 |
<div class="label"> |
| 443 |
<label for="<?php echo esc_attr( $id ); ?>-sender"> |
| 444 |
<?php echo esc_html( __( 'From Name', 'double-opt-in' ) ); ?> |
| 445 |
</label> |
| 446 |
</div> |
| 447 |
<div class="input"> |
| 448 |
<input type="text" id="<?php echo esc_attr( $id ); ?>-sender_name" |
| 449 |
name="<?php echo esc_attr( $id ); ?>[sender_name]" |
| 450 |
class="large-text code" size="70" |
| 451 |
value="<?php echo esc_attr( $metadata['sender_name'] ); ?>"/> |
| 452 |
<p> |
| 453 |
<?php _e( 'This field defines the name of the sender (e.g. Max Mustermann).', 'double-opt-in' ); ?> |
| 454 |
</p> |
| 455 |
</div> |
| 456 |
</div> |
| 457 |
|
| 458 |
<div class="option"> |
| 459 |
<div class="label"> |
| 460 |
<label for="<?php echo esc_attr( $id ); ?>-subject"> |
| 461 |
<?php echo esc_html( __( 'Subject', 'double-opt-in' ) ); ?> |
| 462 |
</label> |
| 463 |
</div> |
| 464 |
<div class="input"> |
| 465 |
<input type="text" id="<?php echo esc_attr( $id ); ?>-subject" |
| 466 |
name="<?php echo esc_attr( $id ); ?>[subject]" |
| 467 |
class="large-text code" size="70" |
| 468 |
value="<?php echo esc_attr( $metadata['subject'] ); ?>"/> |
| 469 |
<p> |
| 470 |
<?php _e( 'Enter a custom subject for the Double-Opt-In mail (e.g.: Please confirm your registration).', 'double-opt-in' ); ?> |
| 471 |
</p> |
| 472 |
</div> |
| 473 |
</div> |
| 474 |
|
| 475 |
<div class="option"> |
| 476 |
<div class="label"> |
| 477 |
<label for="<?php echo esc_attr( $id ); ?>-body"> |
| 478 |
<?php echo esc_html( __( 'Template', 'double-opt-in' ) ); ?> |
| 479 |
</label> |
| 480 |
</div> |
| 481 |
<div class="input"> |
| 482 |
<div class="preview"> |
| 483 |
<div class="preview-item"> |
| 484 |
<div class="preview-item-inner <?php if ( $metadata['template'] == 'blank' ) { |
| 485 |
echo 'active'; |
| 486 |
}; ?>"> |
| 487 |
<img src="<?php echo esc_url( plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'mails/blank.png' ); ?>" |
| 488 |
class="f12-cf7-templateloader-preview" data-template="blank" |
| 489 |
title="Blank"/> |
| 490 |
</div> |
| 491 |
</div> |
| 492 |
<div class="preview-item"> |
| 493 |
<div class="preview-item-inner <?php if ( $metadata['template'] == 'newsletter_en' ) { |
| 494 |
echo 'active'; |
| 495 |
}; ?>"> |
| 496 |
<img src="<?php echo esc_url( plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'mails/newsletter_en.png' ); ?>" |
| 497 |
class="f12-cf7-templateloader-preview" title="Newsletter EN" |
| 498 |
data-template="newsletter_en" alt=""/> |
| 499 |
</div> |
| 500 |
</div> |
| 501 |
<div class="preview-item"> |
| 502 |
<div class="preview-item-inner <?php if ( $metadata['template'] == 'newsletter_en_2' ) { |
| 503 |
echo 'active'; |
| 504 |
}; ?>"> |
| 505 |
<img src="<?php echo esc_url( plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'mails/newsletter_en_2.png' ); ?>" |
| 506 |
class="f12-cf7-templateloader-preview" title="Newsletter EN 2" |
| 507 |
data-template="newsletter_en_2"/> |
| 508 |
</div> |
| 509 |
</div> |
| 510 |
<div class="preview-item"> |
| 511 |
<div class="preview-item-inner <?php if ( $metadata['template'] == 'newsletter_en_3' ) { |
| 512 |
echo 'active'; |
| 513 |
}; ?>"> |
| 514 |
<img src="<?php echo esc_url( plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'mails/newsletter_en_3.png' ); ?>" |
| 515 |
class="f12-cf7-templateloader-preview" title="Newsletter EN 3" |
| 516 |
data-template="newsletter_en_3"/> |
| 517 |
</div> |
| 518 |
</div> |
| 519 |
</div> |
| 520 |
<?php |
| 521 |
$TemplateList = new HTMLSelect( $id . '[template]', array( |
| 522 |
'blank' => 'blank', |
| 523 |
'newsletter_en' => 'newsletter_en', |
| 524 |
'newsletter_en_2' => 'newsletter_en_2', |
| 525 |
'newsletter_en_3' => 'newsletter_en_3' |
| 526 |
), array( |
| 527 |
'class' => array( 'f12-cf7-templateloader' ), |
| 528 |
'style' => array( 'display:none;' ) |
| 529 |
) ); |
| 530 |
$TemplateList->setOptionSelectedByKey( $metadata['template'] ); |
| 531 |
echo wp_kses( $TemplateList->get(), array( |
| 532 |
'select' => array( |
| 533 |
'style' => array(), |
| 534 |
'class' => array(), |
| 535 |
'name' => array() |
| 536 |
), |
| 537 |
'option' => array( |
| 538 |
'value' => array(), |
| 539 |
'selected' => array() |
| 540 |
) |
| 541 |
) ); |
| 542 |
?> |
| 543 |
</div> |
| 544 |
</div> |
| 545 |
|
| 546 |
<div class="option"> |
| 547 |
<div class="label"> |
| 548 |
<label for="<?php echo esc_attr( $id ); ?>-body"> |
| 549 |
<?php echo esc_html( __( 'Message body', 'double-opt-in' ) ); ?> |
| 550 |
</label> |
| 551 |
</div> |
| 552 |
<div class="input"> |
| 553 |
<textarea id="<?php echo esc_attr( $id ); ?>-body" |
| 554 |
name="<?php echo esc_attr( $id ); ?>[body]" |
| 555 |
cols="100" rows="18" |
| 556 |
class="large-text code"><?php echo esc_textarea( $metadata['body'] ); ?></textarea> |
| 557 |
<p> |
| 558 |
<?php _e( 'Enter the Message you want to sent to your customer. Do not forget to add the Double-Opt-In tag ([doubleoptinlink]) e.g.:', 'double-opt-in' ); ?> |
| 559 |
<code> |
| 560 |
<a href="[doubleoptinlink]">Confirm the registration</a> |
| 561 |
</code> |
| 562 |
</p> |
| 563 |
<p> |
| 564 |
<?php _e( 'These placeholders are available for the opt-in Message body: ', 'double-opt-in' ); ?> |
| 565 |
</p> |
| 566 |
<p> |
| 567 |
<code>[doubleoptinlink],[doubleoptin_form_url],[doubleoptin_form_subject],[doubleoptin_form_date],[doubleoptin_form_time],[_site_admin_email],<?php |
| 568 |
$arrayTags = $this->getTags( $post ); |
| 569 |
foreach ( $arrayTags as $key => $value ) { |
| 570 |
$arrayTags[ $key ] = "[" . esc_html( $value ) . "]"; |
| 571 |
} |
| 572 |
echo implode( ",", array_filter( $arrayTags ) ); |
| 573 |
?> |
| 574 |
</code> |
| 575 |
</p> |
| 576 |
</div> |
| 577 |
</div> |
| 578 |
</div> |
| 579 |
|
| 580 |
|
| 581 |
<?php do_action( 'f12_cf7_doubleoptin_admin_panel', $post, $metadata, $id ); ?> |
| 582 |
<?php wp_nonce_field( 'f12_cf7_doubleoptin_save_form_action', 'f12_cf7_doubleoptin_save_form_nonce' ); ?> |
| 583 |
</div> |
| 584 |
</div> |
| 585 |
</div> |
| 586 |
<?php |
| 587 |
} |
| 588 |
} |
| 589 |
} |