plugin_url = $adminPress->plugin_url;
$this->plugin_dir = $adminPress->plugin_dir;
$this->version = $adminPress->version;
$this->options = $adminPress->options;
$this->google_fonts = $this->wp_get_google_webfonts_list( 'alpha' );
}
add_filter( 'adminpress_form', array( $this, 'style_form' ), 11 );
}
/*
* Load google fonts
*/
public function wp_get_google_webfonts_list( $sort='' ) {
/*
$key = Web Fonts Developer API
$sort=
alpha: Sort the list alphabetically
date: Sort the list by date added (most recent font added or updated first)
popularity: Sort the list by popularity (most popular family first)
style: Sort the list by number of styles available (family with most styles first)
trending: Sort the list by families seeing growth in usage (family seeing the most growth first)
*/
if( isset( $this->options['google_api'] ) && $this->options['google_api'] != '' ) {
$key = $this->options['google_api'];
$http = (!empty($_SERVER['HTTPS'])) ? "https" : "http";
$google_api_url = 'https://www.googleapis.com/webfonts/v1/webfonts?key=' . $key . '&sort=' . $sort;
//lets fetch it
$response = wp_remote_get($google_api_url, array('sslverify' => false ));
$data = json_decode($response['body'], true);
$items = $data['items'];
$font_list = array();
foreach ($items as $item) {
$font_list[] .= $item['family'];
}
//Return the saved lit of Google Web Fonts
return $font_list;
}
else {
return array();
}
}
/*
* Form module for main style
*/
public function style_form( $form ) {
ob_start();
?>