wpmetabox / mb-rest-api

Add custom fields to WordPress REST API
19 stars 12 forks source link

Prevent foreach warning #1

Closed mertonium closed 7 years ago

mertonium commented 7 years ago

My logs were filling up with PHP warnings:

PHP Warning: Invalid argument supplied for foreach() in wp-content/plugins/mb-rest-api/mb-rest-api.php on line 76

I'm not sure where the $mb_term_meta_boxes global is supposed to get set (I couldn't find any references to it outside this file), but in my setup it was consistently something that foreach doesn't like.

This commit just adds a guard to get_meta_terms so that it bails early if the foreach isn't going to like $mb_term_meta_boxes - which gets rid of the warnings.

rilwis commented 7 years ago

Thank you for your contribution.

The $mb_term_meta_boxes variable comes from the MB Term Meta extension.