• Resolved ahasanpour

    (@ahasanpour)


    If you have a backslash (\) on the accordion description and try to save your change, all your previously entered data for the current accordion lose.

    A temporary workaround is to use HTML code for backslash: & #092;

    Tested on 2.3.5.

    • This topic was modified 2 years, 3 months ago by ahasanpour.
    • This topic was modified 2 years, 3 months ago by ahasanpour.
    • This topic was modified 2 years, 3 months ago by ahasanpour.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Praveen

    (@praveenmalav09)

    Hi @ahasanpour,

    As per the WordPress new guideline, you can not add special characters in the description section because of escaping functions i.e it stripping out unwanted data.

    Thanks

    Duncan

    (@duncan1967)

    You lose the accordion description (content), yes, but also cannot edit it to remove the backslash. I had posted a workaround here but have withdrawn it as it wasn’t properly tested, apologies. If I get it to work, I’ll add it here.

    • This reply was modified 2 years ago by Duncan.
    • This reply was modified 2 years ago by Duncan.
    • This reply was modified 2 years ago by Duncan. Reason: found bug in my suggested work-around
    • This reply was modified 2 years ago by Duncan. Reason: found bug in my suggested work-around
    Duncan

    (@duncan1967)

    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
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bug report: crash when have backslash on desc’ is closed to new replies.