Skip to content
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

Merged
merged 41 commits into from
May 15, 2024

Conversation

elchugreeva
Copy link
Contributor

No description provided.

$this->has_pro = Utils::has_pro();
}

private function valid_item( $item ) {
Copy link
Contributor

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] ) ) {
Copy link
Contributor

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] ) ) {
Copy link
Contributor

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 ) ) {
Copy link
Contributor

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 );
Copy link
Member

@hein-obox hein-obox May 15, 2024

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.

Suggested change
$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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return $home_screen_data;
return $home_screen_data;

@TzviRabinovitch TzviRabinovitch merged commit 95fd633 into elementor:main May 15, 2024
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants