Skip to content

Commit

Permalink
fix: replace array_map with array_walk
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloiankoski committed Oct 17, 2023
1 parent 0730a3b commit 910e402
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,12 @@ public function register_block() {
* @return string;
*/
public function render_block( $attributes ) {
$ids = $this->getAsArray($attributes['formIDs']);
array_walk($ids, '_give_redirect_form_id');

$parameters = array(
'forms_per_page' => absint( $attributes['formsPerPage'] ),
'ids' => implode(',',
array_map('_give_redirect_form_id', $this->getAsArray($attributes['formIDs']))
),
'ids' => implode(',', $ids),
'exclude' => implode(',', $this->getAsArray($attributes['excludedFormIDs'] ) ),
'orderby' => $attributes['orderBy'],
'order' => $attributes['order'],
Expand Down
6 changes: 3 additions & 3 deletions blocks/donor-wall/class-give-donor-wall.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ public function register_block() {
*/
public function render_block( $attributes ) {
$avatarSize = absint( $attributes['avatarSize'] );
$ids = $this->getAsArray($attributes['formID']);
array_walk($ids, '_give_redirect_form_id');

$parameters = [
'donors_per_page' => absint( $attributes['donorsPerPage'] ),
'form_id' => implode(',',
array_map('_give_redirect_form_id', $this->getAsArray($attributes['formID']))
),
'form_id' => implode(',', $ids),
'ids' => implode(',', $this->getAsArray($attributes['ids'] ) ),
'cats' => implode(',', $this->getAsArray($attributes['categories'] ) ),
'tags' => implode(',', $this->getAsArray($attributes['tags'] ) ),
Expand Down
4 changes: 3 additions & 1 deletion includes/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,9 @@ function give_form_grid_shortcode( $atts ) {

// Maybe filter forms by IDs.
if ( ! empty( $atts['ids'] ) ) {
$form_args['post__in'] = array_map('_give_redirect_form_id', array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) ) );
$ids = array_filter(array_map('trim', explode(',', $atts['ids'])));
array_walk($ids, '_give_redirect_form_id');
$form_args['post__in'] = $ids;
}

// Convert comma-separated form IDs into array.
Expand Down
4 changes: 3 additions & 1 deletion src/MultiFormGoals/MultiFormGoal/Shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ public function renderCallback($attributes)
'give_multi_form_goal'
);

array_walk($attributes['ids'], '_give_redirect_form_id');

$multiFormGoal = new MultiFormGoal(
[
'ids' => array_map('_give_redirect_form_id', $attributes['ids']),
'ids' => $attributes['ids'],
'tags' => $attributes['tags'],
'categories' => $attributes['categories'],
'goal' => $attributes['goal'],
Expand Down
4 changes: 3 additions & 1 deletion src/MultiFormGoals/ProgressBar/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ public function addBlock()
**/
public function renderCallback($attributes)
{
array_walk($attributes['ids'], '_give_redirect_form_id');

$progressBar = new ProgressBar(
[
'ids' => array_map('_give_redirect_form_id', $attributes['ids']),
'ids' => $attributes['ids'],
'tags' => $attributes['tags'],
'categories' => $attributes['categories'],
'goal' => $attributes['goal'],
Expand Down

0 comments on commit 910e402

Please sign in to comment.