@@ -59,28 +59,6 @@ public static function init() {
5959 Plugin::VERSION
6060 );
6161
62- \wp_register_script (
63- 'AceEditor ' ,
64- \plugin_dir_url (__FILE__ )."../public/js/ace-builds/src-min-noconflict/ace.js " ,
65- array ('jquery ' ),
66- Plugin::VERSION
67- );
68-
69- \wp_localize_script (
70- 'AceEditor ' ,
71- 'AceEditorLocalized ' ,
72- array (
73- 'plugin_url ' => \plugin_dir_url (__FILE__ ) . "../ " ,
74- )
75- );
76-
77- \wp_enqueue_script (
78- "AceEditor " ,
79- \plugin_dir_url (__FILE__ )."../public/js/ace-builds/src-min-noconflict/ace.js " ,
80- array ("jquery " ),
81- Plugin::VERSION
82- );
83-
8462 \wp_register_style (
8563 'RollbarWordpressSettings ' ,
8664 \plugin_dir_url (__FILE__ )."../public/css/RollbarWordpressSettings.css " ,
@@ -89,20 +67,11 @@ public static function init() {
8967 );
9068 \wp_enqueue_style ('RollbarWordpressSettings ' );
9169 });
92-
93- \add_action ('init ' , array (get_called_class (), 'registerSession ' ));
9470
9571 \add_action ('admin_post_rollbar_wp_restore_defaults ' , array (get_called_class (), 'restoreDefaultsAction ' ));
9672
9773 \add_action ('pre_update_option_rollbar_wp ' , array (get_called_class (), 'preUpdate ' ));
9874 }
99-
100- public static function registerSession ()
101- {
102- if ( ! session_id () && ! defined ( 'DOING_CRON ' ) ) {
103- session_start ();
104- }
105- }
10675
10776 function addAdminMenu ()
10877 {
@@ -372,6 +341,13 @@ public static function flashRedirect($type, $message)
372341
373342 public static function flashMessage ($ type , $ message )
374343 {
344+ // This is only designed to run in the admin for the main HTML request.
345+ // If there is no session at this point something has gone terribly
346+ // wrong, and we should bail out.
347+ if ( ! is_admin () || ! session_id () || wp_doing_cron () ) {
348+ return ;
349+ }
350+
375351 $ _SESSION ['rollbar_wp_flash_message ' ] = array (
376352 "type " => $ type ,
377353 "message " => $ message
@@ -397,14 +373,18 @@ public static function preUpdate($settings)
397373 try {
398374 Plugin::instance ()->enableMustUsePlugin ();
399375 } catch (\Exception $ exception ) {
400- self ::flashMessage ('error ' , 'Failed enabling the Must-Use plugin. ' );
376+ add_action ('admin_notices ' , function () {
377+ echo '<div class="error notice"><p><strong>Error:</strong> failed to enable the Rollbar Must-Use plugin.</p></div> ' ;
378+ });
401379 $ settings ['enable_must_use_plugin ' ] = false ;
402380 }
403381 } else {
404382 try {
405383 Plugin::instance ()->disableMustUsePlugin ();
406384 } catch (\Exception $ exception ) {
407- self ::flashMessage ('error ' , 'Failed disabling the Must-Use plugin. ' );
385+ add_action ('admin_notices ' , function () {
386+ echo '<div class="error notice"><p><strong>Error:</strong> failed to disable the Rollbar Must-Use plugin.</p></div> ' ;
387+ });
408388 $ settings ['enable_must_use_plugin ' ] = true ;
409389 }
410390 }
0 commit comments