Update:
To recap, if an accordion content – the description entry – has a backslash character then the accordion becomes corrupted and the error –
Warning: foreach() argument must be of type array|object, bool given in D:\web\laragon\www\stellarbusinessenglish.com\wp-content\plugins\sbe-responsive-accordion-and-collapse\front\ac-content.php on line 57
– appears.
The content can still be retrieved in wp_postmeta with the post_id of the original accordion (as shown in the URL of the ‘edit accordion’) and copied into a new accordion, if needs be … minus the offending backslash, of course.
It would appear that the stripslashes() function which – as the name suggests – removes such characters is for some reason not working, at least in PHP 8.1.12 and Responsive Accordion 2.3.8.
As a workaround, locating plugin file /lib/admin/ac-save-data.php and adding the line after line 8 such that –
if($TotalCount) {
$accordion_title = stripslashes(sanitize_text_field($_POST['accordion_title']
[$i]));
becomes –
if($TotalCount) {
$_POST['accordion_desc'][$i] = str_replace("\\", "", $_POST['accordion_desc'][$i] );
$accordion_title = stripslashes(sanitize_text_field($_POST['accordion_title'][$i]));
– will fix the problem, removing backslash characters as desired. Accordion content with backslashes – which my own have several of, for reasons not relevent to this post, then have them removed and the accordion functions once more as intended.
There appears nothing at fault with the nice, clean, well-written plugin code itself. I can’t trace why this is happening, and post this in the hope it is valuable to the plugin developers and anyone else who encounters backslash-related issues with this lovely accordion plugin.
-
This reply was modified 2 years ago by Duncan. Reason: syntax error around code snippet
-
This reply was modified 2 years ago by Duncan. Reason: syntax error around code snippet
-
This reply was modified 2 years ago by Duncan. Reason: Making post more understandable
-
This reply was modified 2 years ago by Duncan. Reason: typo in coce