<?php

function popmake_available_extensions() {
	if(($extensions = get_site_transient('popup-maker-extension-list')) === false) {

		// data to send in our API request
		$api_params = array( 
			'edd_action'	=> 'extension_list', 
			'url'       => home_url()
		);
		// Call the custom API.
		$response = wp_remote_get( add_query_arg( $api_params, POPMAKE_API_URL ), array( 'timeout' => 15, 'sslverify' => false ) );

		// make sure the response came back okay
		if ( is_wp_error( $response ) )
			return array();

		$extensions = json_decode( wp_remote_retrieve_body( $response ) );
		set_site_transient( 'popup-maker-extension-list', $extensions, 86400 );
	}
	return $extensions;
}

add_filter('popmake_existing_extension_images', 'popmake_core_extension_images', 10);
function popmake_core_extension_images($array) {
	return array_merge($array, array(
		'unlimited-themes',
		'scroll-triggered-popups',
		'popup-analytics',
		'forced-interaction',
		'age-verification-modals',
		'advanced-theme-builder',
		'exit-intent-popups',
		'auto-open-popups',
		'ajax-login-modals',
	));
}
