Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 13 additions & 33 deletions src/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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()
{
Expand Down Expand Up @@ -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
Expand All @@ -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 '<div class="error notice"><p><strong>Error:</strong> failed to enable the Rollbar Must-Use plugin.</p></div>';
});
$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 '<div class="error notice"><p><strong>Error:</strong> failed to disable the Rollbar Must-Use plugin.</p></div>';
});
$settings['enable_must_use_plugin'] = true;
}
}
Expand Down