Passed
Push — feature/rebusify ( 0fe5b2...103190 )
by Paul
08:37 queued 03:55
created
plugin/Helper.php 2 patches
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -9,125 +9,125 @@
 block discarded – undo
9 9
 
10 10
 class Helper
11 11
 {
12
-    use Arr;
13
-    use Str;
12
+	use Arr;
13
+	use Str;
14 14
 
15
-    /**
16
-     * @param string $name
17
-     * @param string $path
18
-     * @return string
19
-     */
20
-    public function buildClassName($name, $path = '')
21
-    {
22
-        $className = $this->camelCase($name);
23
-        $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
24
-        return !empty($path)
25
-            ? __NAMESPACE__.'\\'.$path.'\\'.$className
26
-            : $className;
27
-    }
15
+	/**
16
+	 * @param string $name
17
+	 * @param string $path
18
+	 * @return string
19
+	 */
20
+	public function buildClassName($name, $path = '')
21
+	{
22
+		$className = $this->camelCase($name);
23
+		$path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
24
+		return !empty($path)
25
+			? __NAMESPACE__.'\\'.$path.'\\'.$className
26
+			: $className;
27
+	}
28 28
 
29
-    /**
30
-     * @param string $name
31
-     * @param string $prefix
32
-     * @return string
33
-     */
34
-    public function buildMethodName($name, $prefix = '')
35
-    {
36
-        return lcfirst($prefix.$this->buildClassName($name));
37
-    }
29
+	/**
30
+	 * @param string $name
31
+	 * @param string $prefix
32
+	 * @return string
33
+	 */
34
+	public function buildMethodName($name, $prefix = '')
35
+	{
36
+		return lcfirst($prefix.$this->buildClassName($name));
37
+	}
38 38
 
39
-    /**
40
-     * @param string $name
41
-     * @return string
42
-     */
43
-    public function buildPropertyName($name)
44
-    {
45
-        return lcfirst($this->buildClassName($name));
46
-    }
39
+	/**
40
+	 * @param string $name
41
+	 * @return string
42
+	 */
43
+	public function buildPropertyName($name)
44
+	{
45
+		return lcfirst($this->buildClassName($name));
46
+	}
47 47
 
48
-    /**
49
-     * @param string $cast
50
-     * @param mixed $value
51
-     * @return mixed
52
-     */
53
-    public function castTo($cast = '', $value)
54
-    {
55
-        switch ($cast) {
56
-            case 'array':
57
-                return (array) $value;
58
-            case 'boolean':
59
-                return filter_var($value, FILTER_VALIDATE_BOOLEAN);
60
-            case 'float':
61
-                return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
62
-            case 'integer':
63
-                return (int) filter_var($value, FILTER_VALIDATE_INT);
64
-            case 'object':
65
-                return (object) (array) $value;
66
-            case 'string':
67
-                if (is_object($value) && in_array('__toString', get_class_methods($value))) {
68
-                    return (string) $value->__toString();
69
-                }
70
-                if (is_array($value) || is_object($value)) {
71
-                    return serialize($value);
72
-                }
73
-                return (string) $value;
74
-            default:
75
-                return $value;
76
-        }
77
-    }
48
+	/**
49
+	 * @param string $cast
50
+	 * @param mixed $value
51
+	 * @return mixed
52
+	 */
53
+	public function castTo($cast = '', $value)
54
+	{
55
+		switch ($cast) {
56
+			case 'array':
57
+				return (array) $value;
58
+			case 'boolean':
59
+				return filter_var($value, FILTER_VALIDATE_BOOLEAN);
60
+			case 'float':
61
+				return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
62
+			case 'integer':
63
+				return (int) filter_var($value, FILTER_VALIDATE_INT);
64
+			case 'object':
65
+				return (object) (array) $value;
66
+			case 'string':
67
+				if (is_object($value) && in_array('__toString', get_class_methods($value))) {
68
+					return (string) $value->__toString();
69
+				}
70
+				if (is_array($value) || is_object($value)) {
71
+					return serialize($value);
72
+				}
73
+				return (string) $value;
74
+			default:
75
+				return $value;
76
+		}
77
+	}
78 78
 
79
-    /**
80
-     * @param string $key
81
-     * @return mixed
82
-     */
83
-    public function filterInput($key, array $request = [])
84
-    {
85
-        if (isset($request[$key])) {
86
-            return $request[$key];
87
-        }
88
-        $variable = filter_input(INPUT_POST, $key);
89
-        if (is_null($variable) && isset($_POST[$key])) {
90
-            $variable = $_POST[$key];
91
-        }
92
-        return $variable;
93
-    }
79
+	/**
80
+	 * @param string $key
81
+	 * @return mixed
82
+	 */
83
+	public function filterInput($key, array $request = [])
84
+	{
85
+		if (isset($request[$key])) {
86
+			return $request[$key];
87
+		}
88
+		$variable = filter_input(INPUT_POST, $key);
89
+		if (is_null($variable) && isset($_POST[$key])) {
90
+			$variable = $_POST[$key];
91
+		}
92
+		return $variable;
93
+	}
94 94
 
95
-    /**
96
-     * @param string $key
97
-     * @return array
98
-     */
99
-    public function filterInputArray($key)
100
-    {
101
-        $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
102
-        if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
103
-            $variable = $_POST[$key];
104
-        }
105
-        return (array) $variable;
106
-    }
95
+	/**
96
+	 * @param string $key
97
+	 * @return array
98
+	 */
99
+	public function filterInputArray($key)
100
+	{
101
+		$variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
102
+		if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
103
+			$variable = $_POST[$key];
104
+		}
105
+		return (array) $variable;
106
+	}
107 107
 
108
-    /**
109
-     * @return string
110
-     */
111
-    public function getIpAddress()
112
-    {
113
-        $cloudflareIps = glsr(Cache::class)->getCloudflareIps();
114
-        $ipv6 = defined('AF_INET6')
115
-            ? $cloudflareIps['v6']
116
-            : [];
117
-        $whitelist = apply_filters('site-reviews/whip/whitelist', [
118
-            Whip::CLOUDFLARE_HEADERS => [
119
-                Whip::IPV4 => $cloudflareIps['v4'],
120
-                Whip::IPV6 => $ipv6,
121
-            ],
122
-            Whip::CUSTOM_HEADERS => [
123
-                Whip::IPV4 => ['127.0.0.1'],
124
-                Whip::IPV6 => ['::1'],
125
-            ],
126
-        ]);
127
-        $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
128
-        $methods = apply_filters('site-reviews/whip/methods', $methods);
129
-        $whip = new Whip($methods, $whitelist);
130
-        do_action_ref_array('site-reviews/whip', [$whip]);
131
-        return (string) $whip->getValidIpAddress();
132
-    }
108
+	/**
109
+	 * @return string
110
+	 */
111
+	public function getIpAddress()
112
+	{
113
+		$cloudflareIps = glsr(Cache::class)->getCloudflareIps();
114
+		$ipv6 = defined('AF_INET6')
115
+			? $cloudflareIps['v6']
116
+			: [];
117
+		$whitelist = apply_filters('site-reviews/whip/whitelist', [
118
+			Whip::CLOUDFLARE_HEADERS => [
119
+				Whip::IPV4 => $cloudflareIps['v4'],
120
+				Whip::IPV6 => $ipv6,
121
+			],
122
+			Whip::CUSTOM_HEADERS => [
123
+				Whip::IPV4 => ['127.0.0.1'],
124
+				Whip::IPV6 => ['::1'],
125
+			],
126
+		]);
127
+		$methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
128
+		$methods = apply_filters('site-reviews/whip/methods', $methods);
129
+		$whip = new Whip($methods, $whitelist);
130
+		do_action_ref_array('site-reviews/whip', [$whip]);
131
+		return (string) $whip->getValidIpAddress();
132
+	}
133 133
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
      * @param string $path
18 18
      * @return string
19 19
      */
