3 | | This is a meta ticket to track overall progress making replacements throughout core. Because there will be many instances and each requires validation, individual tickets should be opened for each replacement. |
| 3 | This is a meta ticket to track overall progress making replacements throughout core. Because there will be many instances and each requires validation, individual tickets should be opened for each patch. |
| 4 | |
| 5 | **If you have reviewed any core files, please add a note in this ticket about which files you have reviewed and reference any tickets with patches that you have opened as a result of your review.** |
| 6 | |
| 7 | Dev note detailing the new polyfills: https://make.wordpress.org/core/2018/05/17/new-php-polyfills-in-4-9-6/ |
| 8 | |
| 9 | == Using `is_countable()` |
| 10 | |
| 11 | === Old Way |
| 12 | |
| 13 | {{{ |
| 14 | if ( count( $var ) > 0 ) { |
| 15 | // Do something. |
| 16 | } |
| 17 | }}} |
| 18 | |
| 19 | === New Way |
| 20 | |
| 21 | {{{ |
| 22 | if ( is_countable( $var ) && count( $var ) > 0 ) { |
| 23 | // Do something. |
| 24 | } |
| 25 | }}} |
| 26 | |
| 27 | == Using `is_iterable()` |
| 28 | |
| 29 | === Old Way |
| 30 | |
| 31 | {{{ |
| 32 | if ( count( $var ) > 0 ) { |
| 33 | foreach( $var as $key => $value) { |
| 34 | // Do something. |
| 35 | } |
| 36 | } |
| 37 | }}} |
| 38 | |
| 39 | === New Way |
| 40 | |
| 41 | {{{ |
| 42 | if ( is_iterable( $var ) ) { |
| 43 | foreach( $var as $key => $value) { |
| 44 | // Do something. |
| 45 | } |
| 46 | } |
| 47 | }}} |