1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
<?php
namespace SIW\Compatibility;
use SIW\Properties;
use SIW\Email\Template;
class Mailpoet {
public static function init() {
if ( ! class_exists( '\WYSIJA' ) ) {
return;
}
$self = new self();
add_action( 'widgets_init', [ $self, 'unregister_widget' ], 99 );
add_action( 'wp_enqueue_scripts', [ $self, 'deregister_style' ], PHP_INT_MAX );
add_action( 'wp_ajax_nopriv_wysija_ajax', [ $self, 'block_signups' ], 1 );
add_filter( 'wysija_subscription_limit_base', [ $self, 'set_subscription_limit_base' ] );
add_action( 'siw_update_plugin', [ $self, 'update_confirmation_mail_template'] );
add_action( 'init', [ $self, 'remove_extra_image_size'] );
}
public function unregister_widget() {
unregister_widget( 'WYSIJA_NL_Widget' );
}
public function deregister_style() {
wp_deregister_style( 'validate-engine-css' );
}
public function remove_extra_image_size() {
remove_image_size( 'wysija-newsletters-max' );
}
public function block_signups() {
$controller = $_POST['controller'];
$task = $_POST['task'];
if ( 'subscribers' == $controller && 'save' == $task ) {
wp_die( '', \WP_Http::FORBIDDEN );
}
}
public function set_subscription_limit_base() {
return HOUR_IN_SECONDS;
}
public function update_confirmation_mail_template() {
$model_config = \WYSIJA::get('config','model');
$confirm_email_id = $model_config->values['confirm_email_id'];
$template_args = [
'subject' => 'Aanmelding nieuwsbrief',
'message' => 'Beste [user:firstname],'. BR2 .
'Bedankt voor je aanmelding voor de SIW-nieuwsbrief!' . SPACE .
'Om zeker te weten dat je inschrijving correct is, vragen we je je aanmelding te bevestigen.' . BR2 .
'[activation_link]Klik hier om je aanmelding voor onze nieuwsbrief direct te bevestigen[/activation_link]' . BR2 .
sprintf( 'Tip: voeg %s toe aan je adresboek.', Properties::EMAIL ) . SPACE .
'Zo mis je nooit meer nieuws over onze infodagen, ervaringsverhalen of projecten.',
'show_signature' => true,
'signature_name' => 'De vrijwilligers van SIW', 'siw',
'remove_linebreaks' => true,
];
$template = new Template( $template_args );
global $wpdb;
if ( ! isset( $wpdb->wysija_email ) ) {
$wpdb->wysija_email = $wpdb->prefix . 'wysija_email';
}
$wpdb->query(
$wpdb->prepare(
"UPDATE $wpdb->wysija_email
SET body = %s
WHERE $wpdb->wysija_email.email_id = %d",
$template->generate(),
$confirm_email_id
)
);
}
}