Disable External Pingacks on WordPress Posts and Only Allow 'Self Pings'
I use wordpress for my Social Media site. WordPress Pings allow other blog posts to appear in comments when they link to us.
I want to limit it to only blog posts created on my own site. Basically I only want SELF-PINGS/Trackbacks.
If Other site tries to send ping reject it then and their, but if my own site https://milyin.com's post tries to send a ping readily accept it and show it in comment section.
I tried, wp-admin - discussion - (unselect) Allow links from other blog posts.
But that disables internal Pings too. Secondly My authors are able to turn on/off the pingbacks for each post. So, many of the posts still recieve external pings.
Here's a screenshot of the same: https://snipboard.io/8lVIrE.jpg
I tried to do some code.
I found a tutorial from How Disable Self Pingbacks in WordPress
And I tried to modify it to fit my needs
function SelfPing( $links ) {
$Home = get_option( 'home' );
foreach ( $links as $l = $link ){
if ( strpos( $link, $Home ) === false){
unset($links[$l]);
}
}
}
add_action( 'pre_ping', 'SelfPing' );
However this didn't solve the purpose.
I still recieve pings from all sorts of sites, on my posts, as majority of my authors manually turn on Pings.
So How can I have only self pings, and remove external pings, even when my authors manually turn on pings for all posts.