-
Notifications
You must be signed in to change notification settings - Fork 19
/
wordpress-sentry.php
executable file
·67 lines (49 loc) · 1.47 KB
/
wordpress-sentry.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/*
Plugin Name: WordPress Sentry Client
Plugin URI: http://www.hzdg.com
Description: Sends PHP errors to Django Sentry
Author: Ryan Bagwell
Version: 1
Author URI: http://www.ryanbagwell.com
*/
require_once( dirname(__FILE__) . '/class.wp-raven-client.php' );
class WPSentry extends WP_Raven_Client {
private static $instance = null;
public function __construct() {
add_action('admin_menu', array($this, 'addOptionsPage'));
if (is_admin() && $_POST)
$this->saveOptions();
parent::__construct();
static::$instance = $this;
}
public function addOptionsPage() {
add_options_page('Sentry Error Reporting Settings', 'Sentry', 'edit_pages', 'sentrysettings', array($this, 'printOptionsHTML'));
}
public function printOptionsHTML() {
$error_levels = $this->errorLevelMap;
$settings = $this->settings;
require_once( dirname(__FILE__) . '/optionspage.html.php' );
}
public function saveOptions() {
if (!isset($_POST['sentry_dsn']) || !isset($_POST['sentry_reporting_level']))
return;
update_option('sentry-settings', array(
'dsn' => $_POST['sentry_dsn'],
'reporting_level' => $_POST['sentry_reporting_level']
));
}
public function getSettings() {
return $this->settings;
}
public static function load() {
try {
$wps = new WPSentry();
} catch (Exception $e) {
}
}
public static function getInstance() {
return self::$instance;
}
}
add_action('plugins_loaded', array('WPSentry', 'load'));