Uname: Linux webm012.cluster130.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 8.0.30 [ PHP INFO ] PHP os: Linux
Server Ip: 145.239.37.162
Your Ip: 216.73.216.190
User: dreampi (1009562) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : Migration_20241007_170437_Db.php
<?php declare(strict_types = 1);

namespace MailPoet\Migrations\Db;

if (!defined('ABSPATH')) exit;


use MailPoet\Migrator\DbMigration;

/**
 * In https://github.com/mailpoet/mailpoet/pull/5628 we removed Google+ social icons
 * but they were still used in templates. This migration removes them from the templates.
 */
class Migration_20241007_170437_Db extends DbMigration {
  public function run(): void {
    global $wpdb;
    $templatesTable = esc_sql($wpdb->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);
    }
  }
}
© 2026 GrazzMean-Shell