@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public static function load() |
23 | 23 | { |
24 | - if( empty( static::$instance )) { |
|
24 | + if( empty( static::$instance ) ) { |
|
25 | 25 | static::$instance = new static; |
26 | 26 | } |
27 | 27 | return static::$instance; |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function __construct() |
34 | 34 | { |
35 | - $this->file = trailingslashit( dirname( __DIR__ )).static::ID.'.php'; |
|
36 | - $this->log = new Log( $this->path( 'development.log' )); |
|
35 | + $this->file = trailingslashit( dirname( __DIR__ ) ) . static::ID . '.php'; |
|
36 | + $this->log = new Log( $this->path( 'development.log' ) ); |
|
37 | 37 | $plugin = get_file_data( $this->file, [ |
38 | 38 | 'languages' => 'Domain Path', |
39 | 39 | 'name' => 'Plugin Name', |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function init() |
51 | 51 | { |
52 | - add_action( 'admin_init', [$this, 'clearLog'] ); |
|
53 | - add_action( 'plugins_loaded', [$this, 'registerLanguages'] ); |
|
54 | - add_action( 'admin_menu', [$this, 'registerMenu'] ); |
|
55 | - add_action( 'admin_menu', [$this, 'registerSettings'] ); |
|
56 | - add_filter( 'all', [$this, 'initLogger'] ); |
|
52 | + add_action( 'admin_init', [ $this, 'clearLog' ] ); |
|
53 | + add_action( 'plugins_loaded', [ $this, 'registerLanguages' ] ); |
|
54 | + add_action( 'admin_menu', [ $this, 'registerMenu' ] ); |
|
55 | + add_action( 'admin_menu', [ $this, 'registerSettings' ] ); |
|
56 | + add_filter( 'all', [ $this, 'initLogger' ] ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function initLogger() |
64 | 64 | { |
65 | - $args = func_get_args() + ['', null, 'debug']; |
|
66 | - if( $args[0] !== static::ID || is_null( $args[1] ))return; |
|
67 | - $this->log->log( $args[2], $args[1] ); |
|
65 | + $args = func_get_args() + [ '', null, 'debug' ]; |
|
66 | + if( $args[ 0 ] !== static::ID || is_null( $args[ 1 ] ) )return; |
|
67 | + $this->log->log( $args[ 2 ], $args[ 1 ] ); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function clearLog() |
74 | 74 | { |
75 | - $request = filter_input( INPUT_POST, static::ID, FILTER_DEFAULT , FILTER_REQUIRE_ARRAY ); |
|
76 | - if( empty( $request['action'] ) || $request['action'] != 'clear-log' )return; |
|
77 | - check_admin_referer( $request['action'] ); |
|
75 | + $request = filter_input( INPUT_POST, static::ID, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
76 | + if( empty( $request[ 'action' ] ) || $request[ 'action' ] != 'clear-log' )return; |
|
77 | + check_admin_referer( $request[ 'action' ] ); |
|
78 | 78 | $this->log->clear(); |
79 | - add_action( 'admin_notices', [$this, 'renderNotice'] ); |
|
79 | + add_action( 'admin_notices', [ $this, 'renderNotice' ] ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function path( $file = '' ) |
87 | 87 | { |
88 | - return realpath( plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' )); |
|
88 | + return realpath( plugin_dir_path( $this->file ) . ltrim( trim( $file ), '/' ) ); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | public function registerLanguages() |
95 | 95 | { |
96 | 96 | load_plugin_textdomain( static::ID, '', |
97 | - trailingslashit( plugin_basename( $this->path() ).'/'.$this->languages ) |
|
97 | + trailingslashit( plugin_basename( $this->path() ) . '/' . $this->languages ) |
|
98 | 98 | ); |
99 | 99 | } |
100 | 100 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | __( 'Logger', 'logger' ), |
111 | 111 | 'manage_options', |
112 | 112 | static::ID, |
113 | - [$this, 'renderSettingsPage'] |
|
113 | + [ $this, 'renderSettingsPage' ] |
|
114 | 114 | ); |
115 | 115 | } |
116 | 116 | |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | * @param string $view |
128 | 128 | * @return void|null |
129 | 129 | */ |
130 | - public function render( $view, array $data = [] ) |
|
130 | + public function render( $view, array $data = [ ] ) |
|
131 | 131 | { |
132 | - if( !file_exists( $file = $this->path( 'views/'.$view.'.php' )))return; |
|
132 | + if( !file_exists( $file = $this->path( 'views/' . $view . '.php' ) ) )return; |
|
133 | 133 | extract( $data ); |
134 | 134 | include $file; |
135 | 135 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $this->render( 'notice', [ |
143 | 143 | 'notice' => __( 'The log was cleared.', 'logger' ), |
144 | 144 | 'status' => 'success', |
145 | - ]); |
|
145 | + ] ); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | 'log' => $this->log, |
157 | 157 | 'settings' => $this->getSettings(), |
158 | 158 | 'title' => __( 'Logger', 'logger' ), |
159 | - ]); |
|
159 | + ] ); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | */ |
165 | 165 | protected function getSettings() |
166 | 166 | { |
167 | - $settings = get_option( static::ID, [] ); |
|
168 | - if( empty( $settings )) { |
|
167 | + $settings = get_option( static::ID, [ ] ); |
|
168 | + if( empty( $settings ) ) { |
|
169 | 169 | update_option( static::ID, $settings = [ |
170 | 170 | 'enabled' => 0, |
171 | - ]); |
|
171 | + ] ); |
|
172 | 172 | } |
173 | - return (object)$settings; |
|
173 | + return (object) $settings; |
|
174 | 174 | } |
175 | 175 | } |
@@ -39,7 +39,8 @@ discard block |
||
39 | 39 | 'name' => 'Plugin Name', |
40 | 40 | 'version' => 'Version', |
41 | 41 | ], 'plugin' ); |
42 | - array_walk( $plugin, function( $value, $key ) { |
|
42 | + array_walk( $plugin, function( $value, $key ) |
|
43 | + { |
|
43 | 44 | $this->$key = $value; |
44 | 45 | }); |
45 | 46 | } |
@@ -63,7 +64,9 @@ discard block |
||
63 | 64 | public function initLogger() |
64 | 65 | { |
65 | 66 | $args = func_get_args() + ['', null, 'debug']; |
66 | - if( $args[0] !== static::ID || is_null( $args[1] ))return; |
|
67 | + if( $args[0] !== static::ID || is_null( $args[1] )) { |
|
68 | + return; |
|
69 | + } |
|
67 | 70 | $this->log->log( $args[2], $args[1] ); |
68 | 71 | } |
69 | 72 | |
@@ -73,7 +76,9 @@ discard block |
||
73 | 76 | public function clearLog() |
74 | 77 | { |
75 | 78 | $request = filter_input( INPUT_POST, static::ID, FILTER_DEFAULT , FILTER_REQUIRE_ARRAY ); |
76 | - if( empty( $request['action'] ) || $request['action'] != 'clear-log' )return; |
|
79 | + if( empty( $request['action'] ) || $request['action'] != 'clear-log' ) { |
|
80 | + return; |
|
81 | + } |
|
77 | 82 | check_admin_referer( $request['action'] ); |
78 | 83 | $this->log->clear(); |
79 | 84 | add_action( 'admin_notices', [$this, 'renderNotice'] ); |
@@ -129,7 +134,9 @@ discard block |
||
129 | 134 | */ |
130 | 135 | public function render( $view, array $data = [] ) |
131 | 136 | { |
132 | - if( !file_exists( $file = $this->path( 'views/'.$view.'.php' )))return; |
|
137 | + if( !file_exists( $file = $this->path( 'views/'.$view.'.php' ))) { |
|
138 | + return; |
|
139 | + } |
|
133 | 140 | extract( $data ); |
134 | 141 | include $file; |
135 | 142 | } |