File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Gravity Perks // QR Code // Decode HTML entities in QR codes that only consist of a URL
4+ * https://gravitywiz.com/documentation/gravity-forms-qr-code/
5+ *
6+ * Instructions: https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
7+ */
8+ add_filter ( 'gpqr_content_pre_generate ' , function ( $ content ) {
9+ // Only modify QR codes that only consist of a URL.
10+ if ( ! preg_match ( '/^https?:\/\// ' , $ content ) ) {
11+ return $ content ;
12+ }
13+
14+ // Prevent infinite loop.
15+ if ( html_entity_decode ( $ content ) === $ content ) {
16+ return $ content ;
17+ }
18+
19+ // Use while loop in case there are recursively encoded HTML entities (e.g. &amp;).
20+ while ( html_entity_decode ( $ content ) !== $ content ) {
21+ $ content = html_entity_decode ( $ content );
22+ }
23+
24+ return $ content ;
25+ } );
You can’t perform that action at this time.
0 commit comments