diff --git a/config.php b/config.php index 779affd26..8ee76d794 100644 --- a/config.php +++ b/config.php @@ -4,7 +4,7 @@ # Define version constant if ( ! defined( __NAMESPACE__ . '\VERSION' ) ) { - define( __NAMESPACE__ . '\VERSION', '3.6.3' ); + define( __NAMESPACE__ . '\VERSION', '3.6.4' ); } # Define root directory diff --git a/core/Block.php b/core/Block.php index a8fea2df2..d27491aa4 100644 --- a/core/Block.php +++ b/core/Block.php @@ -11,6 +11,6 @@ class Block extends Container { * {@inheritDoc} */ public static function make() { - return call_user_func_array( array( get_parent_class(), 'make' ), array_merge( array( 'block' ), func_get_args() ) ); + return call_user_func_array( array( parent::class, 'make' ), array_merge( array( 'block' ), func_get_args() ) ); } } diff --git a/core/Container.php b/core/Container.php index 506860112..f120df2da 100644 --- a/core/Container.php +++ b/core/Container.php @@ -33,7 +33,7 @@ public static function factory() { * @return \Carbon_Fields\Container\Container */ public static function make() { - return call_user_func_array( array( get_class(), 'factory' ), func_get_args() ); + return call_user_func_array( array( static::class, 'factory' ), func_get_args() ); } /** @@ -46,9 +46,9 @@ public static function __callStatic( $method, $arguments ) { if ( strpos( $method, 'make_' ) === 0 ) { $raw_type = substr_replace( $method, '', 0, 5 ); array_unshift( $arguments, $raw_type ); - return call_user_func_array( array( get_class(), 'factory' ), $arguments ); + return call_user_func_array( array( static::class, 'factory' ), $arguments ); } else { - trigger_error( sprintf( 'Call to undefined function: %s::%s().', get_class(), $method ), E_USER_ERROR ); + trigger_error( sprintf( 'Call to undefined function: %s::%s().', static::class, $method ), E_USER_ERROR ); } } } diff --git a/core/Container/Container.php b/core/Container/Container.php index eafa05017..26cd3760b 100644 --- a/core/Container/Container.php +++ b/core/Container/Container.php @@ -223,7 +223,7 @@ public static function factory( $raw_type, $id, $name = '' ) { * @return Container */ public static function make() { - return call_user_func_array( array( get_class(), 'factory' ), func_get_args() ); + return call_user_func_array( array( static::class, 'factory' ), func_get_args() ); } /** diff --git a/core/Container/Nav_Menu_Item_Container.php b/core/Container/Nav_Menu_Item_Container.php index a009bce95..7bc7eaf63 100644 --- a/core/Container/Nav_Menu_Item_Container.php +++ b/core/Container/Nav_Menu_Item_Container.php @@ -37,7 +37,7 @@ public function __construct( $id, $title, $type, $condition_collection, $conditi } // Register the custom edit walker only once - $callable = array( get_class(), 'edit_walker' ); + $callable = array( static::class, 'edit_walker' ); if ( ! has_filter( 'wp_edit_nav_menu_walker', $callable ) ) { add_filter( 'wp_edit_nav_menu_walker', $callable, 10, 2 ); } diff --git a/core/Container/Theme_Options_Container.php b/core/Container/Theme_Options_Container.php index 355864ea9..753df9102 100644 --- a/core/Container/Theme_Options_Container.php +++ b/core/Container/Theme_Options_Container.php @@ -251,7 +251,7 @@ protected function register_page() { * @return Container $this */ public function set_page_parent( $parent ) { - if ( is_a( $parent, get_class() ) ) { + if ( is_a( $parent, static::class ) ) { $this->settings['parent'] = $parent->get_page_file(); return $this; } diff --git a/core/Datastore/Datastore.php b/core/Datastore/Datastore.php index 12209d24b..9ee3c2d39 100644 --- a/core/Datastore/Datastore.php +++ b/core/Datastore/Datastore.php @@ -76,6 +76,6 @@ public static function factory( $raw_type ) { * @return Datastore_Interface */ public static function make() { - return call_user_func_array( array( get_class(), 'factory' ), func_get_args() ); + return call_user_func_array( array( static::class, 'factory' ), func_get_args() ); } } diff --git a/core/Field.php b/core/Field.php index 0e4d075b4..5fb34c09b 100644 --- a/core/Field.php +++ b/core/Field.php @@ -54,7 +54,7 @@ public static function factory() { * @return \Carbon_Fields\Field\Field */ public static function make() { - return call_user_func_array( array( get_class(), 'factory' ), func_get_args() ); + return call_user_func_array( array( static::class, 'factory' ), func_get_args() ); } /** @@ -67,9 +67,9 @@ public static function __callStatic( $method, $arguments ) { if ( strpos( $method, 'make_' ) === 0 ) { $raw_type = substr_replace( $method, '', 0, 5 ); array_unshift( $arguments, $raw_type ); - return call_user_func_array( array( get_class(), 'factory' ), $arguments ); + return call_user_func_array( array( static::class, 'factory' ), $arguments ); } else { - trigger_error( sprintf( 'Call to undefined function: %s::%s().', get_class(), $method ), E_USER_ERROR ); + trigger_error( sprintf( 'Call to undefined function: %s::%s().', static::class, $method ), E_USER_ERROR ); } } } diff --git a/core/Field/Field.php b/core/Field/Field.php index 62c1ffb76..256e5d414 100644 --- a/core/Field/Field.php +++ b/core/Field/Field.php @@ -249,7 +249,7 @@ public static function factory( $raw_type, $name, $label = null ) { * @return Field */ public static function make() { - return call_user_func_array( array( get_class(), 'factory' ), func_get_args() ); + return call_user_func_array( array( static::class, 'factory' ), func_get_args() ); } /** @@ -293,8 +293,8 @@ public function get_type() { public function activate() { $this->admin_init(); - add_action( 'admin_print_footer_scripts', array( get_class(), 'admin_hook_scripts' ), 5 ); - add_action( 'admin_print_footer_scripts', array( get_class(), 'admin_hook_styles' ), 5 ); + add_action( 'admin_print_footer_scripts', array( static::class, 'admin_hook_scripts' ), 5 ); + add_action( 'admin_print_footer_scripts', array( static::class, 'admin_hook_styles' ), 5 ); static::activate_field_type( get_class( $this ) ); do_action( 'carbon_fields_field_activated', $this ); diff --git a/package.json b/package.json index 36ddee222..f82077acc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "carbon-fields", - "version": "3.6.3", + "version": "3.6.4", "description": "WordPress developer-friendly custom fields for post types, taxonomy terms, users, comments, widgets, options, navigation menus and more.", "directories": { "test": "tests" diff --git a/packages/core/fields/multiselect/index.js b/packages/core/fields/multiselect/index.js index 46414f359..c15fe8746 100644 --- a/packages/core/fields/multiselect/index.js +++ b/packages/core/fields/multiselect/index.js @@ -23,7 +23,7 @@ class MultiselectField extends Component { onChange } = this.props; - onChange( id, selected.map( ( item ) => item.value ) ); + onChange( id, selected?.map( ( item ) => item.value ) ?? [] ); } /** diff --git a/packages/metaboxes/monitors/conditional-display/handler/index.js b/packages/metaboxes/monitors/conditional-display/handler/index.js index 86303525c..91cf8f3a8 100644 --- a/packages/metaboxes/monitors/conditional-display/handler/index.js +++ b/packages/metaboxes/monitors/conditional-display/handler/index.js @@ -98,7 +98,7 @@ export default function handler( { containers, context } ) { results.forEach( ( [ id, result ] ) => { const postboxNode = document.getElementById( id ); const containerNode = document.querySelector( `.container-${ id }` ); - const isMounted = !! containerNode.dataset.mounted; + const isMounted = !! containerNode?.dataset?.mounted; if ( postboxNode ) { postboxNode.hidden = ! result; @@ -119,10 +119,10 @@ export default function handler( { containers, context } ) { if ( result && ! isMounted ) { renderContainer( containers[ id ], context ); } - + if ( ! result && isMounted ) { delete containerNode?.dataset?.mounted; - + // Rely on React's internals instead of `unmountComponentAtNode` // due to https://github.com/facebook/react/issues/13690. // TODO: Conditionally render the fields in the container, this way