fixed subscribe in comments
This commit is contained in:
@ -9,10 +9,17 @@ class Hooks {
|
||||
function init() {
|
||||
// Subscribe in comments
|
||||
if((bool)Setting::getValue('subscribe.on_comment.enabled')) {
|
||||
add_action(
|
||||
'comment_form_after_fields',
|
||||
'\MailPoet\Subscription\Comment::extendForm'
|
||||
);
|
||||
if(is_user_logged_in()) {
|
||||
add_action(
|
||||
'comment_form_field_comment',
|
||||
'\MailPoet\Subscription\Comment::extendLoggedInForm'
|
||||
);
|
||||
} else {
|
||||
add_action(
|
||||
'comment_form_after_fields',
|
||||
'\MailPoet\Subscription\Comment::extendLoggedOutForm'
|
||||
);
|
||||
}
|
||||
|
||||
add_action(
|
||||
'comment_post',
|
||||
|
@ -25,7 +25,7 @@ class Initializer {
|
||||
register_activation_hook(Env::$file, array($this, 'runMigrator'));
|
||||
register_activation_hook(Env::$file, array($this, 'runPopulator'));
|
||||
|
||||
add_action('init', array($this, 'setup'));
|
||||
add_action('plugins_loaded', array($this, 'setup'));
|
||||
add_action('widgets_init', array($this, 'setupWidget'));
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,7 @@ class Localizer {
|
||||
function init() {
|
||||
add_action(
|
||||
'init',
|
||||
array($this, 'setup'),
|
||||
0
|
||||
array($this, 'setup')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -8,13 +8,22 @@ class Comment {
|
||||
const APPROVED = 1;
|
||||
const PENDING_APPROVAL = 0;
|
||||
|
||||
static function extendForm() {
|
||||
static function extendLoggedInForm($field) {
|
||||
$field .= self::getSubscriptionField();
|
||||
return $field;
|
||||
}
|
||||
|
||||
static function extendLoggedOutForm() {
|
||||
echo self::getSubscriptionField();
|
||||
}
|
||||
|
||||
static function getSubscriptionField() {
|
||||
$label = Setting::getValue(
|
||||
'subscribe.on_comment.label',
|
||||
__('Yes, add me to your mailing list.')
|
||||
);
|
||||
|
||||
print '<p class="comment-form-mailpoet">
|
||||
return '<p class="comment-form-mailpoet">
|
||||
<label for="mailpoet_subscribe_on_comment">
|
||||
<input
|
||||
type="checkbox"
|
||||
|
Reference in New Issue
Block a user