Add space between foreach and ‘(‘
[MAILPOET-1791]
This commit is contained in:
@ -35,7 +35,7 @@ class RoboFile extends \Robo\Tasks {
|
||||
);
|
||||
|
||||
$list = array();
|
||||
foreach($files as $file) {
|
||||
foreach ($files as $file) {
|
||||
$list[] = $file[0];
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ class RoboFile extends \Robo\Tasks {
|
||||
|
||||
// Create manifest file
|
||||
$manifest = [];
|
||||
foreach(glob('assets/dist/css/*.css') as $style) {
|
||||
foreach (glob('assets/dist/css/*.css') as $style) {
|
||||
// Hash and rename styles if production environment
|
||||
if($opts['env'] === 'production') {
|
||||
$hashed_style = sprintf(
|
||||
|
@ -46,7 +46,7 @@ class API {
|
||||
$this->access_control = $access_control;
|
||||
$this->settings = $settings;
|
||||
$this->wp = $wp;
|
||||
foreach($this->_available_api_versions as $available_api_version) {
|
||||
foreach ($this->_available_api_versions as $available_api_version) {
|
||||
$this->addEndpointNamespace(
|
||||
sprintf('%s\%s', __NAMESPACE__, $available_api_version),
|
||||
$available_api_version
|
||||
@ -116,7 +116,7 @@ class API {
|
||||
$error_response = $this->createErrorResponse(Error::BAD_REQUEST, $error_message, Response::STATUS_BAD_REQUEST);
|
||||
return $error_response;
|
||||
} else if(!empty($this->_endpoint_namespaces[$this->_request_api_version])) {
|
||||
foreach($this->_endpoint_namespaces[$this->_request_api_version] as $namespace) {
|
||||
foreach ($this->_endpoint_namespaces[$this->_request_api_version] as $namespace) {
|
||||
$endpoint_class = sprintf(
|
||||
'%s\%s',
|
||||
$namespace,
|
||||
|
@ -81,11 +81,11 @@ class AutomatedLatestContent extends APIEndpoint {
|
||||
$used_posts = array();
|
||||
$rendered_posts = array();
|
||||
|
||||
foreach($data['blocks'] as $block) {
|
||||
foreach ($data['blocks'] as $block) {
|
||||
$posts = $this->ALC->getPosts($block, $used_posts);
|
||||
$rendered_posts[] = $this->ALC->transformPosts($block, $posts);
|
||||
|
||||
foreach($posts as $post) {
|
||||
foreach ($posts as $post) {
|
||||
$used_posts[] = $post->ID;
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class Forms extends APIEndpoint {
|
||||
$listing_data = $this->listing_handler->get('\MailPoet\Models\Form', $data);
|
||||
|
||||
$data = array();
|
||||
foreach($listing_data['items'] as $form) {
|
||||
foreach ($listing_data['items'] as $form) {
|
||||
$form = $form->asArray();
|
||||
|
||||
$form['signups'] = StatisticsForms::getTotalSignups($form['id']);
|
||||
@ -161,7 +161,7 @@ class Forms extends APIEndpoint {
|
||||
$is_widget = false;
|
||||
$widgets = get_option('widget_mailpoet_form');
|
||||
if(!empty($widgets)) {
|
||||
foreach($widgets as $widget) {
|
||||
foreach ($widgets as $widget) {
|
||||
if(isset($widget['form']) && (int)$widget['form'] === $form_id) {
|
||||
$is_widget = true;
|
||||
break;
|
||||
@ -173,7 +173,7 @@ class Forms extends APIEndpoint {
|
||||
// or if it's selected by the admin
|
||||
$has_segment_selection = false;
|
||||
$list_selection = [];
|
||||
foreach($body as $i => $block) {
|
||||
foreach ($body as $i => $block) {
|
||||
if($block['type'] === 'segment') {
|
||||
$has_segment_selection = true;
|
||||
if(!empty($block['params']['values'])) {
|
||||
|
@ -108,7 +108,7 @@ class Newsletters extends APIEndpoint {
|
||||
if(!empty($segments)) {
|
||||
NewsletterSegment::where('newsletter_id', $newsletter->id)
|
||||
->deleteMany();
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
if(!is_array($segment)) continue;
|
||||
$relation = NewsletterSegment::create();
|
||||
$relation->segment_id = (int)$segment['id'];
|
||||
@ -127,7 +127,7 @@ class Newsletters extends APIEndpoint {
|
||||
$newsletter->type
|
||||
)->findMany();
|
||||
// update newsletter options
|
||||
foreach($option_fields as $option_field) {
|
||||
foreach ($option_fields as $option_field) {
|
||||
if(isset($options[$option_field->name])) {
|
||||
$newsletter_option = NewsletterOption::createOrUpdate(
|
||||
array(
|
||||
@ -406,7 +406,7 @@ class Newsletters extends APIEndpoint {
|
||||
$listing_data = $this->listing_handler->get('\MailPoet\Models\Newsletter', $data);
|
||||
|
||||
$data = array();
|
||||
foreach($listing_data['items'] as $newsletter) {
|
||||
foreach ($listing_data['items'] as $newsletter) {
|
||||
$queue = false;
|
||||
|
||||
if($newsletter->type === Newsletter::TYPE_STANDARD) {
|
||||
@ -504,7 +504,7 @@ class Newsletters extends APIEndpoint {
|
||||
'newsletter_type', $newsletter->type
|
||||
)->findArray();
|
||||
|
||||
foreach($option_fields as $option_field) {
|
||||
foreach ($option_fields as $option_field) {
|
||||
if(isset($options[$option_field['name']])) {
|
||||
$relation = NewsletterOption::create();
|
||||
$relation->newsletter_id = $newsletter->id;
|
||||
|
@ -46,7 +46,7 @@ class Segments extends APIEndpoint {
|
||||
$listing_data = $this->listing_handler->get('\MailPoet\Models\Segment', $data);
|
||||
|
||||
$data = array();
|
||||
foreach($listing_data['items'] as $segment) {
|
||||
foreach ($listing_data['items'] as $segment) {
|
||||
$segment->subscribers_url = admin_url(
|
||||
'admin.php?page=mailpoet-subscribers#/filter[segment='.$segment->id.']'
|
||||
);
|
||||
|
@ -36,7 +36,7 @@ class Settings extends APIEndpoint {
|
||||
__('You have not specified any settings to be saved.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
foreach($settings as $name => $value) {
|
||||
foreach ($settings as $name => $value) {
|
||||
$this->settings->set($name, $value);
|
||||
}
|
||||
$bridge = new Bridge();
|
||||
|
@ -89,7 +89,7 @@ class Subscribers extends APIEndpoint {
|
||||
}
|
||||
|
||||
$data = array();
|
||||
foreach($listing_data['items'] as $subscriber) {
|
||||
foreach ($listing_data['items'] as $subscriber) {
|
||||
$data[] = $subscriber
|
||||
->withSubscriptions()
|
||||
->asArray();
|
||||
|
@ -52,7 +52,7 @@ class API {
|
||||
);
|
||||
|
||||
$custom_fields = CustomField::selectMany(array('id', 'name'))->findMany();
|
||||
foreach($custom_fields as $custom_field) {
|
||||
foreach ($custom_fields as $custom_field) {
|
||||
$data[] = array(
|
||||
'id' => 'cf_' . $custom_field->id,
|
||||
'name' => $custom_field->name
|
||||
@ -88,7 +88,7 @@ class API {
|
||||
|
||||
// throw exception when trying to subscribe to WP Users or WooCommerce Customers segments
|
||||
$found_segments_ids = array();
|
||||
foreach($found_segments as $found_segment) {
|
||||
foreach ($found_segments as $found_segment) {
|
||||
if($found_segment->type === Segment::TYPE_WP_USERS) {
|
||||
throw new \Exception(__(sprintf("Can't subscribe to a WordPress Users list with ID %d.", $found_segment->id), 'mailpoet'));
|
||||
}
|
||||
@ -142,7 +142,7 @@ class API {
|
||||
|
||||
// throw exception when trying to subscribe to WP Users or WooCommerce Customers segments
|
||||
$found_segments_ids = array();
|
||||
foreach($found_segments as $segment) {
|
||||
foreach ($found_segments as $segment) {
|
||||
if($segment->type === Segment::TYPE_WP_USERS) {
|
||||
throw new \Exception(__(sprintf("Can't unsubscribe from a WordPress Users list with ID %d.", $segment->id), 'mailpoet'));
|
||||
}
|
||||
@ -287,7 +287,7 @@ class API {
|
||||
protected function _scheduleWelcomeNotification(Subscriber $subscriber, array $segments) {
|
||||
$result = Scheduler::scheduleSubscriberWelcomeNotification($subscriber->id, $segments);
|
||||
if(is_array($result)) {
|
||||
foreach($result as $queue) {
|
||||
foreach ($result as $queue) {
|
||||
if($queue instanceof Sending && $queue->getErrors()) {
|
||||
throw new \Exception(
|
||||
__(sprintf('Subscriber added, but welcome email failed to send: %s', strtolower(implode(', ', $queue->getErrors()))), 'mailpoet')
|
||||
|
@ -27,8 +27,8 @@ class Capabilities {
|
||||
function setupWPCapabilities() {
|
||||
$permissions = AccessControl::getDefaultPermissions();
|
||||
$role_objects = array();
|
||||
foreach($permissions as $name => $roles) {
|
||||
foreach($roles as $role) {
|
||||
foreach ($permissions as $name => $roles) {
|
||||
foreach ($roles as $role) {
|
||||
if(!isset($role_objects[$role])) {
|
||||
$role_objects[$role] = get_role($role);
|
||||
}
|
||||
@ -41,8 +41,8 @@ class Capabilities {
|
||||
function removeWPCapabilities() {
|
||||
$permissions = AccessControl::getDefaultPermissions();
|
||||
$role_objects = array();
|
||||
foreach($permissions as $name => $roles) {
|
||||
foreach($roles as $role) {
|
||||
foreach ($permissions as $name => $roles) {
|
||||
foreach ($roles as $role) {
|
||||
if(!isset($role_objects[$role])) {
|
||||
$role_objects[$role] = get_role($role);
|
||||
}
|
||||
@ -79,7 +79,7 @@ class Capabilities {
|
||||
|
||||
function registerMembersCapabilities() {
|
||||
$permissions = AccessControl::getPermissionLabels();
|
||||
foreach($permissions as $name => $label) {
|
||||
foreach ($permissions as $name => $label) {
|
||||
$this->registerMembersCapability($name, $label);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class DeferredAdminNotices {
|
||||
public function printAndClean() {
|
||||
$notices = get_option(DeferredAdminNotices::OPTIONS_KEY_NAME, array());
|
||||
|
||||
foreach($notices as $notice) {
|
||||
foreach ($notices as $notice) {
|
||||
$notice = new Notice(Notice::TYPE_WARNING, $notice["message"]);
|
||||
add_action('network_admin_notices', array($notice, 'displayWPNotice'));
|
||||
}
|
||||
@ -33,4 +33,4 @@ class DeferredAdminNotices {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ class MP2Migrator {
|
||||
$lists_count = count($lists);
|
||||
|
||||
if(is_array($lists)) {
|
||||
foreach($lists as $list) {
|
||||
foreach ($lists as $list) {
|
||||
$segment = $this->importSegment($list);
|
||||
if(!empty($segment)) {
|
||||
$imported_segments_count++;
|
||||
@ -412,7 +412,7 @@ class MP2Migrator {
|
||||
$this->log(__("Importing custom fields...", 'mailpoet'));
|
||||
$custom_fields = $this->getCustomFields();
|
||||
|
||||
foreach($custom_fields as $custom_field) {
|
||||
foreach ($custom_fields as $custom_field) {
|
||||
$result = $this->importCustomField($custom_field);
|
||||
if(!empty($result)) {
|
||||
$imported_custom_fields_count++;
|
||||
@ -567,7 +567,7 @@ class MP2Migrator {
|
||||
$users_count = count($users);
|
||||
|
||||
if(is_array($users)) {
|
||||
foreach($users as $user) {
|
||||
foreach ($users as $user) {
|
||||
$subscriber = $this->importSubscriber($user);
|
||||
if(!empty($subscriber)) {
|
||||
$imported_subscribers_count++;
|
||||
@ -675,7 +675,7 @@ class MP2Migrator {
|
||||
*/
|
||||
private function importSubscriberSegments($subscriber, $user_id) {
|
||||
$user_lists = $this->getUserLists($user_id);
|
||||
foreach($user_lists as $user_list) {
|
||||
foreach ($user_lists as $user_list) {
|
||||
$this->importSubscriberSegment($subscriber->id, $user_list);
|
||||
}
|
||||
}
|
||||
@ -736,7 +736,7 @@ class MP2Migrator {
|
||||
*/
|
||||
private function importSubscriberCustomFields($subscriber, $user) {
|
||||
$imported_custom_fields = $this->getImportedCustomFields();
|
||||
foreach($imported_custom_fields as $custom_field) {
|
||||
foreach ($imported_custom_fields as $custom_field) {
|
||||
$custom_field_column = 'cf_' . $custom_field['id'];
|
||||
$this->importSubscriberCustomField($subscriber->id, $custom_field, $user[$custom_field_column]);
|
||||
}
|
||||
@ -794,7 +794,7 @@ class MP2Migrator {
|
||||
public function getImportedMapping($model) {
|
||||
$mappings = array();
|
||||
$mapping_relations = MappingToExternalEntities::where('type', $model)->findArray();
|
||||
foreach($mapping_relations as $relation) {
|
||||
foreach ($mapping_relations as $relation) {
|
||||
$mappings[$relation['old_id']] = $relation['new_id'];
|
||||
}
|
||||
return $mappings;
|
||||
@ -818,7 +818,7 @@ class MP2Migrator {
|
||||
$forms_count = count($forms);
|
||||
|
||||
if(is_array($forms)) {
|
||||
foreach($forms as $form) {
|
||||
foreach ($forms as $form) {
|
||||
$new_form = $this->importForm($form);
|
||||
if(!empty($new_form)) {
|
||||
$imported_forms_count++;
|
||||
@ -876,7 +876,7 @@ class MP2Migrator {
|
||||
);
|
||||
|
||||
$mp3_form_body = array();
|
||||
foreach($body as $field) {
|
||||
foreach ($body as $field) {
|
||||
$type = $this->mapCustomFieldType($field['type']);
|
||||
if($type == 'segment') {
|
||||
$field_id = 'segments';
|
||||
@ -927,7 +927,7 @@ class MP2Migrator {
|
||||
*/
|
||||
private function getMappedSegmentIds($mp2_list_ids) {
|
||||
$mp3_segment_ids = array();
|
||||
foreach($mp2_list_ids as $list_id) {
|
||||
foreach ($mp2_list_ids as $list_id) {
|
||||
if(isset($this->segments_mapping[$list_id])) {
|
||||
$mp3_segment_ids[] = $this->segments_mapping[$list_id];
|
||||
}
|
||||
@ -970,9 +970,9 @@ class MP2Migrator {
|
||||
*/
|
||||
private function replaceListIds($values) {
|
||||
$mp3_values = array();
|
||||
foreach($values as $value) {
|
||||
foreach ($values as $value) {
|
||||
$mp3_value = array();
|
||||
foreach($value as $item => $item_value) {
|
||||
foreach ($value as $item => $item_value) {
|
||||
if(($item == 'list_id') && isset($this->segments_mapping[$item_value])) {
|
||||
$segment_id = $this->segments_mapping[$item_value];
|
||||
$mp3_value['id'] = $segment_id;
|
||||
|
@ -547,7 +547,7 @@ class Menu {
|
||||
if(!empty($field['params']['values'])) {
|
||||
$values = array();
|
||||
|
||||
foreach($field['params']['values'] as $value) {
|
||||
foreach ($field['params']['values'] as $value) {
|
||||
$values[$value['value']] = $value['value'];
|
||||
}
|
||||
$field['params']['values'] = $values;
|
||||
@ -780,7 +780,7 @@ class Menu {
|
||||
$screen_id = $_REQUEST['page'];
|
||||
}
|
||||
if(!empty($exclude)) {
|
||||
foreach($exclude as $slug) {
|
||||
foreach ($exclude as $slug) {
|
||||
if(stripos($screen_id, $slug) !== false) {
|
||||
return false;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class Migrator {
|
||||
global $wpdb;
|
||||
|
||||
$output = [];
|
||||
foreach($this->models as $model) {
|
||||
foreach ($this->models as $model) {
|
||||
$modelMethod = Helpers::underscoreToCamelCase($model);
|
||||
$output = array_merge(dbDelta($this->$modelMethod()), $output);
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ class Populator {
|
||||
|
||||
protected function newsletterTemplates() {
|
||||
$templates = array();
|
||||
foreach($this->templates as $template) {
|
||||
foreach ($this->templates as $template) {
|
||||
$template = self::TEMPLATES_NAMESPACE . $template;
|
||||
$template = new $template(Env::$assets_url);
|
||||
$templates[] = $template->get();
|
||||
@ -351,7 +351,7 @@ class Populator {
|
||||
$remove_duplicates =
|
||||
isset($data_descriptor['remove_duplicates']) && $data_descriptor['remove_duplicates'];
|
||||
|
||||
foreach($rows as $row) {
|
||||
foreach ($rows as $row) {
|
||||
$existence_comparison_fields = array_intersect_key(
|
||||
$row,
|
||||
$identification_columns
|
||||
@ -405,7 +405,7 @@ class Populator {
|
||||
|
||||
$conditions = array('1=1');
|
||||
$values = array();
|
||||
foreach($where as $field => $value) {
|
||||
foreach ($where as $field => $value) {
|
||||
$conditions[] = "`t1`.`$field` = `t2`.`$field`";
|
||||
$conditions[] = "`t1`.`$field` = %s";
|
||||
$values[] = $value;
|
||||
|
@ -49,7 +49,7 @@ class RequirementsChecker {
|
||||
self::TEST_VENDOR_SOURCE
|
||||
);
|
||||
$results = array();
|
||||
foreach($available_tests as $test) {
|
||||
foreach ($available_tests as $test) {
|
||||
$results[$test] = call_user_func(array($this, 'check' . $test));
|
||||
}
|
||||
return $results;
|
||||
@ -68,7 +68,7 @@ class RequirementsChecker {
|
||||
);
|
||||
return $this->processError($error);
|
||||
}
|
||||
foreach($paths as $path) {
|
||||
foreach ($paths as $path) {
|
||||
$index_file = $path . '/index.php';
|
||||
if(!file_exists($index_file)) {
|
||||
file_put_contents(
|
||||
@ -108,7 +108,7 @@ class RequirementsChecker {
|
||||
}
|
||||
|
||||
function checkVendorSource() {
|
||||
foreach($this->vendor_classes as $dependency) {
|
||||
foreach ($this->vendor_classes as $dependency) {
|
||||
$dependency_path = $this->getDependencyPath($dependency);
|
||||
if(!$dependency_path) {
|
||||
$error = sprintf(
|
||||
|
@ -11,7 +11,7 @@ use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class Shortcodes {
|
||||
private $wp;
|
||||
|
||||
|
||||
function __construct() {
|
||||
$this->wp = new WPFunctions;
|
||||
}
|
||||
@ -102,7 +102,7 @@ class Shortcodes {
|
||||
$html .= '<h3 class="mailpoet_archive_title">'.$title.'</h3>';
|
||||
}
|
||||
$html .= '<ul class="mailpoet_archive">';
|
||||
foreach($newsletters as $newsletter) {
|
||||
foreach ($newsletters as $newsletter) {
|
||||
$queue = $newsletter->queue()->findOne();
|
||||
$html .= '<li>'.
|
||||
'<span class="mailpoet_archive_date">'.
|
||||
|
@ -57,7 +57,7 @@ class Bounce extends SimpleWorker {
|
||||
|
||||
$task_subscribers = new TaskSubscribers($task);
|
||||
|
||||
foreach($subscriber_batches as $subscribers_to_process_ids) {
|
||||
foreach ($subscriber_batches as $subscribers_to_process_ids) {
|
||||
// abort if execution limit is reached
|
||||
CronHelper::enforceExecutionLimit($this->timer);
|
||||
|
||||
@ -81,7 +81,7 @@ class Bounce extends SimpleWorker {
|
||||
}
|
||||
|
||||
function processApiResponse(array $checked_emails) {
|
||||
foreach($checked_emails as $email) {
|
||||
foreach ($checked_emails as $email) {
|
||||
if(!isset($email['address'], $email['bounce'])) {
|
||||
continue;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class Scheduler {
|
||||
$scheduled_queues = self::getScheduledQueues();
|
||||
if(!count($scheduled_queues)) return false;
|
||||
$this->updateTasks($scheduled_queues);
|
||||
foreach($scheduled_queues as $i => $queue) {
|
||||
foreach ($scheduled_queues as $i => $queue) {
|
||||
$newsletter = Newsletter::findOneWithOptions($queue->newsletter_id);
|
||||
if(!$newsletter || $newsletter->deleted_at !== null) {
|
||||
$queue->delete();
|
||||
|
@ -131,11 +131,11 @@ class Migration extends SimpleWorker {
|
||||
);
|
||||
|
||||
if(!empty($queues)) {
|
||||
foreach(array_chunk($queues, self::BATCH_SIZE) as $queue_batch) {
|
||||
foreach (array_chunk($queues, self::BATCH_SIZE) as $queue_batch) {
|
||||
// abort if execution limit is reached
|
||||
CronHelper::enforceExecutionLimit($this->timer);
|
||||
|
||||
foreach($queue_batch as $queue) {
|
||||
foreach ($queue_batch as $queue) {
|
||||
// create a new scheduled task of type "sending"
|
||||
$wpdb->query(sprintf(
|
||||
'INSERT IGNORE INTO %1$s (`type`, %2$s) ' .
|
||||
@ -180,7 +180,7 @@ class Migration extends SimpleWorker {
|
||||
}
|
||||
|
||||
if(!empty($task_ids)) {
|
||||
foreach($task_ids as $task_id) {
|
||||
foreach ($task_ids as $task_id) {
|
||||
// abort if execution limit is reached
|
||||
CronHelper::enforceExecutionLimit($this->timer);
|
||||
|
||||
@ -215,7 +215,7 @@ class Migration extends SimpleWorker {
|
||||
|
||||
if(!empty($subscribers['to_process'])) {
|
||||
$subscribers_to_migrate = array_slice($subscribers['to_process'], $migrated_unprocessed_count);
|
||||
foreach($subscribers_to_migrate as $sub_id) {
|
||||
foreach ($subscribers_to_migrate as $sub_id) {
|
||||
// abort if execution limit is reached
|
||||
CronHelper::enforceExecutionLimit($this->timer);
|
||||
|
||||
@ -229,7 +229,7 @@ class Migration extends SimpleWorker {
|
||||
|
||||
if(!empty($subscribers['processed'])) {
|
||||
$subscribers_to_migrate = array_slice($subscribers['processed'], $migrated_processed_count);
|
||||
foreach($subscribers_to_migrate as $sub_id) {
|
||||
foreach ($subscribers_to_migrate as $sub_id) {
|
||||
// abort if execution limit is reached
|
||||
CronHelper::enforceExecutionLimit($this->timer);
|
||||
|
||||
|
@ -27,7 +27,7 @@ class SendingErrorHandler {
|
||||
}
|
||||
|
||||
private function processSoftError(MailerError $error, SendingTask $sending_task, $prepared_subscribers_ids, $prepared_subscribers) {
|
||||
foreach($error->getSubscriberErrors() as $subscriber_error) {
|
||||
foreach ($error->getSubscriberErrors() as $subscriber_error) {
|
||||
$subscriber_id_index = array_search($subscriber_error->getEmail(), $prepared_subscribers);
|
||||
$message = $subscriber_error->getMessage() ?: $error->getMessage();
|
||||
$sending_task->saveSubscriberError($prepared_subscribers_ids[$subscriber_id_index], $message);
|
||||
|
@ -45,7 +45,7 @@ class SendingQueue {
|
||||
|
||||
function process() {
|
||||
$this->enforceSendingAndExecutionLimits();
|
||||
foreach(self::getRunningQueues() as $queue) {
|
||||
foreach (self::getRunningQueues() as $queue) {
|
||||
if(!$queue instanceof SendingTask) continue;
|
||||
ScheduledTaskModel::touchAllByIds(array($queue->task_id));
|
||||
|
||||
@ -71,7 +71,7 @@ class SendingQueue {
|
||||
$newsletter_segments_ids = $this->newsletter_task->getNewsletterSegments($newsletter);
|
||||
// get subscribers
|
||||
$subscriber_batches = new BatchIterator($queue->task_id, $this->batch_size);
|
||||
foreach($subscriber_batches as $subscribers_to_process_ids) {
|
||||
foreach ($subscriber_batches as $subscribers_to_process_ids) {
|
||||
if(!empty($newsletter_segments_ids[0])) {
|
||||
// Check that subscribers are in segments
|
||||
$finder = new SubscribersFinder();
|
||||
@ -120,7 +120,7 @@ class SendingQueue {
|
||||
$prepared_subscribers_ids = array();
|
||||
$unsubscribe_urls = array();
|
||||
$statistics = array();
|
||||
foreach($subscribers as $subscriber) {
|
||||
foreach ($subscribers as $subscriber) {
|
||||
// render shortcodes and replace subscriber data in tracked links
|
||||
$prepared_newsletters[] =
|
||||
$this->newsletter_task->prepareNewsletterForSending(
|
||||
|
@ -20,7 +20,7 @@ class Posts {
|
||||
return false;
|
||||
}
|
||||
$newsletter_id = $newsletter->parent_id; // parent post notification
|
||||
foreach($matched_posts_ids as $post_id) {
|
||||
foreach ($matched_posts_ids as $post_id) {
|
||||
$newsletter_post = NewsletterPost::create();
|
||||
$newsletter_post->newsletter_id = $newsletter_id;
|
||||
$newsletter_post->post_id = $post_id;
|
||||
|
@ -47,10 +47,10 @@ abstract class SimpleWorker {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach($scheduled_tasks as $i => $task) {
|
||||
foreach ($scheduled_tasks as $i => $task) {
|
||||
$this->prepareTask($task);
|
||||
}
|
||||
foreach($running_tasks as $i => $task) {
|
||||
foreach ($running_tasks as $i => $task) {
|
||||
$this->processTask($task);
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ class Worker {
|
||||
function process() {
|
||||
$settings = $this->settings->get(self::SETTINGS_KEY);
|
||||
$this->mailer->sender = $this->mailer->getSenderNameAndAddress($this->constructSenderEmail());
|
||||
foreach(self::getDueTasks() as $task) {
|
||||
foreach (self::getDueTasks() as $task) {
|
||||
try {
|
||||
$this->mailer->send($this->constructNewsletter($task), $settings['address']);
|
||||
} catch(\Exception $e) {
|
||||
|
@ -54,7 +54,7 @@ abstract class Base {
|
||||
|
||||
if(!empty($rules)) {
|
||||
$rules = array_unique($rules);
|
||||
foreach($rules as $rule => $value) {
|
||||
foreach ($rules as $rule => $value) {
|
||||
if(is_bool($value)) {
|
||||
$value = ($value) ? 'true' : 'false';
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class Checkbox extends Base {
|
||||
|
||||
$selected_value = self::getFieldValue($block);
|
||||
|
||||
foreach($options as $option) {
|
||||
foreach ($options as $option) {
|
||||
$html .= '<label class="mailpoet_checkbox_label">';
|
||||
$html .= '<input type="checkbox" class="mailpoet_checkbox" ';
|
||||
|
||||
@ -51,4 +51,4 @@ class Checkbox extends Base {
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class Date extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
foreach($date_selectors as $date_selector) {
|
||||
foreach ($date_selectors as $date_selector) {
|
||||
if($date_selector === 'DD') {
|
||||
$block['selected'] = $day;
|
||||
$html .= '<select class="mailpoet_date_day" ';
|
||||
|
@ -22,7 +22,7 @@ class Radio extends Base {
|
||||
|
||||
$selected_value = self::getFieldValue($block);
|
||||
|
||||
foreach($options as $option) {
|
||||
foreach ($options as $option) {
|
||||
$html .= '<label class="mailpoet_radio_label">';
|
||||
|
||||
$html .= '<input type="radio" class="mailpoet_radio" ';
|
||||
@ -58,4 +58,4 @@ class Radio extends Base {
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class Segment extends Base {
|
||||
: array()
|
||||
);
|
||||
|
||||
foreach($options as $option) {
|
||||
foreach ($options as $option) {
|
||||
if(!isset($option['id']) || !isset($option['name'])) continue;
|
||||
|
||||
$is_checked = (isset($option['is_checked']) && $option['is_checked']) ? 'checked="checked"' : '';
|
||||
@ -40,4 +40,4 @@ class Segment extends Base {
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class Select extends Base {
|
||||
: array()
|
||||
);
|
||||
|
||||
foreach($options as $option) {
|
||||
foreach ($options as $option) {
|
||||
if(!empty($option['is_hidden'])) {
|
||||
continue;
|
||||
}
|
||||
@ -59,4 +59,4 @@ class Select extends Base {
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class Renderer {
|
||||
$html = ($honeypot_enabled) ?
|
||||
'<label class="mailpoet_hp_email_label">' . __('Please leave this field empty', 'mailpoet') . '<input type="email" name="data[email]"></label>' :
|
||||
'';
|
||||
foreach($blocks as $key => $block) {
|
||||
foreach ($blocks as $key => $block) {
|
||||
if($block['type'] == 'submit' && $settings->get('re_captcha.enabled')) {
|
||||
$site_key = $settings->get('re_captcha.site_token');
|
||||
$html .= '<div class="mailpoet_recaptcha" data-sitekey="'. $site_key .'">
|
||||
@ -70,7 +70,7 @@ class Renderer {
|
||||
}
|
||||
$html .= static::renderBlock($block) . PHP_EOL;
|
||||
}
|
||||
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class FieldNameObfuscator {
|
||||
|
||||
public function deobfuscateFormPayload($data) {
|
||||
$result = array();
|
||||
foreach($data as $key => $value) {
|
||||
foreach ($data as $key => $value) {
|
||||
$result[$this->deobfuscateField($key)] = $value;
|
||||
}
|
||||
return $result;
|
||||
@ -35,4 +35,4 @@ class FieldNameObfuscator {
|
||||
return strpos($name, FieldNameObfuscator::OBFUSCATED_FIELD_PREFIX) === 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ EOL;
|
||||
$styles = new CSSParser($this->stylesheet);
|
||||
$styles = $styles->parse();
|
||||
$formatted_styles = array();
|
||||
foreach($styles->getAllDeclarationBlocks() as $style_declaration) {
|
||||
foreach ($styles->getAllDeclarationBlocks() as $style_declaration) {
|
||||
$selectors = array_map(function($selector) use ($prefix) {
|
||||
return sprintf('%s %s', $prefix, $selector->__toString());
|
||||
}, $style_declaration->getSelectors());
|
||||
|
@ -213,7 +213,7 @@ EOL;
|
||||
<p>
|
||||
<select class="widefat" id="<?php echo $this->get_field_id('form') ?>" name="<?php echo $this->get_field_name('form'); ?>">
|
||||
<?php
|
||||
foreach($forms as $form) {
|
||||
foreach ($forms as $form) {
|
||||
$is_selected = ($selected_form === (int)$form['id']) ? 'selected="selected"' : '';
|
||||
?>
|
||||
<option value="<?php echo (int)$form['id']; ?>" <?php echo $is_selected; ?>><?php echo esc_html($form['name']); ?></option>
|
||||
|
@ -67,7 +67,7 @@ class MailPoetMapper {
|
||||
|
||||
private function getSubscribersErrors($result_parsed, $subscribers) {
|
||||
$errors = [];
|
||||
foreach($result_parsed as $result_error) {
|
||||
foreach ($result_parsed as $result_error) {
|
||||
if(!is_array($result_error) || !isset($result_error['index']) || !isset($subscribers[$result_error['index']])) {
|
||||
throw new InvalidArgumentException( __('Invalid MSS response format.', 'mailpoet'));
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class Form extends Model {
|
||||
$skipped_types = array('html', 'divider', 'submit');
|
||||
$fields = array();
|
||||
|
||||
foreach((array)$body as $field) {
|
||||
foreach ((array)$body as $field) {
|
||||
if(empty($field['id'])
|
||||
|| empty($field['type'])
|
||||
|| in_array($field['type'], $skipped_types)
|
||||
|
@ -141,7 +141,7 @@ class Model extends \Sudzy\ValidModel {
|
||||
|
||||
if(!empty($keys)) {
|
||||
$first = true;
|
||||
foreach($keys as $field => $value) {
|
||||
foreach ($keys as $field => $value) {
|
||||
if($first) {
|
||||
$model = static::where($field, $value);
|
||||
$first = false;
|
||||
@ -337,7 +337,7 @@ class Model extends \Sudzy\ValidModel {
|
||||
|
||||
public function validate() {
|
||||
$success = true;
|
||||
foreach(array_keys($this->_validations) as $field) {
|
||||
foreach (array_keys($this->_validations) as $field) {
|
||||
$success = $success && $this->validateField($field, $this->$field);
|
||||
}
|
||||
$this->setError($this->getValidationErrors());
|
||||
|
@ -23,7 +23,7 @@ class ModelValidator extends \Sudzy\Engine {
|
||||
|
||||
private function setupValidators() {
|
||||
$_this = $this;
|
||||
foreach($this->validators as $validator => $action) {
|
||||
foreach ($this->validators as $validator => $action) {
|
||||
$this->addValidator($validator, function($params) use ($action, $_this) {
|
||||
return call_user_func(array($_this, $action), $params);
|
||||
});
|
||||
@ -44,4 +44,4 @@ class ModelValidator extends \Sudzy\Engine {
|
||||
}
|
||||
return (is_null($newsletter_body) || (is_array($newsletter_body) && !empty($newsletter_body['html']) && !empty($newsletter_body['text'])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ class Newsletter extends Model {
|
||||
$segments = $this->segments()->findMany();
|
||||
|
||||
if(!empty($segments)) {
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
$relation = NewsletterSegment::create();
|
||||
$relation->segment_id = $segment->id;
|
||||
$relation->newsletter_id = $duplicate->id;
|
||||
@ -404,7 +404,7 @@ class Newsletter extends Model {
|
||||
->findMany();
|
||||
|
||||
if(!empty($options)) {
|
||||
foreach($options as $option) {
|
||||
foreach ($options as $option) {
|
||||
$relation = NewsletterOption::create();
|
||||
$relation->newsletter_id = $duplicate->id;
|
||||
$relation->option_field_id = $option->option_field_id;
|
||||
@ -450,7 +450,7 @@ class Newsletter extends Model {
|
||||
$segments = $this->segments()->findMany();
|
||||
|
||||
if(!empty($segments)) {
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
$relation = NewsletterSegment::create();
|
||||
$relation->segment_id = $segment->id;
|
||||
$relation->newsletter_id = $notification_history->id;
|
||||
@ -486,7 +486,7 @@ class Newsletter extends Model {
|
||||
->whereNotIn('segment_id', $segment_ids)->findArray();
|
||||
$deleted_segments = array();
|
||||
|
||||
foreach($links as $link) {
|
||||
foreach ($links as $link) {
|
||||
$deleted_segments[] = array(
|
||||
'id' => $link['segment_id'],
|
||||
'name' => __('Deleted list', 'mailpoet')
|
||||
@ -565,7 +565,7 @@ class Newsletter extends Model {
|
||||
);
|
||||
$result = array();
|
||||
|
||||
foreach($statisticsExprs as $name => $statisticsExpr) {
|
||||
foreach ($statisticsExprs as $name => $statisticsExpr) {
|
||||
if(!in_array($this->type, array(self::TYPE_WELCOME, self::TYPE_AUTOMATIC))) {
|
||||
$row = $statisticsExpr->whereRaw('`queue_id` = ?', array($this->queue['id']))->findOne();
|
||||
} else {
|
||||
@ -664,7 +664,7 @@ class Newsletter extends Model {
|
||||
'value' => ''
|
||||
);
|
||||
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
$newsletters = $segment->newsletters()
|
||||
->filter('filterType', $type, $group)
|
||||
->filter('groupBy', $data);
|
||||
@ -689,7 +689,7 @@ class Newsletter extends Model {
|
||||
static function filterBy($orm, $data = array()) {
|
||||
// apply filters
|
||||
if(!empty($data['filter'])) {
|
||||
foreach($data['filter'] as $key => $value) {
|
||||
foreach ($data['filter'] as $key => $value) {
|
||||
if($key === 'segment') {
|
||||
$segment = Segment::findOne($value);
|
||||
if($segment !== false) {
|
||||
@ -720,7 +720,7 @@ class Newsletter extends Model {
|
||||
static function filterWithOptions($orm, $type) {
|
||||
$orm = $orm->select(MP_NEWSLETTERS_TABLE.'.*');
|
||||
$optionFields = NewsletterOptionField::findArray();
|
||||
foreach($optionFields as $optionField) {
|
||||
foreach ($optionFields as $optionField) {
|
||||
if($optionField['newsletter_type'] !== $type) {
|
||||
continue;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class ScheduledTaskSubscriber extends Model {
|
||||
* For large batches use MailPoet\Segments\SubscribersFinder::addSubscribersToTaskFromSegments()
|
||||
*/
|
||||
static function addSubscribers($task_id, array $subscriber_ids) {
|
||||
foreach($subscriber_ids as $subscriber_id) {
|
||||
foreach ($subscriber_ids as $subscriber_id) {
|
||||
self::createOrUpdate(array(
|
||||
'task_id' => $task_id,
|
||||
'subscriber_id' => $subscriber_id
|
||||
|
@ -49,7 +49,7 @@ class Segment extends Model {
|
||||
$duplicate = parent::duplicate($data);
|
||||
|
||||
if($duplicate !== false) {
|
||||
foreach($this->subscribers()->findResultSet() as $relation) {
|
||||
foreach ($this->subscribers()->findResultSet() as $relation) {
|
||||
$new_relation = SubscriberSegment::create();
|
||||
$new_relation->set('subscriber_id', $relation->id);
|
||||
$new_relation->set('segment_id', $duplicate->id);
|
||||
@ -280,7 +280,7 @@ class Segment extends Model {
|
||||
->groupBy('type')
|
||||
->findArray();
|
||||
$result = array();
|
||||
foreach($analytics as $segment) {
|
||||
foreach ($analytics as $segment) {
|
||||
$result[$segment['type']] = $segment['count'];
|
||||
}
|
||||
return $result;
|
||||
|
@ -25,7 +25,7 @@ class SendingQueue extends Model {
|
||||
const PRIORITY_LOW = 10;
|
||||
|
||||
private $emoji;
|
||||
|
||||
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
@ -109,7 +109,7 @@ class SendingQueue extends Model {
|
||||
|
||||
function encodeEmojisInBody($newsletter_rendered_body) {
|
||||
if(is_array($newsletter_rendered_body)) {
|
||||
foreach($newsletter_rendered_body as $key => $value) {
|
||||
foreach ($newsletter_rendered_body as $key => $value) {
|
||||
$newsletter_rendered_body[$key] = $this->emoji->encodeForUTF8Column(
|
||||
self::$_table,
|
||||
'newsletter_rendered_body',
|
||||
@ -122,7 +122,7 @@ class SendingQueue extends Model {
|
||||
|
||||
function decodeEmojisInBody($newsletter_rendered_body) {
|
||||
if(is_array($newsletter_rendered_body)) {
|
||||
foreach($newsletter_rendered_body as $key => $value) {
|
||||
foreach ($newsletter_rendered_body as $key => $value) {
|
||||
$newsletter_rendered_body[$key] = $this->emoji->decodeEntities($value);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class Setting extends Model {
|
||||
$settingsCollection = self::findMany();
|
||||
$settings = array();
|
||||
if(!empty($settingsCollection)) {
|
||||
foreach($settingsCollection as $setting) {
|
||||
foreach ($settingsCollection as $setting) {
|
||||
$value = (is_serialized($setting->value)
|
||||
? unserialize($setting->value)
|
||||
: $setting->value
|
||||
|
@ -8,7 +8,7 @@ class StatisticsNewsletters extends Model {
|
||||
|
||||
static function createMultiple(array $data) {
|
||||
$values = array();
|
||||
foreach($data as $value) {
|
||||
foreach ($data as $value) {
|
||||
if(!empty($value['newsletter_id']) &&
|
||||
!empty($value['subscriber_id']) &&
|
||||
!empty($value['queue_id'])
|
||||
|
@ -242,7 +242,7 @@ class Subscriber extends Model {
|
||||
'value' => 'none'
|
||||
);
|
||||
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
$subscribers_count = $segment->subscribers()
|
||||
->filter('groupBy', $group)
|
||||
->count();
|
||||
@ -270,7 +270,7 @@ class Subscriber extends Model {
|
||||
if(empty($filters)) {
|
||||
return $orm;
|
||||
}
|
||||
foreach($filters as $key => $value) {
|
||||
foreach ($filters as $key => $value) {
|
||||
if($key === 'segment') {
|
||||
if($value === 'none') {
|
||||
return self::filter('withoutSegments');
|
||||
@ -333,7 +333,7 @@ class Subscriber extends Model {
|
||||
static function filterWithCustomFields($orm) {
|
||||
$orm = $orm->select(MP_SUBSCRIBERS_TABLE.'.*');
|
||||
$customFields = CustomField::findArray();
|
||||
foreach($customFields as $customField) {
|
||||
foreach ($customFields as $customField) {
|
||||
$orm = $orm->select_expr(
|
||||
'IFNULL(GROUP_CONCAT(CASE WHEN ' .
|
||||
MP_CUSTOM_FIELDS_TABLE . '.id=' . $customField['id'] . ' THEN ' .
|
||||
@ -363,7 +363,7 @@ class Subscriber extends Model {
|
||||
static function filterWithCustomFieldsForExport($orm) {
|
||||
$orm = $orm->select(MP_SUBSCRIBERS_TABLE.'.*');
|
||||
$customFields = CustomField::findArray();
|
||||
foreach($customFields as $customField) {
|
||||
foreach ($customFields as $customField) {
|
||||
$orm = $orm->selectExpr(
|
||||
'MAX(CASE WHEN ' .
|
||||
MP_CUSTOM_FIELDS_TABLE . '.id=' . $customField['id'] . ' THEN ' .
|
||||
@ -493,7 +493,7 @@ class Subscriber extends Model {
|
||||
->whereIn('custom_field_id', $custom_field_ids)
|
||||
->where('subscriber_id', $this->id())
|
||||
->findMany();
|
||||
foreach($relations as $relation) {
|
||||
foreach ($relations as $relation) {
|
||||
$this->{'cf_'.$relation->custom_field_id} = $relation->value;
|
||||
}
|
||||
|
||||
@ -531,7 +531,7 @@ class Subscriber extends Model {
|
||||
// get custom fields
|
||||
$custom_fields = CustomField::whereIdIn($custom_field_ids)->findMany();
|
||||
|
||||
foreach($custom_fields as $custom_field) {
|
||||
foreach ($custom_fields as $custom_field) {
|
||||
$value = (isset($custom_fields_data[$custom_field->id])
|
||||
? $custom_fields_data[$custom_field->id]
|
||||
: null
|
||||
@ -646,7 +646,7 @@ class Subscriber extends Model {
|
||||
$emails_sent = 0;
|
||||
if(!empty($subscribers)) {
|
||||
$sender = new ConfirmationEmailMailer();
|
||||
foreach($subscribers as $subscriber) {
|
||||
foreach ($subscribers as $subscriber) {
|
||||
if($sender->sendConfirmationEmail($subscriber)) {
|
||||
$emails_sent++;
|
||||
}
|
||||
@ -830,7 +830,7 @@ class Subscriber extends Model {
|
||||
'last_name' => '',
|
||||
'status' => (!$settings->get('signup_confirmation.enabled')) ? self::STATUS_SUBSCRIBED : self::STATUS_UNCONFIRMED
|
||||
);
|
||||
foreach($required_field_default_values as $field => $value) {
|
||||
foreach ($required_field_default_values as $field => $value) {
|
||||
if(!isset($data[$field])) {
|
||||
$data[$field] = $value;
|
||||
}
|
||||
@ -840,7 +840,7 @@ class Subscriber extends Model {
|
||||
|
||||
static function extractCustomFieldsFromFromObject($data) {
|
||||
$custom_fields = array();
|
||||
foreach($data as $key => $value) {
|
||||
foreach ($data as $key => $value) {
|
||||
if(strpos($key, 'cf_') === 0) {
|
||||
$custom_fields[(int)substr($key, 3)] = $value;
|
||||
unset($data[$key]);
|
||||
|
@ -23,7 +23,7 @@ class SubscriberSegment extends Model {
|
||||
|
||||
if(!empty($segment_ids)) {
|
||||
// unsubscribe from segments
|
||||
foreach($segment_ids as $segment_id) {
|
||||
foreach ($segment_ids as $segment_id) {
|
||||
|
||||
// do not remove subscriptions to the WP Users or WooCommerce Customers segments
|
||||
if(($wp_segment !== false && (int)$wp_segment->id === (int)$segment_id)
|
||||
@ -75,7 +75,7 @@ class SubscriberSegment extends Model {
|
||||
if($subscriber === false) return false;
|
||||
if(!empty($segment_ids)) {
|
||||
// subscribe to specified segments
|
||||
foreach($segment_ids as $segment_id) {
|
||||
foreach ($segment_ids as $segment_id) {
|
||||
if((int)$segment_id > 0) {
|
||||
self::createOrUpdate(array(
|
||||
'subscriber_id' => $subscriber->id,
|
||||
@ -104,8 +104,8 @@ class SubscriberSegment extends Model {
|
||||
// create many subscriptions to each segment
|
||||
$values = array();
|
||||
$row_count = 0;
|
||||
foreach($segment_ids as &$segment_id) {
|
||||
foreach($subscriber_ids as &$subscriber_id) {
|
||||
foreach ($segment_ids as &$segment_id) {
|
||||
foreach ($subscriber_ids as &$subscriber_id) {
|
||||
$values[] = (int)$subscriber_id;
|
||||
$values[] = (int)$segment_id;
|
||||
$row_count++;
|
||||
|
@ -97,7 +97,7 @@ class AutomatedLatestContent {
|
||||
if(isset($args['terms']) && is_array($args['terms'])) {
|
||||
$taxonomies = array();
|
||||
// Categorize terms based on their taxonomies
|
||||
foreach($args['terms'] as $term) {
|
||||
foreach ($args['terms'] as $term) {
|
||||
$taxonomy = $term['taxonomy'];
|
||||
if(!isset($taxonomies[$taxonomy])) {
|
||||
$taxonomies[$taxonomy] = array();
|
||||
@ -105,7 +105,7 @@ class AutomatedLatestContent {
|
||||
$taxonomies[$taxonomy][] = $term['id'];
|
||||
}
|
||||
|
||||
foreach($taxonomies as $taxonomy => $terms) {
|
||||
foreach ($taxonomies as $taxonomy => $terms) {
|
||||
if(!empty($terms)) {
|
||||
$tax = array(
|
||||
'taxonomy' => $taxonomy,
|
||||
@ -141,7 +141,7 @@ class AutomatedLatestContent {
|
||||
|
||||
private function logPosts(array $posts) {
|
||||
$posts_to_log = [];
|
||||
foreach($posts as $post) {
|
||||
foreach ($posts as $post) {
|
||||
$posts_to_log[] = [
|
||||
'id' => $post->ID,
|
||||
'post_date' => $post->post_date,
|
||||
|
@ -7,7 +7,7 @@ class MetaInformationManager {
|
||||
|
||||
function appendMetaInformation($content, $post, $args) {
|
||||
// Append author and categories above and below contents
|
||||
foreach(array('above', 'below') as $position) {
|
||||
foreach (array('above', 'below') as $position) {
|
||||
$position_field = $position . 'Text';
|
||||
$text = array();
|
||||
|
||||
|
@ -19,7 +19,7 @@ class PostListTransformer {
|
||||
$results = array();
|
||||
$use_divider = filter_var($this->args['showDivider'], FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
foreach($posts as $index => $post) {
|
||||
foreach ($posts as $index => $post) {
|
||||
if($use_divider && $index > 0) {
|
||||
$results[] = $this->transformer->getDivider();
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class StructureTransformer {
|
||||
* elements and inserts tags as children of top ancestor
|
||||
*/
|
||||
protected function hoistImagesToRoot(DomNode $root) {
|
||||
foreach($root->query('img') as $item) {
|
||||
foreach ($root->query('img') as $item) {
|
||||
$top_ancestor = DOMUtil::findTopAncestor($item);
|
||||
$offset = $top_ancestor->index();
|
||||
|
||||
@ -105,7 +105,7 @@ class StructureTransformer {
|
||||
private function mergeNeighboringBlocks(array $structure) {
|
||||
$updated_structure = array();
|
||||
$text_accumulator = '';
|
||||
foreach($structure as $item) {
|
||||
foreach ($structure as $item) {
|
||||
if($item['type'] === 'text') {
|
||||
$text_accumulator .= $item['text'];
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class Links {
|
||||
}
|
||||
// extract HTML anchor tags
|
||||
$DOM = DomParser::parseStr($content);
|
||||
foreach($DOM->query('a') as $link) {
|
||||
foreach ($DOM->query('a') as $link) {
|
||||
if(!$link->href) continue;
|
||||
$extracted_links[] = array(
|
||||
'type' => self::LINK_TYPE_URL,
|
||||
@ -57,7 +57,7 @@ class Links {
|
||||
->whereEqual('queue_id', $queue_id)
|
||||
->findMany();
|
||||
$saved_links = array();
|
||||
foreach($links as $link) {
|
||||
foreach ($links as $link) {
|
||||
$saved_links[$link->url] = $link->asArray();
|
||||
}
|
||||
return $saved_links;
|
||||
@ -70,7 +70,7 @@ class Links {
|
||||
$link['processed_link'] = self::DATA_TAG_CLICK . '-' . $link['hash'];
|
||||
return $link;
|
||||
}, $saved_links);
|
||||
foreach($extracted_links as $extracted_link) {
|
||||
foreach ($extracted_links as $extracted_link) {
|
||||
$link = $extracted_link['link'];
|
||||
if (array_key_exists($link, $processed_links))
|
||||
continue;
|
||||
@ -92,7 +92,7 @@ class Links {
|
||||
static function replace($content, $processed_links) {
|
||||
// replace HTML anchor tags
|
||||
$DOM = DomParser::parseStr($content);
|
||||
foreach($DOM->query('a') as $link) {
|
||||
foreach ($DOM->query('a') as $link) {
|
||||
$link_to_replace = $link->href;
|
||||
$replacement_link = (!empty($processed_links[$link_to_replace]['processed_link'])) ?
|
||||
$processed_links[$link_to_replace]['processed_link'] :
|
||||
@ -102,7 +102,7 @@ class Links {
|
||||
}
|
||||
$content = $DOM->__toString();
|
||||
// replace link shortcodes and markdown links
|
||||
foreach($processed_links as $processed_link) {
|
||||
foreach ($processed_links as $processed_link) {
|
||||
$link_to_replace = $processed_link['link'];
|
||||
$replacement_link = $processed_link['processed_link'];
|
||||
if($processed_link['type'] == self::LINK_TYPE_SHORTCODE) {
|
||||
@ -129,7 +129,7 @@ class Links {
|
||||
// match data tags
|
||||
$subscriber = Subscriber::findOne($subscriber_id);
|
||||
preg_match_all(self::getLinkRegex(), $content, $matches);
|
||||
foreach($matches[1] as $index => $match) {
|
||||
foreach ($matches[1] as $index => $match) {
|
||||
$hash = null;
|
||||
if(preg_match('/-/', $match)) {
|
||||
list(, $hash) = explode('-', $match);
|
||||
@ -155,7 +155,7 @@ class Links {
|
||||
}
|
||||
|
||||
static function save(array $links, $newsletter_id, $queue_id) {
|
||||
foreach($links as $link) {
|
||||
foreach ($links as $link) {
|
||||
if (isset($link['id']))
|
||||
continue;
|
||||
if(empty($link['hash']) || empty($link['link'])) continue;
|
||||
@ -171,7 +171,7 @@ class Links {
|
||||
static function convertHashedLinksToShortcodesAndUrls($content, $queue_id, $convert_all = false) {
|
||||
preg_match_all(self::getLinkRegex(), $content, $links);
|
||||
$links = array_unique(Helpers::flattenArray($links));
|
||||
foreach($links as $link) {
|
||||
foreach ($links as $link) {
|
||||
$link_hash = explode('-', $link);
|
||||
if(!isset($link_hash[1])) continue;
|
||||
$newsletter_link = NewsletterLink::where('hash', $link_hash[1])
|
||||
|
@ -18,7 +18,7 @@ class Footer {
|
||||
$links = $DOM->query('a');
|
||||
if($links->count()) {
|
||||
$css = new CSS();
|
||||
foreach($links as $link) {
|
||||
foreach ($links as $link) {
|
||||
$element_link_styles = StylesHelper::getStyles($element['styles'], 'link');
|
||||
$link->style = $css->mergeInlineStyles($element_link_styles, $link->style);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class Header {
|
||||
$links = $DOM->query('a');
|
||||
if($links->count()) {
|
||||
$css = new CSS();
|
||||
foreach($links as $link) {
|
||||
foreach ($links as $link) {
|
||||
$element_link_styles = StylesHelper::getStyles($element['styles'], 'link');
|
||||
$link->style = $css->mergeInlineStyles($element_link_styles, $link->style);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class Renderer {
|
||||
$column_widths = ColumnsHelper::columnWidth($column_count, $columns_layout);
|
||||
$column_content = [];
|
||||
|
||||
foreach($data['blocks'] as $index => $column_blocks) {
|
||||
foreach ($data['blocks'] as $index => $column_blocks) {
|
||||
$rendered_block_element = $this->renderBlocksInColumn($column_blocks, $column_widths[$index]);
|
||||
$column_content[] = $rendered_block_element;
|
||||
}
|
||||
@ -78,7 +78,7 @@ class Renderer {
|
||||
function automatedLatestContentTransformedPosts($args) {
|
||||
$posts_to_exclude = $this->getPosts();
|
||||
$ALC_posts = $this->ALC->getPosts($args, $posts_to_exclude);
|
||||
foreach($ALC_posts as $post) {
|
||||
foreach ($ALC_posts as $post) {
|
||||
$posts_to_exclude[] = $post->ID;
|
||||
}
|
||||
$this->setPosts($posts_to_exclude);
|
||||
|
@ -5,7 +5,7 @@ class Social {
|
||||
static function render($element) {
|
||||
$icons_block = '';
|
||||
if(is_array($element['icons'])) {
|
||||
foreach($element['icons'] as $index => $icon) {
|
||||
foreach ($element['icons'] as $index => $icon) {
|
||||
if(empty($icon['image'])) {
|
||||
continue;
|
||||
}
|
||||
|
@ -30,10 +30,10 @@ class Text {
|
||||
$DOM_parser = new pQuery();
|
||||
$DOM = $DOM_parser->parseStr($html);
|
||||
$blockquotes = $DOM->query('blockquote');
|
||||
foreach($blockquotes as $blockquote) {
|
||||
foreach ($blockquotes as $blockquote) {
|
||||
$contents = array();
|
||||
$paragraphs = $blockquote->query('p, h1, h2, h3, h4', 0);
|
||||
foreach($paragraphs as $index => $paragraph) {
|
||||
foreach ($paragraphs as $index => $paragraph) {
|
||||
if(preg_match('/h\d/', $paragraph->getTag())) {
|
||||
$contents[] = $paragraph->getOuterText();
|
||||
} else {
|
||||
@ -76,7 +76,7 @@ class Text {
|
||||
$DOM = $DOM_parser->parseStr($html);
|
||||
$paragraphs = $DOM->query('p');
|
||||
if(!$paragraphs->count()) return $html;
|
||||
foreach($paragraphs as $paragraph) {
|
||||
foreach ($paragraphs as $paragraph) {
|
||||
// process empty paragraphs
|
||||
if(!trim($paragraph->html())) {
|
||||
$next_element = ($paragraph->getNextSibling()) ?
|
||||
@ -140,7 +140,7 @@ class Text {
|
||||
$DOM = $DOM_parser->parseStr($html);
|
||||
$lists = $DOM->query('ol, ul, li');
|
||||
if(!$lists->count()) return $html;
|
||||
foreach($lists as $list) {
|
||||
foreach ($lists as $list) {
|
||||
if($list->tag === 'li') {
|
||||
$list->setInnertext($list->html());
|
||||
$list->class = 'mailpoet_paragraph';
|
||||
@ -159,7 +159,7 @@ class Text {
|
||||
$DOM = $DOM_parser->parseStr($html);
|
||||
$headings = $DOM->query('h1, h2, h3, h4');
|
||||
if(!$headings->count()) return $html;
|
||||
foreach($headings as $heading) {
|
||||
foreach ($headings as $heading) {
|
||||
$heading->style = StylesHelper::applyTextAlignment($heading->style);
|
||||
$heading->style .= 'padding:0;font-style:normal;font-weight:normal;';
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class Renderer {
|
||||
$alignment = ColumnsHelper::columnAlignment($columns_count);
|
||||
$index = 0;
|
||||
$result = $this->getMultipleColumnsContainerStart($class, $content_block['styles']['block'], isset($content_block['image'])?$content_block['image']:null);
|
||||
foreach($columns_data as $content) {
|
||||
foreach ($columns_data as $content) {
|
||||
$result .= $this->getMultipleColumnsContentStart($widths[$index++], $alignment, $class);
|
||||
$result .= $content;
|
||||
$result .= $this->getMultipleColumnsContentEnd();
|
||||
|
@ -80,7 +80,7 @@ class Renderer {
|
||||
$content_blocks = (array_key_exists('blocks', $content))
|
||||
? $content['blocks']
|
||||
: array();
|
||||
foreach($content_blocks as $block) {
|
||||
foreach ($content_blocks as $block) {
|
||||
if($block['type'] === 'automatedLatestContentLayout') {
|
||||
$blocks = array_merge(
|
||||
$blocks,
|
||||
@ -115,7 +115,7 @@ class Renderer {
|
||||
|
||||
function renderStyles($styles) {
|
||||
$css = '';
|
||||
foreach($styles as $selector => $style) {
|
||||
foreach ($styles as $selector => $style) {
|
||||
switch($selector) {
|
||||
case 'text':
|
||||
$selector = 'td.mailpoet_paragraph, td.mailpoet_blockquote, li.mailpoet_paragraph';
|
||||
@ -153,7 +153,7 @@ class Renderer {
|
||||
function postProcessTemplate($template) {
|
||||
$DOM = $this->DOM_parser->parseStr($template);
|
||||
// replace spaces in image tag URLs
|
||||
foreach($DOM->query('img') as $image) {
|
||||
foreach ($DOM->query('img') as $image) {
|
||||
$image->src = str_replace(' ', '%20', $image->src);
|
||||
}
|
||||
$template = $DOM->query('.mailpoet_template');
|
||||
|
@ -88,7 +88,7 @@ class StylesHelper {
|
||||
$css = $selector . '{' . PHP_EOL;
|
||||
$style = self::applyHeadingMargin($style, $selector);
|
||||
$style = self::applyLineHeight($style, $selector);
|
||||
foreach($style as $attribute => $individual_style) {
|
||||
foreach ($style as $attribute => $individual_style) {
|
||||
$individual_style = self::applyFontFamily($attribute, $individual_style);
|
||||
$css .= self::translateCSSAttribute($attribute) . ':' . $individual_style . ';' . PHP_EOL;
|
||||
}
|
||||
@ -135,7 +135,7 @@ class StylesHelper {
|
||||
|
||||
private static function getCustomFontsNames($styles) {
|
||||
$font_names = [];
|
||||
foreach($styles as $style) {
|
||||
foreach ($styles as $style) {
|
||||
if(isset($style['fontFamily']) && in_array($style['fontFamily'], self::$custom_fonts)) {
|
||||
$font_names[$style['fontFamily']] = true;
|
||||
}
|
||||
@ -145,7 +145,7 @@ class StylesHelper {
|
||||
|
||||
static function getCustomFontsLinks($styles) {
|
||||
$links = [];
|
||||
foreach(self::getCustomFontsNames($styles) as $name) {
|
||||
foreach (self::getCustomFontsNames($styles) as $name) {
|
||||
$links[] = urlencode($name) . ':400,400i,700,700i';
|
||||
}
|
||||
if(!count($links)) {
|
||||
|
@ -48,7 +48,7 @@ class Scheduler {
|
||||
);
|
||||
$newsletters = self::getNewsletters(Newsletter::TYPE_NOTIFICATION);
|
||||
if(!count($newsletters)) return false;
|
||||
foreach($newsletters as $newsletter) {
|
||||
foreach ($newsletters as $newsletter) {
|
||||
$post = NewsletterPost::where('newsletter_id', $newsletter->id)
|
||||
->where('post_id', $post_id)
|
||||
->findOne();
|
||||
@ -62,7 +62,7 @@ class Scheduler {
|
||||
$newsletters = self::getNewsletters(Newsletter::TYPE_WELCOME);
|
||||
if(empty($newsletters)) return false;
|
||||
$result = array();
|
||||
foreach($newsletters as $newsletter) {
|
||||
foreach ($newsletters as $newsletter) {
|
||||
if($newsletter->event === 'segment' &&
|
||||
in_array($newsletter->segment, $segments)
|
||||
) {
|
||||
@ -75,7 +75,7 @@ class Scheduler {
|
||||
static function scheduleAutomaticEmail($group, $event, $scheduling_condition = false, $subscriber_id = false, $meta = false) {
|
||||
$newsletters = self::getNewsletters(Newsletter::TYPE_AUTOMATIC, $group);
|
||||
if(empty($newsletters)) return false;
|
||||
foreach($newsletters as $newsletter) {
|
||||
foreach ($newsletters as $newsletter) {
|
||||
if($newsletter->event !== $event) continue;
|
||||
if(is_callable($scheduling_condition) && !$scheduling_condition($newsletter)) continue;
|
||||
self::createAutomaticEmailSendingTask($newsletter, $subscriber_id, $meta);
|
||||
@ -89,7 +89,7 @@ class Scheduler {
|
||||
) {
|
||||
$newsletters = self::getNewsletters(Newsletter::TYPE_WELCOME);
|
||||
if(empty($newsletters)) return false;
|
||||
foreach($newsletters as $newsletter) {
|
||||
foreach ($newsletters as $newsletter) {
|
||||
if($newsletter->event === 'user') {
|
||||
if(!empty($old_user_data['roles'])) {
|
||||
// do not schedule welcome newsletter if roles have not changed
|
||||
|
@ -45,7 +45,7 @@ class BulkAction {
|
||||
return $bulk_action->apply('\MailPoet\Models\Subscriber', $this->data);
|
||||
} else {
|
||||
$handlers = $this->wp->applyFilters('mailpoet_subscribers_in_segment_apply_bulk_action_handlers', array());
|
||||
foreach($handlers as $handler) {
|
||||
foreach ($handlers as $handler) {
|
||||
$meta = $handler->apply($segment, $this->data);
|
||||
if($meta) {
|
||||
return $meta;
|
||||
|
@ -19,7 +19,7 @@ class SubscribersFinder {
|
||||
|
||||
function findSubscribersInSegments($subscribers_to_process_ids, $newsletter_segments_ids) {
|
||||
$result = array();
|
||||
foreach($newsletter_segments_ids as $segment_id) {
|
||||
foreach ($newsletter_segments_ids as $segment_id) {
|
||||
$segment = Segment::findOne($segment_id);
|
||||
$result = array_merge($result, $this->findSubscribersInSegment($segment, $subscribers_to_process_ids));
|
||||
}
|
||||
@ -32,7 +32,7 @@ class SubscribersFinder {
|
||||
return Subscriber::extractSubscribersIds($subscribers);
|
||||
}
|
||||
$finders = $this->wp->applyFilters('mailpoet_get_subscribers_in_segment_finders', array());
|
||||
foreach($finders as $finder) {
|
||||
foreach ($finders as $finder) {
|
||||
$subscribers = $finder->findSubscribersInSegment($segment, $subscribers_to_process_ids);
|
||||
if($subscribers) {
|
||||
return Subscriber::extractSubscribersIds($subscribers);
|
||||
@ -49,7 +49,7 @@ class SubscribersFinder {
|
||||
// Prepare subscribers on the DB side for performance reasons
|
||||
$staticSegments = array();
|
||||
$dynamicSegments = array();
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
if($this->isStaticSegment($segment)) {
|
||||
$staticSegments[] = $segment;
|
||||
} else {
|
||||
@ -92,7 +92,7 @@ class SubscribersFinder {
|
||||
|
||||
private function addSubscribersToTaskFromDynamicSegments(ScheduledTask $task, array $segments) {
|
||||
$count = 0;
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
$count += $this->addSubscribersToTaskFromDynamicSegment($task, $segment);
|
||||
}
|
||||
return $count;
|
||||
@ -101,7 +101,7 @@ class SubscribersFinder {
|
||||
private function addSubscribersToTaskFromDynamicSegment(ScheduledTask $task, Segment $segment) {
|
||||
$finders = $this->wp->applyFilters('mailpoet_get_subscribers_in_segment_finders', array());
|
||||
$count = 0;
|
||||
foreach($finders as $finder) {
|
||||
foreach ($finders as $finder) {
|
||||
$subscribers = $finder->getSubscriberIdsInSegment($segment);
|
||||
if($subscribers) {
|
||||
$count += $this->addSubscribersToTaskByIds($task, $subscribers);
|
||||
@ -131,7 +131,7 @@ class SubscribersFinder {
|
||||
|
||||
private function unique($subscribers) {
|
||||
$result = array();
|
||||
foreach($subscribers as $subscriber) {
|
||||
foreach ($subscribers as $subscriber) {
|
||||
if(is_a($subscriber, 'MailPoet\Models\Model')) {
|
||||
$result[$subscriber->id] = $subscriber;
|
||||
} elseif(is_scalar($subscriber)) {
|
||||
|
@ -34,7 +34,7 @@ class SubscribersListings {
|
||||
return $listing_data = $this->handler->get('\MailPoet\Models\Subscriber', $data);
|
||||
}
|
||||
$handlers = $this->wp->applyFilters('mailpoet_get_subscribers_listings_in_segment_handlers', array());
|
||||
foreach($handlers as $handler) {
|
||||
foreach ($handlers as $handler) {
|
||||
$listings = $handler->get($segment, $data);
|
||||
if($listings) {
|
||||
return $listings;
|
||||
|
@ -54,7 +54,7 @@ class Pages {
|
||||
*/
|
||||
static function isMailpoetPage($id) {
|
||||
$mailpoetPages = static::getMailPoetPages();
|
||||
foreach($mailpoetPages as $mailpoetPage) {
|
||||
foreach ($mailpoetPages as $mailpoetPage) {
|
||||
if($mailpoetPage->ID === $id) {
|
||||
return true;
|
||||
}
|
||||
@ -69,7 +69,7 @@ class Pages {
|
||||
);
|
||||
|
||||
$pages = array();
|
||||
foreach($all_pages as $page) {
|
||||
foreach ($all_pages as $page) {
|
||||
$pages[] = static::getPageData($page);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ class SettingsController {
|
||||
if($default === null) {
|
||||
$default = $this->getDefaultValue($key_parts);
|
||||
}
|
||||
foreach($key_parts as $key_part) {
|
||||
foreach ($key_parts as $key_part) {
|
||||
if(array_key_exists($key_part, $setting)) {
|
||||
$setting = $setting[$key_part];
|
||||
} else {
|
||||
@ -94,7 +94,7 @@ class SettingsController {
|
||||
$main_key = $key_parts[0];
|
||||
$last_key = array_pop($key_parts);
|
||||
$setting =& self::$settings;
|
||||
foreach($key_parts as $key_part) {
|
||||
foreach ($key_parts as $key_part) {
|
||||
$setting =& $setting[$key_part];
|
||||
if(!is_array($setting)) {
|
||||
$setting = [];
|
||||
@ -119,7 +119,7 @@ class SettingsController {
|
||||
|
||||
private function getDefaultValue($keys) {
|
||||
$default = $this->getAllDefaults();
|
||||
foreach($keys as $key) {
|
||||
foreach ($keys as $key) {
|
||||
if(array_key_exists($key, $default)) {
|
||||
$default = $default[$key];
|
||||
} else {
|
||||
|
@ -32,7 +32,7 @@ class DynamicSubscribersGetter extends SubscribersGetter {
|
||||
$segment_id = $this->segments_ids[$this->segment_index];
|
||||
|
||||
$filters = $this->wp->applyFilters(
|
||||
'mailpoet_get_segment_filters',
|
||||
'mailpoet_get_segment_filters',
|
||||
$segment_id
|
||||
);
|
||||
|
||||
@ -42,7 +42,7 @@ class DynamicSubscribersGetter extends SubscribersGetter {
|
||||
|
||||
$name = Segment::findOne($segment_id)->name;
|
||||
|
||||
foreach($filters as $filter) {
|
||||
foreach ($filters as $filter) {
|
||||
$subscribers = $filter->toSql($subscribers);
|
||||
}
|
||||
|
||||
@ -72,4 +72,4 @@ class DynamicSubscribersGetter extends SubscribersGetter {
|
||||
return $subscribers;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ class Export {
|
||||
$subscribers = $this->getSubscribers();
|
||||
while($subscribers !== false) {
|
||||
$processed_subscribers += count($subscribers);
|
||||
foreach($subscribers as $subscriber) {
|
||||
foreach ($subscribers as $subscriber) {
|
||||
$row = $this->formatSubscriberData($subscriber);
|
||||
$row[] = ucwords($subscriber['segment_name']);
|
||||
fwrite($CSV_file, implode(',', array_map($format_CSV, $row)) . "\n");
|
||||
@ -119,7 +119,7 @@ class Export {
|
||||
$subscribers = $this->getSubscribers();
|
||||
while($subscribers !== false) {
|
||||
$processed_subscribers += count($subscribers);
|
||||
foreach($subscribers as $i => $subscriber) {
|
||||
foreach ($subscribers as $i => $subscriber) {
|
||||
$current_segment = ucwords($subscriber['segment_name']);
|
||||
// Sheet header (1st row) will be written only if:
|
||||
// * This is the first time we're processing a segment
|
||||
|
@ -74,7 +74,7 @@ class Import {
|
||||
|
||||
function getSubscriberDataValidationRules($subscribers_fields) {
|
||||
$validation_rules = array();
|
||||
foreach($subscribers_fields as $column => $field) {
|
||||
foreach ($subscribers_fields as $column => $field) {
|
||||
$validation_rules[$column] = (!empty($field['validation_rule'])) ?
|
||||
$field['validation_rule'] :
|
||||
false;
|
||||
@ -153,7 +153,7 @@ class Import {
|
||||
function validateSubscribersData($subscribers_data, $validation_rules) {
|
||||
$invalid_records = array();
|
||||
$validator = new ModelValidator();
|
||||
foreach($subscribers_data as $column => &$data) {
|
||||
foreach ($subscribers_data as $column => &$data) {
|
||||
$validation_rule = $validation_rules[$column];
|
||||
if($validation_rule === 'email') {
|
||||
$data = array_map(
|
||||
@ -184,7 +184,7 @@ class Import {
|
||||
}
|
||||
}
|
||||
if($invalid_records) {
|
||||
foreach($subscribers_data as $column => &$data) {
|
||||
foreach ($subscribers_data as $column => &$data) {
|
||||
$data = array_diff_key($data, array_flip($invalid_records));
|
||||
$data = array_values($data);
|
||||
}
|
||||
@ -195,7 +195,7 @@ class Import {
|
||||
|
||||
function transformSubscribersData($subscribers, $columns) {
|
||||
$transformed_subscribers = [];
|
||||
foreach($columns as $column => $data) {
|
||||
foreach ($columns as $column => $data) {
|
||||
$transformed_subscribers[$column] = array_column($subscribers, $data['index']);
|
||||
}
|
||||
return $transformed_subscribers;
|
||||
@ -205,7 +205,7 @@ class Import {
|
||||
// $subscribers_data is an two-dimensional associative array
|
||||
// of all subscribers being imported: [field => [value1, value2], field => [value1, value2], ...]
|
||||
$temp_existing_subscribers = array();
|
||||
foreach(array_chunk($subscribers_data['email'], self::DB_QUERY_CHUNK_SIZE) as $subscribers_emails) {
|
||||
foreach (array_chunk($subscribers_data['email'], self::DB_QUERY_CHUNK_SIZE) as $subscribers_emails) {
|
||||
// create a two-dimensional indexed array of all existing subscribers
|
||||
// with just wp_user_id and email fields: [[wp_user_id, email], [wp_user_id, email], ...]
|
||||
$temp_existing_subscribers = array_merge(
|
||||
@ -230,9 +230,9 @@ class Import {
|
||||
// and reduce $subscribers_data to only new subscribers by removing existing subscribers
|
||||
$existing_subscribers = [];
|
||||
$subscribers_emails = array_flip($subscribers_data['email']);
|
||||
foreach($temp_existing_subscribers as $temp_existing_subscriber) {
|
||||
foreach ($temp_existing_subscribers as $temp_existing_subscriber) {
|
||||
$existing_subscriber_key = $subscribers_emails[$temp_existing_subscriber['email']];
|
||||
foreach($subscribers_data as $field => &$value) {
|
||||
foreach ($subscribers_data as $field => &$value) {
|
||||
$existing_subscribers[$field][] = $value[$existing_subscriber_key];
|
||||
unset($value[$existing_subscriber_key]);
|
||||
}
|
||||
@ -260,7 +260,7 @@ class Import {
|
||||
);
|
||||
if(!$existing_trashed_records) return;
|
||||
$existing_trashed_records = Helpers::flattenArray($existing_trashed_records);
|
||||
foreach(array_chunk($existing_trashed_records, self::DB_QUERY_CHUNK_SIZE) as
|
||||
foreach (array_chunk($existing_trashed_records, self::DB_QUERY_CHUNK_SIZE) as
|
||||
$subscriber_ids) {
|
||||
Subscriber::whereIn('id', $subscriber_ids)
|
||||
->deleteMany();
|
||||
@ -271,7 +271,7 @@ class Import {
|
||||
|
||||
function addMissingRequiredFields($subscribers) {
|
||||
$subscribers_count = count($subscribers['data'][key($subscribers['data'])]);
|
||||
foreach(array_keys($this->required_subscribers_fields) as $required_field) {
|
||||
foreach (array_keys($this->required_subscribers_fields) as $required_field) {
|
||||
if(in_array($required_field, $subscribers['fields'])) continue;
|
||||
$subscribers['data'][$required_field] = array_fill(
|
||||
0,
|
||||
@ -333,7 +333,7 @@ class Import {
|
||||
return $subscribers_data['data'][$field][$index];
|
||||
}, $subscribers_data['fields']);
|
||||
}, range(0, $subscribers_count - 1));
|
||||
foreach(array_chunk($subscribers, self::DB_QUERY_CHUNK_SIZE) as $data) {
|
||||
foreach (array_chunk($subscribers, self::DB_QUERY_CHUNK_SIZE) as $data) {
|
||||
if($action == 'create') {
|
||||
Subscriber::createMultiple(
|
||||
$subscribers_data['fields'],
|
||||
@ -349,7 +349,7 @@ class Import {
|
||||
}
|
||||
}
|
||||
$created_or_updated_subscribers = array();
|
||||
foreach(array_chunk($subscribers_data['data']['email'], self::DB_QUERY_CHUNK_SIZE) as $data) {
|
||||
foreach (array_chunk($subscribers_data['data']['email'], self::DB_QUERY_CHUNK_SIZE) as $data) {
|
||||
$created_or_updated_subscribers = array_merge(
|
||||
$created_or_updated_subscribers,
|
||||
Subscriber::selectMany(array('id', 'email'))->whereIn('email', $data)->findArray()
|
||||
@ -388,9 +388,9 @@ class Import {
|
||||
// assemble a two-dimensional array: [[custom_field_id, subscriber_id, value], [custom_field_id, subscriber_id, value], ...]
|
||||
$subscribers_custom_fields_data = array();
|
||||
$subscribers_emails = array_flip($subscribers_data['data']['email']);
|
||||
foreach($created_or_updated_subscribers as $created_or_updated_subscriber) {
|
||||
foreach ($created_or_updated_subscribers as $created_or_updated_subscriber) {
|
||||
$subscriber_index = $subscribers_emails[$created_or_updated_subscriber['email']];
|
||||
foreach($subscribers_data['data'] as $field => $values) {
|
||||
foreach ($subscribers_data['data'] as $field => $values) {
|
||||
// exclude non-custom fields
|
||||
if(!is_int($field)) continue;
|
||||
$subscribers_custom_fields_data[] = array(
|
||||
@ -400,7 +400,7 @@ class Import {
|
||||
);
|
||||
}
|
||||
}
|
||||
foreach(array_chunk($subscribers_custom_fields_data, self::DB_QUERY_CHUNK_SIZE) as $subscribers_custom_fields_data_chunk) {
|
||||
foreach (array_chunk($subscribers_custom_fields_data, self::DB_QUERY_CHUNK_SIZE) as $subscribers_custom_fields_data_chunk) {
|
||||
SubscriberCustomField::createMultiple(
|
||||
$subscribers_custom_fields_data_chunk
|
||||
);
|
||||
@ -417,7 +417,7 @@ class Import {
|
||||
}
|
||||
|
||||
function addSubscribersToSegments($subscribers_ids, $segments_ids) {
|
||||
foreach(array_chunk($subscribers_ids, self::DB_QUERY_CHUNK_SIZE) as $subscriber_ids_chunk) {
|
||||
foreach (array_chunk($subscribers_ids, self::DB_QUERY_CHUNK_SIZE) as $subscriber_ids_chunk) {
|
||||
SubscriberSegment::subscribeManyToSegments(
|
||||
$subscriber_ids_chunk, $segments_ids
|
||||
);
|
||||
|
@ -46,7 +46,7 @@ class MailChimp {
|
||||
}
|
||||
|
||||
$lists = [];
|
||||
foreach($response->data as $list) {
|
||||
foreach ($response->data as $list) {
|
||||
$lists[] = array(
|
||||
'id' => $list->id,
|
||||
'name' => $list->name
|
||||
@ -68,7 +68,7 @@ class MailChimp {
|
||||
$bytes_fetched = 0;
|
||||
$subscribers = [];
|
||||
$header = [];
|
||||
foreach($lists as $list) {
|
||||
foreach ($lists as $list) {
|
||||
$url = sprintf($this->export_url, $this->data_center, $this->api_key, $list);
|
||||
$connection = @fopen($url, 'r');
|
||||
if(!$connection) {
|
||||
|
@ -27,7 +27,7 @@ class NewsletterClicksExporter {
|
||||
->offset(self::LIMIT * ($page - 1))
|
||||
->findArray();
|
||||
|
||||
foreach($statistics as $row) {
|
||||
foreach ($statistics as $row) {
|
||||
$result[] = $this->exportNewsletter($row);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class NewslettersExporter {
|
||||
|
||||
$newsletters = $this->loadNewsletters($statistics);
|
||||
|
||||
foreach($statistics as $row) {
|
||||
foreach ($statistics as $row) {
|
||||
$result[] = $this->exportNewsletter($row, $newsletters, $subscriber);
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ class NewslettersExporter {
|
||||
$newsletters = Newsletter::whereIn('id', $newsletter_ids)->findMany();
|
||||
|
||||
$result = array();
|
||||
foreach($newsletters as $newsletter) {
|
||||
foreach ($newsletters as $newsletter) {
|
||||
$result[$newsletter->id()] = $newsletter;
|
||||
}
|
||||
return $result;
|
||||
|
@ -19,7 +19,7 @@ class SegmentsExporter {
|
||||
$result = array();
|
||||
$segments = $subscriber->getAllSegmentNamesWithStatus();
|
||||
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
$result[] = $this->exportSegment($segment);
|
||||
}
|
||||
|
||||
@ -49,4 +49,4 @@ class SegmentsExporter {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class SubscriberExporter {
|
||||
'value' => $subscriber->created_at,
|
||||
);
|
||||
|
||||
foreach($custom_fields as $custom_field_id => $custom_field_name) {
|
||||
foreach ($custom_fields as $custom_field_id => $custom_field_name) {
|
||||
$custom_field_value = $subscriber->{$custom_field_id};
|
||||
if($custom_field_value) {
|
||||
$result[] = array(
|
||||
@ -83,7 +83,7 @@ class SubscriberExporter {
|
||||
private function getCustomFields() {
|
||||
$fields = CustomField::findMany();
|
||||
$result = array();
|
||||
foreach($fields as $field) {
|
||||
foreach ($fields as $field) {
|
||||
$result['cf_' . $field->id] = $field->name;
|
||||
}
|
||||
return $result;
|
||||
@ -106,4 +106,4 @@ class SubscriberExporter {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ class NewSubscriberNotificationMailer {
|
||||
*/
|
||||
private function getSegmentNames($segments) {
|
||||
$names = [];
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
$names[] = $segment->get('name');
|
||||
}
|
||||
return implode(', ', $names);
|
||||
|
@ -13,7 +13,7 @@ class RequiredCustomFieldValidator {
|
||||
*/
|
||||
public function validate(array $data) {
|
||||
$all_custom_fields = $this->getCustomFields();
|
||||
foreach($all_custom_fields as $custom_field_id => $custom_field_name) {
|
||||
foreach ($all_custom_fields as $custom_field_id => $custom_field_name) {
|
||||
if($this->isCustomFieldMissing($custom_field_id, $data)) {
|
||||
throw new \Exception(
|
||||
__(sprintf('Missing value for custom field "%s"', $custom_field_name), 'mailpoet')
|
||||
@ -40,7 +40,7 @@ class RequiredCustomFieldValidator {
|
||||
|
||||
$required_custom_fields = CustomField::findMany();
|
||||
|
||||
foreach($required_custom_fields as $custom_field) {
|
||||
foreach ($required_custom_fields as $custom_field) {
|
||||
if(is_serialized($custom_field->params)) {
|
||||
$params = unserialize($custom_field->params);
|
||||
if(is_array($params) && isset($params['required']) && $params['required']) {
|
||||
|
@ -37,7 +37,7 @@ class SubscriberPersonalDataEraser {
|
||||
|
||||
private function eraseCustomFields($subscriber_id) {
|
||||
$custom_fields = SubscriberCustomField::where('subscriber_id', $subscriber_id)->findMany();
|
||||
foreach($custom_fields as $custom_field) {
|
||||
foreach ($custom_fields as $custom_field) {
|
||||
$custom_field->value = '';
|
||||
$custom_field->save();
|
||||
}
|
||||
@ -53,4 +53,4 @@ class SubscriberPersonalDataEraser {
|
||||
$subscriber->save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ class Pages {
|
||||
}
|
||||
$subscribed_segment_ids = array();
|
||||
if(!empty($this->subscriber->subscriptions)) {
|
||||
foreach($this->subscriber->subscriptions as $subscription) {
|
||||
foreach ($this->subscriber->subscriptions as $subscription) {
|
||||
if($subscription['status'] === Subscriber::STATUS_SUBSCRIBED) {
|
||||
$subscribed_segment_ids[] = $subscription['segment_id'];
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ class Sending {
|
||||
}
|
||||
|
||||
public function hydrate(array $data) {
|
||||
foreach($data as $k => $v) {
|
||||
foreach ($data as $k => $v) {
|
||||
$this->__set($k, $v);
|
||||
}
|
||||
}
|
||||
@ -242,7 +242,7 @@ class Sending {
|
||||
->limit($amount)
|
||||
->findMany();
|
||||
$result = array();
|
||||
foreach($tasks as $task) {
|
||||
foreach ($tasks as $task) {
|
||||
$result[] = static::createFromTask($task);
|
||||
}
|
||||
return array_filter($result);
|
||||
@ -257,7 +257,7 @@ class Sending {
|
||||
->limit($amount)
|
||||
->findMany();
|
||||
$result = array();
|
||||
foreach($tasks as $task) {
|
||||
foreach ($tasks as $task) {
|
||||
$result[] = static::createFromTask($task);
|
||||
}
|
||||
return array_filter($result);
|
||||
|
@ -26,7 +26,7 @@ class State
|
||||
WHERE deleted_at IS NULL AND `type` = 'sending'
|
||||
GROUP BY status;"
|
||||
)->findMany();
|
||||
foreach($counts as $count) {
|
||||
foreach ($counts as $count) {
|
||||
if($count->status === null) {
|
||||
$stats[ScheduledTask::VIRTUAL_STATUS_RUNNING] = (int)$count->value;
|
||||
continue;
|
||||
@ -48,7 +48,7 @@ class State
|
||||
],
|
||||
$limit = Scheduler::TASK_BATCH_SIZE) {
|
||||
$tasks = [];
|
||||
foreach($statuses as $status) {
|
||||
foreach ($statuses as $status) {
|
||||
$query = ScheduledTask::orderByDesc('created_at')
|
||||
->whereNull('deleted_at')
|
||||
->limit($limit);
|
||||
|
@ -41,7 +41,7 @@ class Assets extends \Twig_Extension {
|
||||
$stylesheets = func_get_args();
|
||||
$output = array();
|
||||
|
||||
foreach($stylesheets as $stylesheet) {
|
||||
foreach ($stylesheets as $stylesheet) {
|
||||
$output[] = sprintf(
|
||||
'<link rel="stylesheet" type="text/css" href="%s/dist/css/%s" />',
|
||||
$this->_globals['assets_url'],
|
||||
@ -56,7 +56,7 @@ class Assets extends \Twig_Extension {
|
||||
$scripts = func_get_args();
|
||||
$output = array();
|
||||
|
||||
foreach($scripts as $script) {
|
||||
foreach ($scripts as $script) {
|
||||
$output[] = sprintf(
|
||||
'<script type="text/javascript" src="%s/%s/%s"></script>',
|
||||
$this->_globals['assets_url'],
|
||||
@ -86,4 +86,4 @@ class Assets extends \Twig_Extension {
|
||||
$useCdn = defined('MAILPOET_USE_CDN') ? MAILPOET_USE_CDN : true;
|
||||
return ($useCdn ? self::CDN_URL : $this->_globals['base_url'] . '/plugin_repository/') . "assets/$path";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class I18n extends \Twig_Extension {
|
||||
'date' => 'date'
|
||||
);
|
||||
|
||||
foreach($functions as $twig_function => $function) {
|
||||
foreach ($functions as $twig_function => $function) {
|
||||
$twig_functions[] = new \Twig_SimpleFunction(
|
||||
$twig_function,
|
||||
array($this, $function),
|
||||
@ -44,7 +44,7 @@ class I18n extends \Twig_Extension {
|
||||
$output = array();
|
||||
|
||||
$output[] = '<script type="text/javascript">';
|
||||
foreach($translations as $key => $translation) {
|
||||
foreach ($translations as $key => $translation) {
|
||||
$output[] =
|
||||
'MailPoet.I18n.add("'.$key.'", "'. str_replace('"', '\"', $translation) . '");';
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ function array_column($input = null, $column_key = null, $index_key = null) {
|
||||
}
|
||||
}
|
||||
$result_array = [];
|
||||
foreach($params_input as $row) {
|
||||
foreach ($params_input as $row) {
|
||||
$key = $value = null;
|
||||
$key_set = $value_set = false;
|
||||
if($params_index_key !== null && array_key_exists($params_index_key, $row)) {
|
||||
|
@ -43,7 +43,7 @@ class CSS {
|
||||
$css_blocks = '';
|
||||
|
||||
// Find all <style> blocks and cut styles from them (leaving media queries)
|
||||
foreach($html->query('style') as $style) {
|
||||
foreach ($html->query('style') as $style) {
|
||||
list($_css_to_parse, $_css_to_keep) = $this->splitMediaQueries($style->getInnerText());
|
||||
$css_blocks .= $_css_to_parse;
|
||||
if(!empty($_css_to_keep)) {
|
||||
@ -66,7 +66,7 @@ class CSS {
|
||||
// We loop over each rule by increasing order of specificity, find the nodes matching the selector
|
||||
// and apply the CSS properties
|
||||
foreach ($rules as $rule) {
|
||||
foreach($html->query($rule['selector']) as $node) {
|
||||
foreach ($html->query($rule['selector']) as $node) {
|
||||
// I'm leaving this for debug purposes, it has proved useful.
|
||||
/*
|
||||
if($node->already_styled === 'yes')
|
||||
@ -105,11 +105,11 @@ class CSS {
|
||||
// We need to start with a rule with lowest specificity
|
||||
$rules = array_reverse($rules);
|
||||
foreach ($rules as $rule) {
|
||||
foreach($rule['properties'] as $key => $value) {
|
||||
foreach ($rule['properties'] as $key => $value) {
|
||||
if(strpos($value, '!important') === false) {
|
||||
continue;
|
||||
}
|
||||
foreach($html->query($rule['selector']) as $node) {
|
||||
foreach ($html->query($rule['selector']) as $node) {
|
||||
$style = $this->styleToArray($node->style);
|
||||
$style[$key] = $value;
|
||||
$node->style = $this->arrayToStyle($style);
|
||||
@ -131,9 +131,9 @@ class CSS {
|
||||
$rules = array();
|
||||
$position = 0;
|
||||
|
||||
foreach($css->css as $declarations) {
|
||||
foreach($declarations as $selectors => $properties) {
|
||||
foreach(explode(",", $selectors) as $selector) {
|
||||
foreach ($css->css as $declarations) {
|
||||
foreach ($declarations as $selectors => $properties) {
|
||||
foreach (explode(",", $selectors) as $selector) {
|
||||
$rules[] = array(
|
||||
'position' => $position,
|
||||
'specificity' => $this->calculateCSSSpecifity($selector),
|
||||
@ -257,7 +257,7 @@ class CSS {
|
||||
|
||||
if(trim($str) === '') return $array;
|
||||
|
||||
foreach(explode(';', $str) as $kv) {
|
||||
foreach (explode(';', $str) as $kv) {
|
||||
if($kv === '') {
|
||||
continue;
|
||||
}
|
||||
@ -275,7 +275,7 @@ class CSS {
|
||||
*/
|
||||
private function arrayToStyle($array) {
|
||||
$parts = array();
|
||||
foreach($array as $k => $v) {
|
||||
foreach ($array as $k => $v) {
|
||||
$parts[] = "$k:$v";
|
||||
}
|
||||
return implode(';', $parts);
|
||||
|
@ -63,7 +63,7 @@ class ConflictResolver {
|
||||
$dequeue_styles = function() use($_this) {
|
||||
global $wp_styles;
|
||||
if(empty($wp_styles->queue)) return;
|
||||
foreach($wp_styles->queue as $wp_style) {
|
||||
foreach ($wp_styles->queue as $wp_style) {
|
||||
if(empty($wp_styles->registered[$wp_style])) continue;
|
||||
$registered_style = $wp_styles->registered[$wp_style];
|
||||
if(!preg_match('!' . implode('|', $_this->permitted_assets_locations['styles']) . '!i', $registered_style->src)) {
|
||||
@ -83,7 +83,7 @@ class ConflictResolver {
|
||||
// unload all scripts except from the list of allowed
|
||||
$dequeue_scripts = function() use($_this) {
|
||||
global $wp_scripts;
|
||||
foreach($wp_scripts->queue as $wp_script) {
|
||||
foreach ($wp_scripts->queue as $wp_script) {
|
||||
if(empty($wp_scripts->registered[$wp_script])) continue;
|
||||
$registered_script = $wp_scripts->registered[$wp_script];
|
||||
if(!preg_match('!' . implode('|', $_this->permitted_assets_locations['scripts']) . '!i', $registered_script->src)) {
|
||||
|
@ -114,7 +114,7 @@ abstract class ValidModel extends \Model {
|
||||
*/
|
||||
public function save() {
|
||||
if($this->isNew()) { //Fields populated by create() or hydrate() don't pass through set()
|
||||
foreach(array_keys($this->_validations) as $field) {
|
||||
foreach (array_keys($this->_validations) as $field) {
|
||||
$this->validateField($field, $this->$field);
|
||||
}
|
||||
}
|
||||
@ -133,7 +133,7 @@ abstract class ValidModel extends \Model {
|
||||
public function set($key, $value = null) {
|
||||
if(is_array($key)) {
|
||||
// multiple values
|
||||
foreach($key as $field => $value) {
|
||||
foreach ($key as $field => $value) {
|
||||
$this->validateAndSet($field, $value);
|
||||
}
|
||||
} else {
|
||||
|
@ -37,7 +37,7 @@ class XLSXWriter
|
||||
public function __destruct()
|
||||
{
|
||||
if (!empty($this->temp_files)) {
|
||||
foreach($this->temp_files as $temp_file) {
|
||||
foreach ($this->temp_files as $temp_file) {
|
||||
@unlink($temp_file);
|
||||
}
|
||||
}
|
||||
@ -67,7 +67,7 @@ class XLSXWriter
|
||||
|
||||
public function writeToFile($filename)
|
||||
{
|
||||
foreach($this->sheets as $sheet_name => $sheet) {
|
||||
foreach ($this->sheets as $sheet_name => $sheet) {
|
||||
self::finalizeSheet($sheet_name);//making sure all footers have been written
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ class XLSXWriter
|
||||
$zip->addFromString("_rels/.rels", self::buildRelationshipsXML());
|
||||
|
||||
$zip->addEmptyDir("xl/worksheets/");
|
||||
foreach($this->sheets as $sheet) {
|
||||
foreach ($this->sheets as $sheet) {
|
||||
$zip->addFile($sheet->filename, "xl/worksheets/".$sheet->xmlname );
|
||||
}
|
||||
if (!empty($this->shared_strings)) {
|
||||
@ -214,7 +214,7 @@ class XLSXWriter
|
||||
{
|
||||
$this->writeSheetHeader($sheet_name, $header_types);
|
||||
}
|
||||
foreach($data as $i=>$row)
|
||||
foreach ($data as $i=>$row)
|
||||
{
|
||||
$this->writeSheetRow($sheet_name, $row);
|
||||
}
|
||||
@ -329,7 +329,7 @@ class XLSXWriter
|
||||
$file = new XLSXWriter_BuffererWriter($temporary_filename, $fd_flags='w', $check_utf8=true);
|
||||
$file->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n");
|
||||
$file->write('<sst count="'.($this->shared_string_count).'" uniqueCount="'.count($this->shared_strings).'" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">');
|
||||
foreach($this->shared_strings as $s=>$c)
|
||||
foreach ($this->shared_strings as $s=>$c)
|
||||
{
|
||||
$file->write('<si><t>'.self::xmlspecialchars($s).'</t></si>');
|
||||
}
|
||||
@ -381,7 +381,7 @@ class XLSXWriter
|
||||
$workbook_xml.='<fileVersion appName="Calc"/><workbookPr backupFile="false" showObjects="all" date1904="false"/><workbookProtection/>';
|
||||
$workbook_xml.='<bookViews><workbookView activeTab="0" firstSheet="0" showHorizontalScroll="true" showSheetTabs="true" showVerticalScroll="true" tabRatio="212" windowHeight="8192" windowWidth="16384" xWindow="0" yWindow="0"/></bookViews>';
|
||||
$workbook_xml.='<sheets>';
|
||||
foreach($this->sheets as $sheet_name=>$sheet) {
|
||||
foreach ($this->sheets as $sheet_name=>$sheet) {
|
||||
$workbook_xml.='<sheet name="'.self::xmlspecialchars($sheet->sheetname).'" sheetId="'.($i+1).'" state="visible" r:id="rId'.($i+2).'"/>';
|
||||
$i++;
|
||||
}
|
||||
@ -397,7 +397,7 @@ class XLSXWriter
|
||||
$wkbkrels_xml.='<?xml version="1.0" encoding="UTF-8"?>'."\n";
|
||||
$wkbkrels_xml.='<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">';
|
||||
$wkbkrels_xml.='<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>';
|
||||
foreach($this->sheets as $sheet_name=>$sheet) {
|
||||
foreach ($this->sheets as $sheet_name=>$sheet) {
|
||||
$wkbkrels_xml.='<Relationship Id="rId'.($i+2).'" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/'.($sheet->xmlname).'"/>';
|
||||
$i++;
|
||||
}
|
||||
@ -416,7 +416,7 @@ class XLSXWriter
|
||||
$content_types_xml.='<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
|
||||
$content_types_xml.='<Override PartName="/_rels/.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>';
|
||||
$content_types_xml.='<Override PartName="/xl/_rels/workbook.xml.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>';
|
||||
foreach($this->sheets as $sheet_name=>$sheet) {
|
||||
foreach ($this->sheets as $sheet_name=>$sheet) {
|
||||
$content_types_xml.='<Override PartName="/xl/worksheets/'.($sheet->xmlname).'" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>';
|
||||
}
|
||||
if (!empty($this->shared_strings)) {
|
||||
|
@ -30,7 +30,7 @@ class Emoji {
|
||||
$matches = array();
|
||||
if(preg_match_all($regex, $content, $matches)) {
|
||||
if(!empty($matches[1])) {
|
||||
foreach($matches[1] as $emoji) {
|
||||
foreach ($matches[1] as $emoji) {
|
||||
$entity = html_entity_decode($emoji, ENT_COMPAT, 'UTF-8');
|
||||
$content = str_replace($emoji, $entity, $content);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class Readme {
|
||||
$c = 0;
|
||||
$changelog = array();
|
||||
|
||||
foreach($entries as $entry) {
|
||||
foreach ($entries as $entry) {
|
||||
// Locate version header and changes list
|
||||
preg_match('/=(.*?)=(.*)/s', $entry, $parts);
|
||||
|
||||
|
@ -49,7 +49,7 @@ class ChangelogController {
|
||||
|
||||
private function renderList(array $issues, $field) {
|
||||
$messages = [];
|
||||
foreach($issues as $issue) {
|
||||
foreach ($issues as $issue) {
|
||||
if(!isset($issue['fields'][$field])) {
|
||||
continue;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class Jira {
|
||||
if($version_name === null) {
|
||||
return end($versions);
|
||||
}
|
||||
foreach($versions as $version) {
|
||||
foreach ($versions as $version) {
|
||||
if($version_name === $version['name']) {
|
||||
return $version;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class Form {
|
||||
*/
|
||||
public function withSegments(array $segments) {
|
||||
$ids = [];
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
$ids[] = $segment->id();
|
||||
}
|
||||
$this->data['settings']['segments'] = $ids;
|
||||
|
@ -166,7 +166,7 @@ class Newsletter {
|
||||
* @return Newsletter
|
||||
*/
|
||||
public function withSegments(array $segments) {
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
$this->segments[] = $segment->id();
|
||||
}
|
||||
return $this;
|
||||
@ -187,7 +187,7 @@ class Newsletter {
|
||||
*/
|
||||
public function create() {
|
||||
$newsletter = \MailPoet\Models\Newsletter::createOrUpdate($this->data);
|
||||
foreach($this->options as $option_id => $option_value) {
|
||||
foreach ($this->options as $option_id => $option_value) {
|
||||
\MailPoet\Models\NewsletterOption::createOrUpdate(
|
||||
[
|
||||
'newsletter_id' => $newsletter->id,
|
||||
@ -196,7 +196,7 @@ class Newsletter {
|
||||
]
|
||||
);
|
||||
}
|
||||
foreach($this->segments as $segment_id) {
|
||||
foreach ($this->segments as $segment_id) {
|
||||
NewsletterSegment::createOrUpdate([
|
||||
'newsletter_id' => $newsletter->id,
|
||||
'segment_id' => $segment_id,
|
||||
|
@ -62,7 +62,7 @@ class Subscriber {
|
||||
*/
|
||||
public function create() {
|
||||
$subscriber = \MailPoet\Models\Subscriber::createOrUpdate($this->data);
|
||||
foreach($this->segments as $segment) {
|
||||
foreach ($this->segments as $segment) {
|
||||
SubscriberSegment::createOrUpdate([
|
||||
'subscriber_id' => $subscriber->id(),
|
||||
'segment_id' => $segment->id(),
|
||||
|
@ -20,7 +20,7 @@ class Acceptance extends \Codeception\Module
|
||||
-15 // Number of log entries to tail
|
||||
);
|
||||
|
||||
foreach($logEntries as $logEntry) {
|
||||
foreach ($logEntries as $logEntry) {
|
||||
if($this->isJSError($logEntry)) {
|
||||
// Collect JS errors into an array
|
||||
$this->js_errors[] = $logEntry['message'];
|
||||
|
@ -10,7 +10,7 @@ class AutomatedLatestContentTest extends \MailPoetTest {
|
||||
$endpoint = new AutomatedLatestContent(new \MailPoet\Newsletter\AutomatedLatestContent(), new WPFunctions);
|
||||
$response = $endpoint->getPostTypes();
|
||||
expect($response->data)->notEmpty();
|
||||
foreach($response->data as $post_type) {
|
||||
foreach ($response->data as $post_type) {
|
||||
expect($post_type)->count(2);
|
||||
expect($post_type['name'])->notEmpty();
|
||||
expect($post_type['label'])->notEmpty();
|
||||
|
@ -53,7 +53,7 @@ class CustomFieldsTest extends \MailPoetTest {
|
||||
|
||||
function _before() {
|
||||
parent::_before();
|
||||
foreach($this->custom_fields as $custom_field) {
|
||||
foreach ($this->custom_fields as $custom_field) {
|
||||
CustomField::createOrUpdate($custom_field);
|
||||
}
|
||||
}
|
||||
@ -64,7 +64,7 @@ class CustomFieldsTest extends \MailPoetTest {
|
||||
expect($response->status)->equals(APIResponse::STATUS_OK);
|
||||
expect($response->data)->count(count($this->custom_fields));
|
||||
|
||||
foreach($response->data as $custom_field) {
|
||||
foreach ($response->data as $custom_field) {
|
||||
expect($custom_field['name'])->notEmpty();
|
||||
expect($custom_field['type'])->notEmpty();
|
||||
expect($custom_field['params'])->notEmpty();
|
||||
|
@ -97,7 +97,7 @@ class NewsletterTemplatesTest extends \MailPoetTest {
|
||||
|
||||
$normalize = function($array) {
|
||||
$result = array();
|
||||
foreach($array as $key => $value) {
|
||||
foreach ($array as $key => $value) {
|
||||
if(in_array($key, ['newsletter_id', 'name', 'body'])) {
|
||||
$result[$key] = $value;
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ class NewslettersTest extends \MailPoetTest {
|
||||
'nthWeekDay',
|
||||
'schedule'
|
||||
);
|
||||
foreach($newsletter_options as $option) {
|
||||
foreach ($newsletter_options as $option) {
|
||||
$newsletter_option_field = NewsletterOptionField::create();
|
||||
$newsletter_option_field->name = $option;
|
||||
$newsletter_option_field->newsletter_type = Newsletter::TYPE_NOTIFICATION;
|
||||
@ -293,7 +293,7 @@ class NewslettersTest extends \MailPoetTest {
|
||||
'nthWeekDay',
|
||||
'schedule'
|
||||
);
|
||||
foreach($newsletter_options as $option) {
|
||||
foreach ($newsletter_options as $option) {
|
||||
$newsletter_option_field = NewsletterOptionField::create();
|
||||
$newsletter_option_field->name = $option;
|
||||
$newsletter_option_field->newsletter_type = Newsletter::TYPE_NOTIFICATION;
|
||||
|
@ -90,7 +90,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
private function _createOrUpdateNewsletterOptions($newsletter_id, $newsletter_type, $options) {
|
||||
foreach($options as $option => $value) {
|
||||
foreach ($options as $option => $value) {
|
||||
$newsletter_option_field = NewsletterOptionField::where('name', $option)->findOne();
|
||||
if(!$newsletter_option_field) {
|
||||
$newsletter_option_field = NewsletterOptionField::create();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user