Passed
Push — master ( 4db9fd...925e6d )
by Paul
08:15 queued 04:12
created
plugin/Handlers/EnqueuePublicAssets.php 2 patches
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -9,148 +9,148 @@
 block discarded – undo
9 9
 
10 10
 class EnqueuePublicAssets
11 11
 {
12
-    /**
13
-     * @return void
14
-     */
15
-    public function handle()
16
-    {
17
-        $this->enqueueAssets();
18
-        $this->enqueuePolyfillService();
19
-        $this->enqueueRecaptchaScript();
20
-        $this->inlineScript();
21
-        $this->inlineStyles();
22
-    }
12
+	/**
13
+	 * @return void
14
+	 */
15
+	public function handle()
16
+	{
17
+		$this->enqueueAssets();
18
+		$this->enqueuePolyfillService();
19
+		$this->enqueueRecaptchaScript();
20
+		$this->inlineScript();
21
+		$this->inlineStyles();
22
+	}
23 23
 
24
-    /**
25
-     * @return void
26
-     */
27
-    public function enqueueAssets()
28
-    {
29
-        if (apply_filters('site-reviews/assets/css', true)) {
30
-            wp_enqueue_style(
31
-                Application::ID,
32
-                $this->getStylesheet(),
33
-                [],
34
-                glsr()->version
35
-            );
36
-        }
37
-        if (apply_filters('site-reviews/assets/js', true)) {
38
-            $dependencies = apply_filters('site-reviews/assets/polyfill', true)
39
-                ? [Application::ID.'/polyfill']
40
-                : [];
41
-            $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies);
42
-            wp_enqueue_script(
43
-                Application::ID,
44
-                glsr()->url('assets/scripts/'.Application::ID.'.js'),
45
-                $dependencies,
46
-                glsr()->version,
47
-                true
48
-            );
49
-        }
50
-    }
24
+	/**
25
+	 * @return void
26
+	 */
27
+	public function enqueueAssets()
28
+	{
29
+		if (apply_filters('site-reviews/assets/css', true)) {
30
+			wp_enqueue_style(
31
+				Application::ID,
32
+				$this->getStylesheet(),
33
+				[],
34
+				glsr()->version
35
+			);
36
+		}
37
+		if (apply_filters('site-reviews/assets/js', true)) {
38
+			$dependencies = apply_filters('site-reviews/assets/polyfill', true)
39
+				? [Application::ID.'/polyfill']
40
+				: [];
41
+			$dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies);
42
+			wp_enqueue_script(
43
+				Application::ID,
44
+				glsr()->url('assets/scripts/'.Application::ID.'.js'),
45
+				$dependencies,
46
+				glsr()->version,
47
+				true
48
+			);
49
+		}
50
+	}
51 51
 
52
-    /**
53
-     * @return void
54
-     */
55
-    public function enqueuePolyfillService()
56
-    {
57
-        if (!apply_filters('site-reviews/assets/polyfill', true)) {
58
-            return;
59
-        }
60
-        wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([
61
-            'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver',
62
-            'flags' => 'gated',
63
-        ], 'https://polyfill.io/v3/polyfill.min.js'));
64
-    }
52
+	/**
53
+	 * @return void
54
+	 */
55
+	public function enqueuePolyfillService()
56
+	{
57
+		if (!apply_filters('site-reviews/assets/polyfill', true)) {
58
+			return;
59
+		}
60
+		wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([
61
+			'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver',
62
+			'flags' => 'gated',
63
+		], 'https://polyfill.io/v3/polyfill.min.js'));
64
+	}
65 65
 
66
-    /**
67
-     * @return void
68
-     */
69
-    public function enqueueRecaptchaScript()
70
-    {
71
-        // wpforms-recaptcha
72
-        // google-recaptcha
73
-        // nf-google-recaptcha
74
-        if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
75
-            return;
76
-        }
77
-        $language = apply_filters('site-reviews/recaptcha/language', get_locale());
78
-        wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([
79
-            'hl' => $language,
80
-            'render' => 'explicit',
81
-        ], 'https://www.google.com/recaptcha/api.js'));
82
-    }
66
+	/**
67
+	 * @return void
68
+	 */
69
+	public function enqueueRecaptchaScript()
70
+	{
71
+		// wpforms-recaptcha
72
+		// google-recaptcha
73
+		// nf-google-recaptcha
74
+		if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
75
+			return;
76
+		}
77
+		$language = apply_filters('site-reviews/recaptcha/language', get_locale());
78
+		wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([
79
+			'hl' => $language,
80
+			'render' => 'explicit',
81
+		], 'https://www.google.com/recaptcha/api.js'));
82
+	}
83 83
 
