- Removes space between IF and statement

This commit is contained in:
Vlad
2016-05-18 09:26:36 -04:00
parent bf1ab3a593
commit 31e082eb2b
22 changed files with 48 additions and 48 deletions

View File

@ -39,7 +39,7 @@ class Env {
self::$assets_url = plugins_url('/assets', $file); self::$assets_url = plugins_url('/assets', $file);
$wp_upload_dir = wp_upload_dir(); $wp_upload_dir = wp_upload_dir();
self::$temp_path = $wp_upload_dir['basedir'].'/'.self::$plugin_name; 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); mkdir(self::$temp_path);
} }
self::$temp_url = $wp_upload_dir['baseurl'].'/'.self::$plugin_name; self::$temp_url = $wp_upload_dir['baseurl'].'/'.self::$plugin_name;

View File

@ -10,7 +10,7 @@ use \MailPoet\Segments\WP;
use \MailPoet\Models\Setting; use \MailPoet\Models\Setting;
use \MailPoet\Settings\Pages; use \MailPoet\Settings\Pages;
if (!defined('ABSPATH')) exit; if(!defined('ABSPATH')) exit;
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
@ -36,7 +36,7 @@ class Populator {
$column_conditions = array_map(function($key) use ($field) { $column_conditions = array_map(function($key) use ($field) {
return $key . '=' . $field[$key]; return $key . '=' . $field[$key];
}, $field); }, $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( $wpdb->insert(
$table, $table,
$field $field
@ -207,7 +207,7 @@ class Populator {
$_this = $this; $_this = $this;
array_map(function($row) use ($_this, $table) { array_map(function($row) use ($_this, $table) {
if (!$_this->rowExists($table, $row)) { if(!$_this->rowExists($table, $row)) {
$_this->insertRow($table, $row); $_this->insertRow($table, $row);
} }
}, $rows); }, $rows);

View File

@ -47,7 +47,7 @@ class Scheduler {
function processWelcomeNewsletter($newsletter, $queue) { function processWelcomeNewsletter($newsletter, $queue) {
$subscriber = unserialize($queue->subscribers); $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(); $queue->delete();
return; return;
} }

View File

@ -43,7 +43,7 @@ class SendingQueue {
} }
$newsletter = $newsletter->asArray(); $newsletter = $newsletter->asArray();
$newsletter['body'] = $this->getOrRenderNewsletterBody($queue, $newsletter); $newsletter['body'] = $this->getOrRenderNewsletterBody($queue, $newsletter);
if ($newsletter['type'] === 'notification' && if($newsletter['type'] === 'notification' &&
strpos($newsletter['body']['html'], 'data-post-id') === false strpos($newsletter['body']['html'], 'data-post-id') === false
){ ){
$queue->delete(); $queue->delete();
@ -61,14 +61,14 @@ class SendingQueue {
$subscribers_ids) { $subscribers_ids) {
$subscribers = Subscriber::whereIn('id', $subscribers_ids) $subscribers = Subscriber::whereIn('id', $subscribers_ids)
->findArray(); ->findArray();
if (count($subscribers_ids) !== count($subscribers)) { if(count($subscribers_ids) !== count($subscribers)) {
$queue->subscribers->to_process = $this->recalculateSubscriberCount( $queue->subscribers->to_process = $this->recalculateSubscriberCount(
Helpers::arrayColumn($subscribers, 'id'), Helpers::arrayColumn($subscribers, 'id'),
$subscribers_ids, $subscribers_ids,
$queue->subscribers->to_process $queue->subscribers->to_process
); );
} }
if (!count($queue->subscribers->to_process)) { if(!count($queue->subscribers->to_process)) {
$this->updateQueue($queue); $this->updateQueue($queue);
continue; continue;
} }

View File

@ -93,7 +93,7 @@ class Newsletter extends Model {
} }
function getStatistics() { function getStatistics() {
if ($this->queue === false) { if($this->queue === false) {
return false; return false;
} }
return SendingQueue::tableAlias('queues') return SendingQueue::tableAlias('queues')

View File

@ -1,7 +1,7 @@
<?php <?php
namespace MailPoet\Models; namespace MailPoet\Models;
if (!defined('ABSPATH')) exit; if(!defined('ABSPATH')) exit;
class Setting extends Model { class Setting extends Model {
public static $_table = MP_SETTINGS_TABLE; public static $_table = MP_SETTINGS_TABLE;

View File

@ -26,7 +26,7 @@ class AutomatedLatestContent {
$wherePostUnsent = 'ID NOT IN (' . $sentPostsQuery . ')'; $wherePostUnsent = 'ID NOT IN (' . $sentPostsQuery . ')';
if (!empty($where)) $wherePostUnsent = ' AND ' . $wherePostUnsent; if(!empty($where)) $wherePostUnsent = ' AND ' . $wherePostUnsent;
return $where . $wherePostUnsent; return $where . $wherePostUnsent;
} }
@ -48,7 +48,7 @@ class AutomatedLatestContent {
if(isset($args['posts']) && is_array($args['posts'])) { if(isset($args['posts']) && is_array($args['posts'])) {
$parameters['post__in'] = $args['posts']; $parameters['post__in'] = $args['posts'];
} }
if (!empty($posts_to_exclude)) { if(!empty($posts_to_exclude)) {
$parameters['post__not_in'] = $posts_to_exclude; $parameters['post__not_in'] = $posts_to_exclude;
} }
$parameters['tax_query'] = $this->constructTaxonomiesQuery($args); $parameters['tax_query'] = $this->constructTaxonomiesQuery($args);
@ -106,13 +106,13 @@ class AutomatedLatestContent {
} }
private function _attachSentPostsFilter() { private function _attachSentPostsFilter() {
if ($this->newsletter_id > 0) { if($this->newsletter_id > 0) {
add_action('posts_where', array($this, 'filterOutSentPosts')); add_action('posts_where', array($this, 'filterOutSentPosts'));
} }
} }
private function _detachSentPostsFilter() { private function _detachSentPostsFilter() {
if ($this->newsletter_id > 0) { if($this->newsletter_id > 0) {
remove_action('posts_where', array($this, 'filterOutSentPosts')); remove_action('posts_where', array($this, 'filterOutSentPosts'));
} }
} }

View File

@ -11,14 +11,14 @@ class MetaInformationManager {
$position_field = $position . 'Text'; $position_field = $position . 'Text';
$text = array(); $text = array();
if ($args['showAuthor'] === $position_field) { if($args['showAuthor'] === $position_field) {
$text[] = self::getPostAuthor( $text[] = self::getPostAuthor(
$post->post_author, $post->post_author,
$args['authorPrecededBy'] $args['authorPrecededBy']
); );
} }
if ($args['showCategories'] === $position_field) { if($args['showCategories'] === $position_field) {
$text[] = self::getPostCategories( $text[] = self::getPostCategories(
$post->ID, $post->ID,
$post->post_type, $post->post_type,
@ -26,10 +26,10 @@ class MetaInformationManager {
); );
} }
if (!empty($text)) { if(!empty($text)) {
$text = '<p>' . implode('<br />', $text) . '</p>'; $text = '<p>' . implode('<br />', $text) . '</p>';
if ($position === 'above') $content = $text . $content; if($position === 'above') $content = $text . $content;
else if ($position === 'below') $content .= $text; else if($position === 'below') $content .= $text;
} }
} }

View File

@ -8,9 +8,9 @@ class PostContentManager {
const MAX_EXCERPT_LENGTH = 60; const MAX_EXCERPT_LENGTH = 60;
function getContent($post, $displayType) { function getContent($post, $displayType) {
if ($displayType === 'titleOnly') { if($displayType === 'titleOnly') {
return ''; return '';
} elseif ($displayType === 'excerpt') { } elseif($displayType === 'excerpt') {
// get excerpt // get excerpt
if(!empty($post->post_excerpt)) { if(!empty($post->post_excerpt)) {
return $post->post_excerpt; return $post->post_excerpt;
@ -50,7 +50,7 @@ class PostContentManager {
private function generateExcerpt($content) { private function generateExcerpt($content) {
// if excerpt is empty then try to find the "more" tag // if excerpt is empty then try to find the "more" tag
$excerpts = explode('<!--more-->', $content); $excerpts = explode('<!--more-->', $content);
if (count($excerpts) > 1) { if(count($excerpts) > 1) {
// <!--more--> separator was present // <!--more--> separator was present
return $excerpts[0]; return $excerpts[0];
} else { } else {

View File

@ -17,7 +17,7 @@ class PostListTransformer {
$use_divider = $this->args['showDivider'] === 'true'; $use_divider = $this->args['showDivider'] === 'true';
foreach ($posts as $index => $post) { foreach ($posts as $index => $post) {
if ($use_divider && $index > 0) { if($use_divider && $index > 0) {
$results[] = $this->args['divider']; $results[] = $this->args['divider'];
} }

View File

@ -155,13 +155,13 @@ class PostTransformer {
private function getPostTitle($post) { private function getPostTitle($post) {
$title = $post->post_title; $title = $post->post_title;
if ($this->args['titleIsLink'] === 'true') { if($this->args['titleIsLink'] === 'true') {
$title = '<a href="' . get_permalink($post->ID) . '">' . $title . '</a>'; $title = '<a href="' . get_permalink($post->ID) . '">' . $title . '</a>';
} }
if (in_array($this->args['titleFormat'], array('h1', 'h2', 'h3'))) { if(in_array($this->args['titleFormat'], array('h1', 'h2', 'h3'))) {
$tag = $this->args['titleFormat']; $tag = $this->args['titleFormat'];
} elseif ($this->args['titleFormat'] === 'ul') { } elseif($this->args['titleFormat'] === 'ul') {
$tag = 'li'; $tag = 'li';
} else { } else {
$tag = 'h1'; $tag = 'h1';

View File

@ -25,7 +25,7 @@ class StructureTransformer {
$top_ancestor = $this->findTopAncestor($item); $top_ancestor = $this->findTopAncestor($item);
$offset = $top_ancestor->index(); $offset = $top_ancestor->index();
if ($item->hasParent('a')) { if($item->hasParent('a')) {
$item = $item->parent; $item = $item->parent;
} }
@ -46,8 +46,8 @@ class StructureTransformer {
*/ */
private function transformTagsToBlocks($root, $image_full_width) { private function transformTagsToBlocks($root, $image_full_width) {
return array_map(function($item) use ($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 === 'img' || $item->tag === 'a' && $item->query('img')) {
if ($item->tag === 'a') { if($item->tag === 'a') {
$link = $item->getAttribute('href'); $link = $item->getAttribute('href');
$image = $item->children[0]; $image = $item->children[0];
} else { } else {
@ -87,11 +87,11 @@ class StructureTransformer {
$updated_structure = array(); $updated_structure = array();
$text_accumulator = ''; $text_accumulator = '';
foreach ($structure as $item) { foreach ($structure as $item) {
if ($item['type'] === 'text') { if($item['type'] === 'text') {
$text_accumulator .= $item['text']; $text_accumulator .= $item['text'];
} }
if ($item['type'] !== 'text') { if($item['type'] !== 'text') {
if (!empty($text_accumulator)) { if(!empty($text_accumulator)) {
$updated_structure[] = array( $updated_structure[] = array(
'type' => 'text', 'type' => 'text',
'text' => trim($text_accumulator), 'text' => trim($text_accumulator),
@ -102,7 +102,7 @@ class StructureTransformer {
} }
} }
if (!empty($text_accumulator)) { if(!empty($text_accumulator)) {
$updated_structure[] = array( $updated_structure[] = array(
'type' => 'text', 'type' => 'text',
'text' => trim($text_accumulator), 'text' => trim($text_accumulator),

View File

@ -25,7 +25,7 @@ class TitleListTransformer {
$alignment = $this->args['titleAlignment']; $alignment = $this->args['titleAlignment'];
$alignment = (in_array($alignment, array('left', 'right', 'center'))) ? $alignment : 'left'; $alignment = (in_array($alignment, array('left', 'right', 'center'))) ? $alignment : 'left';
if ($this->args['titleIsLink']) { if($this->args['titleIsLink']) {
$title = '<a href="' . get_permalink($post->ID) . '">' . $title . '</a>'; $title = '<a href="' . get_permalink($post->ID) . '">' . $title . '</a>';
} }

View File

@ -11,7 +11,7 @@ class Transformer {
function __construct($args) { function __construct($args) {
$title_list_only = $args['displayType'] === 'titleOnly' && $args['titleFormat'] === 'ul'; $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); else $transformer = new PostListTransformer($args);
$this->transformer = $transformer; $this->transformer = $transformer;
} }

View File

@ -29,13 +29,13 @@ class Renderer {
} }
function createElementFromBlockType($block, $column_count) { function createElementFromBlockType($block, $column_count) {
if ($block['type'] === 'automatedLatestContent') { if($block['type'] === 'automatedLatestContent') {
$content = $this->processAutomatedLatestContent($block, $column_count); $content = $this->processAutomatedLatestContent($block, $column_count);
return $content; return $content;
} }
$block = StylesHelper::applyTextAlignment($block); $block = StylesHelper::applyTextAlignment($block);
$block_class = __NAMESPACE__ . '\\' . ucfirst($block['type']); $block_class = __NAMESPACE__ . '\\' . ucfirst($block['type']);
if (!class_exists($block_class)) { if(!class_exists($block_class)) {
return ''; return '';
} }
return $block_class::render($block, $column_count); return $block_class::render($block, $column_count);

View File

@ -81,7 +81,7 @@ class Text {
false; false;
// if previous or next paragraphs are empty OR previous paragraph // if previous or next paragraphs are empty OR previous paragraph
// is a heading, insert a break line // is a heading, insert a break line
if (!$next_element || if(!$next_element ||
!$previous_element || !$previous_element ||
(preg_match('/h\d+/', $previous_element_tag)) (preg_match('/h\d+/', $previous_element_tag))
) { ) {

View File

@ -89,14 +89,14 @@ class StylesHelper {
} }
static function applyHeadingMargin($style, $selector) { 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']; $font_size = (int)$style['fontSize'];
$style['margin'] = sprintf('0 0 %spx 0', self::$heading_margin_multiplier * $font_size); $style['margin'] = sprintf('0 0 %spx 0', self::$heading_margin_multiplier * $font_size);
return $style; return $style;
} }
static function applyLineHeight($style, $selector) { 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']; $font_size = (int)$style['fontSize'];
$style['lineHeight'] = sprintf('%spx', self::$line_height_multiplier * $font_size); $style['lineHeight'] = sprintf('%spx', self::$line_height_multiplier * $font_size);
return $style; return $style;

View File

@ -53,7 +53,7 @@ class Newsletter {
break; break;
case 'number': case 'number':
if ($newsletter['type'] !== 'notification') return false; if($newsletter['type'] !== 'notification') return false;
$sent_newsletters = $sent_newsletters =
SendingQueue::where('newsletter_id', $newsletter['id']) SendingQueue::where('newsletter_id', $newsletter['id'])
->where('status', 'completed') ->where('status', 'completed')

View File

@ -142,7 +142,7 @@ class Newsletters {
} }
$newsletter_id = (isset($data['id'])) ? (int)$data['id'] : 0; $newsletter_id = (isset($data['id'])) ? (int)$data['id'] : 0;
$newsletter = Newsletter::findOne($newsletter_id); $newsletter = Newsletter::findOne($newsletter_id);
if (!$newsletter) { if(!$newsletter) {
return array( return array(
'result' => false, 'result' => false,
'errors' => array(__('Newsletter could not be read.')) 'errors' => array(__('Newsletter could not be read.'))

View File

@ -43,7 +43,7 @@ class SendingQueue {
$options['segments'] = serialize($data['segments']); $options['segments'] = serialize($data['segments']);
unset($data['options']); unset($data['options']);
} }
if ($options && if($options &&
($newsletter['type'] === 'notification' || $newsletter['type'] === 'welcome') ($newsletter['type'] === 'notification' || $newsletter['type'] === 'welcome')
) { ) {
$option_fields = NewsletterOptionField::where( $option_fields = NewsletterOptionField::where(
@ -54,7 +54,7 @@ class SendingQueue {
$relation = NewsletterOption::where('option_field_id', $option_field['id']) $relation = NewsletterOption::where('option_field_id', $option_field['id'])
->where('newsletter_id', $newsletter['id']) ->where('newsletter_id', $newsletter['id'])
->findOne(); ->findOne();
if (!$relation) { if(!$relation) {
$relation = NewsletterOption::create(); $relation = NewsletterOption::create();
$relation->newsletter_id = $newsletter['id']; $relation->newsletter_id = $newsletter['id'];
$relation->option_field_id = $option_field['id']; $relation->option_field_id = $option_field['id'];
@ -63,7 +63,7 @@ class SendingQueue {
$relation->save(); $relation->save();
} }
} }
if ($newsletter['type'] === 'notification') { if($newsletter['type'] === 'notification') {
// convert scheduling options into cron format and add to queue // convert scheduling options into cron format and add to queue
$newsletter = Scheduler::processPostNotificationSchedule($newsletter['id']); $newsletter = Scheduler::processPostNotificationSchedule($newsletter['id']);
Scheduler::createPostNotificationQueue($newsletter); Scheduler::createPostNotificationQueue($newsletter);

View File

@ -17,8 +17,8 @@ class BootStrapMenu {
Segment::getSegmentsWithSubscriberCount() : Segment::getSegmentsWithSubscriberCount() :
Segment::getSegmentsForExport($with_confirmed_subscribers); Segment::getSegmentsForExport($with_confirmed_subscribers);
return array_map(function($segment) { return array_map(function($segment) {
if (!$segment['name']) $segment['name'] = __('Not In Segment'); if(!$segment['name']) $segment['name'] = __('Not In Segment');
if (!$segment['id']) $segment['id'] = 0; if(!$segment['id']) $segment['id'] = 0;
return array( return array(
'id' => $segment['id'], 'id' => $segment['id'],
'name' => $segment['name'], 'name' => $segment['name'],

View File

@ -119,7 +119,7 @@ class MailChimp {
} }
function getDataCenter($APIKey) { 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 // double parantheses: http://phpsadness.com/sad/51
$key_parts = explode('-', $APIKey); $key_parts = explode('-', $APIKey);
return end($key_parts); return end($key_parts);