20
-    public function buildClassName($name, $path = '')
20
+    public function buildClassName( $name, $path = '' )
21 21
     {
22
-        $className = $this->camelCase($name);
23
-        $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
22
+        $className = $this->camelCase( $name );
23
+        $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' );
24 24
         return !empty($path)
25 25
             ? __NAMESPACE__.'\\'.$path.'\\'.$className
26 26
             : $className;
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
      * @param string $prefix
32 32
      * @return string
33 33
      */
34
-    public function buildMethodName($name, $prefix = '')
34
+    public function buildMethodName( $name, $prefix = '' )
35 35
     {
36
-        return lcfirst($prefix.$this->buildClassName($name));
36
+        return lcfirst( $prefix.$this->buildClassName( $name ) );
37 37
     }
38 38
 
39 39
     /**
40 40
      * @param string $name
41 41
      * @return string
42 42
      */
43
-    public function buildPropertyName($name)
43
+    public function buildPropertyName( $name )
44 44
     {
45
-        return lcfirst($this->buildClassName($name));
45
+        return lcfirst( $this->buildClassName( $name ) );
46 46
     }
47 47
 
48 48
     /**
@@ -50,27 +50,27 @@  discard block
 block discarded – undo
50 50
      * @param mixed $value
51 51
      * @return mixed
52 52
      */
53
-    public function castTo($cast = '', $value)
53
+    public function castTo( $cast = '', $value )
54 54
     {
55
-        switch ($cast) {
55
+        switch( $cast ) {
56 56
             case 'array':
57
-                return (array) $value;
57
+                return (array)$value;
58 58
             case 'boolean':
59
-                return filter_var($value, FILTER_VALIDATE_BOOLEAN);
59
+                return filter_var( $value, FILTER_VALIDATE_BOOLEAN );
60 60
             case 'float':
61
-                return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
61
+                return (float)filter_var( $value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND );
62 62
             case 'integer':
63
-                return (int) filter_var($value, FILTER_VALIDATE_INT);
63
+                return (int)filter_var( $value, FILTER_VALIDATE_INT );
64 64
             case 'object':
65
-                return (object) (array) $value;
65
+                return (object)(array)$value;
66 66
             case 'string':
67
-                if (is_object($value) && in_array('__toString', get_class_methods($value))) {
68
-                    return (string) $value->__toString();
67
+                if( is_object( $value ) && in_array( '__toString', get_class_methods( $value ) ) ) {
68
+                    return (string)$value->__toString();
69 69
                 }
70
-                if (is_array($value) || is_object($value)) {
71
-                    return serialize($value);
70
+                if( is_array( $value ) || is_object( $value ) ) {
71
+                    return serialize( $value );
72 72
                 }
73
-                return (string) $value;
73
+                return (string)$value;
74 74
             default:
75 75
                 return $value;
76 76
         }
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
      * @param string $key
81 81
      * @return mixed
82 82
      */
83
-    public function filterInput($key, array $request = [])
83
+    public function filterInput( $key, array $request = [] )
84 84
     {
85
-        if (isset($request[$key])) {
85
+        if( isset($request[$key]) ) {
86 86
             return $request[$key];
87 87
         }
88
-        $variable = filter_input(INPUT_POST, $key);
89
-        if (is_null($variable) && isset($_POST[$key])) {
88
+        $variable = filter_input( INPUT_POST, $key );
89
+        if( is_null( $variable ) && isset($_POST[$key]) ) {
90 90
             $variable = $_POST[$key];
91 91
         }
92 92
         return $variable;
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
      * @param string $key
97 97
      * @return array
98 98
      */
99
-    public function filterInputArray($key)
99
+    public function filterInputArray( $key )
100 100
     {
101
-        $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
102
-        if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
101
+        $variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
102
+        if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) {
103 103
             $variable = $_POST[$key];
104 104
         }
105
-        return (array) $variable;
105
+        return (array)$variable;
106 106
     }
107 107
 
108 108
     /**
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public function getIpAddress()
112 112
     {
113
-        $cloudflareIps = glsr(Cache::class)->getCloudflareIps();
114
-        $ipv6 = defined('AF_INET6')
113
+        $cloudflareIps = glsr( Cache::class )->getCloudflareIps();
114
+        $ipv6 = defined( 'AF_INET6' )
115 115
             ? $cloudflareIps['v6']
116 116
             : [];
117
-        $whitelist = apply_filters('site-reviews/whip/whitelist', [
117
+        $whitelist = apply_filters( 'site-reviews/whip/whitelist', [
118 118
             Whip::CLOUDFLARE_HEADERS => [
119 119
                 Whip::IPV4 => $cloudflareIps['v4'],
120 120
                 Whip::IPV6 => $ipv6,
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
                 Whip::IPV4 => ['127.0.0.1'],
124 124
                 Whip::IPV6 => ['::1'],
125 125
             ],
126
-        ]);
126
+        ] );
127 127
         $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
128
-        $methods = apply_filters('site-reviews/whip/methods', $methods);
129
-        $whip = new Whip($methods, $whitelist);
130
-        do_action_ref_array('site-reviews/whip', [$whip]);
131
-        return (string) $whip->getValidIpAddress();
128
+        $methods = apply_filters( 'site-reviews/whip/methods', $methods );
129
+        $whip = new Whip( $methods, $whitelist );
130
+        do_action_ref_array( 'site-reviews/whip', [$whip] );
131
+        return (string)$whip->getValidIpAddress();
132 132
     }
133 133
 }
Please login to merge, or discard this patch.
plugin/Modules/Upgrader/Upgrade_4_0_0.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -9,62 +9,62 @@
 block discarded – undo
9 9
 
10 10
 class Upgrade_4_0_0
11 11
 {
12
-    public function __construct()
13
-    {
14
-        $this->migrateSettings();
15
-        $this->protectMetaKeys();
16
-        $this->deleteSessions();
17
-        delete_transient(Application::ID.'_cloudflare_ips');
18
-    }
12
+	public function __construct()
13
+	{
14
+		$this->migrateSettings();
15
+		$this->protectMetaKeys();
16
+		$this->deleteSessions();
17
+		delete_transient(Application::ID.'_cloudflare_ips');
18
+	}
19 19
 
20
-    /**
21
-     * @return void
22
-     */
23
-    public function deleteSessions()
24
-    {
25
-        global $wpdb;
26
-        $wpdb->query("
20
+	/**
21
+	 * @return void
22
+	 */
23
+	public function deleteSessions()
24
+	{
25
+		global $wpdb;
26
+		$wpdb->query("
27 27
             DELETE
28 28
             FROM {$wpdb->options}
29 29
             WHERE option_name LIKE '_glsr_session%'
30 30
         ");
31
-    }
31
+	}
32 32
 
33
-    /**
34
-     * @return void
35
-     */
36
-    public function migrateSettings()
37
-    {
38
-        if ($settings = get_option(OptionManager::databaseKey(3))) {
39
-            $multilingual = 'yes' == glsr(Helper::class)->dataGet($settings, 'settings.general.support.polylang')
40
-                ? 'polylang'
41
-                : '';
42
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.general.multilingual', $multilingual);
43
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.blacklist.integration', '');
44
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit', '');
45
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.email', '');
46
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.ip_address', '');
47
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.username', '');
48
-            unset($settings['settings']['general']['support']);
49
-            update_option(OptionManager::databaseKey(4), $settings);
50
-        }
51
-    }
33
+	/**
34
+	 * @return void
35
+	 */
36
+	public function migrateSettings()
37
+	{
38
+		if ($settings = get_option(OptionManager::databaseKey(3))) {
39
+			$multilingual = 'yes' == glsr(Helper::class)->dataGet($settings, 'settings.general.support.polylang')
40
+				? 'polylang'
41
+				: '';
42
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.general.multilingual', $multilingual);
43
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.blacklist.integration', '');
44
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit', '');
45
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.email', '');
46
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.ip_address', '');
47
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.username', '');
48
+			unset($settings['settings']['general']['support']);
49
+			update_option(OptionManager::databaseKey(4), $settings);
50
+		}
51
+	}
52 52
 
53
-    /**
54
-     * @return void
55
-     */
56
-    public function protectMetaKeys()
57
-    {
58
-        global $wpdb;
59
-        $keys = array_keys(glsr(CreateReviewDefaults::class)->defaults());
60
-        $keys = implode("','", $keys);
61
-        $postType = Application::POST_TYPE;
62
-        $wpdb->query("
53
+	/**
54
+	 * @return void
55
+	 */
56
+	public function protectMetaKeys()
57
+	{
58
+		global $wpdb;
59
+		$keys = array_keys(glsr(CreateReviewDefaults::class)->defaults());
60
+		$keys = implode("','", $keys);
61
+		$postType = Application::POST_TYPE;
62
+		$wpdb->query("
63 63
             UPDATE {$wpdb->postmeta} pm
64 64
             INNER JOIN {$wpdb->posts} p ON p.id = pm.post_id
65 65
             SET pm.meta_key = CONCAT('_', pm.meta_key)
66 66
             WHERE pm.meta_key IN ('{$keys}')
67 67
             AND p.post_type = '{$postType}'
68 68
         ");
69
-    }
69
+	}
70 70
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
         $this->migrateSettings();
15 15
         $this->protectMetaKeys();
16 16
         $this->deleteSessions();
17
-        delete_transient(Application::ID.'_cloudflare_ips');
17
+        delete_transient( Application::ID.'_cloudflare_ips' );
18 18
     }
19 19
 
20 20
     /**
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
     public function deleteSessions()
24 24
     {
25 25
         global $wpdb;
26
-        $wpdb->query("
26
+        $wpdb->query( "
27 27
             DELETE
28 28
             FROM {$wpdb->options}
29 29
             WHERE option_name LIKE '_glsr_session%'
30
-        ");
30
+        " );
31 31
     }
32 32
 
33 33
     /**
@@ -35,18 +35,18 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function migrateSettings()
37 37
     {
38
-        if ($settings = get_option(OptionManager::databaseKey(3))) {
39
-            $multilingual = 'yes' == glsr(Helper::class)->dataGet($settings, 'settings.general.support.polylang')
38
+        if( $settings = get_option( OptionManager::databaseKey( 3 ) ) ) {
39
+            $multilingual = 'yes' == glsr( Helper::class )->dataGet( $settings, 'settings.general.support.polylang' )
40 40
                 ? 'polylang'
41 41
                 : '';
42
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.general.multilingual', $multilingual);
43
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.blacklist.integration', '');
44
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit', '');
45
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.email', '');
46
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.ip_address', '');
47
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.username', '');
42
+            $settings = glsr( Helper::class )->dataSet( $settings, 'settings.general.multilingual', $multilingual );
43
+            $settings = glsr( Helper::class )->dataSet( $settings, 'settings.submissions.blacklist.integration', '' );
44
+            $settings = glsr( Helper::class )->dataSet( $settings, 'settings.submissions.limit', '' );
45
+            $settings = glsr( Helper::class )->dataSet( $settings, 'settings.submissions.limit_whitelist.email', '' );
46
+            $settings = glsr( Helper::class )->dataSet( $settings, 'settings.submissions.limit_whitelist.ip_address', '' );
47
+            $settings = glsr( Helper::class )->dataSet( $settings, 'settings.submissions.limit_whitelist.username', '' );
48 48
             unset($settings['settings']['general']['support']);
49
-            update_option(OptionManager::databaseKey(4), $settings);
49
+            update_option( OptionManager::databaseKey( 4 ), $settings );
50 50
         }
51 51
     }
52 52
 
@@ -56,15 +56,15 @@  discard block
 block discarded – undo
56 56
     public function protectMetaKeys()
57 57
     {
58 58
         global $wpdb;
59
-        $keys = array_keys(glsr(CreateReviewDefaults::class)->defaults());
60
-        $keys = implode("','", $keys);
59
+        $keys = array_keys( glsr( CreateReviewDefaults::class )->defaults() );
60
+        $keys = implode( "','", $keys );
61 61
         $postType = Application::POST_TYPE;
62
-        $wpdb->query("
62
+        $wpdb->query( "
63 63
             UPDATE {$wpdb->postmeta} pm
64 64
             INNER JOIN {$wpdb->posts} p ON p.id = pm.post_id
65 65
             SET pm.meta_key = CONCAT('_', pm.meta_key)
66 66
             WHERE pm.meta_key IN ('{$keys}')
67 67
             AND p.post_type = '{$postType}'
68
-        ");
68
+        " );
69 69
     }
70 70
 }
Please login to merge, or discard this patch.
plugin/Modules/Validator/ValidateReview.php 2 patches
Indentation   +262 added lines, -262 removed lines patch added patch discarded remove patch
@@ -12,288 +12,288 @@
 block discarded – undo
12 12
 
13 13
 class ValidateReview
14 14
 {
15
-    const RECAPTCHA_ENDPOINT = 'https://www.google.com/recaptcha/api/siteverify';
15
+	const RECAPTCHA_ENDPOINT = 'https://www.google.com/recaptcha/api/siteverify';
16 16
 
17
-    const RECAPTCHA_DISABLED = 0;
18
-    const RECAPTCHA_EMPTY = 1;
19
-    const RECAPTCHA_FAILED = 2;
20
-    const RECAPTCHA_INVALID = 3;
21
-    const RECAPTCHA_VALID = 4;
17
+	const RECAPTCHA_DISABLED = 0;
18
+	const RECAPTCHA_EMPTY = 1;
19
+	const RECAPTCHA_FAILED = 2;
20
+	const RECAPTCHA_INVALID = 3;
21
+	const RECAPTCHA_VALID = 4;
22 22
 
23
-    const VALIDATION_RULES = [
24
-        'content' => 'required',
25
-        'email' => 'required|email',
26
-        'name' => 'required',
27
-        'rating' => 'required|number|between:1,5',
28
-        'terms' => 'accepted',
29
-        'title' => 'required',
30
-    ];
23
+	const VALIDATION_RULES = [
24
+		'content' => 'required',
25
+		'email' => 'required|email',
26
+		'name' => 'required',
27
+		'rating' => 'required|number|between:1,5',
28
+		'terms' => 'accepted',
29
+		'title' => 'required',
30
+	];
31 31
 
32
-    /**
33
-     * @var string|void
34
-     */
35
-    public $error;
32
+	/**
33
+	 * @var string|void
34
+	 */
35
+	public $error;
36 36
 
37
-    /**
38
-     * @var string
39
-     */
40
-    public $form_id;
37
+	/**
38
+	 * @var string
39
+	 */
40
+	public $form_id;
41 41
 
42
-    /**
43
-     * @var bool
44
-     */
45
-    public $recaptchaIsUnset = false;
42
+	/**
43
+	 * @var bool
44
+	 */
45
+	public $recaptchaIsUnset = false;
46 46
 
47
-    /**
48
-     * @var array
49
-     */
50
-    public $request;
47
+	/**
48
+	 * @var array
49
+	 */
50
+	public $request;
51 51
 
52
-    /**
53
-     * @var array
54
-     */
55
-    protected $options;
52
+	/**
53
+	 * @var array
54
+	 */
55
+	protected $options;
56 56
 
57
-    /**
58
-     * @return static
59
-     */
60
-    public function validate(array $request)
61
-    {
62
-        $this->form_id = $request['form_id'];
63
-        $this->options = glsr(OptionManager::class)->all();
64
-        $this->request = $this->validateRequest($request);
65
-        $this->validateCustom();
66
-        $this->validateHoneyPot();
67
-        $this->validateReviewLimits();
68
-        $this->validateBlacklist();
69
-        $this->validateAkismet();
70
-        $this->validateRecaptcha();
71
-        if (!empty($this->error)) {
72
-            $this->setSessionValues('message', $this->error);
73
-        }
74
-        return $this;
75
-    }
57
+	/**
58
+	 * @return static
59
+	 */
60
+	public function validate(array $request)
61
+	{
62
+		$this->form_id = $request['form_id'];
63
+		$this->options = glsr(OptionManager::class)->all();
64
+		$this->request = $this->validateRequest($request);
65
+		$this->validateCustom();
66
+		$this->validateHoneyPot();
67
+		$this->validateReviewLimits();
68
+		$this->validateBlacklist();
69
+		$this->validateAkismet();
70
+		$this->validateRecaptcha();
71
+		if (!empty($this->error)) {
72
+			$this->setSessionValues('message', $this->error);
73
+		}
74
+		return $this;
75
+	}
76 76
 
77
-    /**
78
-     * @param string $path
79
-     * @param mixed $fallback
80
-     * @return mixed
81
-     */
82
-    protected function getOption($path, $fallback = '')
83
-    {
84
-        return glsr(Helper::class)->dataGet($this->options, $path, $fallback);
85
-    }
77
+	/**
78
+	 * @param string $path
79
+	 * @param mixed $fallback
80
+	 * @return mixed
81
+	 */
82
+	protected function getOption($path, $fallback = '')
83
+	{
84
+		return glsr(Helper::class)->dataGet($this->options, $path, $fallback);
85
+	}
86 86
 
87
-    /**
88
-     * @return int
89
-     */
90
-    protected function getRecaptchaStatus()
91
-    {
92
-        if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
93
-            return static::RECAPTCHA_DISABLED;
94
-        }
95
-        if (empty($this->request['_recaptcha-token'])) {
96
-            return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5))
97
-                ? static::RECAPTCHA_EMPTY
98
-                : static::RECAPTCHA_FAILED;
99
-        }
100
-        return $this->getRecaptchaTokenStatus();
101
-    }
87
+	/**
88
+	 * @return int
89
+	 */
90
+	protected function getRecaptchaStatus()
91
+	{
92
+		if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
93
+			return static::RECAPTCHA_DISABLED;
94
+		}
95
+		if (empty($this->request['_recaptcha-token'])) {
96
+			return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5))
97
+				? static::RECAPTCHA_EMPTY
98
+				: static::RECAPTCHA_FAILED;
99
+		}
100
+		return $this->getRecaptchaTokenStatus();
101
+	}
102 102
 
103
-    /**
104
-     * @return int
105
-     */
106
-    protected function getRecaptchaTokenStatus()
107
-    {
108
-        $endpoint = add_query_arg([
109
-            'remoteip' => glsr(Helper::class)->getIpAddress(),
110
-            'response' => $this->request['_recaptcha-token'],
111
-            'secret' => $this->getOption('settings.submissions.recaptcha.secret'),
112
-        ], static::RECAPTCHA_ENDPOINT);
113
-        if (is_wp_error($response = wp_remote_get($endpoint))) {
114
-            glsr_log()->error($response->get_error_message());
115
-            return static::RECAPTCHA_FAILED;
116
-        }
117
-        $response = json_decode(wp_remote_retrieve_body($response));
118
-        if (!empty($response->success)) {
119
-            return boolval($response->success)
120
-                ? static::RECAPTCHA_VALID
121
-                : static::RECAPTCHA_INVALID;
122
-        }
123
-        foreach ($response->{'error-codes'} as $error) {
124
-            glsr_log()->error('reCAPTCHA error: '.$error);
125
-        }
126
-        return static::RECAPTCHA_INVALID;
127
-    }
103
+	/**
104
+	 * @return int
105
+	 */
106
+	protected function getRecaptchaTokenStatus()
107
+	{
108
+		$endpoint = add_query_arg([
109
+			'remoteip' => glsr(Helper::class)->getIpAddress(),
110
+			'response' => $this->request['_recaptcha-token'],
111
+			'secret' => $this->getOption('settings.submissions.recaptcha.secret'),
112
+		], static::RECAPTCHA_ENDPOINT);
113
+		if (is_wp_error($response = wp_remote_get($endpoint))) {
114
+			glsr_log()->error($response->get_error_message());
115
+			return static::RECAPTCHA_FAILED;
116
+		}
117
+		$response = json_decode(wp_remote_retrieve_body($response));
118
+		if (!empty($response->success)) {
119
+			return boolval($response->success)
120
+				? static::RECAPTCHA_VALID
121
+				: static::RECAPTCHA_INVALID;
122
+		}
123
+		foreach ($response->{'error-codes'} as $error) {
124
+			glsr_log()->error('reCAPTCHA error: '.$error);
125
+		}
126
+		return static::RECAPTCHA_INVALID;
127
+	}
128 128
 
129
-    /**
130
-     * @return array
131
-     */
132
-    protected function getValidationRules(array $request)
133
-    {
134
-        $rules = array_intersect_key(
135
-            apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request),
136
-            array_flip($this->getOption('settings.submissions.required', []))
137
-        );
138
-        $excluded = explode(',', glsr_get($request, 'excluded'));
139
-        return array_diff_key($rules, array_flip($excluded));
140
-    }
129
+	/**
130
+	 * @return array
131
+	 */
132
+	protected function getValidationRules(array $request)
133
+	{
134
+		$rules = array_intersect_key(
135
+			apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request),
136
+			array_flip($this->getOption('settings.submissions.required', []))
137
+		);
138
+		$excluded = explode(',', glsr_get($request, 'excluded'));
139
+		return array_diff_key($rules, array_flip($excluded));
140
+	}
141 141
 
142
-    /**
143
-     * @return bool
144
-     */
145
-    protected function isRequestValid(array $request)
146
-    {
147
-        $rules = $this->getValidationRules($request);
148
-        $errors = glsr(Validator::class)->validate($request, $rules);
149
-        if (empty($errors)) {
150
-            return true;
151
-        }
152
-        $this->setSessionValues('errors', $errors);
153
-        $this->setSessionValues('values', $request);
154
-        return false;
155
-    }
142
+	/**
143
+	 * @return bool
144
+	 */
145
+	protected function isRequestValid(array $request)
146
+	{
147
+		$rules = $this->getValidationRules($request);
148
+		$errors = glsr(Validator::class)->validate($request, $rules);
149
+		if (empty($errors)) {
150
+			return true;
151
+		}
152
+		$this->setSessionValues('errors', $errors);
153
+		$this->setSessionValues('values', $request);
154
+		return false;
155
+	}
156 156
 
157
-    protected function setError($message, $loggedMessage = '')
158
-    {
159
-        $this->setSessionValues('errors', [], $loggedMessage);
160
-        $this->error = $message;
161
-    }
157
+	protected function setError($message, $loggedMessage = '')
158
+	{
159
+		$this->setSessionValues('errors', [], $loggedMessage);
160
+		$this->error = $message;
161
+	}
162 162
 
163
-    /**
164
-     * @param string $type
165
-     * @param mixed $value
166
-     * @param string $loggedMessage
167
-     * @return void
168
-     */
169
-    protected function setSessionValues($type, $value, $loggedMessage = '')
170
-    {
171
-        glsr()->sessionSet($this->form_id.$type, $value);
172
-        if (!empty($loggedMessage)) {
173
-            glsr_log()->warning($loggedMessage)->debug($this->request);
174
-        }
175
-    }
163
+	/**
164
+	 * @param string $type
165
+	 * @param mixed $value
166
+	 * @param string $loggedMessage
167
+	 * @return void
168
+	 */
169
+	protected function setSessionValues($type, $value, $loggedMessage = '')
170
+	{
171
+		glsr()->sessionSet($this->form_id.$type, $value);
172
+		if (!empty($loggedMessage)) {
173
+			glsr_log()->warning($loggedMessage)->debug($this->request);
174
+		}
175
+	}
176 176
 
177
-    /**
178
-     * @return void
179
-     */
180
-    protected function validateAkismet()
181
-    {
182
-        if (!empty($this->error)) {
183
-            return;
184
-        }
185
-        if (!glsr(Akismet::class)->isSpam($this->request)) {
186
-            return;
187
-        }
188
-        $this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'),
189
-            'Akismet caught a spam submission (consider adding the IP address to the blacklist):'
190
-        );
191
-    }
177
+	/**
178
+	 * @return void
179
+	 */
180
+	protected function validateAkismet()
181
+	{
182
+		if (!empty($this->error)) {
183
+			return;
184
+		}
185
+		if (!glsr(Akismet::class)->isSpam($this->request)) {
186
+			return;
187
+		}
188
+		$this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'),
189
+			'Akismet caught a spam submission (consider adding the IP address to the blacklist):'
190
+		);
191
+	}
192 192
 