84
-    /**
85
-     * @return void
86
-     */
87
-    public function inlineScript()
88
-    {
89
-        $variables = [
90
-            'action' => Application::PREFIX.'action',
91
-            'ajaxpagination' => $this->getFixedSelectorsForPagination(),
92
-            'ajaxurl' => admin_url('admin-ajax.php'),
93
-            'nameprefix' => Application::ID,
94
-            'validationconfig' => glsr(Style::class)->validation,
95
-            'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(),
96
-        ];
97
-        $variables = apply_filters('site-reviews/enqueue/public/localize', $variables);
98
-        wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before');
99
-    }
84
+	/**
85
+	 * @return void
86
+	 */
87
+	public function inlineScript()
88
+	{
89
+		$variables = [
90
+			'action' => Application::PREFIX.'action',
91
+			'ajaxpagination' => $this->getFixedSelectorsForPagination(),
92
+			'ajaxurl' => admin_url('admin-ajax.php'),
93
+			'nameprefix' => Application::ID,
94
+			'validationconfig' => glsr(Style::class)->validation,
95
+			'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(),
96
+		];
97
+		$variables = apply_filters('site-reviews/enqueue/public/localize', $variables);
98
+		wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before');
99
+	}
100 100
 
101
-    /**
102
-     * @return void
103
-     */
104
-    public function inlineStyles()
105
-    {
106
-        $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css');
107
-        if (!apply_filters('site-reviews/assets/css', true)) {
108
-            return;
109
-        }
110
-        if (!file_exists($inlineStylesheetPath)) {
111
-            glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath);
112
-            return;
113
-        }
114
-        $inlineStylesheetValues = glsr()->config('inline-styles');
115
-        $stylesheet = str_replace(
116
-            array_keys($inlineStylesheetValues),
117
-            array_values($inlineStylesheetValues),
118
-            file_get_contents($inlineStylesheetPath)
119
-        );
120
-        wp_add_inline_style(Application::ID, $stylesheet);
121
-    }
101
+	/**
102
+	 * @return void
103
+	 */
104
+	public function inlineStyles()
105
+	{
106
+		$inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css');
107
+		if (!apply_filters('site-reviews/assets/css', true)) {
108
+			return;
109
+		}
110
+		if (!file_exists($inlineStylesheetPath)) {
111
+			glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath);
112
+			return;
113
+		}
114
+		$inlineStylesheetValues = glsr()->config('inline-styles');
115
+		$stylesheet = str_replace(
116
+			array_keys($inlineStylesheetValues),
117
+			array_values($inlineStylesheetValues),
118
+			file_get_contents($inlineStylesheetPath)
119
+		);
120
+		wp_add_inline_style(Application::ID, $stylesheet);
121
+	}
122 122
 
123
-    /**
124
-     * @return string
125
-     */
126
-    protected function buildInlineScript(array $variables)
127
-    {
128
-        $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});';
129
-        foreach ($variables as $key => $value) {
130
-            $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
131
-        }
132
-        $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys
133
-        $optimizedScript = preg_replace($pattern, '$1$2', $script);
134
-        return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables);
135
-    }
123
+	/**
124
+	 * @return string
125
+	 */
126
+	protected function buildInlineScript(array $variables)
127
+	{
128
+		$script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});';
129
+		foreach ($variables as $key => $value) {
130
+			$script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
131
+		}
132
+		$pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys
133
+		$optimizedScript = preg_replace($pattern, '$1$2', $script);
134
+		return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables);
135
+	}
136 136
 
