diff --git a/RoboFile.php b/RoboFile.php index f33940863a..e701b8f872 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -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( diff --git a/lib/API/JSON/API.php b/lib/API/JSON/API.php index 3918c923c1..d9d442d90e 100644 --- a/lib/API/JSON/API.php +++ b/lib/API/JSON/API.php @@ -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, diff --git a/lib/API/JSON/v1/AutomatedLatestContent.php b/lib/API/JSON/v1/AutomatedLatestContent.php index d81160e63e..0a0e184cb4 100644 --- a/lib/API/JSON/v1/AutomatedLatestContent.php +++ b/lib/API/JSON/v1/AutomatedLatestContent.php @@ -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; } } diff --git a/lib/API/JSON/v1/Forms.php b/lib/API/JSON/v1/Forms.php index 3c74d77a4b..bf63f74f3c 100644 --- a/lib/API/JSON/v1/Forms.php +++ b/lib/API/JSON/v1/Forms.php @@ -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'])) { diff --git a/lib/API/JSON/v1/Newsletters.php b/lib/API/JSON/v1/Newsletters.php index ed4f4a72b9..5925f72798 100644 --- a/lib/API/JSON/v1/Newsletters.php +++ b/lib/API/JSON/v1/Newsletters.php @@ -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; diff --git a/lib/API/JSON/v1/Segments.php b/lib/API/JSON/v1/Segments.php index 1ff2fb5cc9..5ce04418bc 100644 --- a/lib/API/JSON/v1/Segments.php +++ b/lib/API/JSON/v1/Segments.php @@ -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.']' ); diff --git a/lib/API/JSON/v1/Settings.php b/lib/API/JSON/v1/Settings.php index 98921fd015..c7e01809d0 100644 --- a/lib/API/JSON/v1/Settings.php +++ b/lib/API/JSON/v1/Settings.php @@ -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(); diff --git a/lib/API/JSON/v1/Subscribers.php b/lib/API/JSON/v1/Subscribers.php index bb05f3542a..b8765acd94 100644 --- a/lib/API/JSON/v1/Subscribers.php +++ b/lib/API/JSON/v1/Subscribers.php @@ -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(); diff --git a/lib/API/MP/v1/API.php b/lib/API/MP/v1/API.php index 51bce19f62..138bf91f90 100644 --- a/lib/API/MP/v1/API.php +++ b/lib/API/MP/v1/API.php @@ -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') diff --git a/lib/Config/Capabilities.php b/lib/Config/Capabilities.php index de1837c45e..bdf8c90f8f 100644 --- a/lib/Config/Capabilities.php +++ b/lib/Config/Capabilities.php @@ -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); } } diff --git a/lib/Config/DeferredAdminNotices.php b/lib/Config/DeferredAdminNotices.php index 5c80d1f667..fbd5a88258 100644 --- a/lib/Config/DeferredAdminNotices.php +++ b/lib/Config/DeferredAdminNotices.php @@ -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 { } } -} \ No newline at end of file +} diff --git a/lib/Config/MP2Migrator.php b/lib/Config/MP2Migrator.php index 8943eef445..ca9dee14c6 100644 --- a/lib/Config/MP2Migrator.php +++ b/lib/Config/MP2Migrator.php @@ -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; diff --git a/lib/Config/Menu.php b/lib/Config/Menu.php index e7a19d1035..3a1ca81667 100644 --- a/lib/Config/Menu.php +++ b/lib/Config/Menu.php @@ -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; } diff --git a/lib/Config/Migrator.php b/lib/Config/Migrator.php index 26fc3cc7c9..53da64502b 100644 --- a/lib/Config/Migrator.php +++ b/lib/Config/Migrator.php @@ -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); } diff --git a/lib/Config/Populator.php b/lib/Config/Populator.php index 6f21300eb7..58235cff90 100644 --- a/lib/Config/Populator.php +++ b/lib/Config/Populator.php @@ -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; diff --git a/lib/Config/RequirementsChecker.php b/lib/Config/RequirementsChecker.php index 018ee4e69d..deaa8bad34 100644 --- a/lib/Config/RequirementsChecker.php +++ b/lib/Config/RequirementsChecker.php @@ -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( diff --git a/lib/Config/Shortcodes.php b/lib/Config/Shortcodes.php index 4a015ba48b..89c032d6c8 100644 --- a/lib/Config/Shortcodes.php +++ b/lib/Config/Shortcodes.php @@ -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 .= '

'.$title.'

'; } $html .= '