193
-    /**
194
-     * @return void
195
-     */
196
-    protected function validateBlacklist()
197
-    {
198
-        if (!empty($this->error)) {
199
-            return;
200
-        }
201
-        if (!glsr(Blacklist::class)->isBlacklisted($this->request)) {
202
-            return;
203
-        }
204
-        $blacklistAction = $this->getOption('settings.submissions.blacklist.action');
205
-        if ('reject' != $blacklistAction) {
206
-            $this->request['blacklisted'] = true;
207
-            return;
208
-        }
209
-        $this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'),
210
-            'Blacklisted submission detected:'
211
-        );
212
-    }
193
+	/**
194
+	 * @return void
195
+	 */
196
+	protected function validateBlacklist()
197
+	{
198
+		if (!empty($this->error)) {
199
+			return;
200
+		}
201
+		if (!glsr(Blacklist::class)->isBlacklisted($this->request)) {
202
+			return;
203
+		}
204
+		$blacklistAction = $this->getOption('settings.submissions.blacklist.action');
205
+		if ('reject' != $blacklistAction) {
206
+			$this->request['blacklisted'] = true;
207
+			return;
208
+		}
209
+		$this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'),
210
+			'Blacklisted submission detected:'
211
+		);
212
+	}
213 213
 
214
-    /**
215
-     * @return void
216
-     */
217
-    protected function validateCustom()
218
-    {
219
-        if (!empty($this->error)) {
220
-            return;
221
-        }
222
-        $validated = apply_filters('site-reviews/validate/custom', true, $this->request);
223
-        if (true === $validated) {
224
-            return;
225
-        }
226
-        $errorMessage = is_string($validated)
227
-            ? $validated
228
-            : __('The review submission failed. Please notify the site administrator.', 'site-reviews');
229
-        $this->setError($errorMessage);
230
-        $this->setSessionValues('values', $this->request);
231
-    }
214
+	/**
215
+	 * @return void
216
+	 */
217
+	protected function validateCustom()
218
+	{
219
+		if (!empty($this->error)) {
220
+			return;
221
+		}
222
+		$validated = apply_filters('site-reviews/validate/custom', true, $this->request);
223
+		if (true === $validated) {
224
+			return;
225
+		}
226
+		$errorMessage = is_string($validated)
227
+			? $validated
228
+			: __('The review submission failed. Please notify the site administrator.', 'site-reviews');
229
+		$this->setError($errorMessage);
230
+		$this->setSessionValues('values', $this->request);
231
+	}
232 232
 
233
-    /**
234
-     * @return void
235
-     */
236
-    protected function validateHoneyPot()
237
-    {
238
-        if (!empty($this->error)) {
239
-            return;
240
-        }
241
-        if (empty($this->request['gotcha'])) {
242
-            return;
243
-        }
244
-        $this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'),
245
-            'The Honeypot caught a bad submission:'
246
-        );
247
-    }
233
+	/**
234
+	 * @return void
235
+	 */
236
+	protected function validateHoneyPot()
237
+	{
238
+		if (!empty($this->error)) {
239
+			return;
240
+		}
241
+		if (empty($this->request['gotcha'])) {
242
+			return;
243
+		}
244
+		$this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'),
245
+			'The Honeypot caught a bad submission:'
246
+		);
247
+	}
248 248
 
249
-    /**
250
-     * @return void
251
-     */
252
-    protected function validateReviewLimits()
253
-    {
254
-        if (!empty($this->error)) {
255
-            return;
256
-        }
257
-        if (!glsr(ReviewLimits::class)->hasReachedLimit($this->request)) {
258
-            return;
259
-        }
260
-        $this->setError(__('You have already submitted a review.', 'site-reviews'));
261
-    }
249
+	/**
250
+	 * @return void
251
+	 */
252
+	protected function validateReviewLimits()
253
+	{
254
+		if (!empty($this->error)) {
255
+			return;
256
+		}
257
+		if (!glsr(ReviewLimits::class)->hasReachedLimit($this->request)) {
258
+			return;
259
+		}
260
+		$this->setError(__('You have already submitted a review.', 'site-reviews'));
261
+	}
262 262
 
