@@ -8,7 +8,7 @@ static function install($update = false) {
88 global $ wpdb ;
99 $ wpdb -> show_errors ();
1010
11- // If new activation, run the initiatlize some variables first.
11+ // If new activation, initialize some variables first.
1212 if (!$ update ) self ::init ();
1313
1414 // CHAINED_QUIZZES
@@ -116,25 +116,31 @@ static function install($update = false) {
116116 $ wpdb ->query ($ sql );
117117 }
118118
119- // setup the default options (when not yet saved ever)
120- if (get_option ('chained_sender_name ' ) == '' ) {
119+ // Setup the default options (when not yet saved ever)
120+ if (get_option ('chained_sender_name ' ) == '' ) {
121121 update_option ('chained_sender_name ' , __ ('WordPress Admin ' , 'chained ' ));
122122 update_option ('chained_sender_email ' , get_option ('admin_email ' ));
123123 update_option ('chained_admin_subject ' , __ ('User results on {{quiz-name}} ' , 'chained ' ));
124124 update_option ('chained_user_subject ' , __ ('Your results on {{quiz-name}} ' , 'chained ' ));
125125 }
126126
127127 $ current_version = get_option ('chained_version ' );
128+ error_log ("Current 'chained_version' = " .$ current_version );
128129
129130 /** PERFORM VERSION-SPECIFIC UPGRADES HERE **/
130131 if ($ current_version < '2.2 ' ) {
131132 update_option ('chained_delete_data ' , 'no ' );
132- } else if ($ current_version < '4.0 ' ) {
133+ } elseif ($ current_version < '4.0 ' ) {
133134 update_option ('chained_debug_mode ' , 'off ' );
135+ } elseif ($ current_version < '5.0 ' ) {
136+ $ wpdb ->query ("ALTER TABLE " .CHAINED_RESULTS ." ADD COLUMN subjective TEXT AFTER description; " );
137+ $ wpdb ->query ("ALTER TABLE " .CHAINED_RESULTS ." ADD COLUMN objective TEXT AFTER subjective; " );
138+ $ wpdb ->query ("ALTER TABLE " .CHAINED_RESULTS ." ADD COLUMN assessment TEXT AFTER objective; " );
139+ $ wpdb ->query ("ALTER TABLE " .CHAINED_RESULTS ." ADD COLUMN plan TEXT AFTER assessment; " );
134140 }
135141
136142 // Set the current plugin version number.
137- update_option ('chained_version ' , '4 .0 ' );
143+ update_option ('chained_version ' , '5 .0 ' );
138144 // exit;
139145 }
140146
@@ -144,8 +150,9 @@ static function menu() {
144150
145151 add_menu_page (__ ('Triage Algorithm ' , 'chained ' ), __ ('Triage Algorithm ' , 'chained ' ), $ chained_caps , "chained_quizzes " , array ('ChainedQuizQuizzes ' , "manage " ));
146152 add_submenu_page ('chained_quizzes ' , __ ('Algorithms ' , 'chained ' ), __ ('Algorithms ' , 'chained ' ), $ chained_caps , 'chained_quizzes ' , array ('ChainedQuizQuizzes ' , "manage " ));
147- add_submenu_page ('chained_quizzes ' , __ ('Settings ' , 'chained ' ), __ ('Settings ' , 'chained ' ), 'manage_options ' , 'chainedquiz_options ' , array ('ChainedQuiz ' ,'options ' ));
153+ add_submenu_page ('chained_quizzes ' , __ ('Settings ' , 'chained ' ), __ ('Settings ' , 'chained ' ), 'manage_options ' , 'chainedquiz_options ' , array ('ChainedQuiz ' ,'options ' ));
148154 add_submenu_page ('chained_quizzes ' , __ ('Social Sharing ' , 'chained ' ), __ ('Social Sharing ' , 'chained ' ), $ chained_caps , 'chainedquiz_social_sharing ' , array ('ChainedSharing ' ,'options ' ));
155+ add_submenu_page ('chained_quizzes ' , __ ('Help ' , 'chained ' ), __ ('Help ' , 'chained ' ), $ chained_caps , 'chainedquiz_help ' , array ('ChainedQuiz ' ,'help ' ));
149156
150157 add_submenu_page (NULL , __ ('Chained Quiz Results ' , 'chained ' ), __ ('Chained Quiz Results ' , 'chained ' ), $ chained_caps , 'chainedquiz_results ' , array ('ChainedQuizResults ' ,'manage ' ));
151158 add_submenu_page (NULL , __ ('Chained Quiz Questions ' , 'chained ' ), __ ('Chained Quiz Questions ' , 'chained ' ), $ chained_caps , 'chainedquiz_questions ' , array ('ChainedQuizQuestions ' ,'manage ' ));
@@ -165,7 +172,7 @@ static function scripts() {
165172 'chained-common ' ,
166173 CHAINED_URL .'js/common.js ' ,
167174 false ,
168- '4 .0 ' ,
175+ '5 .0 ' ,
169176 false
170177 );
171178 wp_enqueue_script ("chained-common " );
@@ -180,37 +187,28 @@ static function init() {
180187 load_plugin_textdomain ( 'chained ' , false , CHAINED_RELATIVE_PATH ."/languages/ " );
181188 if (!session_id ()) @session_start ();
182189
183- // define table names
190+ // Define table names as named constants.
184191 define ( 'CHAINED_QUIZZES ' , $ wpdb ->prefix . "chained_quizzes " );
185192 define ( 'CHAINED_QUESTIONS ' , $ wpdb ->prefix . "chained_questions " );
186193 define ( 'CHAINED_CHOICES ' , $ wpdb ->prefix . "chained_choices " );
187194 define ( 'CHAINED_RESULTS ' , $ wpdb ->prefix . "chained_results " );
188195 define ( 'CHAINED_COMPLETED ' , $ wpdb ->prefix . "chained_completed " );
189196 define ( 'CHAINED_USER_ANSWERS ' , $ wpdb ->prefix . "chained_user_answers " );
190- define ( 'CHAINED_VERSION ' , get_option ('chained_version ' ));
197+ // define( 'CHAINED_VERSION', get_option('chained_version'));
191198
192- // shortcodes
199+ // Register shortcodes offered by this plugin.
193200 add_shortcode ('triage-algorithm ' , array ("TriageShortcodes " , "algorithmShortcodeHandler " ));
194201 add_shortcode ('triage-submissions ' , array ("TriageShortcodes " , "responsesShortcodeHandler " ));
195202 add_shortcode ('chained-share ' , array ("ChainedSharing " , "display " ));
196203
197- // once daily delete empty records older than 1 day
198- // if(get_option('chainedquiz_cleanup') != date("Y-m-d") and defined('CHAINED_COMPLETED')) {
199- // $wpdb->query("DELETE FROM ".CHAINED_COMPLETED." WHERE not_empty=0 AND datetime < '".current_time('mysql')."' - INTERVAL 24 HOUR");
200- // update_option('chainedquiz_cleanup', date("Y-m-d"));
201- // }
202-
203204 add_action ('template_redirect ' , array ('ChainedSharing ' , 'social_share_snippet ' ));
204205
205206 // default CSV separator if not set
206- if (get_option ('chained_csv_delim ' ) == '' ) {
207+ if (get_option ('chained_csv_delim ' ) == '' ) {
207208 update_option ('chained_csv_delim ' , ', ' );
208209 update_option ('chained_csv_quotes ' , '1 ' );
209210 }
210211
211- // $version = get_option('chained_version');
212- // if($version < '0.8') self::install(true);
213-
214212 // Go ahead and activate the plugin now by running the install script.
215213 self ::install (true );
216214 }
@@ -264,6 +262,6 @@ static function options() {
264262 }
265263
266264 static function help () {
267- require (CHAINED_PATH ."/views/help.php " );
265+ require (CHAINED_PATH ."/views/help.html. php " );
268266 }
269267}
0 commit comments