In order to make use of this plugin, you are going to need a Google API Key. Click on the settings icon on the top toolbar to get and enter your Google API credentials."; } else { $api_url = "https://www.googleapis.com/webfonts/v1/webfonts?key="; $api_data = wp_remote_get($api_url . $google_api_key); //return codes if valid or not if($api_data['response']['code'] !== 200){ $errors = true; echo "

Oops! It appears that your Google API Key is incorrect or invalid. Click on the settings icon on the top toolbar and update your Google API credentials.

"; } } echo '
'; // display error message to users if ( version_compare( phpversion(), '5.2', '<' ) ) { $errors = true; echo "

Sorry, this function requires PHP 5.2 or higher. Please check with your site administrator.

"; } if(!function_exists("json_decode")){ $errors = true; echo "

Sorry, this function requires PHP json_decode() function. Please check with your site administrator.

"; } echo '
'; //if no errors, get the content if(!$errors) : // transient caching if ( false === ( $font_list = get_transient( 'wp_googlefontmgr_manager_cache' ) ) ) { $api_data = wp_remote_get($api_url . $google_api_key); $response = $api_data['response']; $body = json_decode($api_data['body'], true); if(200 === $response['code']){ $font_list = $body; set_transient( 'wp_googlefontmgr_manager_cache', $font_list, 60*60*12 ); } } if(isset($font_list) && count($font_list) == 0){ echo "Error: Can not connect to Google Web Fonts API, please double check your API Key and Try Again!"; } else { //load font styles $fontselectdrop = ""; $fontdata = get_option("wp_googlefontmgr_fonts"); if($fontdata) { //load fonts for use in plugin $array = explode(",", $fontdata); foreach($array as $value) { $cssname = "google-font-manager-" .strtolower(str_replace(" ", "-", $value)); wp_enqueue_style($cssname,'//fonts.googleapis.com/css?family='.$value); $fontselectdrop .='
  • ' .$value. '
  • '; } } //echo get_option("wp_googlefontmgr_styleopts", ""); ?>
    Selected Fonts
    Preview Fonts
    Default styles
    How to Use

    Fonts applied to your website:

    You have not added any fonts to this template yet. You may add up to five custom fonts for use in any template. Use the form located on the right to select the fonts you want to add. Click the preview tab to browse through available fonts and see what each one looks like.

    "; } else { $array = explode(",", $fontdata); foreach($array as $value) { echo '

    ' .$value. '

    Grumpy wizards make toxic brew for the evil Queen and Jack.

    '; } } ?>


    To preview what each font looks like, simply click on the font you want to view and the "font viewer tab" will open and display the characters for you. This allows you to see what the font will look like in action on your site.

    " . $font_name . ""; $autocomplete .= '"' .$font_name. '",'; $font_name = str_replace(" ", "-", $font['family']); } echo '
    '; echo $google_fontlist; echo '
    '; ?>