@@ -25,37 +25,37 @@ discard block |
||
25 | 25 | public $title; |
26 | 26 | public $url; |
27 | 27 | |
28 | - public function __construct($input) |
|
28 | + public function __construct( $input ) |
|
29 | 29 | { |
30 | 30 | $this->request = $input; |
31 | 31 | $this->ajax_request = isset($input['_ajax_request']); |
32 | - $this->assigned_to = $this->getNumeric('assign_to'); |
|
33 | - $this->author = sanitize_text_field($this->getUser('name')); |
|
32 | + $this->assigned_to = $this->getNumeric( 'assign_to' ); |
|
33 | + $this->author = sanitize_text_field( $this->getUser( 'name' ) ); |
|
34 | 34 | $this->avatar = $this->getAvatar(); |
35 | 35 | $this->blacklisted = isset($input['blacklisted']); |
36 | - $this->category = sanitize_key($this->get('category')); |
|
37 | - $this->content = sanitize_textarea_field($this->get('content')); |
|
36 | + $this->category = sanitize_key( $this->get( 'category' ) ); |
|
37 | + $this->content = sanitize_textarea_field( $this->get( 'content' ) ); |
|
38 | 38 | $this->custom = $this->getCustom(); |
39 | - $this->date = $this->getDate('date'); |
|
40 | - $this->email = sanitize_email($this->getUser('email')); |
|
41 | - $this->form_id = sanitize_key($this->get('form_id')); |
|
42 | - $this->ip_address = $this->get('ip_address'); |
|
43 | - $this->post_id = intval($this->get('_post_id')); |
|
44 | - $this->rating = intval($this->get('rating')); |
|
45 | - $this->referer = $this->get('_referer'); |
|
46 | - $this->response = sanitize_textarea_field($this->get('response')); |
|
39 | + $this->date = $this->getDate( 'date' ); |
|
40 | + $this->email = sanitize_email( $this->getUser( 'email' ) ); |
|
41 | + $this->form_id = sanitize_key( $this->get( 'form_id' ) ); |
|
42 | + $this->ip_address = $this->get( 'ip_address' ); |
|
43 | + $this->post_id = intval( $this->get( '_post_id' ) ); |
|
44 | + $this->rating = intval( $this->get( 'rating' ) ); |
|
45 | + $this->referer = $this->get( '_referer' ); |
|
46 | + $this->response = sanitize_textarea_field( $this->get( 'response' ) ); |
|
47 | 47 | $this->terms = !empty($input['terms']); |
48 | - $this->title = sanitize_text_field($this->get('title')); |
|
49 | - $this->url = esc_url_raw($this->get('url')); |
|
48 | + $this->title = sanitize_text_field( $this->get( 'title' ) ); |
|
49 | + $this->url = esc_url_raw( $this->get( 'url' ) ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @param string $key |
54 | 54 | * @return string |
55 | 55 | */ |
56 | - protected function get($key) |
|
56 | + protected function get( $key ) |
|
57 | 57 | { |
58 | - return (string) glsr_get($this->request, $key); |
|
58 | + return (string)glsr_get( $this->request, $key ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function getAvatar() |
65 | 65 | { |
66 | - $avatar = $this->get('avatar'); |
|
67 | - return !filter_var($avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED) |
|
68 | - ? (string) get_avatar_url($this->get('email')) |
|
66 | + $avatar = $this->get( 'avatar' ); |
|
67 | + return !filter_var( $avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED ) |
|
68 | + ? (string)get_avatar_url( $this->get( 'email' ) ) |
|
69 | 69 | : $avatar; |
70 | 70 | } |
71 | 71 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | '_referer', 'assign_to', 'category', 'content', 'date', 'email', 'excluded', 'form_id', |
80 | 80 | 'gotcha', 'ip_address', 'name', 'rating', 'response', 'terms', 'title', 'url', |
81 | 81 | ]; |
82 | - $unset = apply_filters('site-reviews/create/unset-keys-from-custom', $unset); |
|
82 | + $unset = apply_filters( 'site-reviews/create/unset-keys-from-custom', $unset ); |
|
83 | 83 | $custom = $this->request; |
84 | - foreach ($unset as $value) { |
|
84 | + foreach( $unset as $value ) { |
|
85 | 85 | unset($custom[$value]); |
86 | 86 | } |
87 | 87 | return $custom; |
@@ -91,29 +91,29 @@ discard block |
||
91 | 91 | * @param string $key |
92 | 92 | * @return string |
93 | 93 | */ |
94 | - protected function getDate($key) |
|
94 | + protected function getDate( $key ) |
|
95 | 95 | { |
96 | - $date = strtotime($this->get($key)); |
|
97 | - if (false === $date) { |
|
96 | + $date = strtotime( $this->get( $key ) ); |
|
97 | + if( false === $date ) { |
|
98 | 98 | $date = time(); |
99 | 99 | } |
100 | - return get_date_from_gmt(gmdate('Y-m-d H:i:s', $date)); |
|
100 | + return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ) ); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | 104 | * @param string $key |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - protected function getUser($key) |
|
107 | + protected function getUser( $key ) |
|
108 | 108 | { |
109 | - $value = $this->get($key); |
|
110 | - if (empty($value)) { |
|
109 | + $value = $this->get( $key ); |
|
110 | + if( empty($value) ) { |
|
111 | 111 | $user = wp_get_current_user(); |
112 | 112 | $userValues = [ |
113 | 113 | 'email' => 'user_email', |
114 | 114 | 'name' => 'display_name', |
115 | 115 | ]; |
116 | - if ($user->exists() && array_key_exists($key, $userValues)) { |
|
116 | + if( $user->exists() && array_key_exists( $key, $userValues ) ) { |
|
117 | 117 | return $user->{$userValues[$key]}; |
118 | 118 | } |
119 | 119 | } |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | * @param string $key |
125 | 125 | * @return string |
126 | 126 | */ |
127 | - protected function getNumeric($key) |
|
127 | + protected function getNumeric( $key ) |
|
128 | 128 | { |
129 | - $value = $this->get($key); |
|
130 | - return is_numeric($value) |
|
129 | + $value = $this->get( $key ); |
|
130 | + return is_numeric( $value ) |
|
131 | 131 | ? $value |
132 | 132 | : ''; |
133 | 133 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | { |
7 | 7 | public $pointers; |
8 | 8 | |
9 | - public function __construct(array $input) |
|
9 | + public function __construct( array $input ) |
|
10 | 10 | { |
11 | 11 | $this->pointers = $input['pointers']; |
12 | 12 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | public $postType; |
16 | 16 | public $single; |
17 | 17 | |
18 | - public function __construct($input) |
|
18 | + public function __construct( $input ) |
|
19 | 19 | { |
20 | - $args = glsr(PostTypeDefaults::class)->merge($input); |
|
21 | - $this->normalize($args); |
|
20 | + $args = glsr( PostTypeDefaults::class )->merge( $input ); |
|
21 | + $this->normalize( $args ); |
|
22 | 22 | $this->normalizeColumns(); |
23 | 23 | $this->normalizeLabels(); |
24 | 24 | } |
@@ -26,19 +26,19 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @return void |
28 | 28 | */ |
29 | - protected function normalize(array $args) |
|
29 | + protected function normalize( array $args ) |
|
30 | 30 | { |
31 | - foreach ($args as $key => $value) { |
|
32 | - $property = glsr(Helper::class)->buildPropertyName($key); |
|
33 | - if (!property_exists($this, $property)) { |
|
31 | + foreach( $args as $key => $value ) { |
|
32 | + $property = glsr( Helper::class )->buildPropertyName( $key ); |
|
33 | + if( !property_exists( $this, $property ) ) { |
|
34 | 34 | continue; |
35 | 35 | } |
36 | 36 | $this->$property = $value; |
37 | 37 | unset($args[$key]); |
38 | 38 | } |
39 | - $this->args = wp_parse_args($args, [ |
|
39 | + $this->args = wp_parse_args( $args, [ |
|
40 | 40 | 'menu_name' => $this->plural, |
41 | - ]); |
|
41 | + ] ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | */ |
47 | 47 | protected function normalizeLabels() |
48 | 48 | { |
49 | - $this->args['labels'] = wp_parse_args($this->args['labels'], [ |
|
50 | - 'add_new_item' => sprintf(_x('Add New %s', 'Add New Post', 'site-reviews'), $this->plural), |
|
51 | - 'all_items' => sprintf(_x('All %s', 'All Posts', 'site-reviews'), $this->plural), |
|
52 | - 'archives' => sprintf(_x('%s Archives', 'Post Archives', 'site-reviews'), $this->single), |
|
53 | - 'edit_item' => sprintf(_x('Edit %s', 'Edit Post', 'site-reviews'), $this->single), |
|
54 | - 'insert_into_item' => sprintf(_x('Insert into %s', 'Insert into Post', 'site-reviews'), $this->single), |
|
49 | + $this->args['labels'] = wp_parse_args( $this->args['labels'], [ |
|
50 | + 'add_new_item' => sprintf( _x( 'Add New %s', 'Add New Post', 'site-reviews' ), $this->plural ), |
|
51 | + 'all_items' => sprintf( _x( 'All %s', 'All Posts', 'site-reviews' ), $this->plural ), |
|
52 | + 'archives' => sprintf( _x( '%s Archives', 'Post Archives', 'site-reviews' ), $this->single ), |
|
53 | + 'edit_item' => sprintf( _x( 'Edit %s', 'Edit Post', 'site-reviews' ), $this->single ), |
|
54 | + 'insert_into_item' => sprintf( _x( 'Insert into %s', 'Insert into Post', 'site-reviews' ), $this->single ), |
|
55 | 55 | 'menu_name' => $this->args['menu_name'], |
56 | 56 | 'name' => $this->plural, |
57 | - 'new_item' => sprintf(_x('New %s', 'New Post', 'site-reviews'), $this->single), |
|
58 | - 'not_found' => sprintf(_x('No %s found', 'No Posts found', 'site-reviews'), $this->plural), |
|
59 | - 'not_found_in_trash' => sprintf(_x('No %s found in Trash', 'No Posts found in Trash', 'site-reviews'), $this->plural), |
|
60 | - 'search_items' => sprintf(_x('Search %s', 'Search Posts', 'site-reviews'), $this->plural), |
|
57 | + 'new_item' => sprintf( _x( 'New %s', 'New Post', 'site-reviews' ), $this->single ), |
|
58 | + 'not_found' => sprintf( _x( 'No %s found', 'No Posts found', 'site-reviews' ), $this->plural ), |
|
59 | + 'not_found_in_trash' => sprintf( _x( 'No %s found in Trash', 'No Posts found in Trash', 'site-reviews' ), $this->plural ), |
|
60 | + 'search_items' => sprintf( _x( 'Search %s', 'Search Posts', 'site-reviews' ), $this->plural ), |
|
61 | 61 | 'singular_name' => $this->single, |
62 | - 'uploaded_to_this_item' => sprintf(_x('Uploaded to this %s', 'Uploaded to this Post', 'site-reviews'), $this->single), |
|
63 | - 'view_item' => sprintf(_x('View %s', 'View Post', 'site-reviews'), $this->single), |
|
64 | - ]); |
|
62 | + 'uploaded_to_this_item' => sprintf( _x( 'Uploaded to this %s', 'Uploaded to this Post', 'site-reviews' ), $this->single ), |
|
63 | + 'view_item' => sprintf( _x( 'View %s', 'View Post', 'site-reviews' ), $this->single ), |
|
64 | + ] ); |
|
65 | 65 | unset($this->args['menu_name']); |
66 | 66 | } |
67 | 67 | |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | protected function normalizeColumns() |
72 | 72 | { |
73 | 73 | $this->columns = ['cb' => ''] + $this->columns; |
74 | - if (array_key_exists('category', $this->columns)) { |
|
75 | - $keys = array_keys($this->columns); |
|
76 | - $keys[array_search('category', $keys)] = 'taxonomy-'.Application::TAXONOMY; |
|
77 | - $this->columns = array_combine($keys, $this->columns); |
|
74 | + if( array_key_exists( 'category', $this->columns ) ) { |
|
75 | + $keys = array_keys( $this->columns ); |
|
76 | + $keys[array_search( 'category', $keys )] = 'taxonomy-'.Application::TAXONOMY; |
|
77 | + $this->columns = array_combine( $keys, $this->columns ); |
|
78 | 78 | } |
79 | - if (array_key_exists('pinned', $this->columns)) { |
|
80 | - $this->columns['pinned'] = glsr(Builder::class)->span('<span>'.$this->columns['pinned'].'</span>', |
|
79 | + if( array_key_exists( 'pinned', $this->columns ) ) { |
|
80 | + $this->columns['pinned'] = glsr( Builder::class )->span( '<span>'.$this->columns['pinned'].'</span>', |
|
81 | 81 | ['class' => 'pinned-icon'] |
82 | 82 | ); |
83 | 83 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | { |
7 | 7 | public $shortcodes; |
8 | 8 | |
9 | - public function __construct($input) |
|
9 | + public function __construct( $input ) |
|
10 | 10 | { |
11 | 11 | $this->shortcodes = $input; |
12 | 12 | } |
@@ -2,32 +2,32 @@ |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | 'rating' => [ |
5 | - 'label' => __('Your overall rating', 'site-reviews'), |
|
5 | + 'label' => __( 'Your overall rating', 'site-reviews' ), |
|
6 | 6 | 'type' => 'rating', |
7 | 7 | ], |
8 | 8 | 'title' => [ |
9 | - 'label' => __('Title of your review', 'site-reviews'), |
|
10 | - 'placeholder' => __('Summarize your review or highlight an interesting detail', 'site-reviews'), |
|
9 | + 'label' => __( 'Title of your review', 'site-reviews' ), |
|
10 | + 'placeholder' => __( 'Summarize your review or highlight an interesting detail', 'site-reviews' ), |
|
11 | 11 | 'type' => 'text', |
12 | 12 | ], |
13 | 13 | 'content' => [ |
14 | - 'label' => __('Your review', 'site-reviews'), |
|
15 | - 'placeholder' => __('Tell people your review', 'site-reviews'), |
|
14 | + 'label' => __( 'Your review', 'site-reviews' ), |
|
15 | + 'placeholder' => __( 'Tell people your review', 'site-reviews' ), |
|
16 | 16 | 'rows' => 5, |
17 | 17 | 'type' => 'textarea', |
18 | 18 | ], |
19 | 19 | 'name' => [ |
20 | - 'label' => __('Your name', 'site-reviews'), |
|
21 | - 'placeholder' => __('Tell us your name', 'site-reviews'), |
|
20 | + 'label' => __( 'Your name', 'site-reviews' ), |
|
21 | + 'placeholder' => __( 'Tell us your name', 'site-reviews' ), |
|
22 | 22 | 'type' => 'text', |
23 | 23 | ], |
24 | 24 | 'email' => [ |
25 | - 'label' => __('Your email', 'site-reviews'), |
|
26 | - 'placeholder' => __('Tell us your email', 'site-reviews'), |
|
25 | + 'label' => __( 'Your email', 'site-reviews' ), |
|
26 | + 'placeholder' => __( 'Tell us your email', 'site-reviews' ), |
|
27 | 27 | 'type' => 'email', |
28 | 28 | ], |
29 | 29 | 'terms' => [ |
30 | - 'label' => __('This review is based on my own experience and is my genuine opinion.', 'site-reviews'), |
|
30 | + 'label' => __( 'This review is based on my own experience and is my genuine opinion.', 'site-reviews' ), |
|
31 | 31 | 'type' => 'checkbox', |
32 | 32 | ], |
33 | 33 | ]; |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - ':star-empty' => glsr()->url('assets/images/star-empty.svg'), |
|
5 | - ':star-error' => glsr()->url('assets/images/star-error.svg'), |
|
6 | - ':star-full' => glsr()->url('assets/images/star-full.svg'), |
|
7 | - ':star-half' => glsr()->url('assets/images/star-half.svg'), |
|
4 | + ':star-empty' => glsr()->url( 'assets/images/star-empty.svg' ), |
|
5 | + ':star-error' => glsr()->url( 'assets/images/star-error.svg' ), |
|
6 | + ':star-full' => glsr()->url( 'assets/images/star-full.svg' ), |
|
7 | + ':star-half' => glsr()->url( 'assets/images/star-half.svg' ), |
|
8 | 8 | ]; |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <tr class="glsr-field {{ class }}"> |
4 | 4 | <th scope="row">{{ label }}</th> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <button type="submit" class="glsr-button btn btn-primary"> |
4 | 4 | <span class="glsr-button-loading"></span> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-field form-group {{ class }}"> |
4 | 4 | {{ label }} |