| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 8.7414 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 1 | public function handle( Command $command ) |
|
| 16 | { |
||
| 17 | 1 | $review = glsr( ReviewManager::class )->create( $command ); |
|
| 18 | 1 | if( !$review ) { |
|
| 19 | glsr( Session::class )->set( $command->form_id.'errors', [] ); |
||
| 20 | glsr( Session::class )->set( $command->form_id.'message', __( 'Your review could not be submitted and the error has been logged. Please notify the site admin.', 'site-reviews' )); |
||
| 21 | return; |
||
| 22 | } |
||
| 23 | 1 | glsr( Session::class )->set( $command->form_id.'message', __( 'Your review has been submitted!', 'site-reviews' )); |
|
| 24 | 1 | glsr( Notification::class )->send( $review ); |
|
| 25 | do_action( 'site-reviews/local/review/submitted', $review ); |
||
| 26 | if( $command->ajax_request )return; |
||
| 27 | if( empty( $command->referer )) { |
||
| 28 | glsr_log()->warning( 'The form referer ($_SERVER[REQUEST_URI]) was empty.' )->info( $command ); |
||
| 29 | $command->referer = home_url(); |
||
| 30 | } |
||
| 31 | wp_safe_redirect( $command->referer ); |
||
| 32 | exit; |
||
| 33 | } |
||
| 35 |