diff --git a/includes/class-boldgrid-inspirations-deploy-api.php b/includes/class-boldgrid-inspirations-deploy-api.php index 1d0a07c..e4e4364 100644 --- a/includes/class-boldgrid-inspirations-deploy-api.php +++ b/includes/class-boldgrid-inspirations-deploy-api.php @@ -42,6 +42,32 @@ public function __construct( $configs ) { $this->configs = $configs; } + /** + * Get Screenshot. + * + * @param array $args + */ + public function get_screenshot( $args ) { + $api_url = $this->configs['asset_server'] . $this->configs['ajax_calls']['get_screenshot']; + + $remote_post_args = array( + 'method' => 'POST', + 'body' => $args, + 'timeout' => 20, + ); + + $response = wp_remote_retrieve_body( wp_remote_post( $api_url, $remote_post_args ) ); + $response = json_decode( $response ? $response : '', true ); + + if ( $response && ! empty( $response['result']['data']['asset_id'] ) ) { + $asset_id = $response['result']['data']['asset_id']; + $key = get_option( 'boldgrid_api_key' ); + $url = $this->configs['asset_server'] . '/api/asset/get?key=' . $key . '&id=' . $asset_id; + + update_option( 'boldgrid_site_screenshot', $url ); + } + } + /** * Get install options. * diff --git a/includes/class-boldgrid-inspirations-deploy.php b/includes/class-boldgrid-inspirations-deploy.php index 44e6ab1..39780ce 100644 --- a/includes/class-boldgrid-inspirations-deploy.php +++ b/includes/class-boldgrid-inspirations-deploy.php @@ -1822,6 +1822,25 @@ public function finish_deployment() { * may have added a Crio Premium service for the user. Delete license data so it can be refreshed. */ Boldgrid_Inspirations_Update::delete_license(); + + // Get a screenshot of the new site. + $this->get_screenshot(); + } + + /** + * Get the screenshot. + */ + public function get_screenshot() { + $site_url = get_site_url(); + + $api_key_hash = $this->asset_manager->api->get_api_key_hash(); + + $args = array( + 'site_url' => $site_url, + 'key' => $api_key_hash, + ); + + $this->api->get_screenshot( $args ); } /** diff --git a/includes/class-boldgrid-inspirations-my-inspiration.php b/includes/class-boldgrid-inspirations-my-inspiration.php index a1848a8..a926753 100644 --- a/includes/class-boldgrid-inspirations-my-inspiration.php +++ b/includes/class-boldgrid-inspirations-my-inspiration.php @@ -421,9 +421,13 @@ public function box_support() { * @since 1.7.0 */ public function box_theme() { - $theme = wp_get_theme(); ?> + $theme = wp_get_theme(); + $screenshot_url = get_option( 'boldgrid_site_screenshot', $theme->get_screenshot() ); + ?> + + -

+

'/api/build/get-install-details', 'get_build_profile_using_in_progress_theme' => '/api/build/get-using-in-progress-theme', 'get_generic' => '/api/build/get-generic', + 'get_screenshot' => '/api/build/get-screenshot', // Pde. 'get_curated' => '/api/pde/get-curated-asset', // Theme.