Plugin Directory

Changeset 2486853


Ignore:
Timestamp:
03/04/2021 01:49:44 PM (5 years ago)
Author:
dlmconversion
Message:

checkout version 1.4

Location:
wp-dlm-faq/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-dlm-faq/trunk/readme.txt

    r2480121 r2486853  
    44Requires at least: 5.0
    55Tested up to: 5.5
    6 Stable tag: 1.3
     6Stable tag: 1.4
    77License: GPLv2 or later
    88
     
    1515
    1616== Changelog ==
     17
     18= 1.4 =
     19* add bullets to the new line in asnwers
    1720
    1821= 1.3 =
     
    3134== Upgrade notice ==
    3235
     36= 1.4 =
     37* add bullets to the new line in asnwers
     38
     39= 1.3 =
     40* refine the code to remove the see all button if there is less than 10 questions on a page
     41
     42= 1.2 =
     43* refine the code to eliminate extra special chars
     44
    3345= 1.1 =
    3446Upgrade if you want to have a read more link in the list page as you do not want to have all the faq display at once.
  • wp-dlm-faq/trunk/wp-dlm-faq.php

    r2480121 r2486853  
    44 * Plugin URI: https://wordpress.org/plugins/wp-dlm-faq/
    55 * Description: The plugin used for faq.
    6  * Version: 1.3
     6 * Version: 1.4
    77 * Author: DLM
    88 * Author URI: https://dlmconversion.com/wordpress-plugins/
     
    156156        }
    157157        $faq = get_field($field_name, $id);
    158         $faq = str_replace('"', '', str_replace("'", "", str_replace('\"', '', $faq)));
    159         $faq = str_replace('{', '{"', str_replace('}', '"}', $faq));
    160         $faq = str_replace(':{', '":{', str_replace(':[{', '":[{', $faq));
    161        
    162         $faq = str_replace(',answer', '","answer', str_replace('question:', 'question":"', str_replace('answer:', 'answer":"', str_replace('}],', '}],"', $faq))));
    163         $faq = str_replace('}]"},', '}]},"', str_replace('}]"}"}', '}]}}', $faq));
     158        $faq = clean_faqs($faq);
    164159       
    165160        $character = json_decode($faq, true);
     
    272267        }
    273268        $faq = get_field($field_name, $id);
    274         $faq = str_replace('"', '', str_replace("'", "", str_replace('\"', '', $faq)));
    275         $faq = str_replace('{', '{"', str_replace('}', '"}', $faq));
    276         $faq = str_replace(':{', '":{', str_replace(':[{', '":[{', $faq));
    277        
    278         $faq = str_replace(',answer', '","answer', str_replace('question:', 'question":"', str_replace('answer:', 'answer":"', str_replace('}],', '}],"', $faq))));
    279         $faq = str_replace('}]"},', '}]},"', str_replace('}]"}"}', '}]}}', $faq));
     269   
     270        echo $faq = clean_faqs($faq);
    280271        $character = json_decode($faq, true);
    281272        if($my_options['id_number']!=1){
     
    298289
    299290                            if("faq-no-".$i == "faq-no-".$my_options['id_number_acc']){
    300                                 $wrap .= '<div class="faq-item faq-no-'.$i.' nxtall"><h3 class=""><span class="ui-state-active ui-icon"></span>'.str_replace("u2019", "'", $value['question']).'</h3><div style="display: none;"><p>'.str_replace("u2019", "'", str_replace(".nn", ".<br><br>", $value['answer'])).'</p></div></div>';
     291                                $wrap .= '<div class="faq-item faq-no-'.$i.' nxtall"><h3 class=""><span class="ui-state-active ui-icon"></span>'.str_replace("u2019", "'", $value['question']).'</h3><div style="display: none;"><p>'.str_replace("u2019", "'", str_replace('•', '<br>• ', $value['answer'])).'</p></div></div>';
    301292                            }
    302293                            else{
    303                             $wrap .= '<div class="faq-item faq-no-'.$i.'"><h3 class=""><span class="ui-state-active ui-icon"></span>'.str_replace("u2019", "'", $value['question']).'</h3><div style="display: none;"><p>'.str_replace("u2019", "'", str_replace(".nn", ".<br><br>", $value['answer'])).'</p></div></div>';
     294                            $wrap .= '<div class="faq-item faq-no-'.$i.'"><h3 class=""><span class="ui-state-active ui-icon"></span>'.str_replace("u2019", "'", $value['question']).'</h3><div style="display: none;"><p>'.str_replace("u2019", "'", str_replace('•', '<br>• ', $value['answer'])).'</p></div></div>';
    304295                            }
    305296                             $i++;
     
    320311                            //print_r($value);
    321312                           if("faq-no-".$i == "faq-no-".$my_options['id_number_acc']){
    322                                 $wrap .= '<div class="faq-item faq-no-'.$i.' nxtall"><h3 class=""><span class="ui-state-active ui-icon"></span>'.str_replace("u2019", "'", $value['question']).'</h3><div style="display: none;"><p>'.str_replace("u2019", "'", str_replace(".nn", ".<br><br>", $value['answer'])).'</p></div></div>';
     313                                $wrap .= '<div class="faq-item faq-no-'.$i.' nxtall"><h3 class=""><span class="ui-state-active ui-icon"></span>'.str_replace("u2019", "'", $value['question']).'</h3><div style="display: none;"><p>'.str_replace("u2019", "'", str_replace('•', '<br>• ', $value['answer'])).'</p></div></div>';
    323314                            }
    324315                            else{
    325                             $wrap .= '<div class="faq-item faq-no-'.$i.'"><h3 class=""><span class="ui-state-active ui-icon"></span>'.str_replace("u2019", "'", $value['question']).'</h3><div style="display: none;"><p>'.str_replace("u2019", "'", str_replace(".nn", ".<br><br>", $value['answer'])).'</p></div></div>';
     316                            $wrap .= '<div class="faq-item faq-no-'.$i.'"><h3 class=""><span class="ui-state-active ui-icon"></span>'.str_replace("u2019", "'", $value['question']).'</h3><div style="display: none;"><p>'.str_replace("u2019", "'", str_replace('•', '<br>• ', $value['answer'])).'</p></div></div>';
    326317                            }
    327318                            $i++;
     
    339330                        //print_r($value);
    340331                        if("faq-no-".$i == "faq-no-".$my_options['id_number_acc']){
    341                                 $wrap .= '<div class="faq-item faq-no-'.$i.' nxtall"><h3 class=""><span class="ui-state-active ui-icon"></span>'.str_replace("u2019", "'", $value['question']).'</h3><div style="display: none;"><p>'.str_replace("u2019", "'", str_replace(".nn", ".<br><br>", $value['answer'])).'</p></div></div>';
     332                                $wrap .= '<div class="faq-item faq-no-'.$i.' nxtall"><h3 class=""><span class="ui-state-active ui-icon"></span>'.str_replace("u2019", "'", $value['question']).'</h3><div style="display: none;"><p>'.str_replace("u2019", "'", str_replace('•', '<br>• ', $value['answer'])).'</p></div></div>';
    342333                            }
    343334                            else{
    344                             $wrap .= '<div class="faq-item faq-no-'.$i.'"><h3 class=""><span class="ui-state-active ui-icon"></span>'.str_replace("u2019", "'", $value['question']).'</h3><div style="display: none;"><p>'.str_replace("u2019", "'", str_replace(".nn", ".<br><br>", $value['answer'])).'</p></div></div>';
     335                            $wrap .= '<div class="faq-item faq-no-'.$i.'"><h3 class=""><span class="ui-state-active ui-icon"></span>'.str_replace("u2019", "'", $value['question']).'</h3><div style="display: none;"><p>'.str_replace("u2019", "'", str_replace('•', '<br>• ', $value['answer'])).'</p></div></div>';
    345336                            }
    346337                            $i++;
     
    350341            }
    351342        endif;
     343        $wrap .='</div>';
    352344        if($i>10){
    353             $wrap .='</div><div class="faq-bottom"><a class="btn btn-gold all-btn" href="#dlm_faq">See All</a></div>';
     345            $wrap .='<div class="faq-bottom"><a class="btn btn-gold all-btn" href="#dlm_faq">See All</a></div>';
    354346        }
    355347
     
    400392                $faq = get_field($field_name, $id);
    401393           
    402                 $faq = str_replace('"', '', str_replace("'", "", str_replace('\"', '', $faq)));
    403                 $faq = str_replace('{', '{"', str_replace('}', '"}', $faq));
    404                 $faq = str_replace(':{', '":{', str_replace(':[{', '":[{', $faq));
    405 
    406                 $faq = str_replace(',answer', '","answer', str_replace('question:', 'question":"', str_replace('answer:', 'answer":"', str_replace('}],', '}],"', $faq))));
    407                 $faq = str_replace('}]"},', '}]},"', str_replace('}]"}"}', '}]}}', $faq));
     394                $faq = clean_faqs($faq);
    408395           
    409396                $character = json_decode($faq, true);
     
    420407                                                        'acceptedAnswer' => array(
    421408                                                            '@type' => 'Answer',
    422                                                             'text'  => str_replace("u2019", "'", str_replace(".nn", ".<br><br>", $value['answer']))
     409                                                            'text'  => str_replace("u2019", "'", $value['answer'])
    423410                                                        )
    424411                                                    );
     
    442429                                                            'acceptedAnswer' => array(
    443430                                                                '@type' => 'Answer',
    444                                                                 'text'  => str_replace("u2019", "'", str_replace(".nn", ".<br><br>", $value['answer']))
     431                                                                'text'  => str_replace("u2019", "'", $value['answer'])
    445432                                                            )
    446433                                                        );
     
    461448                                                    'acceptedAnswer' => array(
    462449                                                        '@type' => 'Answer',
    463                                                         'text'  => str_replace("u2019", "'", str_replace(".nn", ".<br><br>", $value['answer']))
     450                                                        'text'  => str_replace("u2019", "'", $value['answer'])
    464451                                                    )
    465452                                                );
     
    495482
    496483    $faq = get_field($_REQUEST["title"], $id);
    497     $faq = str_replace('"', '', str_replace("'", "", str_replace('\"', '', $faq)));
    498     $faq = str_replace('{', '{"', str_replace('}', '"}', $faq));
    499     $faq = str_replace(':{', '":{', str_replace(':[{', '":[{', $faq));
    500 
    501     $faq = str_replace(',answer', '","answer', str_replace('question:', 'question":"', str_replace('answer:', 'answer":"', str_replace('}],', '}],"', $faq))));
    502     $faq = str_replace('}]"},', '}]},"', str_replace('}]"}"}', '}]}}', $faq));
     484    $faq = clean_faqs($faq);
    503485    $character = json_decode($faq, true);
    504486
     
    522504}
    523505
     506function clean_faqs($faq){
     507    $search  = array('\"', "'", '"', '{', '}', ':[{', ':{', '}],', 'answer:', 'question:', ',answer', '}]"}"}', '}]"},');
     508    $replace = array('', '', '', '{"', '"}', '":[{', '":{', '}],"', 'answer":"', 'question":"', '","answer', '}]}}', '}]},"');
     509    return str_replace($search, $replace, $faq);
     510}
     511
     512
    524513if( is_admin() )
    525514    $my_settings_page = new MySettingsPage();
Note: See TracChangeset for help on using the changeset viewer.