tokkonopapa / WordPress-IP-Geo-Block

A WordPress plugin that will blocks any comment, pingback and trackback spams posted from outside your nation. And it will also protect against malicious access to the login form, admin area and XML-RPC from undesired countries.
http://www.ipgeoblock.com/
29 stars 14 forks source link

Post blocked by country listed on blog page #33

Closed mcolomer closed 6 years ago

mcolomer commented 6 years ago

Hi,

I have detected that a blocked post appears in blog list but a not found page is shown when you click on it. Is there any fast way to fix this by myself?

I would like to avoid showing blocked post in blog list page to avoid noise for end user.

Best,

tokkonopapa commented 6 years ago

Hi @mcolomer ,

I hope the following code snippet can help you.

$settings = IP_Geo_Block::get_option();
$validate = IP_Geo_Block::get_geolocation();
$validate = IP_Geo_Block::validate_country( 'public', validate, $settings['public'] );
if ( 'passed' === $validate['result'] ) {
    // do stuff;
}

Please find Example 17 about IP_Geo_Block::get_geolocation().

mcolomer commented 6 years ago

Thank you tokko.

It works like a charm.

Best,

tokkonopapa commented 6 years ago

Good, and one thing I should add to avoid error just in case:

if ( class_exists( 'IP_Geo_Block' ) ) {
    // the above code snippet here;
} else {
    // do full stuff here;
}