Skip to content

Instantly share code, notes, and snippets.

Avatar
🍪

numan türle numanturle

🍪
View GitHub Profile
@numanturle
numanturle / crawler_detect.php
Created May 21, 2018 — forked from geerlingguy/crawler_detect.php
Detect crawlers/bots/spiders in PHP (simple and fast)
View crawler_detect.php
<?php
/**
* Check if the given user agent string is one of a crawler, spider, or bot.
*
* @param string $user_agent
* A user agent string (e.g. Googlebot/2.1 (+http://www.google.com/bot.html))
*
* @return bool
* TRUE if the user agent is a bot, FALSE if not.
View Search Block in Transient (30 Sec)
// Get user IP in WordPress
function get_the_user_ip() {
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
//check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
}else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return apply_filters( 'wpb_get_ip', $ip );
}
You can’t perform that action at this time.