Description of the bug
A PHP warning occurs when the code tries to access an array key that may not exist.
The issue happens in class-gallery.php at line 168 when using the following expression:
! empty( trim( $matches[2] ) )
Proposed Fix
! empty( trim( $matches[2] ?? '' ) )
Steps To Reproduce
- Trigger the Apple News export process on a post that does not produce a full regex match with index
- Observe PHP logs or browser console for warnings.
- See the Undefined array key 2 warning in the logs.
Additional Information
No response