diff --git a/lib/Config/Env.php b/lib/Config/Env.php index 3443c253bc..4d26ab21af 100644 --- a/lib/Config/Env.php +++ b/lib/Config/Env.php @@ -39,7 +39,7 @@ class Env { self::$assets_url = plugins_url('/assets', $file); $wp_upload_dir = wp_upload_dir(); self::$temp_path = $wp_upload_dir['basedir'].'/'.self::$plugin_name; - if (!is_dir(self::$temp_path)) { + if(!is_dir(self::$temp_path)) { mkdir(self::$temp_path); } self::$temp_url = $wp_upload_dir['baseurl'].'/'.self::$plugin_name; diff --git a/lib/Config/Populator.php b/lib/Config/Populator.php index 0b48231f67..db1f29b2c5 100644 --- a/lib/Config/Populator.php +++ b/lib/Config/Populator.php @@ -10,7 +10,7 @@ use \MailPoet\Segments\WP; use \MailPoet\Models\Setting; use \MailPoet\Settings\Pages; -if (!defined('ABSPATH')) exit; +if(!defined('ABSPATH')) exit; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); @@ -36,7 +36,7 @@ class Populator { $column_conditions = array_map(function($key) use ($field) { return $key . '=' . $field[$key]; }, $field); - if ($wpdb->get_var("SELECT COUNT(*) FROM " . $table . " WHERE " . implode(' AND ', $column_conditions)) === 0) { + if($wpdb->get_var("SELECT COUNT(*) FROM " . $table . " WHERE " . implode(' AND ', $column_conditions)) === 0) { $wpdb->insert( $table, $field @@ -207,7 +207,7 @@ class Populator { $_this = $this; array_map(function($row) use ($_this, $table) { - if (!$_this->rowExists($table, $row)) { + if(!$_this->rowExists($table, $row)) { $_this->insertRow($table, $row); } }, $rows); diff --git a/lib/Cron/Workers/Scheduler.php b/lib/Cron/Workers/Scheduler.php index 5f05d891aa..e190149204 100644 --- a/lib/Cron/Workers/Scheduler.php +++ b/lib/Cron/Workers/Scheduler.php @@ -47,7 +47,7 @@ class Scheduler { function processWelcomeNewsletter($newsletter, $queue) { $subscriber = unserialize($queue->subscribers); - if (!isset($subscriber['to_process']) || !isset($subscriber['to_process'][0])) { + if(!isset($subscriber['to_process']) || !isset($subscriber['to_process'][0])) { $queue->delete(); return; } diff --git a/lib/Cron/Workers/SendingQueue.php b/lib/Cron/Workers/SendingQueue.php index 244746c31d..d21b025973 100644 --- a/lib/Cron/Workers/SendingQueue.php +++ b/lib/Cron/Workers/SendingQueue.php @@ -43,7 +43,7 @@ class SendingQueue { } $newsletter = $newsletter->asArray(); $newsletter['body'] = $this->getOrRenderNewsletterBody($queue, $newsletter); - if ($newsletter['type'] === 'notification' && + if($newsletter['type'] === 'notification' && strpos($newsletter['body']['html'], 'data-post-id') === false ){ $queue->delete(); @@ -61,14 +61,14 @@ class SendingQueue { $subscribers_ids) { $subscribers = Subscriber::whereIn('id', $subscribers_ids) ->findArray(); - if (count($subscribers_ids) !== count($subscribers)) { + if(count($subscribers_ids) !== count($subscribers)) { $queue->subscribers->to_process = $this->recalculateSubscriberCount( Helpers::arrayColumn($subscribers, 'id'), $subscribers_ids, $queue->subscribers->to_process ); } - if (!count($queue->subscribers->to_process)) { + if(!count($queue->subscribers->to_process)) { $this->updateQueue($queue); continue; } diff --git a/lib/Models/Newsletter.php b/lib/Models/Newsletter.php index 78673900be..ad1f7c778f 100644 --- a/lib/Models/Newsletter.php +++ b/lib/Models/Newsletter.php @@ -93,7 +93,7 @@ class Newsletter extends Model { } function getStatistics() { - if ($this->queue === false) { + if($this->queue === false) { return false; } return SendingQueue::tableAlias('queues') diff --git a/lib/Models/Setting.php b/lib/Models/Setting.php index 6920bb526f..503be71ba8 100644 --- a/lib/Models/Setting.php +++ b/lib/Models/Setting.php @@ -1,7 +1,7 @@ constructTaxonomiesQuery($args); @@ -106,13 +106,13 @@ class AutomatedLatestContent { } private function _attachSentPostsFilter() { - if ($this->newsletter_id > 0) { + if($this->newsletter_id > 0) { add_action('posts_where', array($this, 'filterOutSentPosts')); } } private function _detachSentPostsFilter() { - if ($this->newsletter_id > 0) { + if($this->newsletter_id > 0) { remove_action('posts_where', array($this, 'filterOutSentPosts')); } } diff --git a/lib/Newsletter/Editor/MetaInformationManager.php b/lib/Newsletter/Editor/MetaInformationManager.php index 8b1f842e4e..acd0045e26 100644 --- a/lib/Newsletter/Editor/MetaInformationManager.php +++ b/lib/Newsletter/Editor/MetaInformationManager.php @@ -11,14 +11,14 @@ class MetaInformationManager { $position_field = $position . 'Text'; $text = array(); - if ($args['showAuthor'] === $position_field) { + if($args['showAuthor'] === $position_field) { $text[] = self::getPostAuthor( $post->post_author, $args['authorPrecededBy'] ); } - if ($args['showCategories'] === $position_field) { + if($args['showCategories'] === $position_field) { $text[] = self::getPostCategories( $post->ID, $post->post_type, @@ -26,10 +26,10 @@ class MetaInformationManager { ); } - if (!empty($text)) { + if(!empty($text)) { $text = '

' . implode('
', $text) . '

'; - if ($position === 'above') $content = $text . $content; - else if ($position === 'below') $content .= $text; + if($position === 'above') $content = $text . $content; + else if($position === 'below') $content .= $text; } } diff --git a/lib/Newsletter/Editor/PostContentManager.php b/lib/Newsletter/Editor/PostContentManager.php index c06c94eac6..ab94600d4b 100644 --- a/lib/Newsletter/Editor/PostContentManager.php +++ b/lib/Newsletter/Editor/PostContentManager.php @@ -8,9 +8,9 @@ class PostContentManager { const MAX_EXCERPT_LENGTH = 60; function getContent($post, $displayType) { - if ($displayType === 'titleOnly') { + if($displayType === 'titleOnly') { return ''; - } elseif ($displayType === 'excerpt') { + } elseif($displayType === 'excerpt') { // get excerpt if(!empty($post->post_excerpt)) { return $post->post_excerpt; @@ -50,7 +50,7 @@ class PostContentManager { private function generateExcerpt($content) { // if excerpt is empty then try to find the "more" tag $excerpts = explode('', $content); - if (count($excerpts) > 1) { + if(count($excerpts) > 1) { // separator was present return $excerpts[0]; } else { diff --git a/lib/Newsletter/Editor/PostListTransformer.php b/lib/Newsletter/Editor/PostListTransformer.php index e2da0e75ef..75a151d5f7 100644 --- a/lib/Newsletter/Editor/PostListTransformer.php +++ b/lib/Newsletter/Editor/PostListTransformer.php @@ -17,7 +17,7 @@ class PostListTransformer { $use_divider = $this->args['showDivider'] === 'true'; foreach ($posts as $index => $post) { - if ($use_divider && $index > 0) { + if($use_divider && $index > 0) { $results[] = $this->args['divider']; } diff --git a/lib/Newsletter/Editor/PostTransformer.php b/lib/Newsletter/Editor/PostTransformer.php index ae6228dab6..138b466dba 100644 --- a/lib/Newsletter/Editor/PostTransformer.php +++ b/lib/Newsletter/Editor/PostTransformer.php @@ -155,13 +155,13 @@ class PostTransformer { private function getPostTitle($post) { $title = $post->post_title; - if ($this->args['titleIsLink'] === 'true') { + if($this->args['titleIsLink'] === 'true') { $title = '' . $title . ''; } - if (in_array($this->args['titleFormat'], array('h1', 'h2', 'h3'))) { + if(in_array($this->args['titleFormat'], array('h1', 'h2', 'h3'))) { $tag = $this->args['titleFormat']; - } elseif ($this->args['titleFormat'] === 'ul') { + } elseif($this->args['titleFormat'] === 'ul') { $tag = 'li'; } else { $tag = 'h1'; diff --git a/lib/Newsletter/Editor/StructureTransformer.php b/lib/Newsletter/Editor/StructureTransformer.php index ebd88aa77a..ab1603a350 100644 --- a/lib/Newsletter/Editor/StructureTransformer.php +++ b/lib/Newsletter/Editor/StructureTransformer.php @@ -25,7 +25,7 @@ class StructureTransformer { $top_ancestor = $this->findTopAncestor($item); $offset = $top_ancestor->index(); - if ($item->hasParent('a')) { + if($item->hasParent('a')) { $item = $item->parent; } @@ -46,8 +46,8 @@ class StructureTransformer { */ private function transformTagsToBlocks($root, $image_full_width) { return array_map(function($item) use ($image_full_width) { - if ($item->tag === 'img' || $item->tag === 'a' && $item->query('img')) { - if ($item->tag === 'a') { + if($item->tag === 'img' || $item->tag === 'a' && $item->query('img')) { + if($item->tag === 'a') { $link = $item->getAttribute('href'); $image = $item->children[0]; } else { @@ -87,11 +87,11 @@ class StructureTransformer { $updated_structure = array(); $text_accumulator = ''; foreach ($structure as $item) { - if ($item['type'] === 'text') { + if($item['type'] === 'text') { $text_accumulator .= $item['text']; } - if ($item['type'] !== 'text') { - if (!empty($text_accumulator)) { + if($item['type'] !== 'text') { + if(!empty($text_accumulator)) { $updated_structure[] = array( 'type' => 'text', 'text' => trim($text_accumulator), @@ -102,7 +102,7 @@ class StructureTransformer { } } - if (!empty($text_accumulator)) { + if(!empty($text_accumulator)) { $updated_structure[] = array( 'type' => 'text', 'text' => trim($text_accumulator), diff --git a/lib/Newsletter/Editor/TitleListTransformer.php b/lib/Newsletter/Editor/TitleListTransformer.php index 79e4431bb3..76cf81fffb 100644 --- a/lib/Newsletter/Editor/TitleListTransformer.php +++ b/lib/Newsletter/Editor/TitleListTransformer.php @@ -25,7 +25,7 @@ class TitleListTransformer { $alignment = $this->args['titleAlignment']; $alignment = (in_array($alignment, array('left', 'right', 'center'))) ? $alignment : 'left'; - if ($this->args['titleIsLink']) { + if($this->args['titleIsLink']) { $title = '' . $title . ''; } diff --git a/lib/Newsletter/Editor/Transformer.php b/lib/Newsletter/Editor/Transformer.php index 6ce6762785..8e188d72d8 100644 --- a/lib/Newsletter/Editor/Transformer.php +++ b/lib/Newsletter/Editor/Transformer.php @@ -11,7 +11,7 @@ class Transformer { function __construct($args) { $title_list_only = $args['displayType'] === 'titleOnly' && $args['titleFormat'] === 'ul'; - if ($title_list_only) $transformer = new TitleListTransformer($args); + if($title_list_only) $transformer = new TitleListTransformer($args); else $transformer = new PostListTransformer($args); $this->transformer = $transformer; } diff --git a/lib/Newsletter/Renderer/Blocks/Renderer.php b/lib/Newsletter/Renderer/Blocks/Renderer.php index 8de5914e95..38da8bb224 100644 --- a/lib/Newsletter/Renderer/Blocks/Renderer.php +++ b/lib/Newsletter/Renderer/Blocks/Renderer.php @@ -29,13 +29,13 @@ class Renderer { } function createElementFromBlockType($block, $column_count) { - if ($block['type'] === 'automatedLatestContent') { + if($block['type'] === 'automatedLatestContent') { $content = $this->processAutomatedLatestContent($block, $column_count); return $content; } $block = StylesHelper::applyTextAlignment($block); $block_class = __NAMESPACE__ . '\\' . ucfirst($block['type']); - if (!class_exists($block_class)) { + if(!class_exists($block_class)) { return ''; } return $block_class::render($block, $column_count); diff --git a/lib/Newsletter/Renderer/Blocks/Text.php b/lib/Newsletter/Renderer/Blocks/Text.php index d3fa560237..59ce320a1c 100644 --- a/lib/Newsletter/Renderer/Blocks/Text.php +++ b/lib/Newsletter/Renderer/Blocks/Text.php @@ -81,7 +81,7 @@ class Text { false; // if previous or next paragraphs are empty OR previous paragraph // is a heading, insert a break line - if (!$next_element || + if(!$next_element || !$previous_element || (preg_match('/h\d+/', $previous_element_tag)) ) { diff --git a/lib/Newsletter/Renderer/StylesHelper.php b/lib/Newsletter/Renderer/StylesHelper.php index 05159a820a..85ab35a80b 100644 --- a/lib/Newsletter/Renderer/StylesHelper.php +++ b/lib/Newsletter/Renderer/StylesHelper.php @@ -89,14 +89,14 @@ class StylesHelper { } static function applyHeadingMargin($style, $selector) { - if (!preg_match('/h[1-4]/i', $selector)) return $style; + if(!preg_match('/h[1-4]/i', $selector)) return $style; $font_size = (int)$style['fontSize']; $style['margin'] = sprintf('0 0 %spx 0', self::$heading_margin_multiplier * $font_size); return $style; } static function applyLineHeight($style, $selector) { - if (!preg_match('/mailpoet_paragraph|h[1-4]/i', $selector)) return $style; + if(!preg_match('/mailpoet_paragraph|h[1-4]/i', $selector)) return $style; $font_size = (int)$style['fontSize']; $style['lineHeight'] = sprintf('%spx', self::$line_height_multiplier * $font_size); return $style; diff --git a/lib/Newsletter/Shortcodes/Categories/Newsletter.php b/lib/Newsletter/Shortcodes/Categories/Newsletter.php index cda51c0c51..1aae2059c6 100644 --- a/lib/Newsletter/Shortcodes/Categories/Newsletter.php +++ b/lib/Newsletter/Shortcodes/Categories/Newsletter.php @@ -53,7 +53,7 @@ class Newsletter { break; case 'number': - if ($newsletter['type'] !== 'notification') return false; + if($newsletter['type'] !== 'notification') return false; $sent_newsletters = SendingQueue::where('newsletter_id', $newsletter['id']) ->where('status', 'completed') diff --git a/lib/Router/Newsletters.php b/lib/Router/Newsletters.php index d12225d558..0db3ceede9 100644 --- a/lib/Router/Newsletters.php +++ b/lib/Router/Newsletters.php @@ -142,7 +142,7 @@ class Newsletters { } $newsletter_id = (isset($data['id'])) ? (int)$data['id'] : 0; $newsletter = Newsletter::findOne($newsletter_id); - if (!$newsletter) { + if(!$newsletter) { return array( 'result' => false, 'errors' => array(__('Newsletter could not be read.')) diff --git a/lib/Router/SendingQueue.php b/lib/Router/SendingQueue.php index b1d4ae991d..356e6e4315 100644 --- a/lib/Router/SendingQueue.php +++ b/lib/Router/SendingQueue.php @@ -43,7 +43,7 @@ class SendingQueue { $options['segments'] = serialize($data['segments']); unset($data['options']); } - if ($options && + if($options && ($newsletter['type'] === 'notification' || $newsletter['type'] === 'welcome') ) { $option_fields = NewsletterOptionField::where( @@ -54,7 +54,7 @@ class SendingQueue { $relation = NewsletterOption::where('option_field_id', $option_field['id']) ->where('newsletter_id', $newsletter['id']) ->findOne(); - if (!$relation) { + if(!$relation) { $relation = NewsletterOption::create(); $relation->newsletter_id = $newsletter['id']; $relation->option_field_id = $option_field['id']; @@ -63,7 +63,7 @@ class SendingQueue { $relation->save(); } } - if ($newsletter['type'] === 'notification') { + if($newsletter['type'] === 'notification') { // convert scheduling options into cron format and add to queue $newsletter = Scheduler::processPostNotificationSchedule($newsletter['id']); Scheduler::createPostNotificationQueue($newsletter); diff --git a/lib/Subscribers/ImportExport/BootStrapMenu.php b/lib/Subscribers/ImportExport/BootStrapMenu.php index 8877c3aada..170600cd0b 100644 --- a/lib/Subscribers/ImportExport/BootStrapMenu.php +++ b/lib/Subscribers/ImportExport/BootStrapMenu.php @@ -17,8 +17,8 @@ class BootStrapMenu { Segment::getSegmentsWithSubscriberCount() : Segment::getSegmentsForExport($with_confirmed_subscribers); return array_map(function($segment) { - if (!$segment['name']) $segment['name'] = __('Not In Segment'); - if (!$segment['id']) $segment['id'] = 0; + if(!$segment['name']) $segment['name'] = __('Not In Segment'); + if(!$segment['id']) $segment['id'] = 0; return array( 'id' => $segment['id'], 'name' => $segment['name'], diff --git a/lib/Subscribers/ImportExport/Import/MailChimp.php b/lib/Subscribers/ImportExport/Import/MailChimp.php index 11209c9059..303ed44555 100644 --- a/lib/Subscribers/ImportExport/Import/MailChimp.php +++ b/lib/Subscribers/ImportExport/Import/MailChimp.php @@ -119,7 +119,7 @@ class MailChimp { } function getDataCenter($APIKey) { - if (!preg_match('/-[a-zA-Z0-9]{3,}/', $APIKey)) return false; + if(!preg_match('/-[a-zA-Z0-9]{3,}/', $APIKey)) return false; // double parantheses: http://phpsadness.com/sad/51 $key_parts = explode('-', $APIKey); return end($key_parts);