diff --git a/src/Settings.php b/src/Settings.php index ce0336c5..8e9de4d3 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -59,28 +59,6 @@ public static function init() { Plugin::VERSION ); - \wp_register_script( - 'AceEditor', - \plugin_dir_url(__FILE__)."../public/js/ace-builds/src-min-noconflict/ace.js", - array('jquery'), - Plugin::VERSION - ); - - \wp_localize_script( - 'AceEditor', - 'AceEditorLocalized', - array( - 'plugin_url' => \plugin_dir_url(__FILE__) . "../", - ) - ); - - \wp_enqueue_script( - "AceEditor", - \plugin_dir_url(__FILE__)."../public/js/ace-builds/src-min-noconflict/ace.js", - array("jquery"), - Plugin::VERSION - ); - \wp_register_style( 'RollbarWordpressSettings', \plugin_dir_url(__FILE__)."../public/css/RollbarWordpressSettings.css", @@ -89,20 +67,11 @@ public static function init() { ); \wp_enqueue_style('RollbarWordpressSettings'); }); - - \add_action('init', array(get_called_class(), 'registerSession')); \add_action('admin_post_rollbar_wp_restore_defaults', array(get_called_class(), 'restoreDefaultsAction')); \add_action('pre_update_option_rollbar_wp', array(get_called_class(), 'preUpdate')); } - - public static function registerSession() - { - if( ! session_id() && ! defined( 'DOING_CRON' ) ) { - session_start(); - } - } function addAdminMenu() { @@ -372,6 +341,13 @@ public static function flashRedirect($type, $message) public static function flashMessage($type, $message) { + // This is only designed to run in the admin for the main HTML request. + // If there is no session at this point something has gone terribly + // wrong, and we should bail out. + if( ! is_admin() || ! session_id() || wp_doing_cron() ) { + return; + } + $_SESSION['rollbar_wp_flash_message'] = array( "type" => $type, "message" => $message @@ -397,14 +373,18 @@ public static function preUpdate($settings) try { Plugin::instance()->enableMustUsePlugin(); } catch (\Exception $exception) { - self::flashMessage('error', 'Failed enabling the Must-Use plugin.'); + add_action('admin_notices', function () { + echo '

Error: failed to enable the Rollbar Must-Use plugin.

'; + }); $settings['enable_must_use_plugin'] = false; } } else { try { Plugin::instance()->disableMustUsePlugin(); } catch (\Exception $exception) { - self::flashMessage('error', 'Failed disabling the Must-Use plugin.'); + add_action('admin_notices', function () { + echo '

Error: failed to disable the Rollbar Must-Use plugin.

'; + }); $settings['enable_must_use_plugin'] = true; } }