Warnings on foreach loops
-
I had PHP errors turned on and had to make the following changes to the upload.php script (version 2 of the plugin, on WP 4.0) in order to get the plugin working.
Please could you incorporate this in to your next release?
Lines 122-128:
// get list of Categories if ($cat) { $excludes = explode (',', get_option( 'adv_file_upload_exc_cat', 'Uncategorized' )); $cats = adv_file_upload_cat_list( 0, array(), $excludes ); - } + } else { + $cats = false; + }
Line 171 (sometimes
get_intermediate_image_sizes()
will return false):- foreach( get_intermediate_image_sizes() as $s ) { + $intermediate_sizes = get_intermediate_image_sizes(); + if (!is_array($intermediate_sizes)) { + $intermediate_sizes = array(); + } + foreach ( $intermediate_sizes as $s ) {
Line 198 ($destinations can be false if
get_option('adv_file_upload_destination')
fails on line 59):+ if (!is_array($destinations)){ + $destinations = array(); + } foreach( $destinations as $dest ) {
Line 237 ($cats was also not an array somehow):
+ if(!is_array($cats)){ + $cats = array(); + } foreach( $cats as $value ) {
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Warnings on foreach loops’ is closed to new replies.