Skip to main content
4 events
when toggle format what by license comment
Mar 21, 2020 at 22:15 comment added mickmackusa I would also like to endorse the consistent use of square-braced array syntax ([...]). It is more concise than array(...) and provides a visual differentiation from language constructs and function calls which I'll argue improves readability. Either way, only one syntactic style should be used throughout the project -- consistency is important. I personally don't separate } and ` else {` on different lines and I am fundamentally opposed to WP's coding standard which endorses excessive whitespaces around everything.
Mar 21, 2020 at 20:50 comment added James @nigel ren Thanks for your input and comments. I've not had a chance to put these into practice but I can clearly see how they would improve my code, much appreciated. I will come back if any questions.
Mar 21, 2020 at 14:29 comment added mickmackusa Grrr, I was going to suggest recursion, but you beat me to it; plus one. I was also going to recommend that <ul> elements only be written if there are <li> tags for it -- you addressed that too! It may not be a concern for this OP, but I was thinking of declaring a hard limit to the recursion levels. I don't think !empty() is necessary -- if !is_wp_error() then there will be an array declared as $childrenCheck. To check if it is truthy (IOW, has a count), just check if ($childrenCheck) and spare the function call ...unless you prefer the explicit nature of !empty(). Good review.
Mar 21, 2020 at 7:41 history answered Nigel Ren CC BY-SA 4.0