• Resolved kowluk

    (@kowluk)


    Hi, is it possible to turn on the visibility of the crawler’s logs, in particular googlebot? Maybe some modification in the code will give me this option.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Joel James

    (@joelcj91)

    Hi @,

    You can do that using jj4t3_is_human filter. Add something like this to your custom plugin or your theme’s functions.php

    function exclude_googlebot_from_logs( $human ) {
    
    	// If user agent not found.
    	if ( ! isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
    		return $human;
    	}
    
    	// If user agent is a bot, set human flag to false.
    	if ( preg_match( '/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'] ) ) {
    		return false;
    	}
    
    	return $human;
    }
    
    apply_filters( 'jj4t3_is_human', 'exclude_googlebot_from_logs' );
    • This reply was modified 6 years, 8 months ago by Joel James.
    • This reply was modified 6 years, 8 months ago by Joel James.
    Thread Starter kowluk

    (@kowluk)

    it seems to me that this code removes googlebot entries from logs. I want logs to contain them.

    Plugin Author Joel James

    (@joelcj91)

    Oops. I misread your previous post. Ok, that’s simple. Use below function.

    add_filter( 'jj4t3_is_human', '__return_true' );

    • This reply was modified 6 years, 8 months ago by Joel James.
    Thread Starter kowluk

    (@kowluk)

    Unfortunately, it still does not work with me. Maybe I’m doing something wrong. Just in case, can you check the operation of this rule? In any case, thanks for the quick support

    Plugin Author Joel James

    (@joelcj91)

    How do you test this?

    Thread Starter kowluk

    (@kowluk)

    by changing user agent into opera through user agent switcher and via SC – download as googlebot

    Plugin Author Joel James

    (@joelcj91)

    Oh man, sorry. I wrote the above code wrong. It should be add_filter. Not apply_filters. I have updated above comment.

    So your code should be, add_filter( 'jj4t3_is_human', '__return_true' );

    Thread Starter kowluk

    (@kowluk)

    In my custom plugin I used only this code:
    add_filter( 'jj4t3_is_human', '__return_true' );
    and now it works perfectly. Thank you again for your help!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Crawlers Logs’ is closed to new replies.