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