• I’ve got the error:

    Warning: explode() expects parameter 2 to be string, array given in C:\xampp\...\wp-content\plugins\wp-gallery-custom-links\wp-gallery-custom-links.php on line 205
    
    Warning: array_merge(): Argument #2 is not an array in C:\xampp\...\wp-content\plugins\wp-gallery-custom-links\wp-gallery-custom-links.php on line 205
    
    Warning: explode() expects parameter 2 to be string, array given in C:\xampp\...\wp-content\plugins\wp-gallery-custom-links\wp-gallery-custom-links.php on line 216
    
    Warning: array_merge(): Argument #1 is not an array in C:\xampp\...\wp-content\plugins\wp-gallery-custom-links\wp-gallery-custom-links.php on line 216
    
    Warning: array_unique() expects parameter 1 to be array, null given in C:\xampp\...\wp-content\plugins\wp-gallery-custom-links\wp-gallery-custom-links.php on line 220
    
    Warning: Invalid argument supplied for foreach() in C:\xampp\...\wp-content\plugins\wp-gallery-custom-links\wp-gallery-custom-links.php on line 222

    The fastest way I’ve found to fix it is changing the line 205 and 216 to:

    if ( is_array( $attr['ids'] ) ) {
      $attachment_ids = array_merge( $attachment_ids, $attr['ids'] );
    } else {
      $attachment_ids = array_merge( $attachment_ids, explode( ',', $attr['ids'] ) );
    }
    if ( is_array( $attr['include'] ) ) {
      $attachment_ids = array_merge( $attachment_ids, $attr['include'] );
    } else {
      $attachment_ids = array_merge( $attachment_ids, explode( ',', $attr['include'] ) );
    }
  • The topic ‘Error and fix suggestion “explode() expects parameter 2 to be string…”’ is closed to new replies.