Add public keyword to methods

[MAILPOET-2413]
This commit is contained in:
Amine Ben hammou
2019-12-26 12:56:49 +01:00
committed by wxa
parent ec409042d5
commit 43df66d162
823 changed files with 4440 additions and 4440 deletions

View File

@@ -32,7 +32,7 @@ class ConflictResolver {
],
];
function init() {
public function init() {
WPFunctions::get()->addAction(
'mailpoet_conflict_resolver_router_url_query_parameters',
[
@@ -70,12 +70,12 @@ class ConflictResolver {
);
}
function resolveRouterUrlQueryParametersConflict() {
public function resolveRouterUrlQueryParametersConflict() {
// prevents other plugins from overtaking URL query parameters 'action=' and 'endpoint='
unset($_GET['endpoint'], $_GET['action']);
}
function resolveStylesConflict() {
public function resolveStylesConflict() {
$_this = $this;
$_this->permitted_assets_locations['styles'] = WPFunctions::get()->applyFilters('mailpoet_conflict_resolver_whitelist_style', $_this->permitted_assets_locations['styles']);
// unload all styles except from the list of allowed
@@ -106,7 +106,7 @@ class ConflictResolver {
WPFunctions::get()->addAction('admin_print_footer_scripts', $dequeue_styles, $execute_first);
}
function resolveScriptsConflict() {
public function resolveScriptsConflict() {
$_this = $this;
$_this->permitted_assets_locations['scripts'] = WPFunctions::get()->applyFilters('mailpoet_conflict_resolver_whitelist_script', $_this->permitted_assets_locations['scripts']);
// unload all scripts except from the list of allowed
@@ -135,7 +135,7 @@ class ConflictResolver {
WPFunctions::get()->addAction('admin_print_footer_scripts', $dequeue_scripts, $execute_first);
}
function resolveEditorConflict() {
public function resolveEditorConflict() {
// mark editor as already enqueued to prevent loading its assets
// when wp_enqueue_editor() used by some other plugin
@@ -161,7 +161,7 @@ class ConflictResolver {
});
}
function resolveTinyMceConflict() {
public function resolveTinyMceConflict() {
// WordPress TinyMCE scripts may not get enqueued as scripts when some plugins use wp_editor()
// or wp_enqueue_editor(). Instead, they are printed inside the footer script print actions.
// To unload TinyMCE we need to remove those actions.

View File

@@ -13,7 +13,7 @@ class Cookies {
'httponly' => false,
];
function set($name, $value, array $options = []) {
public function set($name, $value, array $options = []) {
$options = $options + self::DEFAULT_OPTIONS;
$value = json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$error = json_last_error();
@@ -33,7 +33,7 @@ class Cookies {
);
}
function get($name) {
public function get($name) {
if (!array_key_exists($name, $_COOKIE)) {
return null;
}
@@ -45,7 +45,7 @@ class Cookies {
return $value;
}
function delete($name) {
public function delete($name) {
unset($_COOKIE[$name]);
}
}

View File

@@ -11,7 +11,7 @@ class DOM {
* ancestor and splitting left and right siblings into subtrees along
* the way, retaining order and nesting level.
*/
static function splitOn(DomNode $bound, DomNode $cut_element) {
public static function splitOn(DomNode $bound, DomNode $cut_element) {
$ignore_text_and_comment_nodes = false;
for ($parent = $cut_element->parent; $bound != $parent; $parent = $grandparent) {
// Clone parent node without children, but with attributes
@@ -32,7 +32,7 @@ class DOM {
}
}
static function findTopAncestor(DomNode $item) {
public static function findTopAncestor(DomNode $item) {
while ($item->parent->parent !== null) {
$item = $item->parent;
}

View File

@@ -53,7 +53,7 @@ class FreeDomains {
'yahoo.com.br', 'hotmail.com.br', 'outlook.com.br', 'uol.com.br', 'bol.com.br', 'terra.com.br', 'ig.com.br', 'itelefonica.com.br', 'r7.com', 'zipmail.com.br', 'globo.com', 'globomail.com', 'oi.com.br',
];
function isEmailOnFreeDomain($email) {
public function isEmailOnFreeDomain($email) {
$email_parts = explode('@', $email);
$domain = end($email_parts);
return in_array($domain, self::FREE_DOMAINS);

View File

@@ -6,13 +6,13 @@ class Helpers {
const DIVIDER = '***MailPoet***';
const LINK_TAG = 'link';
static function isJson($string) {
public static function isJson($string) {
if (!is_string($string)) return false;
json_decode($string);
return json_last_error() == JSON_ERROR_NONE;
}
static function replaceLinkTags($source, $link = false, $attributes = [], $link_tag = false) {
public static function replaceLinkTags($source, $link = false, $attributes = [], $link_tag = false) {
if (!$link) return $source;
$link_tag = ($link_tag) ? $link_tag : self::LINK_TAG;
$attributes = array_map(function($key) use ($attributes) {
@@ -31,7 +31,7 @@ class Helpers {
return preg_replace('/\s+/', ' ', $source);
}
static function getMaxPostSize($bytes = false) {
public static function getMaxPostSize($bytes = false) {
$maxPostSize = ini_get('post_max_size');
if (!$bytes) return $maxPostSize;
if ($maxPostSize === false) {
@@ -52,7 +52,7 @@ class Helpers {
}
}
static function flattenArray($array) {
public static function flattenArray($array) {
if (!$array) return;
$flattened_array = [];
array_walk_recursive($array, function ($a) use (&$flattened_array) {
@@ -61,7 +61,7 @@ class Helpers {
return $flattened_array;
}
static function underscoreToCamelCase($str, $capitalise_first_char = false) {
public static function underscoreToCamelCase($str, $capitalise_first_char = false) {
if ($capitalise_first_char) {
$str[0] = strtoupper($str[0]);
}
@@ -70,28 +70,28 @@ class Helpers {
}, $str);
}
static function camelCaseToUnderscore($str) {
public static function camelCaseToUnderscore($str) {
$str[0] = strtolower($str[0]);
return preg_replace_callback('/([A-Z])/', function ($c) {
return "_" . strtolower($c[1]);
}, $str);
}
static function joinObject($object = []) {
public static function joinObject($object = []) {
return implode(self::DIVIDER, $object);
}
static function splitObject($object = []) {
public static function splitObject($object = []) {
return explode(self::DIVIDER, $object);
}
static function getIP() {
public static function getIP() {
return (isset($_SERVER['REMOTE_ADDR']))
? $_SERVER['REMOTE_ADDR']
: null;
}
static function recursiveTrim($value) {
public static function recursiveTrim($value) {
if (is_array($value))
return array_map([__CLASS__, 'recursiveTrim'], $value);
if (is_string($value))

View File

@@ -15,12 +15,12 @@ class Installation {
/** @var WPFunctions */
private $wp;
function __construct(SettingsController $settings, WPFunctions $wp) {
public function __construct(SettingsController $settings, WPFunctions $wp) {
$this->settings = $settings;
$this->wp = $wp;
}
function isNewInstallation() {
public function isNewInstallation() {
$installed_at = $this->settings->get('installed_at');
if (is_null($installed_at)) {
return true;

View File

@@ -17,12 +17,12 @@ class Subscribers {
/** @var SubscribersRepository */
private $subscribers_repository;
function __construct(SettingsController $settings, SubscribersRepository $subscribers_repository) {
public function __construct(SettingsController $settings, SubscribersRepository $subscribers_repository) {
$this->settings = $settings;
$this->subscribers_repository = $subscribers_repository;
}
function check() {
public function check() {
$subscribers_count = $this->subscribers_repository->getTotalSubscribers();
$has_mss_key = !empty($this->settings->get(Bridge::API_KEY_SETTING_NAME));
$has_premium_key = !empty($this->settings->get(Bridge::PREMIUM_KEY_SETTING_NAME));
@@ -30,7 +30,7 @@ class Subscribers {
return $subscribers_count > $this->getSubscribersLimit();
}
function getSubscribersLimit() {
public function getSubscribersLimit() {
$installation_time = strtotime($this->settings->get('installed_at'));
$old_user = $installation_time < strtotime(self::NEW_LIMIT_DATE);
return $old_user ? self::SUBSCRIBERS_OLD_LIMIT : self::SUBSCRIBERS_NEW_LIMIT;

View File

@@ -5,7 +5,7 @@ namespace MailPoet\Util\License;
class License {
const FREE_PREMIUM_SUBSCRIBERS_LIMIT = 1000;
static function getLicense($license = false) {
public static function getLicense($license = false) {
if (!$license) {
$license = defined('MAILPOET_PREMIUM_LICENSE') ?
MAILPOET_PREMIUM_LICENSE :

View File

@@ -13,19 +13,19 @@ class AfterMigrationNotice {
/** @var SettingsController */
private $settings;
function __construct() {
public function __construct() {
$this->settings = SettingsController::getInstance();
}
function enable() {
public function enable() {
$this->settings->set(self::OPTION_NAME, true);
}
function disable() {
public function disable() {
$this->settings->set(self::OPTION_NAME, false);
}
function init($should_display) {
public function init($should_display) {
if ($should_display && $this->settings->get(self::OPTION_NAME, false)) {
return $this->display();
}

View File

@@ -11,7 +11,7 @@ class BlackFridayNotice {
const OPTION_NAME = 'dismissed-black-friday-notice';
const DISMISS_NOTICE_TIMEOUT_SECONDS = 2592000; // 30 days
function init($should_display) {
public function init($should_display) {
$should_display = $should_display
&& (time() <= strtotime('2019-11-30 23:59:59'))
&& (time() >= strtotime('2019-11-08 00:00:00'))
@@ -36,7 +36,7 @@ class BlackFridayNotice {
WPNotice::displaySuccess($header . $body . $link, $extra_classes, self::OPTION_NAME);
}
function disable() {
public function disable() {
WPFunctions::get()->setTransient(self::OPTION_NAME, true, self::DISMISS_NOTICE_TIMEOUT_SECONDS);
}

View File

@@ -18,12 +18,12 @@ class InactiveSubscribersNotice {
/** @var WPFunctions */
private $wp;
function __construct(SettingsController $settings, WPFunctions $wp) {
public function __construct(SettingsController $settings, WPFunctions $wp) {
$this->settings = $settings;
$this->wp = $wp;
}
function init($should_display) {
public function init($should_display) {
if (!$should_display || !$this->settings->get(self::OPTION_NAME, true)) {
return;
}
@@ -41,7 +41,7 @@ class InactiveSubscribersNotice {
return $this->display($inactive_subscribers_count);
}
function disable() {
public function disable() {
$this->settings->set(self::OPTION_NAME, false);
}

View File

@@ -11,17 +11,17 @@ class PHPVersionWarnings {
const DISMISS_NOTICE_TIMEOUT_SECONDS = 2592000; // 30 days
const OPTION_NAME = 'dismissed-php-version-outdated-notice';
function init($php_version, $should_display) {
public function init($php_version, $should_display) {
if ($should_display && $this->isOutdatedPHPVersion($php_version)) {
return $this->display($php_version);
}
}
function isOutdatedPHPVersion($php_version) {
public function isOutdatedPHPVersion($php_version) {
return version_compare($php_version, '7.0', '<') && !get_transient(self::OPTION_NAME);
}
function display($php_version) {
public function display($php_version) {
$error_string = __('Your website is running on PHP %s which MailPoet does not officially support. Read our [link]simple PHP upgrade guide[/link] or let MailPoets support team upgrade it for you.', 'mailpoet');
$error_string = sprintf($error_string, $php_version);
$get_in_touch_string = __('[link]Yes, I want MailPoet to help me upgrade for free[/link]', 'mailpoet');
@@ -37,7 +37,7 @@ class PHPVersionWarnings {
return Notice::displayWarning($error, $extra_classes, self::OPTION_NAME);
}
function disable() {
public function disable() {
WPFunctions::get()->setTransient(self::OPTION_NAME, true, self::DISMISS_NOTICE_TIMEOUT_SECONDS);
}

View File

@@ -71,7 +71,7 @@ class PermanentNotices {
);
}
function ajaxDismissNoticeHandler() {
public function ajaxDismissNoticeHandler() {
if (!isset($_POST['type'])) return;
switch ($_POST['type']) {
case (PHPVersionWarnings::OPTION_NAME):

View File

@@ -23,19 +23,19 @@ class UnauthorizedEmailInNewslettersNotice {
/** @var WPFunctions */
private $wp;
function __construct(SettingsController $settings, WPFunctions $wp) {
public function __construct(SettingsController $settings, WPFunctions $wp) {
$this->settings = $settings;
$this->wp = $wp;
}
function init($should_display) {
public function init($should_display) {
$validation_error = $this->settings->get(AuthorizedEmailsController::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING);
if ($should_display && isset($validation_error['invalid_senders_in_newsletters'])) {
return $this->display($validation_error);
}
}
function display($validation_error) {
public function display($validation_error) {
$message = $this->getMessageText();
$message .= $this->getNewslettersLinks($validation_error);
$message .= $this->getAuthorizationLink($validation_error);

View File

@@ -19,19 +19,19 @@ class UnauthorizedEmailNotice {
/** @var WPFunctions */
private $wp;
function __construct(SettingsController $settings, WPFunctions $wp) {
public function __construct(SettingsController $settings, WPFunctions $wp) {
$this->settings = $settings;
$this->wp = $wp;
}
function init($should_display) {
public function init($should_display) {
$validation_error = $this->settings->get(AuthorizedEmailsController::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING);
if ($should_display && isset($validation_error['invalid_sender_address'])) {
return $this->display($validation_error);
}
}
function display($validation_error) {
public function display($validation_error) {
$message = $this->getMessageText($validation_error);
$message .= $this->getSettingsButtons($validation_error);
$message .= $this->getAuthorizationLink($validation_error);

View File

@@ -4,7 +4,7 @@ namespace MailPoet\Util;
class SecondLevelDomainNames {
function get($host) {
public function get($host) {
if (preg_match('/[^.]*\.[^.]{2,3}(?:\.[^.]{2,3})?$/', $host, $matches)) {
return $matches[0];
}

View File

@@ -8,7 +8,7 @@ class Security {
const HASH_LENGTH = 12;
const UNSUBSCRIBE_TOKEN_LENGTH = 15;
static function generateToken($action = 'mailpoet_token') {
public static function generateToken($action = 'mailpoet_token') {
return WPFunctions::get()->wpCreateNonce($action);
}
@@ -19,7 +19,7 @@ class Security {
* @param int $length Minimal lenght is 5
* @return string
*/
static function generateRandomString($length = 5) {
public static function generateRandomString($length = 5) {
$length = max(5, (int)$length);
$string = base_convert(
bin2hex(
@@ -37,7 +37,7 @@ class Security {
* @param int $length Maximal length is 32
* @return string
*/
static function generateHash($length = null) {
public static function generateHash($length = null) {
$length = ($length) ? $length : self::HASH_LENGTH;
$auth_key = '';
if (defined('AUTH_KEY')) {

View File

@@ -8,11 +8,11 @@ class Url {
/** @var WPFunctions */
private $wp;
function __construct(WPFunctions $wp) {
public function __construct(WPFunctions $wp) {
$this->wp = $wp;
}
function getCurrentUrl() {
public function getCurrentUrl() {
$home_url = parse_url($this->wp->homeUrl());
$query_args = $this->wp->addQueryArg(null, null);
@@ -24,12 +24,12 @@ class Url {
return $this->wp->homeUrl($query_args);
}
function redirectTo($url = null) {
public function redirectTo($url = null) {
$this->wp->wpSafeRedirect($url);
exit();
}
function redirectBack($params = []) {
public function redirectBack($params = []) {
// check mailpoet_redirect parameter
$referer = (isset($_POST['mailpoet_redirect'])
? $_POST['mailpoet_redirect']
@@ -50,7 +50,7 @@ class Url {
exit();
}
function redirectWithReferer($url = null) {
public function redirectWithReferer($url = null) {
$current_url = $this->getCurrentUrl();
$url = $this->wp->addQueryArg(
[

View File

@@ -5,11 +5,11 @@ namespace MailPoet\Util\pQuery;
class DomNode extends \pQuery\DomNode {
public $childClass = 'MailPoet\Util\pQuery\DomNode';
function getInnerText() {
public function getInnerText() {
return html_entity_decode($this->toString(true, true, 1), ENT_NOQUOTES, 'UTF-8');
}
function getOuterText() {
public function getOuterText() {
return html_entity_decode($this->toString(), ENT_NOQUOTES, 'UTF-8');
}
}