milohuang / reverie

Reverie is a versatile HTML5 responsive WordPress framework based on ZURB's Foundation.
http://theakiba.com/reverie/
MIT License
916 stars 196 forks source link

is_tree issues with Wordpress 3.5 #115

Closed elhashbrown closed 11 years ago

elhashbrown commented 11 years ago

After updating to 3.5 I found errors coming up due to the is_tree conditional tag in functions.php causing problems with Widget Logic.

"Widget logic runs the conditional check quite a few times for each widget, some of those times it runs before WordPress has loaded the posts, which is why the $post global wasn't yet set (in both 3.4 and 3.5). 3.5 now returns false instead of an empty array in cases like this, causing the warning.

However, using the same code under 3.4 with PHP 5.4 generates PHP Warnings as well, meaning under older PHP versions it was silently failing, but it's still a change in behaviour."

See: http://core.trac.wordpress.org/ticket/22882

The solution was to clean up the is_tree code from:

function is_tree( $pid ) {
global $post;

if ( is_page($pid) )
    return true;

$anc = get_post_ancestors( $post->ID );
foreach ( $anc as $ancestor ) {
    if( is_page() && $ancestor == $pid ) {
        return true;
    }
}

return false;
}    

to:

function is_tree($pid) {
    global $post;
    if ( ! is_page() )
            return false;
    if ( is_page( $pid ) )
            return true;
    $anc = get_post_ancestors( $post );
    if ( in_array( $pid, $anc ) )
            return true;
    return false;
}

It may be worth updating the theme with this.

randomfreeform commented 11 years ago

Hi elhashbrown Thanks for the tip! BTW - does anyone know what's happening to Reverie?? I've been using it for a few clients but it seems to be DEAD.. WP & Zurb have new versions out and I fear to keep using it if it's not getting basic updates. Any alternatives anyone knows about that's better then an unsupported Reverie? *(sigh) I mean cheers!, Rand

milohuang commented 11 years ago

Hello elhashbrown. I checked the code and it appears that I didn't use is_tree in functions.php. Any thoughts?

senlin commented 11 years ago

@randomfreeform it seems the author has regained his momentum and is back on track: http://themefortress.com/required-foundation-shortcodes/