Server IP : 172.67.157.199 / Your IP : 3.145.155.45 [ Web Server : Apache System : Linux b70eb322-3aee-0c53-7c82-0db91281f2c6.secureserver.net 6.1.90-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 2 12:09:22 EDT 2024 x86_64 User : root ( 0) PHP Version : 8.0.30.2 Disable Function : NONE Domains : 0 Domains MySQL : ON | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/wp-content/themes/sammy/customize/assets/ |
Upload File : |
jQuery( document ).ready(function($) { "use strict"; /** * Googe Font Select Custom Control * * @author Anthony Hortin <http://maddisondesigns.com> * @license http://www.gnu.org/licenses/gpl-2.0.html * @link https://github.com/maddisondesigns */ $('.google-fonts-list').on('change', function() { var elementRegularWeight = $(this).parent().parent().find('.google-fonts-regularweight-style'); var selectedFont = $(this).val(); var customizerControlName = $(this).attr('control-name'); // Clear Weight/Style dropdowns elementRegularWeight.empty(); // Get the Google Fonts control object var bodyfontcontrol = _wpCustomizeSettings.controls[customizerControlName]; // Find the index of the selected font var indexes = $.map(bodyfontcontrol.ovafontslist, function(obj, index) { if(obj.family === selectedFont) { return index; } }); var index = indexes[0]; // For the selected Google font show the available weight/style variants $.each(bodyfontcontrol.ovafontslist[index].variants, function(val, text) { elementRegularWeight.append( $('<option></option>').val(text).html(text) ); }); // Update the font category based on the selected font $(this).parent().parent().find('.google-fonts-category').val(bodyfontcontrol.ovafontslist[index].category); ovaGetAllSelects($(this).parent().parent()); }); $('.google_fonts_select_control select').on('change', function() { ovaGetAllSelects($(this).parent().parent()); }); function ovaGetAllSelects($element) { var regularweight = $element.find('.google-fonts-regularweight-style').val(); if( regularweight != null ) regularweight = regularweight.join(); var selectedFont = { font: $element.find('.google-fonts-list').val(), regularweight: regularweight, category: $element.find('.google-fonts-category').val(), }; // Important! Make sure to trigger change event so Customizer knows it has to save the field $element.find('.customize-control-google-font-selection').val(JSON.stringify(selectedFont)).trigger('change'); } });