Serialized data fix for WordPress

over 10 years ago in News by luke

There is many solutions for this problem over the internet, but none of them are solving the problem automatically or without editing the WordPress core.

Lately i came up with the solution for this problem for Ether Builder plugin.

So, here it is, feel free to use it.

add_filter('get_post_metadata', 'ether_serialize_fix', 10, 4);

function meta_serialize_fix($null, $object_id, $meta_key, $single)
{
	$meta_type = 'post';

	if ($meta_key == 'YOUR_META_KEY')
	{
		$meta_cache = wp_cache_get($object_id, $meta_type.'_meta');

		if ( ! $meta_cache)
		{
			$meta_cache = update_meta_cache($meta_type, array($object_id));
			$meta_cache = $meta_cache[$object_id];
		}

		if (isset($meta_cache[$meta_key]))

		{
			if ($single)
			{
				if (is_serialized($meta_cache[$meta_key][0]) AND ! maybe_unserialize($meta_cache[$meta_key][0]))
				{
					return array(maybe_unserialize_fixed($meta_cache[$meta_key][0]));
				}
			} else
			{
				foreach ($meta_cache[$meta_key] as $k => $v)
				{
					if (is_serialized($v) AND ! maybe_unserialize($v))
					{
						return array_map('maybe_unserialize_fixed', $meta_cache[$meta_key]);
					}
				}
			}
		}
	}
}

add_filter('option_OPTION_NAME', 'option_serialize_fix', 10, 1);

function option_serialize_fix($option, $value)
{
	if (is_serialized($value) AND ! maybe_unserialize($value))
	{
		return maybe_unserialize_fix($value);
	}
}

function maybe_unserialize_fixed($data)
{
	return maybe_unserialize(preg_replace('!s:(\d+):"(.*?)";!e',"'s:'.strlen('$2').':\"$2\";'", $data));
}

Keep in mind that using this for every meta key / option name is not a good idea. Use conditional tag instead!

Ether Builder 1.5.2

over 10 years ago in API, Ether Builder and News by luke
  • Fixed: Migration issues (if serialized data gets damaged during migration Ether Builder will try to fix it automatically)
  • Fixed: JigoShop compatibility
  • Fixed: Images issue in product categories in WooCommerce plugin
  • Fixed: Displaying nivo slider and roundabout on mobile devices
  • Added: Template tags: ether_builder::the_content and ether_builder::get_the_content as custom wordpress template tags equivalents (useful in custom loops)
  • Added: Lightbox option for single images
  • Added: Option to turn off default lightbox and plug in custom one (functions.php -> add ether: ether::config(‘builder_lightbox’, FALSE ))
  • Fixed: Accordion constrain option
  • Fixed: Custom Bullet List styles and alignment

Ether Builder 1.5.1

over 10 years ago in API, Ether Builder and News by luke
  • Added: ether_builder_widgets filter (you can now hook up and manipulate registered widgets in Builder)
  • Fixed: Displaying Ether Builder content on archive pages
  • Added: Option to enable/disable displaying Ether Builder content on archive pages (Ether > Builder screen in admin panel)
  • Fixed: Nivo Slider styles overwriting

Ether Backup 1.1.2

over 10 years ago in API, Ether Backup and News by luke
  • Fixed: Issues with WordPress 3.4
  • Fixed: Problems during import of options table

Ether Builder 1.4.8

over 10 years ago in API, Ether Builder and News by matt

Changelog:

  • Fixed: Removed Default sidebar
  • Fixed: Visual-HTML tabs toggling
  • Fixed: Minor classes glitches in tables and testimonials
  • Fixed: Problem with sidebar widgets after deactivating Ether Builder
  • Ether Framework 1.6.0

Ether Backup 1.1

over 10 years ago in API, Ether Backup and News by matt

Changelog:

  • Fixed: Variety of small compatibility issues
  • Fixed: Removed occassional warnings
  • Added: Autoupdate
  • Ether Framework 1.6.0

Ether Builder 1.4.7

over 10 years ago in API, Ether Builder and News by luke
  • Fixed: Vertical Tabs
  • Fixed: Missing argument warnings
  • Fixed: Rich text translation issues for non-english languages

Ether Builder 1.4.5

over 10 years ago in API, Ether Builder and News by matt
  • Added: Framework and plugin version info
  • Added: Server-feature-test for easier troubleshooting
  • Fixed: missing prefixes for some css classes (alignment etc.)

Ether Builder 1.4.4

over 10 years ago in API, Ether Builder and News by luke

Ether Builder 1.4.4 is now available via Ether > Update screen and should be available soon via Envato.

  • Removed error handler in production environment
  • Fixed warnings
  • Fixed Nivo Slider responsive
  • Fxied Nivo Slider pause time

If this update didn’t fixed your issue, be patient, we’re working on it:)

Ether Builder 1.4.3

over 10 years ago in API, Ether Builder and News by luke
  • Added: Autoupdate
  • Fixed: Nivo slider and Roundabout disappearing content issue
  • Fixed: Removed error handler in a production environment
  • Fixed: Accordion and tabs broken after the last update