@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | use WPB\Application; |
17 | 17 | |
18 | 18 | $app = ( new Application( |
19 | - array( |
|
20 | - 'paths' => array( |
|
21 | - 'root' => WPB_APP_ROOT, |
|
22 | - ), |
|
23 | - ) |
|
19 | + array( |
|
20 | + 'paths' => array( |
|
21 | + 'root' => WPB_APP_ROOT, |
|
22 | + ), |
|
23 | + ) |
|
24 | 24 | ) ); |
25 | 25 | |
26 | 26 | global $wpb_app; |
@@ -28,27 +28,27 @@ discard block |
||
28 | 28 | $wpb_app = $container = $app->get_instance(); |
29 | 29 | |
30 | 30 | $container->singleton( |
31 | - Illuminate\Contracts\Http\Kernel::class, |
|
32 | - \WPB\App\Http\Kernel::class |
|
31 | + Illuminate\Contracts\Http\Kernel::class, |
|
32 | + \WPB\App\Http\Kernel::class |
|
33 | 33 | ); |
34 | 34 | $container->singleton( |
35 | - \Illuminate\Contracts\Debug\ExceptionHandler::class, |
|
36 | - \WPB\App\Exceptions\Handler::class |
|
35 | + \Illuminate\Contracts\Debug\ExceptionHandler::class, |
|
36 | + \WPB\App\Exceptions\Handler::class |
|
37 | 37 | ); |
38 | 38 | |
39 | 39 | if ( \WPB\Support\Facades\Route::exists( \Illuminate\Http\Request::capture() ) ) { |
40 | - try { |
|
40 | + try { |
|
41 | 41 | |
42 | - $kernel = $container->make( \Illuminate\Contracts\Http\Kernel::class ); |
|
42 | + $kernel = $container->make( \Illuminate\Contracts\Http\Kernel::class ); |
|
43 | 43 | |
44 | - $response = $kernel->handle( \Illuminate\Http\Request::capture() ); |
|
44 | + $response = $kernel->handle( \Illuminate\Http\Request::capture() ); |
|
45 | 45 | |
46 | - $response->send(); |
|
46 | + $response->send(); |
|
47 | 47 | |
48 | - } catch ( \Exception $ex ) { |
|
49 | - if ( ! \WPB\Support\Facades\Route::current() ) { |
|
50 | - return true; |
|
51 | - } |
|
52 | - throw new \Exception( $ex, 1 ); |
|
53 | - } |
|
48 | + } catch ( \Exception $ex ) { |
|
49 | + if ( ! \WPB\Support\Facades\Route::current() ) { |
|
50 | + return true; |
|
51 | + } |
|
52 | + throw new \Exception( $ex, 1 ); |
|
53 | + } |
|
54 | 54 | } |
@@ -9,19 +9,19 @@ discard block |
||
9 | 9 | * @subpackage WPB/bootstrap |
10 | 10 | */ |
11 | 11 | |
12 | -require_once ABSPATH . 'wp-includes/pluggable.php'; |
|
13 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
14 | -require_once __DIR__ . '/../src/helpers.php'; |
|
12 | +require_once ABSPATH.'wp-includes/pluggable.php'; |
|
13 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
14 | +require_once __DIR__.'/../src/helpers.php'; |
|
15 | 15 | |
16 | 16 | use WPB\Application; |
17 | 17 | |
18 | -$app = ( new Application( |
|
18 | +$app = (new Application( |
|
19 | 19 | array( |
20 | 20 | 'paths' => array( |
21 | 21 | 'root' => WPB_APP_ROOT, |
22 | 22 | ), |
23 | 23 | ) |
24 | -) ); |
|
24 | +)); |
|
25 | 25 | |
26 | 26 | global $wpb_app; |
27 | 27 | |
@@ -36,19 +36,19 @@ discard block |
||
36 | 36 | \WPB\App\Exceptions\Handler::class |
37 | 37 | ); |
38 | 38 | |
39 | -if ( \WPB\Support\Facades\Route::exists( \Illuminate\Http\Request::capture() ) ) { |
|
39 | +if (\WPB\Support\Facades\Route::exists(\Illuminate\Http\Request::capture())) { |
|
40 | 40 | try { |
41 | 41 | |
42 | - $kernel = $container->make( \Illuminate\Contracts\Http\Kernel::class ); |
|
42 | + $kernel = $container->make(\Illuminate\Contracts\Http\Kernel::class); |
|
43 | 43 | |
44 | - $response = $kernel->handle( \Illuminate\Http\Request::capture() ); |
|
44 | + $response = $kernel->handle(\Illuminate\Http\Request::capture()); |
|
45 | 45 | |
46 | 46 | $response->send(); |
47 | 47 | |
48 | - } catch ( \Exception $ex ) { |
|
49 | - if ( ! \WPB\Support\Facades\Route::current() ) { |
|
48 | + } catch (\Exception $ex) { |
|
49 | + if (!\WPB\Support\Facades\Route::current()) { |
|
50 | 50 | return true; |
51 | 51 | } |
52 | - throw new \Exception( $ex, 1 ); |
|
52 | + throw new \Exception($ex, 1); |
|
53 | 53 | } |
54 | 54 | } |
@@ -31,60 +31,60 @@ discard block |
||
31 | 31 | use Illuminate\Contracts\Broadcasting\Factory as BroadcastFactory; |
32 | 32 | |
33 | 33 | if ( ! function_exists( 'wpb_csrf_token' ) ) { |
34 | - /** |
|
35 | - * Generate wp nonce. |
|
36 | - * |
|
37 | - * @param string|null $action This is the nonce action name. |
|
38 | - * |
|
39 | - * @return null|string |
|
40 | - */ |
|
41 | - function wpb_csrf_token( $action = 'wpb_nonce' ) { |
|
42 | - return wp_create_nonce( $action ); |
|
43 | - } |
|
34 | + /** |
|
35 | + * Generate wp nonce. |
|
36 | + * |
|
37 | + * @param string|null $action This is the nonce action name. |
|
38 | + * |
|
39 | + * @return null|string |
|
40 | + */ |
|
41 | + function wpb_csrf_token( $action = 'wpb_nonce' ) { |
|
42 | + return wp_create_nonce( $action ); |
|
43 | + } |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | if ( ! function_exists( 'wpb_config' ) ) { |
47 | - /** |
|
48 | - * Get / set the specified configuration value. |
|
49 | - * |
|
50 | - * If an array is passed as the key, we will assume you want to set an array of values. |
|
51 | - * |
|
52 | - * @param array|string|null $key This is the key for config array. |
|
53 | - * @param mixed $default This is the default config value. |
|
54 | - * |
|
55 | - * @return mixed|\Illuminate\Config\Repository |
|
56 | - */ |
|
57 | - function wpb_config( $key = null, $default = null ) { |
|
58 | - if ( is_null( $key ) ) { |
|
59 | - return app( 'config' ); |
|
60 | - } |
|
61 | - |
|
62 | - if ( is_array( $key ) ) { |
|
63 | - return app( 'config' )->set( $key ); |
|
64 | - } |
|
65 | - |
|
66 | - return app( 'config' )->get( $key, $default ); |
|
67 | - } |
|
47 | + /** |
|
48 | + * Get / set the specified configuration value. |
|
49 | + * |
|
50 | + * If an array is passed as the key, we will assume you want to set an array of values. |
|
51 | + * |
|
52 | + * @param array|string|null $key This is the key for config array. |
|
53 | + * @param mixed $default This is the default config value. |
|
54 | + * |
|
55 | + * @return mixed|\Illuminate\Config\Repository |
|
56 | + */ |
|
57 | + function wpb_config( $key = null, $default = null ) { |
|
58 | + if ( is_null( $key ) ) { |
|
59 | + return app( 'config' ); |
|
60 | + } |
|
61 | + |
|
62 | + if ( is_array( $key ) ) { |
|
63 | + return app( 'config' )->set( $key ); |
|
64 | + } |
|
65 | + |
|
66 | + return app( 'config' )->get( $key, $default ); |
|
67 | + } |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | if ( ! function_exists( 'wpb_view' ) ) { |
71 | - /** |
|
72 | - * Render blade view. |
|
73 | - * |
|
74 | - * @param string $view This is the filename. |
|
75 | - * @param array $data This is the view data. |
|
76 | - * @param array $merge_data This is the merge data for view. |
|
77 | - * |
|
78 | - * @throws \Exception This will throw an exception if view class doesn't exists. |
|
79 | - * @return null|string |
|
80 | - */ |
|
81 | - function wpb_view( $view, $data = array(), $merge_data = array() ) { |
|
82 | - if ( ! class_exists( \CodexShaper\Blade\View::class ) ) { |
|
83 | - throw new \Exception( 'View not resolved. Please install View' ); |
|
84 | - } |
|
85 | - |
|
86 | - return ( new \CodexShaper\Blade\View( array( __DIR__ . '/../resources/views' ), __DIR__ . '/../storage/cache' ) )->make( $view, $data = array(), $merge_data = array() ); |
|
87 | - } |
|
71 | + /** |
|
72 | + * Render blade view. |
|
73 | + * |
|
74 | + * @param string $view This is the filename. |
|
75 | + * @param array $data This is the view data. |
|
76 | + * @param array $merge_data This is the merge data for view. |
|
77 | + * |
|
78 | + * @throws \Exception This will throw an exception if view class doesn't exists. |
|
79 | + * @return null|string |
|
80 | + */ |
|
81 | + function wpb_view( $view, $data = array(), $merge_data = array() ) { |
|
82 | + if ( ! class_exists( \CodexShaper\Blade\View::class ) ) { |
|
83 | + throw new \Exception( 'View not resolved. Please install View' ); |
|
84 | + } |
|
85 | + |
|
86 | + return ( new \CodexShaper\Blade\View( array( __DIR__ . '/../resources/views' ), __DIR__ . '/../storage/cache' ) )->make( $view, $data = array(), $merge_data = array() ); |
|
87 | + } |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | if (! function_exists('wpb_abort')) { |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | function wpb_app($abstract = null, array $parameters = []) |
180 | 180 | { |
181 | - global $wpb_app; |
|
181 | + global $wpb_app; |
|
182 | 182 | |
183 | 183 | if (is_null($abstract)) { |
184 | 184 | return $wpb_app; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | use Illuminate\Contracts\Validation\Factory as ValidationFactory; |
31 | 31 | use Illuminate\Contracts\Broadcasting\Factory as BroadcastFactory; |
32 | 32 | |
33 | -if ( ! function_exists( 'wpb_csrf_token' ) ) { |
|
33 | +if (!function_exists('wpb_csrf_token')) { |
|
34 | 34 | /** |
35 | 35 | * Generate wp nonce. |
36 | 36 | * |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return null|string |
40 | 40 | */ |
41 | - function wpb_csrf_token( $action = 'wpb_nonce' ) { |
|
42 | - return wp_create_nonce( $action ); |
|
41 | + function wpb_csrf_token($action = 'wpb_nonce') { |
|
42 | + return wp_create_nonce($action); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | -if ( ! function_exists( 'wpb_config' ) ) { |
|
46 | +if (!function_exists('wpb_config')) { |
|
47 | 47 | /** |
48 | 48 | * Get / set the specified configuration value. |
49 | 49 | * |
@@ -54,20 +54,20 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return mixed|\Illuminate\Config\Repository |
56 | 56 | */ |
57 | - function wpb_config( $key = null, $default = null ) { |
|
58 | - if ( is_null( $key ) ) { |
|
59 | - return app( 'config' ); |
|
57 | + function wpb_config($key = null, $default = null) { |
|
58 | + if (is_null($key)) { |
|
59 | + return app('config'); |
|
60 | 60 | } |
61 | 61 | |
62 | - if ( is_array( $key ) ) { |
|
63 | - return app( 'config' )->set( $key ); |
|
62 | + if (is_array($key)) { |
|
63 | + return app('config')->set($key); |
|
64 | 64 | } |
65 | 65 | |
66 | - return app( 'config' )->get( $key, $default ); |
|
66 | + return app('config')->get($key, $default); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | -if ( ! function_exists( 'wpb_view' ) ) { |
|
70 | +if (!function_exists('wpb_view')) { |
|
71 | 71 | /** |
72 | 72 | * Render blade view. |
73 | 73 | * |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | * @throws \Exception This will throw an exception if view class doesn't exists. |
79 | 79 | * @return null|string |
80 | 80 | */ |
81 | - function wpb_view( $view, $data = array(), $merge_data = array() ) { |
|
82 | - if ( ! class_exists( \CodexShaper\Blade\View::class ) ) { |
|
83 | - throw new \Exception( 'View not resolved. Please install View' ); |
|
81 | + function wpb_view($view, $data = array(), $merge_data = array()) { |
|
82 | + if (!class_exists(\CodexShaper\Blade\View::class)) { |
|
83 | + throw new \Exception('View not resolved. Please install View'); |
|
84 | 84 | } |
85 | 85 | |
86 | - return ( new \CodexShaper\Blade\View( array( __DIR__ . '/../resources/views' ), __DIR__ . '/../storage/cache' ) )->make( $view, $data = array(), $merge_data = array() ); |
|
86 | + return (new \CodexShaper\Blade\View(array(__DIR__.'/../resources/views'), __DIR__.'/../storage/cache'))->make($view, $data = array(), $merge_data = array()); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | -if (! function_exists('wpb_abort')) { |
|
90 | +if (!function_exists('wpb_abort')) { |
|
91 | 91 | /** |
92 | 92 | * Throw an HttpException with the given data. |
93 | 93 | * |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
114 | -if (! function_exists('wpb_abort_if')) { |
|
114 | +if (!function_exists('wpb_abort_if')) { |
|
115 | 115 | /** |
116 | 116 | * Throw an HttpException with the given data if the given condition is true. |
117 | 117 | * |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | -if (! function_exists('wpb_abort_unless')) { |
|
135 | +if (!function_exists('wpb_abort_unless')) { |
|
136 | 136 | /** |
137 | 137 | * Throw an HttpException with the given data unless the given condition is true. |
138 | 138 | * |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | */ |
148 | 148 | function wpb_abort_unless($boolean, $code, $message = '', array $headers = []) |
149 | 149 | { |
150 | - if (! $boolean) { |
|
150 | + if (!$boolean) { |
|
151 | 151 | wpb_abort($code, $message, $headers); |
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | -if (! function_exists('wpb_action')) { |
|
156 | +if (!function_exists('wpb_action')) { |
|
157 | 157 | /** |
158 | 158 | * Generate the URL to a controller action. |
159 | 159 | * |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | -if (! function_exists('wpb_app')) { |
|
171 | +if (!function_exists('wpb_app')) { |
|
172 | 172 | /** |
173 | 173 | * Get the available container instance. |
174 | 174 | * |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | -if (! function_exists('wpb_app_path')) { |
|
191 | +if (!function_exists('wpb_app_path')) { |
|
192 | 192 | /** |
193 | 193 | * Get the path to the application folder. |
194 | 194 | * |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | -if (! function_exists('wpb_asset')) { |
|
204 | +if (!function_exists('wpb_asset')) { |
|
205 | 205 | /** |
206 | 206 | * Generate an asset path for the application. |
207 | 207 | * |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | -if (! function_exists('wpb_auth')) { |
|
218 | +if (!function_exists('wpb_auth')) { |
|
219 | 219 | /** |
220 | 220 | * Get the available auth instance. |
221 | 221 | * |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | -if (! function_exists('wpb_back')) { |
|
235 | +if (!function_exists('wpb_back')) { |
|
236 | 236 | /** |
237 | 237 | * Create a new redirect response to the previous location. |
238 | 238 | * |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
250 | -if (! function_exists('wpb_base_path')) { |
|
250 | +if (!function_exists('wpb_base_path')) { |
|
251 | 251 | /** |
252 | 252 | * Get the path to the base of the install. |
253 | 253 | * |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
263 | -if (! function_exists('wpb_bcrypt')) { |
|
263 | +if (!function_exists('wpb_bcrypt')) { |
|
264 | 264 | /** |
265 | 265 | * Hash the given value against the bcrypt algorithm. |
266 | 266 | * |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | } |
275 | 275 | } |
276 | 276 | |
277 | -if (! function_exists('wpb_broadcast')) { |
|
277 | +if (!function_exists('wpb_broadcast')) { |
|
278 | 278 | /** |
279 | 279 | * Begin broadcasting an event. |
280 | 280 | * |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
290 | -if (! function_exists('wpb_cache')) { |
|
290 | +if (!function_exists('wpb_cache')) { |
|
291 | 291 | /** |
292 | 292 | * Get / set the specified cache value. |
293 | 293 | * |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | return wpb_app('cache')->get($arguments[0], $arguments[1] ?? null); |
311 | 311 | } |
312 | 312 | |
313 | - if (! is_array($arguments[0])) { |
|
313 | + if (!is_array($arguments[0])) { |
|
314 | 314 | throw new Exception( |
315 | 315 | 'When setting a value in the cache, you must pass an array of key / value pairs.' |
316 | 316 | ); |
317 | 317 | } |
318 | 318 | |
319 | - if (! isset($arguments[1])) { |
|
319 | + if (!isset($arguments[1])) { |
|
320 | 320 | throw new Exception( |
321 | 321 | 'You must specify an expiration time when setting a value in the cache.' |
322 | 322 | ); |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
329 | -if (! function_exists('wpb_config_path')) { |
|
329 | +if (!function_exists('wpb_config_path')) { |
|
330 | 330 | /** |
331 | 331 | * Get the configuration path. |
332 | 332 | * |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
342 | -if (! function_exists('wpb_cookie')) { |
|
342 | +if (!function_exists('wpb_cookie')) { |
|
343 | 343 | /** |
344 | 344 | * Create a new cookie instance. |
345 | 345 | * |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
369 | -if (! function_exists('wpb_csrf_field')) { |
|
369 | +if (!function_exists('wpb_csrf_field')) { |
|
370 | 370 | /** |
371 | 371 | * Generate a CSRF token form field. |
372 | 372 | * |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
381 | -if (! function_exists('wpb_database_path')) { |
|
381 | +if (!function_exists('wpb_database_path')) { |
|
382 | 382 | /** |
383 | 383 | * Get the database path. |
384 | 384 | * |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | -if (! function_exists('wpb_decrypt')) { |
|
394 | +if (!function_exists('wpb_decrypt')) { |
|
395 | 395 | /** |
396 | 396 | * Decrypt the given value. |
397 | 397 | * |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
408 | -if (! function_exists('wpb_dispatch')) { |
|
408 | +if (!function_exists('wpb_dispatch')) { |
|
409 | 409 | /** |
410 | 410 | * Dispatch a job to its appropriate handler. |
411 | 411 | * |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | } |
419 | 419 | } |
420 | 420 | |
421 | -if (! function_exists('wpb_dispatch_now')) { |
|
421 | +if (!function_exists('wpb_dispatch_now')) { |
|
422 | 422 | /** |
423 | 423 | * Dispatch a command to its appropriate handler in the current process. |
424 | 424 | * |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | -if (! function_exists('wpb_elixir')) { |
|
435 | +if (!function_exists('wpb_elixir')) { |
|
436 | 436 | /** |
437 | 437 | * Get the path to a versioned Elixir file. |
438 | 438 | * |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
475 | -if (! function_exists('wpb_encrypt')) { |
|
475 | +if (!function_exists('wpb_encrypt')) { |
|
476 | 476 | /** |
477 | 477 | * Encrypt the given value. |
478 | 478 | * |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | } |
487 | 487 | } |
488 | 488 | |
489 | -if (! function_exists('wpb_event')) { |
|
489 | +if (!function_exists('wpb_event')) { |
|
490 | 490 | /** |
491 | 491 | * Dispatch an event and call the listeners. |
492 | 492 | * |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | } |
502 | 502 | } |
503 | 503 | |
504 | -if (! function_exists('wpb_factory')) { |
|
504 | +if (!function_exists('wpb_factory')) { |
|
505 | 505 | /** |
506 | 506 | * Create a model factory builder for a given class, name, and amount. |
507 | 507 | * |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | } |
525 | 525 | } |
526 | 526 | |
527 | -if (! function_exists('wpb_info')) { |
|
527 | +if (!function_exists('wpb_info')) { |
|
528 | 528 | /** |
529 | 529 | * Write some information to the log. |
530 | 530 | * |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | } |
539 | 539 | } |
540 | 540 | |
541 | -if (! function_exists('wpb_logger')) { |
|
541 | +if (!function_exists('wpb_logger')) { |
|
542 | 542 | /** |
543 | 543 | * Log a debug message to the logs. |
544 | 544 | * |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | } |
557 | 557 | } |
558 | 558 | |
559 | -if (! function_exists('wpb_logs')) { |
|
559 | +if (!function_exists('wpb_logs')) { |
|
560 | 560 | /** |
561 | 561 | * Get a log driver instance. |
562 | 562 | * |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | } |
570 | 570 | } |
571 | 571 | |
572 | -if (! function_exists('wpb_method_field')) { |
|
572 | +if (!function_exists('wpb_method_field')) { |
|
573 | 573 | /** |
574 | 574 | * Generate a form field to spoof the HTTP verb used by forms. |
575 | 575 | * |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | } |
583 | 583 | } |
584 | 584 | |
585 | -if (! function_exists('wpb_mix')) { |
|
585 | +if (!function_exists('wpb_mix')) { |
|
586 | 586 | /** |
587 | 587 | * Get the path to a versioned Mix file. |
588 | 588 | * |
@@ -596,11 +596,11 @@ discard block |
||
596 | 596 | { |
597 | 597 | static $manifests = []; |
598 | 598 | |
599 | - if (! Str::startsWith($path, '/')) { |
|
599 | + if (!Str::startsWith($path, '/')) { |
|
600 | 600 | $path = "/{$path}"; |
601 | 601 | } |
602 | 602 | |
603 | - if ($manifestDirectory && ! Str::startsWith($manifestDirectory, '/')) { |
|
603 | + if ($manifestDirectory && !Str::startsWith($manifestDirectory, '/')) { |
|
604 | 604 | $manifestDirectory = "/{$manifestDirectory}"; |
605 | 605 | } |
606 | 606 | |
@@ -616,8 +616,8 @@ discard block |
||
616 | 616 | |
617 | 617 | $manifestPath = wpb_public_path($manifestDirectory.'/mix-manifest.json'); |
618 | 618 | |
619 | - if (! isset($manifests[$manifestPath])) { |
|
620 | - if (! file_exists($manifestPath)) { |
|
619 | + if (!isset($manifests[$manifestPath])) { |
|
620 | + if (!file_exists($manifestPath)) { |
|
621 | 621 | throw new Exception('The Mix manifest does not exist.'); |
622 | 622 | } |
623 | 623 | |
@@ -626,10 +626,10 @@ discard block |
||
626 | 626 | |
627 | 627 | $manifest = $manifests[$manifestPath]; |
628 | 628 | |
629 | - if (! isset($manifest[$path])) { |
|
629 | + if (!isset($manifest[$path])) { |
|
630 | 630 | wpb_report(new Exception("Unable to locate Mix file: {$path}.")); |
631 | 631 | |
632 | - if (! wpb_app('config')->get('app.debug')) { |
|
632 | + if (!wpb_app('config')->get('app.debug')) { |
|
633 | 633 | return $path; |
634 | 634 | } |
635 | 635 | } |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | } |
639 | 639 | } |
640 | 640 | |
641 | -if (! function_exists('wpb_now')) { |
|
641 | +if (!function_exists('wpb_now')) { |
|
642 | 642 | /** |
643 | 643 | * Create a new Carbon instance for the current time. |
644 | 644 | * |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | } |
652 | 652 | } |
653 | 653 | |
654 | -if (! function_exists('wpb_old')) { |
|
654 | +if (!function_exists('wpb_old')) { |
|
655 | 655 | /** |
656 | 656 | * Retrieve an old input item. |
657 | 657 | * |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
668 | -if (! function_exists('wpb_policy')) { |
|
668 | +if (!function_exists('wpb_policy')) { |
|
669 | 669 | /** |
670 | 670 | * Get a policy instance for a given class. |
671 | 671 | * |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | } |
681 | 681 | } |
682 | 682 | |
683 | -if (! function_exists('wpb_public_path')) { |
|
683 | +if (!function_exists('wpb_public_path')) { |
|
684 | 684 | /** |
685 | 685 | * Get the path to the public folder. |
686 | 686 | * |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | } |
694 | 694 | } |
695 | 695 | |
696 | -if (! function_exists('wpb_redirect')) { |
|
696 | +if (!function_exists('wpb_redirect')) { |
|
697 | 697 | /** |
698 | 698 | * Get an instance of the redirector. |
699 | 699 | * |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | } |
714 | 714 | } |
715 | 715 | |
716 | -if (! function_exists('wpb_report')) { |
|
716 | +if (!function_exists('wpb_report')) { |
|
717 | 717 | /** |
718 | 718 | * Report an exception. |
719 | 719 | * |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | function wpb_report($exception) |
724 | 724 | { |
725 | 725 | if ($exception instanceof Throwable && |
726 | - ! $exception instanceof Exception) { |
|
726 | + !$exception instanceof Exception) { |
|
727 | 727 | $exception = new FatalThrowableError($exception); |
728 | 728 | } |
729 | 729 | |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | } |
732 | 732 | } |
733 | 733 | |
734 | -if (! function_exists('wpb_request')) { |
|
734 | +if (!function_exists('wpb_request')) { |
|
735 | 735 | /** |
736 | 736 | * Get an instance of the current request or an input item from the request. |
737 | 737 | * |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | } |
756 | 756 | } |
757 | 757 | |
758 | -if (! function_exists('wpb_rescue')) { |
|
758 | +if (!function_exists('wpb_rescue')) { |
|
759 | 759 | /** |
760 | 760 | * Catch a potential exception and return a default value. |
761 | 761 | * |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | } |
776 | 776 | } |
777 | 777 | |
778 | -if (! function_exists('wpb_resolve')) { |
|
778 | +if (!function_exists('wpb_resolve')) { |
|
779 | 779 | /** |
780 | 780 | * Resolve a service from the container. |
781 | 781 | * |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | } |
789 | 789 | } |
790 | 790 | |
791 | -if (! function_exists('wpb_resource_path')) { |
|
791 | +if (!function_exists('wpb_resource_path')) { |
|
792 | 792 | /** |
793 | 793 | * Get the path to the resources folder. |
794 | 794 | * |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | } |
802 | 802 | } |
803 | 803 | |
804 | -if (! function_exists('wpb_response')) { |
|
804 | +if (!function_exists('wpb_response')) { |
|
805 | 805 | /** |
806 | 806 | * Return a new response from the application. |
807 | 807 | * |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | } |
823 | 823 | } |
824 | 824 | |
825 | -if (! function_exists('wpb_route')) { |
|
825 | +if (!function_exists('wpb_route')) { |
|
826 | 826 | /** |
827 | 827 | * Generate the URL to a named route. |
828 | 828 | * |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | } |
838 | 838 | } |
839 | 839 | |
840 | -if (! function_exists('wpb_secure_asset')) { |
|
840 | +if (!function_exists('wpb_secure_asset')) { |
|
841 | 841 | /** |
842 | 842 | * Generate an asset path for the application. |
843 | 843 | * |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | } |
851 | 851 | } |
852 | 852 | |
853 | -if (! function_exists('wpb_secure_url')) { |
|
853 | +if (!function_exists('wpb_secure_url')) { |
|
854 | 854 | /** |
855 | 855 | * Generate a HTTPS url for the application. |
856 | 856 | * |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | } |
865 | 865 | } |
866 | 866 | |
867 | -if (! function_exists('wpb_session')) { |
|
867 | +if (!function_exists('wpb_session')) { |
|
868 | 868 | /** |
869 | 869 | * Get / set the specified session value. |
870 | 870 | * |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | } |
889 | 889 | } |
890 | 890 | |
891 | -if (! function_exists('wpb_storage_path')) { |
|
891 | +if (!function_exists('wpb_storage_path')) { |
|
892 | 892 | /** |
893 | 893 | * Get the path to the storage folder. |
894 | 894 | * |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | } |
902 | 902 | } |
903 | 903 | |
904 | -if (! function_exists('wpb_today')) { |
|
904 | +if (!function_exists('wpb_today')) { |
|
905 | 905 | /** |
906 | 906 | * Create a new Carbon instance for the current date. |
907 | 907 | * |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | } |
915 | 915 | } |
916 | 916 | |
917 | -if (! function_exists('wpb_trans')) { |
|
917 | +if (!function_exists('wpb_trans')) { |
|
918 | 918 | /** |
919 | 919 | * Translate the given message. |
920 | 920 | * |
@@ -933,7 +933,7 @@ discard block |
||
933 | 933 | } |
934 | 934 | } |
935 | 935 | |
936 | -if (! function_exists('wpb_trans_choice')) { |
|
936 | +if (!function_exists('wpb_trans_choice')) { |
|
937 | 937 | /** |
938 | 938 | * Translates the given message based on a count. |
939 | 939 | * |
@@ -949,7 +949,7 @@ discard block |
||
949 | 949 | } |
950 | 950 | } |
951 | 951 | |
952 | -if (! function_exists('__')) { |
|
952 | +if (!function_exists('__')) { |
|
953 | 953 | /** |
954 | 954 | * Translate the given message. |
955 | 955 | * |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | } |
965 | 965 | } |
966 | 966 | |
967 | -if (! function_exists('wpb_url')) { |
|
967 | +if (!function_exists('wpb_url')) { |
|
968 | 968 | /** |
969 | 969 | * Generate a url for the application. |
970 | 970 | * |
@@ -983,7 +983,7 @@ discard block |
||
983 | 983 | } |
984 | 984 | } |
985 | 985 | |
986 | -if (! function_exists('wpb_validator')) { |
|
986 | +if (!function_exists('wpb_validator')) { |
|
987 | 987 | /** |
988 | 988 | * Create a new Validator instance. |
989 | 989 | * |
@@ -30,256 +30,256 @@ |
||
30 | 30 | */ |
31 | 31 | class Application { |
32 | 32 | |
33 | - /** |
|
34 | - * The app container. |
|
35 | - * |
|
36 | - * @since 1.0.0 |
|
37 | - * @access protected |
|
38 | - * @var \Illuminate\Contracts\Container\Container $app The app container. |
|
39 | - */ |
|
40 | - protected $app = null; |
|
41 | - |
|
42 | - /** |
|
43 | - * The config. |
|
44 | - * |
|
45 | - * @since 1.0.0 |
|
46 | - * @access protected |
|
47 | - * @var \WPB\Support\Facades\Config $config The config. |
|
48 | - */ |
|
49 | - protected $config; |
|
50 | - |
|
51 | - /** |
|
52 | - * The database manager. |
|
53 | - * |
|
54 | - * @since 1.0.0 |
|
55 | - * @access protected |
|
56 | - * @var \CodexShaper\Database\Database $db The database manager. |
|
57 | - */ |
|
58 | - protected $db; |
|
59 | - |
|
60 | - /** |
|
61 | - * The default options. |
|
62 | - * |
|
63 | - * @since 1.0.0 |
|
64 | - * @access protected |
|
65 | - * @var array $options The default options. |
|
66 | - */ |
|
67 | - protected $options; |
|
68 | - |
|
69 | - /** |
|
70 | - * This string unique root path. |
|
71 | - * |
|
72 | - * @since 1.0.0 |
|
73 | - * @access protected |
|
74 | - * @var string $root This string unique root path. |
|
75 | - */ |
|
76 | - protected $root; |
|
77 | - |
|
78 | - /** |
|
79 | - * The application factory. |
|
80 | - * |
|
81 | - * @since 1.0.0 |
|
82 | - * @param array $options The site options. |
|
83 | - * @param \Illuminate\Contracts\Container\Container as ContainerInterface $container The app container. |
|
84 | - * |
|
85 | - * @return void |
|
86 | - */ |
|
87 | - public function __construct( $options = array(), ContainerInterface $container = null ) { |
|
88 | - $this->options = $options; |
|
89 | - |
|
90 | - $this->app = $container; |
|
91 | - |
|
92 | - if ( is_null( $this->app ) ) { |
|
93 | - $this->app = new Container(); |
|
94 | - Facade::setFacadeApplication( $this->app ); |
|
95 | - $this->app->instance( ContainerInterface::class, $this->app ); |
|
96 | - } |
|
97 | - |
|
98 | - $this->app['app'] = $this->app; |
|
99 | - |
|
100 | - $this->root = __DIR__ . '/../../../../'; |
|
101 | - |
|
102 | - if ( ! empty( $this->options ) && isset( $this->options['paths']['root'] ) ) { |
|
103 | - $this->root = rtrim( $this->options['paths']['root'], '/' ) . '/'; |
|
104 | - } |
|
105 | - |
|
106 | - if ( ! isset( $this->app['root'] ) ) { |
|
107 | - $this->app['root'] = $this->root; |
|
108 | - } |
|
109 | - |
|
110 | - $this->config = new Config( $this->options ); |
|
111 | - |
|
112 | - $this->setup_env(); |
|
113 | - $this->register_config(); |
|
114 | - $this->setup_database(); |
|
115 | - $this->register_providers(); |
|
116 | - $this->register_request(); |
|
117 | - $this->register_instances(); |
|
118 | - $this->load_routes( $this->app['router'] ); |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Get the app container. |
|
123 | - * |
|
124 | - * @since 1.0.0 |
|
125 | - * |
|
126 | - * @return \Illuminate\Container\Container |
|
127 | - */ |
|
128 | - public function get_instance() { |
|
129 | - if ( ! $this->app ) { |
|
130 | - new self(); |
|
131 | - } |
|
132 | - |
|
133 | - return $this->app; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Setup the env. |
|
138 | - * |
|
139 | - * @since 1.0.0 |
|
140 | - * |
|
141 | - * @return void |
|
142 | - */ |
|
143 | - protected function setup_env() { |
|
144 | - $this->app['env'] = $this->config->get( 'app.env' ); |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * Register config. |
|
149 | - * |
|
150 | - * @since 1.0.0 |
|
151 | - * |
|
152 | - * @return void |
|
153 | - */ |
|
154 | - protected function register_config() { |
|
155 | - $this->app->bind( |
|
156 | - 'config', |
|
157 | - function () { |
|
158 | - return array( |
|
159 | - 'app' => $this->config->get( 'app' ), |
|
160 | - 'view.paths' => $this->config->get( 'view.paths' ), |
|
161 | - 'view.compiled' => $this->config->get( 'view.compiled' ), |
|
162 | - ); |
|
163 | - }, |
|
164 | - true |
|
165 | - ); |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Setup the database. |
|
170 | - * |
|
171 | - * @since 1.0.0 |
|
172 | - * |
|
173 | - * @return void |
|
174 | - */ |
|
175 | - protected function setup_database() { |
|
176 | - global $wpdb; |
|
177 | - |
|
178 | - $this->db = new Database( |
|
179 | - array( |
|
180 | - 'driver' => 'mysql', |
|
181 | - 'host' => $wpdb->dbhost, |
|
182 | - 'database' => $wpdb->dbname, |
|
183 | - 'username' => $wpdb->dbuser, |
|
184 | - 'password' => $wpdb->dbpassword, |
|
185 | - 'prefix' => $wpdb->prefix, |
|
186 | - 'charset' => $wpdb->charset, |
|
187 | - 'collation' => $wpdb->collate, |
|
188 | - ) |
|
189 | - ); |
|
190 | - |
|
191 | - $this->db->run(); |
|
192 | - |
|
193 | - $this->app->singleton( |
|
194 | - 'db', |
|
195 | - function () { |
|
196 | - return $this->db; |
|
197 | - } |
|
198 | - ); |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * Register providers. |
|
203 | - * |
|
204 | - * @since 1.0.0 |
|
205 | - * |
|
206 | - * @return void |
|
207 | - */ |
|
208 | - protected function register_providers() { |
|
209 | - $providers = $this->config->get( 'app.providers' ); |
|
210 | - |
|
211 | - if ( $providers && count( $providers ) > 0 ) { |
|
212 | - foreach ( $providers as $provider ) { |
|
213 | - with( new $provider( $this->app ) )->register(); |
|
214 | - } |
|
215 | - } |
|
216 | - } |
|
217 | - |
|
218 | - /** |
|
219 | - * Register request. |
|
220 | - * |
|
221 | - * @since 1.0.0 |
|
222 | - * |
|
223 | - * @return void |
|
224 | - */ |
|
225 | - protected function register_request() { |
|
226 | - $this->app->bind( |
|
227 | - 'request', |
|
228 | - function ( $app ) { |
|
229 | - $request = Request::capture(); |
|
230 | - $wp_user = wp_get_current_user(); |
|
231 | - if ( $wp_user ) { |
|
232 | - $user = User::find( $wp_user->ID ); |
|
233 | - $request->merge( array( 'user' => $user ) ); |
|
234 | - $request->setUserResolver( |
|
235 | - function () use ( $user ) { |
|
236 | - return $user; |
|
237 | - } |
|
238 | - ); |
|
239 | - } |
|
240 | - |
|
241 | - return $request; |
|
242 | - } |
|
243 | - ); |
|
244 | - } |
|
245 | - |
|
246 | - /** |
|
247 | - * Register router. |
|
248 | - * |
|
249 | - * @since 1.0.0 |
|
250 | - * |
|
251 | - * @return void |
|
252 | - */ |
|
253 | - protected function register_instances() { |
|
254 | - $this->app->instance( \Illuminate\Http\Request::class, $this->app['request'] ); |
|
255 | - $this->app->instance( \Illuminate\Routing\Router::class, $this->app['router'] ); |
|
256 | - $this->app->instance( \WPB\Router::class, $this->app['router'] ); |
|
257 | - $this->app->instance( \Illuminate\Contracts\View\Factory::class, $this->app['view'] ); |
|
258 | - $this->app->instance( \Illuminate\Contracts\Routing\UrlGenerator::class, $this->app['url'] ); |
|
259 | - $this->app->alias( 'Route', \WPB\Support\Facades\Route::class ); |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * Get the config value. |
|
264 | - * |
|
265 | - * @since 1.0.0 |
|
266 | - * @param \Illuminate\Routing\Router $router The app router. |
|
267 | - * @param string $dir The custom routes directory. |
|
268 | - * |
|
269 | - * @return void |
|
270 | - */ |
|
271 | - public function load_routes( $router, $dir = null ) { |
|
272 | - if ( ! $dir ) { |
|
273 | - $dir = __DIR__ . '/../routes/'; |
|
274 | - } |
|
275 | - |
|
276 | - require $dir . 'web.php'; |
|
277 | - |
|
278 | - $router->group( |
|
279 | - array( 'prefix' => 'api' ), |
|
280 | - function () use ( $dir, $router ) { |
|
281 | - require $dir . 'api.php'; |
|
282 | - } |
|
283 | - ); |
|
284 | - } |
|
33 | + /** |
|
34 | + * The app container. |
|
35 | + * |
|
36 | + * @since 1.0.0 |
|
37 | + * @access protected |
|
38 | + * @var \Illuminate\Contracts\Container\Container $app The app container. |
|
39 | + */ |
|
40 | + protected $app = null; |
|
41 | + |
|
42 | + /** |
|
43 | + * The config. |
|
44 | + * |
|
45 | + * @since 1.0.0 |
|
46 | + * @access protected |
|
47 | + * @var \WPB\Support\Facades\Config $config The config. |
|
48 | + */ |
|
49 | + protected $config; |
|
50 | + |
|
51 | + /** |
|
52 | + * The database manager. |
|
53 | + * |
|
54 | + * @since 1.0.0 |
|
55 | + * @access protected |
|
56 | + * @var \CodexShaper\Database\Database $db The database manager. |
|
57 | + */ |
|
58 | + protected $db; |
|
59 | + |
|
60 | + /** |
|
61 | + * The default options. |
|
62 | + * |
|
63 | + * @since 1.0.0 |
|
64 | + * @access protected |
|
65 | + * @var array $options The default options. |
|
66 | + */ |
|
67 | + protected $options; |
|
68 | + |
|
69 | + /** |
|
70 | + * This string unique root path. |
|
71 | + * |
|
72 | + * @since 1.0.0 |
|
73 | + * @access protected |
|
74 | + * @var string $root This string unique root path. |
|
75 | + */ |
|
76 | + protected $root; |
|
77 | + |
|
78 | + /** |
|
79 | + * The application factory. |
|
80 | + * |
|
81 | + * @since 1.0.0 |
|
82 | + * @param array $options The site options. |
|
83 | + * @param \Illuminate\Contracts\Container\Container as ContainerInterface $container The app container. |
|
84 | + * |
|
85 | + * @return void |
|
86 | + */ |
|
87 | + public function __construct( $options = array(), ContainerInterface $container = null ) { |
|
88 | + $this->options = $options; |
|
89 | + |
|
90 | + $this->app = $container; |
|
91 | + |
|
92 | + if ( is_null( $this->app ) ) { |
|
93 | + $this->app = new Container(); |
|
94 | + Facade::setFacadeApplication( $this->app ); |
|
95 | + $this->app->instance( ContainerInterface::class, $this->app ); |
|
96 | + } |
|
97 | + |
|
98 | + $this->app['app'] = $this->app; |
|
99 | + |
|
100 | + $this->root = __DIR__ . '/../../../../'; |
|
101 | + |
|
102 | + if ( ! empty( $this->options ) && isset( $this->options['paths']['root'] ) ) { |
|
103 | + $this->root = rtrim( $this->options['paths']['root'], '/' ) . '/'; |
|
104 | + } |
|
105 | + |
|
106 | + if ( ! isset( $this->app['root'] ) ) { |
|
107 | + $this->app['root'] = $this->root; |
|
108 | + } |
|
109 | + |
|
110 | + $this->config = new Config( $this->options ); |
|
111 | + |
|
112 | + $this->setup_env(); |
|
113 | + $this->register_config(); |
|
114 | + $this->setup_database(); |
|
115 | + $this->register_providers(); |
|
116 | + $this->register_request(); |
|
117 | + $this->register_instances(); |
|
118 | + $this->load_routes( $this->app['router'] ); |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Get the app container. |
|
123 | + * |
|
124 | + * @since 1.0.0 |
|
125 | + * |
|
126 | + * @return \Illuminate\Container\Container |
|
127 | + */ |
|
128 | + public function get_instance() { |
|
129 | + if ( ! $this->app ) { |
|
130 | + new self(); |
|
131 | + } |
|
132 | + |
|
133 | + return $this->app; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Setup the env. |
|
138 | + * |
|
139 | + * @since 1.0.0 |
|
140 | + * |
|
141 | + * @return void |
|
142 | + */ |
|
143 | + protected function setup_env() { |
|
144 | + $this->app['env'] = $this->config->get( 'app.env' ); |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * Register config. |
|
149 | + * |
|
150 | + * @since 1.0.0 |
|
151 | + * |
|
152 | + * @return void |
|
153 | + */ |
|
154 | + protected function register_config() { |
|
155 | + $this->app->bind( |
|
156 | + 'config', |
|
157 | + function () { |
|
158 | + return array( |
|
159 | + 'app' => $this->config->get( 'app' ), |
|
160 | + 'view.paths' => $this->config->get( 'view.paths' ), |
|
161 | + 'view.compiled' => $this->config->get( 'view.compiled' ), |
|
162 | + ); |
|
163 | + }, |
|
164 | + true |
|
165 | + ); |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Setup the database. |
|
170 | + * |
|
171 | + * @since 1.0.0 |
|
172 | + * |
|
173 | + * @return void |
|
174 | + */ |
|
175 | + protected function setup_database() { |
|
176 | + global $wpdb; |
|
177 | + |
|
178 | + $this->db = new Database( |
|
179 | + array( |
|
180 | + 'driver' => 'mysql', |
|
181 | + 'host' => $wpdb->dbhost, |
|
182 | + 'database' => $wpdb->dbname, |
|
183 | + 'username' => $wpdb->dbuser, |
|
184 | + 'password' => $wpdb->dbpassword, |
|
185 | + 'prefix' => $wpdb->prefix, |
|
186 | + 'charset' => $wpdb->charset, |
|
187 | + 'collation' => $wpdb->collate, |
|
188 | + ) |
|
189 | + ); |
|
190 | + |
|
191 | + $this->db->run(); |
|
192 | + |
|
193 | + $this->app->singleton( |
|
194 | + 'db', |
|
195 | + function () { |
|
196 | + return $this->db; |
|
197 | + } |
|
198 | + ); |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * Register providers. |
|
203 | + * |
|
204 | + * @since 1.0.0 |
|
205 | + * |
|
206 | + * @return void |
|
207 | + */ |
|
208 | + protected function register_providers() { |
|
209 | + $providers = $this->config->get( 'app.providers' ); |
|
210 | + |
|
211 | + if ( $providers && count( $providers ) > 0 ) { |
|
212 | + foreach ( $providers as $provider ) { |
|
213 | + with( new $provider( $this->app ) )->register(); |
|
214 | + } |
|
215 | + } |
|
216 | + } |
|
217 | + |
|
218 | + /** |
|
219 | + * Register request. |
|
220 | + * |
|
221 | + * @since 1.0.0 |
|
222 | + * |
|
223 | + * @return void |
|
224 | + */ |
|
225 | + protected function register_request() { |
|
226 | + $this->app->bind( |
|
227 | + 'request', |
|
228 | + function ( $app ) { |
|
229 | + $request = Request::capture(); |
|
230 | + $wp_user = wp_get_current_user(); |
|
231 | + if ( $wp_user ) { |
|
232 | + $user = User::find( $wp_user->ID ); |
|
233 | + $request->merge( array( 'user' => $user ) ); |
|
234 | + $request->setUserResolver( |
|
235 | + function () use ( $user ) { |
|
236 | + return $user; |
|
237 | + } |
|
238 | + ); |
|
239 | + } |
|
240 | + |
|
241 | + return $request; |
|
242 | + } |
|
243 | + ); |
|
244 | + } |
|
245 | + |
|
246 | + /** |
|
247 | + * Register router. |
|
248 | + * |
|
249 | + * @since 1.0.0 |
|
250 | + * |
|
251 | + * @return void |
|
252 | + */ |
|
253 | + protected function register_instances() { |
|
254 | + $this->app->instance( \Illuminate\Http\Request::class, $this->app['request'] ); |
|
255 | + $this->app->instance( \Illuminate\Routing\Router::class, $this->app['router'] ); |
|
256 | + $this->app->instance( \WPB\Router::class, $this->app['router'] ); |
|
257 | + $this->app->instance( \Illuminate\Contracts\View\Factory::class, $this->app['view'] ); |
|
258 | + $this->app->instance( \Illuminate\Contracts\Routing\UrlGenerator::class, $this->app['url'] ); |
|
259 | + $this->app->alias( 'Route', \WPB\Support\Facades\Route::class ); |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * Get the config value. |
|
264 | + * |
|
265 | + * @since 1.0.0 |
|
266 | + * @param \Illuminate\Routing\Router $router The app router. |
|
267 | + * @param string $dir The custom routes directory. |
|
268 | + * |
|
269 | + * @return void |
|
270 | + */ |
|
271 | + public function load_routes( $router, $dir = null ) { |
|
272 | + if ( ! $dir ) { |
|
273 | + $dir = __DIR__ . '/../routes/'; |
|
274 | + } |
|
275 | + |
|
276 | + require $dir . 'web.php'; |
|
277 | + |
|
278 | + $router->group( |
|
279 | + array( 'prefix' => 'api' ), |
|
280 | + function () use ( $dir, $router ) { |
|
281 | + require $dir . 'api.php'; |
|
282 | + } |
|
283 | + ); |
|
284 | + } |
|
285 | 285 | } |
@@ -84,30 +84,30 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return void |
86 | 86 | */ |
87 | - public function __construct( $options = array(), ContainerInterface $container = null ) { |
|
87 | + public function __construct($options = array(), ContainerInterface $container = null) { |
|
88 | 88 | $this->options = $options; |
89 | 89 | |
90 | 90 | $this->app = $container; |
91 | 91 | |
92 | - if ( is_null( $this->app ) ) { |
|
92 | + if (is_null($this->app)) { |
|
93 | 93 | $this->app = new Container(); |
94 | - Facade::setFacadeApplication( $this->app ); |
|
95 | - $this->app->instance( ContainerInterface::class, $this->app ); |
|
94 | + Facade::setFacadeApplication($this->app); |
|
95 | + $this->app->instance(ContainerInterface::class, $this->app); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $this->app['app'] = $this->app; |
99 | 99 | |
100 | - $this->root = __DIR__ . '/../../../../'; |
|
100 | + $this->root = __DIR__.'/../../../../'; |
|
101 | 101 | |
102 | - if ( ! empty( $this->options ) && isset( $this->options['paths']['root'] ) ) { |
|
103 | - $this->root = rtrim( $this->options['paths']['root'], '/' ) . '/'; |
|
102 | + if (!empty($this->options) && isset($this->options['paths']['root'])) { |
|
103 | + $this->root = rtrim($this->options['paths']['root'], '/').'/'; |
|
104 | 104 | } |
105 | 105 | |
106 | - if ( ! isset( $this->app['root'] ) ) { |
|
106 | + if (!isset($this->app['root'])) { |
|
107 | 107 | $this->app['root'] = $this->root; |
108 | 108 | } |
109 | 109 | |
110 | - $this->config = new Config( $this->options ); |
|
110 | + $this->config = new Config($this->options); |
|
111 | 111 | |
112 | 112 | $this->setup_env(); |
113 | 113 | $this->register_config(); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $this->register_providers(); |
116 | 116 | $this->register_request(); |
117 | 117 | $this->register_instances(); |
118 | - $this->load_routes( $this->app['router'] ); |
|
118 | + $this->load_routes($this->app['router']); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @return \Illuminate\Container\Container |
127 | 127 | */ |
128 | 128 | public function get_instance() { |
129 | - if ( ! $this->app ) { |
|
129 | + if (!$this->app) { |
|
130 | 130 | new self(); |
131 | 131 | } |
132 | 132 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @return void |
142 | 142 | */ |
143 | 143 | protected function setup_env() { |
144 | - $this->app['env'] = $this->config->get( 'app.env' ); |
|
144 | + $this->app['env'] = $this->config->get('app.env'); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | protected function register_config() { |
155 | 155 | $this->app->bind( |
156 | 156 | 'config', |
157 | - function () { |
|
157 | + function() { |
|
158 | 158 | return array( |
159 | - 'app' => $this->config->get( 'app' ), |
|
160 | - 'view.paths' => $this->config->get( 'view.paths' ), |
|
161 | - 'view.compiled' => $this->config->get( 'view.compiled' ), |
|
159 | + 'app' => $this->config->get('app'), |
|
160 | + 'view.paths' => $this->config->get('view.paths'), |
|
161 | + 'view.compiled' => $this->config->get('view.compiled'), |
|
162 | 162 | ); |
163 | 163 | }, |
164 | 164 | true |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | $this->app->singleton( |
194 | 194 | 'db', |
195 | - function () { |
|
195 | + function() { |
|
196 | 196 | return $this->db; |
197 | 197 | } |
198 | 198 | ); |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | * @return void |
207 | 207 | */ |
208 | 208 | protected function register_providers() { |
209 | - $providers = $this->config->get( 'app.providers' ); |
|
209 | + $providers = $this->config->get('app.providers'); |
|
210 | 210 | |
211 | - if ( $providers && count( $providers ) > 0 ) { |
|
212 | - foreach ( $providers as $provider ) { |
|
213 | - with( new $provider( $this->app ) )->register(); |
|
211 | + if ($providers && count($providers) > 0) { |
|
212 | + foreach ($providers as $provider) { |
|
213 | + with(new $provider($this->app))->register(); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | } |
@@ -225,14 +225,14 @@ discard block |
||
225 | 225 | protected function register_request() { |
226 | 226 | $this->app->bind( |
227 | 227 | 'request', |
228 | - function ( $app ) { |
|
228 | + function($app) { |
|
229 | 229 | $request = Request::capture(); |
230 | 230 | $wp_user = wp_get_current_user(); |
231 | - if ( $wp_user ) { |
|
232 | - $user = User::find( $wp_user->ID ); |
|
233 | - $request->merge( array( 'user' => $user ) ); |
|
231 | + if ($wp_user) { |
|
232 | + $user = User::find($wp_user->ID); |
|
233 | + $request->merge(array('user' => $user)); |
|
234 | 234 | $request->setUserResolver( |
235 | - function () use ( $user ) { |
|
235 | + function() use ($user) { |
|
236 | 236 | return $user; |
237 | 237 | } |
238 | 238 | ); |
@@ -251,12 +251,12 @@ discard block |
||
251 | 251 | * @return void |
252 | 252 | */ |
253 | 253 | protected function register_instances() { |
254 | - $this->app->instance( \Illuminate\Http\Request::class, $this->app['request'] ); |
|
255 | - $this->app->instance( \Illuminate\Routing\Router::class, $this->app['router'] ); |
|
256 | - $this->app->instance( \WPB\Router::class, $this->app['router'] ); |
|
257 | - $this->app->instance( \Illuminate\Contracts\View\Factory::class, $this->app['view'] ); |
|
258 | - $this->app->instance( \Illuminate\Contracts\Routing\UrlGenerator::class, $this->app['url'] ); |
|
259 | - $this->app->alias( 'Route', \WPB\Support\Facades\Route::class ); |
|
254 | + $this->app->instance(\Illuminate\Http\Request::class, $this->app['request']); |
|
255 | + $this->app->instance(\Illuminate\Routing\Router::class, $this->app['router']); |
|
256 | + $this->app->instance(\WPB\Router::class, $this->app['router']); |
|
257 | + $this->app->instance(\Illuminate\Contracts\View\Factory::class, $this->app['view']); |
|
258 | + $this->app->instance(\Illuminate\Contracts\Routing\UrlGenerator::class, $this->app['url']); |
|
259 | + $this->app->alias('Route', \WPB\Support\Facades\Route::class); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -268,17 +268,17 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return void |
270 | 270 | */ |
271 | - public function load_routes( $router, $dir = null ) { |
|
272 | - if ( ! $dir ) { |
|
273 | - $dir = __DIR__ . '/../routes/'; |
|
271 | + public function load_routes($router, $dir = null) { |
|
272 | + if (!$dir) { |
|
273 | + $dir = __DIR__.'/../routes/'; |
|
274 | 274 | } |
275 | 275 | |
276 | - require $dir . 'web.php'; |
|
276 | + require $dir.'web.php'; |
|
277 | 277 | |
278 | 278 | $router->group( |
279 | - array( 'prefix' => 'api' ), |
|
280 | - function () use ( $dir, $router ) { |
|
281 | - require $dir . 'api.php'; |
|
279 | + array('prefix' => 'api'), |
|
280 | + function() use ($dir, $router) { |
|
281 | + require $dir.'api.php'; |
|
282 | 282 | } |
283 | 283 | ); |
284 | 284 | } |
@@ -27,177 +27,177 @@ |
||
27 | 27 | */ |
28 | 28 | class ComposerScripts { |
29 | 29 | |
30 | - /** |
|
31 | - * Handle the post-install Composer event. |
|
32 | - * |
|
33 | - * @param \Composer\Script\Event $event The composer event. |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public static function post_install( Event $event ) { |
|
37 | - require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php'; |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * Handle the post-update Composer event. |
|
42 | - * |
|
43 | - * @param \Composer\Script\Event $event The composer event. |
|
44 | - * @return void |
|
45 | - */ |
|
46 | - public static function post_update( Event $event ) { |
|
47 | - require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php'; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * Handle the post-autoload-dump Composer event. |
|
52 | - * |
|
53 | - * @param \Composer\Script\Event $event The composer event. |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - public static function post_autoload_dump( Event $event ) { |
|
57 | - require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php'; |
|
58 | - |
|
59 | - $dir = $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/../'; |
|
60 | - $root = dirname( $event->getComposer()->getConfig()->get( 'vendor-dir' ) ); |
|
61 | - |
|
62 | - $vendor_name = strtolower( basename( $root ) ); |
|
63 | - $partials = explode( '-', $vendor_name ); |
|
64 | - $camel_case_partials = array(); |
|
65 | - foreach ( $partials as $partial ) { |
|
66 | - $camel_case_partials[] = ucfirst( strtolower( $partial ) ); |
|
67 | - } |
|
68 | - $camel_case = implode( '_', $camel_case_partials ); |
|
69 | - $snake_case = implode( '_', $partials ); |
|
70 | - |
|
71 | - $files = array( |
|
72 | - '/admin/class-wpb-admin.php', |
|
73 | - '/admin/class-wpb-admin-menu.php', |
|
74 | - '/admin/class-wpb-admin-submenu.php', |
|
75 | - '/admin/partials/wpb-admin-display.php', |
|
76 | - '/admin/css/wpb-admin.css', |
|
77 | - '/admin/js/wpb-admin.js', |
|
78 | - '/app/Exceptions/Handler.php', |
|
79 | - '/app/Http/Controllers/ProductController.php', |
|
80 | - '/app/Http/Middleware/AuthMiddleware.php', |
|
81 | - '/app/Http/Middleware/VerifyCsrfToken.php', |
|
82 | - '/app/Http/Kernel.php', |
|
83 | - '/app/User.php', |
|
84 | - '/app/Post.php', |
|
85 | - '/bootstrap/app.php', |
|
86 | - '/config/app.php', |
|
87 | - '/config/database.php', |
|
88 | - '/config/view.php', |
|
89 | - '/database/migrations/class-create-customers-table.php', |
|
90 | - '/database/seeds/class-customers-table.php', |
|
91 | - '/includes/class-wpb-activator.php', |
|
92 | - '/includes/class-wpb-deactivator.php', |
|
93 | - '/includes/class-wpb-i18n.php', |
|
94 | - '/includes/class-wpb-loader.php', |
|
95 | - '/includes/class-wpb.php', |
|
96 | - '/public/class-wpb-public.php', |
|
97 | - '/public/partials/wpb-public-display.php', |
|
98 | - '/public/css/wpb-public.css', |
|
99 | - '/public/js/wpb-public.js', |
|
100 | - '/resources/js/admin/main.js', |
|
101 | - '/resources/js/admin/router/index.js', |
|
102 | - '/resources/js/frontend/main.js', |
|
103 | - '/resources/js/spa/main.js', |
|
104 | - '/routes/web.php', |
|
105 | - '/routes/api.php', |
|
106 | - '/src/Contracts/Http/Kernel.php', |
|
107 | - '/src/Contracts/ExceptionHandler.php', |
|
108 | - '/src/Database/Eloquent/Scopes/PostAuthorScope.php', |
|
109 | - '/src/Database/Eloquent/Scopes/PostStatusScope.php', |
|
110 | - '/src/Database/Eloquent/Scopes/PostTypeScope.php', |
|
111 | - '/src/Database/DB.php', |
|
112 | - '/src/Exceptions/Handler.php', |
|
113 | - '/src/Http/Events/RequestHandled.php', |
|
114 | - '/src/Http/Kernel.php', |
|
115 | - '/src/helpers.php', |
|
116 | - '/src/Support/Facades/Config.php', |
|
117 | - '/src/Support/Facades/Route.php', |
|
118 | - '/src/Application.php', |
|
119 | - '/tests/Application.php', |
|
120 | - '/wpb.php', |
|
121 | - ); |
|
122 | - |
|
123 | - foreach ( $files as $file ) { |
|
124 | - $file = $root . $file; |
|
125 | - if ( file_exists( $file ) ) { |
|
126 | - |
|
127 | - $filesystem = new Filesystem(); |
|
128 | - |
|
129 | - $contents = $filesystem->get( $file ); |
|
130 | - $contents = str_replace( 'wpb_', $snake_case . '_', $contents ); |
|
131 | - $contents = str_replace( 'wpb', $vendor_name, $contents ); |
|
132 | - $contents = str_replace( 'WPB_APP_ROOT', strtoupper( $camel_case ) . '_APP_ROOT', $contents ); |
|
133 | - $contents = str_replace( 'WPB_FILE', strtoupper( $camel_case ) . '_FILE', $contents ); |
|
134 | - $contents = str_replace( 'WPB_PATH', strtoupper( $camel_case ) . '_PATH', $contents ); |
|
135 | - $contents = str_replace( 'WPB_INCLUDES', strtoupper( $camel_case ) . '_INCLUDES', $contents ); |
|
136 | - $contents = str_replace( 'WPB_URL', strtoupper( $camel_case ) . '_URL', $contents ); |
|
137 | - $contents = str_replace( 'WPB_ASSETS', strtoupper( $camel_case ) . '_ASSETS', $contents ); |
|
138 | - $contents = str_replace( 'WPB_VERSION', strtoupper( $camel_case ) . '_VERSION', $contents ); |
|
139 | - $contents = str_replace( 'WPB', $camel_case, $contents ); |
|
140 | - $filesystem->put( |
|
141 | - $file, |
|
142 | - $contents |
|
143 | - ); |
|
144 | - |
|
145 | - $dir = dirname( $file ); |
|
146 | - $file_name = basename( $file ); |
|
147 | - $new_file_name = str_replace( 'wpb', $vendor_name, $file_name ); |
|
148 | - |
|
149 | - if ( $file_name !== $new_file_name ) { |
|
150 | - rename( $file, $dir . '/' . $new_file_name ); |
|
151 | - } |
|
152 | - } |
|
153 | - } |
|
154 | - |
|
155 | - static::update_composer( $filesystem, $root, $camel_case ); |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * Replace bootstrap file. |
|
160 | - * |
|
161 | - * @since 1.0.0 |
|
162 | - * @access public |
|
163 | - * |
|
164 | - * @param Illuminate\Filesystem\Filesystem $filesystem The illuminate filesystem. |
|
165 | - * @param string $root The string is unique root path for each plugin. |
|
166 | - * @param string $camel_case This string is camel case of project name. |
|
167 | - * |
|
168 | - * @return void |
|
169 | - */ |
|
170 | - protected static function update_bootstrap( $filesystem, $root, $camel_case ) { |
|
171 | - $file = $root . '/bootstrap/app.php'; |
|
172 | - if ( file_exists( $file ) ) { |
|
173 | - $contents = $filesystem->get( $file ); |
|
174 | - $contents = str_replace( 'WPB_APP_ROOT', strtoupper( $camel_case ) . '_APP_ROOT', $contents ); |
|
175 | - $filesystem->put( |
|
176 | - $file, |
|
177 | - $contents |
|
178 | - ); |
|
179 | - |
|
180 | - } |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * Update composer. |
|
185 | - * |
|
186 | - * @param Illuminate\Filesystem\Filesystem $filesystem The illuminate filesystem. |
|
187 | - * @param string $root The app root. |
|
188 | - * @param string $camel_case The composer event. |
|
189 | - * |
|
190 | - * @return void |
|
191 | - */ |
|
192 | - protected static function update_composer( $filesystem, $root, $camel_case ) { |
|
193 | - $file = $root . '/composer.json'; |
|
194 | - if ( file_exists( $file ) ) { |
|
195 | - $contents = $filesystem->get( $file ); |
|
196 | - $contents = str_replace( 'WPB', $camel_case, $contents ); |
|
197 | - $filesystem->put( |
|
198 | - $file, |
|
199 | - $contents |
|
200 | - ); |
|
201 | - } |
|
202 | - } |
|
30 | + /** |
|
31 | + * Handle the post-install Composer event. |
|
32 | + * |
|
33 | + * @param \Composer\Script\Event $event The composer event. |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public static function post_install( Event $event ) { |
|
37 | + require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php'; |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * Handle the post-update Composer event. |
|
42 | + * |
|
43 | + * @param \Composer\Script\Event $event The composer event. |
|
44 | + * @return void |
|
45 | + */ |
|
46 | + public static function post_update( Event $event ) { |
|
47 | + require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php'; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * Handle the post-autoload-dump Composer event. |
|
52 | + * |
|
53 | + * @param \Composer\Script\Event $event The composer event. |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + public static function post_autoload_dump( Event $event ) { |
|
57 | + require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php'; |
|
58 | + |
|
59 | + $dir = $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/../'; |
|
60 | + $root = dirname( $event->getComposer()->getConfig()->get( 'vendor-dir' ) ); |
|
61 | + |
|
62 | + $vendor_name = strtolower( basename( $root ) ); |
|
63 | + $partials = explode( '-', $vendor_name ); |
|
64 | + $camel_case_partials = array(); |
|
65 | + foreach ( $partials as $partial ) { |
|
66 | + $camel_case_partials[] = ucfirst( strtolower( $partial ) ); |
|
67 | + } |
|
68 | + $camel_case = implode( '_', $camel_case_partials ); |
|
69 | + $snake_case = implode( '_', $partials ); |
|
70 | + |
|
71 | + $files = array( |
|
72 | + '/admin/class-wpb-admin.php', |
|
73 | + '/admin/class-wpb-admin-menu.php', |
|
74 | + '/admin/class-wpb-admin-submenu.php', |
|
75 | + '/admin/partials/wpb-admin-display.php', |
|
76 | + '/admin/css/wpb-admin.css', |
|
77 | + '/admin/js/wpb-admin.js', |
|
78 | + '/app/Exceptions/Handler.php', |
|
79 | + '/app/Http/Controllers/ProductController.php', |
|
80 | + '/app/Http/Middleware/AuthMiddleware.php', |
|
81 | + '/app/Http/Middleware/VerifyCsrfToken.php', |
|
82 | + '/app/Http/Kernel.php', |
|
83 | + '/app/User.php', |
|
84 | + '/app/Post.php', |
|
85 | + '/bootstrap/app.php', |
|
86 | + '/config/app.php', |
|
87 | + '/config/database.php', |
|
88 | + '/config/view.php', |
|
89 | + '/database/migrations/class-create-customers-table.php', |
|
90 | + '/database/seeds/class-customers-table.php', |
|
91 | + '/includes/class-wpb-activator.php', |
|
92 | + '/includes/class-wpb-deactivator.php', |
|
93 | + '/includes/class-wpb-i18n.php', |
|
94 | + '/includes/class-wpb-loader.php', |
|
95 | + '/includes/class-wpb.php', |
|
96 | + '/public/class-wpb-public.php', |
|
97 | + '/public/partials/wpb-public-display.php', |
|
98 | + '/public/css/wpb-public.css', |
|
99 | + '/public/js/wpb-public.js', |
|
100 | + '/resources/js/admin/main.js', |
|
101 | + '/resources/js/admin/router/index.js', |
|
102 | + '/resources/js/frontend/main.js', |
|
103 | + '/resources/js/spa/main.js', |
|
104 | + '/routes/web.php', |
|
105 | + '/routes/api.php', |
|
106 | + '/src/Contracts/Http/Kernel.php', |
|
107 | + '/src/Contracts/ExceptionHandler.php', |
|
108 | + '/src/Database/Eloquent/Scopes/PostAuthorScope.php', |
|
109 | + '/src/Database/Eloquent/Scopes/PostStatusScope.php', |
|
110 | + '/src/Database/Eloquent/Scopes/PostTypeScope.php', |
|
111 | + '/src/Database/DB.php', |
|
112 | + '/src/Exceptions/Handler.php', |
|
113 | + '/src/Http/Events/RequestHandled.php', |
|
114 | + '/src/Http/Kernel.php', |
|
115 | + '/src/helpers.php', |
|
116 | + '/src/Support/Facades/Config.php', |
|
117 | + '/src/Support/Facades/Route.php', |
|
118 | + '/src/Application.php', |
|
119 | + '/tests/Application.php', |
|
120 | + '/wpb.php', |
|
121 | + ); |
|
122 | + |
|
123 | + foreach ( $files as $file ) { |
|
124 | + $file = $root . $file; |
|
125 | + if ( file_exists( $file ) ) { |
|
126 | + |
|
127 | + $filesystem = new Filesystem(); |
|
128 | + |
|
129 | + $contents = $filesystem->get( $file ); |
|
130 | + $contents = str_replace( 'wpb_', $snake_case . '_', $contents ); |
|
131 | + $contents = str_replace( 'wpb', $vendor_name, $contents ); |
|
132 | + $contents = str_replace( 'WPB_APP_ROOT', strtoupper( $camel_case ) . '_APP_ROOT', $contents ); |
|
133 | + $contents = str_replace( 'WPB_FILE', strtoupper( $camel_case ) . '_FILE', $contents ); |
|
134 | + $contents = str_replace( 'WPB_PATH', strtoupper( $camel_case ) . '_PATH', $contents ); |
|
135 | + $contents = str_replace( 'WPB_INCLUDES', strtoupper( $camel_case ) . '_INCLUDES', $contents ); |
|
136 | + $contents = str_replace( 'WPB_URL', strtoupper( $camel_case ) . '_URL', $contents ); |
|
137 | + $contents = str_replace( 'WPB_ASSETS', strtoupper( $camel_case ) . '_ASSETS', $contents ); |
|
138 | + $contents = str_replace( 'WPB_VERSION', strtoupper( $camel_case ) . '_VERSION', $contents ); |
|
139 | + $contents = str_replace( 'WPB', $camel_case, $contents ); |
|
140 | + $filesystem->put( |
|
141 | + $file, |
|
142 | + $contents |
|
143 | + ); |
|
144 | + |
|
145 | + $dir = dirname( $file ); |
|
146 | + $file_name = basename( $file ); |
|
147 | + $new_file_name = str_replace( 'wpb', $vendor_name, $file_name ); |
|
148 | + |
|
149 | + if ( $file_name !== $new_file_name ) { |
|
150 | + rename( $file, $dir . '/' . $new_file_name ); |
|
151 | + } |
|
152 | + } |
|
153 | + } |
|
154 | + |
|
155 | + static::update_composer( $filesystem, $root, $camel_case ); |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * Replace bootstrap file. |
|
160 | + * |
|
161 | + * @since 1.0.0 |
|
162 | + * @access public |
|
163 | + * |
|
164 | + * @param Illuminate\Filesystem\Filesystem $filesystem The illuminate filesystem. |
|
165 | + * @param string $root The string is unique root path for each plugin. |
|
166 | + * @param string $camel_case This string is camel case of project name. |
|
167 | + * |
|
168 | + * @return void |
|
169 | + */ |
|
170 | + protected static function update_bootstrap( $filesystem, $root, $camel_case ) { |
|
171 | + $file = $root . '/bootstrap/app.php'; |
|
172 | + if ( file_exists( $file ) ) { |
|
173 | + $contents = $filesystem->get( $file ); |
|
174 | + $contents = str_replace( 'WPB_APP_ROOT', strtoupper( $camel_case ) . '_APP_ROOT', $contents ); |
|
175 | + $filesystem->put( |
|
176 | + $file, |
|
177 | + $contents |
|
178 | + ); |
|
179 | + |
|
180 | + } |
|
181 | + } |
|
182 | + |
|
183 | + /** |
|
184 | + * Update composer. |
|
185 | + * |
|
186 | + * @param Illuminate\Filesystem\Filesystem $filesystem The illuminate filesystem. |
|
187 | + * @param string $root The app root. |
|
188 | + * @param string $camel_case The composer event. |
|
189 | + * |
|
190 | + * @return void |
|
191 | + */ |
|
192 | + protected static function update_composer( $filesystem, $root, $camel_case ) { |
|
193 | + $file = $root . '/composer.json'; |
|
194 | + if ( file_exists( $file ) ) { |
|
195 | + $contents = $filesystem->get( $file ); |
|
196 | + $contents = str_replace( 'WPB', $camel_case, $contents ); |
|
197 | + $filesystem->put( |
|
198 | + $file, |
|
199 | + $contents |
|
200 | + ); |
|
201 | + } |
|
202 | + } |
|
203 | 203 | } |