263
-    /**
264
-     * @return void
265
-     */
266
-    protected function validateRecaptcha()
267
-    {
268
-        if (!empty($this->error)) {
269
-            return;
270
-        }
271
-        $status = $this->getRecaptchaStatus();
272
-        if (in_array($status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID])) {
273
-            return;
274
-        }
275
-        if (static::RECAPTCHA_EMPTY === $status) {
276
-            $this->setSessionValues('recaptcha', 'unset');
277
-            $this->recaptchaIsUnset = true;
278
-            return;
279
-        }
280
-        $this->setSessionValues('recaptcha', 'reset');
281
-        $errors = [
282
-            static::RECAPTCHA_FAILED => __('The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews'),
283
-            static::RECAPTCHA_INVALID => __('The reCAPTCHA verification failed, please try again.', 'site-reviews'),
284
-        ];
285
-        $this->setError($errors[$status]);
286
-    }
263
+	/**
264
+	 * @return void
265
+	 */
266
+	protected function validateRecaptcha()
267
+	{
268
+		if (!empty($this->error)) {
269
+			return;
270
+		}
271
+		$status = $this->getRecaptchaStatus();
272
+		if (in_array($status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID])) {
273
+			return;
274
+		}
275
+		if (static::RECAPTCHA_EMPTY === $status) {
276
+			$this->setSessionValues('recaptcha', 'unset');
277
+			$this->recaptchaIsUnset = true;
278
+			return;
279
+		}
280
+		$this->setSessionValues('recaptcha', 'reset');
281
+		$errors = [
282
+			static::RECAPTCHA_FAILED => __('The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews'),
283
+			static::RECAPTCHA_INVALID => __('The reCAPTCHA verification failed, please try again.', 'site-reviews'),
284
+		];
285
+		$this->setError($errors[$status]);
286
+	}
287 287
 
288
-    /**
289
-     * @return array
290
-     */
291
-    protected function validateRequest(array $request)
292
-    {
293
-        if (!$this->isRequestValid($request)) {
294
-            $this->error = __('Please fix the submission errors.', 'site-reviews');
295
-            return $request;
296
-        }
297
-        return array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request);
298
-    }
288
+	/**
289
+	 * @return array
290
+	 */
291
+	protected function validateRequest(array $request)
292
+	{
293
+		if (!$this->isRequestValid($request)) {
294
+			$this->error = __('Please fix the submission errors.', 'site-reviews');
295
+			return $request;
296
+		}
297
+		return array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request);
298
+	}
299 299
 }
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -57,19 +57,19 @@  discard block
 block discarded – undo
57 57
     /**
58 58
      * @return static
59 59
      */
60
-    public function validate(array $request)
60
+    public function validate( array $request )
61 61
     {
62 62
         $this->form_id = $request['form_id'];
63
-        $this->options = glsr(OptionManager::class)->all();
64
-        $this->request = $this->validateRequest($request);
63
+        $this->options = glsr( OptionManager::class )->all();
64
+        $this->request = $this->validateRequest( $request );
65 65
         $this->validateCustom();
66 66
         $this->validateHoneyPot();
67 67
         $this->validateReviewLimits();
68 68
         $this->validateBlacklist();
69 69
         $this->validateAkismet();
70 70
         $this->validateRecaptcha();
71
-        if (!empty($this->error)) {
72
-            $this->setSessionValues('message', $this->error);
71
+        if( !empty($this->error) ) {
72
+            $this->setSessionValues( 'message', $this->error );
73 73
         }
74 74
         return $this;
75 75
     }
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
      * @param mixed $fallback
80 80
      * @return mixed
81 81
      */
82
-    protected function getOption($path, $fallback = '')
82
+    protected function getOption( $path, $fallback = '' )
83 83
     {
84
-        return glsr(Helper::class)->dataGet($this->options, $path, $fallback);
84
+        return glsr( Helper::class )->dataGet( $this->options, $path, $fallback );
85 85
     }
86 86
 
87 87
     /**
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
      */
90 90
     protected function getRecaptchaStatus()
91 91
     {
92
-        if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
92
+        if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) {
93 93
             return static::RECAPTCHA_DISABLED;
94 94
         }
95
-        if (empty($this->request['_recaptcha-token'])) {
96
-            return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5))
95
+        if( empty($this->request['_recaptcha-token']) ) {
96
+            return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) )
97 97
                 ? static::RECAPTCHA_EMPTY
98 98
                 : static::RECAPTCHA_FAILED;
99 99
         }
@@ -105,23 +105,23 @@  discard block
 block discarded – undo
105 105
      */
106 106
     protected function getRecaptchaTokenStatus()
107 107
     {
108
-        $endpoint = add_query_arg([
109
-            'remoteip' => glsr(Helper::class)->getIpAddress(),
108
+        $endpoint = add_query_arg( [
109
+            'remoteip' => glsr( Helper::class )->getIpAddress(),
110 110
             'response' => $this->request['_recaptcha-token'],
111
-            'secret' => $this->getOption('settings.submissions.recaptcha.secret'),
112
-        ], static::RECAPTCHA_ENDPOINT);
113
-        if (is_wp_error($response = wp_remote_get($endpoint))) {
114
-            glsr_log()->error($response->get_error_message());
111
+            'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ),
112
+        ], static::RECAPTCHA_ENDPOINT );
113
+        if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) {
114
+            glsr_log()->error( $response->get_error_message() );
115 115
             return static::RECAPTCHA_FAILED;
116 116
         }
117
-        $response = json_decode(wp_remote_retrieve_body($response));
118
-        if (!empty($response->success)) {
119
-            return boolval($response->success)
117
+        $response = json_decode( wp_remote_retrieve_body( $response ) );
118
+        if( !empty($response->success) ) {
119
+            return boolval( $response->success )
120 120
                 ? static::RECAPTCHA_VALID
121 121
                 : static::RECAPTCHA_INVALID;
122 122
         }
123
-        foreach ($response->{'error-codes'} as $error) {
124
-            glsr_log()->error('reCAPTCHA error: '.$error);
123
+        foreach( $response->{'error-codes'} as $error ) {
124
+            glsr_log()->error( 'reCAPTCHA error: '.$error );
125 125
         }
126 126
         return static::RECAPTCHA_INVALID;
127 127
     }
@@ -129,34 +129,34 @@  discard block
 block discarded – undo
129 129
     /**
130 130
      * @return array
131 131
      */
132
-    protected function getValidationRules(array $request)
132
+    protected function getValidationRules( array $request )
133 133
     {
134 134
         $rules = array_intersect_key(
135
-            apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request),
136
-            array_flip($this->getOption('settings.submissions.required', []))
135
+            apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ),
136
+            array_flip( $this->getOption( 'settings.submissions.required', [] ) )
137 137
         );
138
-        $excluded = explode(',', glsr_get($request, 'excluded'));
139
-        return array_diff_key($rules, array_flip($excluded));
138
+        $excluded = explode( ',', glsr_get( $request, 'excluded' ) );
139
+        return array_diff_key( $rules, array_flip( $excluded ) );
140 140
     }
141 141
 
142 142
     /**
143 143
      * @return bool
144 144
      */
