hello,
On my site, in the listing content area, submitted hyperlinks are turned into plain text, and embedded links are is disabled. However spammers can put “https://cnn.com” and it is turned into a link. I would like to know if they can be turned into plain text, or disapeared
I think im missing the correct terms to do so. So far i have tried the following with no luck:
// Disable automatic link conversion for plain URLs in content
remove_filter( 'the_content', 'make_clickable', 9 );
remove_filter( 'the_excerpt', 'make_clickable' );
/////////////////////
// Disable automatic link conversion for plain URLs in content
remove_filter( 'the_content', 'make_clickable', 9 );
remove_filter( 'the_excerpt', 'make_clickable' );
// Add a custom function to handle specific class exclusion
function exclude_specific_classes_from_link_conversion( $content ) {
// List of classes to exclude from link conversion
$exclude_classes = array( 'hp-page__content', 'hp-listing__details', 'hp-listing__details--primary' );
// Loop through each excluded class and prevent link conversion
foreach ( $exclude_classes as $class ) {
$content = preg_replace_callback(
'/(<[^>]+)class=[\'"]' . preg_quote( $class, '/' ) . '[\'"]([^>]*>)/i',
function ( $matches ) {
return $matches[1] . 'data-no-link-conversion' . $matches[2];
},
$content
);
}
return $content;
}
add_filter( 'the_content', 'exclude_specific_classes_from_link_conversion', 20 );
add_filter( 'the_excerpt', 'exclude_specific_classes_from_link_conversion', 20 );
/////////////////
function disable_specific_class_link_conversion( $content ) {
// List of classes to exclude from link conversion
$exclude_classes = array( 'hp-page__content', 'hp-listing__details', 'hp-listing__details--primary' );
// Loop through each excluded class and prevent link conversion
foreach ( $exclude_classes as $class ) {
$content = preg_replace_callback(
'/<a(.*?)class=[\'"]' . preg_quote( $class, '/' ) . '[\'"](.*?)>(.*?)<\/a>/i',
function ( $matches ) {
return '<span' . $matches[1] . 'class="' . $matches[2] . '">' . $matches[3] . '</span>';
},
$content
);
}
return $content;
}
add_filter( 'the_content', 'disable_specific_class_link_conversion', 20 );
add_filter( 'the_excerpt', 'disable_specific_class_link_conversion', 20 );
//////
// Disable automatic link conversion for plain URLs in content
remove_filter( 'the_content', 'make_clickable', 9 );
remove_filter( 'the_excerpt', 'make_clickable' );
// Add a custom function to handle specific class exclusion
function exclude_specific_classes_from_link_conversion( $content ) {
// List of classes to exclude from link conversion
$exclude_classes = array( 'hp-page__content', 'hp-listing__details', 'hp-listing__details--primary' );
// Loop through each excluded class and prevent link conversion
foreach ( $exclude_classes as $class ) {
$content = preg_replace_callback(
'/(<[^>]+)class=[\'"]' . preg_quote( $class, '/' ) . '[\'"]([^>]*>)/i',
function ( $matches ) {
return $matches[1] . 'style="pointer-events: none; cursor: default;"' . $matches[2];
},
$content
);
}
return $content;
}
add_filter( 'the_content', 'exclude_specific_classes_from_link_conversion', 20 );
add_filter( 'the_excerpt', 'exclude_specific_classes_from_link_conversion', 20 );