public function render_content() { if (self::$firstLoad) { self::$firstLoad = false; TitanFrameworkOptionSelectGooglefont::createScript(); } // set a default value $value = $this->value(); if ($value == array() || empty($value)) { $value = serialize(array('name' => 'Open Sans', 'variants' => array('400'), 'subsets' => array('latin'))); } $allFonts = titan_get_googlefonts(); ?> <script> jQuery(document).ready(function($) { setTimeout( function() { jQuery('input[data-customize-setting-link=<?php echo $this->id; ?> ]').val('<?php echo serialize($value); ?> '); }, 1 ); }); </script> <label> <span class="customize-control-title"><?php echo esc_html($this->label); ?> </span> <?php if (!empty($this->description)) { echo "<p class='description'>{$this->description}</p>"; } ?> <select class='tf-select-googlefont'> <?php foreach ($allFonts as $key => $fontStuff) { printf("<option value='%s' data-subset='%s' data-variants='%s'>%s</option>", esc_attr($key), esc_attr(json_encode($fontStuff['subsets'])), esc_attr(json_encode($fontStuff['variants'])), $fontStuff['name']); } ?> </select> <?php // select variants echo "<p class='description tf-variants'>Choose the styles to include:</p>"; echo "<fieldset class='tf-googlefont-area'>"; $allVariants = array('100', '100italic', '200', '200italic', '300', '300italic', '400', 'italic', '500', '500italic', '600', '600italic', '700', '700italic', '800', '800italic', '900', '900italic'); foreach ($allVariants as $key => $variant) { printf("<label style='display: none'><input type='checkbox' class='variant' data-variant='%s'/> %s</label>", esc_attr($variant), TitanFrameworkOptionSelectGooglefont::getVariantName($variant)); } echo "</fieldset>"; // select charsets echo "<p class='description tf-subsets'>Choose the subsets to include:</p>"; echo "<fieldset class='tf-googlefont-area'>"; $allSubsets = array("latin", "latin-ext", "greek", "vietnamese", "cyrillic", "cyrillic-ext", "khmer", "greek-ext"); foreach ($allSubsets as $key => $subset) { printf("<label style='display: none'><input type='checkbox' class='subset' data-subset='%s'/> %s</label>", esc_attr($subset), $subset); } echo "</fieldset>"; if (!is_serialized($value)) { $value = serialize($value); } ?> <input type='hidden' <?php $this->link(); ?> value='<?php echo esc_attr($value); ?> '/> </label> <?php }