New and improved list filter. This new filter will be loaded only when user clicks on it. This new filter is loaded using reusable JS template to speed up page load. Previously there was a bug: when there are lots of terms, AnsPress do not shows all of them. From now on filter term can be searched and filtered. Also selecting multiple term is possible with new filter.
It doesn’t work: it works: the problem is in the home url! what would be the solution? Thanks!
Thank you Rahul. Cagliostro, I recently had Google blacklist 3 of my websites because they contained malware and after 4 weeks I am still trying to find out how new malware is being injected after it is being removed by SiteLock and all password, FTP accounts changed. The new Anspress website that I am launching will have anywhere from 1000 to 22,000 investors involved in a bankruptcy case.
Thank for the reply Rahul. I have tried this solution but it’s not working. Let me tell you I have customized the plugin core file, see the following code with “——-” what I have added in question-loop.php: <?php /** * Question class * *@package AnsPress *@author Rahul Aryan <[email protected]> *@license GPL-2.0+ *@link http://rahularyan.com *@copyright 2014 Rahul Aryan */ // If this file is called directly, abort. if ( ! defined( ‘WPINC’ ) ) { die; } if ( ! class_exists( ‘Question_Query’ ) ) : /** * Question * * This class is for retriving questions based on $args */ class Question_Query extends WP_Query { public $args = array(); /** * Initialize class *@param array $args *@access public *@since 2.0 */ public function __construct( $args = array() ) { if ( is_front_page() ) { $paged = (isset( $_GET[’ap_paged’] )) ? (int) $_GET[’ap_paged’] : 1; } else { $paged = (get_query_var( ‘paged’ )) ? get_query_var( ‘paged’ ) : 1; } if ( isset( $args[’post_parent’] ) ) { $post_parent = $args[’post_parent’]; } else { $post_parent = (get_query_var( ‘parent’ )) ? get_query_var( ‘parent’ ) : false; } $defaults = array( ‘showposts’ => ap_opt( ‘question_per_page’ ), ‘paged’ => $paged, ); $args[’post_status’][] = ‘publish’; $args[’post_status’][] = ‘closed’; if ( $post_parent ) { $this->args[’post_parent’] = $post_parent; } $this->args = wp_parse_args( $args, $defaults ); if ( get_query_var( ‘ap_s’ ) != ” ) { $this->args[’s’] = sanitize_text_field( get_query_var( ‘ap_s’ ) ); } if ( isset( $this->args[ ‘sortby’ ] ) ) { —————————————————————————– $this->orderby_questions($this->args[ ‘global_group_id’ ]); —————————————————————————– } $this->args[’post_type’] = […]
Hello, I am still waiting for the reply from plugin guys. Thanks
Ok, the latest update fixed some problems. Still i can’t (and nobody can) Answer ANY Question. The console shows maybe some problem at: function ap_default(a,b){return"undefined"!=typeof a?a:b}function apLoadingDot(){i=0,setInterval(function(){jQuery(".ap-loading-dot").html(Array(++i%4+1).join("."))},300)}function apAjaxData(a){return a+="&action=ap_ajax"}function apQueryStringToJSON(a){var b=a.split("&"),c={};return b.forEach(function(a){a=a.split("="),c[a[0]]=encodeURIComponent(a[1]||"")}),JSON.parse(JSON.stringify(c))}function apGetValueFromStr(a,b){b=b.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var c=new RegExp("[\\?&]"+b+"=([^&#]*)"),d=c.exec(a);return null==d?!1:decodeURIComponent(d[1].replace(/\+/g," "))}function apCenterBox(a){var a=jQuery(a),b=a.parent();b.css({position:"relative"}),a.css("left",(b.width()-a.width())/2),a.css("top",(b.height()-a.height())/2)}function apIsJsonString(a){try{JSON.parse(a)}catch(b){return!1}return!0}function apLoadCssJs(a,b){if("js"==b){var c=document.createElement("script");c.setAttribute("type","text/javascript"),c.setAttribute("src",a)}else if("css"==b){var c=document.createElement("link");c.setAttribute("rel","stylesheet"),c.setAttribute("type","text/css"),c.setAttribute("href",a)}"undefined"!=typeof c&&document.getElementsByTagName("head")[0].appendChild(c)}function apLoadTemplate(a,b,c){c=c||!1,0===jQuery("#template-"+a).length?jQuery.get(b,function(b){jQuery('<script id="template-'+a+'" type="text/html">'+b+"</script>").appendTo("body"),jQuery(a).trigger(a,b),c&&c(b)}):c&&c(jQuery("#template-"+a).html())}function apParseAjaxResponse(a){if(a=jQuery(a),"undefined"==typeof a.filter("#ap-response"))return console.log("Not a valid AnsPress ajax response."),{};var b=a.filter("#ap-response").html();return"undefined"!=typeof b&&b.length>2?JSON.parse(b):{}}function apCamelize(a){return a.replace(/(?:^\w|[A-Z]|\b\w)/g,function(a,b){return 0==b?a.toLowerCase():a.toUpperCase()}).replace(/\s+/g,"")}function apMergeObj(a,b){for(var c in b)try{b[c].constructor==Object?a[c]=MergeRecursive(a[c],b[c]):a[c]=b[c]}catch(d){a[c]=b[c]}return a}!function(a){a.fn.aptip=function(b){function c(b){"undefined"!=typeof a(b).attr("title")&&(a(b).data("aptiptitle",a(b).attr("title")),a(b).removeAttr("title"))}function d(b){var c=a(window).height(),d=a(b).offset(),e=a(b).outerHeight(),g=a(b).outerWidth(),h=a(b).data("tipposition")||!1,i=f.position.split(/ +/);h&&(i=h.split(/ +/));var j="top";switch(i[0]){case"bottom":j=d.top+e+10;break;case"center":j=d.top+e/2-tip.outerHeight()/2;break;default:j=d.top-tip.outerHeight()-10}var k="right";switch(i[1]){case"left":k=d.left-g;break;case"center":k=d.left+g/2-tip.outerWidth()/2;break;default:k=d.left+g}tip.addClass("x-"+i[0]+" y-"+i[1]);var l=a(document).scrollTop();0>k&&(k=5),l>j&&(j=d.top+g);var m=a(window).scrollTop()+c-tip.outerHeight();j>m&&(j-=tip.outerHeight()),tip.css({overflow:"absolute",top:j,left:k}),tip.find(".arrow").css({top:j,left:k})}function e(b){var e=a(b),h=e.data("userid")||e.data("catid")||!1,i=(e.data("action")||!1,e.data("tipquery")||!1);if(h&&!i){var j=e.data("catid")||!1;j=j?"&type=cat":"",e.data("tipquery","action=ap_ajax&ap_ajax_action=hover_card&id="+h+j),i=e.data("tipquery")}if(i!==!1&&(f.ajax=i),c(b),""==f.title)var k=e.data("aptiptitle");else var k=f.title;if(0!=k.length){if(tip=a('<div class="ap-tooltip '+f.theme+'"><div class="ap-tooltip-in">'+k+"</div></div>"),""!=f.ajax&&!g.ajax_running)if(0==a(e.attr("data-ajax")).length&&0==a("#"+h+"_card").length)g.ajax_running=!0,a.ajax({type:"POST",url:ajaxurl,data:f.ajax+"&ap_ajax_nonce="+ap_nonce,success:function(c){var f=a(c),c={},h=f.filter("#ap-response").html();"undefined"!=typeof h&&h.length>2&&(c=JSON.parse(h)),c.apTemplate&&"object"==typeof c.apTemplate&&apLoadTemplate(c.apTemplate.name,c.apTemplate.template,function(f){var h=a(Ta.render(f,c.apData));console.log(h);var i=parseInt(a(".aptip-data").length);g.data_id="aptipd-"+(i+1),h.addClass("aptip-data "+g.data_id),e.attr("data-ajax","."+g.data_id),a("body").append(h.clone()),tip.find(".ap-tooltip-in").html(h.show()),d(b)}),g.ajax_running=!1}});else{var l=a("#"+h+"_card").html();tip.find(".ap-tooltip-in").html(a(l).show())}if(""!=f.before){var m=f.before;m(tip,b,function(){d(b)})}tip.appendTo("body"),d(b)}}var f=a.extend({theme:"",delay:"",title:"",before:"",ajax:"",position:"top center"},b);this.ajax_running=!1;var g=this;return this.each(function(){$this=a(this);var b=this;$this.mouseenter(function(){""!=f.delay?delay=setTimeout(function(){e(b)},f.delay):e(this)}).mouseleave(function(){"undefined"!=typeof tip&&tip.remove(),"undefined"!=typeof delay&&clearTimeout(delay)})}),this},a.fn.autogrow=function(b){function c(c){var d,e=a(this),f=e.innerHeight(),g=this.scrollHeight,h=e.data("autogrow-start-height")||0;if(g>f)this.scrollTop=0,b.animate?e.stop().animate({height:g},b.speed):e.innerHeight(g);else if(!c||8==c.which||46==c.which||c.ctrlKey&&88==c.which)if(f>h){d=e.clone().addClass(b.cloneClass).css({position:"absolute",zIndex:-10,height:""}).val(e.val()),e.after(d);do g=d[0].scrollHeight-1,d.innerHeight(g);while(g===d[0].scrollHeight);g++,d.remove(),e.focus(),h>g&&(g=h),f>g&&b.animate?e.stop().animate({height:g},b.speed):e.innerHeight(g)}else e.innerHeight(h)}var d=a(this).css({overflow:"hidden",resize:"none"}),e=d.selector,f={context:a(document),animate:!0,speed:50,fixMinHeight:!0,cloneClass:"autogrowclone",onInitialize:!1};return b=a.isPlainObject(b)?b:{context:b?b:a(document)},b=a.extend({},f,b),d.each(function(d,e){var f,g;e=a(e),e.is(":visible")||parseInt(e.css("height"),10)>0?f=parseInt(e.css("height"),10)||e.innerHeight():(g=e.clone().addClass(b.cloneClass).val(e.val()).css({position:"absolute",visibility:"hidden",display:"block"}),a("body").append(g),f=g.innerHeight(),g.remove()),b.fixMinHeight&&e.data("autogrow-start-height",f),e.css("height",f),b.onInitialize&&e.length&&c.call(e[0])}),b.context.on("keyup paste",e,c),d},a.fn.center=function(){return this.css({position:"fixed"}),a(window).height()>a(this).outerHeight()?this.css("top",Math.max(0,(a(window).height()-a(this).outerHeight())/2)+"px"):(this.css("top",50),this.css("height",a(window).height()-80)),this.css("left",Math.max(0,(a(window).width()-a(this).outerWidth())/2+a(window).scrollLeft())+"px"),this},a.fn.apAjaxQueryString=function(){var b=a(this).data("query").split("::"),c={};c.action="ap_ajax",c.ap_ajax_action=b[0],c.__nonce=b[1],c.args={};var d=0;return a.each(b,function(a){0!=a&&1!=a&&(c.args[d]=b[a],d++)}),c}}(jQuery);var Tangular={};Tangular.helpers={},Tangular.version="v1.5.2",Tangular.cache={},Tangular.debug=!1,Tangular.settings={delimiters:["{{","}}"]},Tangular.register=function(a,b){return Tangular.helpers[a]=b,Tangular},Tangular.compile=function(a){a||(a="");for(var b,c=-1,d=[],e=-1,f=0,g=a.length,h=0,i=Tangular.settings.delimiters[0].length;g>c++;){var j=a.substring(c,c+i);if(-1===e)if(j!==Tangular.settings.delimiters[0]);else{if(-1!==e){h++;continue}b=a.substring(f,c),d.push(b?'unescape("'+escape(b)+'")':'""'),e=c+i}else if(j===Tangular.settings.delimiters[1]){if(h>0){h–;continue}d.push(a.substring(e,c).trim()),f=c+i,e=-1;continue}}b=a.substring(f,g),d.push(b?'unescape("'+escape(b)+'")':'""'),g=d.length;for(var k="$output+=",l='var $s=this,$output="",$t,$v;',m=[],n=!1,o=0,p=0;g>p;p++)if(p%2!==0){var q=d[p],r=!1,c=q.lastIndexOf("|"),s=null,t=q.substring(0,3);"if "===t&&(q="if( "+q.substring(3)+"){",r=!0),"foreach "===q.substring(0,8)&&(s=q.split(" "),"var"===s[1]&&s.splice(1,1),m.push(s[1]),r=!0,n=!0,o++);var u=q.substring(0,5);if("endif"===u||"fi"===q?(q="}",r=!0):"else"===u?(q="} else {",r=!0):"else if"===q.substring(0,7)?(q="}else if( "+q.substring(8)+"){",r=!0):("end"===t||"endfor"===q.substring(0,6))&&(q=m.length?"}})()}":"}}",m.pop(),r=!0,o–,0===o&&(n=!1)),q=r?Tangular.append(q,m,n,"$s").trim():Tangular.helper(q,m,n,"$s"),r){if(s){var v=Tangular.append(s[3],m,n,"$s");q="if ("+v+"&&"+v+".length){(function(){for(var i=0,length="+v+".length;i<length;i++){var "+s[1]+"="+v+"[i];var $index=i;"}l+=q}else l+=k+q+";"}else l+=k+d[p]+";";var w=59===l.charCodeAt(l.length-1);return Tangular.debug&&(console.log("Tangular:"),console.log("function(helpers,$) {"+l+(w?"":";")+"return $output;"),console.log(a.trim()),console.log("—————————"),console.log("")),function(a,b){return new Function("helpers","$",l+(w?"":";")+"return $output;").call(a,function(a){var b=Tangular.helpers[a];return b?b:(console.warn('Tangular helper "'+a+'" not found.'),function(a){return void 0===a?"undefined":null===a?"null":a.toString()})},b)}},Tangular.helper=function(a,b,c){var d,e=a.indexOf("|");if(-1===e)return d=Tangular.append(a.trim(),b,c,"$s").trim(),'helpers("encode").call($s,'+d+")";d=Tangular.append(a.substring(0,e).trim(),b,c).trim(),a=a.substring(e+1).trim().split("|");for(var f="",g=0,h=a.length;h>g;g++){var i,j=a[g].trim().replace("()","");e=j.indexOf("("),-1===e?(i=j,j=".call($s,$t)"):(i=j.substring(0,e),j=".call($s,$t,"+j.substring(e+1)),j='$t=helpers("'+i+'")'+j,f+=j+";"}return'"";$t='+d+";"+f+"$output+=$t"},Tangular.append=function(a,b,c,d){return void 0===b&&(b=[]),a?a.replace(/[\_\$a-zΓ‘-ΕΎΓ-Ε½A-Z0-9\s\.]+/g,function(a,c,e){var f=e.substring(c-1,c),g=!1,h=a.trim();switch(('"'===f||"'"===f||"."===f)&&(g=!0),a.trim()){case"else":case"end":case"endfor":case"endif":case"fi":case"foreach":case"if":case"else if":return a;case"$index":if(!g)return a}if(""===h)return"";if(g)return a;g=!1;for(var i=0,j=b.length;j>i;i++){var k=b[i].length;if(h.substring(0,k)===b[i]){if(h.length!==k){var f=h.substring(k,k+1);if("."!==f&&"+"!==f)continue}g=!0;break}}if("$"===h)return"Tangular.$wrap($)";if("$."===h.substring(0,2)&&(d="$",h=h.substring(2)),g)return h;f=h.substring(0,1);var l=f.charCodeAt(0);return l>47&&58>l?h:"Tangular.$wrap("+(d||"$s")+',"'+h+'")'}):"Tangular.$wrap("+(d||"$s")+")"},Tangular.$wrap=function(a,b,c){if(!a)return a;if(!b)return a;var d=Tangular.cache[b];if(null===d)return a[b];if(d||(d=b.split("."),Tangular.cache[b]=1===d.length?null:d),1===d.length)return a[b];for(var e=a,f=0,g=d.length;g>f;f++){var h=d[f];if(e=e[h],!e)return f+1===g?e:c}return e},Tangular.render=function(a,b,c){return(void 0===b||null===b)&&(b={}),"string"==typeof a&&(a=Tangular.compile(a)),a(b,c)},Tangular.register("encode",function(a){return(void 0===a||null===a)&&(a=""),a.toString().replace(/[<>&"]/g,function(a){switch(a){case"&":return"&";case"<":return"<";case">":return">";case'"':return"""}return a})}),Tangular.register("raw",function(a){return(void 0===a||null===a)&&(a=""),a}),"undefined"!=typeof global?global.Tangular=global.Ta=Tangular:"undefined"!=typeof window&&(window.Tangular||(window.Tangular=Tangular),window.Ta=Tangular),Tangular.debug=!0,Ta.register("objLength",function(a){return Object.keys(a).length}),function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):(window.WatchJS=a(),window.watch=window.WatchJS.watch,window.unwatch=window.WatchJS.unwatch,window.callWatchers=window.WatchJS.callWatchers)}(function(){function a(){v=null;for(var a=0;a<u.length;a++)u[a]();u.length=0}var b={noMore:!1,useDirtyCheck:!1},c=[],d=[],e=[],f=!1;try{f=Object.defineProperty&&Object.defineProperty({},"x",{})}catch(g){}var h=function(a){var b={};return a&&"[object Function]"==b.toString.call(a)},i=function(a){return"[object Array]"===Object.prototype.toString.call(a)},j=function(a){return"[object Object]"==={}.toString.apply(a)},k=function(a,b){var c=[],d=[];if("string"!=typeof a&&"string"!=typeof b){if(i(a))for(var e=0;e<a.length;e++)void 0===b[e]&&c.push(e);else for(e in a)a.hasOwnProperty(e)&&void 0===b[e]&&c.push(e);if(i(b))for(var f=0;f<b.length;f++)void 0===a[f]&&d.push(f);else for(f in b)b.hasOwnProperty(f)&&void 0===a[f]&&d.push(f)}return{added:c,removed:d}},l=function(a){if(null==a||"object"!=typeof a)return a;var b,c=a.constructor();for(b in a)c[b]=a[b];return c},m=function(a,b,c,d){try{Object.observe(a,function(a){a.forEach(function(a){a.name===b&&d(a.object[a.name])})})}catch(e){try{Object.defineProperty(a,b,{get:c,set:function(a){d.call(this,a,!0)},enumerable:!0,configurable:!0})}catch(f){try{Object.prototype.__defineGetter__.call(a,b,c),Object.prototype.__defineSetter__.call(a,b,function(a){d.call(this,a,!0)})}catch(g){o(a,b,d)}}}},n=function(a,b,c){try{Object.defineProperty(a,b,{enumerable:!1,configurable:!0,writable:!1,value:c})}catch(d){a[b]=c}},o=function(a,b,c){d[d.length]={prop:b,object:a,orig:l(a[b]),callback:c}},p=function(a,b,c,d){if("string"!=typeof a&&(a instanceof Object||i(a))){if(i(a)){if(A(a,"__watchall__",b,c),void 0===c||c>0)for(var e=0;e<a.length;e++)p(a[e],b,c,d)}else{var g=[];for(e in a)"$val"==e||!f&&"watchers"===e||Object.prototype.hasOwnProperty.call(a,e)&&g.push(e);q(a,g,b,c,d)}d&&K(a,"$$watchlengthsubjectroot",b,c)}},q=function(a,b,c,d,e){if("string"!=typeof a&&(a instanceof Object||i(a)))for(var f=0;f<b.length;f++)r(a,b[f],c,d,e)},r=function(a,b,c,d,e){"string"!=typeof a&&(a instanceof Object||i(a))&&!h(a[b])&&(null!=a[b]&&(void 0===d||d>0)&&p(a[b],c,void 0!==d?d-1:d),A(a,b,c,d),e&&(void 0===d||d>0)&&K(a,b,c,d))},s=function(a,b){if(!(a instanceof String)&&(a instanceof Object||i(a)))if(i(a)){for(var c=["__watchall__"],d=0;d<a.length;d++)c.push(d);t(a,c,b)}else{var e=function(a){var c,d=[];for(c in a)a.hasOwnProperty(c)&&(a[c]instanceof Object?e(a[c]):d.push(c));t(a,d,b)};e(a)}},t=function(a,b,c){for(var d in […]
Please update AnsPress to latest commit. This was due to category and tags update committed before AnsPress hence some new functions are not found. Update to Latest and it it will solve.
My debug.log [02-May-2016 07:46:55 UTC] PHP Fatal error: Uncaught Error: Call to undefined function ap_list_filters_get_active() in /home/wp-content/plugins/categories-for-anspress/categories-for-anspress.php:835 Stack trace: #0 /home/wp-includes/plugin.php(235): Categories_For_AnsPress::ap_main_questions_args(Array) #1 /home/wp-content/plugins/anspress-question-answer/includes/common-pages.php(81): apply_filters('ap_main_questio…', Array) #2 /home/wp-content/plugins/anspress-question-answer/includes/theme.php(434): AnsPress_Common_Pages::base_page() #3 /home/wp-content/plugins/anspress-question-answer/includes/shortcode-basepage.php(66): ap_page() #4 /home/wp-includes/shortcodes.php(326): AnsPress_BasePage_Shortcode->anspress_sc('', '', 'anspress') #5 [internal function]: do_shortcode_tag(Array) #6 /home/wp-includes/shortcodes.php(223): preg_replace_callback('/\\ in /home/wp-content/plugins/categories-for-anspress/categories-for-anspress.php on line 835 [02-May-2016 07:46:59 UTC] PHP Fatal error: Uncaught Error: Call to undefined function ap_list_filters_get_active() in /home/wp-content/plugins/categories-for-anspress/categories-for-anspress.php:835 Stack trace: #0 /home/wp-includes/plugin.php(235): Categories_For_AnsPress::ap_main_questions_args(Array) #1 /home/wp-content/plugins/anspress-question-answer/includes/common-pages.php(81): apply_filters('ap_main_questio…', Array) #2 /home/wp-content/plugins/anspress-question-answer/includes/theme.php(434): AnsPress_Common_Pages::base_page() #3 /home/wp-content/plugins/anspress-question-answer/includes/shortcode-basepage.php(66): ap_page() #4 /home/wp-includes/shortcodes.php(326): AnsPress_BasePage_Shortcode->anspress_sc('', '', 'anspress') #5 [internal function]: do_shortcode_tag(Array) #6 /home/wp-includes/shortcodes.php(223): preg_replace_callback('/\\ in /home/wp-content/plugins/categories-for-anspress/categories-for-anspress.php on line 835 egories-for-anspress.php on line 835
Try this: [anspress page="activity"]