25
isagent
is_agent
SYNOPSIS
is_agent($s, $agent=false)
CODE
- function is_agent($s, $agent=false) {
- if (!$agent) {
- require_once 'useragent.php';
- $agent=user_agent();
- }
- return $agent and preg_match('/'. $s . '/i', $agent);
- }
is_opengraph
SYNOPSIS
is_opengraph($agent=false)
DESCRIPTION
is_opengraph
returns true
if $agent
is the name of an agent capable of reading Open Graph tags.
By default, if $agent
is false
, is_opengraph
tests the value returned by user_agent
.
CODE
- function is_opengraph($agent=false) {
- $bots = array(
- 'facebookexternalhit',
- 'facebot',
- 'google',
- 'twitterbot',
- 'linkedinbot',
- 'pinterest',
- 'whatsapp',
- );
- return is_agent(implode('|', $bots), $agent);
is_bot
SYNOPSIS
is_bot($agent=false)
DESCRIPTION
is_bot
returns true
if $agent
is the name of a search engine agent.
By default, if $agent
is false
, is_bot
tests the value returned by user_agent
.
CODE
- function is_bot($agent=false){
- $bots = array(
- 'googlebot',
- 'bingbot',
- 'yahoo! slurp',
- 'baiduspider',
- 'yandexbot',
- );
- return is_agent(implode('|', $bots), $agent);
Comments