Finally a solution provide by @Rizier123
if(!preg_match("https://wordpress.stackexchange.com/" . preg_quote($citation_string, "https://wordpress.stackexchange.com/") . "https://wordpress.stackexchange.com/", $footer_contents))
@Rizier123 say : The problem are the slashes in your pattern, just use preg_quote() to escape them, e.g.
so the code will be like this :
add_action('template_redirect', 'foobar_explode_if_no_citation');
function foobar_explode_if_no_citation(){
#Get the absolute server path to footer.php
$footer_path = locate_template('footer.php');
#Store the footer file contents in a var
$footer_contents = file_get_contents($footer_path);
#The required string
$citation_string = 'Designed by Foo Bar <a href="http://YourLink.com">anchor</a>';
#Set off the nuclear bomb if there is an egregious offense
if(!preg_match("https://wordpress.stackexchange.com/" . preg_quote($citation_string, "https://wordpress.stackexchange.com/") . "https://wordpress.stackexchange.com/", $footer_contents))
exit('All your websitez are belong to me. Make sure this string "Designed by Foo Bar" is included in footer.php');
}
? Who will work with this code ?
coders who worked days and night to provide great content, and just putting their citation words or link as a copyright..and dont want a user of the script remove it or replace it with his own without permission…
it’s just a simple way to respect the copyright! respect coders.
5
solved probleme adding Txt and Links in preg_match()