PluginProbe
Ultimate FAQ Accordion Plugin / trunk
Ultimate FAQ Accordion Plugin vtrunk
2.4.14 2.4.13 2.4.12 2.4.11 2.4.10 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 241 releases
ultimate-faqs / includes / BackwardsCompatibility.class.php

BackwardsCompatibility.class.php in Ultimate FAQ Accordion Plugin trunk, at includes/BackwardsCompatibility.class.php

197 lines 12.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit;
3
4 if ( ! class_exists( 'ewdufaqBackwardsCompatibility' ) ) {
5 /**
6 * Class to handle transforming the plugin settings from the
7 * previous style (individual options) to the new one (options array)
8 *
9 * @since 2.0.0
10 */
11 class ewdufaqBackwardsCompatibility {
12
13 public function __construct() {
14
15 if ( empty( get_option( 'ewd-ufaq-settings' ) ) and get_option( 'EWD_UFAQ_Full_Version' ) ) { $this->run_backwards_compat(); }
16 elseif ( ! get_option( 'ewd-ufaq-permission-level' ) ) { update_option( 'ewd-ufaq-permission-level', 1 ); }
17 }
18
19 public function run_backwards_compat() {
20
21 $settings = array(
22 'custom-css' => get_option( 'EWD_UFAQ_Custom_CSS' ),
23 'disable-faq-toggle' => get_option( 'EWD_UFAQ_Toggle' ) == 'Yes' ? false : true,
24 'faq-category-toggle' => get_option( 'EWD_UFAQ_Category_Toggle' ) == 'Yes' ? true : false,
25 'faq-category-accordion' => get_option( 'EWD_UFAQ_Category_Accordion' ) == 'Yes' ? true : false,
26 'expand-collapse-all' => get_option( 'EWD_UFAQ_Expand_Collapse_All' ) == 'Yes' ? true : false,
27 'faq-accordion' => get_option( 'EWD_UFAQ_FAQ_Accordion' ) == 'Yes' ? true : false,
28 'hide-categories' => get_option( 'EWD_UFAQ_Hide_Categories' ) == 'Yes' ? true : false,
29 'hide-tags' => get_option( 'EWD_UFAQ_Hide_Tags' ) == 'Yes' ? true : false,
30 'scroll-to-top' => get_option( 'EWD_UFAQ_Scroll_To_Top' ) == 'Yes' ? true : false,
31 'display-all-answers' => get_option( 'EWD_UFAQ_Display_All_Answers' ) == 'Yes' ? true : false,
32 'display-author' => get_option( 'EWD_UFAQ_Display_Author' ) == 'Yes' ? true : false,
33 'display-date' => get_option( 'EWD_UFAQ_Display_Date' ) == 'Yes' ? true : false,
34 'display-back-to-top' => get_option( 'EWD_UFAQ_Display_Back_To_Top' ) == 'Yes' ? true : false,
35 'include-permalink' => get_option( 'EWD_UFAQ_Include_Permalink' ) == 'Yes' ? 'both' : ( get_option( 'EWD_UFAQ_Include_Permalink' ) == 'No' ? 'none' : strtolower( get_option( 'EWD_UFAQ_Include_Permalink' ) ) ),
36 'permalink-type' => get_option( 'EWD_UFAQ_Permalink_Type' ) == 'SamePage' ? 'same_page' : 'individual_page',
37 'comments-on' => get_option( 'EWD_UFAQ_Comments_On' ) == 'Yes' ? true : false,
38 'disable-microdata' => get_option( 'EWD_UFAQ_Disable_Microdata' ) == 'Yes' ? true : false,
39 'access-role' => get_option( 'EWD_UFAQ_Access_Role' ),
40 'display-style' => strtolower( get_option( 'EWD_UFAQ_Display_Style' ) ),
41 'number-of-columns' => strtolower( get_option( 'EWD_UFAQ_FAQ_Number_Of_Columns' ) ),
42 'responsive-columns' => get_option( 'EWD_UFAQ_Responsive_Columns' ) == 'Yes' ? true : false,
43 'color-block-shape' => strtolower( get_option( 'EWD_UFAQ_Color_Block_Shape' ) ),
44 'faqs-per-page' => get_option( 'EWD_UFAQ_FAQs_Per_Page' ),
45 'page-type' => strtolower( get_option( 'EWD_UFAQ_Page_Type' ) ),
46 'faq-ratings' => get_option( 'EWD_UFAQ_FAQ_Ratings' ) == 'Yes' ? true : false,
47 'thumbs-up-image' => get_option( 'EWD_UFAQ_Thumbs_Up_Image' ),
48 'thumbs-down-image' => get_option( 'EWD_UFAQ_Thumbs_Down_Image' ),
49 'woocommerce-integration' => get_option( 'EWD_UFAQ_WooCommerce_FAQs' ) == 'Yes' ? true : false,
50 'woocommerce-use-product' => get_option( 'EWD_UFAQ_Use_Product' ) == 'Yes' ? true : false,
51 'wpforms-integration' => get_option( 'EWD_UFAQ_WPForms_Integration' ) == 'Yes' ? true : false,
52 'wpforms-post-count' => get_option( 'EWD_UFAQ_WPForms_Post_Count' ),
53 'wpforms-faq-location' => strtolower( get_option( 'EWD_UFAQ_WPForms_FAQ_Location' ) ),
54 'reveal-effect' => strtolower( get_option( 'EWD_UFAQ_Reveal_Effect' ) ),
55 'pretty-permalinks' => get_option( 'EWD_UFAQ_Pretty_Permalinks' ) == 'Yes' ? true : false,
56 'allow-proposed-answer' => get_option( 'EWD_UFAQ_Allow_Proposed_Answer' ) == 'Yes' ? true : false,
57 'submit-custom-fields' => get_option( 'EWD_UFAQ_Submit_Custom_Fields' ) == 'Yes' ? true : false,
58 'submit-question-captcha' => get_option( 'EWD_UFAQ_Submit_Question_Captcha' ) == 'Yes' ? true : false,
59 'submitted-default-category' => get_option( 'EWD_UFAQ_Submitted_Default_Category' ),
60 'admin-question-notification' => get_option( 'EWD_UFAQ_Admin_Question_Notification' ) == 'Yes' ? true : false,
61 'admin-notification-email' => get_option( 'EWD_UFAQ_Admin_Notification_Email' ),
62 'submit-faq-email' => get_option( 'EWD_UFAQ_Submit_FAQ_Email' ),
63 'auto-complete-titles' => get_option( 'EWD_UFAQ_Auto_Complete_Titles' ) == 'Yes' ? true : false,
64 'highlight-search-term' => get_option( 'EWD_UFAQ_Highlight_Search_Term' ) == 'Yes' ? true : false,
65 'slug-base' => get_option( 'EWD_UFAQ_Slug_Base' ),
66 'social-media' => array_diff( explode( ',', strtolower( get_option( 'EWD_UFAQ_Social_Media' ) ) ), array( 'blank' ) ),
67 'faq-elements-order' => $this->convert_elements_order(),
68 'slug-base' => get_option( 'EWD_UFAQ_Slug_Base' ),
69 'group-by-category' => get_option( 'EWD_UFAQ_Group_By_Category' ) == 'Yes' ? true : false,
70 'group-by-category-count' => get_option( 'EWD_UFAQ_Group_By_Category_Count' ) == 'Yes' ? true : false,
71 'category-order-by' => strtolower( get_option( 'EWD_UFAQ_Group_By_Order_By' ) ),
72 'category-order' => strtolower( get_option( 'EWD_UFAQ_Group_By_Order' ) ),
73 'faq-order-by' => strtolower( get_option( 'EWD_UFAQ_Order_By' ) ),
74 'faq-order' => strtolower( get_option( 'EWD_UFAQ_Order' ) ),
75 'faq-fields' => $this->convert_field_array(),
76 'hide-blank-fields' => get_option( 'EWD_UFAQ_Hide_Blank_Fields' ) == 'Yes' ? true : false,
77 'label-posted' => get_option( 'EWD_UFAQ_Posted_Label' ),
78 'label-by' => get_option( 'EWD_UFAQ_By_Label' ),
79 'label-on' => get_option( 'EWD_UFAQ_On_Label' ),
80 'label-categories' => get_option( 'EWD_UFAQ_Category_Label' ),
81 'label-tags' => get_option( 'EWD_UFAQ_Tag_Label' ),
82 'label-enter-question' => get_option( 'EWD_UFAQ_Enter_Question_Label' ),
83 'label-search' => get_option( 'EWD_UFAQ_Search_Label' ),
84 'label-permalink' => get_option( 'EWD_UFAQ_Permalink_Label' ),
85 'label-back-to-top' => get_option( 'EWD_UFAQ_Back_To_Top_Label' ),
86 'label-woocommerce-tab' => get_option( 'EWD_UFAQ_WooCommerce_Tab_Label' ),
87 'label-share-faq' => get_option( 'EWD_UFAQ_Share_FAQ_Label' ),
88 'label-ratings' => get_option( 'EWD_UFAQ_Find_FAQ_Helpful_Label' ),
89 'label-search-placeholder' => get_option( 'EWD_UFAQ_Search_Placeholder_Label' ),
90 'label-thank-you-submit' => get_option( 'EWD_UFAQ_Thank_You_Submit_Label' ),
91 'label-submit-question' => get_option( 'EWD_UFAQ_Submit_Question_Label' ),
92 'label-please-fill-form-below' => get_option( 'EWD_UFAQ_Please_Fill_Form_Below_Label' ),
93 'label-send-question' => get_option( 'EWD_UFAQ_Send_Question_Label' ),
94 'label-question-title' => get_option( 'EWD_UFAQ_Question_Title_Label' ),
95 'label-question-title-explanation' => get_option( 'EWD_UFAQ_What_Question_Being_Answered_Label' ),
96 'label-proposed-answer' => get_option( 'EWD_UFAQ_Proposed_Answer_Label' ),
97 'label-question-author' => get_option( 'EWD_UFAQ_Review_Author_Label' ),
98 'label-question-author-explanation' => get_option( 'EWD_UFAQ_What_Name_With_Review_Label' ),
99 'label-captcha-image-number' => get_option( 'EWD_UFAQ_Captcha_Image_Number_Label' ),
100 'label-retrieving-results' => get_option( 'EWD_UFAQ_Retrieving_Results' ),
101 'label-no-results-found' => get_option( 'EWD_UFAQ_No_Results_Found_Text' ),
102 'styling-toggle-background-color' => get_option( 'EWD_UFAQ_Styling_Default_Bg_Color' ),
103 'styling-toggle-font-color' => get_option( 'EWD_UFAQ_Styling_Default_Font_Color' ),
104 'styling-toggle-border-size' => get_option( 'EWD_UFAQ_Styling_Default_Border_Size' ),
105 'styling-toggle-border-color' => get_option( 'EWD_UFAQ_Styling_Default_Border_Color' ),
106 'styling-toggle-border-radius' => get_option( 'EWD_UFAQ_Styling_Default_Border_Radius' ),
107 'styling-toggle-symbol-size' => get_option( 'EWD_UFAQ_Styling_Toggle_Symbol_Size' ),
108 'styling-block-background-color' => get_option( 'EWD_UFAQ_Styling_Block_Bg_Color' ),
109 'styling-block-font-color' => get_option( 'EWD_UFAQ_Styling_Block_Font_Color' ),
110 'styling-list-font' => get_option( 'EWD_UFAQ_Styling_List_Font' ),
111 'styling-list-font-size' => get_option( 'EWD_UFAQ_Styling_List_Font_Size' ),
112 'styling-list-font-color' => get_option( 'EWD_UFAQ_Styling_List_Font_Color' ),
113 'styling-list-margin' => get_option( 'EWD_UFAQ_Styling_List_Margin' ),
114 'styling-list-padding' => get_option( 'EWD_UFAQ_Styling_List_Padding' ),
115 'styling-question-font' => get_option( 'EWD_UFAQ_Styling_Question_Font' ),
116 'styling-question-font-size' => get_option( 'EWD_UFAQ_Styling_Question_Font_Size' ),
117 'styling-question-font-color' => get_option( 'EWD_UFAQ_Styling_Question_Font_Color' ),
118 'styling-question-margin' => get_option( 'EWD_UFAQ_Styling_Question_Margin' ),
119 'styling-question-padding' => get_option( 'EWD_UFAQ_Styling_Question_Padding' ),
120 'styling-question-icon-top-margin' => get_option( 'EWD_UFAQ_Styling_Question_Icon_Top_Margin' ),
121 'styling-answer-font' => get_option( 'EWD_UFAQ_Styling_Answer_Font' ),
122 'styling-answer-font-size' => get_option( 'EWD_UFAQ_Styling_Answer_Font_Size' ),
123 'styling-answer-font-color' => get_option( 'EWD_UFAQ_Styling_Answer_Font_Color' ),
124 'styling-answer-margin' => get_option( 'EWD_UFAQ_Styling_Answer_Margin' ),
125 'styling-answer-padding' => get_option( 'EWD_UFAQ_Styling_Answer_Padding' ),
126 'styling-postdate-font' => get_option( 'EWD_UFAQ_Styling_Postdate_Font' ),
127 'styling-postdate-font-size' => get_option( 'EWD_UFAQ_Styling_Postdate_Font_Size' ),
128 'styling-postdate-font-color' => get_option( 'EWD_UFAQ_Styling_Postdate_Font_Color' ),
129 'styling-postdate-margin' => get_option( 'EWD_UFAQ_Styling_Postdate_Margin' ),
130 'styling-postdate-padding' => get_option( 'EWD_UFAQ_Styling_Postdate_Padding' ),
131 'styling-category-heading-font' => get_option( 'EWD_UFAQ_Styling_Category_Heading_Font' ),
132 'styling-category-heading-font-size' => get_option( 'EWD_UFAQ_Styling_Category_Heading_Font_Size' ),
133 'styling-category-heading-font-color' => get_option( 'EWD_UFAQ_Styling_Category_Heading_Font_Color' ),
134 'styling-category-font' => get_option( 'EWD_UFAQ_Styling_Category_Font' ),
135 'styling-category-font-size' => get_option( 'EWD_UFAQ_Styling_Category_Font_Size' ),
136 'styling-category-font-color' => get_option( 'EWD_UFAQ_Styling_Category_Font_Color' ),
137 'styling-category-margin' => get_option( 'EWD_UFAQ_Styling_Category_Margin' ),
138 'styling-category-padding' => get_option( 'EWD_UFAQ_Styling_Category_Padding' ),
139 'styling-category-heading-type' => get_option( 'EWD_UFAQ_Styling_Category_Heading_Type' ),
140 'styling-faq-heading-type' => get_option( 'EWD_UFAQ_Styling_FAQ_Heading_Type' ),
141 'styling-toggle-symbol' => get_option( 'EWD_UFAQ_Toggle_Symbol' ),
142 );
143
144 add_option( 'ewd-ufaq-review-ask-time', get_option( 'EWD_UFAQ_Ask_Review_Date' ) );
145 add_option( 'ewd-ufaq-installation-time', get_option( 'EWD_UFAQ_Install_Time' ) );
146
147 update_option( 'ewd-ufaq-permission-level', get_option( 'EWD_UFAQ_Full_Version' ) == 'Yes' ? 2 : 1 );
148
149 update_option( 'ewd-ufaq-settings', $settings );
150 }
151
152 public function convert_elements_order() {
153
154 $elements_order = array();
155
156 $old_elements = get_option( 'EWD_UFAQ_FAQ_Elements' );
157
158 foreach ( $old_elements as $old_element ) {
159
160 $elements_order[ strtolower( $old_element ) ] = $this->get_element_label( $old_element );
161 }
162
163 return json_encode( $elements_order );
164 }
165
166 public function convert_field_array() {
167
168 $old_faq_fields = get_option( 'EWD_UFAQ_FAQ_Fields' );
169 $new_faq_fields = array();
170
171 foreach ( $old_faq_fields as $old_faq_field ) {
172
173 $new_field = array(
174 'id' => $old_faq_field['FieldID'],
175 'name' => $old_faq_field['FieldName'],
176 'type' => $old_faq_field['FieldType'],
177 'options' => ! empty( $old_faq_field['FieldValues'] ) ? $old_faq_field['FieldValues'] : '',
178 );
179
180 $new_faq_fields[] = $new_field;
181 }
182
183 return json_encode( $new_faq_fields );
184 }
185
186 public function get_element_label( $element ) {
187
188 if ( $element == 'Author_Date' ) { return 'Author/Date'; }
189 elseif ( $element == 'Custom_Fields' ) { return 'Custom Fields'; }
190 elseif ( $element == 'Social_Media' ) { return 'Social Media'; }
191 elseif ( $element == 'Back_To_Top' ) { return 'Back to Top'; }
192
193 return $element;
194 }
195 }
196
197 }