@@ -16,7 +16,9 @@ discard block |
||
| 16 | 16 | public function routeAdminPostRequest() |
| 17 | 17 | { |
| 18 | 18 | $request = $this->getRequest(); |
| 19 | - if( !$this->isValidPostRequest( $request ))return; |
|
| 19 | + if( !$this->isValidPostRequest( $request )) { |
|
| 20 | + return; |
|
| 21 | + } |
|
| 20 | 22 | $this->checkAdminNonce( $request['action'] ); |
| 21 | 23 | $this->routeRequest( 'admin', $request['action'], $request ); |
| 22 | 24 | } |
@@ -51,9 +53,13 @@ discard block |
||
| 51 | 53 | */ |
| 52 | 54 | public function routePublicPostRequest() |
| 53 | 55 | { |
| 54 | - if( is_admin() )return; |
|
| 56 | + if( is_admin() ) { |
|
| 57 | + return; |
|
| 58 | + } |
|
| 55 | 59 | $request = $this->getRequest(); |
| 56 | - if( !$this->isValidPostRequest( $request ))return; |
|
| 60 | + if( !$this->isValidPostRequest( $request )) { |
|
| 61 | + return; |
|
| 62 | + } |
|
| 57 | 63 | if( !wp_verify_nonce( $request['_wpnonce'], $request['action'] )) { |
| 58 | 64 | glsr_log()->error( 'Nonce check failed for public request' )->info( $request ); |
| 59 | 65 | return; |
@@ -67,7 +73,9 @@ discard block |
||
| 67 | 73 | public function routeWebhookRequest() |
| 68 | 74 | { |
| 69 | 75 | $request = filter_input( INPUT_GET, Application::PREFIX.'hook' ); |
| 70 | - if( !$request )return; |
|
| 76 | + if( !$request ) { |
|
| 77 | + return; |
|
| 78 | + } |
|
| 71 | 79 | // @todo manage webhook here |
| 72 | 80 | } |
| 73 | 81 | |
@@ -92,7 +100,9 @@ discard block |
||
| 92 | 100 | { |
| 93 | 101 | foreach( ['request', Application::ID] as $key ) { |
| 94 | 102 | $request = glsr( Helper::class )->filterInputArray( $key ); |
| 95 | - if( !empty( $request ))break; |
|
| 103 | + if( !empty( $request )) { |
|
| 104 | + break; |
|
| 105 | + } |
|
| 96 | 106 | } |
| 97 | 107 | if( isset( $request[Application::ID]['action'] )) { |
| 98 | 108 | $request = $request[Application::ID]; |
@@ -29,7 +29,8 @@ |
||
| 29 | 29 | protected $settings; |
| 30 | 30 | protected $taxonomy; |
| 31 | 31 | |
| 32 | - public function __construct( Application $app ) { |
|
| 32 | + public function __construct( Application $app ) |
|
| 33 | + { |
|
| 33 | 34 | $this->app = $app; |
| 34 | 35 | $this->admin = $app->make( AdminController::class ); |
| 35 | 36 | $this->editor = $app->make( EditorController::class ); |
@@ -4,7 +4,8 @@ discard block |
||
| 4 | 4 | /** |
| 5 | 5 | * @return mixed |
| 6 | 6 | */ |
| 7 | -function glsr( $alias = null ) { |
|
| 7 | +function glsr( $alias = null ) |
|
| 8 | +{ |
|
| 8 | 9 | $app = \GeminiLabs\SiteReviews\Application::load(); |
| 9 | 10 | return !empty( $alias ) |
| 10 | 11 | ? $app->make( $alias ) |
@@ -14,7 +15,8 @@ discard block |
||
| 14 | 15 | /** |
| 15 | 16 | * @return \WP_Screen|object |
| 16 | 17 | */ |
| 17 | -function glsr_current_screen() { |
|
| 18 | +function glsr_current_screen() |
|
| 19 | +{ |
|
| 18 | 20 | if( function_exists( 'get_current_screen' )) { |
| 19 | 21 | $screen = get_current_screen(); |
| 20 | 22 | } |
@@ -26,7 +28,8 @@ discard block |
||
| 26 | 28 | /** |
| 27 | 29 | * @return \GeminiLabs\SiteReviews\Database |
| 28 | 30 | */ |
| 29 | -function glsr_db() { |
|
| 31 | +function glsr_db() |
|
| 32 | +{ |
|
| 30 | 33 | return glsr( 'Database' ); |
| 31 | 34 | } |
| 32 | 35 | |
@@ -34,7 +37,8 @@ discard block |
||
| 34 | 37 | * @param mixed ...$vars |
| 35 | 38 | * @return void |
| 36 | 39 | */ |
| 37 | -function glsr_debug( ...$vars ) { |
|
| 40 | +function glsr_debug( ...$vars ) |
|
| 41 | +{ |
|
| 38 | 42 | if( count( $vars ) == 1 ) { |
| 39 | 43 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
| 40 | 44 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -51,7 +55,8 @@ discard block |
||
| 51 | 55 | /** |
| 52 | 56 | * @return \GeminiLabs\SiteReviews\Modules\Console |
| 53 | 57 | */ |
| 54 | -function glsr_log() { |
|
| 58 | +function glsr_log() |
|
| 59 | +{ |
|
| 55 | 60 | $args = func_get_args(); |
| 56 | 61 | $context = isset( $args[1] ) |
| 57 | 62 | ? $args[1] |
@@ -67,14 +72,16 @@ discard block |
||
| 67 | 72 | * @param mixed $fallback |
| 68 | 73 | * @return string|array |
| 69 | 74 | */ |
| 70 | -function glsr_get_option( $path = '', $fallback = '' ) { |
|
| 75 | +function glsr_get_option( $path = '', $fallback = '' ) |
|
| 76 | +{ |
|
| 71 | 77 | return glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback ); |
| 72 | 78 | } |
| 73 | 79 | |
| 74 | 80 | /** |
| 75 | 81 | * @return array |
| 76 | 82 | */ |
| 77 | -function glsr_get_options() { |
|
| 83 | +function glsr_get_options() |
|
| 84 | +{ |
|
| 78 | 85 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
| 79 | 86 | } |
| 80 | 87 | |
@@ -190,7 +190,9 @@ |
||
| 190 | 190 | if( $index === false |
| 191 | 191 | || !isset( $caller[$index+2]['class'] ) |
| 192 | 192 | || !isset( $caller[$index+2]['function'] ) |
| 193 | - )return; |
|
| 193 | + ) { |
|
| 194 | + return; |
|
| 195 | + } |
|
| 194 | 196 | return sprintf( '[%s()->%s:%s] ', |
| 195 | 197 | $caller[$index+2]['class'], |
| 196 | 198 | $caller[$index+2]['function'], |