I have upgraded to PHP8.o and have a plugin
using the depreciated each() function.
Would this be a correct refactor of this code? -- see the inline comments where I have made the changes
// get the importable types
$types = $this -> get_importable_post_types();
settype($types, 'array'); // I added this line
if ( ! $types ) :
_e('Sorry, there are no public post types that support post thumbnails.', 'plugin_default');
return;
endif;
_e('The default post type for new posts will be ', 'plugin_default');
if ( count($types) == 1 ):
// only one so no need for selector
// list($post_type, $post_type_name) = each($types); // I have taken this line out
$post_type = key($types); // I added this line
$post_type_name = current($types); // I added this line
?>
Thanks for your help