0

I'm using the Hierarchical Pages plugin on a site and I notice that if I flip to a newer version of PHP, it errors out and it appears that using sizeof in this particualr instance is the culprit:

if (($args['show_home'] == 'yes') || (sizeof($page_info[$front_page]['children']))) {
      $page_info[$front_page]['show'] = 1;  // always show front page
    }

To be honest, I'm not too familiar with this plugin, but after doing some digging it looks like it should be using something like count((array)...). So I updated it to this:

    if (($args['show_home'] == 'yes') || (count((array)$page_info[$front_page]['children']))) {
      $page_info[$front_page]['show'] = 1;  // always show front page
    }

And that seems to clear out the error, but I just want to make sure if that's a good or correct thing to implement and if I'm missing anything.

1

1 Answer 1

0

Modifying a contributed plugin is not suggested. If you ever update that plugin it may reintroduce the error. The best approach is to fork the plugin or submit a patch to the plugin developer.

Other than that sizeof() is just an alias of count() so if that resolves the error I would just issue roll with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.