137
-    /**
138
-     * @return array
139
-     */
140
-    protected function getFixedSelectorsForPagination()
141
-    {
142
-        $selectors = ['#wpadminbar', '.site-navigation-fixed'];
143
-        return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors);
144
-    }
137
+	/**
138
+	 * @return array
139
+	 */
140
+	protected function getFixedSelectorsForPagination()
141
+	{
142
+		$selectors = ['#wpadminbar', '.site-navigation-fixed'];
143
+		return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors);
144
+	}
145 145
 
146
-    /**
147
-     * @return string
148
-     */
149
-    protected function getStylesheet()
150
-    {
151
-        $currentStyle = glsr(Style::class)->style;
152
-        return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css'))
153
-            ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css')
154
-            : glsr()->url('assets/styles/'.Application::ID.'.css');
155
-    }
146
+	/**
147
+	 * @return string
148
+	 */
149
+	protected function getStylesheet()
150
+	{
151
+		$currentStyle = glsr(Style::class)->style;
152
+		return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css'))
153
+			? glsr()->url('assets/styles/custom/'.$currentStyle.'.css')
154
+			: glsr()->url('assets/styles/'.Application::ID.'.css');
155
+	}
156 156
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      */
27 27
     public function enqueueAssets()
28 28
     {
29
-        if (apply_filters('site-reviews/assets/css', true)) {
29
+        if( apply_filters( 'site-reviews/assets/css', true ) ) {
30 30
             wp_enqueue_style(
31 31
                 Application::ID,
32 32
                 $this->getStylesheet(),
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
                 glsr()->version
35 35
             );
36 36
         }
37
-        if (apply_filters('site-reviews/assets/js', true)) {
38
-            $dependencies = apply_filters('site-reviews/assets/polyfill', true)
37
+        if( apply_filters( 'site-reviews/assets/js', true ) ) {
38
+            $dependencies = apply_filters( 'site-reviews/assets/polyfill', true )
39 39
                 ? [Application::ID.'/polyfill']
40 40
                 : [];
41
-            $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies);
41
+            $dependencies = apply_filters( 'site-reviews/enqueue/public/dependencies', $dependencies );
42 42
             wp_enqueue_script(
43 43
                 Application::ID,
44
-                glsr()->url('assets/scripts/'.Application::ID.'.js'),
44
+                glsr()->url( 'assets/scripts/'.Application::ID.'.js' ),
45 45
                 $dependencies,
46 46
                 glsr()->version,
47 47
                 true
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function enqueuePolyfillService()
56 56
     {
57
-        if (!apply_filters('site-reviews/assets/polyfill', true)) {
57
+        if( !apply_filters( 'site-reviews/assets/polyfill', true ) ) {
58 58
             return;
59 59
         }
60
-        wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([
60
+        wp_enqueue_script( Application::ID.'/polyfill', add_query_arg( [
61 61
             'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver',
62 62
             'flags' => 'gated',
63
-        ], 'https://polyfill.io/v3/polyfill.min.js'));
63
+        ], 'https://polyfill.io/v3/polyfill.min.js' ) );
64 64
     }
65 65
 
66 66
     /**
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
         // wpforms-recaptcha
72 72
         // google-recaptcha
73 73
         // nf-google-recaptcha
74
-        if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
74
+        if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) {
75 75
             return;
76 76
         }
77
-        $language = apply_filters('site-reviews/recaptcha/language', get_locale());
78
-        wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([
77
+        $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() );
78
+        wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg( [
79 79
             'hl' => $language,
80 80
             'render' => 'explicit',
81
-        ], 'https://www.google.com/recaptcha/api.js'));
81
+        ], 'https://www.google.com/recaptcha/api.js' ) );
82 82
     }
83 83
 
84 84
     /**
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
         $variables = [
90 90
             'action' => Application::PREFIX.'action',
91 91
             'ajaxpagination' => $this->getFixedSelectorsForPagination(),
92
-            'ajaxurl' => admin_url('admin-ajax.php'),
92
+            'ajaxurl' => admin_url( 'admin-ajax.php' ),
93 93
             'nameprefix' => Application::ID,
94
-            'validationconfig' => glsr(Style::class)->validation,
95
-            'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(),
94
+            'validationconfig' => glsr( Style::class )->validation,
95
+            'validationstrings' => glsr( ValidationStringsDefaults::class )->defaults(),
96 96
         ];
97
-        $variables = apply_filters('site-reviews/enqueue/public/localize', $variables);
98
-        wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before');
97
+        $variables = apply_filters( 'site-reviews/enqueue/public/localize', $variables );
98
+        wp_add_inline_script( Application::ID, $this->buildInlineScript( $variables ), 'before' );
99 99
     }
100 100
 
101 101
     /**
@@ -103,35 +103,35 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function inlineStyles()
105 105
     {
106
-        $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css');
107
-        if (!apply_filters('site-reviews/assets/css', true)) {
106
+        $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' );
107
+        if( !apply_filters( 'site-reviews/assets/css', true ) ) {
108 108
             return;
109 109
         }
110
-        if (!file_exists($inlineStylesheetPath)) {
111
-            glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath);
110
+        if( !file_exists( $inlineStylesheetPath ) ) {
111
+            glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath );
112 112
             return;
113 113
         }
114
-        $inlineStylesheetValues = glsr()->config('inline-styles');
114
+        $inlineStylesheetValues = glsr()->config( 'inline-styles' );
115 115
         $stylesheet = str_replace(
116
-            array_keys($inlineStylesheetValues),
117
-            array_values($inlineStylesheetValues),
118
-            file_get_contents($inlineStylesheetPath)
116
+            array_keys( $inlineStylesheetValues ),
117
+            array_values( $inlineStylesheetValues ),
118
+            file_get_contents( $inlineStylesheetPath )
119 119
         );
120
-        wp_add_inline_style(Application::ID, $stylesheet);
120
+        wp_add_inline_style( Application::ID, $stylesheet );
121 121
     }
122 122
 
123 123
     /**
124 124
      * @return string
125 125
      */
126
-    protected function buildInlineScript(array $variables)
126
+    protected function buildInlineScript( array $variables )
127 127
     {
128 128
         $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});';
129
-        foreach ($variables as $key => $value) {
130
-            $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
129
+        foreach( $variables as $key => $value ) {
130
+            $script .= sprintf( 'GLSR.%s=%s;', $key, json_encode( $value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) );
131 131
         }
132 132
         $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys
133
-        $optimizedScript = preg_replace($pattern, '$1$2', $script);
134
-        return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables);
133
+        $optimizedScript = preg_replace( $pattern, '$1$2', $script );
134
+        return apply_filters( 'site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables );
135 135
     }
136 136
 
137 137
     /**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     protected function getFixedSelectorsForPagination()
141 141
     {
142 142
         $selectors = ['#wpadminbar', '.site-navigation-fixed'];
143
-        return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors);
143
+        return apply_filters( 'site-reviews/enqueue/public/localize/ajax-pagination', $selectors );
144 144
     }
145 145
 
146 146
     /**
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
      */
149 149
     protected function getStylesheet()
150 150
     {
151
-        $currentStyle = glsr(Style::class)->style;
152
-        return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css'))
153
-            ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css')
154
-            : glsr()->url('assets/styles/'.Application::ID.'.css');
151
+        $currentStyle = glsr( Style::class )->style;
152
+        return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' ) )
153
+            ? glsr()->url( 'assets/styles/custom/'.$currentStyle.'.css' )
154
+            : glsr()->url( 'assets/styles/'.Application::ID.'.css' );
155 155
     }
156 156
 }
Please login to merge, or discard this patch.
plugin/Controllers/SettingsController.php 2 patches
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -9,120 +9,120 @@
 block discarded – undo
9 9
 
10 10
 class SettingsController extends Controller
11 11
 {
12
-    /**
13
-     * @param mixed $input
14
-     * @return array
15
-     * @callback register_setting
16
-     */
17
-    public function callbackRegisterSettings($input)
18
-    {
19
-        $settings = Arr::consolidateArray($input);
20
-        if (1 === count($settings) && array_key_exists('settings', $settings)) {
21
-            $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input);
22
-            $options = $this->sanitizeGeneral($input, $options);
23
-            $options = $this->sanitizeSubmissions($input, $options);
24
-            $options = $this->sanitizeTranslations($input, $options);
25
-            $options = apply_filters('site-reviews/settings/callback', $options, $settings);
26
-            if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') {
27
-                glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews'));
28
-            }
29
-            return $options;
30
-        }
31
-        return $input;
32
-    }
12
+	/**
13
+	 * @param mixed $input
14
+	 * @return array
15
+	 * @callback register_setting
16
+	 */
17
+	public function callbackRegisterSettings($input)
18
+	{
19
+		$settings = Arr::consolidateArray($input);
20
+		if (1 === count($settings) && array_key_exists('settings', $settings)) {
21
+			$options = array_replace_recursive(glsr(OptionManager::class)->all(), $input);
22
+			$options = $this->sanitizeGeneral($input, $options);
23
+			$options = $this->sanitizeSubmissions($input, $options);
24
+			$options = $this->sanitizeTranslations($input, $options);
25
+			$options = apply_filters('site-reviews/settings/callback', $options, $settings);
26
+			if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') {
27
+				glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews'));
28
+			}
29
+			return $options;
30
+		}
31
+		return $input;
32
+	}
33 33
 