145
-    protected function isRequestValid(array $request)
145
+    protected function isRequestValid( array $request )
146 146
     {
147
-        $rules = $this->getValidationRules($request);
148
-        $errors = glsr(Validator::class)->validate($request, $rules);
149
-        if (empty($errors)) {
147
+        $rules = $this->getValidationRules( $request );
148
+        $errors = glsr( Validator::class )->validate( $request, $rules );
149
+        if( empty($errors) ) {
150 150
             return true;
151 151
         }
152
-        $this->setSessionValues('errors', $errors);
153
-        $this->setSessionValues('values', $request);
152
+        $this->setSessionValues( 'errors', $errors );
153
+        $this->setSessionValues( 'values', $request );
154 154
         return false;
155 155
     }
156 156
 
157
-    protected function setError($message, $loggedMessage = '')
157
+    protected function setError( $message, $loggedMessage = '' )
158 158
     {
159
-        $this->setSessionValues('errors', [], $loggedMessage);
159
+        $this->setSessionValues( 'errors', [], $loggedMessage );
160 160
         $this->error = $message;
161 161
     }
162 162
 
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
      * @param string $loggedMessage
167 167
      * @return void
168 168
      */
169
-    protected function setSessionValues($type, $value, $loggedMessage = '')
169
+    protected function setSessionValues( $type, $value, $loggedMessage = '' )
170 170
     {
171
-        glsr()->sessionSet($this->form_id.$type, $value);
172
-        if (!empty($loggedMessage)) {
173
-            glsr_log()->warning($loggedMessage)->debug($this->request);
171
+        glsr()->sessionSet( $this->form_id.$type, $value );
172
+        if( !empty($loggedMessage) ) {
173
+            glsr_log()->warning( $loggedMessage )->debug( $this->request );
174 174
         }
175 175
     }
176 176
 
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
      */
180 180
     protected function validateAkismet()
181 181
     {
182
-        if (!empty($this->error)) {
182
+        if( !empty($this->error) ) {
183 183
             return;
184 184
         }
185
-        if (!glsr(Akismet::class)->isSpam($this->request)) {
185
+        if( !glsr( Akismet::class )->isSpam( $this->request ) ) {
186 186
             return;
187 187
         }
188
-        $this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'),
188
+        $this->setError( __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ),
189 189
             'Akismet caught a spam submission (consider adding the IP address to the blacklist):'
190 190
         );
191 191
     }
@@ -195,18 +195,18 @@  discard block
 block discarded – undo
195 195
      */
196 196
     protected function validateBlacklist()
197 197
     {
198
-        if (!empty($this->error)) {
198
+        if( !empty($this->error) ) {
199 199
             return;
200 200
         }
201
-        if (!glsr(Blacklist::class)->isBlacklisted($this->request)) {
201
+        if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) ) {
202 202
             return;
203 203
         }
204
-        $blacklistAction = $this->getOption('settings.submissions.blacklist.action');
205
-        if ('reject' != $blacklistAction) {
204
+        $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' );
205
+        if( 'reject' != $blacklistAction ) {
206 206
             $this->request['blacklisted'] = true;
207 207
             return;
208 208
         }
209
-        $this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'),
209
+        $this->setError( __( 'Your review cannot be submitted at this time.', 'site-reviews' ),
210 210
             'Blacklisted submission detected:'
211 211
         );
212 212
     }
@@ -216,18 +216,18 @@  discard block
 block discarded – undo
216 216
      */
217 217
     protected function validateCustom()
218 218
     {
219
-        if (!empty($this->error)) {
219
+        if( !empty($this->error) ) {
220 220
             return;
221 221
         }
222
-        $validated = apply_filters('site-reviews/validate/custom', true, $this->request);
223
-        if (true === $validated) {
222
+        $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request );
223
+        if( true === $validated ) {
224 224
             return;
225 225
         }
226
-        $errorMessage = is_string($validated)
226
+        $errorMessage = is_string( $validated )
227 227
             ? $validated
228
-            : __('The review submission failed. Please notify the site administrator.', 'site-reviews');
229
-        $this->setError($errorMessage);
230
-        $this->setSessionValues('values', $this->request);
228
+            : __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' );
229
+        $this->setError( $errorMessage );
230
+        $this->setSessionValues( 'values', $this->request );
231 231
     }
232 232
 
233 233
     /**
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
      */
236 236
     protected function validateHoneyPot()
237 237
     {
238
-        if (!empty($this->error)) {
238
+        if( !empty($this->error) ) {
239 239
             return;
240 240
         }
241
-        if (empty($this->request['gotcha'])) {
241
+        if( empty($this->request['gotcha']) ) {
242 242
             return;
243 243
         }
244
-        $this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'),
244
+        $this->setError( __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ),
245 245
             'The Honeypot caught a bad submission:'
246 246
         );
247 247
     }
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
      */
252 252
     protected function validateReviewLimits()
253 253
     {
254
-        if (!empty($this->error)) {
254
+        if( !empty($this->error) ) {
255 255
             return;
256 256
         }
257
-        if (!glsr(ReviewLimits::class)->hasReachedLimit($this->request)) {
257
+        if( !glsr( ReviewLimits::class )->hasReachedLimit( $this->request ) ) {
258 258
             return;
259 259
         }
260
-        $this->setError(__('You have already submitted a review.', 'site-reviews'));
260
+        $this->setError( __( 'You have already submitted a review.', 'site-reviews' ) );
261 261
     }
262 262
 
263 263
     /**
@@ -265,35 +265,35 @@  discard block
 block discarded – undo
265 265
      */
266 266
     protected function validateRecaptcha()
267 267
     {
268
-        if (!empty($this->error)) {
268
+        if( !empty($this->error) ) {
269 269
             return;
270 270
         }
271 271
         $status = $this->getRecaptchaStatus();
272
-        if (in_array($status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID])) {
272
+        if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) ) {
273 273
             return;
274 274
         }
275
-        if (static::RECAPTCHA_EMPTY === $status) {
276
-            $this->setSessionValues('recaptcha', 'unset');
275
+        if( static::RECAPTCHA_EMPTY === $status ) {
276
+            $this->setSessionValues( 'recaptcha', 'unset' );
277 277
             $this->recaptchaIsUnset = true;
278 278
             return;
279 279
         }
280
-        $this->setSessionValues('recaptcha', 'reset');
280
+        $this->setSessionValues( 'recaptcha', 'reset' );
281 281
         $errors = [
282
-            static::RECAPTCHA_FAILED => __('The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews'),
283
-            static::RECAPTCHA_INVALID => __('The reCAPTCHA verification failed, please try again.', 'site-reviews'),
282
+            static::RECAPTCHA_FAILED => __( 'The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews' ),
283
+            static::RECAPTCHA_INVALID => __( 'The reCAPTCHA verification failed, please try again.', 'site-reviews' ),
284 284
         ];
285
-        $this->setError($errors[$status]);
285
+        $this->setError( $errors[$status] );
286 286
     }
287 287
 
288 288
     /**
289 289
      * @return array
290 290
      */
291
-    protected function validateRequest(array $request)
291
+    protected function validateRequest( array $request )
292 292
     {
293
-        if (!$this->isRequestValid($request)) {
294
-            $this->error = __('Please fix the submission errors.', 'site-reviews');
293
+        if( !$this->isRequestValid( $request ) ) {
294
+            $this->error = __( 'Please fix the submission errors.', 'site-reviews' );
295 295
             return $request;
296 296
         }
297
-        return array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request);
297
+        return array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request );
298 298
     }
299 299
 }
Please login to merge, or discard this patch.
plugin/Modules/ReviewLimits.php 2 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -7,103 +7,103 @@
 block discarded – undo
7 7
 
8 8
 class ReviewLimits
9 9
 {
10
-    protected $request;
10
+	protected $request;
11 11
 
12
-    /**
13
-     * @return array
14
-     * @filter site-reviews/get/reviews/query
15
-     */
16
-    public function filterReviewsQuery(array $parameters, array $args)
17
-    {
18
-        if ($authorId = get_current_user_id()) {
19
-            $parameters['author'] = $authorId;
20
-        }
21
-        $parameters['post_status'] = ['pending', 'publish'];
22
-        return apply_filters('site-reviews/reviews-limits/query', $parameters, $args);
23
-    }
12
+	/**
13
+	 * @return array
14
+	 * @filter site-reviews/get/reviews/query
15
+	 */
16
+	public function filterReviewsQuery(array $parameters, array $args)
17
+	{
18
+		if ($authorId = get_current_user_id()) {
19
+			$parameters['author'] = $authorId;
20
+		}
21
+		$parameters['post_status'] = ['pending', 'publish'];
22
+		return apply_filters('site-reviews/reviews-limits/query', $parameters, $args);
23
+	}
24 24
 
25
-    /**
26
-     * @return bool
27
-     */
28
-    public function hasReachedLimit(array $request = [])
29
-    {
30
-        $this->request = $request;
31
-        $method = glsr(Helper::class)->buildMethodName(
32
-            glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy'
33
-        );
34
-        return method_exists($this, $method)
35
-            ? !call_user_func([$this, $method])
36
-            : false;
37
-    }
25
+	/**
26
+	 * @return bool
27
+	 */
28
+	public function hasReachedLimit(array $request = [])
29
+	{
30
+		$this->request = $request;
31
+		$method = glsr(Helper::class)->buildMethodName(
32
+			glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy'
33
+		);
34
+		return method_exists($this, $method)
35
+			? !call_user_func([$this, $method])
36
+			: false;
37
+	}
38 38
 
39
-    /**
40
-     * @param string $value
41
-     * @param string $whitelist
42
-     * @return bool
43
-     */
44
-    public function isWhitelisted($value, $whitelist)
45
-    {
46
-        if (empty($whitelist)) {
47
-            return false;
48
-        }
49
-        return in_array($value, array_filter(explode("\n", $whitelist), 'trim'));
50
-    }
39
+	/**
40
+	 * @param string $value
41
+	 * @param string $whitelist
42
+	 * @return bool
43
+	 */
44
+	public function isWhitelisted($value, $whitelist)
45
+	{
46
+		if (empty($whitelist)) {
47
+			return false;
48
+		}
49
+		return in_array($value, array_filter(explode("\n", $whitelist), 'trim'));
50
+	}
51 51
 
52
-    /**
53
-     * @param string $whitelistName
54
-     * @return string
55
-     */
56
-    protected function getWhitelist($whitelistName)
57
-    {
58
-        return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName);
59
-    }
52
+	/**
53
+	 * @param string $whitelistName
54
+	 * @return string
55
+	 */
56
+	protected function getWhitelist($whitelistName)
57
+	{
58
+		return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName);
59
+	}
60 60
 
61
-    /**
62
-     * @return bool
63
-     */
64
-    protected function validate($key, $value, $addMetaQuery = true)
65
-    {
66
-        if ($this->isWhitelisted($value, $this->getWhitelist($key))) {
67
-            return true;
68
-        }
69
-        add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2);
70
-        $args = ['assigned_to' => glsr_get($this->request, 'assign_to')];
71
-        if ($addMetaQuery) {
72
-            $args[$key] = $value;
73
-        }
74
-        $reviews = glsr_get_reviews($args);
75
-        remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5);
76
-        return 0 === count($reviews);
77
-    }
61
+	/**
62
+	 * @return bool
63
+	 */
64
+	protected function validate($key, $value, $addMetaQuery = true)
65
+	{
66
+		if ($this->isWhitelisted($value, $this->getWhitelist($key))) {
67
+			return true;
68
+		}
69
+		add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2);
70
+		$args = ['assigned_to' => glsr_get($this->request, 'assign_to')];
71
+		if ($addMetaQuery) {
72
+			$args[$key] = $value;
73
+		}
74
+		$reviews = glsr_get_reviews($args);
75
+		remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5);
76
+		return 0 === count($reviews);
77
+	}
78 78
 
79
-    /**
80
-     * @return bool
81
-     */
82
-    protected function validateByEmail()
83
-    {
84
-        glsr_log()->debug('Email is: '.glsr_get($this->request, 'email'));
85
-        return $this->validate('email', glsr_get($this->request, 'email'));
86
-    }
79
+	/**
80
+	 * @return bool
81
+	 */
82
+	protected function validateByEmail()
83
+	{
84
+		glsr_log()->debug('Email is: '.glsr_get($this->request, 'email'));
85
+		return $this->validate('email', glsr_get($this->request, 'email'));
86
+	}
87 87
 
88
-    /**
89
-     * @return bool
90
-     */
91
-    protected function validateByIpAddress()
92
-    {
93
-        glsr_log()->debug('IP Address is: '.glsr_get($this->request, 'ip_address'));
94
-        return $this->validate('ip_address', glsr_get($this->request, 'ip_address'));
95
-    }
88
+	/**
89
+	 * @return bool
90
+	 */
91
+	protected function validateByIpAddress()
92
+	{
93
+		glsr_log()->debug('IP Address is: '.glsr_get($this->request, 'ip_address'));
94
+		return $this->validate('ip_address', glsr_get($this->request, 'ip_address'));
95
+	}
96 96
 
97
-    /**
98
-     * @return bool
99
-     */
100
-    protected function validateByUsername()
101
-    {
102
-        $user = wp_get_current_user();
103
-        if (!$user->exists()) {
104
-            return true;
105
-        }
106
-        glsr_log()->debug('Username is: '.$user->user_login);
107
-        return $this->validate('username', $user->user_login, false);
108
-    }
97
+	/**
98
+	 * @return bool
99
+	 */
100
+	protected function validateByUsername()
101
+	{
102
+		$user = wp_get_current_user();
103
+		if (!$user->exists()) {
104
+			return true;
105
+		}
106
+		glsr_log()->debug('Username is: '.$user->user_login);
107
+		return $this->validate('username', $user->user_login, false);
108
+	}
109 109
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -13,26 +13,26 @@  discard block
 block discarded – undo
13 13
      * @return array
14 14
      * @filter site-reviews/get/reviews/query
15 15
      */
16
-    public function filterReviewsQuery(array $parameters, array $args)
16
+    public function filterReviewsQuery( array $parameters, array $args )
17 17
     {
18
-        if ($authorId = get_current_user_id()) {
18
+        if( $authorId = get_current_user_id() ) {
19 19
             $parameters['author'] = $authorId;
20 20
         }
21 21
         $parameters['post_status'] = ['pending', 'publish'];
22
-        return apply_filters('site-reviews/reviews-limits/query', $parameters, $args);
22
+        return apply_filters( 'site-reviews/reviews-limits/query', $parameters, $args );
23 23
     }
24 24
 
25 25
     /**
26 26
      * @return bool
27 27
      */
28
-    public function hasReachedLimit(array $request = [])
28
+    public function hasReachedLimit( array $request = [] )
29 29
     {
30 30
         $this->request = $request;
31
-        $method = glsr(Helper::class)->buildMethodName(
32
-            glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy'
31
+        $method = glsr( Helper::class )->buildMethodName(
32
+            glsr( OptionManager::class )->get( 'settings.submissions.limit' ), 'validateBy'
33 33
         );
34
-        return method_exists($this, $method)
35
-            ? !call_user_func([$this, $method])
34
+        return method_exists( $this, $method )
35
+            ? !call_user_func( [$this, $method] )
36 36
             : false;
37 37
     }
38 38
 
@@ -41,39 +41,39 @@  discard block
 block discarded – undo
41 41
      * @param string $whitelist
42 42
      * @return bool
43 43
      */
44
-    public function isWhitelisted($value, $whitelist)
44
+    public function isWhitelisted( $value, $whitelist )
45 45
     {
46
-        if (empty($whitelist)) {
46
+        if( empty($whitelist) ) {
47 47
             return false;
48 48
         }
49
-        return in_array($value, array_filter(explode("\n", $whitelist), 'trim'));
49
+        return in_array( $value, array_filter( explode( "\n", $whitelist ), 'trim' ) );
50 50
     }
51 51
 
52 52
     /**
53 53
      * @param string $whitelistName
54 54
      * @return string
55 55
      */
56
-    protected function getWhitelist($whitelistName)
56
+    protected function getWhitelist( $whitelistName )
57 57
     {
58
-        return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName);
58
+        return glsr( OptionManager::class )->get( 'settings.submissions.limit_whitelist.'.$whitelistName );
59 59
     }
60 60
 
61 61
     /**
62 62
      * @return bool
63 63
      */
64
-    protected function validate($key, $value, $addMetaQuery = true)
64
+    protected function validate( $key, $value, $addMetaQuery = true )
65 65
     {
66
-        if ($this->isWhitelisted($value, $this->getWhitelist($key))) {
66
+        if( $this->isWhitelisted( $value, $this->getWhitelist( $key ) ) ) {
67 67
             return true;
68 68
         }
69
-        add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2);
70
-        $args = ['assigned_to' => glsr_get($this->request, 'assign_to')];
71
-        if ($addMetaQuery) {
69
+        add_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2 );
70
+        $args = ['assigned_to' => glsr_get( $this->request, 'assign_to' )];
71
+        if( $addMetaQuery ) {
72 72
             $args[$key] = $value;
73 73
         }
74
-        $reviews = glsr_get_reviews($args);
75
-        remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5);
76
-        return 0 === count($reviews);
74
+        $reviews = glsr_get_reviews( $args );
75
+        remove_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5 );
76
+        return 0 === count( $reviews );
77 77
     }
78 78
 
79 79
     /**
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
      */
82 82
     protected function validateByEmail()
83 83
     {
84
-        glsr_log()->debug('Email is: '.glsr_get($this->request, 'email'));
85
-        return $this->validate('email', glsr_get($this->request, 'email'));
84
+        glsr_log()->debug( 'Email is: '.glsr_get( $this->request, 'email' ) );
85
+        return $this->validate( 'email', glsr_get( $this->request, 'email' ) );
86 86
     }
87 87
 
88 88
     /**
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
      */
91 91
     protected function validateByIpAddress()
92 92
     {
93
-        glsr_log()->debug('IP Address is: '.glsr_get($this->request, 'ip_address'));
94
-        return $this->validate('ip_address', glsr_get($this->request, 'ip_address'));
93
+        glsr_log()->debug( 'IP Address is: '.glsr_get( $this->request, 'ip_address' ) );
94
+        return $this->validate( 'ip_address', glsr_get( $this->request, 'ip_address' ) );
95 95
     }
96 96
 
97 97
     /**
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
     protected function validateByUsername()
101 101
     {
102 102
         $user = wp_get_current_user();
103
-        if (!$user->exists()) {
103
+        if( !$user->exists() ) {
104 104
             return true;
105 105
         }
106
-        glsr_log()->debug('Username is: '.$user->user_login);
107
-        return $this->validate('username', $user->user_login, false);
106
+        glsr_log()->debug( 'Username is: '.$user->user_login );
107
+        return $this->validate( 'username', $user->user_login, false );
108 108
     }
109 109
 }
Please login to merge, or discard this patch.
views/pages/welcome/support.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <p class="about-description">
4
-    Still need help with <?= glsr()->name; ?>? We offer excellent support for you. But don't forget to check our <a target="_blank" href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!shortcodes'); ?>">documentation</a> first.
4
+    Still need help with <?= glsr()->name; ?>? We offer excellent support for you. But don't forget to check our <a target="_blank" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!shortcodes' ); ?>">documentation</a> first.
5 5
 </p>
6 6
 <div class="is-fullwidth">
7 7
     <div class="glsr-flex-row glsr-has-2-columns">
Please login to merge, or discard this patch.
plugin/Handlers/EnqueueAdminAssets.php 1 patch
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -10,158 +10,158 @@
 block discarded – undo
10 10
 
11 11
 class EnqueueAdminAssets
12 12
 {
13
-    /**
14
-     * @var array
15
-     */
16
-    protected $pointers;
13
+	/**
14
+	 * @var array
15
+	 */
16
+	protected $pointers;
17 17
 
18
-    /**
19
-     * @return void
20
-     */
21
-    public function handle(Command $command)
22
-    {
23
-        $this->generatePointers($command->pointers);
24
-        $this->enqueueAssets();
25
-        $this->localizeAssets();
26
-    }
18
+	/**
19
+	 * @return void
20
+	 */
21
+	public function handle(Command $command)
22
+	{
23
+		$this->generatePointers($command->pointers);
24
+		$this->enqueueAssets();
25
+		$this->localizeAssets();
26
+	}
27 27
 
28
-    /**
29
-     * @return void
30
-     */
31
-    public function enqueueAssets()
32
-    {
33
-        wp_enqueue_style(
34
-            Application::ID,
35
-            glsr()->url('assets/styles/'.Application::ID.'-admin.css'),
36
-            [],
37
-            glsr()->version
38
-        );
39
-        if (!$this->isCurrentScreen()) {
40
-            return;
41
-        }
42
-        wp_enqueue_script(
43
-            Application::ID,
44
-            glsr()->url('assets/scripts/'.Application::ID.'-admin.js'),
45
-            $this->getDependencies(),
46
-            glsr()->version,
47
-            true
48
-        );
49
-        if (!empty($this->pointers)) {
50
-            wp_enqueue_style('wp-pointer');
51
-            wp_enqueue_script('wp-pointer');
52
-        }
53
-    }
28
+	/**
29
+	 * @return void
30
+	 */
31
+	public function enqueueAssets()
32
+	{
33
+		wp_enqueue_style(
34
+			Application::ID,
35
+			glsr()->url('assets/styles/'.Application::ID.'-admin.css'),
36
+			[],
37
+			glsr()->version
38
+		);
39
+		if (!$this->isCurrentScreen()) {
40
+			return;
41
+		}
42
+		wp_enqueue_script(
43
+			Application::ID,
44
+			glsr()->url('assets/scripts/'.Application::ID.'-admin.js'),
45
+			$this->getDependencies(),
46
+			glsr()->version,
47
+			true
48
+		);
49
+		if (!empty($this->pointers)) {
50
+			wp_enqueue_style('wp-pointer');
51
+			wp_enqueue_script('wp-pointer');
52
+		}
53
+	}
54 54
 
55
-    /**
56
-     * @return void
57
-     */
58
-    public function localizeAssets()
59
-    {
60
-        $variables = [
61
-            'action' => Application::PREFIX.'action',
62
-            'addons' => [],
63
-            'ajaxurl' => admin_url('admin-ajax.php'),
64
-            'hideoptions' => [
65
-                'site_reviews' => glsr(SiteReviewsShortcode::class)->getHideOptions(),
66
-                'site_reviews_form' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(),
67
-                'site_reviews_summary' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(),
68
-            ],
69
-            'nameprefix' => Application::ID,
70
-            'nonce' => [
71
-                'change-status' => wp_create_nonce('change-status'),
72
-                'clear-console' => wp_create_nonce('clear-console'),
73
-                'count-reviews' => wp_create_nonce('count-reviews'),
74
-                'fetch-console' => wp_create_nonce('fetch-console'),
75
-                'mce-shortcode' => wp_create_nonce('mce-shortcode'),
76
-                'sync-reviews' => wp_create_nonce('sync-reviews'),
77
-                'toggle-pinned' => wp_create_nonce('toggle-pinned'),
78
-            ],
79
-            'pointers' => $this->pointers,
80
-            'shortcodes' => [],
81
-            'tinymce' => [
82
-                'glsr_shortcode' => glsr()->url('assets/scripts/mce-plugin.js'),
83
-            ],
84
-        ];
85
-        if (user_can_richedit()) {
86
-            $variables['shortcodes'] = $this->localizeShortcodes();
87
-        }
88
-        $variables = apply_filters('site-reviews/enqueue/admin/localize', $variables);
89
-        wp_localize_script(Application::ID, 'GLSR', $variables);
90
-    }
55
+	/**
56
+	 * @return void
57
+	 */
58
+	public function localizeAssets()
59
+	{
60
+		$variables = [
61
+			'action' => Application::PREFIX.'action',
62
+			'addons' => [],
63
+			'ajaxurl' => admin_url('admin-ajax.php'),
64
+			'hideoptions' => [
65
+				'site_reviews' => glsr(SiteReviewsShortcode::class)->getHideOptions(),
66
+				'site_reviews_form' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(),
67
+				'site_reviews_summary' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(),
68
+			],
69
+			'nameprefix' => Application::ID,
70
+			'nonce' => [
71
+				'change-status' => wp_create_nonce('change-status'),
72
+				'clear-console' => wp_create_nonce('clear-console'),
73
+				'count-reviews' => wp_create_nonce('count-reviews'),
74
+				'fetch-console' => wp_create_nonce('fetch-console'),
75
+				'mce-shortcode' => wp_create_nonce('mce-shortcode'),
76
+				'sync-reviews' => wp_create_nonce('sync-reviews'),
77
+				'toggle-pinned' => wp_create_nonce('toggle-pinned'),
78
+			],
79
+			'pointers' => $this->pointers,
80
+			'shortcodes' => [],
81
+			'tinymce' => [
82
+				'glsr_shortcode' => glsr()->url('assets/scripts/mce-plugin.js'),
83
+			],
84
+		];
85
+		if (user_can_richedit()) {
86
+			$variables['shortcodes'] = $this->localizeShortcodes();
87
+		}
88
+		$variables = apply_filters('site-reviews/enqueue/admin/localize', $variables);
89
+		wp_localize_script(Application::ID, 'GLSR', $variables);
90
+	}
91 91
 
92
-    /**
93
-     * @return array
94
-     */
95
-    protected function getDependencies()
96
-    {
97
-        $dependencies = apply_filters('site-reviews/enqueue/admin/dependencies', []);
98
-        $dependencies = array_merge($dependencies, [
99
-            'jquery', 'jquery-ui-sortable', 'underscore', 'wp-util',
100
-        ]);
101
-        return $dependencies;
102
-    }
92
+	/**
93
+	 * @return array
94
+	 */
95
+	protected function getDependencies()
96
+	{
97
+		$dependencies = apply_filters('site-reviews/enqueue/admin/dependencies', []);
98
+		$dependencies = array_merge($dependencies, [
99
+			'jquery', 'jquery-ui-sortable', 'underscore', 'wp-util',
100
+		]);
101
+		return $dependencies;
102
+	}
103 103
 
104
-    /**
105
-     * @return array
106
-     */
107
-    protected function generatePointer(array $pointer)
108
-    {
109
-        return [
110
-            'id' => $pointer['id'],
111
-            'options' => [
112
-                'content' => '<h3>'.$pointer['title'].'</h3><p>'.$pointer['content'].'</p>',
113
-                'position' => $pointer['position'],
114
-            ],
115
-            'screen' => $pointer['screen'],
116
-            'target' => $pointer['target'],
117
-        ];
118
-    }
104
+	/**
105
+	 * @return array
106
+	 */
107
+	protected function generatePointer(array $pointer)
108
+	{
109
+		return [
110
+			'id' => $pointer['id'],
111
+			'options' => [
112
+				'content' => '<h3>'.$pointer['title'].'</h3><p>'.$pointer['content'].'</p>',
113
+				'position' => $pointer['position'],
114
+			],
115
+			'screen' => $pointer['screen'],
116
+			'target' => $pointer['target'],
117
+		];
118
+	}
119 119
 
120
-    /**
121
-     * @return void
122
-     */
123
-    protected function generatePointers(array $pointers)
124
-    {
125
-        $dismissedPointers = get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true);
126
-        $dismissedPointers = explode(',', (string) $dismissedPointers);
127
-        $generatedPointers = [];
128
-        foreach ($pointers as $pointer) {
129
-            if ($pointer['screen'] != glsr_current_screen()->id) {
130
-                continue;
131
-            }
132
-            if (in_array($pointer['id'], $dismissedPointers)) {
133
-                continue;
134
-            }
135
-            $generatedPointers[] = $this->generatePointer($pointer);
136
-        }
137
-        $this->pointers = $generatedPointers;
138
-    }
120
+	/**
121
+	 * @return void
122
+	 */
123
+	protected function generatePointers(array $pointers)
124
+	{
125
+		$dismissedPointers = get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true);
126
+		$dismissedPointers = explode(',', (string) $dismissedPointers);
127
+		$generatedPointers = [];
128
+		foreach ($pointers as $pointer) {
129
+			if ($pointer['screen'] != glsr_current_screen()->id) {
130
+				continue;
131
+			}
132
+			if (in_array($pointer['id'], $dismissedPointers)) {
133
+				continue;
134
+			}
135
+			$generatedPointers[] = $this->generatePointer($pointer);
136
+		}
137
+		$this->pointers = $generatedPointers;
138
+	}
139 139
 
