@@ -59,7 +59,7 @@ class Bread
5959 *
6060 * @var integer
6161 */
62- private int $ requested_setting = 1 ;
62+ private int $ requested_setting = 0 ;
6363 private $ protocol ;
6464 private string $ tmp_dir ;
6565 /**
@@ -74,7 +74,6 @@ class Bread
7474 * @var array
7575 */
7676 private array $ translate = array ();
77- private bool $ generating_meeting_list = false ;
7877 private bool $ exporting_meeting_list = false ;
7978 /**
8079 * The wizard wants to know if we are generating the first meeting list for this site.
@@ -176,7 +175,7 @@ private static function rrmdir($dir)
176175 @rmdir ($ dir );
177176 }
178177 }
179- private function loadAllSettings ($ holder ): int
178+ public function loadAllSettings ($ holder ): int
180179 {
181180 if (isset ($ holder ['bread_preview_settings ' ])) {
182181 $ this ->allSettings = array ();
@@ -188,6 +187,7 @@ private function loadAllSettings($holder): int
188187 $ this ->allSettings = array ();
189188 $ this ->allSettings [1 ] = "Default Setting " ;
190189 $ this ->maxSetting = 1 ;
190+ $ this ->initial_setting = true ;
191191 } else {
192192 foreach ($ this ->allSettings as $ key => $ value ) {
193193 if ($ key > $ this ->maxSetting ) {
@@ -241,29 +241,26 @@ private function getCurrentMeetingListHolder(): array
241241 $ ret ['current-meeting-list ' ] = $ _REQUEST ['current-meeting-list ' ];
242242 } elseif (isset ($ _REQUEST ['export-meeting-list ' ])) {
243243 $ ret ['current-meeting-list ' ] = $ _REQUEST ['export-meeting-list ' ];
244- $ this ->exporting_meeting_list = true ;
245244 } elseif (isset ($ _COOKIE ['current-meeting-list ' ])) {
246245 $ ret ['current-meeting-list ' ] = $ _COOKIE ['current-meeting-list ' ];
247246 }
248- $ this ->generating_meeting_list = !empty ($ ret ) && !is_admin () && !$ this ->exporting_meeting_list ;
249247 return $ ret ;
250248 }
251- /**
252- * Undocumented function
253- *
254- * @return void
255- */
256249 public function generatingMeetingList (): bool
257250 {
258- return $ this -> generating_meeting_list ;
251+ return ( isset ( $ _REQUEST [ ' current-meeting-list ' ]) || isset ( $ _REQUEST [ ' preview-meeting-list ' ])) && ! is_admin () ;
259252 }
260253 public function exportingMeetingList (): bool
261254 {
262- return $ this -> exporting_meeting_list ;
255+ return isset ( $ _REQUEST [ ' export-meeting-list ' ]) && ! is_admin () ;
263256 }
264257 public function generateOptionName ($ current_setting )
265258 {
266- return Bread::OPTIONS_NAME . '_ ' . $ current_setting ;
259+ if ($ current_setting != 1 ) {
260+ return Bread::OPTIONS_NAME . '_ ' . $ current_setting ;
261+ } else {
262+ return Bread::OPTIONS_NAME ;
263+ }
267264 }
268265 /**
269266 * Retrieves the plugin options from the database.
@@ -278,19 +275,14 @@ public function &getConfigurationForSettingId($current_setting)
278275 if (is_array ($ this ->allSettings [$ current_setting ])) {
279276 $ this ->options = $ this ->allSettings [$ current_setting ];
280277 } else {
281- if ($ current_setting != 1 ) {
282- $ this ->optionsName = $ this ->generateOptionName ($ current_setting );
283- } else {
284- $ this ->optionsName = Bread::OPTIONS_NAME ;
285- }
278+ $ this ->optionsName = $ this ->generateOptionName ($ current_setting );
286279 //Don't forget to set up the default options
287280 if (!$ theOptions = get_option ($ this ->optionsName )) {
288281 if ($ current_setting != 1 ) {
289282 unset($ this ->allSettings [$ current_setting ]);
290283 update_option (Bread::SETTINGS , $ this ->allSettings );
291284 die ('Undefined setting: ' . $ current_setting );
292285 }
293- $ this ->initial_setting = true ;
294286 $ import_file = plugin_dir_path (__FILE__ ) . "../admin/templates/30/trifold-landscape-largefont.json " ;
295287 $ encode_options = file_get_contents ($ import_file );
296288 $ theOptions = json_decode ($ encode_options , true );
@@ -322,12 +314,12 @@ public function setOptionsName($name)
322314 }
323315 public function getRequestedSetting ()
324316 {
317+ if ($ this ->requested_setting == 0 ) {
318+ $ holder = $ this ->getCurrentMeetingListHolder ();
319+ $ this ->requested_setting = $ this ->loadAllSettings ($ holder );
320+ }
325321 return $ this ->requested_setting ;
326322 }
327- public function setRequestedSetting ($ id )
328- {
329- $ this ->requested_setting = $ id ;
330- }
331323 /**
332324 * Define the core functionality of the plugin.
333325 *
@@ -347,9 +339,6 @@ public function __construct()
347339 $ this ->plugin_name = 'bread ' ;
348340 $ this ->tmp_dir = $ this ->setup_temp_dir ();
349341 $ this ->protocol = (strpos (strtolower (home_url ()), "https " ) !== false ? "https " : "http " ) . ":// " ;
350-
351- $ holder = $ this ->getCurrentMeetingListHolder ();
352- $ this ->requested_setting = $ this ->loadAllSettings ($ holder );
353342 $ this ->bread_bmlt = new Bread_Bmlt ($ this );
354343
355344 $ this ->load_dependencies ();
@@ -383,7 +372,7 @@ public function getProtocol()
383372 *
384373 * @return bool true when no setting existed previously, ie, if we should create setting 1.
385374 */
386- public function getInitialSetting ()
375+ public function isInitialSetting ()
387376 {
388377 return $ this ->initial_setting ;
389378 }
@@ -775,7 +764,7 @@ private function renamed_option(string $old, string $new)
775764 */
776765 public function updateOptions ()
777766 {
778- update_option (Bread:: getOptionsName (), $ this ->options );
767+ update_option ($ this -> getOptionsName (), $ this ->options );
779768 }
780769 public static function get_TransientKey ($ setting ): string
781770 {
0 commit comments