Exclude globals from camel case conversion

[MAILPOET-1796]
This commit is contained in:
Jan Jakeš
2020-01-06 12:52:41 +01:00
committed by Jan Jakeš
parent 94afd66325
commit 6522635dc7
14 changed files with 59 additions and 57 deletions

View File

@@ -73,7 +73,7 @@ class Newsletters {
}
public function render() {
global $wpRoles;
global $wp_roles; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$data = [];
@@ -90,7 +90,7 @@ class Newsletters {
$data['current_wp_user'] = $this->wp->wpGetCurrentUser()->to_array();
$data['current_wp_user_firstname'] = $this->wp->wpGetCurrentUser()->user_firstname;
$data['site_url'] = $this->wp->siteUrl();
$data['roles'] = $wpRoles->get_names();
$data['roles'] = $wp_roles->get_names(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$data['roles']['mailpoet_all'] = $this->wp->__('In any WordPress role', 'mailpoet');
$installedAtDateTime = new \DateTime($data['settings']['installed_at']);

View File

@@ -28,7 +28,7 @@ class Update {
public function render() {
global $wp;
$currentUrl = $this->wp->homeUrl(add_query_arg($wp->queryString, $wp->request));
$currentUrl = $this->wp->homeUrl(add_query_arg($wp->query_string, $wp->request)); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$redirectUrl =
(!empty($_GET['mailpoet_redirect']))
? urldecode($_GET['mailpoet_redirect'])

View File

@@ -27,7 +27,7 @@ class Reporter {
}
public function getData() {
global $wpdb, $wpVersion, $woocommerce;
global $wpdb, $wp_version, $woocommerce; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$mta = $this->settings->get('mta', []);
$newsletters = Newsletter::getAnalytics();
$isCronTriggerMethodWP = $this->settings->get('cron_trigger.method') === CronTrigger::METHOD_WORDPRESS;
@@ -41,7 +41,7 @@ class Reporter {
$result = [
'PHP version' => PHP_VERSION,
'MySQL version' => $wpdb->db_version(),
'WordPress version' => $wpVersion,
'WordPress version' => $wp_version, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
'Multisite environment' => WPFunctions::get()->isMultisite() ? 'yes' : 'no',
'RTL' => WPFunctions::get()->isRtl() ? 'yes' : 'no',
'WP_MEMORY_LIMIT' => WP_MEMORY_LIMIT,

View File

@@ -45,9 +45,10 @@ class AutomaticEmails {
}
public function getAutomaticEmails() {
global $wpFilter;
global $wp_filter; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$registeredGroups = preg_grep('!^' . self::FILTER_PREFIX . '(.*?)$!', array_keys($wpFilter));
// phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$registeredGroups = preg_grep('!^' . self::FILTER_PREFIX . '(.*?)$!', array_keys($wp_filter));
if (empty($registeredGroups)) return null;
@@ -126,9 +127,10 @@ class AutomaticEmails {
}
public function unregisterAutomaticEmails() {
global $wpFilter;
global $wp_filter; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$registeredGroups = preg_grep('!^' . self::FILTER_PREFIX . '(.*?)$!', array_keys($wpFilter));
// phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$registeredGroups = preg_grep('!^' . self::FILTER_PREFIX . '(.*?)$!', array_keys($wp_filter));
if (empty($registeredGroups)) return null;

View File

@@ -143,7 +143,7 @@ class Migration extends SimpleWorker {
$queue['id']
));
// link the queue with the task via task_id
$newTaskId = $wpdb->insertId;
$newTaskId = $wpdb->insert_id; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$wpdb->query(sprintf(
'UPDATE %1$s SET `task_id` = %2$s WHERE `id` = %3$s',
MP_SENDING_QUEUES_TABLE,

View File

@@ -41,9 +41,9 @@ class WooCommerceCategory implements Filter {
"itemmeta.order_item_id = items.order_item_id AND itemmeta.meta_key = '_product_id'",
'itemmeta'
);
$orm->join($wpdb->termRelationships, ['itemmeta.meta_value', '=', 'term_relationships.object_id'], 'term_relationships');
$orm->join($wpdb->term_relationships, ['itemmeta.meta_value', '=', 'term_relationships.object_id'], 'term_relationships'); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$orm->rawJoin(
'INNER JOIN ' . $wpdb->termTaxonomy,
'INNER JOIN ' . $wpdb->term_taxonomy, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
'
term_taxonomy.term_taxonomy_id=term_relationships.term_taxonomy_id
AND

View File

@@ -56,12 +56,12 @@ class PostTransformerContentsExtractor {
*
* https://mailpoet.atlassian.net/browse/MAILPOET-1365
*/
global $contentWidth; // default is NULL
global $content_width; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps, default is NULL
$contentWidthCopy = $contentWidth;
$contentWidth = Env::NEWSLETTER_CONTENT_WIDTH;
$contentWidthCopy = $content_width; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$content_width = Env::NEWSLETTER_CONTENT_WIDTH; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$imageInfo = $this->wp->wpGetAttachmentImageSrc($id, 'mailpoet_newsletter_max');
$contentWidth = $contentWidthCopy;
$content_width = $contentWidthCopy; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
return $imageInfo;
}

View File

@@ -83,7 +83,7 @@ class Pages {
$subscriptionUrlFactory = Subscription\SubscriptionUrlFactory::getInstance();
return [
'id' => $page->ID,
'title' => $page->postTitle,
'title' => $page->post_title, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
'url' => [
'unsubscribe' => $subscriptionUrlFactory->getSubscriptionUrl($page, 'unsubscribe'),
'manage' => $subscriptionUrlFactory->getSubscriptionUrl($page, 'manage'),

View File

@@ -178,7 +178,7 @@ class Pages {
}
if (
($post->postTitle !== $this->wp->__('MailPoet Page', 'mailpoet'))
($post->post_title !== $this->wp->__('MailPoet Page', 'mailpoet')) // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
||
($pageTitle !== $this->wp->singlePostTitle('', false))
) {

View File

@@ -80,12 +80,12 @@ class ConflictResolver {
$_this->permittedAssetsLocations['styles'] = WPFunctions::get()->applyFilters('mailpoet_conflict_resolver_whitelist_style', $_this->permittedAssetsLocations['styles']);
// unload all styles except from the list of allowed
$dequeueStyles = function() use($_this) {
global $wpStyles;
if (!isset($wpStyles->registered)) return;
if (empty($wpStyles->queue)) return;
foreach ($wpStyles->queue as $wpStyle) {
if (empty($wpStyles->registered[$wpStyle])) continue;
$registeredStyle = $wpStyles->registered[$wpStyle];
global $wp_styles; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
if (!isset($wp_styles->registered)) return; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
if (empty($wp_styles->queue)) return; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
foreach ($wp_styles->queue as $wpStyle) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
if (empty($wp_styles->registered[$wpStyle])) continue; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$registeredStyle = $wp_styles->registered[$wpStyle]; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
if (!is_string($registeredStyle->src)) {
continue;
}
@@ -111,10 +111,10 @@ class ConflictResolver {
$_this->permittedAssetsLocations['scripts'] = WPFunctions::get()->applyFilters('mailpoet_conflict_resolver_whitelist_script', $_this->permittedAssetsLocations['scripts']);
// unload all scripts except from the list of allowed
$dequeueScripts = function() use($_this) {
global $wpScripts;
foreach ($wpScripts->queue as $wpScript) {
if (empty($wpScripts->registered[$wpScript])) continue;
$registeredScript = $wpScripts->registered[$wpScript];
global $wp_scripts; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
foreach ($wp_scripts->queue as $wpScript) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
if (empty($wp_scripts->registered[$wpScript])) continue; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$registeredScript = $wp_scripts->registered[$wpScript]; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
if (!is_string($registeredScript->src)) {
continue;
}
@@ -139,8 +139,8 @@ class ConflictResolver {
// mark editor as already enqueued to prevent loading its assets
// when wp_enqueue_editor() used by some other plugin
global $wpActions;
$wpActions['wp_enqueue_editor'] = 1;
global $wp_actions; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$wp_actions['wp_enqueue_editor'] = 1; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
// prevent editor loading when used wp_editor() used by some other plugin
WPFunctions::get()->addFilter('wp_editor_settings', function () {
@@ -173,12 +173,12 @@ class ConflictResolver {
];
$disableWpTinymce = function() use ($tinyMceFooterScriptHooks) {
global $wpFilter;
global $wp_filter; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$actionName = 'admin_print_footer_scripts';
if (!isset($wpFilter[$actionName])) {
if (!isset($wp_filter[$actionName])) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
return;
}
foreach ($wpFilter[$actionName]->callbacks as $priority => $callbacks) {
foreach ($wp_filter[$actionName]->callbacks as $priority => $callbacks) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
foreach ($tinyMceFooterScriptHooks as $hook) {
if (isset($callbacks[$hook])) {
WPFunctions::get()->removeAction($actionName, $callbacks[$hook]['function'], $priority);

View File

@@ -41,9 +41,9 @@ class DefaultsExtension extends Extension { // phpcs:ignore PSR1.Classes.ClassDe
// get rid of 'blog/' prefix that is added automatically to rewrite rules on multisite by default
// (init() loads 'permalink_structure' option from DB, flush_rules() regenerates 'rewrite_rules')
global $wpRewrite;
$wpRewrite->init();
$wpRewrite->flush_rules();
global $wp_rewrite; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$wp_rewrite->init(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$wp_rewrite->flush_rules(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
}
private function setupWooCommerce() {

View File

@@ -4,10 +4,10 @@ namespace MailPoet\Test\Config;
class InitializerTest extends \MailPoetTest {
public function testItConfiguresHooks() {
global $wpFilter;
global $wp_filter; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$isHooked = false;
// mailpoet should hook to 'wp_loaded' with priority of 10
foreach ($wpFilter['wp_loaded'][10] as $name => $hook) {
foreach ($wp_filter['wp_loaded'][10] as $name => $hook) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
if (preg_match('/postInitialize/', $name)) $isHooked = true;
}
expect($isHooked)->true();

View File

@@ -13,8 +13,8 @@ class ConflictResolverTest extends \MailPoetTest {
parent::__construct();
$this->conflictResolver = new ConflictResolver();
$this->conflictResolver->init();
global $wpFilter;
$this->wpFilter = $wpFilter;
global $wp_filter; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$this->wpFilter = $wp_filter; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
}
public function testItResolvesRouterUrlQueryParametersConflict() {
@@ -39,10 +39,10 @@ class ConflictResolverTest extends \MailPoetTest {
do_action('admin_print_styles');
do_action('admin_print_footer_scripts');
do_action('admin_footer');
global $wpStyles;
global $wp_styles; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
// it should dequeue all styles except those found on the list of permitted locations
expect(in_array('select2', $wpStyles->queue))->false();
expect(in_array('permitted_style', $wpStyles->queue))->true();
expect(in_array('select2', $wp_styles->queue))->false(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
expect(in_array('permitted_style', $wp_styles->queue))->true(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
}
public function testItWhitelistsStyles() {
@@ -60,9 +60,9 @@ class ConflictResolverTest extends \MailPoetTest {
do_action('admin_print_styles');
do_action('admin_print_footer_scripts');
do_action('admin_footer');
global $wpStyles;
global $wp_styles; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
// it should not dequeue select2 style
expect(in_array('select2', $wpStyles->queue))->true();
expect(in_array('select2', $wp_styles->queue))->true(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
}
public function testItUnloadsAllScriptsFromLocationsNotOnPermittedList() {
@@ -76,11 +76,11 @@ class ConflictResolverTest extends \MailPoetTest {
$this->conflictResolver->resolveScriptsConflict();
do_action('wp_print_scripts');
do_action('admin_print_footer_scripts');
global $wpScripts;
global $wp_scripts; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
// it should dequeue all scripts except those found on the list of permitted locations
expect(in_array('select2', $wpScripts->queue))->false();
expect(in_array('some_random_script', $wpScripts->queue))->false();
expect(in_array('permitted_script', $wpScripts->queue))->true();
expect(in_array('select2', $wp_scripts->queue))->false(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
expect(in_array('some_random_script', $wp_scripts->queue))->false(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
expect(in_array('permitted_script', $wp_scripts->queue))->true(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
}
public function testItWhitelistsScripts() {
@@ -96,11 +96,11 @@ class ConflictResolverTest extends \MailPoetTest {
$this->conflictResolver->resolveStylesConflict();
do_action('wp_print_scripts');
do_action('admin_print_footer_scripts');
global $wpScripts;
global $wp_scripts; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
// it should not dequeue select2 script
expect(in_array('select2', $wpScripts->queue))->true();
expect(in_array('select2', $wp_scripts->queue))->true(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
}
public function _after() {
}
}
}

View File

@@ -12,9 +12,9 @@ class FunctionsTest extends \MailPoetTest {
public $contentWidth;
public function _before() {
parent::_before();
global $contentWidth;
$this->contentWidth = $contentWidth;
$contentWidth = 150;
global $content_width; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$this->contentWidth = $content_width; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$content_width = 150; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$this->action = 'mailpoet_test_action';
$this->filter = 'mailpoet_test_filter';
$this->wp = new WPFunctions;
@@ -93,7 +93,7 @@ class FunctionsTest extends \MailPoetTest {
}
public function _after() {
global $contentWidth;
$contentWidth = $this->contentWidth;
global $content_width; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$content_width = $this->contentWidth; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
}
}