Upgrade to 5.10.4 breaks subgroups

Support General Upgrade to 5.10.4 breaks subgroups

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #47131
    Topher DeRosiaTopher DeRosia
    Participant

    Here's my code: https://gist.github.com/topher1kenobe/4ede89488143bbd78168f15c8528e2ac

    I'm using composer to include meta-box in my plugin and it has 5.9.7. When I upgrade to 5.10.4 the UI breaks entirely.

    #47144
    PeterPeter
    Moderator

    Hello Topher,

    Can you please also share the code that creates the field group? Or export the field group to a JSON file and share it here. I will import it to my demo site and use your code to output the subfield value to see how it displays in the frontend.
    Following the documentation https://docs.metabox.io/extensions/meta-box-builder/#export--import

    #47145
    Topher DeRosiaTopher DeRosia
    Participant

    See if this works: https://gist.github.com/topher1kenobe/bf5902f0698ac53abff605af4cfe3d27

    #47158
    PeterPeter
    Moderator

    Hello,

    I see there are two issues in the code that you create to output the field value:

    1. Missing the closing square bracket:

    - current:
    $image = RWMB_Image_Field::file_info( $image_id, [ 'size' => 'thumbnail' );

    - it should be:
    $image = RWMB_Image_Field::file_info( $image_id, [ 'size' => 'thumbnail' ] );

    2. Missing the field prefix when accessing the subgroup and subfields, for example:

    - current:

    // Field image:
    $image_ids = $subgroup[ 'image' ] ?? [];

    - it should be:

    // Field title:
    echo $subgroup[ 'ie-slider-title' ] ?? '';

    The correct code is:

    $groups = rwmb_meta( 'ie-slider-sliders' );
    foreach ( $groups as $group ) {
    	
    	// Field slider:
    	$subgroups = $group[ 'ie-slider-slider' ] ?? '';
    	foreach ( $subgroups as $subgroup ) {
    		
    		// Field title:
    		echo $subgroup[ 'ie-slider-title' ] ?? '';
    		
    		// Field image:
    		$image_ids = $subgroup[ 'ie-slider-image' ] ?? [];
    		?>
    		<h3>Uploaded images</h3>
    		<ul>
    			<?php foreach ( $image_ids as $image_id ) : ?>
    				<?php $image = RWMB_Image_Field::file_info( $image_id, [ 'size' => 'thumbnail' ] ); ?>
    				<li><img src="<?php echo $image['url']; ?>"></li>
    			<?php endforeach ?>
    		</ul>
    		<?php
    		
    		// Field caption:
    		echo $subgroup[ 'ie-slider-caption' ] ?? '';
    		
    		// Field description:
    		$values = $subgroup[ 'ie-slider-description' ] ?? '';
    		foreach ( $values as $value ) :
    			echo do_shortcode( wpautop( $value ) );
    		endforeach;	
    	}
    
    }
    #47177
    Topher DeRosiaTopher DeRosia
    Participant

    Bleh, my response wasn't recorded. I think we need to start this thread again. All the code I posted above is from the exporter, which means the flaws are in the exporter as well.

    The code I'm actually using is https://gist.github.com/topher1kenobe/ed31a29f40502044e5de87a53d9289b6

    And the full plugin is at http://derosia.com/ie-slider.3.0.2.zip

    #47180
    Topher DeRosiaTopher DeRosia
    Participant

    I've found that 5.10.1 does not cause an issue, whilst 5.10.4 does.

    #47181
    Topher DeRosiaTopher DeRosia
    Participant

    Ok, it gets weirder. I don't think it's core, I removed meta-box/meta-box-group from my project and it resolved all problems.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.