Add public keyword to methods
[MAILPOET-2413]
This commit is contained in:
@@ -19,7 +19,7 @@ class Captcha {
|
||||
/** @var CaptchaSession */
|
||||
private $captcha_session;
|
||||
|
||||
function __construct(WPFunctions $wp = null, CaptchaSession $captcha_session = null) {
|
||||
public function __construct(WPFunctions $wp = null, CaptchaSession $captcha_session = null) {
|
||||
if ($wp === null) {
|
||||
$wp = new WPFunctions;
|
||||
}
|
||||
@@ -30,11 +30,11 @@ class Captcha {
|
||||
$this->captcha_session = $captcha_session;
|
||||
}
|
||||
|
||||
function isSupported() {
|
||||
public function isSupported() {
|
||||
return extension_loaded('gd') && function_exists('imagettftext');
|
||||
}
|
||||
|
||||
function isRequired($subscriber_email = null) {
|
||||
public function isRequired($subscriber_email = null) {
|
||||
if ($this->isUserExemptFromCaptcha()) {
|
||||
return false;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ class Captcha {
|
||||
return !empty(array_intersect($roles, (array)$user->roles));
|
||||
}
|
||||
|
||||
function renderImage($width = null, $height = null, $session_id = null, $return = false) {
|
||||
public function renderImage($width = null, $height = null, $session_id = null, $return = false) {
|
||||
if (!$this->isSupported()) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ class CaptchaRenderer {
|
||||
/** @var SubscriptionUrlFactory */
|
||||
private $subscription_url_factory;
|
||||
|
||||
function __construct(UrlHelper $url_helper, WPFunctions $wp, CaptchaSession $captcha_session, SubscriptionUrlFactory $subscription_url_factory) {
|
||||
public function __construct(UrlHelper $url_helper, WPFunctions $wp, CaptchaSession $captcha_session, SubscriptionUrlFactory $subscription_url_factory) {
|
||||
$this->url_helper = $url_helper;
|
||||
$this->wp = $wp;
|
||||
$this->captcha_session = $captcha_session;
|
||||
|
@@ -18,39 +18,39 @@ class CaptchaSession {
|
||||
/** @var string */
|
||||
private $id;
|
||||
|
||||
function __construct(WPFunctions $wp) {
|
||||
public function __construct(WPFunctions $wp) {
|
||||
$this->wp = $wp;
|
||||
}
|
||||
|
||||
function init($id = null) {
|
||||
public function init($id = null) {
|
||||
$this->id = $id ?: Security::generateRandomString(self::ID_LENGTH);
|
||||
}
|
||||
|
||||
function getId() {
|
||||
public function getId() {
|
||||
if ($this->id === null) {
|
||||
throw new \Exception("MailPoet captcha session not initialized.");
|
||||
}
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
public function reset() {
|
||||
$this->wp->deleteTransient($this->getKey(self::SESSION_FORM_KEY));
|
||||
$this->wp->deleteTransient($this->getKey(self::SESSION_HASH_KEY));
|
||||
}
|
||||
|
||||
function setFormData(array $data) {
|
||||
public function setFormData(array $data) {
|
||||
$this->wp->setTransient($this->getKey(self::SESSION_FORM_KEY), $data, self::EXPIRATION);
|
||||
}
|
||||
|
||||
function getFormData() {
|
||||
public function getFormData() {
|
||||
return $this->wp->getTransient($this->getKey(self::SESSION_FORM_KEY));
|
||||
}
|
||||
|
||||
function setCaptchaHash($hash) {
|
||||
public function setCaptchaHash($hash) {
|
||||
$this->wp->setTransient($this->getKey(self::SESSION_HASH_KEY), $hash, self::EXPIRATION);
|
||||
}
|
||||
|
||||
function getCaptchaHash() {
|
||||
public function getCaptchaHash() {
|
||||
return $this->wp->getTransient($this->getKey(self::SESSION_HASH_KEY));
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ class Comment {
|
||||
/** @var SubscriberActions */
|
||||
private $subscriber_actions;
|
||||
|
||||
function __construct(
|
||||
public function __construct(
|
||||
SettingsController $settings,
|
||||
SubscriberActions $subscriber_actions
|
||||
) {
|
||||
@@ -25,12 +25,12 @@ class Comment {
|
||||
$this->subscriber_actions = $subscriber_actions;
|
||||
}
|
||||
|
||||
function extendLoggedInForm($field) {
|
||||
public function extendLoggedInForm($field) {
|
||||
$field .= $this->getSubscriptionField();
|
||||
return $field;
|
||||
}
|
||||
|
||||
function extendLoggedOutForm() {
|
||||
public function extendLoggedOutForm() {
|
||||
echo $this->getSubscriptionField();
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class Comment {
|
||||
</p>';
|
||||
}
|
||||
|
||||
function onSubmit($comment_id, $comment_status) {
|
||||
public function onSubmit($comment_id, $comment_status) {
|
||||
if ($comment_status === Comment::SPAM) return;
|
||||
|
||||
if (
|
||||
@@ -74,7 +74,7 @@ class Comment {
|
||||
}
|
||||
}
|
||||
|
||||
function onStatusUpdate($comment_id, $action) {
|
||||
public function onStatusUpdate($comment_id, $action) {
|
||||
if ($action === 'approve') {
|
||||
// check if the comment's author wants to subscribe
|
||||
$do_subscribe = (
|
||||
|
@@ -15,12 +15,12 @@ class Form {
|
||||
/** @var UrlHelper */
|
||||
private $url_helper;
|
||||
|
||||
function __construct(API $api, UrlHelper $url_helper) {
|
||||
public function __construct(API $api, UrlHelper $url_helper) {
|
||||
$this->api = $api;
|
||||
$this->url_helper = $url_helper;
|
||||
}
|
||||
|
||||
function onSubmit($request_data = false) {
|
||||
public function onSubmit($request_data = false) {
|
||||
$request_data = ($request_data) ? $request_data : $_REQUEST;
|
||||
$this->api->setRequestData($request_data, Endpoint::TYPE_POST);
|
||||
$form_id = (!empty($request_data['data']['form_id'])) ? (int)$request_data['data']['form_id'] : false;
|
||||
|
@@ -19,13 +19,13 @@ class Manage {
|
||||
/** @var LinkTokens */
|
||||
private $link_tokens;
|
||||
|
||||
function __construct(UrlHelper $url_helper, FieldNameObfuscator $field_name_obfuscator, LinkTokens $link_tokens) {
|
||||
public function __construct(UrlHelper $url_helper, FieldNameObfuscator $field_name_obfuscator, LinkTokens $link_tokens) {
|
||||
$this->url_helper = $url_helper;
|
||||
$this->field_name_obfuscator = $field_name_obfuscator;
|
||||
$this->link_tokens = $link_tokens;
|
||||
}
|
||||
|
||||
function onSave() {
|
||||
public function onSave() {
|
||||
$action = (isset($_POST['action']) ? $_POST['action'] : null);
|
||||
$token = (isset($_POST['token']) ? $_POST['token'] : null);
|
||||
|
||||
|
@@ -55,7 +55,7 @@ class Pages {
|
||||
/** @var AssetsController */
|
||||
private $assets_controller;
|
||||
|
||||
function __construct(
|
||||
public function __construct(
|
||||
NewSubscriberNotificationMailer $new_subscriber_notification_sender,
|
||||
WPFunctions $wp,
|
||||
SettingsController $settings,
|
||||
@@ -77,7 +77,7 @@ class Pages {
|
||||
$this->assets_controller = $assets_controller;
|
||||
}
|
||||
|
||||
function init($action = false, $data = [], $init_shortcodes = false, $init_page_filters = false) {
|
||||
public function init($action = false, $data = [], $init_shortcodes = false, $init_page_filters = false) {
|
||||
$this->action = $action;
|
||||
$this->data = $data;
|
||||
$this->subscriber = $this->getSubscriber();
|
||||
@@ -90,14 +90,14 @@ class Pages {
|
||||
return (array_key_exists('preview', $_GET) || array_key_exists('preview', $this->data));
|
||||
}
|
||||
|
||||
function initPageFilters() {
|
||||
public function initPageFilters() {
|
||||
$this->wp->addFilter('wp_title', [$this,'setWindowTitle'], 10, 3);
|
||||
$this->wp->addFilter('document_title_parts', [$this,'setWindowTitleParts'], 10, 1);
|
||||
$this->wp->addFilter('the_title', [$this,'setPageTitle'], 10, 1);
|
||||
$this->wp->addFilter('the_content', [$this,'setPageContent'], 10, 1);
|
||||
}
|
||||
|
||||
function initShortcodes() {
|
||||
public function initShortcodes() {
|
||||
$this->wp->addShortcode('mailpoet_manage', [$this, 'getManageLink']);
|
||||
$this->wp->addShortcode('mailpoet_manage_subscription', [$this, 'getManageContent']);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ class Pages {
|
||||
return ($subscriber && $this->link_tokens->verifyToken($subscriber, $token)) ? $subscriber : false;
|
||||
}
|
||||
|
||||
function confirm() {
|
||||
public function confirm() {
|
||||
$this->subscriber = $this->getSubscriber();
|
||||
if ($this->subscriber === false || $this->subscriber->status === Subscriber::STATUS_SUBSCRIBED) {
|
||||
return false;
|
||||
@@ -158,7 +158,7 @@ class Pages {
|
||||
}
|
||||
}
|
||||
|
||||
function unsubscribe() {
|
||||
public function unsubscribe() {
|
||||
if (!$this->isPreview()
|
||||
&& ($this->subscriber !== false)
|
||||
&& ($this->subscriber->status !== Subscriber::STATUS_UNSUBSCRIBED)
|
||||
@@ -169,7 +169,7 @@ class Pages {
|
||||
}
|
||||
}
|
||||
|
||||
function setPageTitle($page_title = '') {
|
||||
public function setPageTitle($page_title = '') {
|
||||
global $post;
|
||||
|
||||
if ($this->action !== self::ACTION_CAPTCHA && $this->isPreview() === false && $this->subscriber === false) {
|
||||
@@ -201,7 +201,7 @@ class Pages {
|
||||
}
|
||||
}
|
||||
|
||||
function setPageContent($page_content = '[mailpoet_page]') {
|
||||
public function setPageContent($page_content = '[mailpoet_page]') {
|
||||
// if we're not in preview mode or captcha page and the subscriber does not exist
|
||||
if ($this->action !== self::ACTION_CAPTCHA && $this->isPreview() === false && $this->subscriber === false) {
|
||||
return $this->wp->__("Your email address doesn't appear in our lists anymore. Sign up again or contact us if this appears to be a mistake.", 'mailpoet');
|
||||
@@ -234,7 +234,7 @@ class Pages {
|
||||
}
|
||||
}
|
||||
|
||||
function setWindowTitle($title, $separator, $separator_location = 'right') {
|
||||
public function setWindowTitle($title, $separator, $separator_location = 'right') {
|
||||
$title_parts = explode(" $separator ", $title);
|
||||
if ($separator_location === 'right') {
|
||||
// first part
|
||||
@@ -247,7 +247,7 @@ class Pages {
|
||||
return implode(" $separator ", $title_parts);
|
||||
}
|
||||
|
||||
function setWindowTitleParts($meta = []) {
|
||||
public function setWindowTitleParts($meta = []) {
|
||||
$meta['title'] = $this->setPageTitle($meta['title']);
|
||||
return $meta;
|
||||
}
|
||||
@@ -501,7 +501,7 @@ class Pages {
|
||||
return $content;
|
||||
}
|
||||
|
||||
function getManageLink($params) {
|
||||
public function getManageLink($params) {
|
||||
if (!$this->subscriber) return $this->wp->__('Link to subscription management page is only available to mailing lists subscribers.', 'mailpoet');
|
||||
|
||||
// get label or display default label
|
||||
|
@@ -14,7 +14,7 @@ class Registration {
|
||||
/** @var SubscriberActions */
|
||||
private $subscriber_actions;
|
||||
|
||||
function __construct(
|
||||
public function __construct(
|
||||
SettingsController $settings,
|
||||
SubscriberActions $subscriber_actions
|
||||
) {
|
||||
@@ -22,7 +22,7 @@ class Registration {
|
||||
$this->subscriber_actions = $subscriber_actions;
|
||||
}
|
||||
|
||||
function extendForm() {
|
||||
public function extendForm() {
|
||||
$label = $this->settings->get(
|
||||
'subscribe.on_register.label',
|
||||
WPFunctions::get()->__('Yes, please add me to your mailing list.', 'mailpoet')
|
||||
@@ -40,7 +40,7 @@ class Registration {
|
||||
</p>';
|
||||
}
|
||||
|
||||
function onMultiSiteRegister($result) {
|
||||
public function onMultiSiteRegister($result) {
|
||||
if (empty($result['errors']->errors)) {
|
||||
if (
|
||||
isset($_POST['mailpoet']['subscribe_on_register'])
|
||||
@@ -55,7 +55,7 @@ class Registration {
|
||||
return $result;
|
||||
}
|
||||
|
||||
function onRegister(
|
||||
public function onRegister(
|
||||
$errors,
|
||||
$user_login,
|
||||
$user_email = null
|
||||
|
@@ -30,12 +30,12 @@ class SubscriptionUrlFactory {
|
||||
$this->link_tokens = $link_tokens;
|
||||
}
|
||||
|
||||
function getCaptchaUrl($session_id) {
|
||||
public function getCaptchaUrl($session_id) {
|
||||
$post = $this->getPost($this->settings->get('subscription.pages.captcha'));
|
||||
return $this->getSubscriptionUrl($post, 'captcha', null, ['captcha_session_id' => $session_id]);
|
||||
}
|
||||
|
||||
function getCaptchaImageUrl($width, $height, $session_id) {
|
||||
public function getCaptchaImageUrl($width, $height, $session_id) {
|
||||
$post = $this->getPost($this->settings->get('subscription.pages.captcha'));
|
||||
return $this->getSubscriptionUrl(
|
||||
$post,
|
||||
@@ -45,22 +45,22 @@ class SubscriptionUrlFactory {
|
||||
);
|
||||
}
|
||||
|
||||
function getConfirmationUrl(Subscriber $subscriber = null) {
|
||||
public function getConfirmationUrl(Subscriber $subscriber = null) {
|
||||
$post = $this->getPost($this->settings->get('subscription.pages.confirmation'));
|
||||
return $this->getSubscriptionUrl($post, 'confirm', $subscriber);
|
||||
}
|
||||
|
||||
function getManageUrl(Subscriber $subscriber = null) {
|
||||
public function getManageUrl(Subscriber $subscriber = null) {
|
||||
$post = $this->getPost($this->settings->get('subscription.pages.manage'));
|
||||
return $this->getSubscriptionUrl($post, 'manage', $subscriber);
|
||||
}
|
||||
|
||||
function getUnsubscribeUrl(Subscriber $subscriber = null) {
|
||||
public function getUnsubscribeUrl(Subscriber $subscriber = null) {
|
||||
$post = $this->getPost($this->settings->get('subscription.pages.unsubscribe'));
|
||||
return $this->getSubscriptionUrl($post, 'unsubscribe', $subscriber);
|
||||
}
|
||||
|
||||
function getSubscriptionUrl(
|
||||
public function getSubscriptionUrl(
|
||||
$post = null,
|
||||
$action = null,
|
||||
Subscriber $subscriber = null,
|
||||
@@ -101,7 +101,7 @@ class SubscriptionUrlFactory {
|
||||
/**
|
||||
* @return SubscriptionUrlFactory
|
||||
*/
|
||||
static function getInstance() {
|
||||
public static function getInstance() {
|
||||
if (!self::$instance instanceof SubscriptionUrlFactory) {
|
||||
self::$instance = new SubscriptionUrlFactory(new WPFunctions, SettingsController::getInstance(), new LinkTokens);
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ use MailPoet\Util\Helpers;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class Throttling {
|
||||
static function throttle() {
|
||||
public static function throttle() {
|
||||
$wp = new WPFunctions;
|
||||
$subscription_limit_enabled = $wp->applyFilters('mailpoet_subscription_limit_enabled', true);
|
||||
|
||||
@@ -48,7 +48,7 @@ class Throttling {
|
||||
return false;
|
||||
}
|
||||
|
||||
static function purge() {
|
||||
public static function purge() {
|
||||
$wp = new WPFunctions;
|
||||
$interval = $wp->applyFilters('mailpoet_subscription_purge_window', MONTH_IN_SECONDS);
|
||||
return SubscriberIP::whereRaw(
|
||||
@@ -57,7 +57,7 @@ class Throttling {
|
||||
)->deleteMany();
|
||||
}
|
||||
|
||||
static function secondsToTimeString($seconds) {
|
||||
public static function secondsToTimeString($seconds) {
|
||||
$wp = new WPFunctions;
|
||||
$hrs = floor($seconds / 3600);
|
||||
$min = floor($seconds % 3600 / 60);
|
||||
|
Reference in New Issue
Block a user