Passed
Push — master ( bc9eb9...4db9fd )
by Paul
06:17
created
plugin/Modules/Upgrader.php 2 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -8,83 +8,83 @@
 block discarded – undo
8 8
 
9 9
 class Upgrader
10 10
 {
11
-    /**
12
-     * @return string
13
-     */
14
-    public $currentVersion;
11
+	/**
12
+	 * @return string
13
+	 */
14
+	public $currentVersion;
15 15
 
16
-    /**
17
-     * @return void
18
-     */
19
-    public function run()
20
-    {
21
-        $filenames = [];
22
-        $iterator = new DirectoryIterator(dirname(__FILE__).'/Upgrader');
23
-        foreach ($iterator as $fileinfo) {
24
-            if ($fileinfo->isFile()) {
25
-                $filenames[] = $fileinfo->getFilename();
26
-            }
27
-        }
28
-        natsort($filenames);
29
-        $this->currentVersion = $this->currentVersion();
30
-        array_walk($filenames, function ($file) {
31
-            $className = str_replace('.php', '', $file);
32
-            $upgradeFromVersion = str_replace(['Upgrade_', '_'], ['', '.'], $className);
33
-            $suffix = preg_replace('/[\d.]+(.+)?/', '${1}', glsr()->version); // allow alpha/beta versions
34
-            if (version_compare($this->currentVersion, $upgradeFromVersion.$suffix, '>=')) {
35
-                return;
36
-            }
37
-            glsr('Modules\\Upgrader\\'.$className);
38
-            glsr_log()->notice('Completed Upgrade for v'.$upgradeFromVersion.$suffix);
39
-        });
40
-        $this->finish();
41
-    }
16
+	/**
17
+	 * @return void
18
+	 */
19
+	public function run()
20
+	{
21
+		$filenames = [];
22
+		$iterator = new DirectoryIterator(dirname(__FILE__).'/Upgrader');
23
+		foreach ($iterator as $fileinfo) {
24
+			if ($fileinfo->isFile()) {
25
+				$filenames[] = $fileinfo->getFilename();
26
+			}
27
+		}
28
+		natsort($filenames);
29
+		$this->currentVersion = $this->currentVersion();
30
+		array_walk($filenames, function ($file) {
31
+			$className = str_replace('.php', '', $file);
32
+			$upgradeFromVersion = str_replace(['Upgrade_', '_'], ['', '.'], $className);
33
+			$suffix = preg_replace('/[\d.]+(.+)?/', '${1}', glsr()->version); // allow alpha/beta versions
34
+			if (version_compare($this->currentVersion, $upgradeFromVersion.$suffix, '>=')) {
35
+				return;
36
+			}
37
+			glsr('Modules\\Upgrader\\'.$className);
38
+			glsr_log()->notice('Completed Upgrade for v'.$upgradeFromVersion.$suffix);
39
+		});
40
+		$this->finish();
41
+	}
42 42
 
43
-    /**
44
-     * @return void
45
-     */
46
-    public function finish()
47
-    {
48
-        if ($this->currentVersion !== glsr()->version) {
49
-            $this->setReviewCounts();
50
-            $this->updateVersionFrom($this->currentVersion);
51
-        } elseif (!glsr(OptionManager::class)->get('last_review_count', false)) {
52
-            $this->setReviewCounts();
53
-        }
54
-    }
43
+	/**
44
+	 * @return void
45
+	 */
46
+	public function finish()
47
+	{
48
+		if ($this->currentVersion !== glsr()->version) {
49
+			$this->setReviewCounts();
50
+			$this->updateVersionFrom($this->currentVersion);
51
+		} elseif (!glsr(OptionManager::class)->get('last_review_count', false)) {
52
+			$this->setReviewCounts();
53
+		}
54
+	}
55 55
 
56
-    /**
57
-     * @return string
58
-     */
59
-    protected function currentVersion()
60
-    {
61
-        $fallback = '0.0.0';
62
-        $majorVersions = [4, 3, 2];
63
-        foreach ($majorVersions as $majorVersion) {
64
-            $settings = get_option(OptionManager::databaseKey($majorVersion));
65
-            $version = Arr::get($settings, 'version', $fallback);
66
-            if (version_compare($version, $fallback, '>')) {
67
-                return $version;
68
-            }
69
-        }
70
-        return $fallback;
71
-    }
56
+	/**
57
+	 * @return string
58
+	 */
59
+	protected function currentVersion()
60
+	{
61
+		$fallback = '0.0.0';
62
+		$majorVersions = [4, 3, 2];
63
+		foreach ($majorVersions as $majorVersion) {
64
+			$settings = get_option(OptionManager::databaseKey($majorVersion));
65
+			$version = Arr::get($settings, 'version', $fallback);
66
+			if (version_compare($version, $fallback, '>')) {
67
+				return $version;
68
+			}
69
+		}
70
+		return $fallback;
71
+	}
72 72
 
73
-    /**
74
-     * @return void
75
-     */
76
-    protected function setReviewCounts()
77
-    {
78
-        add_action('admin_init', 'glsr_calculate_ratings');
79
-    }
73
+	/**
74
+	 * @return void
75
+	 */
76
+	protected function setReviewCounts()
77
+	{
78
+		add_action('admin_init', 'glsr_calculate_ratings');
79
+	}
80 80
 
81
-    /**
82
-     * @param string $previousVersion
83
-     * @return void
84
-     */
85
-    protected function updateVersionFrom($previousVersion)
86
-    {
87
-        glsr(OptionManager::class)->set('version', glsr()->version);
88
-        glsr(OptionManager::class)->set('version_upgraded_from', $previousVersion);
89
-    }
81
+	/**
82
+	 * @param string $previousVersion
83
+	 * @return void
84
+	 */
85
+	protected function updateVersionFrom($previousVersion)
86
+	{
87
+		glsr(OptionManager::class)->set('version', glsr()->version);
88
+		glsr(OptionManager::class)->set('version_upgraded_from', $previousVersion);
89
+	}
90 90
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -19,23 +19,23 @@  discard block
 block discarded – undo
19 19
     public function run()
20 20
     {
21 21
         $filenames = [];
22
-        $iterator = new DirectoryIterator(dirname(__FILE__).'/Upgrader');
23
-        foreach ($iterator as $fileinfo) {
24
-            if ($fileinfo->isFile()) {
22
+        $iterator = new DirectoryIterator( dirname( __FILE__ ).'/Upgrader' );
23
+        foreach( $iterator as $fileinfo ) {
24
+            if( $fileinfo->isFile() ) {
25 25
                 $filenames[] = $fileinfo->getFilename();
26 26
             }
27 27
         }
28
-        natsort($filenames);
28
+        natsort( $filenames );
29 29
         $this->currentVersion = $this->currentVersion();
30
-        array_walk($filenames, function ($file) {
31
-            $className = str_replace('.php', '', $file);
32
-            $upgradeFromVersion = str_replace(['Upgrade_', '_'], ['', '.'], $className);
33
-            $suffix = preg_replace('/[\d.]+(.+)?/', '${1}', glsr()->version); // allow alpha/beta versions
34
-            if (version_compare($this->currentVersion, $upgradeFromVersion.$suffix, '>=')) {
30
+        array_walk( $filenames, function( $file ) {
31
+            $className = str_replace( '.php', '', $file );
32
+            $upgradeFromVersion = str_replace( ['Upgrade_', '_'], ['', '.'], $className );
33
+            $suffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions
34
+            if( version_compare( $this->currentVersion, $upgradeFromVersion.$suffix, '>=' ) ) {
35 35
                 return;
36 36
             }
37
-            glsr('Modules\\Upgrader\\'.$className);
38
-            glsr_log()->notice('Completed Upgrade for v'.$upgradeFromVersion.$suffix);
37
+            glsr( 'Modules\\Upgrader\\'.$className );
38
+            glsr_log()->notice( 'Completed Upgrade for v'.$upgradeFromVersion.$suffix );
39 39
         });
40 40
         $this->finish();
41 41
     }
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function finish()
47 47
     {
48
-        if ($this->currentVersion !== glsr()->version) {
48
+        if( $this->currentVersion !== glsr()->version ) {
49 49
             $this->setReviewCounts();
50
-            $this->updateVersionFrom($this->currentVersion);
51
-        } elseif (!glsr(OptionManager::class)->get('last_review_count', false)) {
50
+            $this->updateVersionFrom( $this->currentVersion );
51
+        } elseif( !glsr( OptionManager::class )->get( 'last_review_count', false ) ) {
52 52
             $this->setReviewCounts();
53 53
         }
54 54
     }
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
     {
61 61
         $fallback = '0.0.0';
62 62
         $majorVersions = [4, 3, 2];
63
-        foreach ($majorVersions as $majorVersion) {
64
-            $settings = get_option(OptionManager::databaseKey($majorVersion));
65
-            $version = Arr::get($settings, 'version', $fallback);
66
-            if (version_compare($version, $fallback, '>')) {
63
+        foreach( $majorVersions as $majorVersion ) {
64
+            $settings = get_option( OptionManager::databaseKey( $majorVersion ) );
65
+            $version = Arr::get( $settings, 'version', $fallback );
66
+            if( version_compare( $version, $fallback, '>' ) ) {
67 67
                 return $version;
68 68
             }
69 69
         }
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
      */
76 76
     protected function setReviewCounts()
77 77
     {
78
-        add_action('admin_init', 'glsr_calculate_ratings');
78
+        add_action( 'admin_init', 'glsr_calculate_ratings' );
79 79
     }
80 80
 
81 81
     /**
82 82
      * @param string $previousVersion
83 83
      * @return void
84 84
      */
85
-    protected function updateVersionFrom($previousVersion)
85
+    protected function updateVersionFrom( $previousVersion )
86 86
     {
87
-        glsr(OptionManager::class)->set('version', glsr()->version);
88
-        glsr(OptionManager::class)->set('version_upgraded_from', $previousVersion);
87
+        glsr( OptionManager::class )->set( 'version', glsr()->version );
88
+        glsr( OptionManager::class )->set( 'version_upgraded_from', $previousVersion );
89 89
     }
90 90
 }
Please login to merge, or discard this patch.
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,Array.prototype.forEach,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,Array.prototype.forEach,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,Array.prototype.forEach,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.