34
-    /**
35
-     * @return void
36
-     * @action admin_init
37
-     */
38
-    public function registerSettings()
39
-    {
40
-        register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [
41
-            'sanitize_callback' => [$this, 'callbackRegisterSettings'],
42
-        ]);
43
-    }
34
+	/**
35
+	 * @return void
36
+	 * @action admin_init
37
+	 */
38
+	public function registerSettings()
39
+	{
40
+		register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [
41
+			'sanitize_callback' => [$this, 'callbackRegisterSettings'],
42
+		]);
43
+	}
44 44
 
45
-    /**
46
-     * @return array
47
-     */
48
-    protected function sanitizeGeneral(array $input, array $options)
49
-    {
50
-        $key = 'settings.general';
51
-        $inputForm = Arr::get($input, $key);
52
-        if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) {
53
-            $options = Arr::set($options, $key.'.multilingual', '');
54
-        }
55
-        if ('' == trim(Arr::get($inputForm, 'notification_message'))) {
56
-            $defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message');
57
-            $options = Arr::set($options, $key.'.notification_message', $defaultValue);
58
-        }
59
-        $defaultValue = Arr::get($inputForm, 'notifications', []);
60
-        $options = Arr::set($options, $key.'.notifications', $defaultValue);
61
-        return $options;
62
-    }
45
+	/**
46
+	 * @return array
47
+	 */
48
+	protected function sanitizeGeneral(array $input, array $options)
49
+	{
50
+		$key = 'settings.general';
51
+		$inputForm = Arr::get($input, $key);
52
+		if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) {
53
+			$options = Arr::set($options, $key.'.multilingual', '');
54
+		}
55
+		if ('' == trim(Arr::get($inputForm, 'notification_message'))) {
56
+			$defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message');
57
+			$options = Arr::set($options, $key.'.notification_message', $defaultValue);
58
+		}
59
+		$defaultValue = Arr::get($inputForm, 'notifications', []);
60
+		$options = Arr::set($options, $key.'.notifications', $defaultValue);
61
+		return $options;
62
+	}
63 63
 
