jQuery(document).ready(function($){ $(document).on('click', '#siteseo_validate_schema', function(e){ e.preventDefault(); // Fetch Schema var schemaContentWrap = $("#siteseo_schema_preview #raw_schema"); if(!schemaContentWrap.length){ schemaContentWrap = $("#siteseo_schema_preview"); } let schemaContent = schemaContentWrap.text(), $form = $("
", { "method": "POST", "action": "https://search.google.com/test/rich-results", "target": "_blank" }), $input = $("", { "type": "hidden", "name": "code_snippet", "value": schemaContent }); $form.append($input); $("body").append($form); $form.submit(); $form.remove(); }); $(document).on('change', '.siteseo_structured_data_type', function(e){ e.preventDefault(); let schemaType = $(this).val(), propertiesContainer = $('#siteseo_schema_properties_container'), customSchemaContainer = $('#siteseo_custom_schema_container'), propertiesDiv = $('.siteseo-schema-properties'); $('.siteseo_structured_data_type').val(schemaType); propertiesDiv.empty(); if(schemaType === ''){ propertiesContainer.addClass('hidden'); customSchemaContainer.addClass('hidden'); $('#siteseo_schema_preview').html(''); $('#raw_schema').text(''); return; } if(schemaType === 'CustomSchema'){ propertiesContainer.addClass('hidden'); customSchemaContainer.removeClass('hidden'); updateCustomSchemaPreview(); return; } else{ propertiesContainer.removeClass('hidden'); customSchemaContainer.addClass('hidden'); } // schemas load let properties = structuredDataMetabox.propertyTemplates[schemaType] || {}; // Create form fields for each property $.each(properties, function(property, defaultValue){ var label = property.replace(/([a-z])([A-Z])/g, '$1 $2'); label = label.charAt(0).toUpperCase() + label.slice(1); let field = '', is_textarea_fields = ['description', 'instructions', 'reviewBody', 'questions', 'step', 'ingredients', 'recipeInstructions', 'courseDescription', 'bookDescription', 'softwareRequirements', 'menu'], is_date_type_fields = ['datePublished', 'dateModified', 'uploadDate', 'startDate', 'endDate', 'foundingDate', 'releaseDate']; if(is_textarea_fields.includes(property)){ field = $('