Skip to content

Instantly share code, notes, and snippets.

@iamkingsleyf
Created May 9, 2019 11:22
Show Gist options
  • Save iamkingsleyf/1ff2851abbef0d27f308b845c2d5c552 to your computer and use it in GitHub Desktop.
Save iamkingsleyf/1ff2851abbef0d27f308b845c2d5c552 to your computer and use it in GitHub Desktop.
disable wordpress self ping
/* ----------------------------------------------------------------------------
DISABLE SELF PING
*/
//Pass the variable by reference to the function, so the function can modify the variable.
function no_self_ping (&$links) {
$home = get_option( 'home' );
foreach ( $links as $l => $link )
//Find the position of the first occurrence of a substring in a string.
//($a === $b) Identical operator. TRUE if $a is equal to $b, and they are of the same type.
if ( 0 === strpos( $link, $home ) )
//Unset the variable
unset($links[$l]);
}
//Hooks the function to the specific action (pre_ping)
add_action( 'pre_ping', 'no_self_ping' );
/* ----------------------------------------------------------------------------
DISABLE SELF PING END
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment