@@ -34,6 +34,7 @@ function mathilda_tools_controller() {
3434 $ handbook_show =false ;
3535 $ mathilda_reset =false ;
3636 $ import_break =false ;
37+ $ cron_status =false ;
3738
3839 // Load Tweets
3940 if (isset ($ _GET ['cron ' ])) {
@@ -42,6 +43,13 @@ function mathilda_tools_controller() {
4243 $ run_cron =true ;
4344 }
4445 }
46+ // Cron Status
47+ if (isset ($ _GET ['cronstatus ' ])) {
48+ if ($ _GET ['cronstatus ' ]=='true ' )
49+ {
50+ $ cron_status =true ;
51+ }
52+ }
4553 // Scripting
4654 if (isset ($ _GET ['scripting ' ])) {
4755 if ($ _GET ['scripting ' ]=='true ' )
@@ -148,6 +156,8 @@ function mathilda_tools_controller() {
148156function mathilda_tools () {
149157
150158 /* Dynamic Labels */
159+
160+ /* Import Status */
151161 $ label_import_botton ="" ;
152162 $ label_import_status =get_option ('mathilda_import_running ' );
153163 if ($ label_import_status ==0 ) {
@@ -156,6 +166,15 @@ function mathilda_tools() {
156166 $ label_import_botton ="Status! " ;
157167 }
158168
169+ /* cron Status */
170+ $ label_cronstatus_button ="" ;
171+ $ label_cronstatus_status =get_option ('mathilda_cron_status ' );
172+ if ($ label_cronstatus_status ==0 ) {
173+ $ label_cronstatus_button ="Activate! " ;
174+ } else {
175+ $ label_cronstatus_button ="Deactivate! " ;
176+ }
177+
159178 /* Headline */
160179 echo '<h1 class="mathilda_tools_headline">Tweets</h1>
161180 <p class="mathilda_tools_description">Mathilda Tools</p> ' ;
@@ -193,6 +212,36 @@ function mathilda_tools() {
193212 }
194213 }
195214
215+ // Auto Load
216+ if (isset ($ _GET ['cronstatus ' ])) {
217+ if ($ _GET ['cronstatus ' ]=='true ' )
218+ {
219+ $ autoload_status =get_option ('mathilda_cron_status ' );
220+ if ($ autoload_status ) {
221+ update_option ('mathilda_cron_status ' ,'0 ' );
222+ $ label_cronstatus_button ="Activate! " ;
223+ echo '<div class="updated fade">
224+ <p><strong>Auto Load has been deactivated.</strong></p>
225+ </div> ' ;
226+ } else {
227+
228+ $ initial_load = get_option ('mathilda_initial_load ' );
229+ if ($ initial_load ==1 ) {
230+ update_option ('mathilda_cron_status ' ,'1 ' );
231+ $ label_cronstatus_button ="Deactivate! " ;
232+ echo '<div class="updated fade">
233+ <p><strong>Auto Load has been activated.</strong></p>
234+ </div> ' ;
235+ } else {
236+ echo '<div class="notice notice-warning is-dismissible">
237+ <p><strong>Auto Load can still not be activated. You have to run an initial load manually first (Load Tweets).</strong></p>
238+ </div> ' ;
239+ }
240+
241+ }
242+ }
243+ }
244+
196245 // Embed Reset
197246 if (isset ($ _GET ['resetisconfirmed ' ])) {
198247 if ($ _GET ['resetisconfirmed ' ]=='true ' )
@@ -226,6 +275,16 @@ function mathilda_tools() {
226275 <a class="button" href=" ' .admin_url ().'tools.php?page=mathilda-tools-menu&cron=true" >Run!</a>
227276 </td>
228277 </tr>
278+
279+ <!-- Status Cron -->
280+ <tr valign="top">
281+ <th scope="row">
282+ <label for="cron">Auto Load</label>
283+ </th>
284+ <td>
285+ <a class="button" href=" ' .admin_url ().'tools.php?page=mathilda-tools-menu&cronstatus=true"> ' .$ label_cronstatus_button .'</a>
286+ </td>
287+ </tr>
229288
230289 <!-- Load Twitter Export -->
231290 <tr valign="top">
0 commit comments