Skip to content

Commit

Permalink
add kits call
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoladj77 committed Oct 10, 2024
1 parent d703f3b commit c0c9beb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions modules/admin/classes/rest/onboarding-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

class Onboarding_Settings {

const KITS_ENDPOINT = 'https://ms-8874.elementor.com/api/v1/kits-library/kits';

public function __construct() {

add_action(
Expand All @@ -28,6 +30,20 @@ function () {
);
}

public function get_kits() {
$kits = get_transient( 'e_hello_plus_kits' );

if ( ! $kits ) {
$kits = wp_remote_get( self::KITS_ENDPOINT );
$kits = wp_remote_retrieve_body( $kits );
$kits = json_decode( $kits, true );
$kits = array_slice( $kits, 0, 8 );
set_transient( 'e_hello_plus_kits', $kits, 24 * HOUR_IN_SECONDS );
}

return $kits;
}

public function get_onboarding_settings() {
$nonce = wp_create_nonce( 'updates' );

Expand All @@ -38,6 +54,7 @@ public function get_onboarding_settings() {
'elementorInstalled' => Utils::is_elementor_installed(),
'elementorActive' => Utils::is_elementor_active(),
'modalCloseRedirectUrl' => admin_url( 'admin.php?page=hello-plus' ),
'kits' => $this->get_kits(),
],
]
);
Expand Down

0 comments on commit c0c9beb

Please sign in to comment.