Changeset 3227084
- Timestamp:
- 01/22/2025 08:37:28 PM (14 months ago)
- Location:
- searchwp-live-ajax-search
- Files:
-
- 26 deleted
- 10 edited
- 1 copied
-
tags/1.8.4 (copied) (copied from searchwp-live-ajax-search/trunk)
-
tags/1.8.4/.browserslistrc (deleted)
-
tags/1.8.4/.postcssrc (deleted)
-
tags/1.8.4/README.md (deleted)
-
tags/1.8.4/assets/gutenberg/src (deleted)
-
tags/1.8.4/assets/javascript/dist/script.js (modified) (12 diffs)
-
tags/1.8.4/assets/javascript/dist/script.min.js (modified) (1 diff)
-
tags/1.8.4/assets/javascript/src (deleted)
-
tags/1.8.4/banner-772x250.png (deleted)
-
tags/1.8.4/includes/class-template.php (modified) (2 diffs)
-
tags/1.8.4/package-lock.json (deleted)
-
tags/1.8.4/package.json (deleted)
-
tags/1.8.4/readme.txt (modified) (2 diffs)
-
tags/1.8.4/rollup.config.js (deleted)
-
tags/1.8.4/screenshot-1.png (deleted)
-
tags/1.8.4/screenshot-2.png (deleted)
-
tags/1.8.4/screenshot-3.png (deleted)
-
tags/1.8.4/screenshot-4.png (deleted)
-
tags/1.8.4/searchwp-live-ajax-search.php (modified) (3 diffs)
-
trunk/.browserslistrc (deleted)
-
trunk/.postcssrc (deleted)
-
trunk/README.md (deleted)
-
trunk/assets/gutenberg/src (deleted)
-
trunk/assets/javascript/dist/script.js (modified) (12 diffs)
-
trunk/assets/javascript/dist/script.min.js (modified) (1 diff)
-
trunk/assets/javascript/src (deleted)
-
trunk/banner-772x250.png (deleted)
-
trunk/includes/class-template.php (modified) (2 diffs)
-
trunk/package-lock.json (deleted)
-
trunk/package.json (deleted)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/rollup.config.js (deleted)
-
trunk/screenshot-1.png (deleted)
-
trunk/screenshot-2.png (deleted)
-
trunk/screenshot-3.png (deleted)
-
trunk/screenshot-4.png (deleted)
-
trunk/searchwp-live-ajax-search.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
searchwp-live-ajax-search/tags/1.8.4/assets/javascript/dist/script.js
r3168904 r3227084 30 30 top: '50%', 31 31 left: '50%', 32 shadow: '0 0 1px transparent', 32 shadow: '0 0 1px transparent', // prevent aliased lines 33 33 position: 'absolute', 34 34 }; … … 48 48 this.el.className = this.opts.className; 49 49 this.el.setAttribute('role', 'progressbar'); 50 css(this.el, { 51 position: this.opts.position, 52 width: 0, 53 zIndex: this.opts.zIndex, 54 left: this.opts.left, 55 top: this.opts.top, 56 transform: "scale(" + this.opts.scale + ")", 57 }); 50 this.el.style.position = this.opts.position; 51 this.el.style.width = "0"; 52 this.el.style.zIndex = this.opts.zIndex.toString(); 53 this.el.style.left = this.opts.left; 54 this.el.style.top = this.opts.top; 55 this.el.style.transform = "scale(".concat(this.opts.scale, ")"); 58 56 if (target) { 59 57 target.insertBefore(this.el, target.firstChild || null); … … 68 66 Spinner.prototype.stop = function () { 69 67 if (this.el) { 70 if (typeof requestAnimationFrame !== 'undefined') {71 cancelAnimationFrame(this.animateId);72 }73 else {74 clearTimeout(this.animateId);75 }76 68 if (this.el.parentNode) { 77 69 this.el.parentNode.removeChild(this.el); … … 83 75 return Spinner; 84 76 }()); 85 /**86 * Sets multiple style properties at once.87 */88 function css(el, props) {89 for (var prop in props) {90 el.style[prop] = props[prop];91 }92 return el;93 }94 77 /** 95 78 * Returns the line color from the given string or array. … … 113 96 for (var i = 0; i < opts.lines; i++) { 114 97 var degrees = ~~(360 / opts.lines * i + opts.rotate); 115 var backgroundLine = css(document.createElement('div'), { 116 position: 'absolute', 117 top: -opts.width / 2 + "px", 118 width: (opts.length + opts.width) + 'px', 119 height: opts.width + 'px', 120 background: getColor(opts.fadeColor, i), 121 borderRadius: borderRadius, 122 transformOrigin: 'left', 123 transform: "rotate(" + degrees + "deg) translateX(" + opts.radius + "px)", 124 }); 98 var backgroundLine = document.createElement('div'); 99 backgroundLine.style.position = 'absolute'; 100 backgroundLine.style.top = "".concat(-opts.width / 2, "px"); 101 backgroundLine.style.width = (opts.length + opts.width) + 'px'; 102 backgroundLine.style.height = opts.width + 'px'; 103 backgroundLine.style.background = getColor(opts.fadeColor, i); 104 backgroundLine.style.borderRadius = borderRadius; 105 backgroundLine.style.transformOrigin = 'left'; 106 backgroundLine.style.transform = "rotate(".concat(degrees, "deg) translateX(").concat(opts.radius, "px)"); 125 107 var delay = i * opts.direction / opts.lines / opts.speed; 126 108 delay -= 1 / opts.speed; // so initial animation state will include trail 127 var line = css(document.createElement('div'), { 128 width: '100%', 129 height: '100%', 130 background: getColor(opts.color, i), 131 borderRadius: borderRadius, 132 boxShadow: normalizeShadow(shadows, degrees), 133 animation: 1 / opts.speed + "s linear " + delay + "s infinite " + opts.animation, 134 }); 109 var line = document.createElement('div'); 110 line.style.width = '100%'; 111 line.style.height = '100%'; 112 line.style.background = getColor(opts.color, i); 113 line.style.borderRadius = borderRadius; 114 line.style.boxShadow = normalizeShadow(shadows, degrees); 115 line.style.animation = "".concat(1 / opts.speed, "s linear ").concat(delay, "s infinite ").concat(opts.animation); 135 116 backgroundLine.appendChild(line); 136 117 el.appendChild(backgroundLine); … … 160 141 } 161 142 shadows.push({ 162 prefix: matches[1] || '', 143 prefix: matches[1] || '', // could have value of 'inset' or undefined 163 144 x: x, 164 145 y: y, … … 270 251 271 252 // Set up and position the results' container. 272 var results_el_html = '<div aria-expanded="false" class="searchwp-live-search-results" id="' + this.results_id + '" role="listbox"tabindex="0"></div>';253 var results_el_html = '<div aria-expanded="false" class="searchwp-live-search-results" id="' + this.results_id + '" tabindex="0"></div>'; 273 254 274 255 // If parent_el was specified, inject the results el into it instead of appending it to the body. … … 277 258 // Specified as a data property on the html input. 278 259 this.parent_el = jQuery( swpparentel ); 279 this.parent_el. html( results_el_html );260 this.parent_el.append( results_el_html ); 280 261 } else if (this.config.parent_el) { 281 262 // Specified by the config set in php. 282 263 this.parent_el = jQuery( this.config.parent_el ); 283 this.parent_el. html( results_el_html );264 this.parent_el.append( results_el_html ); 284 265 } else { 285 266 // No parent, just append to the body. … … 335 316 // If the user typed, show the results wrapper and spinner. 336 317 self.position_results(); 337 self.results_el.addClass( 'searchwp-live-search-results-showing' ) ;318 self.results_el.addClass( 'searchwp-live-search-results-showing' ).attr( 'role', 'listbox' ); 338 319 self.show_spinner(); 339 320 self.results_showing = true; … … 474 455 475 456 position_results: function () { 476 var $input = this.input_el, 477 input_offset = $input.offset(), 478 $results = this.results_el, 479 results_top_offset = 0; 457 var $input = this.input_el, 458 $parent_form = $input.parents( 'form:eq(0)' ), 459 $results = this.results_el, 460 isGutenbergButtonInside = $parent_form.hasClass( 'wp-block-search__button-inside' ), 461 input_offset = {}, 462 results_top_offset = 0; 480 463 481 464 // Don't try to position a results element when the input field is hidden. … … 483 466 return; 484 467 } 468 469 // If this is a Gutenberg search block and the button is placed inside, we need to position the results relative to the form. 470 if ( isGutenbergButtonInside ) { 471 $input = $parent_form; 472 } 473 474 input_offset = $input.offset(); 485 475 486 476 // Check for an offset. … … 511 501 this.aria_expanded( false ); 512 502 this.results_el.empty().removeClass( 'searchwp-live-search-results-showing' ); 503 this.results_el.removeAttr( 'role' ); 513 504 this.results_showing = false; 514 505 this.has_results = false; -
searchwp-live-ajax-search/tags/1.8.4/assets/javascript/dist/script.min.js
r3168904 r3227084 1 !function(){"use strict";var e=window&&window.__assign||function(){return e=Object.assign||function(e){for(var t,s=1,i=arguments.length;s<i;s++)for(var r in t=arguments[s])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)},t={lines:12,length:7,width:5,radius:10,scale:1,corners:1,color:"#000",fadeColor:"transparent",animation:"spinner-line-fade-default",rotate:0,direction:1,speed:1,zIndex:2e9,className:"spinner",top:"50%",left:"50%",shadow:"0 0 1px transparent",position:"absolute"},s=function(){function s(s){void 0===s&&(s={}),this.opts=e(e({},t),s)}return s.prototype.spin=function(e){return this.stop(),this.el=document.createElement("div"),this.el.className=this.opts.className,this.el.setAttribute("role","progressbar"), i(this.el,{position:this.opts.position,width:0,zIndex:this.opts.zIndex,left:this.opts.left,top:this.opts.top,transform:"scale("+this.opts.scale+")"}),e&&e.insertBefore(this.el,e.firstChild||null),function(e,t){var s=Math.round(t.corners*t.width*500)/1e3+"px",a="none";!0===t.shadow?a="0 2px 4px #000":"string"==typeof t.shadow&&(a=t.shadow);for(var o=function(e){for(var t=/^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/,s=[],i=0,r=e.split(",");i<r.length;i++){var n=r[i].match(t);if(null!==n){var a=+n[2],o=+n[5],h=n[4],l=n[7];0!==a||h||(h=l),0!==o||l||(l=h),h===l&&s.push({prefix:n[1]||"",x:a,y:o,xUnits:h,yUnits:l,end:n[8]})}}return s}(a),h=0;h<t.lines;h++){var l=~~(360/t.lines*h+t.rotate),u=i(document.createElement("div"),{position:"absolute",top:-t.width/2+"px",width:t.length+t.width+"px",height:t.width+"px",background:r(t.fadeColor,h),borderRadius:s,transformOrigin:"left",transform:"rotate("+l+"deg) translateX("+t.radius+"px)"}),c=h*t.direction/t.lines/t.speed;c-=1/t.speed;var p=i(document.createElement("div"),{width:"100%",height:"100%",background:r(t.color,h),borderRadius:s,boxShadow:n(o,l),animation:1/t.speed+"s linear "+c+"s infinite "+t.animation});u.appendChild(p),e.appendChild(u)}}(this.el,this.opts),this},s.prototype.stop=function(){return this.el&&("undefined"!=typeof requestAnimationFrame?cancelAnimationFrame(this.animateId):clearTimeout(this.animateId),this.el.parentNode&&this.el.parentNode.removeChild(this.el),this.el=void 0),this},s}();function i(e,t){for(var s in t)e.style[s]=t[s];return e}function r(e,t){return"string"==typeof e?e:e[t%e.length]}function n(e,t){for(var s=[],i=0,r=e;i<r.length;i++){var n=r[i],o=a(n.x,n.y,t);s.push(n.prefix+o[0]+n.xUnits+" "+o[1]+n.yUnits+n.end)}return s.join(", ")}function a(e,t,s){var i=s*Math.PI/180,r=Math.sin(i),n=Math.cos(i);return[Math.round(1e3*(e*n+t*r))/1e3,Math.round(1e3*(-e*r+t*n))/1e3]}!function(){var e="searchwp_live_search";function t(e){this.config=null,this.input_el=e,this.results_id=null,this.results_el=null,this.parent_el=null,this.results_showing=!1,this.form_el=null,this.timer=!1,this.last_string="",this.spinner=null,this.spinner_showing=!1,this.has_results=!1,this.current_request=!1,this.results_destroy_on_blur=!0,this.a11y_keys=[27,40,13,38,9],this.init()}t.prototype={init:function(){var e=this,t=this.input_el;this.form_el=t.parents("form:eq(0)"),this.results_id=this.uniqid("searchwp_live_search_results_");var i=!1,r=t.data("swpconfig");if(r&&void 0!==r)for(var n in searchwp_live_search_params.config)r===n&&(i=!0,this.config=searchwp_live_search_params.config[n]);else for(var a in searchwp_live_search_params.config)"default"===a&&(i=!0,this.config=searchwp_live_search_params.config[a]);if(i){var o=t.data("swpengine");o||(o=this.config.engine),t.data("swpengine",o),t.attr("autocomplete","off"),t.attr("aria-owns",this.results_id),t.attr("aria-autocomplete","both"),t.attr("aria-label",searchwp_live_search_params.aria_instructions);var h='<div aria-expanded="false" class="searchwp-live-search-results" id="'+this.results_id+'" role="listbox" tabindex="0"></div>',l=t.data("swpparentel");l?(this.parent_el=jQuery(l),this.parent_el.html(h)):this.config.parent_el?(this.parent_el=jQuery(this.config.parent_el),this.parent_el.html(h)):jQuery("body").append(jQuery(h)),this.results_el=jQuery("#"+this.results_id),this.position_results(),jQuery(window).resize((function(){e.position_results()})),this.config.spinner&&(void 0===this.config.spinner.scale&&(this.config.spinner.scale=1),void 0===this.config.spinner.fadeColor&&(this.config.spinner.fadeColor="transparent"),void 0===this.config.spinner.animation&&(this.config.spinner.animation="searchwp-spinner-line-fade-quick"),void 0===this.config.spinner.position&&(this.config.spinner.position="absolute"),this.spinner=new s(this.config.spinner)),void 0===this.config.abort_on_enter&&(this.config.abort_on_enter=!0),t.keyup((function(t){jQuery.inArray(t.keyCode,e.a11y_keys)>-1||(e.current_request&&e.config.abort_on_enter&&13===t.keyCode&&e.current_request.abort(),jQuery.trim(e.input_el.val()).length?e.results_showing||(e.position_results(),e.results_el.addClass("searchwp-live-search-results-showing"),e.show_spinner(),e.results_showing=!0):e.destroy_results(),e.has_results&&!e.spinner_showing&&e.last_string!==jQuery.trim(e.input_el.val())&&(e.results_el.empty(),e.show_spinner()),t.currentTarget.value.length>=e.config.input.min_chars?e.results_el.removeClass("searchwp-live-search-no-min-chars"):e.results_el.addClass("searchwp-live-search-no-min-chars"),e.position_results())})).keyup(jQuery.proxy(this.maybe_search,this)),(this.config.results_destroy_on_blur||void 0===this.config.results_destroy_on_blur)&&jQuery("html").click((function(t){jQuery(t.target).parents(".searchwp-live-search-results").length||e.destroy_results()})),t.click((function(e){e.stopPropagation()}))}else alert(searchwp_live_search_params.msg_no_config_found)},keyboard_navigation:function(){var e=this,t=this.input_el,s=this.results_el,i="searchwp-live-search-result--focused",r=".searchwp-live-search-result",n=this.a11y_keys;jQuery(document).off("keyup.searchwp_a11y").on("keyup.searchwp_a11y",(function(a){if(s.hasClass("searchwp-live-search-results-showing")){if(-1!==jQuery.inArray(a.keyCode,n)){if(a.preventDefault(),27===a.keyCode)return e.destroy_results(),jQuery(document).off("keyup.searchwp_a11y"),t.focus(),void jQuery(document).trigger("searchwp_live_escape_results");if(40===a.keyCode){var o=jQuery(s[0]).find("."+i);1===o.length&&1===o.next().length?o.removeClass(i).attr("aria-selected","false").next().addClass(i).attr("aria-selected","true").find("a").focus():(o.removeClass(i).attr("aria-selected","false"),s.find(r+":first").addClass(i).attr("aria-selected","true").find("a").focus()),jQuery(document).trigger("searchwp_live_key_arrowdown_pressed")}if(38===a.keyCode){var h=jQuery(s[0]).find("."+i);1===h.length&&1===h.prev().length?h.removeClass(i).attr("aria-selected","false").prev().addClass(i).attr("aria-selected","true").find("a").focus():(h.removeClass(i).attr("aria-selected","false"),s.find(r+":last").addClass(i).attr("aria-selected","true").find("a").focus()),jQuery(document).trigger("searchwp_live_key_arrowup_pressed")}13===a.keyCode&&jQuery(document).trigger("searchwp_live_key_enter_pressed"),9===a.keyCode&&jQuery(document).trigger("searchwp_live_key_tab_pressed")}}else jQuery(document).off("keyup.searchwp_a11y")})),jQuery(document).trigger("searchwp_live_keyboad_navigation")},aria_expanded:function(e){var t=this.results_el;e?t.attr("aria-expanded","true"):t.attr("aria-expanded","false"),jQuery(document).trigger("searchwp_live_aria_expanded")},position_results:function(){var e=this.input_el,t=e.offset(),s=this.results_el,i=0;if(!e.is(":hidden")){if(t.left+=parseInt(this.config.results.offset.x,10),t.top+=parseInt(this.config.results.offset.y,10),"top"===this.config.results.position)i=0-s.height();else i=e.outerHeight();s.css("left",t.left),s.css("top",t.top+i+"px"),"auto"===this.config.results.width&&s.width(e.outerWidth()-parseInt(s.css("paddingRight").replace("px",""),10)-parseInt(s.css("paddingLeft").replace("px",""),10)),jQuery(document).trigger("searchwp_live_position_results",[s.css("left"),s.css("top"),s.width()])}},destroy_results:function(e){this.hide_spinner(),this.aria_expanded(!1),this.results_el.empty().removeClass("searchwp-live-search-results-showing"),this.results_showing=!1,this.has_results=!1,jQuery(document).trigger("searchwp_live_destroy_results")},maybe_search:function(e){jQuery.inArray(e.keyCode,this.a11y_keys)>-1||(clearTimeout(this.timer),e.currentTarget.value.length>=this.config.input.min_chars&&(this.current_request&&this.current_request.abort(),this.timer=setTimeout(jQuery.proxy(this.search,this,e),this.config.input.delay)))},show_spinner:function(){this.config.spinner&&!this.spinner_showing&&(this.spinner.spin(document.getElementById(this.results_id)),this.spinner_showing=!0,jQuery(document).trigger("searchwp_live_show_spinner"))},hide_spinner:function(){this.config.spinner&&(this.spinner.stop(),this.spinner_showing=!1,jQuery(document).trigger("searchwp_live_hide_spinner"))},search:function(e){var t=this,s=this.form_el,i=s.serialize(),r=s.attr("action")?s.attr("action"):"",n=this.input_el,a=this.results_el;jQuery(document).trigger("searchwp_live_search_start",[n,a,s,r,i]),this.aria_expanded(!1),i+="&action=searchwp_live_search&swpengine="+n.data("swpengine"),i+="&swpquery="+encodeURIComponent(n.val()),i+="&origin_id="+parseInt(searchwp_live_search_params.origin_id,10),-1!==r.indexOf("?")&&(r=r.split("?"),i+="&"+r[1]),this.last_string=n.val(),this.has_results=!0,this.current_request=jQuery.ajax({url:searchwp_live_search_params.ajaxurl,type:"GET",data:i,complete:function(){jQuery(document).trigger("searchwp_live_search_complete",[n,a,s,r,i]),t.spinner_showing=!1,this.current_request=!1,jQuery(document).trigger("searchwp_live_search_shutdown",[n,a,s,r,i])},success:function(e){0===e&&(e=""),jQuery(document).trigger("searchwp_live_search_success",[n,a,s,r,i]),a.html(e),t.position_results(),t.aria_expanded(!0),t.keyboard_navigation(),jQuery(document).trigger("searchwp_live_search_shutdown",[n,a,s,r,i])}})},uniqid:function(e,t){var s;void 0===e&&(e="");var i=function(e,t){return t<(e=parseInt(e,10).toString(16)).length?e.slice(e.length-t):t>e.length?new Array(t-e.length+1).join("0")+e:e};return this.php_js||(this.php_js={}),this.php_js.uniqidSeed||(this.php_js.uniqidSeed=Math.floor(123456789*Math.random())),this.php_js.uniqidSeed++,s=e,s+=i(parseInt((new Date).getTime()/1e3,10),8),s+=i(this.php_js.uniqidSeed,5),t&&(s+=(10*Math.random()).toFixed(8).toString()),s}},jQuery.fn[e]=function(s){return this.each((function(){jQuery.data(this,"plugin_"+e)||jQuery.data(this,"plugin_"+e,new t(jQuery(this)))})),this}}(),jQuery(document).ready((function(){"function"==typeof jQuery().searchwp_live_search&&(jQuery('input[data-swplive="true"]').searchwp_live_search(),"undefined"!=typeof _SEARCHWP_LIVE_AJAX_SEARCH_BLOCKS&&_SEARCHWP_LIVE_AJAX_SEARCH_BLOCKS&&jQuery("input.wp-block-search__input").each((function(){jQuery(this).attr("data-swpengine",_SEARCHWP_LIVE_AJAX_SEARCH_ENGINE),jQuery(this).attr("data-swpconfig",_SEARCHWP_LIVE_AJAX_SEARCH_CONFIG),jQuery(this).searchwp_live_search()})))}))}();1 !function(){"use strict";var e=window&&window.__assign||function(){return e=Object.assign||function(e){for(var t,s=1,i=arguments.length;s<i;s++)for(var r in t=arguments[s])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)},t={lines:12,length:7,width:5,radius:10,scale:1,corners:1,color:"#000",fadeColor:"transparent",animation:"spinner-line-fade-default",rotate:0,direction:1,speed:1,zIndex:2e9,className:"spinner",top:"50%",left:"50%",shadow:"0 0 1px transparent",position:"absolute"},s=function(){function s(s){void 0===s&&(s={}),this.opts=e(e({},t),s)}return s.prototype.spin=function(e){return this.stop(),this.el=document.createElement("div"),this.el.className=this.opts.className,this.el.setAttribute("role","progressbar"),this.el.style.position=this.opts.position,this.el.style.width="0",this.el.style.zIndex=this.opts.zIndex.toString(),this.el.style.left=this.opts.left,this.el.style.top=this.opts.top,this.el.style.transform="scale(".concat(this.opts.scale,")"),e&&e.insertBefore(this.el,e.firstChild||null),function(e,t){var s=Math.round(t.corners*t.width*500)/1e3+"px",n="none";!0===t.shadow?n="0 2px 4px #000":"string"==typeof t.shadow&&(n=t.shadow);for(var a=function(e){for(var t=/^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/,s=[],i=0,r=e.split(",");i<r.length;i++){var n=r[i].match(t);if(null!==n){var a=+n[2],o=+n[5],h=n[4],l=n[7];0!==a||h||(h=l),0!==o||l||(l=h),h===l&&s.push({prefix:n[1]||"",x:a,y:o,xUnits:h,yUnits:l,end:n[8]})}}return s}(n),o=0;o<t.lines;o++){var h=~~(360/t.lines*o+t.rotate),l=document.createElement("div");l.style.position="absolute",l.style.top="".concat(-t.width/2,"px"),l.style.width=t.length+t.width+"px",l.style.height=t.width+"px",l.style.background=i(t.fadeColor,o),l.style.borderRadius=s,l.style.transformOrigin="left",l.style.transform="rotate(".concat(h,"deg) translateX(").concat(t.radius,"px)");var u=o*t.direction/t.lines/t.speed;u-=1/t.speed;var c=document.createElement("div");c.style.width="100%",c.style.height="100%",c.style.background=i(t.color,o),c.style.borderRadius=s,c.style.boxShadow=r(a,h),c.style.animation="".concat(1/t.speed,"s linear ").concat(u,"s infinite ").concat(t.animation),l.appendChild(c),e.appendChild(l)}}(this.el,this.opts),this},s.prototype.stop=function(){return this.el&&(this.el.parentNode&&this.el.parentNode.removeChild(this.el),this.el=void 0),this},s}();function i(e,t){return"string"==typeof e?e:e[t%e.length]}function r(e,t){for(var s=[],i=0,r=e;i<r.length;i++){var a=r[i],o=n(a.x,a.y,t);s.push(a.prefix+o[0]+a.xUnits+" "+o[1]+a.yUnits+a.end)}return s.join(", ")}function n(e,t,s){var i=s*Math.PI/180,r=Math.sin(i),n=Math.cos(i);return[Math.round(1e3*(e*n+t*r))/1e3,Math.round(1e3*(-e*r+t*n))/1e3]}!function(){var e="searchwp_live_search";function t(e){this.config=null,this.input_el=e,this.results_id=null,this.results_el=null,this.parent_el=null,this.results_showing=!1,this.form_el=null,this.timer=!1,this.last_string="",this.spinner=null,this.spinner_showing=!1,this.has_results=!1,this.current_request=!1,this.results_destroy_on_blur=!0,this.a11y_keys=[27,40,13,38,9],this.init()}t.prototype={init:function(){var e=this,t=this.input_el;this.form_el=t.parents("form:eq(0)"),this.results_id=this.uniqid("searchwp_live_search_results_");var i=!1,r=t.data("swpconfig");if(r&&void 0!==r)for(var n in searchwp_live_search_params.config)r===n&&(i=!0,this.config=searchwp_live_search_params.config[n]);else for(var a in searchwp_live_search_params.config)"default"===a&&(i=!0,this.config=searchwp_live_search_params.config[a]);if(i){var o=t.data("swpengine");o||(o=this.config.engine),t.data("swpengine",o),t.attr("autocomplete","off"),t.attr("aria-owns",this.results_id),t.attr("aria-autocomplete","both"),t.attr("aria-label",searchwp_live_search_params.aria_instructions);var h='<div aria-expanded="false" class="searchwp-live-search-results" id="'+this.results_id+'" tabindex="0"></div>',l=t.data("swpparentel");l?(this.parent_el=jQuery(l),this.parent_el.append(h)):this.config.parent_el?(this.parent_el=jQuery(this.config.parent_el),this.parent_el.append(h)):jQuery("body").append(jQuery(h)),this.results_el=jQuery("#"+this.results_id),this.position_results(),jQuery(window).resize((function(){e.position_results()})),this.config.spinner&&(void 0===this.config.spinner.scale&&(this.config.spinner.scale=1),void 0===this.config.spinner.fadeColor&&(this.config.spinner.fadeColor="transparent"),void 0===this.config.spinner.animation&&(this.config.spinner.animation="searchwp-spinner-line-fade-quick"),void 0===this.config.spinner.position&&(this.config.spinner.position="absolute"),this.spinner=new s(this.config.spinner)),void 0===this.config.abort_on_enter&&(this.config.abort_on_enter=!0),t.keyup((function(t){jQuery.inArray(t.keyCode,e.a11y_keys)>-1||(e.current_request&&e.config.abort_on_enter&&13===t.keyCode&&e.current_request.abort(),jQuery.trim(e.input_el.val()).length?e.results_showing||(e.position_results(),e.results_el.addClass("searchwp-live-search-results-showing").attr("role","listbox"),e.show_spinner(),e.results_showing=!0):e.destroy_results(),e.has_results&&!e.spinner_showing&&e.last_string!==jQuery.trim(e.input_el.val())&&(e.results_el.empty(),e.show_spinner()),t.currentTarget.value.length>=e.config.input.min_chars?e.results_el.removeClass("searchwp-live-search-no-min-chars"):e.results_el.addClass("searchwp-live-search-no-min-chars"),e.position_results())})).keyup(jQuery.proxy(this.maybe_search,this)),(this.config.results_destroy_on_blur||void 0===this.config.results_destroy_on_blur)&&jQuery("html").click((function(t){jQuery(t.target).parents(".searchwp-live-search-results").length||e.destroy_results()})),t.click((function(e){e.stopPropagation()}))}else alert(searchwp_live_search_params.msg_no_config_found)},keyboard_navigation:function(){var e=this,t=this.input_el,s=this.results_el,i="searchwp-live-search-result--focused",r=".searchwp-live-search-result",n=this.a11y_keys;jQuery(document).off("keyup.searchwp_a11y").on("keyup.searchwp_a11y",(function(a){if(s.hasClass("searchwp-live-search-results-showing")){if(-1!==jQuery.inArray(a.keyCode,n)){if(a.preventDefault(),27===a.keyCode)return e.destroy_results(),jQuery(document).off("keyup.searchwp_a11y"),t.focus(),void jQuery(document).trigger("searchwp_live_escape_results");if(40===a.keyCode){var o=jQuery(s[0]).find("."+i);1===o.length&&1===o.next().length?o.removeClass(i).attr("aria-selected","false").next().addClass(i).attr("aria-selected","true").find("a").focus():(o.removeClass(i).attr("aria-selected","false"),s.find(r+":first").addClass(i).attr("aria-selected","true").find("a").focus()),jQuery(document).trigger("searchwp_live_key_arrowdown_pressed")}if(38===a.keyCode){var h=jQuery(s[0]).find("."+i);1===h.length&&1===h.prev().length?h.removeClass(i).attr("aria-selected","false").prev().addClass(i).attr("aria-selected","true").find("a").focus():(h.removeClass(i).attr("aria-selected","false"),s.find(r+":last").addClass(i).attr("aria-selected","true").find("a").focus()),jQuery(document).trigger("searchwp_live_key_arrowup_pressed")}13===a.keyCode&&jQuery(document).trigger("searchwp_live_key_enter_pressed"),9===a.keyCode&&jQuery(document).trigger("searchwp_live_key_tab_pressed")}}else jQuery(document).off("keyup.searchwp_a11y")})),jQuery(document).trigger("searchwp_live_keyboad_navigation")},aria_expanded:function(e){var t=this.results_el;e?t.attr("aria-expanded","true"):t.attr("aria-expanded","false"),jQuery(document).trigger("searchwp_live_aria_expanded")},position_results:function(){var e=this.input_el,t=e.parents("form:eq(0)"),s=this.results_el,i=t.hasClass("wp-block-search__button-inside"),r={},n=0;if(!e.is(":hidden")){if(i&&(e=t),(r=e.offset()).left+=parseInt(this.config.results.offset.x,10),r.top+=parseInt(this.config.results.offset.y,10),"top"===this.config.results.position)n=0-s.height();else n=e.outerHeight();s.css("left",r.left),s.css("top",r.top+n+"px"),"auto"===this.config.results.width&&s.width(e.outerWidth()-parseInt(s.css("paddingRight").replace("px",""),10)-parseInt(s.css("paddingLeft").replace("px",""),10)),jQuery(document).trigger("searchwp_live_position_results",[s.css("left"),s.css("top"),s.width()])}},destroy_results:function(e){this.hide_spinner(),this.aria_expanded(!1),this.results_el.empty().removeClass("searchwp-live-search-results-showing"),this.results_el.removeAttr("role"),this.results_showing=!1,this.has_results=!1,jQuery(document).trigger("searchwp_live_destroy_results")},maybe_search:function(e){jQuery.inArray(e.keyCode,this.a11y_keys)>-1||(clearTimeout(this.timer),e.currentTarget.value.length>=this.config.input.min_chars&&(this.current_request&&this.current_request.abort(),this.timer=setTimeout(jQuery.proxy(this.search,this,e),this.config.input.delay)))},show_spinner:function(){this.config.spinner&&!this.spinner_showing&&(this.spinner.spin(document.getElementById(this.results_id)),this.spinner_showing=!0,jQuery(document).trigger("searchwp_live_show_spinner"))},hide_spinner:function(){this.config.spinner&&(this.spinner.stop(),this.spinner_showing=!1,jQuery(document).trigger("searchwp_live_hide_spinner"))},search:function(e){var t=this,s=this.form_el,i=s.serialize(),r=s.attr("action")?s.attr("action"):"",n=this.input_el,a=this.results_el;jQuery(document).trigger("searchwp_live_search_start",[n,a,s,r,i]),this.aria_expanded(!1),i+="&action=searchwp_live_search&swpengine="+n.data("swpengine"),i+="&swpquery="+encodeURIComponent(n.val()),i+="&origin_id="+parseInt(searchwp_live_search_params.origin_id,10),-1!==r.indexOf("?")&&(r=r.split("?"),i+="&"+r[1]),this.last_string=n.val(),this.has_results=!0,this.current_request=jQuery.ajax({url:searchwp_live_search_params.ajaxurl,type:"GET",data:i,complete:function(){jQuery(document).trigger("searchwp_live_search_complete",[n,a,s,r,i]),t.spinner_showing=!1,this.current_request=!1,jQuery(document).trigger("searchwp_live_search_shutdown",[n,a,s,r,i])},success:function(e){0===e&&(e=""),jQuery(document).trigger("searchwp_live_search_success",[n,a,s,r,i]),a.html(e),t.position_results(),t.aria_expanded(!0),t.keyboard_navigation(),jQuery(document).trigger("searchwp_live_search_shutdown",[n,a,s,r,i])}})},uniqid:function(e,t){var s;void 0===e&&(e="");var i=function(e,t){return t<(e=parseInt(e,10).toString(16)).length?e.slice(e.length-t):t>e.length?new Array(t-e.length+1).join("0")+e:e};return this.php_js||(this.php_js={}),this.php_js.uniqidSeed||(this.php_js.uniqidSeed=Math.floor(123456789*Math.random())),this.php_js.uniqidSeed++,s=e,s+=i(parseInt((new Date).getTime()/1e3,10),8),s+=i(this.php_js.uniqidSeed,5),t&&(s+=(10*Math.random()).toFixed(8).toString()),s}},jQuery.fn[e]=function(s){return this.each((function(){jQuery.data(this,"plugin_"+e)||jQuery.data(this,"plugin_"+e,new t(jQuery(this)))})),this}}(),jQuery(document).ready((function(){"function"==typeof jQuery().searchwp_live_search&&(jQuery('input[data-swplive="true"]').searchwp_live_search(),"undefined"!=typeof _SEARCHWP_LIVE_AJAX_SEARCH_BLOCKS&&_SEARCHWP_LIVE_AJAX_SEARCH_BLOCKS&&jQuery("input.wp-block-search__input").each((function(){jQuery(this).attr("data-swpengine",_SEARCHWP_LIVE_AJAX_SEARCH_ENGINE),jQuery(this).attr("data-swpconfig",_SEARCHWP_LIVE_AJAX_SEARCH_CONFIG),jQuery(this).searchwp_live_search()})))}))}(); -
searchwp-live-ajax-search/tags/1.8.4/includes/class-template.php
r3168904 r3227084 404 404 public static function get_display_data( $result ) { 405 405 406 // During a multisite search, results can be from multiple blogs. 407 // If the result is from a different blog than the current one, we need to switch to that blog before fetching the result's data. 408 $switched_blog = self::maybe_switch_blog( $result ); 409 410 // Get the native entry for the result. 411 $result = self::maybe_get_native_entry( $result ); 412 406 413 /** 407 414 * Filter the result object. … … 474 481 $data = apply_filters( 'searchwp_live_search_results_entry_data', empty( $data ) ? $defaults : $data, $result ); 475 482 483 if ( $switched_blog ) { 484 restore_current_blog(); 485 } 486 476 487 // Make sure that default array structure is preserved. 477 488 return is_array( $data ) ? array_merge( $defaults, $data ) : $defaults; 489 } 490 491 /** 492 * Switch to the blog of the result. 493 * 494 * @since 1.8.4 495 * 496 * @param mixed $result Result object. 497 */ 498 private static function maybe_switch_blog( $result ) { 499 500 // Only switch to the blog if SearchWP is active. 501 if ( ! class_exists( 'SearchWP' ) ) { 502 return false; 503 } 504 505 if ( 506 $result instanceof \stdClass && 507 property_exists( $result, 'site' ) && 508 absint( $result->site ) !== get_current_blog_id() 509 ) { 510 switch_to_blog( absint( $result->site ) ); 511 512 return true; 513 } 514 515 return false; 516 } 517 518 /** 519 * Get the native entry of the result. 520 * 521 * @since 1.8.4 522 * 523 * @param mixed $result Result object. 524 * 525 * @return \WP_Post|\WP_User|\WP_Term|mixed 526 */ 527 private static function maybe_get_native_entry( $result ) { 528 529 // If SearchWP is not active, the result is already the native entry. 530 if ( ! class_exists( 'SearchWP\Entry' ) ) { 531 return $result; 532 } 533 534 if ( $result instanceof \stdClass && property_exists( $result, 'source' ) ) { 535 536 $id = absint( $result->id ); 537 538 if ( strpos( $result->source, 'post' . SEARCHWP_SEPARATOR ) === 0 ) { 539 $result = get_post( $id ); 540 } elseif ( strpos( $result->source, 'taxonomy' . SEARCHWP_SEPARATOR ) === 0 ) { 541 $result = get_term( $id ); 542 } elseif ( $result->source === 'user' ) { 543 $result = get_user_by( 'ID', $id ); 544 } 545 } elseif ( $result instanceof \SearchWP\Entry ) { 546 547 $result = $result->native(); 548 } 549 550 return $result; 478 551 } 479 552 -
searchwp-live-ajax-search/tags/1.8.4/readme.txt
r3168904 r3227084 4 4 Requires at least: 4.8 5 5 Tested up to: 6.5 6 Stable tag: 1.8. 36 Stable tag: 1.8.4 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 74 74 75 75 == Changelog == 76 77 = 1.8.4 = 78 * Adds support for SearchWP multisite search. 79 * Improves search results dropdown role attribute, for better accessibility. 80 * Adjust results width to match Gutenberg form width when the search button is inside. 81 * Fixes the display of the results dropdown within a custom parent element. 76 82 77 83 = 1.8.3 = -
searchwp-live-ajax-search/tags/1.8.4/searchwp-live-ajax-search.php
r3168904 r3227084 4 4 Plugin URI: https://searchwp.com/ 5 5 Description: Enhance your search forms with live search, powered by SearchWP (if installed) 6 Version: 1.8. 36 Version: 1.8.4 7 7 Requires PHP: 5.6 8 8 Author: SearchWP, LLC … … 11 11 Tested up to: 6.5 12 12 13 Copyright 2014-202 4SearchWP, LLC13 Copyright 2014-2025 SearchWP, LLC 14 14 15 15 This program is free software; you can redistribute it and/or … … 37 37 * @since 1.7.0 38 38 */ 39 define( 'SEARCHWP_LIVE_SEARCH_VERSION', '1.8. 3' );39 define( 'SEARCHWP_LIVE_SEARCH_VERSION', '1.8.4' ); 40 40 } 41 41 -
searchwp-live-ajax-search/trunk/assets/javascript/dist/script.js
r3168904 r3227084 30 30 top: '50%', 31 31 left: '50%', 32 shadow: '0 0 1px transparent', 32 shadow: '0 0 1px transparent', // prevent aliased lines 33 33 position: 'absolute', 34 34 }; … … 48 48 this.el.className = this.opts.className; 49 49 this.el.setAttribute('role', 'progressbar'); 50 css(this.el, { 51 position: this.opts.position, 52 width: 0, 53 zIndex: this.opts.zIndex, 54 left: this.opts.left, 55 top: this.opts.top, 56 transform: "scale(" + this.opts.scale + ")", 57 }); 50 this.el.style.position = this.opts.position; 51 this.el.style.width = "0"; 52 this.el.style.zIndex = this.opts.zIndex.toString(); 53 this.el.style.left = this.opts.left; 54 this.el.style.top = this.opts.top; 55 this.el.style.transform = "scale(".concat(this.opts.scale, ")"); 58 56 if (target) { 59 57 target.insertBefore(this.el, target.firstChild || null); … … 68 66 Spinner.prototype.stop = function () { 69 67 if (this.el) { 70 if (typeof requestAnimationFrame !== 'undefined') {71 cancelAnimationFrame(this.animateId);72 }73 else {74 clearTimeout(this.animateId);75 }76 68 if (this.el.parentNode) { 77 69 this.el.parentNode.removeChild(this.el); … … 83 75 return Spinner; 84 76 }()); 85 /**86 * Sets multiple style properties at once.87 */88 function css(el, props) {89 for (var prop in props) {90 el.style[prop] = props[prop];91 }92 return el;93 }94 77 /** 95 78 * Returns the line color from the given string or array. … … 113 96 for (var i = 0; i < opts.lines; i++) { 114 97 var degrees = ~~(360 / opts.lines * i + opts.rotate); 115 var backgroundLine = css(document.createElement('div'), { 116 position: 'absolute', 117 top: -opts.width / 2 + "px", 118 width: (opts.length + opts.width) + 'px', 119 height: opts.width + 'px', 120 background: getColor(opts.fadeColor, i), 121 borderRadius: borderRadius, 122 transformOrigin: 'left', 123 transform: "rotate(" + degrees + "deg) translateX(" + opts.radius + "px)", 124 }); 98 var backgroundLine = document.createElement('div'); 99 backgroundLine.style.position = 'absolute'; 100 backgroundLine.style.top = "".concat(-opts.width / 2, "px"); 101 backgroundLine.style.width = (opts.length + opts.width) + 'px'; 102 backgroundLine.style.height = opts.width + 'px'; 103 backgroundLine.style.background = getColor(opts.fadeColor, i); 104 backgroundLine.style.borderRadius = borderRadius; 105 backgroundLine.style.transformOrigin = 'left'; 106 backgroundLine.style.transform = "rotate(".concat(degrees, "deg) translateX(").concat(opts.radius, "px)"); 125 107 var delay = i * opts.direction / opts.lines / opts.speed; 126 108 delay -= 1 / opts.speed; // so initial animation state will include trail 127 var line = css(document.createElement('div'), { 128 width: '100%', 129 height: '100%', 130 background: getColor(opts.color, i), 131 borderRadius: borderRadius, 132 boxShadow: normalizeShadow(shadows, degrees), 133 animation: 1 / opts.speed + "s linear " + delay + "s infinite " + opts.animation, 134 }); 109 var line = document.createElement('div'); 110 line.style.width = '100%'; 111 line.style.height = '100%'; 112 line.style.background = getColor(opts.color, i); 113 line.style.borderRadius = borderRadius; 114 line.style.boxShadow = normalizeShadow(shadows, degrees); 115 line.style.animation = "".concat(1 / opts.speed, "s linear ").concat(delay, "s infinite ").concat(opts.animation); 135 116 backgroundLine.appendChild(line); 136 117 el.appendChild(backgroundLine); … … 160 141 } 161 142 shadows.push({ 162 prefix: matches[1] || '', 143 prefix: matches[1] || '', // could have value of 'inset' or undefined 163 144 x: x, 164 145 y: y, … … 270 251 271 252 // Set up and position the results' container. 272 var results_el_html = '<div aria-expanded="false" class="searchwp-live-search-results" id="' + this.results_id + '" role="listbox"tabindex="0"></div>';253 var results_el_html = '<div aria-expanded="false" class="searchwp-live-search-results" id="' + this.results_id + '" tabindex="0"></div>'; 273 254 274 255 // If parent_el was specified, inject the results el into it instead of appending it to the body. … … 277 258 // Specified as a data property on the html input. 278 259 this.parent_el = jQuery( swpparentel ); 279 this.parent_el. html( results_el_html );260 this.parent_el.append( results_el_html ); 280 261 } else if (this.config.parent_el) { 281 262 // Specified by the config set in php. 282 263 this.parent_el = jQuery( this.config.parent_el ); 283 this.parent_el. html( results_el_html );264 this.parent_el.append( results_el_html ); 284 265 } else { 285 266 // No parent, just append to the body. … … 335 316 // If the user typed, show the results wrapper and spinner. 336 317 self.position_results(); 337 self.results_el.addClass( 'searchwp-live-search-results-showing' ) ;318 self.results_el.addClass( 'searchwp-live-search-results-showing' ).attr( 'role', 'listbox' ); 338 319 self.show_spinner(); 339 320 self.results_showing = true; … … 474 455 475 456 position_results: function () { 476 var $input = this.input_el, 477 input_offset = $input.offset(), 478 $results = this.results_el, 479 results_top_offset = 0; 457 var $input = this.input_el, 458 $parent_form = $input.parents( 'form:eq(0)' ), 459 $results = this.results_el, 460 isGutenbergButtonInside = $parent_form.hasClass( 'wp-block-search__button-inside' ), 461 input_offset = {}, 462 results_top_offset = 0; 480 463 481 464 // Don't try to position a results element when the input field is hidden. … … 483 466 return; 484 467 } 468 469 // If this is a Gutenberg search block and the button is placed inside, we need to position the results relative to the form. 470 if ( isGutenbergButtonInside ) { 471 $input = $parent_form; 472 } 473 474 input_offset = $input.offset(); 485 475 486 476 // Check for an offset. … … 511 501 this.aria_expanded( false ); 512 502 this.results_el.empty().removeClass( 'searchwp-live-search-results-showing' ); 503 this.results_el.removeAttr( 'role' ); 513 504 this.results_showing = false; 514 505 this.has_results = false; -
searchwp-live-ajax-search/trunk/assets/javascript/dist/script.min.js
r3168904 r3227084 1 !function(){"use strict";var e=window&&window.__assign||function(){return e=Object.assign||function(e){for(var t,s=1,i=arguments.length;s<i;s++)for(var r in t=arguments[s])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)},t={lines:12,length:7,width:5,radius:10,scale:1,corners:1,color:"#000",fadeColor:"transparent",animation:"spinner-line-fade-default",rotate:0,direction:1,speed:1,zIndex:2e9,className:"spinner",top:"50%",left:"50%",shadow:"0 0 1px transparent",position:"absolute"},s=function(){function s(s){void 0===s&&(s={}),this.opts=e(e({},t),s)}return s.prototype.spin=function(e){return this.stop(),this.el=document.createElement("div"),this.el.className=this.opts.className,this.el.setAttribute("role","progressbar"), i(this.el,{position:this.opts.position,width:0,zIndex:this.opts.zIndex,left:this.opts.left,top:this.opts.top,transform:"scale("+this.opts.scale+")"}),e&&e.insertBefore(this.el,e.firstChild||null),function(e,t){var s=Math.round(t.corners*t.width*500)/1e3+"px",a="none";!0===t.shadow?a="0 2px 4px #000":"string"==typeof t.shadow&&(a=t.shadow);for(var o=function(e){for(var t=/^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/,s=[],i=0,r=e.split(",");i<r.length;i++){var n=r[i].match(t);if(null!==n){var a=+n[2],o=+n[5],h=n[4],l=n[7];0!==a||h||(h=l),0!==o||l||(l=h),h===l&&s.push({prefix:n[1]||"",x:a,y:o,xUnits:h,yUnits:l,end:n[8]})}}return s}(a),h=0;h<t.lines;h++){var l=~~(360/t.lines*h+t.rotate),u=i(document.createElement("div"),{position:"absolute",top:-t.width/2+"px",width:t.length+t.width+"px",height:t.width+"px",background:r(t.fadeColor,h),borderRadius:s,transformOrigin:"left",transform:"rotate("+l+"deg) translateX("+t.radius+"px)"}),c=h*t.direction/t.lines/t.speed;c-=1/t.speed;var p=i(document.createElement("div"),{width:"100%",height:"100%",background:r(t.color,h),borderRadius:s,boxShadow:n(o,l),animation:1/t.speed+"s linear "+c+"s infinite "+t.animation});u.appendChild(p),e.appendChild(u)}}(this.el,this.opts),this},s.prototype.stop=function(){return this.el&&("undefined"!=typeof requestAnimationFrame?cancelAnimationFrame(this.animateId):clearTimeout(this.animateId),this.el.parentNode&&this.el.parentNode.removeChild(this.el),this.el=void 0),this},s}();function i(e,t){for(var s in t)e.style[s]=t[s];return e}function r(e,t){return"string"==typeof e?e:e[t%e.length]}function n(e,t){for(var s=[],i=0,r=e;i<r.length;i++){var n=r[i],o=a(n.x,n.y,t);s.push(n.prefix+o[0]+n.xUnits+" "+o[1]+n.yUnits+n.end)}return s.join(", ")}function a(e,t,s){var i=s*Math.PI/180,r=Math.sin(i),n=Math.cos(i);return[Math.round(1e3*(e*n+t*r))/1e3,Math.round(1e3*(-e*r+t*n))/1e3]}!function(){var e="searchwp_live_search";function t(e){this.config=null,this.input_el=e,this.results_id=null,this.results_el=null,this.parent_el=null,this.results_showing=!1,this.form_el=null,this.timer=!1,this.last_string="",this.spinner=null,this.spinner_showing=!1,this.has_results=!1,this.current_request=!1,this.results_destroy_on_blur=!0,this.a11y_keys=[27,40,13,38,9],this.init()}t.prototype={init:function(){var e=this,t=this.input_el;this.form_el=t.parents("form:eq(0)"),this.results_id=this.uniqid("searchwp_live_search_results_");var i=!1,r=t.data("swpconfig");if(r&&void 0!==r)for(var n in searchwp_live_search_params.config)r===n&&(i=!0,this.config=searchwp_live_search_params.config[n]);else for(var a in searchwp_live_search_params.config)"default"===a&&(i=!0,this.config=searchwp_live_search_params.config[a]);if(i){var o=t.data("swpengine");o||(o=this.config.engine),t.data("swpengine",o),t.attr("autocomplete","off"),t.attr("aria-owns",this.results_id),t.attr("aria-autocomplete","both"),t.attr("aria-label",searchwp_live_search_params.aria_instructions);var h='<div aria-expanded="false" class="searchwp-live-search-results" id="'+this.results_id+'" role="listbox" tabindex="0"></div>',l=t.data("swpparentel");l?(this.parent_el=jQuery(l),this.parent_el.html(h)):this.config.parent_el?(this.parent_el=jQuery(this.config.parent_el),this.parent_el.html(h)):jQuery("body").append(jQuery(h)),this.results_el=jQuery("#"+this.results_id),this.position_results(),jQuery(window).resize((function(){e.position_results()})),this.config.spinner&&(void 0===this.config.spinner.scale&&(this.config.spinner.scale=1),void 0===this.config.spinner.fadeColor&&(this.config.spinner.fadeColor="transparent"),void 0===this.config.spinner.animation&&(this.config.spinner.animation="searchwp-spinner-line-fade-quick"),void 0===this.config.spinner.position&&(this.config.spinner.position="absolute"),this.spinner=new s(this.config.spinner)),void 0===this.config.abort_on_enter&&(this.config.abort_on_enter=!0),t.keyup((function(t){jQuery.inArray(t.keyCode,e.a11y_keys)>-1||(e.current_request&&e.config.abort_on_enter&&13===t.keyCode&&e.current_request.abort(),jQuery.trim(e.input_el.val()).length?e.results_showing||(e.position_results(),e.results_el.addClass("searchwp-live-search-results-showing"),e.show_spinner(),e.results_showing=!0):e.destroy_results(),e.has_results&&!e.spinner_showing&&e.last_string!==jQuery.trim(e.input_el.val())&&(e.results_el.empty(),e.show_spinner()),t.currentTarget.value.length>=e.config.input.min_chars?e.results_el.removeClass("searchwp-live-search-no-min-chars"):e.results_el.addClass("searchwp-live-search-no-min-chars"),e.position_results())})).keyup(jQuery.proxy(this.maybe_search,this)),(this.config.results_destroy_on_blur||void 0===this.config.results_destroy_on_blur)&&jQuery("html").click((function(t){jQuery(t.target).parents(".searchwp-live-search-results").length||e.destroy_results()})),t.click((function(e){e.stopPropagation()}))}else alert(searchwp_live_search_params.msg_no_config_found)},keyboard_navigation:function(){var e=this,t=this.input_el,s=this.results_el,i="searchwp-live-search-result--focused",r=".searchwp-live-search-result",n=this.a11y_keys;jQuery(document).off("keyup.searchwp_a11y").on("keyup.searchwp_a11y",(function(a){if(s.hasClass("searchwp-live-search-results-showing")){if(-1!==jQuery.inArray(a.keyCode,n)){if(a.preventDefault(),27===a.keyCode)return e.destroy_results(),jQuery(document).off("keyup.searchwp_a11y"),t.focus(),void jQuery(document).trigger("searchwp_live_escape_results");if(40===a.keyCode){var o=jQuery(s[0]).find("."+i);1===o.length&&1===o.next().length?o.removeClass(i).attr("aria-selected","false").next().addClass(i).attr("aria-selected","true").find("a").focus():(o.removeClass(i).attr("aria-selected","false"),s.find(r+":first").addClass(i).attr("aria-selected","true").find("a").focus()),jQuery(document).trigger("searchwp_live_key_arrowdown_pressed")}if(38===a.keyCode){var h=jQuery(s[0]).find("."+i);1===h.length&&1===h.prev().length?h.removeClass(i).attr("aria-selected","false").prev().addClass(i).attr("aria-selected","true").find("a").focus():(h.removeClass(i).attr("aria-selected","false"),s.find(r+":last").addClass(i).attr("aria-selected","true").find("a").focus()),jQuery(document).trigger("searchwp_live_key_arrowup_pressed")}13===a.keyCode&&jQuery(document).trigger("searchwp_live_key_enter_pressed"),9===a.keyCode&&jQuery(document).trigger("searchwp_live_key_tab_pressed")}}else jQuery(document).off("keyup.searchwp_a11y")})),jQuery(document).trigger("searchwp_live_keyboad_navigation")},aria_expanded:function(e){var t=this.results_el;e?t.attr("aria-expanded","true"):t.attr("aria-expanded","false"),jQuery(document).trigger("searchwp_live_aria_expanded")},position_results:function(){var e=this.input_el,t=e.offset(),s=this.results_el,i=0;if(!e.is(":hidden")){if(t.left+=parseInt(this.config.results.offset.x,10),t.top+=parseInt(this.config.results.offset.y,10),"top"===this.config.results.position)i=0-s.height();else i=e.outerHeight();s.css("left",t.left),s.css("top",t.top+i+"px"),"auto"===this.config.results.width&&s.width(e.outerWidth()-parseInt(s.css("paddingRight").replace("px",""),10)-parseInt(s.css("paddingLeft").replace("px",""),10)),jQuery(document).trigger("searchwp_live_position_results",[s.css("left"),s.css("top"),s.width()])}},destroy_results:function(e){this.hide_spinner(),this.aria_expanded(!1),this.results_el.empty().removeClass("searchwp-live-search-results-showing"),this.results_showing=!1,this.has_results=!1,jQuery(document).trigger("searchwp_live_destroy_results")},maybe_search:function(e){jQuery.inArray(e.keyCode,this.a11y_keys)>-1||(clearTimeout(this.timer),e.currentTarget.value.length>=this.config.input.min_chars&&(this.current_request&&this.current_request.abort(),this.timer=setTimeout(jQuery.proxy(this.search,this,e),this.config.input.delay)))},show_spinner:function(){this.config.spinner&&!this.spinner_showing&&(this.spinner.spin(document.getElementById(this.results_id)),this.spinner_showing=!0,jQuery(document).trigger("searchwp_live_show_spinner"))},hide_spinner:function(){this.config.spinner&&(this.spinner.stop(),this.spinner_showing=!1,jQuery(document).trigger("searchwp_live_hide_spinner"))},search:function(e){var t=this,s=this.form_el,i=s.serialize(),r=s.attr("action")?s.attr("action"):"",n=this.input_el,a=this.results_el;jQuery(document).trigger("searchwp_live_search_start",[n,a,s,r,i]),this.aria_expanded(!1),i+="&action=searchwp_live_search&swpengine="+n.data("swpengine"),i+="&swpquery="+encodeURIComponent(n.val()),i+="&origin_id="+parseInt(searchwp_live_search_params.origin_id,10),-1!==r.indexOf("?")&&(r=r.split("?"),i+="&"+r[1]),this.last_string=n.val(),this.has_results=!0,this.current_request=jQuery.ajax({url:searchwp_live_search_params.ajaxurl,type:"GET",data:i,complete:function(){jQuery(document).trigger("searchwp_live_search_complete",[n,a,s,r,i]),t.spinner_showing=!1,this.current_request=!1,jQuery(document).trigger("searchwp_live_search_shutdown",[n,a,s,r,i])},success:function(e){0===e&&(e=""),jQuery(document).trigger("searchwp_live_search_success",[n,a,s,r,i]),a.html(e),t.position_results(),t.aria_expanded(!0),t.keyboard_navigation(),jQuery(document).trigger("searchwp_live_search_shutdown",[n,a,s,r,i])}})},uniqid:function(e,t){var s;void 0===e&&(e="");var i=function(e,t){return t<(e=parseInt(e,10).toString(16)).length?e.slice(e.length-t):t>e.length?new Array(t-e.length+1).join("0")+e:e};return this.php_js||(this.php_js={}),this.php_js.uniqidSeed||(this.php_js.uniqidSeed=Math.floor(123456789*Math.random())),this.php_js.uniqidSeed++,s=e,s+=i(parseInt((new Date).getTime()/1e3,10),8),s+=i(this.php_js.uniqidSeed,5),t&&(s+=(10*Math.random()).toFixed(8).toString()),s}},jQuery.fn[e]=function(s){return this.each((function(){jQuery.data(this,"plugin_"+e)||jQuery.data(this,"plugin_"+e,new t(jQuery(this)))})),this}}(),jQuery(document).ready((function(){"function"==typeof jQuery().searchwp_live_search&&(jQuery('input[data-swplive="true"]').searchwp_live_search(),"undefined"!=typeof _SEARCHWP_LIVE_AJAX_SEARCH_BLOCKS&&_SEARCHWP_LIVE_AJAX_SEARCH_BLOCKS&&jQuery("input.wp-block-search__input").each((function(){jQuery(this).attr("data-swpengine",_SEARCHWP_LIVE_AJAX_SEARCH_ENGINE),jQuery(this).attr("data-swpconfig",_SEARCHWP_LIVE_AJAX_SEARCH_CONFIG),jQuery(this).searchwp_live_search()})))}))}();1 !function(){"use strict";var e=window&&window.__assign||function(){return e=Object.assign||function(e){for(var t,s=1,i=arguments.length;s<i;s++)for(var r in t=arguments[s])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)},t={lines:12,length:7,width:5,radius:10,scale:1,corners:1,color:"#000",fadeColor:"transparent",animation:"spinner-line-fade-default",rotate:0,direction:1,speed:1,zIndex:2e9,className:"spinner",top:"50%",left:"50%",shadow:"0 0 1px transparent",position:"absolute"},s=function(){function s(s){void 0===s&&(s={}),this.opts=e(e({},t),s)}return s.prototype.spin=function(e){return this.stop(),this.el=document.createElement("div"),this.el.className=this.opts.className,this.el.setAttribute("role","progressbar"),this.el.style.position=this.opts.position,this.el.style.width="0",this.el.style.zIndex=this.opts.zIndex.toString(),this.el.style.left=this.opts.left,this.el.style.top=this.opts.top,this.el.style.transform="scale(".concat(this.opts.scale,")"),e&&e.insertBefore(this.el,e.firstChild||null),function(e,t){var s=Math.round(t.corners*t.width*500)/1e3+"px",n="none";!0===t.shadow?n="0 2px 4px #000":"string"==typeof t.shadow&&(n=t.shadow);for(var a=function(e){for(var t=/^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/,s=[],i=0,r=e.split(",");i<r.length;i++){var n=r[i].match(t);if(null!==n){var a=+n[2],o=+n[5],h=n[4],l=n[7];0!==a||h||(h=l),0!==o||l||(l=h),h===l&&s.push({prefix:n[1]||"",x:a,y:o,xUnits:h,yUnits:l,end:n[8]})}}return s}(n),o=0;o<t.lines;o++){var h=~~(360/t.lines*o+t.rotate),l=document.createElement("div");l.style.position="absolute",l.style.top="".concat(-t.width/2,"px"),l.style.width=t.length+t.width+"px",l.style.height=t.width+"px",l.style.background=i(t.fadeColor,o),l.style.borderRadius=s,l.style.transformOrigin="left",l.style.transform="rotate(".concat(h,"deg) translateX(").concat(t.radius,"px)");var u=o*t.direction/t.lines/t.speed;u-=1/t.speed;var c=document.createElement("div");c.style.width="100%",c.style.height="100%",c.style.background=i(t.color,o),c.style.borderRadius=s,c.style.boxShadow=r(a,h),c.style.animation="".concat(1/t.speed,"s linear ").concat(u,"s infinite ").concat(t.animation),l.appendChild(c),e.appendChild(l)}}(this.el,this.opts),this},s.prototype.stop=function(){return this.el&&(this.el.parentNode&&this.el.parentNode.removeChild(this.el),this.el=void 0),this},s}();function i(e,t){return"string"==typeof e?e:e[t%e.length]}function r(e,t){for(var s=[],i=0,r=e;i<r.length;i++){var a=r[i],o=n(a.x,a.y,t);s.push(a.prefix+o[0]+a.xUnits+" "+o[1]+a.yUnits+a.end)}return s.join(", ")}function n(e,t,s){var i=s*Math.PI/180,r=Math.sin(i),n=Math.cos(i);return[Math.round(1e3*(e*n+t*r))/1e3,Math.round(1e3*(-e*r+t*n))/1e3]}!function(){var e="searchwp_live_search";function t(e){this.config=null,this.input_el=e,this.results_id=null,this.results_el=null,this.parent_el=null,this.results_showing=!1,this.form_el=null,this.timer=!1,this.last_string="",this.spinner=null,this.spinner_showing=!1,this.has_results=!1,this.current_request=!1,this.results_destroy_on_blur=!0,this.a11y_keys=[27,40,13,38,9],this.init()}t.prototype={init:function(){var e=this,t=this.input_el;this.form_el=t.parents("form:eq(0)"),this.results_id=this.uniqid("searchwp_live_search_results_");var i=!1,r=t.data("swpconfig");if(r&&void 0!==r)for(var n in searchwp_live_search_params.config)r===n&&(i=!0,this.config=searchwp_live_search_params.config[n]);else for(var a in searchwp_live_search_params.config)"default"===a&&(i=!0,this.config=searchwp_live_search_params.config[a]);if(i){var o=t.data("swpengine");o||(o=this.config.engine),t.data("swpengine",o),t.attr("autocomplete","off"),t.attr("aria-owns",this.results_id),t.attr("aria-autocomplete","both"),t.attr("aria-label",searchwp_live_search_params.aria_instructions);var h='<div aria-expanded="false" class="searchwp-live-search-results" id="'+this.results_id+'" tabindex="0"></div>',l=t.data("swpparentel");l?(this.parent_el=jQuery(l),this.parent_el.append(h)):this.config.parent_el?(this.parent_el=jQuery(this.config.parent_el),this.parent_el.append(h)):jQuery("body").append(jQuery(h)),this.results_el=jQuery("#"+this.results_id),this.position_results(),jQuery(window).resize((function(){e.position_results()})),this.config.spinner&&(void 0===this.config.spinner.scale&&(this.config.spinner.scale=1),void 0===this.config.spinner.fadeColor&&(this.config.spinner.fadeColor="transparent"),void 0===this.config.spinner.animation&&(this.config.spinner.animation="searchwp-spinner-line-fade-quick"),void 0===this.config.spinner.position&&(this.config.spinner.position="absolute"),this.spinner=new s(this.config.spinner)),void 0===this.config.abort_on_enter&&(this.config.abort_on_enter=!0),t.keyup((function(t){jQuery.inArray(t.keyCode,e.a11y_keys)>-1||(e.current_request&&e.config.abort_on_enter&&13===t.keyCode&&e.current_request.abort(),jQuery.trim(e.input_el.val()).length?e.results_showing||(e.position_results(),e.results_el.addClass("searchwp-live-search-results-showing").attr("role","listbox"),e.show_spinner(),e.results_showing=!0):e.destroy_results(),e.has_results&&!e.spinner_showing&&e.last_string!==jQuery.trim(e.input_el.val())&&(e.results_el.empty(),e.show_spinner()),t.currentTarget.value.length>=e.config.input.min_chars?e.results_el.removeClass("searchwp-live-search-no-min-chars"):e.results_el.addClass("searchwp-live-search-no-min-chars"),e.position_results())})).keyup(jQuery.proxy(this.maybe_search,this)),(this.config.results_destroy_on_blur||void 0===this.config.results_destroy_on_blur)&&jQuery("html").click((function(t){jQuery(t.target).parents(".searchwp-live-search-results").length||e.destroy_results()})),t.click((function(e){e.stopPropagation()}))}else alert(searchwp_live_search_params.msg_no_config_found)},keyboard_navigation:function(){var e=this,t=this.input_el,s=this.results_el,i="searchwp-live-search-result--focused",r=".searchwp-live-search-result",n=this.a11y_keys;jQuery(document).off("keyup.searchwp_a11y").on("keyup.searchwp_a11y",(function(a){if(s.hasClass("searchwp-live-search-results-showing")){if(-1!==jQuery.inArray(a.keyCode,n)){if(a.preventDefault(),27===a.keyCode)return e.destroy_results(),jQuery(document).off("keyup.searchwp_a11y"),t.focus(),void jQuery(document).trigger("searchwp_live_escape_results");if(40===a.keyCode){var o=jQuery(s[0]).find("."+i);1===o.length&&1===o.next().length?o.removeClass(i).attr("aria-selected","false").next().addClass(i).attr("aria-selected","true").find("a").focus():(o.removeClass(i).attr("aria-selected","false"),s.find(r+":first").addClass(i).attr("aria-selected","true").find("a").focus()),jQuery(document).trigger("searchwp_live_key_arrowdown_pressed")}if(38===a.keyCode){var h=jQuery(s[0]).find("."+i);1===h.length&&1===h.prev().length?h.removeClass(i).attr("aria-selected","false").prev().addClass(i).attr("aria-selected","true").find("a").focus():(h.removeClass(i).attr("aria-selected","false"),s.find(r+":last").addClass(i).attr("aria-selected","true").find("a").focus()),jQuery(document).trigger("searchwp_live_key_arrowup_pressed")}13===a.keyCode&&jQuery(document).trigger("searchwp_live_key_enter_pressed"),9===a.keyCode&&jQuery(document).trigger("searchwp_live_key_tab_pressed")}}else jQuery(document).off("keyup.searchwp_a11y")})),jQuery(document).trigger("searchwp_live_keyboad_navigation")},aria_expanded:function(e){var t=this.results_el;e?t.attr("aria-expanded","true"):t.attr("aria-expanded","false"),jQuery(document).trigger("searchwp_live_aria_expanded")},position_results:function(){var e=this.input_el,t=e.parents("form:eq(0)"),s=this.results_el,i=t.hasClass("wp-block-search__button-inside"),r={},n=0;if(!e.is(":hidden")){if(i&&(e=t),(r=e.offset()).left+=parseInt(this.config.results.offset.x,10),r.top+=parseInt(this.config.results.offset.y,10),"top"===this.config.results.position)n=0-s.height();else n=e.outerHeight();s.css("left",r.left),s.css("top",r.top+n+"px"),"auto"===this.config.results.width&&s.width(e.outerWidth()-parseInt(s.css("paddingRight").replace("px",""),10)-parseInt(s.css("paddingLeft").replace("px",""),10)),jQuery(document).trigger("searchwp_live_position_results",[s.css("left"),s.css("top"),s.width()])}},destroy_results:function(e){this.hide_spinner(),this.aria_expanded(!1),this.results_el.empty().removeClass("searchwp-live-search-results-showing"),this.results_el.removeAttr("role"),this.results_showing=!1,this.has_results=!1,jQuery(document).trigger("searchwp_live_destroy_results")},maybe_search:function(e){jQuery.inArray(e.keyCode,this.a11y_keys)>-1||(clearTimeout(this.timer),e.currentTarget.value.length>=this.config.input.min_chars&&(this.current_request&&this.current_request.abort(),this.timer=setTimeout(jQuery.proxy(this.search,this,e),this.config.input.delay)))},show_spinner:function(){this.config.spinner&&!this.spinner_showing&&(this.spinner.spin(document.getElementById(this.results_id)),this.spinner_showing=!0,jQuery(document).trigger("searchwp_live_show_spinner"))},hide_spinner:function(){this.config.spinner&&(this.spinner.stop(),this.spinner_showing=!1,jQuery(document).trigger("searchwp_live_hide_spinner"))},search:function(e){var t=this,s=this.form_el,i=s.serialize(),r=s.attr("action")?s.attr("action"):"",n=this.input_el,a=this.results_el;jQuery(document).trigger("searchwp_live_search_start",[n,a,s,r,i]),this.aria_expanded(!1),i+="&action=searchwp_live_search&swpengine="+n.data("swpengine"),i+="&swpquery="+encodeURIComponent(n.val()),i+="&origin_id="+parseInt(searchwp_live_search_params.origin_id,10),-1!==r.indexOf("?")&&(r=r.split("?"),i+="&"+r[1]),this.last_string=n.val(),this.has_results=!0,this.current_request=jQuery.ajax({url:searchwp_live_search_params.ajaxurl,type:"GET",data:i,complete:function(){jQuery(document).trigger("searchwp_live_search_complete",[n,a,s,r,i]),t.spinner_showing=!1,this.current_request=!1,jQuery(document).trigger("searchwp_live_search_shutdown",[n,a,s,r,i])},success:function(e){0===e&&(e=""),jQuery(document).trigger("searchwp_live_search_success",[n,a,s,r,i]),a.html(e),t.position_results(),t.aria_expanded(!0),t.keyboard_navigation(),jQuery(document).trigger("searchwp_live_search_shutdown",[n,a,s,r,i])}})},uniqid:function(e,t){var s;void 0===e&&(e="");var i=function(e,t){return t<(e=parseInt(e,10).toString(16)).length?e.slice(e.length-t):t>e.length?new Array(t-e.length+1).join("0")+e:e};return this.php_js||(this.php_js={}),this.php_js.uniqidSeed||(this.php_js.uniqidSeed=Math.floor(123456789*Math.random())),this.php_js.uniqidSeed++,s=e,s+=i(parseInt((new Date).getTime()/1e3,10),8),s+=i(this.php_js.uniqidSeed,5),t&&(s+=(10*Math.random()).toFixed(8).toString()),s}},jQuery.fn[e]=function(s){return this.each((function(){jQuery.data(this,"plugin_"+e)||jQuery.data(this,"plugin_"+e,new t(jQuery(this)))})),this}}(),jQuery(document).ready((function(){"function"==typeof jQuery().searchwp_live_search&&(jQuery('input[data-swplive="true"]').searchwp_live_search(),"undefined"!=typeof _SEARCHWP_LIVE_AJAX_SEARCH_BLOCKS&&_SEARCHWP_LIVE_AJAX_SEARCH_BLOCKS&&jQuery("input.wp-block-search__input").each((function(){jQuery(this).attr("data-swpengine",_SEARCHWP_LIVE_AJAX_SEARCH_ENGINE),jQuery(this).attr("data-swpconfig",_SEARCHWP_LIVE_AJAX_SEARCH_CONFIG),jQuery(this).searchwp_live_search()})))}))}(); -
searchwp-live-ajax-search/trunk/includes/class-template.php
r3168904 r3227084 404 404 public static function get_display_data( $result ) { 405 405 406 // During a multisite search, results can be from multiple blogs. 407 // If the result is from a different blog than the current one, we need to switch to that blog before fetching the result's data. 408 $switched_blog = self::maybe_switch_blog( $result ); 409 410 // Get the native entry for the result. 411 $result = self::maybe_get_native_entry( $result ); 412 406 413 /** 407 414 * Filter the result object. … … 474 481 $data = apply_filters( 'searchwp_live_search_results_entry_data', empty( $data ) ? $defaults : $data, $result ); 475 482 483 if ( $switched_blog ) { 484 restore_current_blog(); 485 } 486 476 487 // Make sure that default array structure is preserved. 477 488 return is_array( $data ) ? array_merge( $defaults, $data ) : $defaults; 489 } 490 491 /** 492 * Switch to the blog of the result. 493 * 494 * @since 1.8.4 495 * 496 * @param mixed $result Result object. 497 */ 498 private static function maybe_switch_blog( $result ) { 499 500 // Only switch to the blog if SearchWP is active. 501 if ( ! class_exists( 'SearchWP' ) ) { 502 return false; 503 } 504 505 if ( 506 $result instanceof \stdClass && 507 property_exists( $result, 'site' ) && 508 absint( $result->site ) !== get_current_blog_id() 509 ) { 510 switch_to_blog( absint( $result->site ) ); 511 512 return true; 513 } 514 515 return false; 516 } 517 518 /** 519 * Get the native entry of the result. 520 * 521 * @since 1.8.4 522 * 523 * @param mixed $result Result object. 524 * 525 * @return \WP_Post|\WP_User|\WP_Term|mixed 526 */ 527 private static function maybe_get_native_entry( $result ) { 528 529 // If SearchWP is not active, the result is already the native entry. 530 if ( ! class_exists( 'SearchWP\Entry' ) ) { 531 return $result; 532 } 533 534 if ( $result instanceof \stdClass && property_exists( $result, 'source' ) ) { 535 536 $id = absint( $result->id ); 537 538 if ( strpos( $result->source, 'post' . SEARCHWP_SEPARATOR ) === 0 ) { 539 $result = get_post( $id ); 540 } elseif ( strpos( $result->source, 'taxonomy' . SEARCHWP_SEPARATOR ) === 0 ) { 541 $result = get_term( $id ); 542 } elseif ( $result->source === 'user' ) { 543 $result = get_user_by( 'ID', $id ); 544 } 545 } elseif ( $result instanceof \SearchWP\Entry ) { 546 547 $result = $result->native(); 548 } 549 550 return $result; 478 551 } 479 552 -
searchwp-live-ajax-search/trunk/readme.txt
r3168904 r3227084 4 4 Requires at least: 4.8 5 5 Tested up to: 6.5 6 Stable tag: 1.8. 36 Stable tag: 1.8.4 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 74 74 75 75 == Changelog == 76 77 = 1.8.4 = 78 * Adds support for SearchWP multisite search. 79 * Improves search results dropdown role attribute, for better accessibility. 80 * Adjust results width to match Gutenberg form width when the search button is inside. 81 * Fixes the display of the results dropdown within a custom parent element. 76 82 77 83 = 1.8.3 = -
searchwp-live-ajax-search/trunk/searchwp-live-ajax-search.php
r3168904 r3227084 4 4 Plugin URI: https://searchwp.com/ 5 5 Description: Enhance your search forms with live search, powered by SearchWP (if installed) 6 Version: 1.8. 36 Version: 1.8.4 7 7 Requires PHP: 5.6 8 8 Author: SearchWP, LLC … … 11 11 Tested up to: 6.5 12 12 13 Copyright 2014-202 4SearchWP, LLC13 Copyright 2014-2025 SearchWP, LLC 14 14 15 15 This program is free software; you can redistribute it and/or … … 37 37 * @since 1.7.0 38 38 */ 39 define( 'SEARCHWP_LIVE_SEARCH_VERSION', '1.8. 3' );39 define( 'SEARCHWP_LIVE_SEARCH_VERSION', '1.8.4' ); 40 40 } 41 41
Note: See TracChangeset
for help on using the changeset viewer.