@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @return void |
| 15 | 15 | */ |
| 16 | - public function download($filename, $content) |
|
| 16 | + public function download( $filename, $content ) |
|
| 17 | 17 | { |
| 18 | - if (!current_user_can(glsr()->constant('CAPABILITY'))) { |
|
| 18 | + if( !current_user_can( glsr()->constant( 'CAPABILITY' ) ) ) { |
|
| 19 | 19 | return; |
| 20 | 20 | } |
| 21 | 21 | nocache_headers(); |
| 22 | - header('Content-Type: text/plain'); |
|
| 23 | - header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 24 | - echo html_entity_decode($content); |
|
| 22 | + header( 'Content-Type: text/plain' ); |
|
| 23 | + header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
|
| 24 | + echo html_entity_decode( $content ); |
|
| 25 | 25 | exit; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -30,18 +30,18 @@ discard block |
||
| 30 | 30 | * @return mixed |
| 31 | 31 | * @throws InvalidArgumentException |
| 32 | 32 | */ |
| 33 | - public function execute($command) |
|
| 33 | + public function execute( $command ) |
|
| 34 | 34 | { |
| 35 | - $handlerClass = str_replace('Commands', 'Handlers', get_class($command)); |
|
| 36 | - if (!class_exists($handlerClass)) { |
|
| 37 | - throw new InvalidArgumentException('Handler '.$handlerClass.' not found.'); |
|
| 35 | + $handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command ) ); |
|
| 36 | + if( !class_exists( $handlerClass ) ) { |
|
| 37 | + throw new InvalidArgumentException( 'Handler '.$handlerClass.' not found.' ); |
|
| 38 | 38 | } |
| 39 | 39 | try { |
| 40 | - return glsr($handlerClass)->handle($command); |
|
| 41 | - } catch (Exception $e) { |
|
| 42 | - status_header(400); |
|
| 43 | - glsr(Notice::class)->addError(new WP_Error('site_reviews_error', $e->getMessage())); |
|
| 44 | - glsr_log()->error($e->getMessage()); |
|
| 40 | + return glsr( $handlerClass )->handle( $command ); |
|
| 41 | + } catch( Exception $e ) { |
|
| 42 | + status_header( 400 ); |
|
| 43 | + glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() ) ); |
|
| 44 | + glsr_log()->error( $e->getMessage() ); |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | |
@@ -50,15 +50,15 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | protected function getPostId() |
| 52 | 52 | { |
| 53 | - return intval(filter_input(INPUT_GET, 'post')); |
|
| 53 | + return intval( filter_input( INPUT_GET, 'post' ) ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * @param int $postId |
| 58 | 58 | * @return bool |
| 59 | 59 | */ |
| 60 | - protected function isReviewPostId($postId) |
|
| 60 | + protected function isReviewPostId( $postId ) |
|
| 61 | 61 | { |
| 62 | - return Application::POST_TYPE == get_post_field('post_type', $postId); |
|
| 62 | + return Application::POST_TYPE == get_post_field( 'post_type', $postId ); |
|
| 63 | 63 | } |
| 64 | 64 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | { |
| 15 | 15 | public function __construct() |
| 16 | 16 | { |
| 17 | - $this->meta = new WP_REST_Post_Meta_Fields(Application::POST_TYPE); |
|
| 17 | + $this->meta = new WP_REST_Post_Meta_Fields( Application::POST_TYPE ); |
|
| 18 | 18 | $this->namespace = Application::ID.'/v1'; |
| 19 | 19 | $this->post_type = Application::POST_TYPE; |
| 20 | 20 | $this->rest_base = 'reviews'; |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | // ['callback' => [$this, 'createReview'], 'methods' => Server::CREATABLE], |
| 30 | 30 | // ['callback' => [$this, 'getReviews'], 'methods' => Server::READABLE], |
| 31 | 31 | // ]); |
| 32 | - register_rest_route($this->namespace, '/types', [ |
|
| 32 | + register_rest_route( $this->namespace, '/types', [ |
|
| 33 | 33 | ['callback' => [$this, 'getReviewTypes'], 'methods' => Server::READABLE], |
| 34 | - ]); |
|
| 34 | + ] ); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public function createReview() |
| 41 | 41 | { |
| 42 | 42 | $response = []; |
| 43 | - return rest_ensure_response($response); |
|
| 43 | + return rest_ensure_response( $response ); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | public function getReviews() |
| 50 | 50 | { |
| 51 | 51 | $response = []; |
| 52 | - return rest_ensure_response($response); |
|
| 52 | + return rest_ensure_response( $response ); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -58,12 +58,12 @@ discard block |
||
| 58 | 58 | public function getReviewTypes() |
| 59 | 59 | { |
| 60 | 60 | $response = []; |
| 61 | - foreach (glsr()->reviewTypes as $slug => $name) { |
|
| 61 | + foreach( glsr()->reviewTypes as $slug => $name ) { |
|
| 62 | 62 | $response[] = [ |
| 63 | 63 | 'name' => $name, |
| 64 | 64 | 'slug' => $slug, |
| 65 | 65 | ]; |
| 66 | 66 | } |
| 67 | - return rest_ensure_response($response); |
|
| 67 | + return rest_ensure_response( $response ); |
|
| 68 | 68 | } |
| 69 | 69 | } |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function renderTaxonomyFilter() |
| 37 | 37 | { |
| 38 | - if (!is_object_in_taxonomy(glsr_current_screen()->post_type, Application::TAXONOMY)) { |
|
| 38 | + if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ) ) { |
|
| 39 | 39 | return; |
| 40 | 40 | } |
| 41 | - echo glsr(Builder::class)->label(__('Filter by category', 'site-reviews'), [ |
|
| 41 | + echo glsr( Builder::class )->label( __( 'Filter by category', 'site-reviews' ), [ |
|
| 42 | 42 | 'class' => 'screen-reader-text', |
| 43 | 43 | 'for' => Application::TAXONOMY, |
| 44 | - ]); |
|
| 45 | - wp_dropdown_categories([ |
|
| 44 | + ] ); |
|
| 45 | + wp_dropdown_categories( [ |
|
| 46 | 46 | 'depth' => 3, |
| 47 | 47 | 'hide_empty' => true, |
| 48 | 48 | 'hide_if_empty' => true, |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | 'show_option_all' => $this->getShowOptionAll(), |
| 55 | 55 | 'taxonomy' => Application::TAXONOMY, |
| 56 | 56 | 'value_field' => 'slug', |
| 57 | - ]); |
|
| 57 | + ] ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | * @return void |
| 68 | 68 | * @action set_object_terms |
| 69 | 69 | */ |
| 70 | - public function restrictTermSelection($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds) |
|
| 70 | + public function restrictTermSelection( $postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds ) |
|
| 71 | 71 | { |
| 72 | - if (Application::TAXONOMY != $taxonomy || count($newTTIds) <= 1) { |
|
| 72 | + if( Application::TAXONOMY != $taxonomy || count( $newTTIds ) <= 1 ) { |
|
| 73 | 73 | return; |
| 74 | 74 | } |
| 75 | - $diff = array_diff($newTTIds, $oldTTIds); |
|
| 76 | - if (empty($newTerm = array_shift($diff))) { |
|
| 77 | - $newTerm = array_shift($newTTIds); |
|
| 75 | + $diff = array_diff( $newTTIds, $oldTTIds ); |
|
| 76 | + if( empty($newTerm = array_shift( $diff )) ) { |
|
| 77 | + $newTerm = array_shift( $newTTIds ); |
|
| 78 | 78 | } |
| 79 | - if ($newTerm) { |
|
| 80 | - wp_set_object_terms($postId, intval($newTerm), $taxonomy); |
|
| 79 | + if( $newTerm ) { |
|
| 80 | + wp_set_object_terms( $postId, intval( $newTerm ), $taxonomy ); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | protected function getSelected() |
| 88 | 88 | { |
| 89 | 89 | global $wp_query; |
| 90 | - return glsr_get($wp_query->query, Application::TAXONOMY); |
|
| 90 | + return glsr_get( $wp_query->query, Application::TAXONOMY ); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | protected function getShowOptionAll() |
| 97 | 97 | { |
| 98 | - $taxonomy = get_taxonomy(Application::TAXONOMY); |
|
| 98 | + $taxonomy = get_taxonomy( Application::TAXONOMY ); |
|
| 99 | 99 | return $taxonomy |
| 100 | - ? ucfirst(strtolower($taxonomy->labels->all_items)) |
|
| 100 | + ? ucfirst( strtolower( $taxonomy->labels->all_items ) ) |
|
| 101 | 101 | : ''; |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -12,9 +12,9 @@ discard block |
||
| 12 | 12 | * @return array |
| 13 | 13 | * @filter block_categories |
| 14 | 14 | */ |
| 15 | - public function filterBlockCategories($categories) |
|
| 15 | + public function filterBlockCategories( $categories ) |
|
| 16 | 16 | { |
| 17 | - $categories = glsr(Helper::class)->consolidateArray($categories); |
|
| 17 | + $categories = glsr( Helper::class )->consolidateArray( $categories ); |
|
| 18 | 18 | $categories[] = [ |
| 19 | 19 | 'icon' => null, |
| 20 | 20 | 'slug' => Application::ID, |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @filter classic_editor_enabled_editors_for_post_type |
| 31 | 31 | * @plugin classic-editor/classic-editor.php |
| 32 | 32 | */ |
| 33 | - public function filterEnabledEditors($editors, $postType) |
|
| 33 | + public function filterEnabledEditors( $editors, $postType ) |
|
| 34 | 34 | { |
| 35 | 35 | return Application::POST_TYPE == $postType |
| 36 | 36 | ? ['block_editor' => false, 'classic_editor' => false] |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @return bool |
| 44 | 44 | * @filter use_block_editor_for_post_type |
| 45 | 45 | */ |
| 46 | - public function filterUseBlockEditor($bool, $postType) |
|
| 46 | + public function filterUseBlockEditor( $bool, $postType ) |
|
| 47 | 47 | { |
| 48 | 48 | return Application::POST_TYPE == $postType |
| 49 | 49 | ? false |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | wp_register_style( |
| 59 | 59 | Application::ID.'/blocks', |
| 60 | - glsr()->url('assets/styles/'.Application::ID.'-blocks.css'), |
|
| 60 | + glsr()->url( 'assets/styles/'.Application::ID.'-blocks.css' ), |
|
| 61 | 61 | ['wp-edit-blocks'], |
| 62 | 62 | glsr()->version |
| 63 | 63 | ); |
| 64 | 64 | wp_register_script( |
| 65 | 65 | Application::ID.'/blocks', |
| 66 | - glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'), |
|
| 66 | + glsr()->url( 'assets/scripts/'.Application::ID.'-blocks.js' ), |
|
| 67 | 67 | ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID], |
| 68 | 68 | glsr()->version |
| 69 | 69 | ); |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | $blocks = [ |
| 79 | 79 | 'form', 'reviews', 'summary', |
| 80 | 80 | ]; |
| 81 | - foreach ($blocks as $block) { |
|
| 82 | - $id = str_replace('_reviews', '', Application::ID.'_'.$block); |
|
| 83 | - $blockClass = glsr(Helper::class)->buildClassName($id.'-block', 'Blocks'); |
|
| 84 | - if (!class_exists($blockClass)) { |
|
| 85 | - glsr_log()->error(sprintf('Class missing (%s)', $blockClass)); |
|
| 81 | + foreach( $blocks as $block ) { |
|
| 82 | + $id = str_replace( '_reviews', '', Application::ID.'_'.$block ); |
|
| 83 | + $blockClass = glsr( Helper::class )->buildClassName( $id.'-block', 'Blocks' ); |
|
| 84 | + if( !class_exists( $blockClass ) ) { |
|
| 85 | + glsr_log()->error( sprintf( 'Class missing (%s)', $blockClass ) ); |
|
| 86 | 86 | continue; |
| 87 | 87 | } |
| 88 | - glsr($blockClass)->register($block); |
|
| 88 | + glsr( $blockClass )->register( $block ); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -7,11 +7,11 @@ |
||
| 7 | 7 | public $id; |
| 8 | 8 | public $pinned; |
| 9 | 9 | |
| 10 | - public function __construct($input) |
|
| 10 | + public function __construct( $input ) |
|
| 11 | 11 | { |
| 12 | 12 | $this->id = $input['id']; |
| 13 | 13 | $this->pinned = isset($input['pinned']) |
| 14 | - ? wp_validate_boolean($input['pinned']) |
|
| 14 | + ? wp_validate_boolean( $input['pinned'] ) |
|
| 15 | 15 | : null; |
| 16 | 16 | } |
| 17 | 17 | } |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | { |
| 7 | 7 | public $widgets; |
| 8 | 8 | |
| 9 | - public function __construct($input) |
|
| 9 | + public function __construct( $input ) |
|
| 10 | 10 | { |
| 11 | 11 | $this->widgets = $input; |
| 12 | 12 | } |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | public $id; |
| 8 | 8 | public $status; |
| 9 | 9 | |
| 10 | - public function __construct($input) |
|
| 10 | + public function __construct( $input ) |
|
| 11 | 11 | { |
| 12 | 12 | $this->id = $input['post_id']; |
| 13 | 13 | $this->status = 'approve' == $input['status'] |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | { |
| 7 | 7 | public $popups; |
| 8 | 8 | |
| 9 | - public function __construct($input) |
|
| 9 | + public function __construct( $input ) |
|
| 10 | 10 | { |
| 11 | 11 | $this->popups = $input; |
| 12 | 12 | } |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | { |
| 7 | 7 | public $args; |
| 8 | 8 | |
| 9 | - public function __construct($input) |
|
| 9 | + public function __construct( $input ) |
|
| 10 | 10 | { |
| 11 | 11 | $this->args = $input; |
| 12 | 12 | } |