Skip to content

Commit db9764a

Browse files
emeaguiarravichdev
authored andcommitted
Retrieve available updates from backend
1 parent 33edb88 commit db9764a

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

assets/src/settings/constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ export const UPDATERS = {
2222
type: 'FONTS',
2323
lastUpdated: parseInt( getConfig( 'fontsLastUpdated' ), 10 ),
2424
needsKey: true,
25-
updateAvailable: false,
25+
updateAvailable: 'update' === getConfig( 'fontsUpdateStatus' ),
2626
autoUpdates: parseInt( getConfig( 'fontsAutoUpdate' ), 10 ),
2727
},
2828
ICONS: {
2929
title: __( 'Material Icons', 'material-design' ),
3030
type: 'ICONS',
3131
lastUpdated: parseInt( getConfig( 'iconsLastUpdated' ), 10 ),
3232
needsKey: false,
33-
updateAvailable: true,
33+
updateAvailable: 'update' === getConfig( 'iconsUpdateStatus' ),
3434
autoUpdates: parseInt( getConfig( 'iconsAutoUpdate' ), 10 ),
3535
},
3636
};

plugin/php/class-admin.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,16 +295,18 @@ public function enqueue_assets() {
295295
'material-settings',
296296
'materialDesignWizard',
297297
[
298-
'restPath' => esc_url( $this->plugin->onboarding_rest_controller->get_base_path() ),
299-
'redirect' => esc_url( admin_url( 'themes.php' ) ),
300-
'nonce' => wp_create_nonce( 'wp_rest' ),
301-
'themeStatus' => esc_html( $this->plugin->theme_status() ),
302-
'assetsRestPath' => esc_url( $this->plugin->assets_rest_controller->get_base_path() ),
303-
'apiStatus' => esc_html( $this->plugin->assets_rest_controller->get_api_status() ),
304-
'fontsLastUpdated' => esc_html( $this->plugin->assets_rest_controller->get_fonts_last_updated() ),
305-
'iconsLastUpdated' => esc_html( $this->plugin->assets_rest_controller->get_icons_last_updated() ),
306-
'fontsAutoUpdate' => esc_html( $this->plugin->assets_rest_controller->get_fonts_auto_update() ),
307-
'iconsAutoUpdate' => esc_html( $this->plugin->assets_rest_controller->get_icons_auto_update() ),
298+
'restPath' => esc_url( $this->plugin->onboarding_rest_controller->get_base_path() ),
299+
'redirect' => esc_url( admin_url( 'themes.php' ) ),
300+
'nonce' => wp_create_nonce( 'wp_rest' ),
301+
'themeStatus' => esc_html( $this->plugin->theme_status() ),
302+
'assetsRestPath' => esc_url( $this->plugin->assets_rest_controller->get_base_path() ),
303+
'apiStatus' => esc_html( $this->plugin->assets_rest_controller->get_api_status() ),
304+
'fontsLastUpdated' => esc_html( $this->plugin->assets_rest_controller->get_fonts_last_updated() ),
305+
'iconsLastUpdated' => esc_html( $this->plugin->assets_rest_controller->get_icons_last_updated() ),
306+
'fontsAutoUpdate' => esc_html( $this->plugin->assets_rest_controller->get_fonts_auto_update() ),
307+
'iconsAutoUpdate' => esc_html( $this->plugin->assets_rest_controller->get_icons_auto_update() ),
308+
'fontsUpdateStatus' => esc_html( $this->plugin->assets_rest_controller->get_fonts_update_status() ),
309+
'iconsUpdateStatus' => esc_html( $this->plugin->assets_rest_controller->get_icons_update_status() ),
308310
]
309311
);
310312
}

plugin/php/class-design-assets-rest-controller.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,24 @@ public function get_icons_auto_update() {
315315
return absint( get_option( Update_Icons::AUTO_UPDATE_SLUG ) );
316316
}
317317

318+
/**
319+
* Return auto update from database
320+
*
321+
* @return int Auto update option
322+
*/
323+
public function get_fonts_update_status() {
324+
return false === get_transient( Update_Fonts::TRANSIENT ) ? 'update' : 'ok';
325+
}
326+
327+
/**
328+
* Return auto update from database
329+
*
330+
* @return int Auto update option
331+
*/
332+
public function get_icons_update_status() {
333+
return false === get_transient( Update_Icons::TRANSIENT ) ? 'update' : 'ok';
334+
}
335+
318336
/**
319337
* Look for API in database.
320338
*

0 commit comments

Comments
 (0)