64
-    /**
65
-     * @return array
66
-     */
67
-    protected function sanitizeSubmissions(array $input, array $options)
68
-    {
69
-        $key = 'settings.submissions';
70
-        $inputForm = Arr::get($input, $key);
71
-        $defaultValue = isset($inputForm['required'])
72
-            ? $inputForm['required']
73
-            : [];
74
-        $options = Arr::set($options, $key.'.required', $defaultValue);
75
-        return $options;
76
-    }
64
+	/**
65
+	 * @return array
66
+	 */
67
+	protected function sanitizeSubmissions(array $input, array $options)
68
+	{
69
+		$key = 'settings.submissions';
70
+		$inputForm = Arr::get($input, $key);
71
+		$defaultValue = isset($inputForm['required'])
72
+			? $inputForm['required']
73
+			: [];
74
+		$options = Arr::set($options, $key.'.required', $defaultValue);
75
+		return $options;
76
+	}
77 77
 
78
-    /**
79
-     * @return array
80
-     */
81
-    protected function sanitizeTranslations(array $input, array $options)
82
-    {
83
-        $key = 'settings.strings';
84
-        $inputForm = Arr::consolidateArray(Arr::get($input, $key));
85
-        if (!empty($inputForm)) {
86
-            $options = Arr::set($options, $key, array_values(array_filter($inputForm)));
87
-            $allowedTags = [
88
-                'a' => ['class' => [], 'href' => [], 'target' => []],
89
-                'span' => ['class' => []],
90
-            ];
91
-            array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) {
92
-                if (isset($string['s2'])) {
93
-                    $string['s2'] = wp_kses($string['s2'], $allowedTags);
94
-                }
95
-                if (isset($string['p2'])) {
96
-                    $string['p2'] = wp_kses($string['p2'], $allowedTags);
97
-                }
98
-            });
99
-        }
100
-        return $options;
101
-    }
78
+	/**
79
+	 * @return array
80
+	 */
81
+	protected function sanitizeTranslations(array $input, array $options)
82
+	{
83
+		$key = 'settings.strings';
84
+		$inputForm = Arr::consolidateArray(Arr::get($input, $key));
85
+		if (!empty($inputForm)) {
86
+			$options = Arr::set($options, $key, array_values(array_filter($inputForm)));
87
+			$allowedTags = [
88
+				'a' => ['class' => [], 'href' => [], 'target' => []],
89
+				'span' => ['class' => []],
90
+			];
91
+			array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) {
92
+				if (isset($string['s2'])) {
93
+					$string['s2'] = wp_kses($string['s2'], $allowedTags);
94
+				}
95
+				if (isset($string['p2'])) {
96
+					$string['p2'] = wp_kses($string['p2'], $allowedTags);
97
+				}
98
+			});
99
+		}
100
+		return $options;
101
+	}
102 102
 