140
-    /**
141
-     * @return bool
142
-     */
143
-    protected function isCurrentScreen()
144
-    {
145
-        $screen = glsr_current_screen();
146
-        return Application::POST_TYPE == $screen->post_type
147
-            || 'dashboard' == $screen->id
148
-            || 'plugins_page_'.Application::ID == $screen->id
149
-            || 'post' == $screen->base
150
-            || 'widgets' == $screen->id;
151
-    }
140
+	/**
141
+	 * @return bool
142
+	 */
143
+	protected function isCurrentScreen()
144
+	{
145
+		$screen = glsr_current_screen();
146
+		return Application::POST_TYPE == $screen->post_type
147
+			|| 'dashboard' == $screen->id
148
+			|| 'plugins_page_'.Application::ID == $screen->id
149
+			|| 'post' == $screen->base
150
+			|| 'widgets' == $screen->id;
151
+	}
152 152
 
153
-    /**
154
-     * @return array
155
-     */
156
-    protected function localizeShortcodes()
157
-    {
158
-        $variables = [];
159
-        foreach (glsr()->mceShortcodes as $tag => $args) {
160
-            if (empty($args['required'])) {
161
-                continue;
162
-            }
163
-            $variables[$tag] = $args['required'];
164
-        }
165
-        return $variables;
166
-    }
153
+	/**
154
+	 * @return array
155
+	 */
156
+	protected function localizeShortcodes()
157
+	{
158
+		$variables = [];
159
+		foreach (glsr()->mceShortcodes as $tag => $args) {
160
+			if (empty($args['required'])) {
161
+				continue;
162
+			}
163
+			$variables[$tag] = $args['required'];
164
+		}
165
+		return $variables;
166
+	}
167 167
 }
Please login to merge, or discard this patch.
plugin/Controllers/AdminController.php 2 patches
Indentation   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -15,222 +15,222 @@
 block discarded – undo
15 15
 
16 16
 class AdminController extends Controller
