Created
May 9, 2019 11:22
-
-
Save iamkingsleyf/1ff2851abbef0d27f308b845c2d5c552 to your computer and use it in GitHub Desktop.
disable wordpress self ping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ---------------------------------------------------------------------------- | |
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