103
-    /**
104
-     * @return bool
105
-     */
106
-    protected function hasMultilingualIntegration($integration)
107
-    {
108
-        if (!in_array($integration, ['polylang', 'wpml'])) {
109
-            return false;
110
-        }
111
-        $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst($integration);
112
-        if (!glsr($integrationClass)->isActive()) {
113
-            glsr(Notice::class)->addError(sprintf(
114
-                __('Please install/activate the %s plugin to enable integration.', 'site-reviews'),
115
-                constant($integrationClass.'::PLUGIN_NAME')
116
-            ));
117
-            return false;
118
-        } elseif (!glsr($integrationClass)->isSupported()) {
119
-            glsr(Notice::class)->addError(sprintf(
120
-                __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'),
121
-                constant($integrationClass.'::PLUGIN_NAME'),
122
-                constant($integrationClass.'::SUPPORTED_VERSION')
123
-            ));
124
-            return false;
125
-        }
126
-        return true;
127
-    }
103
+	/**
104
+	 * @return bool
105
+	 */
106
+	protected function hasMultilingualIntegration($integration)
107
+	{
108
+		if (!in_array($integration, ['polylang', 'wpml'])) {
109
+			return false;
110
+		}
111
+		$integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst($integration);
112
+		if (!glsr($integrationClass)->isActive()) {
113
+			glsr(Notice::class)->addError(sprintf(
114
+				__('Please install/activate the %s plugin to enable integration.', 'site-reviews'),
115
+				constant($integrationClass.'::PLUGIN_NAME')
116
+			));
117
+			return false;
118
+		} elseif (!glsr($integrationClass)->isSupported()) {
119
+			glsr(Notice::class)->addError(sprintf(
120
+				__('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'),
121
+				constant($integrationClass.'::PLUGIN_NAME'),
122
+				constant($integrationClass.'::SUPPORTED_VERSION')
123
+			));
124
+			return false;
125
+		}
126
+		return true;
127
+	}
128 128
 }
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -14,17 +14,17 @@  discard block
 block discarded – undo
14 14
      * @return array
15 15
      * @callback register_setting
16 16
      */
