@@ -248,9 +248,6 @@ function pwsix_process_settings_export()
248248 if (!isset ($ _POST ['pwsix_export_nonce ' ]) || ! wp_verify_nonce ($ _POST ['pwsix_export_nonce ' ], 'pwsix_export_nonce ' )) {
249249 return ;
250250 }
251- if (! current_user_can ('manage_bread ' )) { // TODO: Is this necessary? Why not let the user make a copy
252- return ;
253- }
254251 $ this ->download_settings_inner ();
255252 }
256253 function download_settings ()
@@ -317,13 +314,13 @@ function exportLogFile($file)
317314 }
318315 function current_user_can_modify ()
319316 {
320- if (! current_user_can ('manage_bread ' )) {
321- return false ;
322- }
323317 $ user = wp_get_current_user ();
324318 if (in_array ('administrator ' , $ user ->roles )) {
325319 return true ;
326320 }
321+ if (! current_user_can ('manage_bread ' )) {
322+ return false ;
323+ }
327324 $ authors_safe = $ this ->bread ->getOption ('authors ' );
328325 if (!is_array ($ authors_safe ) || empty ($ authors_safe )) {
329326 return true ;
@@ -335,10 +332,17 @@ function current_user_can_modify()
335332 }
336333 function current_user_can_create ()
337334 {
338- if (! current_user_can ('manage_bread ' )) {
339- return false ;
335+ $ user = wp_get_current_user ();
336+ if (in_array ('administrator ' , $ user ->roles )) {
337+ return true ;
338+ }
339+ if (current_user_can ('manage_options ' )) {
340+ return true ;
341+ }
342+ if (current_user_can ('manage_bread ' )) {
343+ return true ;
340344 }
341- return true ;
345+ return false ;
342346 }
343347 /**
344348 * Process a settings import from a json file
@@ -348,7 +352,7 @@ function pwsix_process_settings_import()
348352 if (empty ($ _REQUEST ['pwsix_import_nonce ' ]) || !wp_verify_nonce ($ _REQUEST ['pwsix_import_nonce ' ], 'pwsix_import_nonce ' )) {
349353 return ;
350354 }
351- if (! current_user_can ( ' manage_bread ' )) {
355+ if (! $ this -> current_user_can_modify ( )) {
352356 return ;
353357 }
354358 $ this ->bread ->getConfigurationForSettingId ($ this ->bread ->getRequestedSetting ());
@@ -376,7 +380,7 @@ function pwsix_process_settings_import()
376380 update_option ($ this ->bread ->getOptionsName (), $ this ->bread ->getOptions ());
377381 setcookie ('current-meeting-list ' , $ this ->bread ->getRequestedSetting (), time () + 10 );
378382 setcookie ('bread_import_file ' , $ import_file , time () + 10 );
379- wp_safe_redirect (admin_url ('?page=class-bread-admin.php ' ));
383+ wp_safe_redirect (admin_url ('?page=bmlt-enabled-bread ' ));
380384 }
381385 function my_theme_add_editor_styles ()
382386 {
@@ -433,11 +437,15 @@ function admin_submenu_link($parent_slug)
433437 activate_bread ();
434438 $ this ->bmltEnabled_admin ->createMenu ();
435439
440+ $ cap = 'manage_options ' ;
441+ if (!current_user_can ($ cap )) {
442+ $ cap = 'manage_bread ' ;
443+ }
436444 $ this ->hook = add_submenu_page (
437445 $ parent_slug ,
438446 'Printable Meeting Lists ' ,
439447 'Printable Meeting Lists ' ,
440- ' manage_bread ' ,
448+ $ cap ,
441449 'bmlt-enabled-bread ' ,
442450 array (&$ this , 'admin_options_page ' ),
443451 2
0 commit comments