-
Notifications
You must be signed in to change notification settings - Fork 21
/
rollbar.php
executable file
·124 lines (106 loc) · 3.16 KB
/
rollbar.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
* Plugin Name: Rollbar
* Plugin URI: https://wordpress.org/plugins/rollbar/
* Description: Rollbar full-stack error tracking for WordPress
* Version: 1.0.2
* Author: flowdee
* Author URI: http://flowdee.de
* Text Domain: rollbar
*
* @package RollbarWP
* @author flowdee
* @copyright Copyright (c) flowdee
*/
// Exit if accessed directly
if( !defined( 'ABSPATH' ) ) exit;
if( !class_exists( 'Rollbar_WP' ) ) {
/**
* Main Rollbar_WP class
*
* @since 1.0.0
*/
class Rollbar_WP {
/**
* @var Rollbar_WP $instance The one true Rollbar_WP
* @since 1.0.0
*/
private static $instance;
/**
* Get active instance
*
* @access public
* @since 1.0.0
* @return object self::$instance The one true Rollbar_WP
*/
public static function instance() {
if( !self::$instance ) {
self::$instance = new Rollbar_WP();
self::$instance->setup_constants();
self::$instance->includes();
self::$instance->load_textdomain();
self::$instance->hooks();
}
return self::$instance;
}
/**
* Setup plugin constants
*
* @access private
* @since 1.0.0
* @return void
*/
private function setup_constants() {
// Plugin version
define( 'ROLLBAR_WP_VER', '1.0.2' );
// Plugin path
define( 'ROLLBAR_WP_DIR', plugin_dir_path( __FILE__ ) );
// Plugin URL
define( 'ROLLBAR_WP_URL', plugin_dir_url( __FILE__ ) );
}
/**
* Include necessary files
*
* @access private
* @since 1.0.0
* @return void
*/
private function includes() {
// Include scripts
require_once ROLLBAR_WP_DIR . 'includes/class.settings.php';
require_once ROLLBAR_WP_DIR . 'includes/functions.php';
}
/**
* Run action and filter hooks
*
* @access private
* @since 1.0.0
* @return void
*/
private function hooks() {
add_action('init', 'rollbar_wp_initialize_php_logging');
add_action('wp_head', 'rollbar_wp_initialize_js_logging');
}
/**
* Internationalization
*
* @access public
* @since 1.0.0
* @return void
*/
public function load_textdomain() {
load_plugin_textdomain( 'rollbar', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
}
} // End if class_exists check
/**
* The main function responsible for returning the one true Rollbar_WP
* instance to functions everywhere
*
* @since 1.0.0
* @return \Rollbar_WP The one true Rollbar_WP
*/
function Rollbar_WP_load() {
return Rollbar_WP::instance();
}
add_action( 'plugins_loaded', 'Rollbar_WP_load' );