17 17
 {
18
-    /**
19
-     * @return void
20
-     * @action admin_enqueue_scripts
21
-     */
22
-    public function enqueueAssets()
23
-    {
24
-        $command = new EnqueueAdminAssets([
25
-            'pointers' => [[
26
-                'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
27
-                'id' => 'glsr-pointer-pinned',
28
-                'position' => [
29
-                    'edge' => 'right',
30
-                    'align' => 'middle',
31
-                ],
32
-                'screen' => Application::POST_TYPE,
33
-                'target' => '#misc-pub-pinned',
34
-                'title' => __('Pin Your Reviews', 'site-reviews'),
35
-            ]],
36
-        ]);
37
-        $this->execute($command);
38
-    }
39
-
40
-    /**
41
-     * @return array
42
-     * @filter plugin_action_links_site-reviews/site-reviews.php
43
-     */
44
-    public function filterActionLinks(array $links)
45
-    {
46
-        $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [
47
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'),
48
-        ]);
49
-        $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
50
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
51
-        ]);
52
-        return $links;
53
-    }
54
-
55
-    /**
56
-     * @param array $capabilities
57
-     * @param string $capability
58
-     * @return array
59
-     * @filter map_meta_cap
60
-     */
61
-    public function filterCreateCapability($capabilities, $capability)
62
-    {
63
-        if ($capability == 'create_'.Application::POST_TYPE) {
64
-            $capabilities[] = 'do_not_allow';
65
-        }
66
-        return $capabilities;
67
-    }
68
-
69
-    /**
70
-     * @param array $items
71
-     * @return array
72
-     * @filter dashboard_glance_items
73
-     */
74
-    public function filterDashboardGlanceItems($items)
75
-    {
76
-        $postCount = wp_count_posts(Application::POST_TYPE);
77
-        if (empty($postCount->publish)) {
78
-            return $items;
79
-        }
80
-        $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
81
-        $text = sprintf($text, number_format_i18n($postCount->publish));
82
-        $items = glsr(Helper::class)->consolidateArray($items);
83
-        $items[] = current_user_can(get_post_type_object(Application::POST_TYPE)->cap->edit_posts)
84
-            ? glsr(Builder::class)->a($text, [
85
-                'class' => 'glsr-review-count',
86
-                'href' => 'edit.php?post_type='.Application::POST_TYPE,
87
-            ])
88
-            : glsr(Builder::class)->span($text, [
89
-                'class' => 'glsr-review-count',
90
-            ]);
91
-        return $items;
92
-    }
93
-
94
-    /**
95
-     * @param array $plugins
96
-     * @return array
97
-     * @filter mce_external_plugins
98
-     */
99
-    public function filterTinymcePlugins($plugins)
100
-    {
101
-        if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
102
-            $plugins = glsr(Helper::class)->consolidateArray($plugins);
103
-            $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
104
-        }
105
-        return $plugins;
106
-    }
107
-
108
-    /**
109
-     * @return void
110
-     * @action admin_init
111
-     */
112
-    public function registerTinymcePopups()
113
-    {
114
-        $command = new RegisterTinymcePopups([
115
-            'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
116
-            'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
117
-            'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
118
-        ]);
119
-        $this->execute($command);
120
-    }
121
-
122
-    /**
123
-     * @param string $editorId
124
-     * @return void|null
125
-     * @action media_buttons
126
-     */
127
-    public function renderTinymceButton($editorId)
128
-    {
129
-        $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
130
-        if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
131
-            return;
132
-        }
133
-        $shortcodes = [];
134
-        foreach (glsr()->mceShortcodes as $shortcode => $values) {
135
-            $shortcodes[$shortcode] = $values;
136
-        }
137
-        if (empty($shortcodes)) {
138
-            return;
139
-        }
140
-        glsr()->render('partials/editor/tinymce', [
141
-            'shortcodes' => $shortcodes,
142
-        ]);
143
-    }
144
-
145
-    /**
146
-     * @return void
147
-     */
148
-    public function routerClearConsole()
149
-    {
150
-        glsr(Console::class)->clear();
151
-        glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
152
-    }
153
-
154
-    /**
155
-     * @return void
156
-     */
157
-    public function routerFetchConsole()
158
-    {
159
-        glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
160
-    }
161
-
162
-    /**
163
-     * @param bool $showNotice
164
-     * @return void
165
-     */
166
-    public function routerCountReviews($showNotice = true)
167
-    {
168
-        glsr(CountsManager::class)->countAll();
169
-        glsr(OptionManager::class)->set('last_review_count', current_time('timestamp'));
170
-        if ($showNotice) {
171
-            glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
172
-        }
173
-    }
174
-
175
-    /**
176
-     * @return void
177
-     */
178
-    public function routerDownloadConsole()
179
-    {
180
-        $this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
181
-    }
182
-
183
-    /**
184
-     * @return void
185
-     */
186
-    public function routerDownloadSystemInfo()
187
-    {
188
-        $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
189
-    }
190
-
191
-    /**
192
-     * @return void
193
-     */
194
-    public function routerExportSettings()
195
-    {
196
-        $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
197
-    }
198
-
199
-    /**
200
-     * @return void
201
-     */
202
-    public function routerImportSettings()
203
-    {
204
-        $file = $_FILES['import-file'];
205
-        if (UPLOAD_ERR_OK !== $file['error']) {
206
-            return glsr(Notice::class)->addError($this->getUploadError($file['error']));
207
-        }
208
-        if ('application/json' !== $file['type'] || !glsr(Helper::class)->endsWith('.json', $file['name'])) {
209
-            return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
210
-        }
211
-        $settings = json_decode(file_get_contents($file['tmp_name']), true);
212
-        if (empty($settings)) {
213
-            return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
214
-        }
215
-        glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
216
-        glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
217
-    }
218
-
219
-    /**
220
-     * @param int $errorCode
221
-     * @return string
222
-     */
223
-    protected function getUploadError($errorCode)
224
-    {
225
-        $errors = [
226
-            UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
227
-            UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
228
-            UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
229
-            UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
230
-            UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
231
-            UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
232
-            UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
233
-        ];
234
-        return glsr_get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
235
-    }
18
+	/**
19
+	 * @return void
20
+	 * @action admin_enqueue_scripts
21
+	 */
22
+	public function enqueueAssets()
23
+	{
24
+		$command = new EnqueueAdminAssets([
25
+			'pointers' => [[
26
+				'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
27
+				'id' => 'glsr-pointer-pinned',
28
+				'position' => [
29
+					'edge' => 'right',
30
+					'align' => 'middle',
31
+				],
32
+				'screen' => Application::POST_TYPE,
33
+				'target' => '#misc-pub-pinned',
34
+				'title' => __('Pin Your Reviews', 'site-reviews'),
35
+			]],
36
+		]);
37
+		$this->execute($command);
38
+	}
39
+
40
+	/**
41
+	 * @return array
42
+	 * @filter plugin_action_links_site-reviews/site-reviews.php
43
+	 */
44
+	public function filterActionLinks(array $links)
45
+	{
46
+		$links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [
47
+			'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'),
48
+		]);
49
+		$links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
50
+			'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
51
+		]);
52
+		return $links;
53
+	}
54
+
55
+	/**
56
+	 * @param array $capabilities
57
+	 * @param string $capability
58
+	 * @return array
59
+	 * @filter map_meta_cap
60
+	 */
61
+	public function filterCreateCapability($capabilities, $capability)
62
+	{
63
+		if ($capability == 'create_'.Application::POST_TYPE) {
64
+			$capabilities[] = 'do_not_allow';
65
+		}
66
+		return $capabilities;
67
+	}
68
+
69
+	/**
70
+	 * @param array $items
71
+	 * @return array
72
+	 * @filter dashboard_glance_items
73
+	 */
74
+	public function filterDashboardGlanceItems($items)
75
+	{
76
+		$postCount = wp_count_posts(Application::POST_TYPE);
77
+		if (empty($postCount->publish)) {
78
+			return $items;
79
+		}
80
+		$text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
81
+		$text = sprintf($text, number_format_i18n($postCount->publish));
82
+		$items = glsr(Helper::class)->consolidateArray($items);
83
+		$items[] = current_user_can(get_post_type_object(Application::POST_TYPE)->cap->edit_posts)
84
+			? glsr(Builder::class)->a($text, [
85
+				'class' => 'glsr-review-count',
86
+				'href' => 'edit.php?post_type='.Application::POST_TYPE,
87
+			])
88
+			: glsr(Builder::class)->span($text, [
89
+				'class' => 'glsr-review-count',
90
+			]);
91
+		return $items;
92
+	}
93
+
94
+	/**
95
+	 * @param array $plugins
96
+	 * @return array
97
+	 * @filter mce_external_plugins
98
+	 */
99
+	public function filterTinymcePlugins($plugins)
100
+	{
101
+		if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
102
+			$plugins = glsr(Helper::class)->consolidateArray($plugins);
103
+			$plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
104
+		}
105
+		return $plugins;
106
+	}
107
+
108
+	/**
109
+	 * @return void
110
+	 * @action admin_init
111
+	 */
112
+	public function registerTinymcePopups()
113
+	{
114
+		$command = new RegisterTinymcePopups([
115
+			'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
116
+			'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
117
+			'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
118
+		]);
119
+		$this->execute($command);
120
+	}
121
+
122
+	/**
123
+	 * @param string $editorId
124
+	 * @return void|null
125
+	 * @action media_buttons
126
+	 */
127
+	public function renderTinymceButton($editorId)
128
+	{
129
+		$allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
130
+		if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
131
+			return;
132
+		}
133
+		$shortcodes = [];
134
+		foreach (glsr()->mceShortcodes as $shortcode => $values) {
135
+			$shortcodes[$shortcode] = $values;
136
+		}
137
+		if (empty($shortcodes)) {
138
+			return;
139
+		}
140
+		glsr()->render('partials/editor/tinymce', [
141
+			'shortcodes' => $shortcodes,
142
+		]);
143
+	}
144
+
145
+	/**
146
+	 * @return void
147
+	 */
148
+	public function routerClearConsole()
149
+	{
150
+		glsr(Console::class)->clear();
151
+		glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
152
+	}
153
+
154
+	/**
155
+	 * @return void
156
+	 */
157
+	public function routerFetchConsole()
158
+	{
159
+		glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
160
+	}
161
+
162
+	/**
163
+	 * @param bool $showNotice
164
+	 * @return void
165
+	 */
166
+	public function routerCountReviews($showNotice = true)
167
+	{
168
+		glsr(CountsManager::class)->countAll();
169
+		glsr(OptionManager::class)->set('last_review_count', current_time('timestamp'));
170
+		if ($showNotice) {
171
+			glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
172
+		}
173
+	}
174
+
175
+	/**
176
+	 * @return void
177
+	 */
178
+	public function routerDownloadConsole()
179
+	{
180
+		$this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
181
+	}
182
+
183
+	/**
184
+	 * @return void
185
+	 */
186
+	public function routerDownloadSystemInfo()
187
+	{
188
+		$this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
189
+	}
190
+
191
+	/**
192
+	 * @return void
193
+	 */
194
+	public function routerExportSettings()
195
+	{
196
+		$this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
197
+	}
198
+
199
+	/**
200
+	 * @return void
201
+	 */
202
+	public function routerImportSettings()
203
+	{
204
+		$file = $_FILES['import-file'];
205
+		if (UPLOAD_ERR_OK !== $file['error']) {
206
+			return glsr(Notice::class)->addError($this->getUploadError($file['error']));
207
+		}
208
+		if ('application/json' !== $file['type'] || !glsr(Helper::class)->endsWith('.json', $file['name'])) {
209
+			return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
210
+		}
211
+		$settings = json_decode(file_get_contents($file['tmp_name']), true);
212
+		if (empty($settings)) {
213
+			return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
214
+		}
215
+		glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
216
+		glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
217
+	}
218
+
219
+	/**
220
+	 * @param int $errorCode
221
+	 * @return string
222
+	 */
223
+	protected function getUploadError($errorCode)
224
+	{
225
+		$errors = [
226
+			UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
227
+			UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
228
+			UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
229
+			UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
230
+			UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
231
+			UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
232
+			UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
233
+		];
234
+		return glsr_get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
235
+	}
236 236
 }
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function enqueueAssets()
23 23
     {
24
-        $command = new EnqueueAdminAssets([
24
+        $command = new EnqueueAdminAssets( [
25 25
             'pointers' => [[
26
-                'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
26
+                'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ),
27 27
                 'id' => 'glsr-pointer-pinned',
28 28
                 'position' => [
29 29
                     'edge' => 'right',
@@ -31,24 +31,24 @@  discard block
 block discarded – undo
31 31
                 ],
32 32
                 'screen' => Application::POST_TYPE,
33 33
                 'target' => '#misc-pub-pinned',
34
-                'title' => __('Pin Your Reviews', 'site-reviews'),
34
+                'title' => __( 'Pin Your Reviews', 'site-reviews' ),
35 35
             ]],
36
-        ]);
37
-        $this->execute($command);
36
+        ] );
37
+        $this->execute( $command );
38 38
     }