17
-    public function callbackRegisterSettings($input)
17
+    public function callbackRegisterSettings( $input )
18 18
     {
19
-        $settings = Arr::consolidateArray($input);
20
-        if (1 === count($settings) && array_key_exists('settings', $settings)) {
21
-            $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input);
22
-            $options = $this->sanitizeGeneral($input, $options);
23
-            $options = $this->sanitizeSubmissions($input, $options);
24
-            $options = $this->sanitizeTranslations($input, $options);
25
-            $options = apply_filters('site-reviews/settings/callback', $options, $settings);
26
-            if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') {
27
-                glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews'));
19
+        $settings = Arr::consolidateArray( $input );
20
+        if( 1 === count( $settings ) && array_key_exists( 'settings', $settings ) ) {
21
+            $options = array_replace_recursive( glsr( OptionManager::class )->all(), $input );
22
+            $options = $this->sanitizeGeneral( $input, $options );
23
+            $options = $this->sanitizeSubmissions( $input, $options );
24
+            $options = $this->sanitizeTranslations( $input, $options );
25
+            $options = apply_filters( 'site-reviews/settings/callback', $options, $settings );
26
+            if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) {
27
+                glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) );
28 28
             }
29 29
             return $options;
30 30
         }
@@ -37,63 +37,63 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function registerSettings()
39 39
     {
40
-        register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [
40
+        register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [
41 41
             'sanitize_callback' => [$this, 'callbackRegisterSettings'],
42
-        ]);
42
+        ] );
43 43
     }
44 44
 
45 45
     /**
46 46
      * @return array
47 47
      */
