Support » Plugin: Powerkit – Supercharge your WordPress Site » is_amp_endpoint was called incorrectly

  • Resolved schwifty5

    (@schwifty5)


    I am adding virtual pages programmatically like seen here: https://gist.github.com/gmazzap/1efe17a8cb573e19c086

    Sadly on the virtual pages the Powerkit plugin is creating a php notice of a too early called is_amp_endpoint() function:

    Notice: is_amp_endpoint was called incorrectly. is_amp_endpoint() was called before the parse_query hook was called.

    Could you please look into this for a fix or give me a hint for a local fix.

    Thanks alot.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I traced it to the lazyload part of powerkit:

    file: class-powerkit-lazyload-public.php
    line: 69

    
    /**
    	 * This conditional tag checks if Lazy Load allowed.
    	 *
    	 * @param array $attr Attributes for the image markup.
    	 */
    	public function is_enabled( $attr = array() ) {
    		if ( is_admin() || is_preview() ) {
    			return false;
    		}
    
    		// Check AMP endpoint.
    		if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
    			return false;
    		}
    
    		// Check feed.
    		if ( is_feed() ) {
    			return false;
    		}
    
    		// Check printpage.
    		if ( get_query_var( 'print' ) || get_query_var( 'printpage' ) ) {
    			return false;
    		}
    
    		// Is filter disabled ?
    		if ( apply_filters( 'powerkit_lazyload_is_disabled', false, $attr ) ) {
    			return false;
    		}
    
    		// Is image disabled ?
    		if ( isset( $attr['class'] ) && preg_match( '/pk-lazyload-disabled/', $attr['class'] ) ) {
    			return false;
    		}
    
    		return true;
    	}
    
    

    Nevermind, issue was solved. There was a action hook missing in my code for parse_query to resolve.

    Plugin Author codesupplyco

    (@codesupplyco)

    Hi!

    Thanks for reporting back.

    I’m glad you managed to resolve the issue.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘is_amp_endpoint was called incorrectly’ is closed to new replies.