39 39
 
40 40
     /**
41 41
      * @return array
42 42
      * @filter plugin_action_links_site-reviews/site-reviews.php
43 43
      */
44
-    public function filterActionLinks(array $links)
44
+    public function filterActionLinks( array $links )
45 45
     {
46
-        $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [
47
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'),
48
-        ]);
49
-        $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
50
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
51
-        ]);
46
+        $links['documentation'] = glsr( Builder::class )->a( __( 'Help', 'site-reviews' ), [
47
+            'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=documentation' ),
48
+        ] );
49
+        $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [
50
+            'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ),
51
+        ] );
52 52
         return $links;
53 53
     }
54 54
 
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
      * @return array
59 59
      * @filter map_meta_cap
60 60
      */
61
-    public function filterCreateCapability($capabilities, $capability)
61
+    public function filterCreateCapability( $capabilities, $capability )
62 62
     {
63
-        if ($capability == 'create_'.Application::POST_TYPE) {
63
+        if( $capability == 'create_'.Application::POST_TYPE ) {
64 64
             $capabilities[] = 'do_not_allow';
65 65
         }
66 66
         return $capabilities;
@@ -71,23 +71,23 @@  discard block
 block discarded – undo
71 71
      * @return array
72 72
      * @filter dashboard_glance_items
73 73
      */
74
-    public function filterDashboardGlanceItems($items)
74
+    public function filterDashboardGlanceItems( $items )
75 75
     {
76
-        $postCount = wp_count_posts(Application::POST_TYPE);
77
-        if (empty($postCount->publish)) {
76
+        $postCount = wp_count_posts( Application::POST_TYPE );
77
+        if( empty($postCount->publish) ) {
78 78
             return $items;
79 79
         }
80
-        $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
81
-        $text = sprintf($text, number_format_i18n($postCount->publish));
82
-        $items = glsr(Helper::class)->consolidateArray($items);
83
-        $items[] = current_user_can(get_post_type_object(Application::POST_TYPE)->cap->edit_posts)
84
-            ? glsr(Builder::class)->a($text, [
80
+        $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' );
81
+        $text = sprintf( $text, number_format_i18n( $postCount->publish ) );
82
+        $items = glsr( Helper::class )->consolidateArray( $items );
83
+        $items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts )
84
+            ? glsr( Builder::class )->a( $text, [
85 85
                 'class' => 'glsr-review-count',
86 86
                 'href' => 'edit.php?post_type='.Application::POST_TYPE,
87
-            ])
88
-            : glsr(Builder::class)->span($text, [
87
+            ] )
88
+            : glsr( Builder::class )->span( $text, [
89 89
                 'class' => 'glsr-review-count',
90
-            ]);
90
+            ] );
91 91
         return $items;
92 92
     }
93 93
 
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
      * @return array
97 97
      * @filter mce_external_plugins
98 98
      */
99
-    public function filterTinymcePlugins($plugins)
99
+    public function filterTinymcePlugins( $plugins )
100 100
     {
101
-        if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
102
-            $plugins = glsr(Helper::class)->consolidateArray($plugins);
103
-            $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
101
+        if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
102
+            $plugins = glsr( Helper::class )->consolidateArray( $plugins );
103
+            $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' );
104 104
         }
105 105
         return $plugins;
106 106
     }
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function registerTinymcePopups()
113 113
     {
114
-        $command = new RegisterTinymcePopups([
115
-            'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
116
-            'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
117
-            'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
118
-        ]);
119
-        $this->execute($command);
114
+        $command = new RegisterTinymcePopups( [
115
+            'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ),
116
+            'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ),
117
+            'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ),
118
+        ] );
119
+        $this->execute( $command );
120 120
     }
121 121
 
122 122
     /**
@@ -124,22 +124,22 @@  discard block
 block discarded – undo
124 124
      * @return void|null
125 125
      * @action media_buttons
126 126
      */
127
-    public function renderTinymceButton($editorId)
127
+    public function renderTinymceButton( $editorId )
128 128
     {
129
-        $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
130
-        if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
129
+        $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId );
130
+        if( 'post' != glsr_current_screen()->base || !in_array( $editorId, $allowedEditors ) ) {
131 131
             return;
132 132
         }
133 133
         $shortcodes = [];
134
-        foreach (glsr()->mceShortcodes as $shortcode => $values) {
134
+        foreach( glsr()->mceShortcodes as $shortcode => $values ) {
135 135
             $shortcodes[$shortcode] = $values;
136 136
         }
137
-        if (empty($shortcodes)) {
137
+        if( empty($shortcodes) ) {
138 138
             return;
139 139
         }
140
-        glsr()->render('partials/editor/tinymce', [
140
+        glsr()->render( 'partials/editor/tinymce', [
141 141
             'shortcodes' => $shortcodes,
142
-        ]);
142
+        ] );
143 143
     }
144 144
 
145 145
     /**
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function routerClearConsole()
149 149
     {
150
-        glsr(Console::class)->clear();
151
-        glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
150
+        glsr( Console::class )->clear();
151
+        glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) );
152 152
     }
153 153
 
154 154
     /**
@@ -156,19 +156,19 @@  discard block
 block discarded – undo
156 156
      */
157 157
     public function routerFetchConsole()
158 158
     {
159
-        glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
159
+        glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) );
160 160
     }
161 161
 
162 162
     /**
163 163
      * @param bool $showNotice
164 164
      * @return void
165 165
      */
166
-    public function routerCountReviews($showNotice = true)
166
+    public function routerCountReviews( $showNotice = true )
167 167
     {
168
-        glsr(CountsManager::class)->countAll();
169
-        glsr(OptionManager::class)->set('last_review_count', current_time('timestamp'));
170
-        if ($showNotice) {
171
-            glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
168
+        glsr( CountsManager::class )->countAll();
169
+        glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ) );
170
+        if( $showNotice ) {
171
+            glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) );
172 172
         }
173 173
     }
174 174
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      */
178 178
     public function routerDownloadConsole()
179 179
     {
180
-        $this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
180
+        $this->download( Application::ID.'-console.txt', glsr( Console::class )->get() );
181 181
     }
182 182
 
183 183
     /**
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
      */
186 186
     public function routerDownloadSystemInfo()
187 187
     {
188
-        $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
188
+        $this->download( Application::ID.'-system-info.txt', glsr( System::class )->get() );
189 189
     }
190 190
 
191 191
     /**
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function routerExportSettings()
195 195
     {
196
-        $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
196
+        $this->download( Application::ID.'-settings.json', glsr( OptionManager::class )->json() );
197 197
     }
198 198
 
199 199
     /**
@@ -202,35 +202,35 @@  discard block
 block discarded – undo
202 202
     public function routerImportSettings()
203 203
     {
204 204
         $file = $_FILES['import-file'];
205
-        if (UPLOAD_ERR_OK !== $file['error']) {
206
-            return glsr(Notice::class)->addError($this->getUploadError($file['error']));
205
+        if( UPLOAD_ERR_OK !== $file['error'] ) {
206
+            return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) );
207 207
         }
208
-        if ('application/json' !== $file['type'] || !glsr(Helper::class)->endsWith('.json', $file['name'])) {
209
-            return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
208
+        if( 'application/json' !== $file['type'] || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) {
209
+            return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) );
210 210
         }
211
-        $settings = json_decode(file_get_contents($file['tmp_name']), true);
212
-        if (empty($settings)) {
213
-            return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
211
+        $settings = json_decode( file_get_contents( $file['tmp_name'] ), true );
212
+        if( empty($settings) ) {
213
+            return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) );
214 214
         }
215
-        glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
216
-        glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
215
+        glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) );
216
+        glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) );
217 217
     }
218 218
 
219 219
     /**
220 220
      * @param int $errorCode
221 221
      * @return string
222 222
      */
223
-    protected function getUploadError($errorCode)
223
+    protected function getUploadError( $errorCode )
224 224
     {
225 225
         $errors = [
226
-            UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
227
-            UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
228
-            UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
229
-            UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
230
-            UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
231
-            UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
232
-            UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
226
+            UPLOAD_ERR_INI_SIZE => __( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews' ),
227
+            UPLOAD_ERR_FORM_SIZE => __( 'The uploaded file is too big.', 'site-reviews' ),
228
+            UPLOAD_ERR_PARTIAL => __( 'The uploaded file was only partially uploaded.', 'site-reviews' ),
229
+            UPLOAD_ERR_NO_FILE => __( 'No file was uploaded.', 'site-reviews' ),
230
+            UPLOAD_ERR_NO_TMP_DIR => __( 'Missing a temporary folder.', 'site-reviews' ),
231
+            UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ),
232
+            UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ),
233 233
         ];
234
-        return glsr_get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
234
+        return glsr_get( $errors, $errorCode, __( 'Unknown upload error.', 'site-reviews' ) );
235 235
     }
236 236
 }
Please login to merge, or discard this patch.
plugin/Defaults/EmailDefaults.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
 
8 8
 class EmailDefaults extends Defaults
9 9
 {
10
-    /**
11
-     * @return array
12
-     */
13
-    protected function defaults()
14
-    {
15
-        return [
16
-            'after' => '',
17
-            'attachments' => [],
18
-            'bcc' => '',
19
-            'before' => '',
20
-            'cc' => '',
21
-            'from' => $this->getFromName().' <'.$this->getFromEmail().'>',
22
-            'message' => '',
23
-            'reply-to' => '',
24
-            'subject' => '',
25
-            'template' => '',
26
-            'template-tags' => [],
27
-            'to' => '',
28
-        ];
29
-    }
10
+	/**
11
+	 * @return array
12
+	 */
13
+	protected function defaults()
14
+	{
15
+		return [
16
+			'after' => '',
17
+			'attachments' => [],
18
+			'bcc' => '',
19
+			'before' => '',
20
+			'cc' => '',
21
+			'from' => $this->getFromName().' <'.$this->getFromEmail().'>',
22
+			'message' => '',
23
+			'reply-to' => '',
24
+			'subject' => '',
25
+			'template' => '',
26
+			'template-tags' => [],
27
+			'to' => '',
28
+		];
29
+	}
30 30
 
31
-    /**
32
-     * @return string
33
-     */
34
-    protected function getFromEmail()
35
-    {
36
-        return glsr(OptionManager::class)->getWP('admin_email');
37
-    }
31
+	/**
32
+	 * @return string
33
+	 */
34
+	protected function getFromEmail()
35
+	{
36
+		return glsr(OptionManager::class)->getWP('admin_email');
37
+	}
38 38
 
39
-    /**
40
-     * @return string
41
-     */
42
-    protected function getFromName()
43
-    {
44
-        return wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES);
45
-    }
39
+	/**
40
+	 * @return string
41
+	 */
42
+	protected function getFromName()
43
+	{
44
+		return wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES);
45
+	}
46 46
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      */
34 34
     protected function getFromEmail()
35 35
     {
36
-        return glsr(OptionManager::class)->getWP('admin_email');
36
+        return glsr( OptionManager::class )->getWP( 'admin_email' );
37 37
     }
38 38
 
39 39
     /**
@@ -41,6 +41,6 @@  discard block
 block discarded – undo
41 41
      */
42 42
     protected function getFromName()
43 43
     {
44
-        return wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES);
44
+        return wp_specialchars_decode( glsr( OptionManager::class )->getWP( 'blogname' ), ENT_QUOTES );
45 45
     }
46 46
 }
Please login to merge, or discard this patch.
views/pages/welcome/whatsnew.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <p class="about-description">We think you'll love the changes in this new release!</p>
4 4
 <div class="is-fullwidth">
Please login to merge, or discard this patch.