jQuery(document).ready(function(a){if("undefined"!=typeof dina_related_posts_ajax){var e=a("#dina_related_posts");e.length&&(e.select2({placeholder:dina_related_posts_ajax.i18n.placeholder,minimumInputLength:3,allowClear:!0,multiple:!0,width:"100%",language:{inputTooShort:function(){return dina_related_posts_ajax.i18n.inputTooShort},noResults:function(){return dina_related_posts_ajax.i18n.noResults},searching:function(){return dina_related_posts_ajax.i18n.searching}},ajax:{url:dina_related_posts_ajax.ajaxurl,dataType:"json",delay:250,data:function(a){return{action:"dina_search_posts",q:a.term||"",exclude:e.data("exclude"),_ajax_nonce:dina_related_posts_ajax.nonce}},processResults:function(a){return Array.isArray(a)||(a=a.data||[]),{results:a.map(function(a){return{id:a.id,text:a.text}})}},cache:!0}}),e.on("select2:select",function(a){var t=a.params.data;if(!e.find('option[value="'+t.id+'"]').length){var n=new Option(t.text,t.id,!0,!0);e.append(n).trigger("change")}}))}});