prefix . 'mailpoet_newsletter_templates'); if (!$this->tableExists($templatesTable)) { return; } $templatesWithGooglePlus = $this->connection->fetchAllAssociative( "SELECT id, body FROM $templatesTable WHERE body LIKE '%\"iconType\":\"google-plus\"%'" ); foreach ($templatesWithGooglePlus as $template) { if (!is_string($template['body'])) { continue; } $body = json_decode($template['body'], true); $error = json_last_error(); if ($error || !is_array($body)) { continue; } $content = &$body['content']; $this->removeGooglePlusIcons($content); $updatedBody = json_encode($body); if ($updatedBody === false) { continue; } $this->connection->update( $templatesTable, ['body' => $updatedBody], ['id' => $template['id']] ); } } private function removeGooglePlusIcons(&$array) { if (!isset($array['blocks']) || !is_array($array['blocks'])) { return; } foreach ($array['blocks'] as &$block) { $this->removeGooglePlusIcons($block); if (!isset($block['type']) || $block['type'] !== 'social') { continue; } $filteredIcons = array_filter($block['icons'], function($icon) { return $icon['iconType'] !== 'google-plus'; }); $block['icons'] = array_values($filteredIcons); } } }