@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function download( $filename, $content ) |
| 17 | 17 | { |
| 18 | - if( !current_user_can( Application::CAPABILITY ))return; |
|
| 18 | + if( !current_user_can( Application::CAPABILITY ) )return; |
|
| 19 | 19 | nocache_headers(); |
| 20 | 20 | header( 'Content-Type: text/plain' ); |
| 21 | 21 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
| 22 | - echo html_entity_decode( wp_strip_all_tags( $content )); |
|
| 22 | + echo html_entity_decode( wp_strip_all_tags( $content ) ); |
|
| 23 | 23 | exit; |
| 24 | 24 | } |
| 25 | 25 | |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function execute( $command ) |
| 32 | 32 | { |
| 33 | - $handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command )); |
|
| 34 | - if( !class_exists( $handlerClass )) { |
|
| 33 | + $handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command ) ); |
|
| 34 | + if( !class_exists( $handlerClass ) ) { |
|
| 35 | 35 | throw new InvalidArgumentException( 'Handler '.$handlerClass.' not found.' ); |
| 36 | 36 | } |
| 37 | 37 | try { |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | catch( Exception $e ) { |
| 41 | 41 | status_header( 400 ); |
| 42 | - glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() )); |
|
| 42 | + glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() ) ); |
|
| 43 | 43 | glsr_log()->error( $e->getMessage() ); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -49,6 +49,6 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | protected function getPostId() |
| 51 | 51 | { |
| 52 | - return intval( filter_input( INPUT_GET, 'post' )); |
|
| 52 | + return intval( filter_input( INPUT_GET, 'post' ) ); |
|
| 53 | 53 | } |
| 54 | 54 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | public function registerPostType() |
| 21 | 21 | { |
| 22 | 22 | if( !glsr()->hasPermission() )return; |
| 23 | - $command = new RegisterPostType([ |
|
| 23 | + $command = new RegisterPostType( [ |
|
| 24 | 24 | 'capabilities'=> ['create_posts' => 'create_'.Application::POST_TYPE], |
| 25 | 25 | 'columns' => [ |
| 26 | 26 | 'title' => '', |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | 'plural' => __( 'Reviews', 'site-reviews' ), |
| 39 | 39 | 'post_type' => Application::POST_TYPE, |
| 40 | 40 | 'single' => __( 'Review', 'site-reviews' ), |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | $this->execute( $command ); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function registerShortcodes() |
| 50 | 50 | { |
| 51 | - $command = new RegisterShortcodes([ |
|
| 51 | + $command = new RegisterShortcodes( [ |
|
| 52 | 52 | 'site_reviews', |
| 53 | 53 | 'site_reviews_form', |
| 54 | 54 | 'site_reviews_summary', |
| 55 | - ]); |
|
| 55 | + ] ); |
|
| 56 | 56 | $this->execute( $command ); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function registerTaxonomy() |
| 64 | 64 | { |
| 65 | - $command = new RegisterTaxonomy([ |
|
| 65 | + $command = new RegisterTaxonomy( [ |
|
| 66 | 66 | 'hierarchical' => true, |
| 67 | 67 | 'meta_box_cb' => 'glsr_categories_meta_box', |
| 68 | 68 | 'public' => false, |
| 69 | 69 | 'show_admin_column' => true, |
| 70 | 70 | 'show_ui' => true, |
| 71 | - ]); |
|
| 71 | + ] ); |
|
| 72 | 72 | $this->execute( $command ); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function registerWidgets() |
| 80 | 80 | { |
| 81 | - $command = new RegisterWidgets([ |
|
| 81 | + $command = new RegisterWidgets( [ |
|
| 82 | 82 | 'site-reviews' => [ |
| 83 | 83 | 'class' => 'glsr-widget glsr-widget-site-reviews', |
| 84 | 84 | 'description' => __( 'Your site’s most recent reviews.', 'site-reviews' ), |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | 'description' => __( 'A summary of your site’s reviews.', 'site-reviews' ), |
| 95 | 95 | 'title' => __( 'Summary of Reviews', 'site-reviews' ), |
| 96 | 96 | ], |
| 97 | - ]); |
|
| 97 | + ] ); |
|
| 98 | 98 | $this->execute( $command ); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public static function load() |
| 39 | 39 | { |
| 40 | - if( empty( static::$instance )) { |
|
| 40 | + if( empty(static::$instance) ) { |
|
| 41 | 41 | static::$instance = new static; |
| 42 | 42 | } |
| 43 | 43 | return static::$instance; |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function __get( $property ) |
| 51 | 51 | { |
| 52 | - if( property_exists( $this, $property ) && !in_array( $property, static::PROTECTED_PROPERTIES )) { |
|
| 52 | + if( property_exists( $this, $property ) && !in_array( $property, static::PROTECTED_PROPERTIES ) ) { |
|
| 53 | 53 | return $this->$property; |
| 54 | 54 | } |
| 55 | - $constant = 'static::'.strtoupper( $this->make( Helper::class )->snakeCase( $property )); |
|
| 56 | - if( defined( $constant )) { |
|
| 55 | + $constant = 'static::'.strtoupper( $this->make( Helper::class )->snakeCase( $property ) ); |
|
| 56 | + if( defined( $constant ) ) { |
|
| 57 | 57 | return constant( $constant ); |
| 58 | 58 | } |
| 59 | - return isset( $this->storage[$property] ) |
|
| 59 | + return isset($this->storage[$property]) |
|
| 60 | 60 | ? $this->storage[$property] |
| 61 | 61 | : null; |
| 62 | 62 | } |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function __set( $property, $value ) |
| 70 | 70 | { |
| 71 | - if( !property_exists( $this, $property ) || in_array( $property, static::PROTECTED_PROPERTIES )) { |
|
| 71 | + if( !property_exists( $this, $property ) || in_array( $property, static::PROTECTED_PROPERTIES ) ) { |
|
| 72 | 72 | $this->storage[$property] = $value; |
| 73 | 73 | } |
| 74 | - else if( !isset( $this->$property )) { |
|
| 74 | + else if( !isset($this->$property) ) { |
|
| 75 | 75 | $this->$property = $value; |
| 76 | 76 | } |
| 77 | 77 | else { |
| 78 | - throw new Exception( sprintf( 'The "%s" property cannot be changed once set.', $property )); |
|
| 78 | + throw new Exception( sprintf( 'The "%s" property cannot be changed once set.', $property ) ); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
@@ -97,16 +97,16 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function make( $abstract ) |
| 99 | 99 | { |
| 100 | - if( !isset( $this->services[$abstract] )) { |
|
| 100 | + if( !isset($this->services[$abstract]) ) { |
|
| 101 | 101 | $abstract = $this->addNamespace( $abstract ); |
| 102 | 102 | } |
| 103 | - if( isset( $this->services[$abstract] )) { |
|
| 103 | + if( isset($this->services[$abstract]) ) { |
|
| 104 | 104 | $abstract = $this->services[$abstract]; |
| 105 | 105 | } |
| 106 | - if( is_callable( $abstract )) { |
|
| 106 | + if( is_callable( $abstract ) ) { |
|
| 107 | 107 | return call_user_func_array( $abstract, [$this] ); |
| 108 | 108 | } |
| 109 | - if( is_object( $abstract )) { |
|
| 109 | + if( is_object( $abstract ) ) { |
|
| 110 | 110 | return $abstract; |
| 111 | 111 | } |
| 112 | 112 | return $this->resolve( $abstract ); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function singleton( $alias, $binding ) |
| 122 | 122 | { |
| 123 | - $this->bind( $alias, $this->make( $binding )); |
|
| 123 | + $this->bind( $alias, $this->make( $binding ) ); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | protected function addNamespace( $abstract ) |
| 132 | 132 | { |
| 133 | - if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract )) { |
|
| 133 | + if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract ) ) { |
|
| 134 | 134 | $abstract = __NAMESPACE__.'\\'.$abstract; |
| 135 | 135 | } |
| 136 | 136 | return $abstract; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | throw new Exception( 'Target ['.$concrete.'] is not instantiable.' ); |
| 153 | 153 | } |
| 154 | 154 | $constructor = $reflector->getConstructor(); |
| 155 | - if( empty( $constructor )) { |
|
| 155 | + if( empty($constructor) ) { |
|
| 156 | 156 | return new $concrete; |
| 157 | 157 | } |
| 158 | 158 | return $reflector->newInstanceArgs( |
@@ -82,7 +82,7 @@ |
||
| 82 | 82 | { |
| 83 | 83 | $this->render()->div( glsr( Notice::class )->get(), [ |
| 84 | 84 | 'id' => 'glsr-notices', |
| 85 | - ]); |
|
| 85 | + ] ); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -130,8 +130,8 @@ |
||
| 130 | 130 | public function validateRequired( $attribute, $value ) |
| 131 | 131 | { |
| 132 | 132 | return is_null( $value ) |
| 133 | - || ( is_string( $value ) && trim( $value ) === '' ) |
|
| 134 | - || ( is_array( $value ) && count( $value ) < 1 ) |
|
| 133 | + || (is_string( $value ) && trim( $value ) === '') |
|
| 134 | + || (is_array( $value ) && count( $value ) < 1) |
|
| 135 | 135 | ? false |
| 136 | 136 | : true; |
| 137 | 137 | } |
@@ -15,10 +15,10 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function add( $type, $message, array $args = [] ) |
| 17 | 17 | { |
| 18 | - if( empty( array_filter( [$message, $type] )))return; |
|
| 18 | + if( empty(array_filter( [$message, $type] )) )return; |
|
| 19 | 19 | $args['message'] = $message; |
| 20 | 20 | $args['type'] = $type; |
| 21 | - add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ))); |
|
| 21 | + add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ) ) ); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | public function get() |
| 55 | 55 | { |
| 56 | 56 | $notices = array_map( 'unserialize', |
| 57 | - array_unique( array_map( 'serialize', get_settings_errors( Application::ID ))) |
|
| 57 | + array_unique( array_map( 'serialize', get_settings_errors( Application::ID ) ) ) |
|
| 58 | 58 | ); |
| 59 | - if( empty( $notices ))return; |
|
| 59 | + if( empty($notices) )return; |
|
| 60 | 60 | return array_reduce( $notices, function( $carry, $notice ) { |
| 61 | - return $carry.$this->buildNotice( json_decode( $notice['message'], true )); |
|
| 61 | + return $carry.$this->buildNotice( json_decode( $notice['message'], true ) ); |
|
| 62 | 62 | }); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | return glsr( Builder::class )->div( $messages, [ |
| 81 | 81 | 'class' => $class, |
| 82 | - ]); |
|
| 82 | + ] ); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -94,13 +94,13 @@ discard block |
||
| 94 | 94 | 'type' => '', |
| 95 | 95 | ]; |
| 96 | 96 | $args = shortcode_atts( $defaults, $args ); |
| 97 | - if( !in_array( $args['type'], ['error', 'warning', 'success'] )) { |
|
| 97 | + if( !in_array( $args['type'], ['error', 'warning', 'success'] ) ) { |
|
| 98 | 98 | $args['type'] = 'success'; |
| 99 | 99 | } |
| 100 | 100 | $args['messages'] = is_wp_error( $args['message'] ) |
| 101 | 101 | ? (array)$args['message']->get_error_message() |
| 102 | 102 | : (array)$args['message']; |
| 103 | - unset( $args['message'] ); |
|
| 103 | + unset($args['message']); |
|
| 104 | 104 | return $args; |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -14,14 +14,14 @@ |
||
| 14 | 14 | { |
| 15 | 15 | $partial = glsr( Html::class )->buildTemplate( 'templates/reviews-form', [ |
| 16 | 16 | 'globals' => $args, |
| 17 | - ]); |
|
| 17 | + ] ); |
|
| 18 | 18 | $form = glsr( Builder::class )->form( $partial, [ |
| 19 | 19 | 'class' => 'glsr-form', |
| 20 | 20 | 'id' => $args['id'], |
| 21 | 21 | 'method' => 'post', |
| 22 | - ]); |
|
| 22 | + ] ); |
|
| 23 | 23 | return glsr( Builder::class )->div( $form, [ |
| 24 | 24 | 'class' => 'glsr-form-wrap '.$args['class'], |
| 25 | - ]); |
|
| 25 | + ] ); |
|
| 26 | 26 | } |
| 27 | 27 | } |
@@ -15,11 +15,11 @@ |
||
| 15 | 15 | public function build( $name, array $args = [] ) |
| 16 | 16 | { |
| 17 | 17 | $roundedRating = floor( round( $args['rating'], 1 ) * 2 ) / 2; |
| 18 | - $percentage = glsr( Builder::class )->span([ |
|
| 19 | - 'style' => 'width:'.( $roundedRating / Rating::MAX_RATING * 100 ).'%;', |
|
| 20 | - ]); |
|
| 18 | + $percentage = glsr( Builder::class )->span( [ |
|
| 19 | + 'style' => 'width:'.($roundedRating / Rating::MAX_RATING * 100).'%;', |
|
| 20 | + ] ); |
|
| 21 | 21 | return glsr( Builder::class )->span( $percentage, [ |
| 22 | 22 | 'class' => 'glsr-star-rating', |
| 23 | - ]); |
|
| 23 | + ] ); |
|
| 24 | 24 | } |
| 25 | 25 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | return glsr( Builder::class )->div( $this->buildSummary().$this->buildPercentageBars(), [ |
| 39 | 39 | 'class' => 'glsr-summary-wrap '.$args['class'], |
| 40 | 40 | 'id' => $args['id'], |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -51,20 +51,20 @@ discard block |
||
| 51 | 51 | $build = glsr( Builder::class ); |
| 52 | 52 | $label = $build->span( $this->args['labels'][$index], [ |
| 53 | 53 | 'class' => 'glsr-bar-label', |
| 54 | - ]); |
|
| 55 | - $barBackground = $build->span([ |
|
| 54 | + ] ); |
|
| 55 | + $barBackground = $build->span( [ |
|
| 56 | 56 | 'class' => 'glsr-bar-percent', |
| 57 | 57 | 'style' => 'width:'.$percent, |
| 58 | - ]); |
|
| 58 | + ] ); |
|
| 59 | 59 | $barPercent = $build->span( $barBackground, [ |
| 60 | 60 | 'class' => 'glsr-bar-background', |
| 61 | - ]); |
|
| 61 | + ] ); |
|
| 62 | 62 | $percent = $build->span( $percent, [ |
| 63 | 63 | 'class' => 'glsr-bar-count', |
| 64 | - ]); |
|
| 64 | + ] ); |
|
| 65 | 65 | return $build->div( $label.$barPercent.$percent, [ |
| 66 | 66 | 'class' => 'glsr-percentage-bar', |
| 67 | - ]); |
|
| 67 | + ] ); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -72,15 +72,15 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | protected function buildPercentageBars() |
| 74 | 74 | { |
| 75 | - if( in_array( 'bars', $this->args['hide'] ))return; |
|
| 76 | - $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews->results )); |
|
| 75 | + if( in_array( 'bars', $this->args['hide'] ) )return; |
|
| 76 | + $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews->results ) ); |
|
| 77 | 77 | $range = range( Rating::MAX_RATING, 1 ); |
| 78 | - $bars = array_reduce( $range, function( $carry, $index ) use( $percentages ) { |
|
| 78 | + $bars = array_reduce( $range, function( $carry, $index ) use($percentages) { |
|
| 79 | 79 | return $carry.$this->buildPercentageBar( intval( $index ), $percentages[$index] ); |
| 80 | 80 | }); |
| 81 | 81 | return glsr( Builder::class )->div( $bars, [ |
| 82 | 82 | 'class' => 'glsr-percentage-bars', |
| 83 | - ]); |
|
| 83 | + ] ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | if( !$this->args['schema'] )return; |
| 92 | 92 | $schema = glsr( Schema::class ); |
| 93 | - $schema->store( $schema->buildSummary( $this->args )); |
|
| 93 | + $schema->store( $schema->buildSummary( $this->args ) ); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -99,10 +99,10 @@ discard block |
||
| 99 | 99 | protected function buildSummary() |
| 100 | 100 | { |
| 101 | 101 | $summary = $this->buildSummaryRating().$this->buildSummaryStars().$this->buildSummaryText(); |
| 102 | - if( empty( $summary ))return; |
|
| 102 | + if( empty($summary) )return; |
|
| 103 | 103 | return glsr( Builder::class )->div( $summary, [ |
| 104 | 104 | 'class' => 'glsr-summary', |
| 105 | - ]); |
|
| 105 | + ] ); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | protected function buildSummaryRating() |
| 112 | 112 | { |
| 113 | - if( in_array( 'rating', $this->args['hide'] ))return; |
|
| 113 | + if( in_array( 'rating', $this->args['hide'] ) )return; |
|
| 114 | 114 | return glsr( Builder::class )->span( $this->rating, [ |
| 115 | 115 | 'class' => 'glsr-summary-rating', |
| 116 | - ]); |
|
| 116 | + ] ); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | protected function buildSummaryStars() |
| 123 | 123 | { |
| 124 | - if( in_array( 'stars', $this->args['hide'] ))return; |
|
| 124 | + if( in_array( 'stars', $this->args['hide'] ) )return; |
|
| 125 | 125 | $stars = glsr( Html::class )->buildPartial( 'star-rating', [ |
| 126 | 126 | 'rating' => $this->rating, |
| 127 | - ]); |
|
| 127 | + ] ); |
|
| 128 | 128 | return glsr( Builder::class )->span( $stars, [ |
| 129 | 129 | 'class' => 'glsr-summary-stars', |
| 130 | - ]); |
|
| 130 | + ] ); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | protected function buildSummaryText() |
| 137 | 137 | { |
| 138 | - if( in_array( 'summary', $this->args['hide'] ))return; |
|
| 138 | + if( in_array( 'summary', $this->args['hide'] ) )return; |
|
| 139 | 139 | $count = count( $this->reviews->results ); |
| 140 | - if( empty( $this->args['text'] )) { |
|
| 140 | + if( empty($this->args['text']) ) { |
|
| 141 | 141 | $this->args['text'] = _nx( |
| 142 | 142 | '{rating} out of {max} stars (based on %d review)', |
| 143 | 143 | '{rating} out of {max} stars (based on %d reviews)', |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | ); |
| 148 | 148 | } |
| 149 | 149 | $summary = str_replace( |
| 150 | - ['{rating}','{max}'], [$this->rating, Rating::MAX_RATING], $this->args['text'] |
|
| 150 | + ['{rating}', '{max}'], [$this->rating, Rating::MAX_RATING], $this->args['text'] |
|
| 151 | 151 | ); |
| 152 | - return str_replace( ['%s','%d'], $count, $summary ); |
|
| 152 | + return str_replace( ['%s', '%d'], $count, $summary ); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -157,6 +157,6 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | protected function isHidden() |
| 159 | 159 | { |
| 160 | - return empty( $this->reviews->results ) && in_array( 'if_empty', $this->args['hide'] ); |
|
| 160 | + return empty($this->reviews->results) && in_array( 'if_empty', $this->args['hide'] ); |
|
| 161 | 161 | } |
| 162 | 162 | } |