# gamipress/8.0.6/assets/js/gamipress-admin-functions.min.js

GamiPress – Gamification plugin to reward points, badges &amp; ranks in WordPress, now with AI, version 8.0.6. 48 lines.

- Page: https://pluginprobe.com/plugins/gamipress/8.0.6/code/assets/js/gamipress-admin-functions.min.js
- Raw: https://pluginprobe.com/plugins/gamipress/8.0.6/raw/assets/js/gamipress-admin-functions.min.js
- Modified: 2026-10-08T09:05:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/gamipress/8.0.6/code/assets/js/gamipress-admin-functions.min.js#L10-L20`.

```javascript
function gamipress_selector($this){if($this.closest('#available-widgets').length)
return;var select2_args={theme:'default gamipress-select2',placeholder:($this.data('placeholder')?$this.data('placeholder'):gamipress_admin_functions.selector_placeholder),allowClear:!0,multiple:($this[0].hasAttribute('multiple')),matcher:gamipress_select2_words_matcher,};$this.gamipress_select2(select2_args)}
function gamipress_post_selector($this){if($this.closest('#available-widgets').length)
return;var select2_args={ajax:{url:ajaxurl,dataType:'json',delay:250,type:'POST',data:function(params){return{q:params.term,page:params.page||1,action:($this.data('action')?$this.data('action'):'gamipress_get_posts'),nonce:gamipress_admin_functions.nonce,post_type:$this.data('post-type').split(','),}},processResults:gamipress_select2_posts_process_results},escapeMarkup:function(markup){return markup},templateResult:gamipress_select2_posts_template_result,theme:'default gamipress-select2',placeholder:($this.data('placeholder')?$this.data('placeholder'):gamipress_admin_functions.post_selector_placeholder),allowClear:!0,multiple:($this[0].hasAttribute('multiple')),matcher:gamipress_select2_words_matcher,};$this.gamipress_select2(select2_args)}
function gamipress_user_selector($this){if($this.closest('#available-widgets').length)
return;var select2_args={ajax:{url:ajaxurl,dataType:'json',delay:250,type:'POST',data:function(params){return{q:params.term,page:params.page||1,action:'gamipress_get_users',nonce:gamipress_admin_functions.nonce,}},processResults:gamipress_select2_users_process_results},escapeMarkup:function(markup){return markup},templateResult:gamipress_select2_users_template_result,theme:'default gamipress-select2',placeholder:($this.data('placeholder')?$this.data('placeholder'):gamipress_admin_functions.user_selector_placeholder),allowClear:!0,multiple:($this[0].hasAttribute('multiple')),matcher:gamipress_select2_words_matcher,};$this.gamipress_select2(select2_args)}
function gamipress_select2_destroy($this,clear_options=!1){$this.removeAttr('data-select2-id');$this.removeData('data-hash');$this.next('.select2').remove();if(clear_options){$this.find('option').remove()}}
function gamipress_select2_posts_template_result(item){if(item.post_parent_title!==undefined){return gamipress_select2_post_parent_template_result(item)}
if(item.post_type!==undefined){var post_type_label=item.post_type;if(gamipress_post_type_exists(item.post_type)){post_type_label=gamipress_get_post_type_label(item.post_type)}
return '<strong>'+item.post_title+'</strong>'+'<span class="result-description">'+'ID: '+item.ID+'<span class="align-right">'+post_type_label+'</span>'+(item.site_name!==undefined?' ('+item.site_name+')':'')+'</span>'}
return item.text}
function gamipress_select2_post_parent_template_result(item){if(item.post_parent_type!==undefined){var post_type_label=item.post_parent_type;if(item.post_parent_type==='points-type'){post_type_label=''}else if(gamipress_post_type_exists(item.post_parent_type)){post_type_label=gamipress_get_post_type_label(item.post_parent_type);post_type_label+=':'}
return '<strong>'+item.post_title+'</strong>'+'<span class="result-description">'+'ID: '+item.ID+'<span class="align-right">'+post_type_label+' '+item.post_parent_title+'</span>'+(item.site_name!==undefined?' ('+item.site_name+')':'')+'</span>'}
return item.text}
function gamipress_select2_posts_process_results(response,params){if(response===null){return{results:[]}}
var formatted_results=[];var results=(response.data.results!==undefined?response.data.results:response.data);results.forEach(function(item){formatted_results.push(jQuery.extend({id:item.ID,text:item.post_title+' (#'+item.ID+')',},item))});return{results:formatted_results,pagination:{more:(response.data.more_results!==undefined?response.data.more_results:!1)}}}
function gamipress_select2_users_template_result(item){if(item.display_name!==undefined){return '<strong>'+item.display_name+'</strong>'+'<span class="result-description">'+'ID: '+item.ID+' - '+item.user_email+' ('+item.user_login+')'+'</span>'}
return item.text}
function gamipress_select2_users_process_results(response,params){if(response===null){return{results:[]}}
var formatted_results=[];var results=(response.data.results!==undefined?response.data.results:response.data);results.forEach(function(item){formatted_results.push(jQuery.extend({id:item.ID,text:item.user_login+' (#'+item.ID+')',},item))});return{results:formatted_results,pagination:{more:(response.data.more_results!==undefined?response.data.more_results:!1)}}}
function gamipress_matches_by_word(text,term){text=text.toUpperCase();var words=term.toUpperCase().split(" ");var found=!0;for(var i=0;i<words.length;i++)
found=(found&&text.indexOf(words[i])>=0);return found}
function gamipress_select2_words_matcher(params,data){if(params.term===undefined||params.term.trim()==='')return data;if(gamipress_matches_by_word(data.text,params.term))return data;return null}
function gamipress_select2_optgroup_matcher(params,data){data.parentText=data.parentText||'';if(params.term===undefined||params.term.trim()==='')return data;if(data.children&&data.children.length>0){var match=jQuery.extend(!0,{},data);for(var c=data.children.length-1;c>=0;c--){var child=data.children[c];child.parentText+=data.parentText+" "+data.text;var matches=gamipress_select2_optgroup_matcher(params,child);if(matches==null){match.children.splice(c,1)}}
if(match.children.length>0){return match}
return gamipress_select2_optgroup_matcher(params,match)}
if(gamipress_matches_by_word((data.parentText+' '+data.text),params.term))return data;return null}
function gamipress_post_type_exists(post_type){return(gamipress_admin_functions.post_type_labels[post_type]!==undefined)}
function gamipress_get_post_type_label(post_type){var label='';if(gamipress_post_type_exists(post_type)){label=gamipress_admin_functions.post_type_labels[post_type]}
return label}
function gamipress_is_reserved_term(term){return(gamipress_admin_functions.reserved_terms.indexOf(term)!==-1)}
function gamipress_get_slug_error(slug,current_slug){if(/[^a-zA-Z0-9\-_]/.test(slug))
return gamipress_admin_functions.slug_error_special_char;if(slug.length>20)
return gamipress_admin_functions.slug_error_max_length;if(gamipress_post_type_exists(slug)&&slug!==current_slug)
return gamipress_admin_functions.slug_error_post_type.replace('%s',gamipress_get_post_type_label(slug));if(gamipress_is_reserved_term(slug))
return gamipress_admin_functions.slug_error_reserved_term;return ''}
function gamipress_download_csv(data,filename){var csv=gamipress_object_to_csv(data);gamipress_download_file(csv,filename,'csv')}
function gamipress_download_file(content,filename,extension,mime_type='',charset=''){if(mime_type===undefined||mime_type==='')
mime_type='text/'+extension;if(charset===undefined||charset==='')
charset='utf-8';var file=(filename.length?filename+'.'+extension:'file.'+extension);var blob=new Blob([content],{type:mime_type+';charset='+charset+';'});if(navigator.msSaveBlob){navigator.msSaveBlob(blob,file)}else{var link=document.createElement("a");link.style.visibility='hidden';if(link.download!==undefined){var url=URL.createObjectURL(blob);link.setAttribute("href",url);link.setAttribute("download",file);document.body.appendChild(link);link.click();document.body.removeChild(link)}}}
function gamipress_object_to_csv(obj){var array=typeof obj!=='object'?JSON.parse(obj):obj;var str='';for(var i=0;i<array.length;i++){var line='';for(var index in array[i]){if(line!==''){line+=','}
line+='"'+array[i][index]+'"'}
str+=line+'\r\n'}
return str}
function gamipress_get_url_param(url,param,default_value=!1){var results=new RegExp('[\?&]'+param+'=([^&#]*)').exec(url);return results[1]||default_value}
function gamipress_is_valid_url(url){var result=url.match(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g);return(result!==null)}
function gamipress_strip_scripts(s){var div=document.createElement('div');div.innerHTML=s;var scripts=div.getElementsByTagName('script');var i=scripts.length;while(i--){scripts[i].parentNode.removeChild(scripts[i])}
return div.innerHTML}
```
