Hello!
I am trying to use the shortcode [‘wphelpful’] within a single.php template but it’s not working at all. Any pointers?
]]>Hi, works for me without problems. Too bad it seems that it is no longer maintained?
Does anyone know where I can find the translation "You previously submitted feedback here on Feb 7, 2022"?
Via Loco Translate it is not in the plugin. Is there any chance that the plugin will be brought back to life? It is the only one in its kind.
Thank you Many greetings
]]>
I do not want loading jQuery (+ migrate) just for this function.
So here is my code with vanilla js.
Maybe it will help someone or the plugin author includes this in his great plugin. Since then You have to wp_dequeue_script(‘wphelpful’);wp_deregister_script(‘wphelpful’); in your theme’s functions.php.
You’re welcome.
var $this;
document.addEventListener('DOMContentLoaded', function() {
// Determine if we should disable the submit button or show the feedback section on load:
var ratings = document.querySelectorAll('.wph .wph-rating');
ratings.forEach(rating => {
rating.addEventListener("change", function (e) {
var checked = [...ratings].filter(el => {
return el.checked;
});
this.closest('.wph form.wph-form').querySelector('.wph-button').disabled = checked.length < 1;
if ((document.querySelectorAll('.wph.wph-after_rating').length > 0) && (checked.length > 0)) {
document.querySelector('.wph-feedback-wrap').classList.add("fade-in-show");
document.querySelector('.wph-feedback-wrap').classList.remove("fade-in-hide");
}
});
var event = document.createEvent('HTMLEvents');
event.initEvent('change', true, false);
rating.dispatchEvent(event);
});
// If we don't show the feedback section, just submit upon rating change:
var never = document.querySelectorAll('.wph.wph-never .wph-rating');
never.forEach(elem => {
elem.addEventListener('change', function(e) {
var event = document.createEvent('HTMLEvents');
event.initEvent('submit', true, false);
var forms = document.querySelectorAll('.wph form.wph-form');
forms.forEach(form => {
form.dispatchEvent(event);
});
});
});
// If we show feedback after rating, show it once we have a rating:
var afterRating = document.querySelectorAll('.wph.wph-after_rating .wph-rating');
afterRating.forEach(elem => {
elem.addEventListener('change', function(e) {
document.querySelector('.wph-feedback-wrap').classList.add("fade-in-show");
document.querySelector('.wph-feedback-wrap').classList.remove("fade-in-hide");
});
});
var forms = document.querySelectorAll(".wph form.wph-form");
forms.forEach(form => {
form.addEventListener("submit", function(e){
e.preventDefault();
$this = form.querySelector('.wph-button');
var data = {
_ajax_nonce: '<?=$nonce?>',
action: 'wphelpful_save_feedback'
};
// add form data to data:
var formData = serializeArray(form);
for (var x in formData) {
data[formData[x]['name'].replace('wphelpful[', '').replace(']', '')] = formData[x]['value'];
}
data['local_time'] = '' + new Date() + '';
$this.setAttribute('disabled', 'disabled');
// change text to active state from settings...
//var button_text = $this.html();
var active_button_text = $this.dataset.active;
$this.innerHTML = active_button_text;
//console.log(data);
var str = [];
for(var p in data){
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(data[p]));
}
str = str.join("&");
var request = new XMLHttpRequest();
request.open('POST', '/wp-admin/admin-ajax.php', true);
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
request.send(str);
request.onload = function() {
if (this.status >= 200 && this.status < 400) {
var respData = JSON.parse(this.response);
for (var x in respData) {
document.querySelector(''+x).outerHTML = respData[x];
}
}
};
request.onerror = function(e) {
$this.setAttribute('disabled', false);
$this.innerHTML = 'Error';
// TODO: should this be a setting?
alert("Uh oh! We ran into an error saving your feedback.");
console.log(e);
};
return false;
});
});
function serializeArray(form) {
var field, l, s = [];
if (typeof form == 'object' && form.nodeName == "FORM") {
var len = form.elements.length;
for (var i=0; i<len; i++) {
field = form.elements[i];
if (field.name && !field.disabled && field.type != 'file' && field.type != 'reset' && field.type != 'submit' && field.type != 'button') {
if (field.type == 'select-multiple') {
l = form.elements[i].options.length;
for (j=0; j<l; j++) {
if(field.options[j].selected)
s[s.length] = { name: field.name, value: field.options[j].value };
}
} else if ((field.type != 'checkbox' && field.type != 'radio') || field.checked) {
s[s.length] = { name: field.name, value: field.value };
}
}
}
}
return s;
}
})
]]>
Is it possible to translate copies using WPML? I have translated the strings but they won’t be shown in the proper language in the website.
]]>Hi,
Thanks for the plugin!
I have a faq and I would like to provide a poll and feedback form for each question. The shortcode however does not provide separate forms with separate states, and I can’t which form was submitted in the list of answers, since it only shows the name of the page.
Thoughts? What does the “Show on content types” “Wp block types” do? does it help here?
Olli
I have added WPHelpful to my page and can see this on desktop. When I view the page on a mobile device it is not there.
]]>I have ticked “Yes, I want to show feedback widget on this page.” and I have also added the shortcode to where I would like the feedback form to be, but now I end up with two forms. How can I fix this?
]]>After last update, there is a display problem while using classic editor (Guttenberg disabled by the plugin by Wordpredd Contributors).
WPhelpful accordion which is normally only at the bottom of the screen somehow overlays text fields (page/post name and content) with white area. After I switch off the WPhelpful tab from showing, I can work on the page but don’t have the option to swicth on/off WPH.
]]>On activation, I’m getting a non-dismissible banner which says…
Please activate your license key to enable all WPHelpful PRO features.
I don’t want to use the Pro version. How do I remove this banner?
]]>If you want people to test the free version, at least there should be some options available. Everything in the plugin is pro-feature, how do I test if it’s going to work me or not?
]]>Three PRE-PURCHASE questions please;
1) Can you please confirm that the shortcode will work on WooCommerce Product Pages with the paid version ? (in the free version it does not for me)
2) Can the padding above/below be reduced ? i.e. in testing the free version I noted significant/excessive padding
3) To reduce the amount of verticial screen space that is used up, is there any option for the text box (for feedback) to be hidden until after someone has already chosen one of the emoji’s ?
Thanks
]]>Hi, looks promising but I ran into a confusing issue: when I use the shortcode, there is no WPHelpful form shown, unless both the options Yes, I want to show feedback widget on this page and Automatically add WPHelpful to enabled content if shortcode isn’t used are checked. But then, there are two forms on the same page: one at the shortcode location and one at the bottom of the page.
It seems the shortcode is kind of useless unless you want two forms on one page. And the only way to get exactly one form (not two or none), is to check both options and not use the shortcode…
Is that by design?
]]>