Errors in pro/cornerstone/includes/classes/common/class-condition-rules.php

I tried to use the date archive condition on an element of mine in a header using Pro.

It throws a fatal error, and that’s because, at line 284 there’s a static function:

public static function current_query_date_archive( $type ) {
    return $this->archive_date( $type );
}

And on at line 300:

public static function current_query_is_first_page() {
    return $this->archive_is_first_page();
}

As a PHP developer, it’s clear to me that you can’t reference an instance variable (particularly $this) inside a static method of a class. There’s no questions the source of the error:

Using $this when not in object context

Everything else looks okay off the cuff.

I am using Pro with the following line in the style.css:

Version: 4.3.3

Thanks,
Asher

I changed:

$this->

In the above examples to:

self::

And that seems to work.

Cheers,
Asher

Also, in my header element, the condition “Date Archive” - is not - “Any” doesn’t seem to work. The element appears on years, months, days… but when I select the specific type, “year” for instance, it does work.

Hi Asher,

Glad that it working now. Please remember that Static method is need to be called using the CLASSNAME::METHODNAME from outside the class and within the same class SELF::METHODNAME.

And in case of Date Archive condition it always compared with a relevant option of Date and in your case year is the option.

Thanks for understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.