Skip to content

Version 4 Migration

Mat Lipe edited this page Mar 13, 2023 · 12 revisions

There are many breaking changes when going from V3 to V4.

Changes should be covered using the doing_it_wrong or deprecated mechanisms built into WP core. Be sure to update to the latest V3 version first with WP_DEBUG on and fix any notices.

PHP Version Requirement

PHP 7.4+ is now required to use this library.

WordPress Version Requirement

WordPress Core 5.8+ is now recommended to use this library. Older versions may work but will not be tested against.

User Term Fields

By default CMB2 stores the values for taxonomy based user fields via set_object_terms. While this works in many cases, it has a potential to conflict with the posts table thus reducing database reliability. Going forward, any taxonomy fields registered for users will by default use the user meta API to handle data.

For existing fields using the object terms system call store_user_terms_in_meta( false ) when registering the fields.

Styles Class

The Theme\Styles class has been completely removed in favor of using the Theme\Resources class.

Arrays deprecated methods removed

All the array_ prefix methods were deprecated back in version 3.6.0. They have now been removed from the Util\Array class.

  1. array_map_recursive
  2. array_chunk_to_associative
  3. array_merge_recursive
  4. array_map_assoc
  5. array_recursive_unset
  6. array_flatten_assoc You will find corresponding methods with the same name just not the array_ prefix.

Autoloader modernization

The Util\Autoloader class has been modernized and simplified. The add API remains the same but if you are doing something complex or custom with the Autoloader class, you'll likely need to modernize your usage as well.

Custom_Post_Type and Taxonomy classes updated

Some properties have changed types to match modern versions of WordPress register_post_type and register_taxonomy.

strict_type are enabled so errors should be obvious and simple to fix.

CMB@ classes updated

Some properties have been remove or made protected in favor of using the available methods.

If you receive a fatal error for trying to access a protected property, switch to the same named method.

Repo and Translate_Abstract constants renamed

All previous constants for for data types have been prepended with TYPE_. This allows more reliable PHPStan scans.

Hook Changes

  • The name of lipe/lib/util/cache/flush hook was fixed. If you were using the old lipe/lipe/util/cache/flush, you'll need to update it.

Image Resize

The get_image_from_content and image_scan argument for the Util\Image_Resize class has been removed with no alternative.

Query_Vars class removed

The Rest_Api\Query_Vars class has been removed with no alternative.

Pagination class removed

The Theme\Pagination class has been removed with no alternative.

Custom_Post_Type_Extended class removed

The Post_Type\Custom_Post_Type_Extended class has been removed with no alternative.

Taxonomy_Extended class removed

The Taxonomy\Taxonomy_Extended class has been removed with no alternative.