48
-    protected function sanitizeGeneral(array $input, array $options)
48
+    protected function sanitizeGeneral( array $input, array $options )
49 49
     {
50 50
         $key = 'settings.general';
51
-        $inputForm = Arr::get($input, $key);
52
-        if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) {
53
-            $options = Arr::set($options, $key.'.multilingual', '');
51
+        $inputForm = Arr::get( $input, $key );
52
+        if( !$this->hasMultilingualIntegration( Arr::get( $inputForm, 'multilingual' ) ) ) {
53
+            $options = Arr::set( $options, $key.'.multilingual', '' );
54 54
         }
55
-        if ('' == trim(Arr::get($inputForm, 'notification_message'))) {
56
-            $defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message');
57
-            $options = Arr::set($options, $key.'.notification_message', $defaultValue);
55
+        if( '' == trim( Arr::get( $inputForm, 'notification_message' ) ) ) {
56
+            $defaultValue = Arr::get( glsr()->defaults, $key.'.notification_message' );
57
+            $options = Arr::set( $options, $key.'.notification_message', $defaultValue );
58 58
         }
59
-        $defaultValue = Arr::get($inputForm, 'notifications', []);
60
-        $options = Arr::set($options, $key.'.notifications', $defaultValue);
59
+        $defaultValue = Arr::get( $inputForm, 'notifications', [] );
60
+        $options = Arr::set( $options, $key.'.notifications', $defaultValue );
61 61
         return $options;
62 62
     }
63 63
 
64 64
     /**
65 65
      * @return array
66 66
      */
67
-    protected function sanitizeSubmissions(array $input, array $options)
67
+    protected function sanitizeSubmissions( array $input, array $options )
68 68
     {
69 69
         $key = 'settings.submissions';
70
-        $inputForm = Arr::get($input, $key);
70
+        $inputForm = Arr::get( $input, $key );
71 71
         $defaultValue = isset($inputForm['required'])
72 72
             ? $inputForm['required']
73 73
             : [];
74
-        $options = Arr::set($options, $key.'.required', $defaultValue);
74
+        $options = Arr::set( $options, $key.'.required', $defaultValue );
75 75
         return $options;
76 76
     }
77 77
 
78 78
     /**
79 79
      * @return array
80 80
      */
81
-    protected function sanitizeTranslations(array $input, array $options)
81
+    protected function sanitizeTranslations( array $input, array $options )
82 82
     {
83 83
         $key = 'settings.strings';
84
-        $inputForm = Arr::consolidateArray(Arr::get($input, $key));
85
-        if (!empty($inputForm)) {
86
-            $options = Arr::set($options, $key, array_values(array_filter($inputForm)));
84
+        $inputForm = Arr::consolidateArray( Arr::get( $input, $key ) );
85
+        if( !empty($inputForm) ) {
86
+            $options = Arr::set( $options, $key, array_values( array_filter( $inputForm ) ) );
87 87
             $allowedTags = [
88 88
                 'a' => ['class' => [], 'href' => [], 'target' => []],
89 89
                 'span' => ['class' => []],
90 90
             ];
91
-            array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) {
92
-                if (isset($string['s2'])) {
93
-                    $string['s2'] = wp_kses($string['s2'], $allowedTags);
91
+            array_walk( $options['settings']['strings'], function( &$string ) use ($allowedTags) {
92
+                if( isset($string['s2']) ) {
93
+                    $string['s2'] = wp_kses( $string['s2'], $allowedTags );
94 94
                 }
95
-                if (isset($string['p2'])) {
96
-                    $string['p2'] = wp_kses($string['p2'], $allowedTags);
95
+                if( isset($string['p2']) ) {
96
+                    $string['p2'] = wp_kses( $string['p2'], $allowedTags );
97 97
                 }
98 98
             });
99 99
         }
@@ -103,24 +103,24 @@  discard block
 block discarded – undo
103 103
     /**
104 104
      * @return bool
105 105
      */
106
-    protected function hasMultilingualIntegration($integration)
106
+    protected function hasMultilingualIntegration( $integration )
107 107
     {
108
-        if (!in_array($integration, ['polylang', 'wpml'])) {
108
+        if( !in_array( $integration, ['polylang', 'wpml'] ) ) {
109 109
             return false;
110 110
         }
111
-        $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst($integration);
112
-        if (!glsr($integrationClass)->isActive()) {
113
-            glsr(Notice::class)->addError(sprintf(
114
-                __('Please install/activate the %s plugin to enable integration.', 'site-reviews'),
115
-                constant($integrationClass.'::PLUGIN_NAME')
116
-            ));
111
+        $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst( $integration );
112
+        if( !glsr( $integrationClass )->isActive() ) {
113
+            glsr( Notice::class )->addError( sprintf(
114
+                __( 'Please install/activate the %s plugin to enable integration.', 'site-reviews' ),
115
+                constant( $integrationClass.'::PLUGIN_NAME' )
116
+            ) );
117 117
             return false;
118
-        } elseif (!glsr($integrationClass)->isSupported()) {
119
-            glsr(Notice::class)->addError(sprintf(
120
-                __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'),
121
-                constant($integrationClass.'::PLUGIN_NAME'),
122
-                constant($integrationClass.'::SUPPORTED_VERSION')
123
-            ));
118
+        } elseif( !glsr( $integrationClass )->isSupported() ) {
119
+            glsr( Notice::class )->addError( sprintf(
120
+                __( 'Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews' ),
121
+                constant( $integrationClass.'::PLUGIN_NAME' ),
122
+                constant( $integrationClass.'::SUPPORTED_VERSION' )
123
+            ) );
124 124
             return false;
125 125
         }
126 126
         return true;
Please login to merge, or discard this patch.
plugin/Defaults/StyleValidationDefaults.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -6,23 +6,23 @@
 block discarded – undo
6 6
 
7 7
 class StyleValidationDefaults extends Defaults
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    protected function defaults()
13
-    {
14
-        return [
15
-            'error_tag' => 'div',
16
-            'error_tag_class' => 'glsr-field-error',
17
-            'field_class' => 'glsr-field',
18
-            'field_error_class' => 'glsr-has-error',
19
-            'input_error_class' => 'glsr-is-invalid',
20
-            'input_valid_class' => 'glsr-is-valid',
21
-            'message_error_class' => 'glsr-has-errors',
22
-            'message_initial_class' => 'glsr-is-visible',
23
-            'message_success_class' => 'glsr-has-success',
24
-            'message_tag' => 'div',
25
-            'message_tag_class' => 'glsr-form-message',
26
-        ];
27
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	protected function defaults()
13
+	{
14
+		return [
15
+			'error_tag' => 'div',
16
+			'error_tag_class' => 'glsr-field-error',
17
+			'field_class' => 'glsr-field',
18
+			'field_error_class' => 'glsr-has-error',
19
+			'input_error_class' => 'glsr-is-invalid',
20
+			'input_valid_class' => 'glsr-is-valid',
21
+			'message_error_class' => 'glsr-has-errors',
22
+			'message_initial_class' => 'glsr-is-visible',
23
+			'message_success_class' => 'glsr-has-success',
24
+			'message_tag' => 'div',
25
+			'message_tag_class' => 'glsr-form-message',
26
+		];
27
+	}
28 28
 }
Please login to merge, or discard this patch.