Title: Undefined variable $priority (with fix)
Last modified: March 7, 2024

---

# Undefined variable $priority (with fix)

 *  [alduinwf](https://wordpress.org/support/users/alduinwf/)
 * (@alduinwf)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/undefined-variable-priority-with-fix/)
 * Hello, my name is Alduin and I’ll be your dragon today 🐲
 * I have administration privileges on a website that uses this plugin. And while
   looking for another issue, I found two warnings in the logs that I want gone 
   because the less random stuff is in the logs, the sooner I find the actual problem;–)
 * So here’s a message I have:
 * `PHP message: PHP Warning:
   Undefined variable $priority in /.../wp-content/plugins/
   event-organiser/includes/class-eo-theme-compatability.php on line 190; PHP message:
   PHP Warning: Undefined variable $priority in /.../wp-content/plugins/event-organiser/
   includes/class-eo-theme-compatability.php on line 213
 * Fix is rather easy. In said file, find (line 190):
 * `$this->remove_filter( 'post_class', $priority );`
 * and replace with:
 * `$this->remove_filter( 'post_class', $priority ?? 10 );`
 * Find further (line 213):
 * `add_filter( 'post_class', array( $this, 'post_class_events_page' ), $priority,
   3 );`
 * replace with:
 * `add_filter( 'post_class', array( $this, 'post_class_events_page' ), $priority??
   10, 3 );`
 * The warning complains about `$priority` not being set. So what my change does
   is to use `$priority` if it happens to be set and if not, assume a default value
   which I set to 10 because I think this is what WordPress would do if left empty.
 * Please, add this to the main code so that it’ll be update-safe. :–)
 * Thank you!

Viewing 1 replies (of 1 total)

 *  [pzingg](https://wordpress.org/support/users/pzingg/)
 * (@pzingg)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/undefined-variable-priority-with-fix/#post-17867342)
 * I also saw this popping up in my debug log, as I had to fix a conflict between
   EO’s theme compatibility and the Avada template builder. It is the result of 
   a code checked in for version 3.12.3. In version 3.12.2 the $priority variable
   did exist and was set to be one greater than the highest installed priority for
   any added ‘post_class’ filter using a lookup function.
 * The priority on line 190 has to be set to the same priority as specified 4 lines
   earlier to remove the filter correctly, and could be 10 or a higher number. The
   priority on line 213 could also be a larger number than 10, if you use the logic
   that was suggested in version 3.12.2. PHP_INT_MAX – 1 is used for most of the
   other filter priorities. So maybe it would be better to use $priority = PHP_INT_MAX–
   1 for both of these?
 * BTW if you have a problem with Avada and Event Organiser’s archive pages, here’s
   a fix (removing the ‘the_content’ filter that EO installs at priority PHP_INT_MAX–
   1.
 * `/* Removes the 'the-content' filter that EO installs when rendering archives.*/
   
   function remove_eo_compat_the_content_filter() { if ( class_exists( 'EO_Theme_Compatabilty')&&
   isset( $GLOBALS['eo_compat'] ) ) { global $eo_compat; remove_filter( 'the_content',
   array( $eo_compat, 'replace_page_content' ), PHP_INT_MAX - 1 ); }}add_action('
   awb_remove_third_party_the_content_changes', 'remove_eo_compat_the_content_filter');
    -  This reply was modified 1 year, 11 months ago by [pzingg](https://wordpress.org/support/users/pzingg/).
    -  This reply was modified 1 year, 11 months ago by [pzingg](https://wordpress.org/support/users/pzingg/).
    -  This reply was modified 1 year, 11 months ago by [pzingg](https://wordpress.org/support/users/pzingg/).

Viewing 1 replies (of 1 total)

The topic ‘Undefined variable $priority (with fix)’ is closed to new replies.

 * ![](https://ps.w.org/event-organiser/assets/icon-256x256.png?rev=978123)
 * [Event Organiser](https://wordpress.org/plugins/event-organiser/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/event-organiser/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/event-organiser/)
 * [Active Topics](https://wordpress.org/support/plugin/event-organiser/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/event-organiser/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/event-organiser/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [pzingg](https://wordpress.org/support/users/pzingg/)
 * Last activity: [1 year, 11 months ago](https://wordpress.org/support/topic/undefined-variable-priority-with-fix/#post-17867342)
 * Status: not resolved