Passed
Push — master ( 078281...45cbff )
by Paul
03:42
created
plugin/Modules/Html/Partials/Pagination.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -10,55 +10,55 @@
 block discarded – undo
10 10
 
11 11
 class Pagination implements PartialContract
12 12
 {
13
-    /**
14
-     * @var array
15
-     */
16
-    protected $args;
13
+	/**
14
+	 * @var array
15
+	 */
16
+	protected $args;
17 17
 
18
-    /**
19
-     * @return void|string
20
-     */
21
-    public function build(array $args = [])
22
-    {
23
-        $this->args = $this->normalize($args);
24
-        if ($this->args['total'] < 2) {
25
-            return;
26
-        }
27
-        return glsr(Template::class)->build('templates/pagination', [
28
-            'context' => [
29
-                'links' => apply_filters('site-reviews/paginate_links', $this->buildLinks(), $this->args),
30
-                'loader' => '<div class="glsr-loader"></div>',
31
-                'screen_reader_text' => __('Site Reviews navigation', 'site-reviews'),
32
-            ],
33
-        ]);
34
-    }
18
+	/**
19
+	 * @return void|string
20
+	 */
21
+	public function build(array $args = [])
22
+	{
23
+		$this->args = $this->normalize($args);
24
+		if ($this->args['total'] < 2) {
25
+			return;
26
+		}
27
+		return glsr(Template::class)->build('templates/pagination', [
28
+			'context' => [
29
+				'links' => apply_filters('site-reviews/paginate_links', $this->buildLinks(), $this->args),
30
+				'loader' => '<div class="glsr-loader"></div>',
31
+				'screen_reader_text' => __('Site Reviews navigation', 'site-reviews'),
32
+			],
33
+		]);
34
+	}
35 35
 
36
-    /**
37
-     * @return string
38
-     */
39
-    protected function buildLinks()
40
-    {
41
-        $args = glsr(Style::class)->paginationArgs($this->args);
42
-        if (is_front_page()) {
43
-            unset($args['format']);
44
-        }
45
-        if ('array' == $args['type']) {
46
-            $args['type'] = 'plain';
47
-        }
48
-        return paginate_links($args);
49
-    }
36
+	/**
37
+	 * @return string
38
+	 */
39
+	protected function buildLinks()
40
+	{
41
+		$args = glsr(Style::class)->paginationArgs($this->args);
42
+		if (is_front_page()) {
43
+			unset($args['format']);
44
+		}
45
+		if ('array' == $args['type']) {
46
+			$args['type'] = 'plain';
47
+		}
48
+		return paginate_links($args);
49
+	}
50 50
 
51
-    /**
52
-     * @return array
53
-     */
54
-    protected function normalize(array $args)
55
-    {
56
-        if ($baseUrl = Arr::get($args, 'baseUrl')) {
57
-            $args['base'] = $baseUrl.'%_%';
58
-        }
59
-        return wp_parse_args(array_filter($args), [
60
-            'current' => glsr(QueryBuilder::class)->getPaged(),
61
-            'total' => 1,
62
-        ]);
63
-    }
51
+	/**
52
+	 * @return array
53
+	 */
54
+	protected function normalize(array $args)
55
+	{
56
+		if ($baseUrl = Arr::get($args, 'baseUrl')) {
57
+			$args['base'] = $baseUrl.'%_%';
58
+		}
59
+		return wp_parse_args(array_filter($args), [
60
+			'current' => glsr(QueryBuilder::class)->getPaged(),
61
+			'total' => 1,
62
+		]);
63
+	}
64 64
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -18,19 +18,19 @@  discard block
 block discarded – undo
18 18
     /**
19 19
      * @return void|string
20 20
      */
21
-    public function build(array $args = [])
21
+    public function build( array $args = [] )
22 22
     {
23
-        $this->args = $this->normalize($args);
24
-        if ($this->args['total'] < 2) {
23
+        $this->args = $this->normalize( $args );
24
+        if( $this->args['total'] < 2 ) {
25 25
             return;
26 26
         }
27
-        return glsr(Template::class)->build('templates/pagination', [
27
+        return glsr( Template::class )->build( 'templates/pagination', [
28 28
             'context' => [
29
-                'links' => apply_filters('site-reviews/paginate_links', $this->buildLinks(), $this->args),
29
+                'links' => apply_filters( 'site-reviews/paginate_links', $this->buildLinks(), $this->args ),
30 30
                 'loader' => '<div class="glsr-loader"></div>',
31
-                'screen_reader_text' => __('Site Reviews navigation', 'site-reviews'),
31
+                'screen_reader_text' => __( 'Site Reviews navigation', 'site-reviews' ),
32 32
             ],
33
-        ]);
33
+        ] );
34 34
     }
35 35
 
36 36
     /**
@@ -38,27 +38,27 @@  discard block
 block discarded – undo
38 38
      */
39 39
     protected function buildLinks()
40 40
     {
41
-        $args = glsr(Style::class)->paginationArgs($this->args);
42
-        if (is_front_page()) {
41
+        $args = glsr( Style::class )->paginationArgs( $this->args );
42
+        if( is_front_page() ) {
43 43
             unset($args['format']);
44 44
         }
45
-        if ('array' == $args['type']) {
45
+        if( 'array' == $args['type'] ) {
46 46
             $args['type'] = 'plain';
47 47
         }
48
-        return paginate_links($args);
48
+        return paginate_links( $args );
49 49
     }
50 50
 
51 51
     /**
52 52
      * @return array
53 53
      */
54
-    protected function normalize(array $args)
54
+    protected function normalize( array $args )
55 55
     {
56
-        if ($baseUrl = Arr::get($args, 'baseUrl')) {
56
+        if( $baseUrl = Arr::get( $args, 'baseUrl' ) ) {
57 57
             $args['base'] = $baseUrl.'%_%';
58 58
         }
59
-        return wp_parse_args(array_filter($args), [
60
-            'current' => glsr(QueryBuilder::class)->getPaged(),
59
+        return wp_parse_args( array_filter( $args ), [
60
+            'current' => glsr( QueryBuilder::class )->getPaged(),
61 61
             'total' => 1,
62
-        ]);
62
+        ] );
63 63
     }
64 64
 }
Please login to merge, or discard this patch.
plugin/Modules/Upgrader/Upgrade_3_0_0.php 2 patches
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -8,160 +8,160 @@
 block discarded – undo
8 8
 
9 9
 class Upgrade_3_0_0
10 10
 {
11
-    const MAPPED_SETTINGS = [
12
-        'settings.general.notification' => 'settings.general.notifications', // array
13
-        'settings.general.notification_email' => 'settings.general.notification_email',
14
-        'settings.general.notification_message' => 'settings.general.notification_message',
15
-        'settings.general.require.approval' => 'settings.general.require.approval',
16
-        'settings.general.require.login' => 'settings.general.require.login',
17
-        'settings.general.require.login_register' => 'settings.general.require.login_register',
18
-        'settings.general.webhook_url' => 'settings.general.notification_slack',
19
-        'settings.reviews-form.akismet' => 'settings.submissions.akismet',
20
-        'settings.reviews-form.blacklist.action' => 'settings.submissions.blacklist.action',
21
-        'settings.reviews-form.blacklist.entries' => 'settings.submissions.blacklist.entries',
22
-        'settings.reviews-form.recaptcha.integration' => 'settings.submissions.recaptcha.integration',
23
-        'settings.reviews-form.recaptcha.key' => 'settings.submissions.recaptcha.key',
24
-        'settings.reviews-form.recaptcha.position' => 'settings.submissions.recaptcha.position',
25
-        'settings.reviews-form.recaptcha.secret' => 'settings.submissions.recaptcha.secret',
26
-        'settings.reviews-form.required' => 'settings.submissions.required', // array
27
-        'settings.reviews.assigned_links.enabled' => 'settings.reviews.assigned_links',
28
-        'settings.reviews.avatars.enabled' => 'settings.reviews.avatars',
29
-        'settings.reviews.date.custom' => 'settings.reviews.date.custom',
30
-        'settings.reviews.date.format' => 'settings.reviews.date.format',
31
-        'settings.reviews.excerpt.enabled' => 'settings.reviews.excerpts',
32
-        'settings.reviews.excerpt.length' => 'settings.reviews.excerpts_length',
33
-        'settings.reviews.schema.address' => 'settings.schema.address',
34
-        'settings.reviews.schema.description.custom' => 'settings.schema.description.custom',
35
-        'settings.reviews.schema.description.default' => 'settings.schema.description.default',
36
-        'settings.reviews.schema.highprice' => 'settings.schema.highprice',
37
-        'settings.reviews.schema.image.custom' => 'settings.schema.image.custom',
38
-        'settings.reviews.schema.image.default' => 'settings.schema.image.default',
39
-        'settings.reviews.schema.lowprice' => 'settings.schema.lowprice',
40
-        'settings.reviews.schema.name.custom' => 'settings.schema.name.custom',
41
-        'settings.reviews.schema.name.default' => 'settings.schema.name.default',
42
-        'settings.reviews.schema.pricecurrency' => 'settings.schema.pricecurrency',
43
-        'settings.reviews.schema.pricerange' => 'settings.schema.pricerange',
44
-        'settings.reviews.schema.telephone' => 'settings.schema.telephone',
45
-        'settings.reviews.schema.type.custom' => 'settings.schema.type.custom',
46
-        'settings.reviews.schema.type.default' => 'settings.schema.type.default',
47
-        'settings.reviews.schema.url.custom' => 'settings.schema.url.custom',
48
-        'settings.reviews.schema.url.default' => 'settings.schema.url.default',
49
-        'version' => 'version_upgraded_from',
50
-    ];
11
+	const MAPPED_SETTINGS = [
12
+		'settings.general.notification' => 'settings.general.notifications', // array
13
+		'settings.general.notification_email' => 'settings.general.notification_email',
14
+		'settings.general.notification_message' => 'settings.general.notification_message',
15
+		'settings.general.require.approval' => 'settings.general.require.approval',
16
+		'settings.general.require.login' => 'settings.general.require.login',
17
+		'settings.general.require.login_register' => 'settings.general.require.login_register',
18
+		'settings.general.webhook_url' => 'settings.general.notification_slack',
19
+		'settings.reviews-form.akismet' => 'settings.submissions.akismet',
20
+		'settings.reviews-form.blacklist.action' => 'settings.submissions.blacklist.action',
21
+		'settings.reviews-form.blacklist.entries' => 'settings.submissions.blacklist.entries',
22
+		'settings.reviews-form.recaptcha.integration' => 'settings.submissions.recaptcha.integration',
23
+		'settings.reviews-form.recaptcha.key' => 'settings.submissions.recaptcha.key',
24
+		'settings.reviews-form.recaptcha.position' => 'settings.submissions.recaptcha.position',
25
+		'settings.reviews-form.recaptcha.secret' => 'settings.submissions.recaptcha.secret',
26
+		'settings.reviews-form.required' => 'settings.submissions.required', // array
27
+		'settings.reviews.assigned_links.enabled' => 'settings.reviews.assigned_links',
28
+		'settings.reviews.avatars.enabled' => 'settings.reviews.avatars',
29
+		'settings.reviews.date.custom' => 'settings.reviews.date.custom',
30
+		'settings.reviews.date.format' => 'settings.reviews.date.format',
31
+		'settings.reviews.excerpt.enabled' => 'settings.reviews.excerpts',
32
+		'settings.reviews.excerpt.length' => 'settings.reviews.excerpts_length',
33
+		'settings.reviews.schema.address' => 'settings.schema.address',
34
+		'settings.reviews.schema.description.custom' => 'settings.schema.description.custom',
35
+		'settings.reviews.schema.description.default' => 'settings.schema.description.default',
36
+		'settings.reviews.schema.highprice' => 'settings.schema.highprice',
37
+		'settings.reviews.schema.image.custom' => 'settings.schema.image.custom',
38
+		'settings.reviews.schema.image.default' => 'settings.schema.image.default',
39
+		'settings.reviews.schema.lowprice' => 'settings.schema.lowprice',
40
+		'settings.reviews.schema.name.custom' => 'settings.schema.name.custom',
41
+		'settings.reviews.schema.name.default' => 'settings.schema.name.default',
42
+		'settings.reviews.schema.pricecurrency' => 'settings.schema.pricecurrency',
43
+		'settings.reviews.schema.pricerange' => 'settings.schema.pricerange',
44
+		'settings.reviews.schema.telephone' => 'settings.schema.telephone',
45
+		'settings.reviews.schema.type.custom' => 'settings.schema.type.custom',
46
+		'settings.reviews.schema.type.default' => 'settings.schema.type.default',
47
+		'settings.reviews.schema.url.custom' => 'settings.schema.url.custom',
48
+		'settings.reviews.schema.url.default' => 'settings.schema.url.default',
49
+		'version' => 'version_upgraded_from',
50
+	];
51 51
 
52
-    /**
53
-     * @var array
54
-     */
55
-    protected $newSettings;
52
+	/**
53
+	 * @var array
54
+	 */
55
+	protected $newSettings;
56 56
 
57
-    /**
58
-     * @var array
59
-     */
60
-    protected $oldSettings;
57
+	/**
58
+	 * @var array
59
+	 */
60
+	protected $oldSettings;
61 61
 
62
-    public function __construct()
63
-    {
64
-        $this->migrateSettings();
65
-    }
62
+	public function __construct()
63
+	{
64
+		$this->migrateSettings();
65
+	}
66 66
 
67
-    /**
68
-     * @return void
69
-     */
70
-    public function migrateSettings()
71
-    {
72
-        $this->newSettings = $this->getNewSettings();
73
-        $this->oldSettings = $this->getOldSettings();
74
-        if (empty($this->oldSettings)) {
75
-            return;
76
-        }
77
-        foreach (static::MAPPED_SETTINGS as $old => $new) {
78
-            if (empty($this->oldSettings[$old])) {
79
-                continue;
80
-            }
81
-            $this->newSettings[$new] = $this->oldSettings[$old];
82
-        }
83
-        $this->migrateNotificationSettings();
84
-        $this->migrateRecaptchaSettings();
85
-        $this->migrateRequiredSettings();
86
-        $oldSettings = Arr::convertDotNotationArray($this->oldSettings);
87
-        $newSettings = Arr::convertDotNotationArray($this->newSettings);
88
-        if (isset($oldSettings['settings']['strings']) && is_array($oldSettings['settings']['strings'])) {
89
-            $newSettings['settings']['strings'] = $oldSettings['settings']['strings'];
90
-        }
91
-        glsr(OptionManager::class)->set($newSettings);
92
-    }
67
+	/**
68
+	 * @return void
69
+	 */
70
+	public function migrateSettings()
71
+	{
72
+		$this->newSettings = $this->getNewSettings();
73
+		$this->oldSettings = $this->getOldSettings();
74
+		if (empty($this->oldSettings)) {
75
+			return;
76
+		}
77
+		foreach (static::MAPPED_SETTINGS as $old => $new) {
78
+			if (empty($this->oldSettings[$old])) {
79
+				continue;
80
+			}
81
+			$this->newSettings[$new] = $this->oldSettings[$old];
82
+		}
83
+		$this->migrateNotificationSettings();
84
+		$this->migrateRecaptchaSettings();
85
+		$this->migrateRequiredSettings();
86
+		$oldSettings = Arr::convertDotNotationArray($this->oldSettings);
87
+		$newSettings = Arr::convertDotNotationArray($this->newSettings);
88
+		if (isset($oldSettings['settings']['strings']) && is_array($oldSettings['settings']['strings'])) {
89
+			$newSettings['settings']['strings'] = $oldSettings['settings']['strings'];
90
+		}
91
+		glsr(OptionManager::class)->set($newSettings);
92
+	}
93 93
 
94
-    /**
95
-     * @return array
96
-     */
97
-    protected function getNewSettings()
98
-    {
99
-        return wp_parse_args(
100
-            Arr::flattenArray(glsr(OptionManager::class)->all()),
101
-            glsr(DefaultsManager::class)->defaults()
102
-        );
103
-    }
94
+	/**
95
+	 * @return array
96
+	 */
97
+	protected function getNewSettings()
98
+	{
99
+		return wp_parse_args(
100
+			Arr::flattenArray(glsr(OptionManager::class)->all()),
101
+			glsr(DefaultsManager::class)->defaults()
102
+		);
103
+	}
104 104
 
105
-    /**
106
-     * @return array
107
-     */
108
-    protected function getOldSettings()
109
-    {
110
-        $defaults = array_fill_keys(array_keys(static::MAPPED_SETTINGS), '');
111
-        $settings = Arr::flattenArray((array) get_option('geminilabs_site_reviews-v2', []));
112
-        if (!empty($settings)) {
113
-            $settings = wp_parse_args($settings, $defaults);
114
-        }
115
-        return $settings;
116
-    }
105
+	/**
106
+	 * @return array
107
+	 */
108
+	protected function getOldSettings()
109
+	{
110
+		$defaults = array_fill_keys(array_keys(static::MAPPED_SETTINGS), '');
111
+		$settings = Arr::flattenArray((array) get_option('geminilabs_site_reviews-v2', []));
112
+		if (!empty($settings)) {
113
+			$settings = wp_parse_args($settings, $defaults);
114
+		}
115
+		return $settings;
116
+	}
117 117
 
118
-    /**
119
-     * @return void
120
-     */
121
-    protected function migrateNotificationSettings()
122
-    {
123
-        $notifications = [
124
-            'custom' => 'custom',
125
-            'default' => 'admin',
126
-            'webhook' => 'slack',
127
-        ];
128
-        $this->newSettings['settings.general.notifications'] = [];
129
-        foreach ($notifications as $old => $new) {
130
-            if ($this->oldSettings['settings.general.notification'] != $old) {
131
-                continue;
132
-            }
133
-            $this->newSettings['settings.general.notifications'][] = $new;
134
-        }
135
-    }
118
+	/**
119
+	 * @return void
120
+	 */
121
+	protected function migrateNotificationSettings()
122
+	{
123
+		$notifications = [
124
+			'custom' => 'custom',
125
+			'default' => 'admin',
126
+			'webhook' => 'slack',
127
+		];
128
+		$this->newSettings['settings.general.notifications'] = [];
129
+		foreach ($notifications as $old => $new) {
130
+			if ($this->oldSettings['settings.general.notification'] != $old) {
131
+				continue;
132
+			}
133
+			$this->newSettings['settings.general.notifications'][] = $new;
134
+		}
135
+	}
136 136
 
137
-    /**
138
-     * @return void
139
-     */
140
-    protected function migrateRecaptchaSettings()
141
-    {
142
-        $recaptcha = [
143
-            'BadgePosition' => $this->oldSettings['settings.reviews-form.recaptcha.position'],
144
-            'SecretKey' => $this->oldSettings['settings.reviews-form.recaptcha.secret'],
145
-            'SiteKey' => $this->oldSettings['settings.reviews-form.recaptcha.key'],
146
-        ];
147
-        if (in_array($this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'])) {
148
-            $this->newSettings['settings.submissions.recaptcha.integration'] = 'all';
149
-        }
150
-        if ('invisible-recaptcha' == $this->oldSettings['settings.reviews-form.recaptcha.integration']) {
151
-            $recaptcha = wp_parse_args((array) get_site_option('ic-settings', [], false), $recaptcha);
152
-        }
153
-        $this->newSettings['settings.submissions.recaptcha.key'] = $recaptcha['SiteKey'];
154
-        $this->newSettings['settings.submissions.recaptcha.secret'] = $recaptcha['SecretKey'];
155
-        $this->newSettings['settings.submissions.recaptcha.position'] = $recaptcha['BadgePosition'];
156
-    }
137
+	/**
138
+	 * @return void
139
+	 */
140
+	protected function migrateRecaptchaSettings()
141
+	{
142
+		$recaptcha = [
143
+			'BadgePosition' => $this->oldSettings['settings.reviews-form.recaptcha.position'],
144
+			'SecretKey' => $this->oldSettings['settings.reviews-form.recaptcha.secret'],
145
+			'SiteKey' => $this->oldSettings['settings.reviews-form.recaptcha.key'],
146
+		];
147
+		if (in_array($this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'])) {
148
+			$this->newSettings['settings.submissions.recaptcha.integration'] = 'all';
149
+		}
150
+		if ('invisible-recaptcha' == $this->oldSettings['settings.reviews-form.recaptcha.integration']) {
151
+			$recaptcha = wp_parse_args((array) get_site_option('ic-settings', [], false), $recaptcha);
152
+		}
153
+		$this->newSettings['settings.submissions.recaptcha.key'] = $recaptcha['SiteKey'];
154
+		$this->newSettings['settings.submissions.recaptcha.secret'] = $recaptcha['SecretKey'];
155
+		$this->newSettings['settings.submissions.recaptcha.position'] = $recaptcha['BadgePosition'];
156
+	}
157 157
 
158
-    /**
159
-     * @return void
160
-     */
161
-    protected function migrateRequiredSettings()
162
-    {
163
-        $this->newSettings['settings.submissions.required'] = array_filter((array) $this->oldSettings['settings.reviews-form.required']);
164
-        $this->newSettings['settings.submissions.required'][] = 'rating';
165
-        $this->newSettings['settings.submissions.required'][] = 'terms';
166
-    }
158
+	/**
159
+	 * @return void
160
+	 */
161
+	protected function migrateRequiredSettings()
162
+	{
163
+		$this->newSettings['settings.submissions.required'] = array_filter((array) $this->oldSettings['settings.reviews-form.required']);
164
+		$this->newSettings['settings.submissions.required'][] = 'rating';
165
+		$this->newSettings['settings.submissions.required'][] = 'terms';
166
+	}
167 167
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
     {
72 72
         $this->newSettings = $this->getNewSettings();
73 73
         $this->oldSettings = $this->getOldSettings();
74
-        if (empty($this->oldSettings)) {
74
+        if( empty($this->oldSettings) ) {
75 75
             return;
76 76
         }
77
-        foreach (static::MAPPED_SETTINGS as $old => $new) {
78
-            if (empty($this->oldSettings[$old])) {
77
+        foreach( static::MAPPED_SETTINGS as $old => $new ) {
78
+            if( empty($this->oldSettings[$old]) ) {
79 79
                 continue;
80 80
             }
81 81
             $this->newSettings[$new] = $this->oldSettings[$old];
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
         $this->migrateNotificationSettings();
84 84
         $this->migrateRecaptchaSettings();
85 85
         $this->migrateRequiredSettings();
86
-        $oldSettings = Arr::convertDotNotationArray($this->oldSettings);
87
-        $newSettings = Arr::convertDotNotationArray($this->newSettings);
88
-        if (isset($oldSettings['settings']['strings']) && is_array($oldSettings['settings']['strings'])) {
86
+        $oldSettings = Arr::convertDotNotationArray( $this->oldSettings );
87
+        $newSettings = Arr::convertDotNotationArray( $this->newSettings );
88
+        if( isset($oldSettings['settings']['strings']) && is_array( $oldSettings['settings']['strings'] ) ) {
89 89
             $newSettings['settings']['strings'] = $oldSettings['settings']['strings'];
90 90
         }
91
-        glsr(OptionManager::class)->set($newSettings);
91
+        glsr( OptionManager::class )->set( $newSettings );
92 92
     }
93 93
 
94 94
     /**
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
     protected function getNewSettings()
98 98
     {
99 99
         return wp_parse_args(
100
-            Arr::flattenArray(glsr(OptionManager::class)->all()),
101
-            glsr(DefaultsManager::class)->defaults()
100
+            Arr::flattenArray( glsr( OptionManager::class )->all() ),
101
+            glsr( DefaultsManager::class )->defaults()
102 102
         );
103 103
     }
104 104
 
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
      */
108 108
     protected function getOldSettings()
109 109
     {
110
-        $defaults = array_fill_keys(array_keys(static::MAPPED_SETTINGS), '');
111
-        $settings = Arr::flattenArray((array) get_option('geminilabs_site_reviews-v2', []));
112
-        if (!empty($settings)) {
113
-            $settings = wp_parse_args($settings, $defaults);
110
+        $defaults = array_fill_keys( array_keys( static::MAPPED_SETTINGS ), '' );
111
+        $settings = Arr::flattenArray( (array)get_option( 'geminilabs_site_reviews-v2', [] ) );
112
+        if( !empty($settings) ) {
113
+            $settings = wp_parse_args( $settings, $defaults );
114 114
         }
115 115
         return $settings;
116 116
     }
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
             'webhook' => 'slack',
127 127
         ];
128 128
         $this->newSettings['settings.general.notifications'] = [];
129
-        foreach ($notifications as $old => $new) {
130
-            if ($this->oldSettings['settings.general.notification'] != $old) {
129
+        foreach( $notifications as $old => $new ) {
130
+            if( $this->oldSettings['settings.general.notification'] != $old ) {
131 131
                 continue;
132 132
             }
133 133
             $this->newSettings['settings.general.notifications'][] = $new;
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
             'SecretKey' => $this->oldSettings['settings.reviews-form.recaptcha.secret'],
145 145
             'SiteKey' => $this->oldSettings['settings.reviews-form.recaptcha.key'],
146 146
         ];
147
-        if (in_array($this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'])) {
147
+        if( in_array( $this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'] ) ) {
148 148
             $this->newSettings['settings.submissions.recaptcha.integration'] = 'all';
149 149
         }
150
-        if ('invisible-recaptcha' == $this->oldSettings['settings.reviews-form.recaptcha.integration']) {
151
-            $recaptcha = wp_parse_args((array) get_site_option('ic-settings', [], false), $recaptcha);
150
+        if( 'invisible-recaptcha' == $this->oldSettings['settings.reviews-form.recaptcha.integration'] ) {
151
+            $recaptcha = wp_parse_args( (array)get_site_option( 'ic-settings', [], false ), $recaptcha );
152 152
         }
153 153
         $this->newSettings['settings.submissions.recaptcha.key'] = $recaptcha['SiteKey'];
154 154
         $this->newSettings['settings.submissions.recaptcha.secret'] = $recaptcha['SecretKey'];
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     protected function migrateRequiredSettings()
162 162
     {
163
-        $this->newSettings['settings.submissions.required'] = array_filter((array) $this->oldSettings['settings.reviews-form.required']);
163
+        $this->newSettings['settings.submissions.required'] = array_filter( (array)$this->oldSettings['settings.reviews-form.required'] );
164 164
         $this->newSettings['settings.submissions.required'][] = 'rating';
165 165
         $this->newSettings['settings.submissions.required'][] = 'terms';
166 166
     }
Please login to merge, or discard this patch.
plugin/Modules/Style.php 2 patches
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -12,144 +12,144 @@
 block discarded – undo
12 12
 
13 13
 class Style
14 14
 {
15
-    /**
16
-     * @var array
17
-     */
18
-    public $fields;
15
+	/**
16
+	 * @var array
17
+	 */
18
+	public $fields;
19 19
 
20
-    /**
21
-     * @var string
22
-     */
23
-    public $style;
20
+	/**
21
+	 * @var string
22
+	 */
23
+	public $style;
24 24
 
25
-    /**
26
-     * @var array
27
-     */
28
-    public $pagination;
25
+	/**
26
+	 * @var array
27
+	 */
28
+	public $pagination;
29 29
 
30
-    /**
31
-     * @var array
32
-     */
33
-    public $validation;
30
+	/**
31
+	 * @var array
32
+	 */
33
+	public $validation;
34 34
 
35
-    public function __construct()
36
-    {
37
-        $this->style = glsr(OptionManager::class)->get('settings.general.style', 'default');
38
-        $this->setConfig();
39
-    }
35
+	public function __construct()
36
+	{
37
+		$this->style = glsr(OptionManager::class)->get('settings.general.style', 'default');
38
+		$this->setConfig();
39
+	}
40 40
 
41
-    /**
42
-     * @param string $view
43
-     * @return string
44
-     */
45
-    public function filterView($view)
46
-    {
47
-        $styledViews = [
48
-            'templates/form/field',
49
-            'templates/form/response',
50
-            'templates/form/submit-button',
51
-            'templates/reviews-form',
52
-        ];
53
-        if (!preg_match('('.implode('|', $styledViews).')', $view)) {
54
-            return $view;
55
-        }
56
-        $views = $this->generatePossibleViews($view);
57
-        foreach ($views as $possibleView) {
58
-            if (!file_exists(glsr()->file($possibleView))) {
59
-                continue;
60
-            }
61
-            return Str::removePrefix('views/', $possibleView);
62
-        }
63
-        return $view;
64
-    }
41
+	/**
42
+	 * @param string $view
43
+	 * @return string
44
+	 */
45
+	public function filterView($view)
46
+	{
47
+		$styledViews = [
48
+			'templates/form/field',
49
+			'templates/form/response',
50
+			'templates/form/submit-button',
51
+			'templates/reviews-form',
52
+		];
53
+		if (!preg_match('('.implode('|', $styledViews).')', $view)) {
54
+			return $view;
55
+		}
56
+		$views = $this->generatePossibleViews($view);
57
+		foreach ($views as $possibleView) {
58
+			if (!file_exists(glsr()->file($possibleView))) {
59
+				continue;
60
+			}
61
+			return Str::removePrefix('views/', $possibleView);
62
+		}
63
+		return $view;
64
+	}
65 65
 
66
-    /**
67
-     * @return string
68
-     */
69
-    public function get()
70
-    {
71
-        return apply_filters('site-reviews/style', $this->style);
72
-    }
66
+	/**
67
+	 * @return string
68
+	 */
69
+	public function get()
70
+	{
71
+		return apply_filters('site-reviews/style', $this->style);
72
+	}
73 73
 
74
-    /**
75
-     * @return array
76
-     */
77
-    public function setConfig()
78
-    {
79
-        $config = shortcode_atts(
80
-            array_fill_keys(['fields', 'pagination', 'validation'], []),
81
-            glsr()->config('styles/'.$this->style)
82
-        );
83
-        $this->fields = glsr(StyleFieldsDefaults::class)->restrict($config['fields']);
84
-        $this->pagination = glsr(PaginationDefaults::class)->restrict($config['pagination']);
85
-        $this->validation = glsr(StyleValidationDefaults::class)->restrict($config['validation']);
86
-    }
74
+	/**
75
+	 * @return array
76
+	 */
77
+	public function setConfig()
78
+	{
79
+		$config = shortcode_atts(
80
+			array_fill_keys(['fields', 'pagination', 'validation'], []),
81
+			glsr()->config('styles/'.$this->style)
82
+		);
83
+		$this->fields = glsr(StyleFieldsDefaults::class)->restrict($config['fields']);
84
+		$this->pagination = glsr(PaginationDefaults::class)->restrict($config['pagination']);
85
+		$this->validation = glsr(StyleValidationDefaults::class)->restrict($config['validation']);
86
+	}
87 87
 
88
-    /**
89
-     * @return void
90
-     */
91
-    public function modifyField(Builder $instance)
92
-    {
93
-        if (!$this->isPublicInstance($instance) || empty(array_filter($this->fields))) {
94
-            return;
95
-        }
96
-        call_user_func_array([$this, 'customize'], [$instance]);
97
-    }
88
+	/**
89
+	 * @return void
90
+	 */
91
+	public function modifyField(Builder $instance)
92
+	{
93
+		if (!$this->isPublicInstance($instance) || empty(array_filter($this->fields))) {
94
+			return;
95
+		}
96
+		call_user_func_array([$this, 'customize'], [$instance]);
97
+	}
98 98
 
99
-    /**
100
-     * @return array
101
-     */
102
-    public function paginationArgs(array $args)
103
-    {
104
-        return wp_parse_args($args, $this->pagination);
105
-    }
99
+	/**
100
+	 * @return array
101
+	 */
102
+	public function paginationArgs(array $args)
103
+	{
104
+		return wp_parse_args($args, $this->pagination);
105
+	}
106 106
 
107
-    /**
108
-     * @return void
109
-     */
110
-    protected function customize(Builder $instance)
111
-    {
112
-        if (!array_key_exists($instance->tag, $this->fields)) {
113
-            return;
114
-        }
115
-        $args = wp_parse_args($instance->args, array_fill_keys(['class', 'type'], ''));
116
-        $key = $instance->tag.'_'.$args['type'];
117
-        $classes = Arr::get($this->fields, $key, Arr::get($this->fields, $instance->tag));
118
-        $instance->args['class'] = trim($args['class'].' '.$classes);
119
-        do_action_ref_array('site-reviews/customize/'.$this->style, [$instance]);
120
-    }
107
+	/**
108
+	 * @return void
109
+	 */
110
+	protected function customize(Builder $instance)
111
+	{
112
+		if (!array_key_exists($instance->tag, $this->fields)) {
113
+			return;
114
+		}
115
+		$args = wp_parse_args($instance->args, array_fill_keys(['class', 'type'], ''));
116
+		$key = $instance->tag.'_'.$args['type'];
117
+		$classes = Arr::get($this->fields, $key, Arr::get($this->fields, $instance->tag));
118
+		$instance->args['class'] = trim($args['class'].' '.$classes);
119
+		do_action_ref_array('site-reviews/customize/'.$this->style, [$instance]);
120
+	}
121 121
 
122
-    /**
123
-     * @param string $view
124
-     * @return array
125
-     */
126
-    protected function generatePossibleViews($view)
127
-    {
128
-        $basename = basename($view);
129
-        $basepath = rtrim($view, $basename);
130
-        $customPath = 'views/partials/styles/'.$this->style.'/';
131
-        $parts = explode('_', $basename);
132
-        $views = [
133
-            $customPath.$basename,
134
-            $customPath.$parts[0],
135
-            $view,
136
-            $basepath.$parts[0],
137
-        ];
138
-        return array_filter($views);
139
-    }
122
+	/**
123
+	 * @param string $view
124
+	 * @return array
125
+	 */
126
+	protected function generatePossibleViews($view)
127
+	{
128
+		$basename = basename($view);
129
+		$basepath = rtrim($view, $basename);
130
+		$customPath = 'views/partials/styles/'.$this->style.'/';
131
+		$parts = explode('_', $basename);
132
+		$views = [
133
+			$customPath.$basename,
134
+			$customPath.$parts[0],
135
+			$view,
136
+			$basepath.$parts[0],
137
+		];
138
+		return array_filter($views);
139
+	}
140 140
 
141
-    /**
142
-     * @return bool
143
-     */
144
-    protected function isPublicInstance(Builder $instance)
145
-    {
146
-        $args = wp_parse_args($instance->args, [
147
-            'is_public' => false,
148
-            'is_raw' => false,
149
-        ]);
150
-        if (is_admin() || !$args['is_public'] || $args['is_raw']) {
151
-            return false;
152
-        }
153
-        return true;
154
-    }
141
+	/**
142
+	 * @return bool
143
+	 */
144
+	protected function isPublicInstance(Builder $instance)
145
+	{
146
+		$args = wp_parse_args($instance->args, [
147
+			'is_public' => false,
148
+			'is_raw' => false,
149
+		]);
150
+		if (is_admin() || !$args['is_public'] || $args['is_raw']) {
151
+			return false;
152
+		}
153
+		return true;
154
+	}
155 155
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
     public function __construct()
36 36
     {
37
-        $this->style = glsr(OptionManager::class)->get('settings.general.style', 'default');
37
+        $this->style = glsr( OptionManager::class )->get( 'settings.general.style', 'default' );
38 38
         $this->setConfig();
39 39
     }
40 40
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      * @param string $view
43 43
      * @return string
44 44
      */
45
-    public function filterView($view)
45
+    public function filterView( $view )
46 46
     {
47 47
         $styledViews = [
48 48
             'templates/form/field',
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
             'templates/form/submit-button',
51 51
             'templates/reviews-form',
52 52
         ];
53
-        if (!preg_match('('.implode('|', $styledViews).')', $view)) {
53
+        if( !preg_match( '('.implode( '|', $styledViews ).')', $view ) ) {
54 54
             return $view;
55 55
         }
56
-        $views = $this->generatePossibleViews($view);
57
-        foreach ($views as $possibleView) {
58
-            if (!file_exists(glsr()->file($possibleView))) {
56
+        $views = $this->generatePossibleViews( $view );
57
+        foreach( $views as $possibleView ) {
58
+            if( !file_exists( glsr()->file( $possibleView ) ) ) {
59 59
                 continue;
60 60
             }
61
-            return Str::removePrefix('views/', $possibleView);
61
+            return Str::removePrefix( 'views/', $possibleView );
62 62
         }
63 63
         return $view;
64 64
     }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function get()
70 70
     {
71
-        return apply_filters('site-reviews/style', $this->style);
71
+        return apply_filters( 'site-reviews/style', $this->style );
72 72
     }
73 73
 
74 74
     /**
@@ -77,77 +77,77 @@  discard block
 block discarded – undo
77 77
     public function setConfig()
78 78
     {
79 79
         $config = shortcode_atts(
80
-            array_fill_keys(['fields', 'pagination', 'validation'], []),
81
-            glsr()->config('styles/'.$this->style)
80
+            array_fill_keys( ['fields', 'pagination', 'validation'], [] ),
81
+            glsr()->config( 'styles/'.$this->style )
82 82
         );
83
-        $this->fields = glsr(StyleFieldsDefaults::class)->restrict($config['fields']);
84
-        $this->pagination = glsr(PaginationDefaults::class)->restrict($config['pagination']);
85
-        $this->validation = glsr(StyleValidationDefaults::class)->restrict($config['validation']);
83
+        $this->fields = glsr( StyleFieldsDefaults::class )->restrict( $config['fields'] );
84
+        $this->pagination = glsr( PaginationDefaults::class )->restrict( $config['pagination'] );
85
+        $this->validation = glsr( StyleValidationDefaults::class )->restrict( $config['validation'] );
86 86
     }
87 87
 
88 88
     /**
89 89
      * @return void
90 90
      */
91
-    public function modifyField(Builder $instance)
91
+    public function modifyField( Builder $instance )
92 92
     {
93
-        if (!$this->isPublicInstance($instance) || empty(array_filter($this->fields))) {
93
+        if( !$this->isPublicInstance( $instance ) || empty(array_filter( $this->fields )) ) {
94 94
             return;
95 95
         }
96
-        call_user_func_array([$this, 'customize'], [$instance]);
96
+        call_user_func_array( [$this, 'customize'], [$instance] );
97 97
     }
98 98
 
99 99
     /**
100 100
      * @return array
101 101
      */
102
-    public function paginationArgs(array $args)
102
+    public function paginationArgs( array $args )
103 103
     {
104
-        return wp_parse_args($args, $this->pagination);
104
+        return wp_parse_args( $args, $this->pagination );
105 105
     }
106 106
 
107 107
     /**
108 108
      * @return void
109 109
      */
110
-    protected function customize(Builder $instance)
110
+    protected function customize( Builder $instance )
111 111
     {
112
-        if (!array_key_exists($instance->tag, $this->fields)) {
112
+        if( !array_key_exists( $instance->tag, $this->fields ) ) {
113 113
             return;
114 114
         }
115
-        $args = wp_parse_args($instance->args, array_fill_keys(['class', 'type'], ''));
115
+        $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) );
116 116
         $key = $instance->tag.'_'.$args['type'];
117
-        $classes = Arr::get($this->fields, $key, Arr::get($this->fields, $instance->tag));
118
-        $instance->args['class'] = trim($args['class'].' '.$classes);
119
-        do_action_ref_array('site-reviews/customize/'.$this->style, [$instance]);
117
+        $classes = Arr::get( $this->fields, $key, Arr::get( $this->fields, $instance->tag ) );
118
+        $instance->args['class'] = trim( $args['class'].' '.$classes );
119
+        do_action_ref_array( 'site-reviews/customize/'.$this->style, [$instance] );
120 120
     }
121 121
 
122 122
     /**
123 123
      * @param string $view
124 124
      * @return array
125 125
      */
126
-    protected function generatePossibleViews($view)
126
+    protected function generatePossibleViews( $view )
127 127
     {
128
-        $basename = basename($view);
129
-        $basepath = rtrim($view, $basename);
128
+        $basename = basename( $view );
129
+        $basepath = rtrim( $view, $basename );
130 130
         $customPath = 'views/partials/styles/'.$this->style.'/';
131
-        $parts = explode('_', $basename);
131
+        $parts = explode( '_', $basename );
132 132
         $views = [
133 133
             $customPath.$basename,
134 134
             $customPath.$parts[0],
135 135
             $view,
136 136
             $basepath.$parts[0],
137 137
         ];
138
-        return array_filter($views);
138
+        return array_filter( $views );
139 139
     }
140 140
 
141 141
     /**
142 142
      * @return bool
143 143
      */
144
-    protected function isPublicInstance(Builder $instance)
144
+    protected function isPublicInstance( Builder $instance )
145 145
     {
146
-        $args = wp_parse_args($instance->args, [
146
+        $args = wp_parse_args( $instance->args, [
147 147
             'is_public' => false,
148 148
             'is_raw' => false,
149
-        ]);
150
-        if (is_admin() || !$args['is_public'] || $args['is_raw']) {
149
+        ] );
150
+        if( is_admin() || !$args['is_public'] || $args['is_raw'] ) {
151 151
             return false;
152 152
         }
153 153
         return true;
Please login to merge, or discard this patch.
plugin/Review.php 2 patches
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -12,173 +12,173 @@
 block discarded – undo
12 12
 
13 13
 class Review implements \ArrayAccess
14 14
 {
15
-    public $assigned_to;
16
-    public $author;
17
-    public $avatar;
18
-    public $content;
19
-    public $custom;
20
-    public $date;
21
-    public $email;
22
-    public $ID;
23
-    public $ip_address;
24
-    public $modified;
25
-    public $pinned;
26
-    public $rating;
27
-    public $response;
28
-    public $review_id;
29
-    public $review_type;
30
-    public $status;
31
-    public $term_ids;
32
-    public $title;
33
-    public $url;
34
-    public $user_id;
15
+	public $assigned_to;
16
+	public $author;
17
+	public $avatar;
18
+	public $content;
19
+	public $custom;
20
+	public $date;
21
+	public $email;
22
+	public $ID;
23
+	public $ip_address;
24
+	public $modified;
25
+	public $pinned;
26
+	public $rating;
27
+	public $response;
28
+	public $review_id;
29
+	public $review_type;
30
+	public $status;
31
+	public $term_ids;
32
+	public $title;
33
+	public $url;
34
+	public $user_id;
35 35
 
36
-    public function __construct(WP_Post $post)
37
-    {
38
-        if (Application::POST_TYPE != $post->post_type) {
39
-            return;
40
-        }
41
-        $this->content = $post->post_content;
42
-        $this->date = $post->post_date;
43
-        $this->ID = intval($post->ID);
44
-        $this->status = $post->post_status;
45
-        $this->title = $post->post_title;
46
-        $this->user_id = intval($post->post_author);
47
-        $this->setProperties($post);
48
-        $this->setTermIds($post);
49
-    }
36
+	public function __construct(WP_Post $post)
37
+	{
38
+		if (Application::POST_TYPE != $post->post_type) {
39
+			return;
40
+		}
41
+		$this->content = $post->post_content;
42
+		$this->date = $post->post_date;
43
+		$this->ID = intval($post->ID);
44
+		$this->status = $post->post_status;
45
+		$this->title = $post->post_title;
46
+		$this->user_id = intval($post->post_author);
47
+		$this->setProperties($post);
48
+		$this->setTermIds($post);
49
+	}
50 50
 
51
-    /**
52
-     * @return mixed
53
-     */
54
-    public function __get($key)
55
-    {
56
-        return $this->offsetGet($key);
57
-    }
51
+	/**
52
+	 * @return mixed
53
+	 */
54
+	public function __get($key)
55
+	{
56
+		return $this->offsetGet($key);
57
+	}
58 58
 
59
-    /**
60
-     * @return string
61
-     */
62
-    public function __toString()
63
-    {
64
-        return (string) $this->build();
65
-    }
59
+	/**
60
+	 * @return string
61
+	 */
62
+	public function __toString()
63
+	{
64
+		return (string) $this->build();
65
+	}
66 66
 
67
-    /**
68
-     * @return ReviewHtml
69
-     */
70
-    public function build(array $args = [])
71
-    {
72
-        if (empty($this->ID)) {
73
-            return new ReviewHtml($this);
74
-        }
75
-        $partial = glsr(SiteReviewsPartial::class);
76
-        $partial->args = glsr(SiteReviewsDefaults::class)->merge($args);
77
-        $partial->options = Arr::flattenArray(glsr(OptionManager::class)->all());
78
-        return $partial->buildReview($this);
79
-    }
67
+	/**
68
+	 * @return ReviewHtml
69
+	 */
70
+	public function build(array $args = [])
71
+	{
72
+		if (empty($this->ID)) {
73
+			return new ReviewHtml($this);
74
+		}
75
+		$partial = glsr(SiteReviewsPartial::class);
76
+		$partial->args = glsr(SiteReviewsDefaults::class)->merge($args);
77
+		$partial->options = Arr::flattenArray(glsr(OptionManager::class)->all());
78
+		return $partial->buildReview($this);
79
+	}
80 80
 
81
-    /**
82
-     * @param mixed $key
83
-     * @return bool
84
-     */
85
-    public function offsetExists($key)
86
-    {
87
-        return property_exists($this, $key) || array_key_exists($key, (array) $this->custom);
88
-    }
81
+	/**
82
+	 * @param mixed $key
83
+	 * @return bool
84
+	 */
85
+	public function offsetExists($key)
86
+	{
87
+		return property_exists($this, $key) || array_key_exists($key, (array) $this->custom);
88
+	}
89 89
 
90
-    /**
91
-     * @param mixed $key
92
-     * @return mixed
93
-     */
94
-    public function offsetGet($key)
95
-    {
96
-        return property_exists($this, $key)
97
-            ? $this->$key
98
-            : Arr::get($this->custom, $key, null);
99
-    }
90
+	/**
91
+	 * @param mixed $key
92
+	 * @return mixed
93
+	 */
94
+	public function offsetGet($key)
95
+	{
96
+		return property_exists($this, $key)
97
+			? $this->$key
98
+			: Arr::get($this->custom, $key, null);
99
+	}
100 100
 
101
-    /**
102
-     * @param mixed $key
103
-     * @param mixed $value
104
-     * @return void
105
-     */
106
-    public function offsetSet($key, $value)
107
-    {
108
-        if (property_exists($this, $key)) {
109
-            $this->$key = $value;
110
-            return;
111
-        }
112
-        if (!is_array($this->custom)) {
113
-            $this->custom = array_filter((array) $this->custom);
114
-        }
115
-        $this->custom[$key] = $value;
116
-    }
101
+	/**
102
+	 * @param mixed $key
103
+	 * @param mixed $value
104
+	 * @return void
105
+	 */
106
+	public function offsetSet($key, $value)
107
+	{
108
+		if (property_exists($this, $key)) {
109
+			$this->$key = $value;
110
+			return;
111
+		}
112
+		if (!is_array($this->custom)) {
113
+			$this->custom = array_filter((array) $this->custom);
114
+		}
115
+		$this->custom[$key] = $value;
116
+	}
117 117
 
118
-    /**
119
-     * @param mixed $key
120
-     * @return void
121
-     */
122
-    public function offsetUnset($key)
123
-    {
124
-        $this->offsetSet($key, null);
125
-    }
118
+	/**
119
+	 * @param mixed $key
120
+	 * @return void
121
+	 */
122
+	public function offsetUnset($key)
123
+	{
124
+		$this->offsetSet($key, null);
125
+	}
126 126
 
127
-    /**
128
-     * @return void
129
-     */
130
-    public function render()
131
-    {
132
-        echo $this->build();
133
-    }
127
+	/**
128
+	 * @return void
129
+	 */
130
+	public function render()
131
+	{
132
+		echo $this->build();
133
+	}
134 134
 
135
-    /**
136
-     * @return bool
137
-     */
138
-    protected function isModified(array $properties)
139
-    {
140
-        return $this->date != $properties['date']
141
-            || $this->content != $properties['content']
142
-            || $this->title != $properties['title'];
143
-    }
135
+	/**
136
+	 * @return bool
137
+	 */
138
+	protected function isModified(array $properties)
139
+	{
140
+		return $this->date != $properties['date']
141
+			|| $this->content != $properties['content']
142
+			|| $this->title != $properties['title'];
143
+	}
144 144
 
145
-    /**
146
-     * @return void
147
-     */
148
-    protected function setProperties(WP_Post $post)
149
-    {
150
-        $defaults = [
151
-            'author' => __('Anonymous', 'site-reviews'),
152
-            'date' => '',
153
-            'review_id' => '',
154
-            'review_type' => 'local',
155
-        ];
156
-        $meta = array_filter(
157
-            array_map('array_shift', array_filter((array) get_post_meta($post->ID))),
158
-            'strlen'
159
-        );
160
-        $meta = array_merge($defaults, Arr::unprefixArrayKeys($meta));
161
-        $properties = glsr(CreateReviewDefaults::class)->restrict(array_merge($defaults, $meta));
162
-        $this->modified = $this->isModified($properties);
163
-        array_walk($properties, function ($value, $key) {
164
-            if (!property_exists($this, $key) || isset($this->$key)) {
165
-                return;
166
-            }
167
-            $this->$key = maybe_unserialize($value);
168
-        });
169
-    }
145
+	/**
146
+	 * @return void
147
+	 */
148
+	protected function setProperties(WP_Post $post)
149
+	{
150
+		$defaults = [
151
+			'author' => __('Anonymous', 'site-reviews'),
152
+			'date' => '',
153
+			'review_id' => '',
154
+			'review_type' => 'local',
155
+		];
156
+		$meta = array_filter(
157
+			array_map('array_shift', array_filter((array) get_post_meta($post->ID))),
158
+			'strlen'
159
+		);
160
+		$meta = array_merge($defaults, Arr::unprefixArrayKeys($meta));
161
+		$properties = glsr(CreateReviewDefaults::class)->restrict(array_merge($defaults, $meta));
162
+		$this->modified = $this->isModified($properties);
163
+		array_walk($properties, function ($value, $key) {
164
+			if (!property_exists($this, $key) || isset($this->$key)) {
165
+				return;
166
+			}
167
+			$this->$key = maybe_unserialize($value);
168
+		});
169
+	}
170 170
 
171
-    /**
172
-     * @return void
173
-     */
174
-    protected function setTermIds(WP_Post $post)
175
-    {
176
-        $this->term_ids = [];
177
-        if (!is_array($terms = get_the_terms($post, Application::TAXONOMY))) {
178
-            return;
179
-        }
180
-        foreach ($terms as $term) {
181
-            $this->term_ids[] = $term->term_id;
182
-        }
183
-    }
171
+	/**
172
+	 * @return void
173
+	 */
174
+	protected function setTermIds(WP_Post $post)
175
+	{
176
+		$this->term_ids = [];
177
+		if (!is_array($terms = get_the_terms($post, Application::TAXONOMY))) {
178
+			return;
179
+		}
180
+		foreach ($terms as $term) {
181
+			$this->term_ids[] = $term->term_id;
182
+		}
183
+	}
184 184
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -33,27 +33,27 @@  discard block
 block discarded – undo
33 33
     public $url;
34 34
     public $user_id;
35 35
 
36
-    public function __construct(WP_Post $post)
36
+    public function __construct( WP_Post $post )
37 37
     {
38
-        if (Application::POST_TYPE != $post->post_type) {
38
+        if( Application::POST_TYPE != $post->post_type ) {
39 39
             return;
40 40
         }
41 41
         $this->content = $post->post_content;
42 42
         $this->date = $post->post_date;
43
-        $this->ID = intval($post->ID);
43
+        $this->ID = intval( $post->ID );
44 44
         $this->status = $post->post_status;
45 45
         $this->title = $post->post_title;
46
-        $this->user_id = intval($post->post_author);
47
-        $this->setProperties($post);
48
-        $this->setTermIds($post);
46
+        $this->user_id = intval( $post->post_author );
47
+        $this->setProperties( $post );
48
+        $this->setTermIds( $post );
49 49
     }
50 50
 
51 51
     /**
52 52
      * @return mixed
53 53
      */
54
-    public function __get($key)
54
+    public function __get( $key )
55 55
     {
56
-        return $this->offsetGet($key);
56
+        return $this->offsetGet( $key );
57 57
     }
58 58
 
59 59
     /**
@@ -61,41 +61,41 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function __toString()
63 63
     {
64
-        return (string) $this->build();
64
+        return (string)$this->build();
65 65
     }
66 66
 
67 67
     /**
68 68
      * @return ReviewHtml
69 69
      */
70
-    public function build(array $args = [])
70
+    public function build( array $args = [] )
71 71
     {
72
-        if (empty($this->ID)) {
73
-            return new ReviewHtml($this);
72
+        if( empty($this->ID) ) {
73
+            return new ReviewHtml( $this );
74 74
         }
75
-        $partial = glsr(SiteReviewsPartial::class);
76
-        $partial->args = glsr(SiteReviewsDefaults::class)->merge($args);
77
-        $partial->options = Arr::flattenArray(glsr(OptionManager::class)->all());
78
-        return $partial->buildReview($this);
75
+        $partial = glsr( SiteReviewsPartial::class );
76
+        $partial->args = glsr( SiteReviewsDefaults::class )->merge( $args );
77
+        $partial->options = Arr::flattenArray( glsr( OptionManager::class )->all() );
78
+        return $partial->buildReview( $this );
79 79
     }
80 80
 
81 81
     /**
82 82
      * @param mixed $key
83 83
      * @return bool
84 84
      */
85
-    public function offsetExists($key)
85
+    public function offsetExists( $key )
86 86
     {
87
-        return property_exists($this, $key) || array_key_exists($key, (array) $this->custom);
87
+        return property_exists( $this, $key ) || array_key_exists( $key, (array)$this->custom );
88 88
     }
89 89
 
90 90
     /**
91 91
      * @param mixed $key
92 92
      * @return mixed
93 93
      */
94
-    public function offsetGet($key)
94
+    public function offsetGet( $key )
95 95
     {
96
-        return property_exists($this, $key)
96
+        return property_exists( $this, $key )
97 97
             ? $this->$key
98
-            : Arr::get($this->custom, $key, null);
98
+            : Arr::get( $this->custom, $key, null );
99 99
     }
100 100
 
101 101
     /**
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
      * @param mixed $value
104 104
      * @return void
105 105
      */
106
-    public function offsetSet($key, $value)
106
+    public function offsetSet( $key, $value )
107 107
     {
108
-        if (property_exists($this, $key)) {
108
+        if( property_exists( $this, $key ) ) {
109 109
             $this->$key = $value;
110 110
             return;
111 111
         }
112
-        if (!is_array($this->custom)) {
113
-            $this->custom = array_filter((array) $this->custom);
112
+        if( !is_array( $this->custom ) ) {
113
+            $this->custom = array_filter( (array)$this->custom );
114 114
         }
115 115
         $this->custom[$key] = $value;
116 116
     }
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
      * @param mixed $key
120 120
      * @return void
121 121
      */
122
-    public function offsetUnset($key)
122
+    public function offsetUnset( $key )
123 123
     {
124
-        $this->offsetSet($key, null);
124
+        $this->offsetSet( $key, null );
125 125
     }
126 126
 
127 127
     /**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     /**
136 136
      * @return bool
137 137
      */
138
-    protected function isModified(array $properties)
138
+    protected function isModified( array $properties )
139 139
     {
140 140
         return $this->date != $properties['date']
141 141
             || $this->content != $properties['content']
@@ -145,39 +145,39 @@  discard block
 block discarded – undo
145 145
     /**
146 146
      * @return void
147 147
      */
148
-    protected function setProperties(WP_Post $post)
148
+    protected function setProperties( WP_Post $post )
149 149
     {
150 150
         $defaults = [
151
-            'author' => __('Anonymous', 'site-reviews'),
151
+            'author' => __( 'Anonymous', 'site-reviews' ),
152 152
             'date' => '',
153 153
             'review_id' => '',
154 154
             'review_type' => 'local',
155 155
         ];
156 156
         $meta = array_filter(
157
-            array_map('array_shift', array_filter((array) get_post_meta($post->ID))),
157
+            array_map( 'array_shift', array_filter( (array)get_post_meta( $post->ID ) ) ),
158 158
             'strlen'
159 159
         );
160
-        $meta = array_merge($defaults, Arr::unprefixArrayKeys($meta));
161
-        $properties = glsr(CreateReviewDefaults::class)->restrict(array_merge($defaults, $meta));
162
-        $this->modified = $this->isModified($properties);
163
-        array_walk($properties, function ($value, $key) {
164
-            if (!property_exists($this, $key) || isset($this->$key)) {
160
+        $meta = array_merge( $defaults, Arr::unprefixArrayKeys( $meta ) );
161
+        $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) );
162
+        $this->modified = $this->isModified( $properties );
163
+        array_walk( $properties, function( $value, $key ) {
164
+            if( !property_exists( $this, $key ) || isset($this->$key) ) {
165 165
                 return;
166 166
             }
167
-            $this->$key = maybe_unserialize($value);
167
+            $this->$key = maybe_unserialize( $value );
168 168
         });
169 169
     }
170 170
 
171 171
     /**
172 172
      * @return void
173 173
      */
174
-    protected function setTermIds(WP_Post $post)
174
+    protected function setTermIds( WP_Post $post )
175 175
     {
176 176
         $this->term_ids = [];
177
-        if (!is_array($terms = get_the_terms($post, Application::TAXONOMY))) {
177
+        if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) ) {
178 178
             return;
179 179
         }
180
-        foreach ($terms as $term) {
180
+        foreach( $terms as $term ) {
181 181
             $this->term_ids[] = $term->term_id;
182 182
         }
183 183
     }
Please login to merge, or discard this patch.
plugin/Helpers/Str.php 2 patches
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -6,164 +6,164 @@
 block discarded – undo
6 6
 
7 7
 class Str
8 8
 {
9
-    /**
10
-     * @param string $string
11
-     * @return string
12
-     */
13
-    public static function camelCase($string)
14
-    {
15
-        $string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
16
-        return str_replace(' ', '', $string);
17
-    }
9
+	/**
10
+	 * @param string $string
11
+	 * @return string
12
+	 */
13
+	public static function camelCase($string)
14
+	{
15
+		$string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
16
+		return str_replace(' ', '', $string);
17
+	}
18 18
 
19
-    /**
20
-     * @param string $name
21
-     * @param string $nameType first|first_initial|initials|last|last_initial
22
-     * @param string $initialType period|period_space|space
23
-     * @return string
24
-     */
25
-    public static function convertName($name, $nameType = '', $initialType = '')
26
-    {
27
-        $names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY);
28
-        $firstName = array_shift($names);
29
-        $lastName = array_pop($names);
30
-        $initialTypes = [
31
-            'period' => '.',
32
-            'period_space' => '. ',
33
-            'space' => ' ',
34
-        ];
35
-        $initialPunctuation = (string) Arr::get($initialTypes, $initialType, ' ');
36
-        if ('initials' == $nameType) {
37
-            return static::convertToInitials($name, $initialPunctuation);
38
-        }
39
-        $nameTypes = [
40
-            'first' => $firstName,
41
-            'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName,
42
-            'last' => $lastName,
43
-            'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation,
44
-        ];
45
-        return trim((string) Arr::get($nameTypes, $nameType, $name));
46
-    }
19
+	/**
20
+	 * @param string $name
21
+	 * @param string $nameType first|first_initial|initials|last|last_initial
22
+	 * @param string $initialType period|period_space|space
23
+	 * @return string
24
+	 */
25
+	public static function convertName($name, $nameType = '', $initialType = '')
26
+	{
27
+		$names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY);
28
+		$firstName = array_shift($names);
29
+		$lastName = array_pop($names);
30
+		$initialTypes = [
31
+			'period' => '.',
32
+			'period_space' => '. ',
33
+			'space' => ' ',
34
+		];
35
+		$initialPunctuation = (string) Arr::get($initialTypes, $initialType, ' ');
36
+		if ('initials' == $nameType) {
37
+			return static::convertToInitials($name, $initialPunctuation);
38
+		}
39
+		$nameTypes = [
40
+			'first' => $firstName,
41
+			'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName,
42
+			'last' => $lastName,
43
+			'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation,
44
+		];
45
+		return trim((string) Arr::get($nameTypes, $nameType, $name));
46
+	}
47 47
 
48
-    /**
49
-     * @param string $path
50
-     * @param string $prefix
51
-     * @return string
52
-     */
53
-    public static function convertPathToId($path, $prefix = '')
54
-    {
55
-        return str_replace(['[', ']'], ['-', ''], static::convertPathToName($path, $prefix));
56
-    }
48
+	/**
49
+	 * @param string $path
50
+	 * @param string $prefix
51
+	 * @return string
52
+	 */
53
+	public static function convertPathToId($path, $prefix = '')
54
+	{
55
+		return str_replace(['[', ']'], ['-', ''], static::convertPathToName($path, $prefix));
56
+	}
57 57
 
58
-    /**
59
-     * @param string $path
60
-     * @param string $prefix
61
-     * @return string
62
-     */
63
-    public static function convertPathToName($path, $prefix = '')
64
-    {
65
-        $levels = explode('.', $path);
66
-        return array_reduce($levels, function ($result, $value) {
67
-            return $result .= '['.$value.']';
68
-        }, $prefix);
69
-    }
58
+	/**
59
+	 * @param string $path
60
+	 * @param string $prefix
61
+	 * @return string
62
+	 */
63
+	public static function convertPathToName($path, $prefix = '')
64
+	{
65
+		$levels = explode('.', $path);
66
+		return array_reduce($levels, function ($result, $value) {
67
+			return $result .= '['.$value.']';
68
+		}, $prefix);
69
+	}
70 70
 
71
-    /**
72
-     * @param string $name
73
-     * @param string $initialPunctuation
74
-     * @return string
75
-     */
76
-    public static function convertToInitials($name, $initialPunctuation = '')
77
-    {
78
-        preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches);
79
-        return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) {
80
-            return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation;
81
-        });
82
-    }
71
+	/**
72
+	 * @param string $name
73
+	 * @param string $initialPunctuation
74
+	 * @return string
75
+	 */
76
+	public static function convertToInitials($name, $initialPunctuation = '')
77
+	{
78
+		preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches);
79
+		return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) {
80
+			return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation;
81
+		});
82
+	}
83 83
 
84
-    /**
85
-     * @param string $string
86
-     * @return string
87
-     */
88
-    public static function dashCase($string)
89
-    {
90
-        return str_replace('_', '-', static::snakeCase($string));
91
-    }
84
+	/**
85
+	 * @param string $string
86
+	 * @return string
87
+	 */
88
+	public static function dashCase($string)
89
+	{
90
+		return str_replace('_', '-', static::snakeCase($string));
91
+	}
92 92
 
93
-    /**
94
-     * @param string $needle
95
-     * @param string $haystack
96
-     * @return bool
97
-     */
98
-    public static function endsWith($needle, $haystack)
99
-    {
100
-        $length = strlen($needle);
101
-        return 0 != $length
102
-            ? substr($haystack, -$length) === $needle
103
-            : true;
104
-    }
93
+	/**
94
+	 * @param string $needle
95
+	 * @param string $haystack
96
+	 * @return bool
97
+	 */
98
+	public static function endsWith($needle, $haystack)
99
+	{
100
+		$length = strlen($needle);
101
+		return 0 != $length
102
+			? substr($haystack, -$length) === $needle
103
+			: true;
104
+	}
105 105
 
106
-    /**
107
-     * @param string $prefix
108
-     * @param string $string
109
-     * @param string|null $trim
110
-     * @return string
111
-     */
112
-    public static function prefix($prefix, $string, $trim = null)
113
-    {
114
-        if (null === $trim) {
115
-            $trim = $prefix;
116
-        }
117
-        return $prefix.trim(static::removePrefix($trim, $string));
118
-    }
106
+	/**
107
+	 * @param string $prefix
108
+	 * @param string $string
109
+	 * @param string|null $trim
110
+	 * @return string
111
+	 */
112
+	public static function prefix($prefix, $string, $trim = null)
113
+	{
114
+		if (null === $trim) {
115
+			$trim = $prefix;
116
+		}
117
+		return $prefix.trim(static::removePrefix($trim, $string));
118
+	}
119 119
 
120
-    /**
121
-     * @param string $prefix
122
-     * @param string $string
123
-     * @return string
124
-     */
125
-    public static function removePrefix($prefix, $string)
126
-    {
127
-        return static::startsWith($prefix, $string)
128
-            ? substr($string, strlen($prefix))
129
-            : $string;
130
-    }
120
+	/**
121
+	 * @param string $prefix
122
+	 * @param string $string
123
+	 * @return string
124
+	 */
125
+	public static function removePrefix($prefix, $string)
126
+	{
127
+		return static::startsWith($prefix, $string)
128
+			? substr($string, strlen($prefix))
129
+			: $string;
130
+	}
131 131
 
132
-    /**
133
-     * @param string $string
134
-     * @return string
135
-     */
136
-    public static function snakeCase($string)
137
-    {
138
-        if (!ctype_lower($string)) {
139
-            $string = preg_replace('/\s+/u', '', $string);
140
-            $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string);
141
-            $string = function_exists('mb_strtolower')
142
-                ? mb_strtolower($string, 'UTF-8')
143
-                : strtolower($string);
144
-        }
145
-        return str_replace('-', '_', $string);
146
-    }
132
+	/**
133
+	 * @param string $string
134
+	 * @return string
135
+	 */
136
+	public static function snakeCase($string)
137
+	{
138
+		if (!ctype_lower($string)) {
139
+			$string = preg_replace('/\s+/u', '', $string);
140
+			$string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string);
141
+			$string = function_exists('mb_strtolower')
142
+				? mb_strtolower($string, 'UTF-8')
143
+				: strtolower($string);
144
+		}
145
+		return str_replace('-', '_', $string);
146
+	}
147 147
 
148
-    /**
149
-     * @param string $needle
150
-     * @param string $haystack
151
-     * @return bool
152
-     */
153
-    public static function startsWith($needle, $haystack)
154
-    {
155
-        return substr($haystack, 0, strlen($needle)) === $needle;
156
-    }
148
+	/**
149
+	 * @param string $needle
150
+	 * @param string $haystack
151
+	 * @return bool
152
+	 */
153
+	public static function startsWith($needle, $haystack)
154
+	{
155
+		return substr($haystack, 0, strlen($needle)) === $needle;
156
+	}
157 157
 
158
-    /**
159
-     * @param string $string
160
-     * @param int $length
161
-     * @return string
162
-     */
163
-    public static function truncate($string, $length)
164
-    {
165
-        return strlen($string) > $length
166
-            ? substr($string, 0, $length)
167
-            : $string;
168
-    }
158
+	/**
159
+	 * @param string $string
160
+	 * @param int $length
161
+	 * @return string
162
+	 */
163
+	public static function truncate($string, $length)
164
+	{
165
+		return strlen($string) > $length
166
+			? substr($string, 0, $length)
167
+			: $string;
168
+	}
169 169
 }
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
      * @param string $string
11 11
      * @return string
12 12
      */
13
-    public static function camelCase($string)
13
+    public static function camelCase( $string )
14 14
     {
15
-        $string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
16
-        return str_replace(' ', '', $string);
15
+        $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ) ) );
16
+        return str_replace( ' ', '', $string );
17 17
     }
18 18
 
19 19
     /**
@@ -22,27 +22,27 @@  discard block
 block discarded – undo
22 22
      * @param string $initialType period|period_space|space
23 23
      * @return string
24 24
      */
25
-    public static function convertName($name, $nameType = '', $initialType = '')
25
+    public static function convertName( $name, $nameType = '', $initialType = '' )
26 26
     {
27
-        $names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY);
28
-        $firstName = array_shift($names);
29
-        $lastName = array_pop($names);
27
+        $names = preg_split( '/\W/', $name, 0, PREG_SPLIT_NO_EMPTY );
28
+        $firstName = array_shift( $names );
29
+        $lastName = array_pop( $names );
30 30
         $initialTypes = [
31 31
             'period' => '.',
32 32
             'period_space' => '. ',
33 33
             'space' => ' ',
34 34
         ];
35
-        $initialPunctuation = (string) Arr::get($initialTypes, $initialType, ' ');
36
-        if ('initials' == $nameType) {
37
-            return static::convertToInitials($name, $initialPunctuation);
35
+        $initialPunctuation = (string)Arr::get( $initialTypes, $initialType, ' ' );
36
+        if( 'initials' == $nameType ) {
37
+            return static::convertToInitials( $name, $initialPunctuation );
38 38
         }
39 39
         $nameTypes = [
40 40
             'first' => $firstName,
41
-            'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName,
41
+            'first_initial' => substr( $firstName, 0, 1 ).$initialPunctuation.$lastName,
42 42
             'last' => $lastName,
43
-            'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation,
43
+            'last_initial' => $firstName.' '.substr( $lastName, 0, 1 ).$initialPunctuation,
44 44
         ];
45
-        return trim((string) Arr::get($nameTypes, $nameType, $name));
45
+        return trim( (string)Arr::get( $nameTypes, $nameType, $name ) );
46 46
     }
47 47
 
48 48
     /**
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
      * @param string $prefix
51 51
      * @return string
52 52
      */
53
-    public static function convertPathToId($path, $prefix = '')
53
+    public static function convertPathToId( $path, $prefix = '' )
54 54
     {
55
-        return str_replace(['[', ']'], ['-', ''], static::convertPathToName($path, $prefix));
55
+        return str_replace( ['[', ']'], ['-', ''], static::convertPathToName( $path, $prefix ) );
56 56
     }
57 57
 
58 58
     /**
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
      * @param string $prefix
61 61
      * @return string
62 62
      */
63
-    public static function convertPathToName($path, $prefix = '')
63
+    public static function convertPathToName( $path, $prefix = '' )
64 64
     {
65
-        $levels = explode('.', $path);
66
-        return array_reduce($levels, function ($result, $value) {
65
+        $levels = explode( '.', $path );
66
+        return array_reduce( $levels, function( $result, $value ) {
67 67
             return $result .= '['.$value.']';
68
-        }, $prefix);
68
+        }, $prefix );
69 69
     }
70 70
 
71 71
     /**
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
      * @param string $initialPunctuation
74 74
      * @return string
75 75
      */
76
-    public static function convertToInitials($name, $initialPunctuation = '')
76
+    public static function convertToInitials( $name, $initialPunctuation = '' )
77 77
     {
78
-        preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches);
79
-        return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) {
80
-            return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation;
78
+        preg_match_all( '/(?<=\s|\b)\pL/u', $name, $matches );
79
+        return array_reduce( $matches[0], function( $carry, $word ) use ($initialPunctuation) {
80
+            return $carry.strtoupper( substr( $word, 0, 1 ) ).$initialPunctuation;
81 81
         });
82 82
     }
83 83
 
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
      * @param string $string
86 86
      * @return string
87 87
      */
88
-    public static function dashCase($string)
88
+    public static function dashCase( $string )
89 89
     {
90
-        return str_replace('_', '-', static::snakeCase($string));
90
+        return str_replace( '_', '-', static::snakeCase( $string ) );
91 91
     }
92 92
 
93 93
     /**
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
      * @param string $haystack
96 96
      * @return bool
97 97
      */
98
-    public static function endsWith($needle, $haystack)
98
+    public static function endsWith( $needle, $haystack )
99 99
     {
100
-        $length = strlen($needle);
100
+        $length = strlen( $needle );
101 101
         return 0 != $length
102
-            ? substr($haystack, -$length) === $needle
102
+            ? substr( $haystack, -$length ) === $needle
103 103
             : true;
104 104
     }
105 105
 
@@ -109,12 +109,12 @@  discard block
 block discarded – undo
109 109
      * @param string|null $trim
110 110
      * @return string
111 111
      */
112
-    public static function prefix($prefix, $string, $trim = null)
112
+    public static function prefix( $prefix, $string, $trim = null )
113 113
     {
114
-        if (null === $trim) {
114
+        if( null === $trim ) {
115 115
             $trim = $prefix;
116 116
         }
117
-        return $prefix.trim(static::removePrefix($trim, $string));
117
+        return $prefix.trim( static::removePrefix( $trim, $string ) );
118 118
     }
119 119
 
120 120
     /**
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
      * @param string $string
123 123
      * @return string
124 124
      */
125
-    public static function removePrefix($prefix, $string)
125
+    public static function removePrefix( $prefix, $string )
126 126
     {
127
-        return static::startsWith($prefix, $string)
128
-            ? substr($string, strlen($prefix))
127
+        return static::startsWith( $prefix, $string )
128
+            ? substr( $string, strlen( $prefix ) )
129 129
             : $string;
130 130
     }
131 131
 
@@ -133,16 +133,16 @@  discard block
 block discarded – undo
133 133
      * @param string $string
134 134
      * @return string
135 135
      */
136
-    public static function snakeCase($string)
136
+    public static function snakeCase( $string )
137 137
     {
138
-        if (!ctype_lower($string)) {
139
-            $string = preg_replace('/\s+/u', '', $string);
140
-            $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string);
141
-            $string = function_exists('mb_strtolower')
142
-                ? mb_strtolower($string, 'UTF-8')
143
-                : strtolower($string);
138
+        if( !ctype_lower( $string ) ) {
139
+            $string = preg_replace( '/\s+/u', '', $string );
140
+            $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string );
141
+            $string = function_exists( 'mb_strtolower' )
142
+                ? mb_strtolower( $string, 'UTF-8' )
143
+                : strtolower( $string );
144 144
         }
145
-        return str_replace('-', '_', $string);
145
+        return str_replace( '-', '_', $string );
146 146
     }
147 147
 
148 148
     /**
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
      * @param string $haystack
151 151
      * @return bool
152 152
      */
153
-    public static function startsWith($needle, $haystack)
153
+    public static function startsWith( $needle, $haystack )
154 154
     {
155
-        return substr($haystack, 0, strlen($needle)) === $needle;
155
+        return substr( $haystack, 0, strlen( $needle ) ) === $needle;
156 156
     }
157 157
 
158 158
     /**
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
      * @param int $length
161 161
      * @return string
162 162
      */
163
-    public static function truncate($string, $length)
163
+    public static function truncate( $string, $length )
164 164
     {
165
-        return strlen($string) > $length
166
-            ? substr($string, 0, $length)
165
+        return strlen( $string ) > $length
166
+            ? substr( $string, 0, $length )
167 167
             : $string;
168 168
     }
169 169
 }
Please login to merge, or discard this patch.
plugin/Modules/Email.php 3 patches
Indentation   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -9,205 +9,205 @@
 block discarded – undo
9 9
 
10 10
 class Email
11 11
 {
12
-    /**
13
-     * @var array
14
-     */
15
-    public $attachments;
16
-
17
-    /**
18
-     * @var array
19
-     */
20
-    public $email;
21
-
22
-    /**
23
-     * @var array
24
-     */
25
-    public $headers;
26
-
27
-    /**
28
-     * @var string
29
-     */
30
-    public $message;
31
-
32
-    /**
33
-     * @var string
34
-     */
35
-    public $subject;
36
-
37
-    /**
38
-     * @var string|array
39
-     */
40
-    public $to;
41
-
42
-    /**
43
-     * @return Email
44
-     */
45
-    public function compose(array $email)
46
-    {
47
-        $this->normalize($email);
48
-        $this->attachments = $this->email['attachments'];
49
-        $this->headers = $this->buildHeaders();
50
-        $this->message = $this->buildHtmlMessage();
51
-        $this->subject = $this->email['subject'];
52
-        $this->to = $this->email['to'];
53
-        add_action('phpmailer_init', [$this, 'buildPlainTextMessage']);
54
-        return $this;
55
-    }
56
-
57
-    /**
58
-     * @param string $format
59
-     * @return string|null
60
-     */
61
-    public function read($format = '')
62
-    {
63
-        if ('plaintext' == $format) {
64
-            $message = $this->stripHtmlTags($this->message);
65
-            return apply_filters('site-reviews/email/message', $message, 'text', $this);
66
-        }
67
-        return $this->message;
68
-    }
69
-
70
-    /**
71
-     * @return void|bool
72
-     */
73
-    public function send()
74
-    {
75
-        if (!$this->message || !$this->subject || !$this->to) {
76
-            return;
77
-        }
78
-        add_action('wp_mail_failed', [$this, 'logMailError']);
79
-        $sent = wp_mail(
80
-            $this->to,
81
-            $this->subject,
82
-            $this->message,
83
-            $this->headers,
84
-            $this->attachments
85
-        );
86
-        remove_action('wp_mail_failed', [$this, 'logMailError']);
87
-        $this->reset();
88
-        return $sent;
89
-    }
90
-
91
-    /**
92
-     * @return void
93
-     * @action phpmailer_init
94
-     */
95
-    public function buildPlainTextMessage(PHPMailer $phpmailer)
96
-    {
97
-        if (empty($this->email)) {
98
-            return;
99
-        }
100
-        if ('text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody)) {
101
-            return;
102
-        }
103
-        $message = $this->stripHtmlTags($phpmailer->Body);
104
-        $phpmailer->AltBody = apply_filters('site-reviews/email/message', $message, 'text', $this);
105
-    }
106
-
107
-    /**
108
-     * @return array
109
-     */
110
-    protected function buildHeaders()
111
-    {
112
-        $allowed = [
113
-            'bcc', 'cc', 'from', 'reply-to',
114
-        ];
115
-        $headers = array_intersect_key($this->email, array_flip($allowed));
116
-        $headers = array_filter($headers);
117
-        foreach ($headers as $key => $value) {
118
-            unset($headers[$key]);
119
-            $headers[] = $key.': '.$value;
120
-        }
121
-        $headers[] = 'Content-Type: text/html';
122
-        return apply_filters('site-reviews/email/headers', $headers, $this);
123
-    }
124
-
125
-    /**
126
-     * @return string
127
-     */
128
-    protected function buildHtmlMessage()
129
-    {
130
-        $template = trim(glsr(OptionManager::class)->get('settings.general.notification_message'));
131
-        if (!empty($template)) {
132
-            $message = glsr(Template::class)->interpolate(
133
-                $template, 
134
-                ['context' => $this->email['template-tags']], 
135
-                $this->email['template']
136
-            );
137
-        } elseif ($this->email['template']) {
138
-            $message = glsr(Template::class)->build('templates/'.$this->email['template'], [
139
-                'context' => $this->email['template-tags'],
140
-            ]);
141
-        }
142
-        if (!isset($message)) {
143
-            $message = $this->email['message'];
144
-        }
145
-        $message = $this->email['before'].$message.$this->email['after'];
146
-        $message = strip_shortcodes($message);
147
-        $message = wptexturize($message);
148
-        $message = wpautop($message);
149
-        $message = str_replace('&lt;&gt; ', '', $message);
150
-        $message = str_replace(']]>', ']]&gt;', $message);
151
-        $message = glsr(Template::class)->build('partials/email/index', [
152
-            'context' => ['message' => $message],
153
-        ]);
154
-        return apply_filters('site-reviews/email/message', stripslashes($message), 'html', $this);
155
-    }
156
-
157
-    /**
158
-     * @param \WP_Error $error
159
-     * @return void
160
-     */
161
-    protected function logMailError($error)
162
-    {
163
-        glsr_log()->error('Email was not sent (wp_mail failed)')
164
-            ->debug($this)
165
-            ->debug($error);
166
-    }
167
-
168
-    /**
169
-     * @return void
170
-     */
171
-    protected function normalize(array $email = [])
172
-    {
173
-        $email = shortcode_atts(glsr(EmailDefaults::class)->defaults(), $email);
174
-        if (empty($email['reply-to'])) {
175
-            $email['reply-to'] = $email['from'];
176
-        }
177
-        $this->email = apply_filters('site-reviews/email/compose', $email, $this);
178
-    }
179
-
180
-    /**
181
-     * @return void
182
-     */
183
-    protected function reset()
184
-    {
185
-        $this->attachments = [];
186
-        $this->email = [];
187
-        $this->headers = [];
188
-        $this->message = null;
189
-        $this->subject = null;
190
-        $this->to = null;
191
-    }
192
-
193
-    /**
194
-     * @return string
195
-     */
196
-    protected function stripHtmlTags($string)
197
-    {
198
-        // remove invisible elements
199
-        $string = preg_replace('@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string);
200
-        // replace certain elements with a line-break
201
-        $string = preg_replace('@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string);
202
-        // replace other elements with a space
203
-        $string = preg_replace('@</(td|th)@iu', ' $0', $string);
204
-        // add a placeholder for plain-text bullets to list elements
205
-        $string = preg_replace('@<(li)[^>]*?>@siu', '$0-o-^-o-', $string);
206
-        // strip all remaining HTML tags
207
-        $string = wp_strip_all_tags($string);
208
-        $string = wp_specialchars_decode($string, ENT_QUOTES);
209
-        $string = preg_replace('/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string);
210
-        $string = str_replace('-o-^-o-', ' - ', $string);
211
-        return html_entity_decode($string, ENT_QUOTES, 'UTF-8');
212
-    }
12
+	/**
13
+	 * @var array
14
+	 */
15
+	public $attachments;
16
+
17
+	/**
18
+	 * @var array
19
+	 */
20
+	public $email;
21
+
22
+	/**
23
+	 * @var array
24
+	 */
25
+	public $headers;
26
+
27
+	/**
28
+	 * @var string
29
+	 */
30
+	public $message;
31
+
32
+	/**
33
+	 * @var string
34
+	 */
35
+	public $subject;
36
+
37
+	/**
38
+	 * @var string|array
39
+	 */
40
+	public $to;
41
+
42
+	/**
43
+	 * @return Email
44
+	 */
45
+	public function compose(array $email)
46
+	{
47
+		$this->normalize($email);
48
+		$this->attachments = $this->email['attachments'];
49
+		$this->headers = $this->buildHeaders();
50
+		$this->message = $this->buildHtmlMessage();
51
+		$this->subject = $this->email['subject'];
52
+		$this->to = $this->email['to'];
53
+		add_action('phpmailer_init', [$this, 'buildPlainTextMessage']);
54
+		return $this;
55
+	}
56
+
57
+	/**
58
+	 * @param string $format
59
+	 * @return string|null
60
+	 */
61
+	public function read($format = '')
62
+	{
63
+		if ('plaintext' == $format) {
64
+			$message = $this->stripHtmlTags($this->message);
65
+			return apply_filters('site-reviews/email/message', $message, 'text', $this);
66
+		}
67
+		return $this->message;
68
+	}
69
+
70
+	/**
71
+	 * @return void|bool
72
+	 */
73
+	public function send()
74
+	{
75
+		if (!$this->message || !$this->subject || !$this->to) {
76
+			return;
77
+		}
78
+		add_action('wp_mail_failed', [$this, 'logMailError']);
79
+		$sent = wp_mail(
80
+			$this->to,
81
+			$this->subject,
82
+			$this->message,
83
+			$this->headers,
84
+			$this->attachments
85
+		);
86
+		remove_action('wp_mail_failed', [$this, 'logMailError']);
87
+		$this->reset();
88
+		return $sent;
89
+	}
90
+
91
+	/**
92
+	 * @return void
93
+	 * @action phpmailer_init
94
+	 */
95
+	public function buildPlainTextMessage(PHPMailer $phpmailer)
96
+	{
97
+		if (empty($this->email)) {
98
+			return;
99
+		}
100
+		if ('text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody)) {
101
+			return;
102
+		}
103
+		$message = $this->stripHtmlTags($phpmailer->Body);
104
+		$phpmailer->AltBody = apply_filters('site-reviews/email/message', $message, 'text', $this);
105
+	}
106
+
107
+	/**
108
+	 * @return array
109
+	 */
110
+	protected function buildHeaders()
111
+	{
112
+		$allowed = [
113
+			'bcc', 'cc', 'from', 'reply-to',
114
+		];
115
+		$headers = array_intersect_key($this->email, array_flip($allowed));
116
+		$headers = array_filter($headers);
117
+		foreach ($headers as $key => $value) {
118
+			unset($headers[$key]);
119
+			$headers[] = $key.': '.$value;
120
+		}
121
+		$headers[] = 'Content-Type: text/html';
122
+		return apply_filters('site-reviews/email/headers', $headers, $this);
123
+	}
124
+
125
+	/**
126
+	 * @return string
127
+	 */
128
+	protected function buildHtmlMessage()
129
+	{
130
+		$template = trim(glsr(OptionManager::class)->get('settings.general.notification_message'));
131
+		if (!empty($template)) {
132
+			$message = glsr(Template::class)->interpolate(
133
+				$template, 
134
+				['context' => $this->email['template-tags']], 
135
+				$this->email['template']
136
+			);
137
+		} elseif ($this->email['template']) {
138
+			$message = glsr(Template::class)->build('templates/'.$this->email['template'], [
139
+				'context' => $this->email['template-tags'],
140
+			]);
141
+		}
142
+		if (!isset($message)) {
143
+			$message = $this->email['message'];
144
+		}
145
+		$message = $this->email['before'].$message.$this->email['after'];
146
+		$message = strip_shortcodes($message);
147
+		$message = wptexturize($message);
148
+		$message = wpautop($message);
149
+		$message = str_replace('&lt;&gt; ', '', $message);
150
+		$message = str_replace(']]>', ']]&gt;', $message);
151
+		$message = glsr(Template::class)->build('partials/email/index', [
152
+			'context' => ['message' => $message],
153
+		]);
154
+		return apply_filters('site-reviews/email/message', stripslashes($message), 'html', $this);
155
+	}
156
+
157
+	/**
158
+	 * @param \WP_Error $error
159
+	 * @return void
160
+	 */
161
+	protected function logMailError($error)
162
+	{
163
+		glsr_log()->error('Email was not sent (wp_mail failed)')
164
+			->debug($this)
165
+			->debug($error);
166
+	}
167
+
168
+	/**
169
+	 * @return void
170
+	 */
171
+	protected function normalize(array $email = [])
172
+	{
173
+		$email = shortcode_atts(glsr(EmailDefaults::class)->defaults(), $email);
174
+		if (empty($email['reply-to'])) {
175
+			$email['reply-to'] = $email['from'];
176
+		}
177
+		$this->email = apply_filters('site-reviews/email/compose', $email, $this);
178
+	}
179
+
180
+	/**
181
+	 * @return void
182
+	 */
183
+	protected function reset()
184
+	{
185
+		$this->attachments = [];
186
+		$this->email = [];
187
+		$this->headers = [];
188
+		$this->message = null;
189
+		$this->subject = null;
190
+		$this->to = null;
191
+	}
192
+
193
+	/**
194
+	 * @return string
195
+	 */
196
+	protected function stripHtmlTags($string)
197
+	{
198
+		// remove invisible elements
199
+		$string = preg_replace('@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string);
200
+		// replace certain elements with a line-break
201
+		$string = preg_replace('@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string);
202
+		// replace other elements with a space
203
+		$string = preg_replace('@</(td|th)@iu', ' $0', $string);
204
+		// add a placeholder for plain-text bullets to list elements
205
+		$string = preg_replace('@<(li)[^>]*?>@siu', '$0-o-^-o-', $string);
206
+		// strip all remaining HTML tags
207
+		$string = wp_strip_all_tags($string);
208
+		$string = wp_specialchars_decode($string, ENT_QUOTES);
209
+		$string = preg_replace('/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string);
210
+		$string = str_replace('-o-^-o-', ' - ', $string);
211
+		return html_entity_decode($string, ENT_QUOTES, 'UTF-8');
212
+	}
213 213
 }
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
     /**
43 43
      * @return Email
44 44
      */
45
-    public function compose(array $email)
45
+    public function compose( array $email )
46 46
     {
47
-        $this->normalize($email);
47
+        $this->normalize( $email );
48 48
         $this->attachments = $this->email['attachments'];
49 49
         $this->headers = $this->buildHeaders();
50 50
         $this->message = $this->buildHtmlMessage();
51 51
         $this->subject = $this->email['subject'];
52 52
         $this->to = $this->email['to'];
53
-        add_action('phpmailer_init', [$this, 'buildPlainTextMessage']);
53
+        add_action( 'phpmailer_init', [$this, 'buildPlainTextMessage'] );
54 54
         return $this;
55 55
     }
56 56
 
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
      * @param string $format
59 59
      * @return string|null
60 60
      */
61
-    public function read($format = '')
61
+    public function read( $format = '' )
62 62
     {
63
-        if ('plaintext' == $format) {
64
-            $message = $this->stripHtmlTags($this->message);
65
-            return apply_filters('site-reviews/email/message', $message, 'text', $this);
63
+        if( 'plaintext' == $format ) {
64
+            $message = $this->stripHtmlTags( $this->message );
65
+            return apply_filters( 'site-reviews/email/message', $message, 'text', $this );
66 66
         }
67 67
         return $this->message;
68 68
     }
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function send()
74 74
     {
75
-        if (!$this->message || !$this->subject || !$this->to) {
75
+        if( !$this->message || !$this->subject || !$this->to ) {
76 76
             return;
77 77
         }
78
-        add_action('wp_mail_failed', [$this, 'logMailError']);
78
+        add_action( 'wp_mail_failed', [$this, 'logMailError'] );
79 79
         $sent = wp_mail(
80 80
             $this->to,
81 81
             $this->subject,
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             $this->headers,
84 84
             $this->attachments
85 85
         );
86
-        remove_action('wp_mail_failed', [$this, 'logMailError']);
86
+        remove_action( 'wp_mail_failed', [$this, 'logMailError'] );
87 87
         $this->reset();
88 88
         return $sent;
89 89
     }
@@ -92,16 +92,16 @@  discard block
 block discarded – undo
92 92
      * @return void
93 93
      * @action phpmailer_init
94 94
      */
95
-    public function buildPlainTextMessage(PHPMailer $phpmailer)
95
+    public function buildPlainTextMessage( PHPMailer $phpmailer )
96 96
     {
97
-        if (empty($this->email)) {
97
+        if( empty($this->email) ) {
98 98
             return;
99 99
         }
100
-        if ('text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody)) {
100
+        if( 'text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody) ) {
101 101
             return;
102 102
         }
103
-        $message = $this->stripHtmlTags($phpmailer->Body);
104
-        $phpmailer->AltBody = apply_filters('site-reviews/email/message', $message, 'text', $this);
103
+        $message = $this->stripHtmlTags( $phpmailer->Body );
104
+        $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this );
105 105
     }
106 106
 
107 107
     /**
@@ -112,14 +112,14 @@  discard block
 block discarded – undo
112 112
         $allowed = [
113 113
             'bcc', 'cc', 'from', 'reply-to',
114 114
         ];
115
-        $headers = array_intersect_key($this->email, array_flip($allowed));
116
-        $headers = array_filter($headers);
117
-        foreach ($headers as $key => $value) {
115
+        $headers = array_intersect_key( $this->email, array_flip( $allowed ) );
116
+        $headers = array_filter( $headers );
117
+        foreach( $headers as $key => $value ) {
118 118
             unset($headers[$key]);
119 119
             $headers[] = $key.': '.$value;
120 120
         }
121 121
         $headers[] = 'Content-Type: text/html';
122
-        return apply_filters('site-reviews/email/headers', $headers, $this);
122
+        return apply_filters( 'site-reviews/email/headers', $headers, $this );
123 123
     }
124 124
 
125 125
     /**
@@ -127,54 +127,54 @@  discard block
 block discarded – undo
127 127
      */
128 128
     protected function buildHtmlMessage()
129 129
     {
130
-        $template = trim(glsr(OptionManager::class)->get('settings.general.notification_message'));
131
-        if (!empty($template)) {
132
-            $message = glsr(Template::class)->interpolate(
130
+        $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' ) );
131
+        if( !empty($template) ) {
132
+            $message = glsr( Template::class )->interpolate(
133 133
                 $template, 
134 134
                 ['context' => $this->email['template-tags']], 
135 135
                 $this->email['template']
136 136
             );
137
-        } elseif ($this->email['template']) {
138
-            $message = glsr(Template::class)->build('templates/'.$this->email['template'], [
137
+        } elseif( $this->email['template'] ) {
138
+            $message = glsr( Template::class )->build( 'templates/'.$this->email['template'], [
139 139
                 'context' => $this->email['template-tags'],
140
-            ]);
140
+            ] );
141 141
         }
142
-        if (!isset($message)) {
142
+        if( !isset($message) ) {
143 143
             $message = $this->email['message'];
144 144
         }
145 145
         $message = $this->email['before'].$message.$this->email['after'];
146
-        $message = strip_shortcodes($message);
147
-        $message = wptexturize($message);
148
-        $message = wpautop($message);
149
-        $message = str_replace('&lt;&gt; ', '', $message);
150
-        $message = str_replace(']]>', ']]&gt;', $message);
151
-        $message = glsr(Template::class)->build('partials/email/index', [
146
+        $message = strip_shortcodes( $message );
147
+        $message = wptexturize( $message );
148
+        $message = wpautop( $message );
149
+        $message = str_replace( '&lt;&gt; ', '', $message );
150
+        $message = str_replace( ']]>', ']]&gt;', $message );
151
+        $message = glsr( Template::class )->build( 'partials/email/index', [
152 152
             'context' => ['message' => $message],
153
-        ]);
154
-        return apply_filters('site-reviews/email/message', stripslashes($message), 'html', $this);
153
+        ] );
154
+        return apply_filters( 'site-reviews/email/message', stripslashes( $message ), 'html', $this );
155 155
     }
156 156
 
157 157
     /**
158 158
      * @param \WP_Error $error
159 159
      * @return void
160 160
      */
161
-    protected function logMailError($error)
161
+    protected function logMailError( $error )
162 162
     {
163
-        glsr_log()->error('Email was not sent (wp_mail failed)')
164
-            ->debug($this)
165
-            ->debug($error);
163
+        glsr_log()->error( 'Email was not sent (wp_mail failed)' )
164
+            ->debug( $this )
165
+            ->debug( $error );
166 166
     }
167 167
 
168 168
     /**
169 169
      * @return void
170 170
      */
171
-    protected function normalize(array $email = [])
171
+    protected function normalize( array $email = [] )
172 172
     {
173
-        $email = shortcode_atts(glsr(EmailDefaults::class)->defaults(), $email);
174
-        if (empty($email['reply-to'])) {
173
+        $email = shortcode_atts( glsr( EmailDefaults::class )->defaults(), $email );
174
+        if( empty($email['reply-to']) ) {
175 175
             $email['reply-to'] = $email['from'];
176 176
         }
177
-        $this->email = apply_filters('site-reviews/email/compose', $email, $this);
177
+        $this->email = apply_filters( 'site-reviews/email/compose', $email, $this );
178 178
     }
179 179
 
180 180
     /**
@@ -193,21 +193,21 @@  discard block
 block discarded – undo
193 193
     /**
194 194
      * @return string
195 195
      */
196
-    protected function stripHtmlTags($string)
196
+    protected function stripHtmlTags( $string )
197 197
     {
198 198
         // remove invisible elements
199
-        $string = preg_replace('@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string);
199
+        $string = preg_replace( '@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string );
200 200
         // replace certain elements with a line-break
201
-        $string = preg_replace('@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string);
201
+        $string = preg_replace( '@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string );
202 202
         // replace other elements with a space
203
-        $string = preg_replace('@</(td|th)@iu', ' $0', $string);
203
+        $string = preg_replace( '@</(td|th)@iu', ' $0', $string );
204 204
         // add a placeholder for plain-text bullets to list elements
205
-        $string = preg_replace('@<(li)[^>]*?>@siu', '$0-o-^-o-', $string);
205
+        $string = preg_replace( '@<(li)[^>]*?>@siu', '$0-o-^-o-', $string );
206 206
         // strip all remaining HTML tags
207
-        $string = wp_strip_all_tags($string);
208
-        $string = wp_specialchars_decode($string, ENT_QUOTES);
209
-        $string = preg_replace('/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string);
210
-        $string = str_replace('-o-^-o-', ' - ', $string);
211
-        return html_entity_decode($string, ENT_QUOTES, 'UTF-8');
207
+        $string = wp_strip_all_tags( $string );
208
+        $string = wp_specialchars_decode( $string, ENT_QUOTES );
209
+        $string = preg_replace( '/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string );
210
+        $string = str_replace( '-o-^-o-', ' - ', $string );
211
+        return html_entity_decode( $string, ENT_QUOTES, 'UTF-8' );
212 212
     }
213 213
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -134,7 +134,8 @@
 block discarded – undo
134 134
                 ['context' => $this->email['template-tags']], 
135 135
                 $this->email['template']
136 136
             );
137
-        } elseif ($this->email['template']) {
137
+        }
138
+        elseif ($this->email['template']) {
138 139
             $message = glsr(Template::class)->build('templates/'.$this->email['template'], [
139 140
                 'context' => $this->email['template-tags'],
140 141
             ]);
Please login to merge, or discard this patch.
views/partials/notices/welcome.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,3 +1,3 @@
 block discarded – undo
1 1
 <div class="notice notice-info is-dismissible glsr-notice" data-dismiss="welcome">
2
-    <p><?= $text; ?> &mdash; <a class="button button-small" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=welcome'); ?>">See what's new</a></p> 
2
+    <p><?= $text; ?> &mdash; <a class="button button-small" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=welcome' ); ?>">See what's new</a></p> 
3 3
 </div>
Please login to merge, or discard this patch.
plugin/Controllers/NoticeController.php 2 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -8,102 +8,102 @@
 block discarded – undo
8 8
 
9 9
 class NoticeController extends Controller
10 10
 {
11
-    const USER_META_KEY = '_glsr_notices';
11
+	const USER_META_KEY = '_glsr_notices';
12 12
 
13
-    /**
14
-     * @return void
15
-     * @action admin_notices
16
-     */
17
-    public function filterAdminNotices()
18
-    {
19
-        $screen = glsr_current_screen();
20
-        $this->renderWelcomeNotice($screen->post_type);
21
-        $this->renderRebusifyNotice($screen->post_type);
22
-        $this->renderAddonsNotice($screen->id);
23
-    }
13
+	/**
14
+	 * @return void
15
+	 * @action admin_notices
16
+	 */
17
+	public function filterAdminNotices()
18
+	{
19
+		$screen = glsr_current_screen();
20
+		$this->renderWelcomeNotice($screen->post_type);
21
+		$this->renderRebusifyNotice($screen->post_type);
22
+		$this->renderAddonsNotice($screen->id);
23
+	}
24 24
 
25
-    /**
26
-     * @return void
27
-     */
28
-    public function routerDismissNotice(array $request)
29
-    {
30
-        if ($key = Arr::get($request, 'notice')) {
31
-            $this->dismissNotice($key);
32
-        }
33
-    }
25
+	/**
26
+	 * @return void
27
+	 */
28
+	public function routerDismissNotice(array $request)
29
+	{
30
+		if ($key = Arr::get($request, 'notice')) {
31
+			$this->dismissNotice($key);
32
+		}
33
+	}
34 34
 
35
-    /**
36
-     * @param string $key
37
-     * @return void
38
-     */
39
-    protected function dismissNotice($key)
40
-    {
41
-        $this->setUserMeta($key, glsr()->version('major'));
42
-    }
35
+	/**
36
+	 * @param string $key
37
+	 * @return void
38
+	 */
39
+	protected function dismissNotice($key)
40
+	{
41
+		$this->setUserMeta($key, glsr()->version('major'));
42
+	}
43 43
 
44
-    /**
45
-     * @param string $key
46
-     * @param mixed $fallback
47
-     * @return mixed
48
-     */
49
-    protected function getUserMeta($key, $fallback)
50
-    {
51
-        $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true);
52
-        return Arr::get($meta, $key, $fallback);
53
-    }
44
+	/**
45
+	 * @param string $key
46
+	 * @param mixed $fallback
47
+	 * @return mixed
48
+	 */
49
+	protected function getUserMeta($key, $fallback)
50
+	{
51
+		$meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true);
52
+		return Arr::get($meta, $key, $fallback);
53
+	}
54 54
 
55
-    /**
56
-     * @param string $screenId
57
-     * @return void
58
-     */
59
-    protected function renderAddonsNotice($screenId)
60
-    {
61
-        if (Application::POST_TYPE.'_page_addons' == $screenId) {
62
-            echo glsr()->render('partials/notices/addons');
63
-        }
64
-    }
55
+	/**
56
+	 * @param string $screenId
57
+	 * @return void
58
+	 */
59
+	protected function renderAddonsNotice($screenId)
60
+	{
61
+		if (Application::POST_TYPE.'_page_addons' == $screenId) {
62
+			echo glsr()->render('partials/notices/addons');
63
+		}
64
+	}
65 65
 
66
-    /**
67
-     * @param string $screenPostType
68
-     * @return void
69
-     */
70
-    protected function renderRebusifyNotice($screenPostType)
71
-    {
72
-        if (Application::POST_TYPE == $screenPostType
73
-            && version_compare(glsr()->version('major'), $this->getUserMeta('rebusify', 0), '>')
74
-            && !glsr(OptionManager::class)->getBool('settings.general.rebusify')) {
75
-            echo glsr()->render('partials/notices/rebusify');
76
-        }
77
-    }
66
+	/**
67
+	 * @param string $screenPostType
68
+	 * @return void
69
+	 */
70
+	protected function renderRebusifyNotice($screenPostType)
71
+	{
72
+		if (Application::POST_TYPE == $screenPostType
73
+			&& version_compare(glsr()->version('major'), $this->getUserMeta('rebusify', 0), '>')
74
+			&& !glsr(OptionManager::class)->getBool('settings.general.rebusify')) {
75
+			echo glsr()->render('partials/notices/rebusify');
76
+		}
77
+	}
78 78
 
79
-    /**
80
-     * @param string $screenPostType
81
-     * @return void
82
-     */
83
-    protected function renderWelcomeNotice($screenPostType)
84
-    {
85
-        if (Application::POST_TYPE == $screenPostType
86
-            && version_compare(glsr()->version('major'), $this->getUserMeta('welcome', 0), '>')) {
87
-            $welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from')
88
-                ? __('Thanks for installing Site Reviews %s, we hope you love it!', 'site-reviews')
89
-                : __('Thanks for updating to Site Reviews %s, we hope you love the changes!', 'site-reviews');
90
-            echo glsr()->render('partials/notices/welcome', [
91
-                'text' => sprintf($welcomeText, glsr()->version),
92
-            ]);
93
-        }
94
-    }
79
+	/**
80
+	 * @param string $screenPostType
81
+	 * @return void
82
+	 */
83
+	protected function renderWelcomeNotice($screenPostType)
84
+	{
85
+		if (Application::POST_TYPE == $screenPostType
86
+			&& version_compare(glsr()->version('major'), $this->getUserMeta('welcome', 0), '>')) {
87
+			$welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from')
88
+				? __('Thanks for installing Site Reviews %s, we hope you love it!', 'site-reviews')
89
+				: __('Thanks for updating to Site Reviews %s, we hope you love the changes!', 'site-reviews');
90
+			echo glsr()->render('partials/notices/welcome', [
91
+				'text' => sprintf($welcomeText, glsr()->version),
92
+			]);
93
+		}
94
+	}
95 95
 
96
-    /**
97
-     * @param string $key
98
-     * @param mixed $fallback
99
-     * @return mixed
100
-     */
101
-    protected function setUserMeta($key, $value)
102
-    {
103
-        $userId = get_current_user_id();
104
-        $meta = (array) get_user_meta($userId, static::USER_META_KEY, true);
105
-        $meta = array_filter(wp_parse_args($meta, []));
106
-        $meta[$key] = $value;
107
-        update_user_meta($userId, static::USER_META_KEY, $meta);
108
-    }
96
+	/**
97
+	 * @param string $key
98
+	 * @param mixed $fallback
99
+	 * @return mixed
100
+	 */
101
+	protected function setUserMeta($key, $value)
102
+	{
103
+		$userId = get_current_user_id();
104
+		$meta = (array) get_user_meta($userId, static::USER_META_KEY, true);
105
+		$meta = array_filter(wp_parse_args($meta, []));
106
+		$meta[$key] = $value;
107
+		update_user_meta($userId, static::USER_META_KEY, $meta);
108
+	}
109 109
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -17,18 +17,18 @@  discard block
 block discarded – undo
17 17
     public function filterAdminNotices()
18 18
     {
19 19
         $screen = glsr_current_screen();
20
-        $this->renderWelcomeNotice($screen->post_type);
21
-        $this->renderRebusifyNotice($screen->post_type);
22
-        $this->renderAddonsNotice($screen->id);
20
+        $this->renderWelcomeNotice( $screen->post_type );
21
+        $this->renderRebusifyNotice( $screen->post_type );
22
+        $this->renderAddonsNotice( $screen->id );
23 23
     }
24 24
 
25 25
     /**
26 26
      * @return void
27 27
      */
28
-    public function routerDismissNotice(array $request)
28
+    public function routerDismissNotice( array $request )
29 29
     {
30
-        if ($key = Arr::get($request, 'notice')) {
31
-            $this->dismissNotice($key);
30
+        if( $key = Arr::get( $request, 'notice' ) ) {
31
+            $this->dismissNotice( $key );
32 32
         }
33 33
     }
34 34
 
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
      * @param string $key
37 37
      * @return void
38 38
      */
39
-    protected function dismissNotice($key)
39
+    protected function dismissNotice( $key )
40 40
     {
41
-        $this->setUserMeta($key, glsr()->version('major'));
41
+        $this->setUserMeta( $key, glsr()->version( 'major' ) );
42 42
     }
43 43
 
44 44
     /**
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
      * @param mixed $fallback
47 47
      * @return mixed
48 48
      */
49
-    protected function getUserMeta($key, $fallback)
49
+    protected function getUserMeta( $key, $fallback )
50 50
     {
51
-        $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true);
52
-        return Arr::get($meta, $key, $fallback);
51
+        $meta = get_user_meta( get_current_user_id(), static::USER_META_KEY, true );
52
+        return Arr::get( $meta, $key, $fallback );
53 53
     }
54 54
 
55 55
     /**
56 56
      * @param string $screenId
57 57
      * @return void
58 58
      */
59
-    protected function renderAddonsNotice($screenId)
59
+    protected function renderAddonsNotice( $screenId )
60 60
     {
61
-        if (Application::POST_TYPE.'_page_addons' == $screenId) {
62
-            echo glsr()->render('partials/notices/addons');
61
+        if( Application::POST_TYPE.'_page_addons' == $screenId ) {
62
+            echo glsr()->render( 'partials/notices/addons' );
63 63
         }
64 64
     }
65 65
 
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
      * @param string $screenPostType
68 68
      * @return void
69 69
      */
70
-    protected function renderRebusifyNotice($screenPostType)
70
+    protected function renderRebusifyNotice( $screenPostType )
71 71
     {
72
-        if (Application::POST_TYPE == $screenPostType
73
-            && version_compare(glsr()->version('major'), $this->getUserMeta('rebusify', 0), '>')
74
-            && !glsr(OptionManager::class)->getBool('settings.general.rebusify')) {
75
-            echo glsr()->render('partials/notices/rebusify');
72
+        if( Application::POST_TYPE == $screenPostType
73
+            && version_compare( glsr()->version( 'major' ), $this->getUserMeta( 'rebusify', 0 ), '>' )
74
+            && !glsr( OptionManager::class )->getBool( 'settings.general.rebusify' ) ) {
75
+            echo glsr()->render( 'partials/notices/rebusify' );
76 76
         }
77 77
     }
78 78
 
@@ -80,16 +80,16 @@  discard block
 block discarded – undo
80 80
      * @param string $screenPostType
81 81
      * @return void
82 82
      */
83
-    protected function renderWelcomeNotice($screenPostType)
83
+    protected function renderWelcomeNotice( $screenPostType )
84 84
     {
85
-        if (Application::POST_TYPE == $screenPostType
86
-            && version_compare(glsr()->version('major'), $this->getUserMeta('welcome', 0), '>')) {
87
-            $welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from')
88
-                ? __('Thanks for installing Site Reviews %s, we hope you love it!', 'site-reviews')
89
-                : __('Thanks for updating to Site Reviews %s, we hope you love the changes!', 'site-reviews');
90
-            echo glsr()->render('partials/notices/welcome', [
91
-                'text' => sprintf($welcomeText, glsr()->version),
92
-            ]);
85
+        if( Application::POST_TYPE == $screenPostType
86
+            && version_compare( glsr()->version( 'major' ), $this->getUserMeta( 'welcome', 0 ), '>' ) ) {
87
+            $welcomeText = '0.0.0' == glsr( OptionManager::class )->get( 'version_upgraded_from' )
88
+                ? __( 'Thanks for installing Site Reviews %s, we hope you love it!', 'site-reviews' )
89
+                : __( 'Thanks for updating to Site Reviews %s, we hope you love the changes!', 'site-reviews' );
90
+            echo glsr()->render( 'partials/notices/welcome', [
91
+                'text' => sprintf( $welcomeText, glsr()->version ),
92
+            ] );
93 93
         }
94 94
     }
95 95
 
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
      * @param mixed $fallback
99 99
      * @return mixed
100 100
      */
101
-    protected function setUserMeta($key, $value)
101
+    protected function setUserMeta( $key, $value )
102 102
     {
103 103
         $userId = get_current_user_id();
104
-        $meta = (array) get_user_meta($userId, static::USER_META_KEY, true);
105
-        $meta = array_filter(wp_parse_args($meta, []));
104
+        $meta = (array)get_user_meta( $userId, static::USER_META_KEY, true );
105
+        $meta = array_filter( wp_parse_args( $meta, [] ) );
106 106
         $meta[$key] = $value;
107
-        update_user_meta($userId, static::USER_META_KEY, $meta);
107
+        update_user_meta( $userId, static::USER_META_KEY, $meta );
108 108
     }
109 109
 }
Please login to merge, or discard this patch.
plugin/Modules/Translator.php 2 patches
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -6,155 +6,155 @@
 block discarded – undo
6 6
 
7 7
 class Translator
8 8
 {
9
-    /**
10
-     * @param string $translation
11
-     * @param string $text
12
-     * @param string $domain
13
-     * @return string
14
-     * @filter gettext
15
-     */
16
-    public function filterGettext($translation, $text, $domain)
17
-    {
18
-        return $this->translate($translation, $domain, [
19
-            'single' => $text,
20
-        ]);
21
-    }
9
+	/**
10
+	 * @param string $translation
11
+	 * @param string $text
12
+	 * @param string $domain
13
+	 * @return string
14
+	 * @filter gettext
15
+	 */
16
+	public function filterGettext($translation, $text, $domain)
17
+	{
18
+		return $this->translate($translation, $domain, [
19
+			'single' => $text,
20
+		]);
21
+	}
22 22
 
23
-    /**
24
-     * @param string $translation
25
-     * @param string $text
26
-     * @param string $context
27
-     * @param string $domain
28
-     * @return string
29
-     * @filter gettext_with_context
30
-     */
31
-    public function filterGettextWithContext($translation, $text, $context, $domain)
32
-    {
33
-        return $this->translate($translation, $domain, [
34
-            'context' => $context,
35
-            'single' => $text,
36
-        ]);
37
-    }
23
+	/**
24
+	 * @param string $translation
25
+	 * @param string $text
26
+	 * @param string $context
27
+	 * @param string $domain
28
+	 * @return string
29
+	 * @filter gettext_with_context
30
+	 */
31
+	public function filterGettextWithContext($translation, $text, $context, $domain)
32
+	{
33
+		return $this->translate($translation, $domain, [
34
+			'context' => $context,
35
+			'single' => $text,
36
+		]);
37
+	}
38 38
 
39
-    /**
40
-     * @param string $translation
41
-     * @param string $single
42
-     * @param string $plural
43
-     * @param int $number
44
-     * @param string $domain
45
-     * @return string
46
-     * @filter ngettext
47
-     */
48
-    public function filterNgettext($translation, $single, $plural, $number, $domain)
49
-    {
50
-        return $this->translate($translation, $domain, [
51
-            'number' => $number,
52
-            'plural' => $plural,
53
-            'single' => $single,
54
-        ]);
55
-    }
39
+	/**
40
+	 * @param string $translation
41
+	 * @param string $single
42
+	 * @param string $plural
43
+	 * @param int $number
44
+	 * @param string $domain
45
+	 * @return string
46
+	 * @filter ngettext
47
+	 */
48
+	public function filterNgettext($translation, $single, $plural, $number, $domain)
49
+	{
50
+		return $this->translate($translation, $domain, [
51
+			'number' => $number,
52
+			'plural' => $plural,
53
+			'single' => $single,
54
+		]);
55
+	}
56 56
 
57
-    /**
58
-     * @param string $translation
59
-     * @param string $single
60
-     * @param string $plural
61
-     * @param int $number
62
-     * @param string $context
63
-     * @param string $domain
64
-     * @return string
65
-     * @filter ngettext_with_context
66
-     */
67
-    public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain)
68
-    {
69
-        return $this->translate($translation, $domain, [
70
-            'context' => $context,
71
-            'number' => $number,
72
-            'plural' => $plural,
73
-            'single' => $single,
74
-        ]);
75
-    }
57
+	/**
58
+	 * @param string $translation
59
+	 * @param string $single
60
+	 * @param string $plural
61
+	 * @param int $number
62
+	 * @param string $context
63
+	 * @param string $domain
64
+	 * @return string
65
+	 * @filter ngettext_with_context
66
+	 */
67
+	public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain)
68
+	{
69
+		return $this->translate($translation, $domain, [
70
+			'context' => $context,
71
+			'number' => $number,
72
+			'plural' => $plural,
73
+			'single' => $single,
74
+		]);
75
+	}
76 76
 
77
-    /**
78
-     * @param string $original
79
-     * @param string $domain
80
-     * @return string
81
-     */
82
-    public function translate($original, $domain, array $args)
83
-    {
84
-        $domains = apply_filters('site-reviews/translator/domains', [Application::ID]);
85
-        if (!in_array($domain, $domains)) {
86
-            return $original;
87
-        }
88
-        $args = $this->normalizeTranslationArgs($args);
89
-        $strings = $this->getTranslationStrings($args['single'], $args['plural']);
90
-        if (empty($strings)) {
91
-            return $original;
92
-        }
93
-        $string = current($strings);
94
-        return 'plural' == $string['type']
95
-            ? $this->translatePlural($domain, $string, $args)
96
-            : $this->translateSingle($domain, $string, $args);
97
-    }
77
+	/**
78
+	 * @param string $original
79
+	 * @param string $domain
80
+	 * @return string
81
+	 */
82
+	public function translate($original, $domain, array $args)
83
+	{
84
+		$domains = apply_filters('site-reviews/translator/domains', [Application::ID]);
85
+		if (!in_array($domain, $domains)) {
86
+			return $original;
87
+		}
88
+		$args = $this->normalizeTranslationArgs($args);
89
+		$strings = $this->getTranslationStrings($args['single'], $args['plural']);
90
+		if (empty($strings)) {
91
+			return $original;
92
+		}
93
+		$string = current($strings);
94
+		return 'plural' == $string['type']
95
+			? $this->translatePlural($domain, $string, $args)
96
+			: $this->translateSingle($domain, $string, $args);
97
+	}
98 98
 
99
-    /**
100
-     * @param string $single
101
-     * @param string $plural
102
-     * @return array
103
-     */
104
-    protected function getTranslationStrings($single, $plural)
105
-    {
106
-        return array_filter(glsr(Translation::class)->translations(), function ($string) use ($single, $plural) {
107
-            return $string['s1'] == html_entity_decode($single, ENT_COMPAT, 'UTF-8')
108
-                && $string['p1'] == html_entity_decode($plural, ENT_COMPAT, 'UTF-8');
109
-        });
110
-    }
99
+	/**
100
+	 * @param string $single
101
+	 * @param string $plural
102
+	 * @return array
103
+	 */
104
+	protected function getTranslationStrings($single, $plural)
105
+	{
106
+		return array_filter(glsr(Translation::class)->translations(), function ($string) use ($single, $plural) {
107
+			return $string['s1'] == html_entity_decode($single, ENT_COMPAT, 'UTF-8')
108
+				&& $string['p1'] == html_entity_decode($plural, ENT_COMPAT, 'UTF-8');
109
+		});
110
+	}
111 111
 
112
-    /**
113
-     * @return array
114
-     */
115
-    protected function normalizeTranslationArgs(array $args)
116
-    {
117
-        $defaults = [
118
-            'context' => '',
119
-            'number' => 1,
120
-            'plural' => '',
121
-            'single' => '',
122
-        ];
123
-        return shortcode_atts($defaults, $args);
124
-    }
112
+	/**
113
+	 * @return array
114
+	 */
115
+	protected function normalizeTranslationArgs(array $args)
116
+	{
117
+		$defaults = [
118
+			'context' => '',
119
+			'number' => 1,
120
+			'plural' => '',
121
+			'single' => '',
122
+		];
123
+		return shortcode_atts($defaults, $args);
124
+	}
125 125
 
126
-    /**
127
-     * @param string $domain
128
-     * @return string
129
-     */
130
-    protected function translatePlural($domain, array $string, array $args)
131
-    {
132
-        if (!empty($string['s2'])) {
133
-            $args['single'] = $string['s2'];
134
-        }
135
-        if (!empty($string['p2'])) {
136
-            $args['plural'] = $string['p2'];
137
-        }
138
-        return get_translations_for_domain($domain)->translate_plural(
139
-            $args['single'],
140
-            $args['plural'],
141
-            $args['number'],
142
-            $args['context']
143
-        );
144
-    }
126
+	/**
127
+	 * @param string $domain
128
+	 * @return string
129
+	 */
130
+	protected function translatePlural($domain, array $string, array $args)
131
+	{
132
+		if (!empty($string['s2'])) {
133
+			$args['single'] = $string['s2'];
134
+		}
135
+		if (!empty($string['p2'])) {
136
+			$args['plural'] = $string['p2'];
137
+		}
138
+		return get_translations_for_domain($domain)->translate_plural(
139
+			$args['single'],
140
+			$args['plural'],
141
+			$args['number'],
142
+			$args['context']
143
+		);
144
+	}
145 145
 
146
-    /**
147
-     * @param string $domain
148
-     * @return string
149
-     */
150
-    protected function translateSingle($domain, array $string, array $args)
151
-    {
152
-        if (!empty($string['s2'])) {
153
-            $args['single'] = $string['s2'];
154
-        }
155
-        return get_translations_for_domain($domain)->translate(
156
-            $args['single'],
157
-            $args['context']
158
-        );
159
-    }
146
+	/**
147
+	 * @param string $domain
148
+	 * @return string
149
+	 */
150
+	protected function translateSingle($domain, array $string, array $args)
151
+	{
152
+		if (!empty($string['s2'])) {
153
+			$args['single'] = $string['s2'];
154
+		}
155
+		return get_translations_for_domain($domain)->translate(
156
+			$args['single'],
157
+			$args['context']
158
+		);
159
+	}
160 160
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
      * @return string
14 14
      * @filter gettext
15 15
      */
16
-    public function filterGettext($translation, $text, $domain)
16
+    public function filterGettext( $translation, $text, $domain )
17 17
     {
18
-        return $this->translate($translation, $domain, [
18
+        return $this->translate( $translation, $domain, [
19 19
             'single' => $text,
20
-        ]);
20
+        ] );
21 21
     }
22 22
 
23 23
     /**
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
      * @return string
29 29
      * @filter gettext_with_context
30 30
      */
31
-    public function filterGettextWithContext($translation, $text, $context, $domain)
31
+    public function filterGettextWithContext( $translation, $text, $context, $domain )
32 32
     {
33
-        return $this->translate($translation, $domain, [
33
+        return $this->translate( $translation, $domain, [
34 34
             'context' => $context,
35 35
             'single' => $text,
36
-        ]);
36
+        ] );
37 37
     }
38 38
 
39 39
     /**
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
      * @return string
46 46
      * @filter ngettext
47 47
      */
48
-    public function filterNgettext($translation, $single, $plural, $number, $domain)
48
+    public function filterNgettext( $translation, $single, $plural, $number, $domain )
49 49
     {
50
-        return $this->translate($translation, $domain, [
50
+        return $this->translate( $translation, $domain, [
51 51
             'number' => $number,
52 52
             'plural' => $plural,
53 53
             'single' => $single,
54
-        ]);
54
+        ] );
55 55
     }
56 56
 
57 57
     /**
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
      * @return string
65 65
      * @filter ngettext_with_context
66 66
      */
67
-    public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain)
67
+    public function filterNgettextWithContext( $translation, $single, $plural, $number, $context, $domain )
68 68
     {
69
-        return $this->translate($translation, $domain, [
69
+        return $this->translate( $translation, $domain, [
70 70
             'context' => $context,
71 71
             'number' => $number,
72 72
             'plural' => $plural,
73 73
             'single' => $single,
74
-        ]);
74
+        ] );
75 75
     }
76 76
 
77 77
     /**
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
      * @param string $domain
80 80
      * @return string
81 81
      */
82
-    public function translate($original, $domain, array $args)
82
+    public function translate( $original, $domain, array $args )
83 83
     {
84
-        $domains = apply_filters('site-reviews/translator/domains', [Application::ID]);
85
-        if (!in_array($domain, $domains)) {
84
+        $domains = apply_filters( 'site-reviews/translator/domains', [Application::ID] );
85
+        if( !in_array( $domain, $domains ) ) {
86 86
             return $original;
87 87
         }
88
-        $args = $this->normalizeTranslationArgs($args);
89
-        $strings = $this->getTranslationStrings($args['single'], $args['plural']);
90
-        if (empty($strings)) {
88
+        $args = $this->normalizeTranslationArgs( $args );
89
+        $strings = $this->getTranslationStrings( $args['single'], $args['plural'] );
90
+        if( empty($strings) ) {
91 91
             return $original;
92 92
         }
93
-        $string = current($strings);
93
+        $string = current( $strings );
94 94
         return 'plural' == $string['type']
95
-            ? $this->translatePlural($domain, $string, $args)
96
-            : $this->translateSingle($domain, $string, $args);
95
+            ? $this->translatePlural( $domain, $string, $args )
96
+            : $this->translateSingle( $domain, $string, $args );
97 97
     }
98 98
 
99 99
     /**
@@ -101,18 +101,18 @@  discard block
 block discarded – undo
101 101
      * @param string $plural
102 102
      * @return array
103 103
      */
104
-    protected function getTranslationStrings($single, $plural)
104
+    protected function getTranslationStrings( $single, $plural )
105 105
     {
106
-        return array_filter(glsr(Translation::class)->translations(), function ($string) use ($single, $plural) {
107
-            return $string['s1'] == html_entity_decode($single, ENT_COMPAT, 'UTF-8')
108
-                && $string['p1'] == html_entity_decode($plural, ENT_COMPAT, 'UTF-8');
106
+        return array_filter( glsr( Translation::class )->translations(), function( $string ) use ($single, $plural) {
107
+            return $string['s1'] == html_entity_decode( $single, ENT_COMPAT, 'UTF-8' )
108
+                && $string['p1'] == html_entity_decode( $plural, ENT_COMPAT, 'UTF-8' );
109 109
         });
110 110
     }
111 111
 
112 112
     /**
113 113
      * @return array
114 114
      */
115
-    protected function normalizeTranslationArgs(array $args)
115
+    protected function normalizeTranslationArgs( array $args )
116 116
     {
117 117
         $defaults = [
118 118
             'context' => '',
@@ -120,22 +120,22 @@  discard block
 block discarded – undo
120 120
             'plural' => '',
121 121
             'single' => '',
122 122
         ];
123
-        return shortcode_atts($defaults, $args);
123
+        return shortcode_atts( $defaults, $args );
124 124
     }
125 125
 
126 126
     /**
127 127
      * @param string $domain
128 128
      * @return string
129 129
      */
130
-    protected function translatePlural($domain, array $string, array $args)
130
+    protected function translatePlural( $domain, array $string, array $args )
131 131
     {
132
-        if (!empty($string['s2'])) {
132
+        if( !empty($string['s2']) ) {
133 133
             $args['single'] = $string['s2'];
134 134
         }
135
-        if (!empty($string['p2'])) {
135
+        if( !empty($string['p2']) ) {
136 136
             $args['plural'] = $string['p2'];
137 137
         }
138
-        return get_translations_for_domain($domain)->translate_plural(
138
+        return get_translations_for_domain( $domain )->translate_plural(
139 139
             $args['single'],
140 140
             $args['plural'],
141 141
             $args['number'],
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
      * @param string $domain
148 148
      * @return string
149 149
      */
150
-    protected function translateSingle($domain, array $string, array $args)
150
+    protected function translateSingle( $domain, array $string, array $args )
151 151
     {
152
-        if (!empty($string['s2'])) {
152
+        if( !empty($string['s2']) ) {
153 153
             $args['single'] = $string['s2'];
154 154
         }
155
-        return get_translations_for_domain($domain)->translate(
155
+        return get_translations_for_domain( $domain )->translate(
156 156
             $args['single'],
157 157
             $args['context']
158 158
         );
Please login to merge, or discard this patch.