WPIntell

Source evidence

Nonce error on shortcode

Da Reactions · support · 2024-08-28T19:22:00+00:00

mixedsentiment
highseverity
0.94relevance
4replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

4 / 32 rows with source links

12.5% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

28 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
Patrick_D1985 resolved
Hi there, Sometimes I seem to be getting the following response; {"success":"no","message":"Nonce error"} From the action “da_reactions_load_buttons”. I am using the following in my template; <?php if (is_plugin_active('da-reactions-premium/da-reactions.php')) { global $post; $item_type = $post->post_type; $item_id = $post->ID; echo do_shortcode('[reactions id="' . $item_id . '" type="' . $item_type . '"]'); } Refreshing the page does not seem to give me a new nonce. I am using FlyingPress as my caching solution. Is there a good way to make sure the shortcode always renders instead of giving the above mentioned response? Hope you can help me with that. Hi Patrick, Thank you for reporting this issue. Surely this is a bug that I need to solve as soon as possible, I’m thinking of removing nonce validation on first call and generating a new nonce with every new request. I’m going to work on it in the next few days. In the meantime, to resolve the issue temporarily, you could try: Disabling the cache: For the specific page or for the shortcode itself. Editing source to remove nonce validation: As a temporary workaround, inside classes/DaReactions/Ajax.php find and remove the block if ( ! $valid_nonce ) { ... } inside loadButtons function. I’ll keep you updated on the progress of the fix and let you know as soon as it’s available. Thank you for your patience and understanding. Best regards, Daniele Hi Daniele, Thanks for getting back to me 🙂 much appreciated! Disabling cache for the shortcode, would not even know how to make that happen. (Beside some hacky ways, which you shouldnt do hahaha) And for the specific page it a bit hard, as I do use it on more or less on every CPT except “page”. I’ll give the other workaround a chance later on and report back. Best regards and thanks again! Thank you for your patience, I can confirm that removing that part didt the trick, now the function looks like this: /** * Invoked from frontend to load button asynchronously * Must not validate nonce because it is not a security issue * And, most of all, some cache plugin may not work properly * * @since 1.0.0 */ public function loadButtons() { header( "Cache-Control: no-store, no-cache, must-revalidate, max-age=0" ); header( "Cache-Control: post-check=0, pre-check=0", false ); header( "Pragma: no-cache" ); $_POST = filter_input_array( INPUT_POST, FILTER_SANITIZE_FULL_SPECIAL_CHARS ); $item_id = (int) $_POST['id']; $item_type = sanitize_text_field( $_POST['type'] ); echo Frontend::getButtons( $item_type, $item_id ); exit(); } I’m going to run some tests, but basically this is the fix. Updated version will be released for everyone in the next few days. Hi there Daniele, Yeah I was able to test it myself a minute ago, and once the nonce check was gone the issue is gone. Thanks being swift about this, very very much appreciated for sure. Keep up being awesome!

Comments

4 shown
Daniele Alessandra 2024-08-29T17:10:00+00:00

Hi Patrick, Thank you for reporting this issue. Surely this is a bug that I need to solve as soon as possible, I’m thinking of removing nonce validation on first call and generating a new nonce with every new request. I’m going to work on it in the next few days. In the meantime, to resolve the issue temporarily, you could try: Disabling the cache: For the specific page or for the shortcode itself. Editing source to remove nonce validation: As a temporary workaround, inside classes/DaReactions/Ajax.php find and remove the block if ( ! $valid_nonce ) { ... } inside loadButtons function. I’ll keep you updated on the progress of the fix and let you know as soon as it’s available. Thank you for your patience and understanding. Best regards, Daniele

Patrick_D1985 2024-08-29T17:43:00+00:00

Hi Daniele, Thanks for getting back to me 🙂 much appreciated! Disabling cache for the shortcode, would not even know how to make that happen. (Beside some hacky ways, which you shouldnt do hahaha) And for the specific page it a bit hard, as I do use it on more or less on every CPT except “page”. I’ll give the other workaround a chance later on and report back. Best regards and thanks again!

Daniele Alessandra 2024-08-29T17:48:00+00:00

Thank you for your patience, I can confirm that removing that part didt the trick, now the function looks like this: /** * Invoked from frontend to load button asynchronously * Must not validate nonce because it is not a security issue * And, most of all, some cache plugin may not work properly * * @since 1.0.0 */ public function loadButtons() { header( "Cache-Control: no-store, no-cache, must-revalidate, max-age=0" ); header( "Cache-Control: post-check=0, pre-check=0", false ); header( "Pragma: no-cache" ); $_POST = filter_input_array( INPUT_POST, FILTER_SANITIZE_FULL_SPECIAL_CHARS ); $item_id = (int) $_POST['id']; $item_type = sanitize_text_field( $_POST['type'] ); echo Frontend::getButtons( $item_type, $item_id ); exit(); } I’m going to run some tests, but basically this is the fix. Updated version will be released for everyone in the next few days.

Patrick_D1985 2024-08-29T17:54:00+00:00

Hi there Daniele, Yeah I was able to test it myself a minute ago, and once the nonce check was gone the issue is gone. Thanks being swift about this, very very much appreciated for sure. Keep up being awesome!