Ultimate FAQ - Version 1.8.27

Version Description

  • Changing the way the schema is included to the new JSON-LD format
  • Adding an option to disable the schema
Download this release

Release Info

Developer Rustaurius
Plugin Icon 128x128 Ultimate FAQ
Version 1.8.27
Comparing to
See all releases

Code changes from version 1.8.26 to 1.8.27

Functions/Update_Admin_Databases.php CHANGED
@@ -44,6 +44,7 @@ function EWD_UFAQ_UpdateOptions() {
44
  if (isset($_POST['permalink_type'])) {update_option('EWD_UFAQ_Permalink_Type', sanitize_text_field($_POST['permalink_type']));}
45
  if (isset($_POST['show_tinymce'])) {update_option('EWD_UFAQ_Show_TinyMCE', sanitize_text_field($_POST['show_tinymce']));}
46
  if (isset($_POST['comments_on'])) {update_option('EWD_UFAQ_Comments_On', sanitize_text_field($_POST['comments_on']));}
 
47
  if (isset($_POST['access_role'])) {update_option('EWD_UFAQ_Access_Role', sanitize_text_field($_POST['access_role']));}
48
 
49
  if (isset($_POST['display_style']) and $UFAQ_Full_Version == "Yes") {update_option('EWD_UFAQ_Display_Style', sanitize_text_field($_POST['display_style']));}
44
  if (isset($_POST['permalink_type'])) {update_option('EWD_UFAQ_Permalink_Type', sanitize_text_field($_POST['permalink_type']));}
45
  if (isset($_POST['show_tinymce'])) {update_option('EWD_UFAQ_Show_TinyMCE', sanitize_text_field($_POST['show_tinymce']));}
46
  if (isset($_POST['comments_on'])) {update_option('EWD_UFAQ_Comments_On', sanitize_text_field($_POST['comments_on']));}
47
+ if (isset($_POST['disable_microdata'])) {update_option('EWD_UFAQ_Disable_Microdata', sanitize_text_field($_POST['disable_microdata']));}
48
  if (isset($_POST['access_role'])) {update_option('EWD_UFAQ_Access_Role', sanitize_text_field($_POST['access_role']));}
49
 
50
  if (isset($_POST['display_style']) and $UFAQ_Full_Version == "Yes") {update_option('EWD_UFAQ_Display_Style', sanitize_text_field($_POST['display_style']));}
Main.php CHANGED
@@ -7,7 +7,7 @@ Author: Etoile Web Design
7
  Author URI: http://www.EtoileWebDesign.com/wordpress-plugins/
8
  Terms and Conditions: http://www.etoilewebdesign.com/plugin-terms-and-conditions/
9
  Text Domain: ultimate-faqs
10
- Version: 1.8.26
11
  */
12
 
13
  global $ewd_ufaq_message;
@@ -204,6 +204,7 @@ function Set_EWD_UFAQ_Options() {
204
  if (get_option("EWD_UFAQ_Permalink_Type") == "") {update_option("EWD_UFAQ_Permalink_Type", "SamePage");}
205
  if (get_option("EWD_UFAQ_Show_TinyMCE") == "") {update_option("EWD_UFAQ_Show_TinyMCE", "Yes");}
206
  if (get_option("EWD_UFAQ_Comments_On") == "") {update_option("EWD_UFAQ_Comments_On", "Yes");}
 
207
  if (get_option("EWD_UFAQ_Access_Role") == "") {update_option("EWD_UFAQ_Access_Role", "edit_posts");}
208
 
209
  if (get_option("EWD_UFAQ_Display_Style") == "") {update_option("EWD_UFAQ_Display_Style", "Default");}
7
  Author URI: http://www.EtoileWebDesign.com/wordpress-plugins/
8
  Terms and Conditions: http://www.etoilewebdesign.com/plugin-terms-and-conditions/
9
  Text Domain: ultimate-faqs
10
+ Version: 1.8.27
11
  */
12
 
13
  global $ewd_ufaq_message;
204
  if (get_option("EWD_UFAQ_Permalink_Type") == "") {update_option("EWD_UFAQ_Permalink_Type", "SamePage");}
205
  if (get_option("EWD_UFAQ_Show_TinyMCE") == "") {update_option("EWD_UFAQ_Show_TinyMCE", "Yes");}
206
  if (get_option("EWD_UFAQ_Comments_On") == "") {update_option("EWD_UFAQ_Comments_On", "Yes");}
207
+ if (get_option("EWD_UFAQ_Disable_Microdata") == "") {update_option("EWD_UFAQ_Disable_Microdata", "No");}
208
  if (get_option("EWD_UFAQ_Access_Role") == "") {update_option("EWD_UFAQ_Access_Role", "edit_posts");}
209
 
210
  if (get_option("EWD_UFAQ_Display_Style") == "") {update_option("EWD_UFAQ_Display_Style", "Default");}
Shortcodes/DisplayFAQs.php CHANGED
@@ -26,6 +26,8 @@ function UFAQ_Display_FAQs_Block() {
26
  add_action( 'init', 'UFAQ_Display_FAQs_Block' );
27
 
28
  function Display_FAQs($atts) {
 
 
29
  $Custom_CSS = get_option("EWD_UFAQ_Custom_CSS");
30
  $FAQ_Toggle = get_option("EWD_UFAQ_Toggle");
31
  $Category_Toggle = get_option("EWD_UFAQ_Category_Toggle");
@@ -224,6 +226,14 @@ function Display_FAQs($atts) {
224
  );
225
  }
226
 
 
 
 
 
 
 
 
 
227
  $Page_Permalink = get_the_permalink();
228
 
229
  $ReturnString .= "<div class='ufaq-faq-list' id='ufaq-faq-list'>";
@@ -338,7 +348,7 @@ function Display_FAQs($atts) {
338
  break 2;
339
  }
340
 
341
- $faq = get_post();
342
  $Category_Terms = wp_get_post_terms($faq->ID, 'ufaq-category');
343
  $Tag_Terms = wp_get_post_terms($faq->ID, 'ufaq-tag');
344
 
@@ -365,7 +375,7 @@ function Display_FAQs($atts) {
365
  $TitlesArray[] = json_encode($Post_Title);
366
  $HeaderString .= "<div class='ufaq-faq-header-title'><a href='' class='ufaq-faq-header-link' data-postid='" . $Unique_ID . "-" . $faq->ID . "-" . $Counter . "'>" . apply_filters('the_title', $Post_Title, $faq->ID) . "</a></div>";
367
 
368
- $ReturnString .= "<div class='ufaq-faq-div ufaq-faq-column-count-" . $FAQ_Number_Of_Columns . " ufaq-faq-responsive-columns-" . $Responsive_Columns . " ufaq-faq-display-style-" . $Display_Style . "' id='ufaq-post-" . $Unique_ID . "-" . $faq->ID . "-" . $Counter . "' data-postid='" . $Unique_ID . "-" . $faq->ID . "-" . $Counter . "' itemscope itemtype='http://schema.org/Question'>";
369
 
370
  $ReturnString .= "<div class='ufaq-faq-title";
371
  if ($FAQ_Toggle != "No") {$ReturnString .= " ufaq-faq-toggle";}
@@ -373,27 +383,27 @@ function Display_FAQs($atts) {
373
  $ReturnString .= "<a class='ewd-ufaq-post-margin' href='" . get_permalink($faq->ID) . "'><div class='ewd-ufaq-post-margin-symbol " . $Color_Block_Shape . "' id='ewd-ufaq-post-margin-symbol-" . $Unique_ID . "-" . $faq->ID . "-" . $Counter . "'><span id='ewd-ufaq-post-symbol-" . $Unique_ID . "-" . $faq->ID . "-" . $Counter;
374
  if ($Display_All_Answers == "Yes") {$ReturnString .= "'>" . $Toggle_Symbol . "</span></div>";}
375
  else {$ReturnString .= "'>" . strtolower($Toggle_Symbol) . "</span></div>";}
376
- $ReturnString .= "<div class='ufaq-faq-title-text'><" . $UFAQ_Styling_FAQ_Heading_Type . " itemprop='name'>" . apply_filters('the_title', $Post_Title, $faq->ID) . "</" . $UFAQ_Styling_FAQ_Heading_Type . "></div><div class='ewd-ufaq-clear'></div></a>";
377
  $ReturnString .= "</div>";
378
 
379
  if (strlen($faq->post_excerpt) > 0) {$ReturnString .= "<div class='ufaq-faq-excerpt' id='ufaq-excerpt-" . $faq->ID . "'>" . apply_filters('the_content', html_entity_decode($faq->post_excerpt)) . "</div>";}
380
  $ReturnString .= "<div class='ufaq-faq-body ufaq-body-" . $faq->ID;
381
  if ($Display_All_Answers != "Yes") {$ReturnString .= " ewd-ufaq-hidden";}
382
- $ReturnString .= "' id='ufaq-body-" . $Unique_ID . "-" . $faq->ID . "-" . $Counter . "' itemprop='suggestedAnswer acceptedAnswer' itemscope itemtype='http://schema.org/Answer'>";
383
 
384
  foreach ($FAQ_Elements as $FAQ_Element) {
385
  if ($FAQ_Element == "Author_Date" and ($Display_Author == "Yes" or $Display_Date == "Yes")) {
386
  $Display_Author_Value = get_post_meta($faq->ID, "EWD_UFAQ_Post_Author", true);
387
  $Display_Date_Value = get_the_date("", $faq->ID);
388
- $ReturnString .= "<div class='ewd-ufaq-author-date' itemprop='author' itemscope itemtype='http://schema.org/Person'>";
389
  $ReturnString .= $Posted_Label . " " ;
390
- if ($Display_Author == "Yes" and $Display_Author_Value != "") {$ReturnString .= $By_Label . " <span class='ewd-ufaq-author' itemprop='name'>" . $Display_Author_Value . "</span> ";}
391
  if ($Display_Date == "Yes") {$ReturnString .= $On_Label . " <span class='ewd-ufaq-date'>" . $Display_Date_Value . "</span> ";}
392
  $ReturnString .= "</div>";
393
  }
394
 
395
  if ($FAQ_Element == "Body") {
396
- $ReturnString .= "<div class='ewd-ufaq-post-margin ufaq-faq-post' id='ufaq-post-" . $faq->ID . "' itemprop='text'>" . apply_filters('the_content', html_entity_decode($Post_Content)) . "</div>";
397
  }
398
 
399
  if ($FAQ_Element == "Custom_Fields" and sizeOf($FAQ_Fields_Array) > 0) {
@@ -456,8 +466,8 @@ function Display_FAQs($atts) {
456
  $ReturnString .= "<div class='ewd-ufaq-ratings-label'>";
457
  $ReturnString .= $Find_FAQ_Helpful_Label;
458
  $ReturnString .= "</div>";
459
- $ReturnString .= "<div class='ewd-ufaq-rating-button ewd-ufaq-up-vote' data-ratingfaqid='" . $faq->ID . "' itemprop='upvoteCount'>" . $Up_Votes . "</div>";
460
- $ReturnString .= "<div class='ewd-ufaq-rating-button ewd-ufaq-down-vote' data-ratingfaqid='" . $faq->ID . "' itemprop='downvoteCount'>" . $Down_Votes . "</div>";
461
  $ReturnString .= "</div>";
462
  $ReturnString .= "<div class='ewd-ufaq-clear'></div>";
463
  }
@@ -504,8 +514,29 @@ function Display_FAQs($atts) {
504
  $ReturnString .= "</a>";
505
  $ReturnString .= "</div>";
506
  }
 
507
  }
508
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
509
  $ReturnString .= "</div>";
510
  $ReturnString .= "</div>";
511
 
@@ -629,6 +660,20 @@ function EWD_UFAQ_Enqueue_Scripts_In_Shortcode() {
629
  if ($Reveal_Effect == "shake") {wp_enqueue_script("jquery-effects-shake");}
630
  if ($Reveal_Effect == "slide") {wp_enqueue_script("jquery-effects-slide");}
631
  wp_enqueue_script("jquery-effects-transfer");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
632
  }
633
 
634
  function EWD_UFAQ_Rand_Chars($CharLength = 10) {
26
  add_action( 'init', 'UFAQ_Display_FAQs_Block' );
27
 
28
  function Display_FAQs($atts) {
29
+ global $ewd_ufaq_schema_data;
30
+
31
  $Custom_CSS = get_option("EWD_UFAQ_Custom_CSS");
32
  $FAQ_Toggle = get_option("EWD_UFAQ_Toggle");
33
  $Category_Toggle = get_option("EWD_UFAQ_Category_Toggle");
226
  );
227
  }
228
 
229
+ if ( ! isset($ewd_ufaq_schema_data) or ! is_array($ewd_ufaq_schema_data) ) {
230
+ $ewd_ufaq_schema_data = array(
231
+ '@context' => "https://schema.org",
232
+ '@type' => 'FAQPage',
233
+ 'mainEntity' => array()
234
+ );
235
+ }
236
+
237
  $Page_Permalink = get_the_permalink();
238
 
239
  $ReturnString .= "<div class='ufaq-faq-list' id='ufaq-faq-list'>";
348
  break 2;
349
  }
350
 
351
+ $faq = get_post();
352
  $Category_Terms = wp_get_post_terms($faq->ID, 'ufaq-category');
353
  $Tag_Terms = wp_get_post_terms($faq->ID, 'ufaq-tag');
354
 
375
  $TitlesArray[] = json_encode($Post_Title);
376
  $HeaderString .= "<div class='ufaq-faq-header-title'><a href='' class='ufaq-faq-header-link' data-postid='" . $Unique_ID . "-" . $faq->ID . "-" . $Counter . "'>" . apply_filters('the_title', $Post_Title, $faq->ID) . "</a></div>";
377
 
378
+ $ReturnString .= "<div class='ufaq-faq-div ufaq-faq-column-count-" . $FAQ_Number_Of_Columns . " ufaq-faq-responsive-columns-" . $Responsive_Columns . " ufaq-faq-display-style-" . $Display_Style . "' id='ufaq-post-" . $Unique_ID . "-" . $faq->ID . "-" . $Counter . "' data-postid='" . $Unique_ID . "-" . $faq->ID . "-" . $Counter . "'>";
379
 
380
  $ReturnString .= "<div class='ufaq-faq-title";
381
  if ($FAQ_Toggle != "No") {$ReturnString .= " ufaq-faq-toggle";}
383
  $ReturnString .= "<a class='ewd-ufaq-post-margin' href='" . get_permalink($faq->ID) . "'><div class='ewd-ufaq-post-margin-symbol " . $Color_Block_Shape . "' id='ewd-ufaq-post-margin-symbol-" . $Unique_ID . "-" . $faq->ID . "-" . $Counter . "'><span id='ewd-ufaq-post-symbol-" . $Unique_ID . "-" . $faq->ID . "-" . $Counter;
384
  if ($Display_All_Answers == "Yes") {$ReturnString .= "'>" . $Toggle_Symbol . "</span></div>";}
385
  else {$ReturnString .= "'>" . strtolower($Toggle_Symbol) . "</span></div>";}
386
+ $ReturnString .= "<div class='ufaq-faq-title-text'><" . $UFAQ_Styling_FAQ_Heading_Type . ">" . apply_filters('the_title', $Post_Title, $faq->ID) . "</" . $UFAQ_Styling_FAQ_Heading_Type . "></div><div class='ewd-ufaq-clear'></div></a>";
387
  $ReturnString .= "</div>";
388
 
389
  if (strlen($faq->post_excerpt) > 0) {$ReturnString .= "<div class='ufaq-faq-excerpt' id='ufaq-excerpt-" . $faq->ID . "'>" . apply_filters('the_content', html_entity_decode($faq->post_excerpt)) . "</div>";}
390
  $ReturnString .= "<div class='ufaq-faq-body ufaq-body-" . $faq->ID;
391
  if ($Display_All_Answers != "Yes") {$ReturnString .= " ewd-ufaq-hidden";}
392
+ $ReturnString .= "' id='ufaq-body-" . $Unique_ID . "-" . $faq->ID . "-" . $Counter . "'>";
393
 
394
  foreach ($FAQ_Elements as $FAQ_Element) {
395
  if ($FAQ_Element == "Author_Date" and ($Display_Author == "Yes" or $Display_Date == "Yes")) {
396
  $Display_Author_Value = get_post_meta($faq->ID, "EWD_UFAQ_Post_Author", true);
397
  $Display_Date_Value = get_the_date("", $faq->ID);
398
+ $ReturnString .= "<div class='ewd-ufaq-author-date'>";
399
  $ReturnString .= $Posted_Label . " " ;
400
+ if ($Display_Author == "Yes" and $Display_Author_Value != "") {$ReturnString .= $By_Label . " <span class='ewd-ufaq-author'>" . $Display_Author_Value . "</span> ";}
401
  if ($Display_Date == "Yes") {$ReturnString .= $On_Label . " <span class='ewd-ufaq-date'>" . $Display_Date_Value . "</span> ";}
402
  $ReturnString .= "</div>";
403
  }
404
 
405
  if ($FAQ_Element == "Body") {
406
+ $ReturnString .= "<div class='ewd-ufaq-post-margin ufaq-faq-post' id='ufaq-post-" . $faq->ID . "'>" . apply_filters('the_content', html_entity_decode($Post_Content)) . "</div>";
407
  }
408
 
409
  if ($FAQ_Element == "Custom_Fields" and sizeOf($FAQ_Fields_Array) > 0) {
466
  $ReturnString .= "<div class='ewd-ufaq-ratings-label'>";
467
  $ReturnString .= $Find_FAQ_Helpful_Label;
468
  $ReturnString .= "</div>";
469
+ $ReturnString .= "<div class='ewd-ufaq-rating-button ewd-ufaq-up-vote' data-ratingfaqid='" . $faq->ID . "'>" . $Up_Votes . "</div>";
470
+ $ReturnString .= "<div class='ewd-ufaq-rating-button ewd-ufaq-down-vote' data-ratingfaqid='" . $faq->ID . "'>" . $Down_Votes . "</div>";
471
  $ReturnString .= "</div>";
472
  $ReturnString .= "<div class='ewd-ufaq-clear'></div>";
473
  }
514
  $ReturnString .= "</a>";
515
  $ReturnString .= "</div>";
516
  }
517
+
518
  }
519
 
520
+ $schema_object = array(
521
+ '@type' => 'Question',
522
+ 'name' => $faq->post_title,
523
+ 'acceptedAnswer' => array(
524
+ '@type' => 'Answer',
525
+ 'text' => $faq->post_content
526
+ )
527
+ );
528
+
529
+ if ( isset($Up_Votes) ) { $schema_object['acceptedAnswer']['upvoteCount'] = $Up_Votes; }
530
+ if ( isset($Down_Votes) ) { $schema_object['acceptedAnswer']['downvoteCount'] = $Down_Votes; }
531
+ if ( isset($Display_Author_Value) ) {
532
+ $schema_object['acceptedAnswer']['author'] = array(
533
+ '@type' => 'Person',
534
+ 'name' => $Display_Author_Value
535
+ );
536
+ }
537
+
538
+ $ewd_ufaq_schema_data['mainEntity'][] = $schema_object;
539
+
540
  $ReturnString .= "</div>";
541
  $ReturnString .= "</div>";
542
 
660
  if ($Reveal_Effect == "shake") {wp_enqueue_script("jquery-effects-shake");}
661
  if ($Reveal_Effect == "slide") {wp_enqueue_script("jquery-effects-slide");}
662
  wp_enqueue_script("jquery-effects-transfer");
663
+
664
+ add_action( 'wp_footer', 'EWD_UFAQ_Print_JSON_LD_Schema' );
665
+ }
666
+
667
+ function EWD_UFAQ_Print_JSON_LD_Schema() {
668
+ global $ewd_ufaq_schema_data;
669
+
670
+ $Disable_Microdata = get_option("EWD_UFAQ_Disable_Microdata");
671
+
672
+ if ( is_array($ewd_ufaq_schema_data) and $Disable_Microdata != 'Yes' ) {
673
+ echo '<script type="application/ld+json" class="ewd-ufaq-ld-json-data">';
674
+ echo wp_json_encode( $ewd_ufaq_schema_data );
675
+ echo '</script>';
676
+ }
677
  }
678
 
679
  function EWD_UFAQ_Rand_Chars($CharLength = 10) {
html/OptionsPage.php CHANGED
@@ -16,6 +16,7 @@
16
  $Permalink_Type = get_option("EWD_UFAQ_Permalink_Type");
17
  $Show_TinyMCE = get_option("EWD_UFAQ_Show_TinyMCE");
18
  $Comments_On = get_option("EWD_UFAQ_Comments_On");
 
19
  $Access_Role = get_option("EWD_UFAQ_Access_Role");
20
 
21
  $Display_Style = get_option("EWD_UFAQ_Display_Style");
@@ -216,6 +217,22 @@
216
  </td>
217
  </tr>
218
  <tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
  <th scope="row">Include Permalink</th>
220
  <td>
221
  <fieldset><legend class="screen-reader-text"><span>Include Permalink</span></legend>
16
  $Permalink_Type = get_option("EWD_UFAQ_Permalink_Type");
17
  $Show_TinyMCE = get_option("EWD_UFAQ_Show_TinyMCE");
18
  $Comments_On = get_option("EWD_UFAQ_Comments_On");
19
+ $Disable_Microdata = get_option("EWD_UFAQ_Disable_Microdata");
20
  $Access_Role = get_option("EWD_UFAQ_Access_Role");
21
 
22
  $Display_Style = get_option("EWD_UFAQ_Display_Style");
217
  </td>
218
  </tr>
219
  <tr>
220
+ <th scope="row">Disable Microdata</th>
221
+ <td>
222
+ <fieldset><legend class="screen-reader-text"><span>Disable Microdata</span></legend>
223
+ <div class="ewd-ufaq-admin-hide-radios">
224
+ <label title='Yes'><input type='radio' name='disable_microdata' value='Yes' <?php if($Disable_Microdata == "Yes") {echo "checked='checked'";} ?> /> <span>Yes</span></label><br />
225
+ <label title='No'><input type='radio' name='disable_microdata' value='No' <?php if($Disable_Microdata == "No") {echo "checked='checked'";} ?> /> <span>No</span></label><br />
226
+ </div>
227
+ <label class="ewd-ufaq-admin-switch">
228
+ <input type="checkbox" class="ewd-ufaq-admin-option-toggle" data-inputname="disable_microdata" <?php if($Disable_Microdata == "Yes") {echo "checked='checked'";} ?>>
229
+ <span class="ewd-ufaq-admin-switch-slider round"></span>
230
+ </label>
231
+ <p>By default, the plugin adds FAQ page scheme when the shortcode is used. Select this option to disable this behaviour.</p>
232
+ </fieldset>
233
+ </td>
234
+ </tr>
235
+ <tr>
236
  <th scope="row">Include Permalink</th>
237
  <td>
238
  <fieldset><legend class="screen-reader-text"><span>Include Permalink</span></legend>
readme.txt CHANGED
@@ -279,7 +279,12 @@ Video 3 - FAQs Ordering
279
  26. FAQ widgets
280
 
281
 
282
- == Changelog ==
 
 
 
 
 
283
  = 1.8.26 =
284
  - Removing placeholder text from the admin
285
 
279
  26. FAQ widgets
280
 
281
 
282
+ == Changelog ==
283
+
284
+ = 1.8.27 =
285
+ - Changing the way the schema is included to the new JSON-LD format
286
+ - Adding an option to disable the schema
287
+
288
  = 1.8.26 =
289
  - Removing placeholder text from the admin
290