Replacing each each() line with proper foreach.
$categoriesSorted = $this->sortParentChild($categories);
if (!$forEdit && is_array($categoriesSorted)) {
- while (list($k, $v) = each($categoriesSorted)) {
- $categoriesSorted[$k]['parent_id'] = $v['parent']['value'];
- $categoriesSorted[$k]['parent'] = $v['parent']['name'];
+ foreach ( $categoriesSorted as $k => $v ) {
+ $categoriesSorted[$k]['parent_id'] = $v['parent']['value'];
+ $categoriesSorted[$k]['parent'] = $v['parent']['name'];
}
}
// Update other data for this image
reset($_REQUEST['file_caption']);
- while (list($k, $v) = each($_REQUEST['file_caption'])) {
- $id = ($k -0);
+ foreach ( $_REQUEST['file_caption'] as $k => $v ) {
+ $id = ($k -0);
- // Sanitize input
- $caption = sanitize_text_field( $_REQUEST['file_caption'][$k] );
- $descr = (isset($_REQUEST['file_descr'])) ? sanitize_text_field( $_REQUEST['file_descr'][$k] ):'';
+ // Sanitize input
+ $caption = sanitize_text_field( $_REQUEST['file_caption'][$k] );
+ $descr = (isset($_REQUEST['file_descr'])) ? sanitize_text_field( $_REQUEST['file_descr'][$k] ):'';
- // Update data for this image
- $sql = "UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX ."files SET caption = '$caption', descr = '$descr' WHERE id = $id;";
- $this->wpdb->query($sql);
+ // Update data for this image
+ $sql = "UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX ."files SET caption = '$caption', descr = '$descr' WHERE id = $id;";
+ $this->wpdb->query($sql);
}
// Check for an image deletion
// For each delete requested
reset($_REQUEST['file_delete']);
- while (list($k, $v) = each($_REQUEST['file_delete'])) {
- $id = ($k -0);
+ foreach ( $_REQUEST['file_delete'] as $k => $v ) {
+ $id = ($k -0);
// If a valid key and delete request is in fact set
if ($id > 0 && $v == 'on') {
$where .= ' AND featured = true';
}
$imageGallery = $this->getList($where, 'T.position');
-
+
// Check if we found anything
if (!is_array($imageGallery) || count($imageGallery) == 0) {
return false;
// Update other data for this image
reset($_REQUEST['galleryImage_caption']);
- while (list($k, $v) = each($_REQUEST['galleryImage_caption'])) {
- $id = ($k -0);
+ foreach ( $_REQUEST['galleryImage_caption'] as $k => $v ) {
+ $id = ($k -0);
- // Sanitize input
- $caption = sanitize_text_field( $_REQUEST['galleryImage_caption'][$k] );
- $descr = sanitize_text_field( $_REQUEST['galleryImage_descr'][$k] );
-// $featured = (isset($_REQUEST['galleryImage_featured']) && isset($_REQUEST['galleryImage_featured'][$k]) && $_REQUEST['galleryImage_featured'][$k] == 'on' ? 'true' : 'false');
+ // Sanitize input
+ $caption = sanitize_text_field( $_REQUEST['galleryImage_caption'][$k] );
+ $descr = sanitize_text_field( $_REQUEST['galleryImage_descr'][$k] );
+ // $featured = (isset($_REQUEST['galleryImage_featured']) && isset($_REQUEST['galleryImage_featured'][$k]) && $_REQUEST['galleryImage_featured'][$k] == 'on' ? 'true' : 'false');
- // Check if this is the featured image
- $thisFeatured = ($featured == $k ? 'true' : 'false');
+ // Check if this is the featured image
+ $thisFeatured = ($featured == $k ? 'true' : 'false');
- // Update data for this image
- $sql = "UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX ."images SET caption = '$caption', descr = '$descr', featured = $thisFeatured WHERE id = $id;";
- $this->wpdb->query($sql);
+ // Update data for this image
+ $sql = "UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX ."images SET caption = '$caption', descr = '$descr', featured = $thisFeatured WHERE id = $id;";
+ $this->wpdb->query($sql);
}
// Check for an image deletion
// For each delete requested
reset($_REQUEST['galleryImage_delete']);
- while (list($k, $v) = each($_REQUEST['galleryImage_delete'])) {
- $id = ($k -0);
+ foreach ( $_REQUEST['galleryImage_delete'] as $k => $v ) {
+ $id = ($k -0);
// If a valid key and delete request is in fact set
if ($id > 0 && $v == 'on') {
// Also delete all copies of the image
reset($this->config['imageSizes']);
- while (list($k, $v) = each($this->config['imageSizes'])) {
+ foreach ( $this->config['imageSizes'] as $k => $v ) {
// Check if the image actually exists - May not if we're doing development
if (is_file(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$imgData['file_name'])) {
// For each image size
reset($sizes);
- while (list($k, $v) = each($sizes)) {
+ foreach ( $sizes as $k => $v ) {
- // Check if the source image exists
- if (is_file(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$srcName)) {
+ // Check if the source image exists
+ if (is_file(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$srcName)) {
- // Copy src file to dst file for this size
- copy(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$srcName, GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$dstName);
+ // Copy src file to dst file for this size
+ copy(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$srcName, GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$dstName);
- }
+ }
}
// Add this image to the images table
}
-?>
\ No newline at end of file
+?>
}
// Post process list adata
- while (list($k, $v) = each($list)) {
+ foreach ( $list as $k => $v ) {
// Addresses
$a = unserialize($v['addresses']);
if ( $start === 0 ) {
// Store all categories and collect the new IDs
reset( $cats );
- while ( list( $k, $c ) = each( $cats ) ) {
+ foreach ( $cats as $k => $c ) {
$sql = "
INSERT INTO ".GLM_MEMBERS_PLUGIN_DB_PREFIX."categories
( name, descr, short_descr, parent)
}
} else {
reset( $cats );
- while ( list( $k, $c ) = each( $cats ) ) {
+ foreach ( $cats as $k => $c ) {
$cats[$k]['new_id'] = $this->getCategoryIdByName( $c['name'] );
}
}
$distances = array();
$over_query_limit = false;
- while (list($k, $m) = each($members)) {
+ foreach ( $members as $k => $m ) {
$members[$k][$distance_field] = false;
$members[$k][$duration_field] = false;
-?>
\ No newline at end of file
+?>
}
// Add list entries
- while (list($k, $v) = each($f['list'])) {
+ foreach ( $f['list'] as $k => $v ) {
$list[$k] = array(
'name' => $v,
'nameEsc' => addslashes($v),
}
// Add list entries
- while (list($k, $v) = each($f['list'])) {
+ foreach ( $f['list'] as $k => $v ) {
$list[$k] = array(
'name' => $v,
'nameEsc' => addslashes($v),
// Build bitmap array
$bitmap = array();
$bitmapNames = array();
- while (list($k, $v) = each($f['bitmap'])) {
+ foreach ( $f['bitmap'] as $k => $v ) {
// If appropriate or requested, build picklists
if ($this->optionIncludeSelectListData || $forEdit || $alwaysList) {
// Build bitmap array
$bitmap = array();
$bitmapNames = array();
- while (list($k, $v) = each($f['bitmap'])) {
+ foreach ( $f['bitmap'] as $k => $v ) {
$bitmap[$k] = array(
'name' => $v,
'nameEsc' => addslashes($v),
if ((isset($_REQUEST[$as."_delete"]) && $_REQUEST[$as."_delete"] == 'on') || ($new && $current_img != false)) {
// Scan all the image size directories and remove this image
- while (list($k, $v) = each($this->config['imageSizes'])) {
+ foreach ( $this->config['imageSizes'] as $k => $v ) {
if (is_file(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$current_img)) {
unlink(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$current_img);
// Finally, move the files to the various size directories and rename them back to the correct name
reset($this->config['imageSizes']);
- while (list($k, $v) = each($this->config['imageSizes'])) {
+ foreach ( $this->config['imageSizes'] as $k => $v ) {
// Check if size directory needs to be made
if (!file_exists(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k)) {
// For each possible field
reset($this->fields);
- while (list($k, $v) = each($this->fields )) {
+ foreach ( $this->fields as $k => $v ) {
// If this field is selected for the current operation
if (isset($v['use']) && (strstr($v['use'], $op) || strstr($v['use'], 'a'))) {
// For each possible field
reset($this->fields);
- while (list($k, $v) = each($this->fields )) {
+ foreach ( $this->fields as $k => $v ) {
// If this field is selected for the current operation
if (isset($v['use']) && (strstr($v['use'], $op) || strstr($v['use'], 'a'))) {
// For each possible field
reset($this->fields);
- while (list($k, $v) = each($this->fields )) {
+ foreach ( $this->fields as $k => $v ) {
// Assume field will be OK
$this->inputFieldStatus = true;
$newList = array();
// Process field output data for each result - use ID field as key
- while (list($k, $v) = each($list)) {
+ foreach ( $list as $k => $v ) {
$newList[$v['id']] = $this->processOutputData($v, 'l');
}
$newName = preg_replace('/\d{10}/', time(), $newData[$f]);
// For each image size
- while (list($k, $v) = each($this->config['imageSizes'])) {
+ foreach ( $this->config['imageSizes'] as $k => $v ) {
// Check if we have that size for the original image, then copy it to the new name
if (file_exists(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$newData[$f])) {
$sep = '';
reset($r['fieldStore']);
- while (list($k, $v) = each($r['fieldStore'])) {
+ foreach ( $r['fieldStore'] as $k => $v ) {
$fields .= $sep." $k";
$vals .= $sep." $v";
$sep = ",\n";
// Check for 'view_only' fields
reset($this->fields);
- while (list($k, $v) = each($this->fields )) {
+ foreach ( $this->fields as $k => $v ) {
if (isset($v['view_only']) && $v['view_only']) {
reset($r['fieldStore']);
// Build list of fields that get updated
- while (list($k, $v) = each($r['fieldStore'])) {
+ foreach ( $r['fieldStore'] as $k => $v ) {
// Determine if the field is supposed to be updated when blank;
$noUpdateWhenBlank = (isset($this->fields[$k]['no_update_when_blank']) && $this->fields[$k]['no_update_when_blank']);
// Finally, move the files to the various size directories and rename them back to the correct name
reset ($this->config['imageSizes']);
- while (list($k, $v) = each($this->config['imageSizes'])) {
+ foreach ( $this->config['imageSizes'] as $k => $v ) {
// Check if size directory needs to be made
if (!file_exists(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k)) {
// If we have categories, add "selected" element default false;
if (is_array($categories2)) {
reset($categories2);
- while (list($k, $v) = each($categories2)) {
+ foreach ( $categories2 as $k => $v ) {
$categories2[$k]['selected'] = false;
}
}
// If we have categories, add "selected" element default false;
if (is_array($categories)) {
reset($categories);
- while (list($k, $v) = each($categories)) {
+ foreach ( $categories as $k => $v ) {
$categories[$k]['selected'] = false;
}
}
// If we're setting all
if ($s == 'all') {
- while (list($key, $val) = each($GLOBALS['showOpts'])) {
+ foreach ( $GLOBALS['showOpts'] as $key => $val ) {
$settings[$val] = true;
}
// Or we're clearing all
} elseif ($s == 'none') {
- while (list($key, $val) = each($GLOBALS['showOpts'])) {
+ foreach ( $GLOBALS['showOpts'] as $key => $val ) {
$settings[$val] = false;
}
// If we're setting all
if ($s == 'all') {
- while (list($key, $val) = each($GLOBALS['showOpts'])) {
+ foreach ( $GLOBALS['showOpts'] as $key => $val ) {
$settings[$val] = true;
}
// Or we're clearing all
} elseif ($s == 'none') {
- while (list($key, $val) = each($GLOBALS['showOpts'])) {
+ foreach ( $GLOBALS['showOpts'] as $key => $val ) {
$settings[$val] = false;
}
$regionsRequested = explode( ',', $actionData['request']['region-search'] );
// Check for numeric ID's only
- while ( list( $k, $v ) = each( $regionsRequested ) ) {
+ foreach ( $regionsRequested as $k => $v ) {
if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) {
$regions[] = ( $v - 0 );
}
$regionsRequested = explode( ',', $actionData['request']['county-search'] );
// Check for numeric ID's only
- while ( list( $k, $v ) = each( $regionsRequested ) ) {
+ foreach ( $regionsRequested as $k => $v ) {
if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) {
$counties[] = ( $v - 0 );
}
$citiesRequested = explode( ',', $actionData['request']['city-search'] );
// Check for numeric ID's only
- while ( list( $k, $v ) = each( $citiesRequested ) ) {
+ foreach ( $citiesRequested as $k => $v ) {
if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) {
$cities[] = ( $v - 0 );
}
$typesRequested = explode(',', $actionData['request']['type']);
// Check for numeric IDs only
- while (list($k, $v) = each($typesRequested)) {
+ foreach ( $typesRequested as $k => $v ) {
// If it's just numeric - note Explode returns an array element with value = 0 if no string.
if (preg_match('/^[0-9]*$/', trim($v)) && $v > 0) {
$catsRequested = explode(',', $actionData['request']['category']);
// Check for numeric IDs only
- while (list($k, $v) = each($catsRequested)) {
+ foreach ( $catsRequested as $k => $v ) {
// If it's just numeric - note Explode returns an array element with value = 0 if no string.
if (preg_match('/^[0-9]*$/', trim($v)) && $v > 0) {
$catsRequested = explode('|', $actionData['request']['category-name']);
// Check for numeric or text selection of categories
- while (list($k, $v) = each($catsRequested)) {
+ foreach ( $catsRequested as $k => $v ) {
$vStripped = html_entity_decode(stripslashes(trim($v)));
// Add ['default'] value to all categories
reset($categoryData);
- while (list($k, $v) = each($categoryData)) {
+ foreach ( $categoryData as $k => $v ) {
$categoryData[$k]['default'] = false;
}
*/
$parentSelected = false;
reset($categoryData);
- while (list($k, $v) = each($categoryData)) {
+ foreach ( $categoryData as $k => $v ) {
// If this is a parent, then clear parent selected
if ($v['parent_id'] != $parentSelected) {