Steps to reproduce
- Create a new listing on the site with an emoji included in the title.
- Share the link to this listing from an iPhone using a messaging app like WhatsApp.
- Click on the shared link from another device (iPhone, Android, or desktop).
Actual result
When the link is shared from an iPhone and clicked from another device, it often redirects to a “404 - Page Not Found” error. However, when the same link is copied and pasted directly into the browser, it works correctly.
Expected result
The link should open the correct listing page regardless of the device or method used to access the URL, including when the link is clicked directly from a messaging app on an iPhone.
Extra details
I have attempted to resolve this issue by using custom filters to remove or encode emojis in the listing titles and slugs, but the problem persists. Below are the code snippets I have used:
Custom Filter to Remove Emojis:
add_filter(
'hivepress/v1/models/listing',
function( $model ) {
$model['fields']['title']['max_length'] = 100;
$model['fields']['description']['max_length'] = 1200;
$model['fields']['images']['required'] = true;
add_filter( 'hivepress/v1/forms/listing_update', function( $form ) {
if ( isset( $form['fields']['title'] ) && ! empty( $form['fields']['title']['value'] ) ) {
$form['fields']['title']['value'] = preg_replace('/[\x{1F600}-\x{1F64F}\x{1F300}-\x{1F5FF}\x{1F680}-\x{1F6FF}\x{1F1E0}-\x{1F1FF}]/u', '', $form['fields']['title']['value']);
}
return $form;
});
add_filter( 'wp_unique_post_slug', function( $slug, $post_ID, $post_status, $post_type, $post_parent ) {
if ( $post_type === 'listing' ) {
$slug = preg_replace('/[\x{1F600}-\x{1F64F}\x{1F300}-\x{1F5FF}\x{1F680}-\x{1F6FF}\x{1F1E0}-\x{1F1FF}]/u', '', $slug);
}
return $slug;
}, 10, 5 );
return $model;
}
);
Despite these attempts, the issue persists, particularly when links are shared from iPhones. I would appreciate any advice or solutions you could provide to ensure the URLs work correctly across all devices.
Thank you in advance for your help!
Best regards