REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 3.39 KB
Close
/home/nshryvcy/himaltourism.com/wp-content/plugins/mailpoet/lib/Subscription/Comment.php
Text
Base64
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing namespace MailPoet\Subscription; if (!defined('ABSPATH')) exit; use MailPoet\Settings\SettingsController; use MailPoet\Subscribers\SubscriberActions; use MailPoet\WP\Functions as WPFunctions; class Comment { const SPAM = 'spam'; const APPROVED = 1; const PENDING_APPROVAL = 0; /** @var SettingsController */ private $settings; /** @var SubscriberActions */ private $subscriberActions; public function __construct( SettingsController $settings, SubscriberActions $subscriberActions ) { $this->settings = $settings; $this->subscriberActions = $subscriberActions; } public function extendLoggedInForm($field) { $field .= $this->getSubscriptionField(); return $field; } public function extendLoggedOutForm() { // The method returns escaped content // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPressDotOrg.sniffs.OutputEscaping.UnescapedOutputParameter echo $this->getSubscriptionField(); } /** * Returns escaped HTML for the subscription field. * * @return string */ private function getSubscriptionField(): string { $label = $this->settings->get( 'subscribe.on_comment.label', __('Yes, please add me to your mailing list.', 'mailpoet') ); return '<p class="comment-form-mailpoet"> <label for="mailpoet_subscribe_on_comment"> <input type="checkbox" id="mailpoet_subscribe_on_comment" value="1" name="mailpoet[subscribe_on_comment]" /> ' . esc_html($label) . ' </label> </p>'; } public function onSubmit($commentId, $commentStatus) { if ($commentStatus === Comment::SPAM) return; if ( isset($_POST['mailpoet']['subscribe_on_comment']) && (bool)$_POST['mailpoet']['subscribe_on_comment'] === true ) { if ($commentStatus === Comment::PENDING_APPROVAL) { // add a comment meta to remember to subscribe the user // once the comment gets approved WPFunctions::get()->addCommentMeta( $commentId, 'mailpoet', 'subscribe_on_comment', true ); } else if ($commentStatus === Comment::APPROVED) { $this->subscribeAuthorOfComment($commentId); } } } public function onStatusUpdate($commentId, $action) { if ($action === 'approve') { // check if the comment's author wants to subscribe $doSubscribe = ( WPFunctions::get()->getCommentMeta( $commentId, 'mailpoet', true ) === 'subscribe_on_comment' ); if ($doSubscribe === true) { $this->subscribeAuthorOfComment($commentId); WPFunctions::get()->deleteCommentMeta($commentId, 'mailpoet'); } } } private function subscribeAuthorOfComment($commentId) { $segmentIds = $this->settings->get('subscribe.on_comment.segments', []); if (!empty($segmentIds)) { $comment = WPFunctions::get()->getComment($commentId); $this->subscriberActions->subscribe( [ 'email' => $comment->comment_author_email, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps 'first_name' => $comment->comment_author, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps ], $segmentIds ); } } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 11
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
Captcha
DIR
-
drwxr-xr-x
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Blacklist.php
1.69 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
CaptchaFormRenderer.php
6.14 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Comment.php
3.39 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Form.php
1.49 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.php
0 B
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Manage.php
7.88 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ManageSubscriptionFormRenderer.php
8.48 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Pages.php
18.24 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Registration.php
3.23 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
SubscriptionUrlFactory.php
4.91 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Throttling.php
3.18 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).