- added Subscriber::subscribe($user, $segment_ids) - refactored Router\Subscribers->subscribe() method to account for new method - added Form\Subscribe class to handle subscription in comments - updated Basics settings page (changed "list" to "segment")
85 lines
1.7 KiB
PHP
85 lines
1.7 KiB
PHP
<?php
|
|
namespace MailPoet\Config;
|
|
use \MailPoet\Models\Setting;
|
|
|
|
class Hooks {
|
|
function __construct() {
|
|
}
|
|
|
|
function init() {
|
|
$subscribe_settings = Setting::getValue('subscribe');
|
|
|
|
if($subscribe_settings !== null) {
|
|
// Subscribe in comments
|
|
if(
|
|
isset($subscribe_settings['on_comment']['enabled'])
|
|
&& $subscribe_settings['on_comment']['enabled']
|
|
) {
|
|
add_action(
|
|
'comment_form',
|
|
'\MailPoet\Form\Subscribe::inComments'
|
|
);
|
|
add_action(
|
|
'comment_post',
|
|
'\MailPoet\Form\Subscribe::onCommentSubmit',
|
|
60,
|
|
2
|
|
);
|
|
add_action(
|
|
'wp_set_comment_status',
|
|
'\MailPoet\Form\Subscribe::onCommentStatusUpdate',
|
|
60,
|
|
2
|
|
);
|
|
}
|
|
}
|
|
|
|
// WP Users synchronization
|
|
add_action(
|
|
'user_register',
|
|
'\MailPoet\Segments\WP::synchronizeUser',
|
|
1
|
|
);
|
|
add_action(
|
|
'added_existing_user',
|
|
'\MailPoet\Segments\WP::synchronizeUser',
|
|
1
|
|
);
|
|
add_action(
|
|
'profile_update',
|
|
'\MailPoet\Segments\WP::synchronizeUser',
|
|
1
|
|
);
|
|
add_action(
|
|
'delete_user',
|
|
'\MailPoet\Segments\WP::synchronizeUser',
|
|
1
|
|
);
|
|
// multisite
|
|
add_action(
|
|
'deleted_user',
|
|
'\MailPoet\Segments\WP::synchronizeUser',
|
|
1
|
|
);
|
|
add_action(
|
|
'remove_user_from_blog',
|
|
'\MailPoet\Segments\WP::synchronizeUser',
|
|
1
|
|
);
|
|
|
|
add_filter(
|
|
'image_size_names_choose',
|
|
array(
|
|
$this,
|
|
'appendImageSizes'
|
|
)
|
|
);
|
|
}
|
|
|
|
function appendImageSizes($sizes) {
|
|
return array_merge($sizes, array(
|
|
'mailpoet_newsletter_max' => __('MailPoet Newsletter'),
|
|
));
|
|
}
|
|
}
|