-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internal: Enable different top section content for Free/Pro Users on the Home screen [ED-14519] #27301
Conversation
…the Home screen [ED-14519]
$this->has_pro = Utils::has_pro(); | ||
} | ||
|
||
private function valid_item( $item ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe is_valid_item ?
} | ||
|
||
public function transform( array $home_screen_data ): array { | ||
if ( is_array( $home_screen_data['top'] ) && count( $home_screen_data['top'] ) > 1 && is_array( $home_screen_data['top'][0] ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you reduce nesting ?
} | ||
|
||
public function transform( array $home_screen_data ): array { | ||
if ( is_array( $home_screen_data['top'] ) && count( $home_screen_data['top'] ) > 1 && is_array( $home_screen_data['top'][0] ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe extract this condition to a function that explains the check ?
$new_top = []; | ||
|
||
foreach ( $home_screen_data['top'] as $index => $item ) { | ||
if ( $this->valid_item( $item ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe extract this to a function that dies the check and pushes to the array if the check passed
} | ||
} | ||
|
||
$home_screen_data['top_with_licences'] = reset( $new_top ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the 'top' data.
And please check indentation.
$home_screen_data['top_with_licences'] = reset( $new_top ); | |
$home_screen_data['top_with_licences'] = reset( $new_top ); | |
unset( $home_screen_data['top'] ); |
|
||
$home_screen_data['top_with_licences'] = reset( $new_top ); | ||
|
||
return $home_screen_data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return $home_screen_data; | |
return $home_screen_data; |
No description provided.