Passed
Push — master ( ccb079...7906b4 )
by Paul
04:39
created
plugin/Database/OptionManager.php 1 patch
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -9,157 +9,157 @@
 block discarded – undo
9 9
 
10 10
 class OptionManager
11 11
 {
12
-    /**
13
-     * @var array
14
-     */
15
-    protected $options;
12
+	/**
13
+	 * @var array
14
+	 */
15
+	protected $options;
16 16
 
17
-    /**
18
-     * @return string
19
-     */
20
-    public static function databaseKey($version = null)
21
-    {
22
-        if (1 == $version) {
23
-            return 'geminilabs_site_reviews_settings';
24
-        }
25
-        if (2 == $version) {
26
-            return 'geminilabs_site_reviews-v2';
27
-        }
28
-        if (null === $version) {
29
-            $version = explode('.', glsr()->version);
30
-            $version = array_shift($version);
31
-        }
32
-        return Str::snakeCase(Application::ID.'-v'.intval($version));
33
-    }
17
+	/**
18
+	 * @return string
19
+	 */
20
+	public static function databaseKey($version = null)
21
+	{
22
+		if (1 == $version) {
23
+			return 'geminilabs_site_reviews_settings';
24
+		}
25
+		if (2 == $version) {
26
+			return 'geminilabs_site_reviews-v2';
27
+		}
28
+		if (null === $version) {
29
+			$version = explode('.', glsr()->version);
30
+			$version = array_shift($version);
31
+		}
32
+		return Str::snakeCase(Application::ID.'-v'.intval($version));
33
+	}
34 34
 
35
-    /**
36
-     * @return array
37
-     */
38
-    public function all()
39
-    {
40
-        if (empty($this->options)) {
41
-            $this->reset();
42
-        }
43
-        return $this->options;
44
-    }
35
+	/**
36
+	 * @return array
37
+	 */
38
+	public function all()
39
+	{
40
+		if (empty($this->options)) {
41
+			$this->reset();
42
+		}
43
+		return $this->options;
44
+	}
45 45
 
46
-    /**
47
-     * @param string $path
48
-     * @return bool
49
-     */
50
-    public function delete($path)
51
-    {
52
-        $keys = explode('.', $path);
53
-        $last = array_pop($keys);
54
-        $options = $this->all();
55
-        $pointer = &$options;
56
-        foreach ($keys as $key) {
57
-            if (!isset($pointer[$key]) || !is_array($pointer[$key])) {
58
-                continue;
59
-            }
60
-            $pointer = &$pointer[$key];
61
-        }
62
-        unset($pointer[$last]);
63
-        return $this->set($options);
64
-    }
46
+	/**
47
+	 * @param string $path
48
+	 * @return bool
49
+	 */
50
+	public function delete($path)
51
+	{
52
+		$keys = explode('.', $path);
53
+		$last = array_pop($keys);
54
+		$options = $this->all();
55
+		$pointer = &$options;
56
+		foreach ($keys as $key) {
57
+			if (!isset($pointer[$key]) || !is_array($pointer[$key])) {
58
+				continue;
59
+			}
60
+			$pointer = &$pointer[$key];
61
+		}
62
+		unset($pointer[$last]);
63
+		return $this->set($options);
64
+	}
65 65
 
66
-    /**
67
-     * @param string $path
68
-     * @param mixed $fallback
69
-     * @param string $cast
70
-     * @return mixed
71
-     */
72
-    public function get($path = '', $fallback = '', $cast = '')
73
-    {
74
-        $result = Arr::get($this->all(), $path, $fallback);
75
-        return Helper::castTo($cast, $result);
76
-    }
66
+	/**
67
+	 * @param string $path
68
+	 * @param mixed $fallback
69
+	 * @param string $cast
70
+	 * @return mixed
71
+	 */
72
+	public function get($path = '', $fallback = '', $cast = '')
73
+	{
74
+		$result = Arr::get($this->all(), $path, $fallback);
75
+		return Helper::castTo($cast, $result);
76
+	}
77 77
 
78
-    /**
79
-     * @param string $path
80
-     * @return bool
81
-     */
82
-    public function getBool($path)
83
-    {
84
-        return Helper::castToBool($this->get($path));
85
-    }
78
+	/**
79
+	 * @param string $path
80
+	 * @return bool
81
+	 */
82
+	public function getBool($path)
83
+	{
84
+		return Helper::castToBool($this->get($path));
85
+	}
86 86
 
87
-    /**
88
-     * @param string $path
89
-     * @param mixed $fallback
90
-     * @param string $cast
91
-     * @return mixed
92
-     */
93
-    public function getWP($path, $fallback = '', $cast = '')
94
-    {
95
-        $option = get_option($path, $fallback);
96
-        if (empty($option)) {
97
-            $option = $fallback;
98
-        }
99
-        return Helper::castTo($cast, $option);
100
-    }
87
+	/**
88
+	 * @param string $path
89
+	 * @param mixed $fallback
90
+	 * @param string $cast
91
+	 * @return mixed
92
+	 */
93
+	public function getWP($path, $fallback = '', $cast = '')
94
+	{
95
+		$option = get_option($path, $fallback);
96
+		if (empty($option)) {
97
+			$option = $fallback;
98
+		}
99
+		return Helper::castTo($cast, $option);
100
+	}
101 101
 
102
-    /**
103
-     * @return string
104
-     */
105
-    public function json()
106
-    {
107
-        return json_encode($this->all());
108
-    }
102
+	/**
103
+	 * @return string
104
+	 */
105
+	public function json()
106
+	{
107
+		return json_encode($this->all());
108
+	}
109 109
 
110
-    /**
111
-     * @return array
112
-     */
113
-    public function normalize(array $options = [])
114
-    {
115
-        $options = wp_parse_args(
116
-            Arr::flatten($options),
117
-            glsr(DefaultsManager::class)->defaults()
118
-        );
119
-        array_walk($options, function (&$value) {
120
-            if (!is_string($value)) {
121
-                return;
122
-            }
123
-            $value = wp_kses($value, wp_kses_allowed_html('post'));
124
-        });
125
-        return Arr::convertFromDotNotation($options);
126
-    }
110
+	/**
111
+	 * @return array
112
+	 */
113
+	public function normalize(array $options = [])
114
+	{
115
+		$options = wp_parse_args(
116
+			Arr::flatten($options),
117
+			glsr(DefaultsManager::class)->defaults()
118
+		);
119
+		array_walk($options, function (&$value) {
120
+			if (!is_string($value)) {
121
+				return;
122
+			}
123
+			$value = wp_kses($value, wp_kses_allowed_html('post'));
124
+		});
125
+		return Arr::convertFromDotNotation($options);
126
+	}
127 127
 
128
-    /**
129
-     * @return bool
130
-     */
131
-    public function isRecaptchaEnabled()
132
-    {
133
-        $integration = $this->get('settings.submissions.recaptcha.integration');
134
-        return 'all' == $integration || ('guest' == $integration && !is_user_logged_in());
135
-    }
128
+	/**
129
+	 * @return bool
130
+	 */
131
+	public function isRecaptchaEnabled()
132
+	{
133
+		$integration = $this->get('settings.submissions.recaptcha.integration');
134
+		return 'all' == $integration || ('guest' == $integration && !is_user_logged_in());
135
+	}
136 136
 
137
-    /**
138
-     * @return array
139
-     */
140
-    public function reset()
141
-    {
142
-        $options = $this->getWP(static::databaseKey(), []);
143
-        if (!is_array($options) || empty($options)) {
144
-            delete_option(static::databaseKey());
145
-            $options = glsr()->defaults ?: [];
146
-        }
147
-        $this->options = $options;
148
-    }
137
+	/**
138
+	 * @return array
139
+	 */
140
+	public function reset()
141
+	{
142
+		$options = $this->getWP(static::databaseKey(), []);
143
+		if (!is_array($options) || empty($options)) {
144
+			delete_option(static::databaseKey());
145
+			$options = glsr()->defaults ?: [];
146
+		}
147
+		$this->options = $options;
148
+	}
149 149
 
150
-    /**
151
-     * @param string|array $pathOrOptions
152
-     * @param mixed $value
153
-     * @return bool
154
-     */
155
-    public function set($pathOrOptions, $value = '')
156
-    {
157
-        if (is_string($pathOrOptions)) {
158
-            $pathOrOptions = Arr::set($this->all(), $pathOrOptions, $value);
159
-        }
160
-        if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) {
161
-            $this->reset();
162
-        }
163
-        return $result;
164
-    }
150
+	/**
151
+	 * @param string|array $pathOrOptions
152
+	 * @param mixed $value
153
+	 * @return bool
154
+	 */
155
+	public function set($pathOrOptions, $value = '')
156
+	{
157
+		if (is_string($pathOrOptions)) {
158
+			$pathOrOptions = Arr::set($this->all(), $pathOrOptions, $value);
159
+		}
160
+		if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) {
161
+			$this->reset();
162
+		}
163
+		return $result;
164
+	}
165 165
 }
Please login to merge, or discard this patch.
plugin/Addons/Addon.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -11,83 +11,83 @@
 block discarded – undo
11 11
  */
12 12
 abstract class Addon
13 13
 {
14
-    const ID = '';
15
-    const SLUG = '';
16
-    const UPDATE_URL = '';
14
+	const ID = '';
15
+	const SLUG = '';
16
+	const UPDATE_URL = '';
17 17
 
18
-    public $file;
19
-    public $languages;
20
-    public $name;
21
-    public $testedTo;
22
-    public $updater;
23
-    public $version;
18
+	public $file;
19
+	public $languages;
20
+	public $name;
21
+	public $testedTo;
22
+	public $updater;
23
+	public $version;
24 24
 
25
-    public function __construct()
26
-    {
27
-        $this->file = str_replace('plugin/Application', static::ID, (new ReflectionClass($this))->getFileName());
28
-        $plugin = get_file_data($this->file, [
29
-            'languages' => 'Domain Path',
30
-            'name' => 'Plugin Name',
31
-            'testedTo' => 'Tested up to',
32
-            'version' => 'Version',
33
-        ], 'plugin');
34
-        array_walk($plugin, function ($value, $key) {
35
-            if (property_exists($this, $key)) {
36
-                $this->$key = $value;
37
-            }
38
-        });
39
-    }
25
+	public function __construct()
26
+	{
27
+		$this->file = str_replace('plugin/Application', static::ID, (new ReflectionClass($this))->getFileName());
28
+		$plugin = get_file_data($this->file, [
29
+			'languages' => 'Domain Path',
30
+			'name' => 'Plugin Name',
31
+			'testedTo' => 'Tested up to',
32
+			'version' => 'Version',
33
+		], 'plugin');
34
+		array_walk($plugin, function ($value, $key) {
35
+			if (property_exists($this, $key)) {
36
+				$this->$key = $value;
37
+			}
38
+		});
39
+	}
40 40
 
41
-    /**
42
-     * @param string $property
43
-     * @return void|string
44
-     */
45
-    public function __get($property)
46
-    {
47
-        if (property_exists($this, $property)) {
48
-            return $this->$property;
49
-        }
50
-        $constant = 'static::'.strtoupper($property);
51
-        if (defined($constant)) {
52
-            return constant($constant);
53
-        }
54
-    }
41
+	/**
42
+	 * @param string $property
43
+	 * @return void|string
44
+	 */
45
+	public function __get($property)
46
+	{
47
+		if (property_exists($this, $property)) {
48
+			return $this->$property;
49
+		}
50
+		$constant = 'static::'.strtoupper($property);
51
+		if (defined($constant)) {
52
+			return constant($constant);
53
+		}
54
+	}
55 55
 
56
-    public function make($class)
57
-    {}
56
+	public function make($class)
57
+	{}
58 58
 
59
-    /**
60
-     * @return void
61
-     */
62
-    abstract public function init();
59
+	/**
60
+	 * @return void
61
+	 */
62
+	abstract public function init();
63 63
 
64
-    /**
65
-     * @param string $file
66
-     * @return string
67
-     */
68
-    public function path($file = '')
69
-    {
70
-        return plugin_dir_path($this->file).ltrim(trim($file), '/');
71
-    }
64
+	/**
65
+	 * @param string $file
66
+	 * @return string
67
+	 */
68
+	public function path($file = '')
69
+	{
70
+		return plugin_dir_path($this->file).ltrim(trim($file), '/');
71
+	}
72 72
 
73
-    /**
74
-     * @return void
75
-     */
76
-    public function update()
77
-    {
78
-        $this->updater = new Updater(static::UPDATE_URL, $this->file, [
79
-            'license' => glsr_get_option('settings.licenses.'.static::ID),
80
-            'testedTo' => $this->testedTo,
81
-        ]);
82
-        $this->updater->init();
83
-    }
73
+	/**
74
+	 * @return void
75
+	 */
76
+	public function update()
77
+	{
78
+		$this->updater = new Updater(static::UPDATE_URL, $this->file, [
79
+			'license' => glsr_get_option('settings.licenses.'.static::ID),
80
+			'testedTo' => $this->testedTo,
81
+		]);
82
+		$this->updater->init();
83
+	}
84 84
 
85
-    /**
86
-     * @param string $path
87
-     * @return string
88
-     */
89
-    public function url($path = '')
90
-    {
91
-        return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
92
-    }
85
+	/**
86
+	 * @param string $path
87
+	 * @return string
88
+	 */
89
+	public function url($path = '')
90
+	{
91
+		return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
92
+	}
93 93
 }
Please login to merge, or discard this patch.
plugin/Addons/Controller.php 1 patch
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -12,325 +12,325 @@
 block discarded – undo
12 12
 
13 13
 abstract class Controller extends BaseController
14 14
 {
15
-    /**
16
-     * @var Addon
17
-     */
18
-    protected $addon;
15
+	/**
16
+	 * @var Addon
17
+	 */
18
+	protected $addon;
19 19
 
20
-    public function __construct()
21
-    {
22
-        $this->setAddon();
23
-    }
20
+	public function __construct()
21
+	{
22
+		$this->setAddon();
23
+	}
24 24
 
25
-    /**
26
-     * @return void
27
-     * @action admin_enqueue_scripts
28
-     */
29
-    public function enqueueAdminAssets()
30
-    {
31
-        if (!$this->isReviewAdminPage()) {
32
-            return;
33
-        }
34
-        $this->enqueueAsset('css', ['suffix' => 'admin']);
35
-        $this->enqueueAsset('js', ['suffix' => 'admin']);
36
-    }
25
+	/**
26
+	 * @return void
27
+	 * @action admin_enqueue_scripts
28
+	 */
29
+	public function enqueueAdminAssets()
30
+	{
31
+		if (!$this->isReviewAdminPage()) {
32
+			return;
33
+		}
34
+		$this->enqueueAsset('css', ['suffix' => 'admin']);
35
+		$this->enqueueAsset('js', ['suffix' => 'admin']);
36
+	}
37 37
 
38
-    /**
39
-     * @return void
40
-     * @action enqueue_block_editor_assets
41
-     */
42
-    public function enqueueBlockAssets()
43
-    {
44
-        $this->registerAsset('css', ['suffix' => 'blocks']);
45
-        $this->registerAsset('js', ['suffix' => 'blocks']);
46
-    }
38
+	/**
39
+	 * @return void
40
+	 * @action enqueue_block_editor_assets
41
+	 */
42
+	public function enqueueBlockAssets()
43
+	{
44
+		$this->registerAsset('css', ['suffix' => 'blocks']);
45
+		$this->registerAsset('js', ['suffix' => 'blocks']);
46
+	}
47 47
 
48
-    /**
49
-     * @return void
50
-     * @action wp_enqueue_scripts
51
-     */
52
-    public function enqueuePublicAssets()
53
-    {
54
-        $this->enqueueAsset('css');
55
-        $this->enqueueAsset('js');
56
-    }
48
+	/**
49
+	 * @return void
50
+	 * @action wp_enqueue_scripts
51
+	 */
52
+	public function enqueuePublicAssets()
53
+	{
54
+		$this->enqueueAsset('css');
55
+		$this->enqueueAsset('js');
56
+	}
57 57
 
58
-    /**
59
-     * @return array
60
-     * @filter plugin_action_links_{addon_id}/{addon_id}.php
61
-     */
62
-    public function filterActionLinks(array $links)
63
-    {
64
-        $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
65
-            'href' => admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-addons'),
66
-        ]);
67
-        return $links;
68
-    }
58
+	/**
59
+	 * @return array
60
+	 * @filter plugin_action_links_{addon_id}/{addon_id}.php
61
+	 */
62
+	public function filterActionLinks(array $links)
63
+	{
64
+		$links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
65
+			'href' => admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-addons'),
66
+		]);
67
+		return $links;
68
+	}
69 69
 
70
-    /**
71
-     * @param string $path
72
-     * @return string
73
-     * @filter site-reviews/config
74
-     */
75
-    public function filterConfigPath($path)
76
-    {
77
-        $addonPrefix = $this->addon->id.'/';
78
-        return Str::contains($path, $addonPrefix)
79
-            ? $addonPrefix.str_replace($addonPrefix, '', $path)
80
-            : $path;
81
-    }
70
+	/**
71
+	 * @param string $path
72
+	 * @return string
73
+	 * @filter site-reviews/config
74
+	 */
75
+	public function filterConfigPath($path)
76
+	{
77
+		$addonPrefix = $this->addon->id.'/';
78
+		return Str::contains($path, $addonPrefix)
79
+			? $addonPrefix.str_replace($addonPrefix, '', $path)
80
+			: $path;
81
+	}
82 82
 
83
-    /**
84
-     * @return array
85
-     * @filter site-reviews/addon/documentation
86
-     */
87
-    public function filterDocumentation(array $documentation)
88
-    {
89
-        $documentation[$this->addon->name] = glsr(Template::class)->build($this->addon->id.'/documentation');
90
-        return $documentation;
91
-    }
83
+	/**
84
+	 * @return array
85
+	 * @filter site-reviews/addon/documentation
86
+	 */
87
+	public function filterDocumentation(array $documentation)
88
+	{
89
+		$documentation[$this->addon->name] = glsr(Template::class)->build($this->addon->id.'/documentation');
90
+		return $documentation;
91
+	}
92 92
 
93
-    /**
94
-     * @param string $path
95
-     * @param string $file
96
-     * @return string
97
-     * @filter site-reviews/path
98
-     */
99
-    public function filterFilePaths($path, $file)
100
-    {
101
-        $addonPrefix = $this->addon->id.'/';
102
-        return Str::startsWith($addonPrefix, $file)
103
-            ? $this->addon->path(Str::replaceFirst($addonPrefix, '', $file))
104
-            : $path;
105
-    }
93
+	/**
94
+	 * @param string $path
95
+	 * @param string $file
96
+	 * @return string
97
+	 * @filter site-reviews/path
98
+	 */
99
+	public function filterFilePaths($path, $file)
100
+	{
101
+		$addonPrefix = $this->addon->id.'/';
102
+		return Str::startsWith($addonPrefix, $file)
103
+			? $this->addon->path(Str::replaceFirst($addonPrefix, '', $file))
104
+			: $path;
105
+	}
106 106
 
107
-    /**
108
-     * @param string $translation
109
-     * @param string $text
110
-     * @return string
111
-     * @filter site-reviews/gettext/{addon_id}
112
-     */
113
-    public function filterGettext($translation, $text)
114
-    {
115
-        return glsr(Translator::class)->translate($translation, $this->addon->id, [
116
-            'single' => $text,
117
-        ]);
118
-    }
107
+	/**
108
+	 * @param string $translation
109
+	 * @param string $text
110
+	 * @return string
111
+	 * @filter site-reviews/gettext/{addon_id}
112
+	 */
113
+	public function filterGettext($translation, $text)
114
+	{
115
+		return glsr(Translator::class)->translate($translation, $this->addon->id, [
116
+			'single' => $text,
117
+		]);
118
+	}
119 119
 
120
-    /**
121
-     * @param string $translation
122
-     * @param string $text
123
-     * @param string $context
124
-     * @return string
125
-     * @filter site-reviews/gettext_with_context/{addon_id}
126
-     */
127
-    public function filterGettextWithContext($translation, $text, $context)
128
-    {
129
-        return glsr(Translator::class)->translate($translation, $this->addon->id, [
130
-            'context' => $context,
131
-            'single' => $text,
132
-        ]);
133
-    }
120
+	/**
121
+	 * @param string $translation
122
+	 * @param string $text
123
+	 * @param string $context
124
+	 * @return string
125
+	 * @filter site-reviews/gettext_with_context/{addon_id}
126
+	 */
127
+	public function filterGettextWithContext($translation, $text, $context)
128
+	{
129
+		return glsr(Translator::class)->translate($translation, $this->addon->id, [
130
+			'context' => $context,
131
+			'single' => $text,
132
+		]);
133
+	}
134 134
 
135
-    /**
136
-     * @param string $translation
137
-     * @param string $single
138
-     * @param string $plural
139
-     * @param int $number
140
-     * @return string
141
-     * @filter site-reviews/ngettext/{addon_id}
142
-     */
143
-    public function filterNgettext($translation, $single, $plural, $number)
144
-    {
145
-        return glsr(Translator::class)->translate($translation, $this->addon->id, [
146
-            'number' => $number,
147
-            'plural' => $plural,
148
-            'single' => $single,
149
-        ]);
150
-    }
135
+	/**
136
+	 * @param string $translation
137
+	 * @param string $single
138
+	 * @param string $plural
139
+	 * @param int $number
140
+	 * @return string
141
+	 * @filter site-reviews/ngettext/{addon_id}
142
+	 */
143
+	public function filterNgettext($translation, $single, $plural, $number)
144
+	{
145
+		return glsr(Translator::class)->translate($translation, $this->addon->id, [
146
+			'number' => $number,
147
+			'plural' => $plural,
148
+			'single' => $single,
149
+		]);
150
+	}
151 151
 
152
-    /**
153
-     * @param string $translation
154
-     * @param string $single
155
-     * @param string $plural
156
-     * @param int $number
157
-     * @param string $context
158
-     * @return string
159
-     * @filter site-reviews/ngettext_with_context/{addon_id}
160
-     */
161
-    public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context)
162
-    {
163
-        return glsr(Translator::class)->translate($translation, $this->addon->id, [
164
-            'context' => $context,
165
-            'number' => $number,
166
-            'plural' => $plural,
167
-            'single' => $single,
168
-        ]);
169
-    }
152
+	/**
153
+	 * @param string $translation
154
+	 * @param string $single
155
+	 * @param string $plural
156
+	 * @param int $number
157
+	 * @param string $context
158
+	 * @return string
159
+	 * @filter site-reviews/ngettext_with_context/{addon_id}
160
+	 */
161
+	public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context)
162
+	{
163
+		return glsr(Translator::class)->translate($translation, $this->addon->id, [
164
+			'context' => $context,
165
+			'number' => $number,
166
+			'plural' => $plural,
167
+			'single' => $single,
168
+		]);
169
+	}
170 170
 
171
-    /**
172
-     * @return array
173
-     * @filter site-reviews/addon/settings
174
-     */
175
-    public function filterSettings(array $settings)
176
-    {
177
-        $settingsFile = $this->addon->path('config/settings.php');
178
-        if (file_exists($settingsFile)) {
179
-            $settings = array_merge((include $settingsFile), $settings);
180
-        }
181
-        return $settings;
182
-    }
171
+	/**
172
+	 * @return array
173
+	 * @filter site-reviews/addon/settings
174
+	 */
175
+	public function filterSettings(array $settings)
176
+	{
177
+		$settingsFile = $this->addon->path('config/settings.php');
178
+		if (file_exists($settingsFile)) {
179
+			$settings = array_merge((include $settingsFile), $settings);
180
+		}
181
+		return $settings;
182
+	}
183 183
 
184
-    /**
185
-     * @return array
186
-     * @filter site-reviews/addon/system-info
187
-     */
188
-    public function filterSystemInfo(array $details)
189
-    {
190
-        $version = $this->addon->version;
191
-        $previousVersion = glsr(OptionManager::class)->get('addons.'.$this->addon->id.'.version_upgraded_from');
192
-        if (empty($previousVersion)) {
193
-            $previousVersion = $version;
194
-        }
195
-        $details[$this->addon->name] = sprintf('%s (%s)', $this->addon->version, $previousVersion);
196
-        return $details;
197
-    }
184
+	/**
185
+	 * @return array
186
+	 * @filter site-reviews/addon/system-info
187
+	 */
188
+	public function filterSystemInfo(array $details)
189
+	{
190
+		$version = $this->addon->version;
191
+		$previousVersion = glsr(OptionManager::class)->get('addons.'.$this->addon->id.'.version_upgraded_from');
192
+		if (empty($previousVersion)) {
193
+			$previousVersion = $version;
194
+		}
195
+		$details[$this->addon->name] = sprintf('%s (%s)', $this->addon->version, $previousVersion);
196
+		return $details;
197
+	}
198 198
 
199
-    /**
200
-     * @return array
201
-     * @filter site-reviews/translation/entries
202
-     */
203
-    public function filterTranslationEntries(array $entries)
204
-    {
205
-        $potFile = $this->addon->path($this->addon->languages.'/'.$this->addon->id.'.pot');
206
-        return glsr(Translation::class)->extractEntriesFromPotFile($potFile, $entries);
207
-    }
199
+	/**
200
+	 * @return array
201
+	 * @filter site-reviews/translation/entries
202
+	 */
203
+	public function filterTranslationEntries(array $entries)
204
+	{
205
+		$potFile = $this->addon->path($this->addon->languages.'/'.$this->addon->id.'.pot');
206
+		return glsr(Translation::class)->extractEntriesFromPotFile($potFile, $entries);
207
+	}
208 208
 
209
-    /**
210
-     * @return array
211
-     * @filter site-reviews/translator/domains
212
-     */
213
-    public function filterTranslatorDomains(array $domains)
214
-    {
215
-        $domains[] = $this->addon->id;
216
-        return $domains;
217
-    }
209
+	/**
210
+	 * @return array
211
+	 * @filter site-reviews/translator/domains
212
+	 */
213
+	public function filterTranslatorDomains(array $domains)
214
+	{
215
+		$domains[] = $this->addon->id;
216
+		return $domains;
217
+	}
218 218
 
219
-    /**
220
-     * @return void
221
-     * @action init
222
-     */
223
-    public function registerBlocks()
224
-    {
225
-    }
219
+	/**
220
+	 * @return void
221
+	 * @action init
222
+	 */
223
+	public function registerBlocks()
224
+	{
225
+	}
226 226
 
227
-    /**
228
-     * @return void
229
-     * @action plugins_loaded
230
-     */
231
-    public function registerLanguages()
232
-    {
233
-        load_plugin_textdomain($this->addon->id, false,
234
-            trailingslashit(plugin_basename($this->addon->path()).'/'.$this->addon->languages)
235
-        );
236
-    }
227
+	/**
228
+	 * @return void
229
+	 * @action plugins_loaded
230
+	 */
231
+	public function registerLanguages()
232
+	{
233
+		load_plugin_textdomain($this->addon->id, false,
234
+			trailingslashit(plugin_basename($this->addon->path()).'/'.$this->addon->languages)
235
+		);
236
+	}
237 237
 
238
-    /**
239
-     * @return void
240
-     * @action init
241
-     */
242
-    public function registerShortcodes()
243
-    {
244
-    }
238
+	/**
239
+	 * @return void
240
+	 * @action init
241
+	 */
242
+	public function registerShortcodes()
243
+	{
244
+	}
245 245
 
246
-    /**
247
-     * @return void
248
-     * @action admin_init
249
-     */
250
-    public function registerTinymcePopups()
251
-    {
252
-    }
246
+	/**
247
+	 * @return void
248
+	 * @action admin_init
249
+	 */
250
+	public function registerTinymcePopups()
251
+	{
252
+	}
253 253
 
254
-    /**
255
-     * @return void
256
-     * @action widgets_init
257
-     */
258
-    public function registerWidgets()
259
-    {
260
-    }
254
+	/**
255
+	 * @return void
256
+	 * @action widgets_init
257
+	 */
258
+	public function registerWidgets()
259
+	{
260
+	}
261 261
 
262
-    /**
263
-     * @param string $rows
264
-     * @return void
265
-     * @action site-reviews/addon/settings/{addon_slug}
266
-     */
267
-    public function renderSettings($rows)
268
-    {
269
-        glsr(Template::class)->render($this->addon->id.'/views/settings', [
270
-            'context' => [
271
-                'rows' => $rows,
272
-                'title' => $this->addon->name,
273
-            ],
274
-        ]);
275
-    }
262
+	/**
263
+	 * @param string $rows
264
+	 * @return void
265
+	 * @action site-reviews/addon/settings/{addon_slug}
266
+	 */
267
+	public function renderSettings($rows)
268
+	{
269
+		glsr(Template::class)->render($this->addon->id.'/views/settings', [
270
+			'context' => [
271
+				'rows' => $rows,
272
+				'title' => $this->addon->name,
273
+			],
274
+		]);
275
+	}
276 276
 
277
-    /**
278
-     * @param string $extension
279
-     * @return array
280
-     */
281
-    protected function buildAssetArgs($extension, array $args = [])
282
-    {
283
-        $args = wp_parse_args($args, [
284
-            'dependencies' => [],
285
-            'in_footer' => true,
286
-            'suffix' => '',
287
-        ]);
288
-        $path = 'assets/'.$this->addon->id.Str::prefix('-', $args['suffix']).'.'.$extension;
289
-        if (!file_exists($this->addon->path($path)) || !in_array($extension, ['css', 'js'])) {
290
-            return [];
291
-        }
292
-        $funcArgs = [
293
-            $this->addon->id.Str::prefix('/', $args['suffix']),
294
-            $this->addon->url($path),
295
-            array_merge([glsr()->id.Str::prefix('/', $args['suffix'])], $args['dependencies']),
296
-            $this->addon->version,
297
-        ];
298
-        if ('js' === $extension && $args['in_footer']) {
299
-            $funcArgs[] = true; // load script in the footer
300
-        }
301
-        return $funcArgs;
302
-    }
277
+	/**
278
+	 * @param string $extension
279
+	 * @return array
280
+	 */
281
+	protected function buildAssetArgs($extension, array $args = [])
282
+	{
283
+		$args = wp_parse_args($args, [
284
+			'dependencies' => [],
285
+			'in_footer' => true,
286
+			'suffix' => '',
287
+		]);
288
+		$path = 'assets/'.$this->addon->id.Str::prefix('-', $args['suffix']).'.'.$extension;
289
+		if (!file_exists($this->addon->path($path)) || !in_array($extension, ['css', 'js'])) {
290
+			return [];
291
+		}
292
+		$funcArgs = [
293
+			$this->addon->id.Str::prefix('/', $args['suffix']),
294
+			$this->addon->url($path),
295
+			array_merge([glsr()->id.Str::prefix('/', $args['suffix'])], $args['dependencies']),
296
+			$this->addon->version,
297
+		];
298
+		if ('js' === $extension && $args['in_footer']) {
299
+			$funcArgs[] = true; // load script in the footer
300
+		}
301
+		return $funcArgs;
302
+	}
303 303
 
304
-    /**
305
-     * @param string $extension
306
-     * @return void
307
-     */
308
-    protected function enqueueAsset($extension, array $args = [])
309
-    {
310
-        if ($args = $this->buildAssetArgs($extension, $args)) {
311
-            $function = 'js' === $extension
312
-                ? 'wp_enqueue_script'
313
-                : 'wp_enqueue_style';
314
-            call_user_func_array($function, $args);
315
-        }
316
-    }
304
+	/**
305
+	 * @param string $extension
306
+	 * @return void
307
+	 */
308
+	protected function enqueueAsset($extension, array $args = [])
309
+	{
310
+		if ($args = $this->buildAssetArgs($extension, $args)) {
311
+			$function = 'js' === $extension
312
+				? 'wp_enqueue_script'
313
+				: 'wp_enqueue_style';
314
+			call_user_func_array($function, $args);
315
+		}
316
+	}
317 317
 
318
-    /**
319
-     * @param string $extension
320
-     * @return void
321
-     */
322
-    protected function registerAsset($extension, array $args = [])
323
-    {
324
-        if ($args = $this->buildAssetArgs($extension, $args)) {
325
-            $function = 'js' === $extension
326
-                ? 'wp_register_script'
327
-                : 'wp_register_style';
328
-            call_user_func_array($function, $args);
329
-        }
330
-    }
318
+	/**
319
+	 * @param string $extension
320
+	 * @return void
321
+	 */
322
+	protected function registerAsset($extension, array $args = [])
323
+	{
324
+		if ($args = $this->buildAssetArgs($extension, $args)) {
325
+			$function = 'js' === $extension
326
+				? 'wp_register_script'
327
+				: 'wp_register_style';
328
+			call_user_func_array($function, $args);
329
+		}
330
+	}
331 331
 
332
-    /**
333
-     * @return void
334
-     */
335
-    abstract protected function setAddon();
332
+	/**
333
+	 * @return void
334
+	 */
335
+	abstract protected function setAddon();
336 336
 }
Please login to merge, or discard this patch.
plugin/Addons/Hooks.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -4,36 +4,36 @@
 block discarded – undo
4 4
 
5 5
 abstract class Hooks
6 6
 {
7
-    protected $addon;
8
-    protected $basename;
9
-    protected $controller;
7
+	protected $addon;
8
+	protected $basename;
9
+	protected $controller;
10 10
 
11
-    /**
12
-     * @return void
13
-     */
14
-    public function run()
15
-    {
16
-        add_action('init',                                                   [$this->addon, 'update']);
17
-        add_action('admin_enqueue_scripts',                                  [$this->controller, 'enqueueAdminAssets']);
18
-        add_action('enqueue_block_editor_assets',                            [$this->controller, 'enqueueBlockAssets']);
19
-        add_action('wp_enqueue_scripts',                                     [$this->controller, 'enqueuePublicAssets']);
20
-        add_filter('plugin_action_links_'.$this->basename,                   [$this->controller, 'filterActionLinks']);
21
-        add_filter('site-reviews/config',                                    [$this->controller, 'filterConfigPath']);
22
-        add_filter('site-reviews/addon/documentation',                       [$this->controller, 'filterDocumentation']);
23
-        add_filter('site-reviews/gettext/site-reviews-images',               [$this->controller, 'filterGettext'], 10, 2);
24
-        add_filter('site-reviews/gettext_with_context/site-reviews-images',  [$this->controller, 'filterGettextWithContext'], 10, 3);
25
-        add_filter('site-reviews/ngettext/site-reviews-images',              [$this->controller, 'filterNgettext'], 10, 4);
26
-        add_filter('site-reviews/ngettext_with_context/site-reviews-images', [$this->controller, 'filterNgettextWithContext'], 10, 5);
27
-        add_filter('site-reviews/path',                                      [$this->controller, 'filterFilePaths'], 10, 2);
28
-        add_filter('site-reviews/addon/settings',                            [$this->controller, 'filterSettings']);
29
-        add_filter('site-reviews/addon/system-info',                         [$this->controller, 'filterSystemInfo']);
30
-        add_filter('site-reviews/translation/entries',                       [$this->controller, 'filterTranslationEntries']);
31
-        add_filter('site-reviews/translator/domains',                        [$this->controller, 'filterTranslatorDomains']);
32
-        add_action('init',                                                   [$this->controller, 'registerBlocks']);
33
-        add_action('plugins_loaded',                                         [$this->controller, 'registerLanguages']);
34
-        add_action('init',                                                   [$this->controller, 'registerShortcodes']);
35
-        add_action('init',                                                   [$this->controller, 'registerTinymcePopups']);
36
-        add_action('widgets_init',                                           [$this->controller, 'registerWidgets']);
37
-        add_action('site-reviews/addon/settings/'.$this->addon->slug,        [$this->controller, 'renderSettings']);
38
-    }
11
+	/**
12
+	 * @return void
13
+	 */
14
+	public function run()
15
+	{
16
+		add_action('init',                                                   [$this->addon, 'update']);
17
+		add_action('admin_enqueue_scripts',                                  [$this->controller, 'enqueueAdminAssets']);
18
+		add_action('enqueue_block_editor_assets',                            [$this->controller, 'enqueueBlockAssets']);
19
+		add_action('wp_enqueue_scripts',                                     [$this->controller, 'enqueuePublicAssets']);
20
+		add_filter('plugin_action_links_'.$this->basename,                   [$this->controller, 'filterActionLinks']);
21
+		add_filter('site-reviews/config',                                    [$this->controller, 'filterConfigPath']);
22
+		add_filter('site-reviews/addon/documentation',                       [$this->controller, 'filterDocumentation']);
23
+		add_filter('site-reviews/gettext/site-reviews-images',               [$this->controller, 'filterGettext'], 10, 2);
24
+		add_filter('site-reviews/gettext_with_context/site-reviews-images',  [$this->controller, 'filterGettextWithContext'], 10, 3);
25
+		add_filter('site-reviews/ngettext/site-reviews-images',              [$this->controller, 'filterNgettext'], 10, 4);
26
+		add_filter('site-reviews/ngettext_with_context/site-reviews-images', [$this->controller, 'filterNgettextWithContext'], 10, 5);
27
+		add_filter('site-reviews/path',                                      [$this->controller, 'filterFilePaths'], 10, 2);
28
+		add_filter('site-reviews/addon/settings',                            [$this->controller, 'filterSettings']);
29
+		add_filter('site-reviews/addon/system-info',                         [$this->controller, 'filterSystemInfo']);
30
+		add_filter('site-reviews/translation/entries',                       [$this->controller, 'filterTranslationEntries']);
31
+		add_filter('site-reviews/translator/domains',                        [$this->controller, 'filterTranslatorDomains']);
32
+		add_action('init',                                                   [$this->controller, 'registerBlocks']);
33
+		add_action('plugins_loaded',                                         [$this->controller, 'registerLanguages']);
34
+		add_action('init',                                                   [$this->controller, 'registerShortcodes']);
35
+		add_action('init',                                                   [$this->controller, 'registerTinymcePopups']);
36
+		add_action('widgets_init',                                           [$this->controller, 'registerWidgets']);
37
+		add_action('site-reviews/addon/settings/'.$this->addon->slug,        [$this->controller, 'renderSettings']);
38
+	}
39 39
 }
Please login to merge, or discard this patch.
plugin/Addons/Updater.php 1 patch
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -8,266 +8,266 @@
 block discarded – undo
8 8
 
9 9
 class Updater
10 10
 {
11
-    /**
12
-     * @var string
13
-     */
14
-    protected $apiUrl;
15
-    /**
16
-     * @var array
17
-     */
18
-    protected $data;
19
-    /**
20
-     * @var string
21
-     */
22
-    protected $plugin;
23
-    /**
24
-     * @var string
25
-     */
26
-    protected $transientName;
11
+	/**
12
+	 * @var string
13
+	 */
14
+	protected $apiUrl;
15
+	/**
16
+	 * @var array
17
+	 */
18
+	protected $data;
19
+	/**
20
+	 * @var string
21
+	 */
22
+	protected $plugin;
23
+	/**
24
+	 * @var string
25
+	 */
26
+	protected $transientName;
27 27
 
28
-    /**
29
-     * @param string $apiUrl
30
-     * @param string $file
31
-     */
32
-    public function __construct($apiUrl, $file, array $data = [])
33
-    {
34
-        if (!function_exists('get_plugin_data')) {
35
-            require_once ABSPATH.WPINC.'/plugin.php';
36
-        }
37
-        $this->apiUrl = trailingslashit(apply_filters('site-reviews/addon/api-url', $apiUrl));
38
-        $this->data = wp_parse_args($data, get_plugin_data($file));
39
-        $this->plugin = plugin_basename($file);
40
-        $this->transientName = Application::PREFIX.md5(Arr::get($data, 'TextDomain'));
41
-    }
28
+	/**
29
+	 * @param string $apiUrl
30
+	 * @param string $file
31
+	 */
32
+	public function __construct($apiUrl, $file, array $data = [])
33
+	{
34
+		if (!function_exists('get_plugin_data')) {
35
+			require_once ABSPATH.WPINC.'/plugin.php';
36
+		}
37
+		$this->apiUrl = trailingslashit(apply_filters('site-reviews/addon/api-url', $apiUrl));
38
+		$this->data = wp_parse_args($data, get_plugin_data($file));
39
+		$this->plugin = plugin_basename($file);
40
+		$this->transientName = Application::PREFIX.md5(Arr::get($data, 'TextDomain'));
41
+	}
42 42
 
43
-    /**
44
-     * @return object
45
-     */
46
-    public function activateLicense(array $data = [])
47
-    {
48
-        return $this->request('activate_license', $data);
49
-    }
43
+	/**
44
+	 * @return object
45
+	 */
46
+	public function activateLicense(array $data = [])
47
+	{
48
+		return $this->request('activate_license', $data);
49
+	}
50 50
 
51
-    /**
52
-     * @return object
53
-     */
54
-    public function checkLicense(array $data = [])
55
-    {
56
-        $response = $this->request('check_license', $data);
57
-        if ('valid' === Arr::get($response, 'license')) {
58
-            $this->getPluginUpdate(true);
59
-        }
60
-        return $response;
61
-    }
51
+	/**
52
+	 * @return object
53
+	 */
54
+	public function checkLicense(array $data = [])
55
+	{
56
+		$response = $this->request('check_license', $data);
57
+		if ('valid' === Arr::get($response, 'license')) {
58
+			$this->getPluginUpdate(true);
59
+		}
60
+		return $response;
61
+	}
62 62
 
63
-    /**
64
-     * @return object
65
-     */
66
-    public function deactivateLicense(array $data = [])
67
-    {
68
-        return $this->request('deactivate_license', $data);
69
-    }
63
+	/**
64
+	 * @return object
65
+	 */
66
+	public function deactivateLicense(array $data = [])
67
+	{
68
+		return $this->request('deactivate_license', $data);
69
+	}
70 70
 
71
-    /**
72
-     * @param false|object|array $result
73
-     * @param string $action
74
-     * @param object $args
75
-     * @return mixed
76
-     */
77
-    public function filterPluginUpdateDetails($result, $action, $args)
78
-    {
79
-        if ('plugin_information' != $action
80
-            || Arr::get($this->data, 'TextDomain') != Arr::get($args, 'slug')) {
81
-            return $result;
82
-        }
83
-        if ($updateInfo = $this->getPluginUpdate()) {
84
-            return $this->modifyUpdateDetails($updateInfo);
85
-        }
86
-        return $result;
87
-    }
71
+	/**
72
+	 * @param false|object|array $result
73
+	 * @param string $action
74
+	 * @param object $args
75
+	 * @return mixed
76
+	 */
77
+	public function filterPluginUpdateDetails($result, $action, $args)
78
+	{
79
+		if ('plugin_information' != $action
80
+			|| Arr::get($this->data, 'TextDomain') != Arr::get($args, 'slug')) {
81
+			return $result;
82
+		}
83
+		if ($updateInfo = $this->getPluginUpdate()) {
84
+			return $this->modifyUpdateDetails($updateInfo);
85
+		}
86
+		return $result;
87
+	}
88 88
 
89
-    /**
90
-     * @param object $transient
91
-     * @return object
92
-     */
93
-    public function filterPluginUpdates($transient)
94
-    {
95
-        if ($updateInfo = $this->getPluginUpdate()) {
96
-            return $this->modifyPluginUpdates($transient, $updateInfo);
97
-        }
98
-        return $transient;
99
-    }
89
+	/**
90
+	 * @param object $transient
91
+	 * @return object
92
+	 */
93
+	public function filterPluginUpdates($transient)
94
+	{
95
+		if ($updateInfo = $this->getPluginUpdate()) {
96
+			return $this->modifyPluginUpdates($transient, $updateInfo);
97
+		}
98
+		return $transient;
99
+	}
100 100
 
101
-    /**
102
-     * @return object
103
-     */
104
-    public function getVersion(array $data = [])
105
-    {
106
-        return $this->request('get_version', $data);
107
-    }
101
+	/**
102
+	 * @return object
103
+	 */
104
+	public function getVersion(array $data = [])
105
+	{
106
+		return $this->request('get_version', $data);
107
+	}
108 108
 
109
-    /**
110
-     * @return void
111
-     */
112
-    public function init()
113
-    {
114
-        if ($this->apiUrl === trailingslashit(home_url())) {
115
-            return;
116
-        }
117
-        add_filter('plugins_api', [$this, 'filterPluginUpdateDetails'], 10, 3);
118
-        add_filter('pre_set_site_transient_update_plugins', [$this, 'filterPluginUpdates'], 999);
119
-        add_action('load-update-core.php', [$this, 'onForceUpdateCheck'], 9);
120
-        add_action('in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink']);
121
-    }
109
+	/**
110
+	 * @return void
111
+	 */
112
+	public function init()
113
+	{
114
+		if ($this->apiUrl === trailingslashit(home_url())) {
115
+			return;
116
+		}
117
+		add_filter('plugins_api', [$this, 'filterPluginUpdateDetails'], 10, 3);
118
+		add_filter('pre_set_site_transient_update_plugins', [$this, 'filterPluginUpdates'], 999);
119
+		add_action('load-update-core.php', [$this, 'onForceUpdateCheck'], 9);
120
+		add_action('in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink']);
121
+	}
122 122
 
123
-    /**
124
-     * @return bool
125
-     */
126
-    public function isLicenseValid()
127
-    {
128
-        $result = $this->checkLicense();
129
-        return 'valid' === Arr::get($result, 'license');
130
-    }
123
+	/**
124
+	 * @return bool
125
+	 */
126
+	public function isLicenseValid()
127
+	{
128
+		$result = $this->checkLicense();
129
+		return 'valid' === Arr::get($result, 'license');
130
+	}
131 131
 
132
-    /**
133
-     * @return void
134
-     */
135
-    public function onForceUpdateCheck()
136
-    {
137
-        if (!filter_input(INPUT_GET, 'force-check')) {
138
-            return;
139
-        }
140
-        foreach (glsr()->addons as $addon) {
141
-            try {
142
-                glsr($addon)->updater->getPluginUpdate(true);
143
-            } catch (\Exception $e) {
144
-                glsr_log()->error($e->getMessage());
145
-            }
146
-        }
147
-    }
132
+	/**
133
+	 * @return void
134
+	 */
135
+	public function onForceUpdateCheck()
136
+	{
137
+		if (!filter_input(INPUT_GET, 'force-check')) {
138
+			return;
139
+		}
140
+		foreach (glsr()->addons as $addon) {
141
+			try {
142
+				glsr($addon)->updater->getPluginUpdate(true);
143
+			} catch (\Exception $e) {
144
+				glsr_log()->error($e->getMessage());
145
+			}
146
+		}
147
+	}
148 148
 
149
-    /**
150
-     * @return void
151
-     */
152
-    public function renderLicenseMissingLink()
153
-    {
154
-        if (!$this->isLicenseValid()) {
155
-            glsr()->render('partials/addons/license-missing');
156
-        }
157
-    }
149
+	/**
150
+	 * @return void
151
+	 */
152
+	public function renderLicenseMissingLink()
153
+	{
154
+		if (!$this->isLicenseValid()) {
155
+			glsr()->render('partials/addons/license-missing');
156
+		}
157
+	}
158 158
 
159
-    /**
160
-     * @return false|object
161
-     */
162
-    protected function getCachedVersion()
163
-    {
164
-        return get_transient($this->transientName);
165
-    }
159
+	/**
160
+	 * @return false|object
161
+	 */
162
+	protected function getCachedVersion()
163
+	{
164
+		return get_transient($this->transientName);
165
+	}
166 166
 
167
-    /**
168
-     * @param bool $force
169
-     * @return false|object
170
-     */
171
-    protected function getPluginUpdate($force = false)
172
-    {
173
-        $version = $this->getCachedVersion();
174
-        if (false === $version || $force) {
175
-            $version = $this->getVersion();
176
-            $this->setCachedVersion($version);
177
-        }
178
-        if (isset($version->error)) {
179
-            glsr_log()->error($version->error);
180
-            return false;
181
-        }
182
-        return $version;
183
-    }
167
+	/**
168
+	 * @param bool $force
169
+	 * @return false|object
170
+	 */
171
+	protected function getPluginUpdate($force = false)
172
+	{
173
+		$version = $this->getCachedVersion();
174
+		if (false === $version || $force) {
175
+			$version = $this->getVersion();
176
+			$this->setCachedVersion($version);
177
+		}
178
+		if (isset($version->error)) {
179
+			glsr_log()->error($version->error);
180
+			return false;
181
+		}
182
+		return $version;
183
+	}
184 184
 
185
-    /**
186
-     * @param object $transient
187
-     * @param object $updateInfo
188
-     * @return object
189
-     */
190
-    protected function modifyPluginUpdates($transient, $updateInfo)
191
-    {
192
-        $updateInfo->id = Application::ID.'/'.Arr::get($this->data, 'TextDomain');
193
-        $updateInfo->plugin = $this->plugin;
194
-        $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
195
-        $updateInfo->tested = Arr::get($this->data, 'testedTo');
196
-        $transient->checked[$this->plugin] = Arr::get($this->data, 'Version');
197
-        $transient->last_checked = time();
198
-        if (Helper::isGreaterThan($updateInfo->new_version, Arr::get($this->data, 'Version'))) {
199
-            unset($transient->no_update[$this->plugin]);
200
-            $updateInfo->update = true;
201
-            $transient->response[$this->plugin] = $updateInfo;
202
-        } else {
203
-            unset($transient->response[$this->plugin]);
204
-            $transient->no_update[$this->plugin] = $updateInfo;
205
-        }
206
-        return $transient;
207
-    }
185
+	/**
186
+	 * @param object $transient
187
+	 * @param object $updateInfo
188
+	 * @return object
189
+	 */
190
+	protected function modifyPluginUpdates($transient, $updateInfo)
191
+	{
192
+		$updateInfo->id = Application::ID.'/'.Arr::get($this->data, 'TextDomain');
193
+		$updateInfo->plugin = $this->plugin;
194
+		$updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
195
+		$updateInfo->tested = Arr::get($this->data, 'testedTo');
196
+		$transient->checked[$this->plugin] = Arr::get($this->data, 'Version');
197
+		$transient->last_checked = time();
198
+		if (Helper::isGreaterThan($updateInfo->new_version, Arr::get($this->data, 'Version'))) {
199
+			unset($transient->no_update[$this->plugin]);
200
+			$updateInfo->update = true;
201
+			$transient->response[$this->plugin] = $updateInfo;
202
+		} else {
203
+			unset($transient->response[$this->plugin]);
204
+			$transient->no_update[$this->plugin] = $updateInfo;
205
+		}
206
+		return $transient;
207
+	}
208 208
 
209
-    /**
210
-     * @param object $updateInfo
211
-     * @return object
212
-     */
213
-    protected function modifyUpdateDetails($updateInfo)
214
-    {
215
-        $updateInfo->author = Arr::get($this->data, 'Author');
216
-        $updateInfo->author_profile = Arr::get($this->data, 'AuthorURI');
217
-        $updateInfo->requires = Arr::get($this->data, 'RequiresWP');
218
-        $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
219
-        $updateInfo->tested = Arr::get($this->data, 'testedTo');
220
-        $updateInfo->version = $updateInfo->new_version;
221
-        return $updateInfo;
222
-    }
209
+	/**
210
+	 * @param object $updateInfo
211
+	 * @return object
212
+	 */
213
+	protected function modifyUpdateDetails($updateInfo)
214
+	{
215
+		$updateInfo->author = Arr::get($this->data, 'Author');
216
+		$updateInfo->author_profile = Arr::get($this->data, 'AuthorURI');
217
+		$updateInfo->requires = Arr::get($this->data, 'RequiresWP');
218
+		$updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
219
+		$updateInfo->tested = Arr::get($this->data, 'testedTo');
220
+		$updateInfo->version = $updateInfo->new_version;
221
+		return $updateInfo;
222
+	}
223 223
 
224
-    /**
225
-     * @param \WP_Error|array $response
226
-     * @return object
227
-     */
228
-    protected function normalizeResponse($response)
229
-    {
230
-        $body = wp_remote_retrieve_body($response);
231
-        if ($data = json_decode($body)) {
232
-            $data = array_map('maybe_unserialize', (array) $data);
233
-            return (object) $data;
234
-        }
235
-        $error = is_wp_error($response)
236
-            ? $response->get_error_message()
237
-            : 'Update server not responding ('.Arr::get($this->data, 'TextDomain').')';
238
-        return (object) ['error' => $error];
239
-    }
224
+	/**
225
+	 * @param \WP_Error|array $response
226
+	 * @return object
227
+	 */
228
+	protected function normalizeResponse($response)
229
+	{
230
+		$body = wp_remote_retrieve_body($response);
231
+		if ($data = json_decode($body)) {
232
+			$data = array_map('maybe_unserialize', (array) $data);
233
+			return (object) $data;
234
+		}
235
+		$error = is_wp_error($response)
236
+			? $response->get_error_message()
237
+			: 'Update server not responding ('.Arr::get($this->data, 'TextDomain').')';
238
+		return (object) ['error' => $error];
239
+	}
240 240
 
241
-    /**
242
-     * @param string $action activate_license|check_license|deactivate_license|get_version
243
-     * @return object
244
-     */
245
-    protected function request($action, array $data = [])
246
-    {
247
-        $data = wp_parse_args($data, $this->data);
248
-        $response = wp_remote_post($this->apiUrl, [
249
-            'body' => [
250
-                'edd_action' => $action,
251
-                'item_id' => Arr::get($data, 'item_id'),
252
-                'item_name' => Arr::get($data, 'Name'),
253
-                'license' => Arr::get($data, 'license'),
254
-                'slug' => Arr::get($data, 'TextDomain'),
255
-                'url' => home_url(),
256
-            ],
257
-            'sslverify' => apply_filters('site-reviews/sslverify/post', false),
258
-            'timeout' => 15,
259
-        ]);
260
-        return $this->normalizeResponse($response);
261
-    }
241
+	/**
242
+	 * @param string $action activate_license|check_license|deactivate_license|get_version
243
+	 * @return object
244
+	 */
245
+	protected function request($action, array $data = [])
246
+	{
247
+		$data = wp_parse_args($data, $this->data);
248
+		$response = wp_remote_post($this->apiUrl, [
249
+			'body' => [
250
+				'edd_action' => $action,
251
+				'item_id' => Arr::get($data, 'item_id'),
252
+				'item_name' => Arr::get($data, 'Name'),
253
+				'license' => Arr::get($data, 'license'),
254
+				'slug' => Arr::get($data, 'TextDomain'),
255
+				'url' => home_url(),
256
+			],
257
+			'sslverify' => apply_filters('site-reviews/sslverify/post', false),
258
+			'timeout' => 15,
259
+		]);
260
+		return $this->normalizeResponse($response);
261
+	}
262 262
 
263
-    /**
264
-     * @param object $version
265
-     * @return void
266
-     */
267
-    protected function setCachedVersion($version)
268
-    {
269
-        if (!isset($version->error)) {
270
-            set_transient($this->transientName, $version, 3 * HOUR_IN_SECONDS);
271
-        }
272
-    }
263
+	/**
264
+	 * @param object $version
265
+	 * @return void
266
+	 */
267
+	protected function setCachedVersion($version)
268
+	{
269
+		if (!isset($version->error)) {
270
+			set_transient($this->transientName, $version, 3 * HOUR_IN_SECONDS);
271
+		}
272
+	}
273 273
 }
Please login to merge, or discard this patch.
plugin/Blocks/SiteReviewsFormBlock.php 1 patch
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -7,105 +7,105 @@
 block discarded – undo
7 7
 
8 8
 class SiteReviewsFormBlock extends BlockGenerator
9 9
 {
10
-    /**
11
-     * @return array
12
-     */
13
-    public function attributes()
14
-    {
15
-        return [
16
-            'assign_to' => [
17
-                'default' => '',
18
-                'type' => 'string',
19
-            ],
20
-            'category' => [
21
-                'default' => '',
22
-                'type' => 'string',
23
-            ],
24
-            'className' => [
25
-                'default' => '',
26
-                'type' => 'string',
27
-            ],
28
-            'hide' => [
29
-                'default' => '',
30
-                'type' => 'string',
31
-            ],
32
-            'id' => [
33
-                'default' => '',
34
-                'type' => 'string',
35
-            ],
36
-        ];
37
-    }
10
+	/**
11
+	 * @return array
12
+	 */
13
+	public function attributes()
14
+	{
15
+		return [
16
+			'assign_to' => [
17
+				'default' => '',
18
+				'type' => 'string',
19
+			],
20
+			'category' => [
21
+				'default' => '',
22
+				'type' => 'string',
23
+			],
24
+			'className' => [
25
+				'default' => '',
26
+				'type' => 'string',
27
+			],
28
+			'hide' => [
29
+				'default' => '',
30
+				'type' => 'string',
31
+			],
32
+			'id' => [
33
+				'default' => '',
34
+				'type' => 'string',
35
+			],
36
+		];
37
+	}
38 38
 
39
-    /**
40
-     * @return string
41
-     */
42
-    public function render(array $attributes)
43
-    {
44
-        $attributes['class'] = $attributes['className'];
45
-        $shortcode = glsr(Shortcode::class);
46
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
47
-            $this->filterBlockClass();
48
-            $this->filterFormFields();
49
-            $this->filterRatingField();
50
-            $this->filterSubmitButton();
51
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
52
-                $this->filterInterpolation();
53
-            }
54
-        }
55
-        return $shortcode->buildBlock($attributes);
56
-    }
39
+	/**
40
+	 * @return string
41
+	 */
42
+	public function render(array $attributes)
43
+	{
44
+		$attributes['class'] = $attributes['className'];
45
+		$shortcode = glsr(Shortcode::class);
46
+		if ('edit' == filter_input(INPUT_GET, 'context')) {
47
+			$this->filterBlockClass();
48
+			$this->filterFormFields();
49
+			$this->filterRatingField();
50
+			$this->filterSubmitButton();
51
+			if (!$this->hasVisibleFields($shortcode, $attributes)) {
52
+				$this->filterInterpolation();
53
+			}
54
+		}
55
+		return $shortcode->buildBlock($attributes);
56
+	}
57 57
 
58
-    /**
59
-     * @return void
60
-     */
61
-    protected function filterFormFields()
62
-    {
63
-        add_filter('site-reviews/config/forms/submission-form', function (array $config) {
64
-            array_walk($config, function (&$field) {
65
-                $field['disabled'] = true;
66
-                $field['tabindex'] = '-1';
67
-            });
68
-            return $config;
69
-        });
70
-    }
58
+	/**
59
+	 * @return void
60
+	 */
61
+	protected function filterFormFields()
62
+	{
63
+		add_filter('site-reviews/config/forms/submission-form', function (array $config) {
64
+			array_walk($config, function (&$field) {
65
+				$field['disabled'] = true;
66
+				$field['tabindex'] = '-1';
67
+			});
68
+			return $config;
69
+		});
70
+	}
71 71
 
72
-    /**
73
-     * @return void
74
-     */
75
-    protected function filterInterpolation()
76
-    {
77
-        add_filter('site-reviews/interpolate/reviews-form', function ($context) {
78
-            $context['class'] = 'glsr-default glsr-block-disabled';
79
-            $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews');
80
-            $context['response'] = '';
81
-            $context['submit_button'] = '';
82
-            return $context;
83
-        });
84
-    }
72
+	/**
73
+	 * @return void
74
+	 */
75
+	protected function filterInterpolation()
76
+	{
77
+		add_filter('site-reviews/interpolate/reviews-form', function ($context) {
78
+			$context['class'] = 'glsr-default glsr-block-disabled';
79
+			$context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews');
80
+			$context['response'] = '';
81
+			$context['submit_button'] = '';
82
+			return $context;
83
+		});
84
+	}
85 85
 
86
-    /**
87
-     * @return void
88
-     */
89
-    protected function filterRatingField()
90
-    {
91
-        add_filter('site-reviews/rendered/field', function ($html, $type, $args) {
92
-            if ('rating' == $args['path']) {
93
-                $stars = '<span class="glsr-stars">';
94
-                $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class));
95
-                $stars.= '</span>';
96
-                $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html);
97
-            }
98
-            return $html;
99
-        }, 10, 3);
100
-    }
86
+	/**
87
+	 * @return void
88
+	 */
89
+	protected function filterRatingField()
90
+	{
91
+		add_filter('site-reviews/rendered/field', function ($html, $type, $args) {
92
+			if ('rating' == $args['path']) {
93
+				$stars = '<span class="glsr-stars">';
94
+				$stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class));
95
+				$stars.= '</span>';
96
+				$html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html);
97
+			}
98
+			return $html;
99
+		}, 10, 3);
100
+	}
101 101
 
102
-    /**
103
-     * @return void
104
-     */
105
-    protected function filterSubmitButton()
106
-    {
107
-        add_filter('site-reviews/rendered/template/form/submit-button', function ($template) {
108
-            return str_replace('type="submit"', 'tabindex="-1"', $template);
109
-        });
110
-    }
102
+	/**
103
+	 * @return void
104
+	 */
105
+	protected function filterSubmitButton()
106
+	{
107
+		add_filter('site-reviews/rendered/template/form/submit-button', function ($template) {
108
+			return str_replace('type="submit"', 'tabindex="-1"', $template);
109
+		});
110
+	}
111 111
 }
Please login to merge, or discard this patch.
plugin/Blocks/SiteReviewsBlock.php 1 patch
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -6,114 +6,114 @@
 block discarded – undo
6 6
 
7 7
 class SiteReviewsBlock extends BlockGenerator
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    public function attributes()
13
-    {
14
-        return [
15
-            'assigned_to' => [
16
-                'default' => '',
17
-                'type' => 'string',
18
-            ],
19
-            'category' => [
20
-                'default' => '',
21
-                'type' => 'string',
22
-            ],
23
-            'className' => [
24
-                'default' => '',
25
-                'type' => 'string',
26
-            ],
27
-            'display' => [
28
-                'default' => 5,
29
-                'type' => 'number',
30
-            ],
31
-            'hide' => [
32
-                'default' => '',
33
-                'type' => 'string',
34
-            ],
35
-            'id' => [
36
-                'default' => '',
37
-                'type' => 'string',
38
-            ],
39
-            'pagination' => [
40
-                'default' => '',
41
-                'type' => 'string',
42
-            ],
43
-            'post_id' => [
44
-                'default' => '',
45
-                'type' => 'string',
46
-            ],
47
-            'rating' => [
48
-                'default' => 0,
49
-                'type' => 'number',
50
-            ],
51
-            'schema' => [
52
-                'default' => false,
53
-                'type' => 'boolean',
54
-            ],
55
-            'type' => [
56
-                'default' => 'local',
57
-                'type' => 'string',
58
-            ],
59
-        ];
60
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	public function attributes()
13
+	{
14
+		return [
15
+			'assigned_to' => [
16
+				'default' => '',
17
+				'type' => 'string',
18
+			],
19
+			'category' => [
20
+				'default' => '',
21
+				'type' => 'string',
22
+			],
23
+			'className' => [
24
+				'default' => '',
25
+				'type' => 'string',
26
+			],
27
+			'display' => [
28
+				'default' => 5,
29
+				'type' => 'number',
30
+			],
31
+			'hide' => [
32
+				'default' => '',
33
+				'type' => 'string',
34
+			],
35
+			'id' => [
36
+				'default' => '',
37
+				'type' => 'string',
38
+			],
39
+			'pagination' => [
40
+				'default' => '',
41
+				'type' => 'string',
42
+			],
43
+			'post_id' => [
44
+				'default' => '',
45
+				'type' => 'string',
46
+			],
47
+			'rating' => [
48
+				'default' => 0,
49
+				'type' => 'number',
50
+			],
51
+			'schema' => [
52
+				'default' => false,
53
+				'type' => 'boolean',
54
+			],
55
+			'type' => [
56
+				'default' => 'local',
57
+				'type' => 'string',
58
+			],
59
+		];
60
+	}
61 61
 
62
-    /**
63
-     * @return string
64
-     */
65
-    public function render(array $attributes)
66
-    {
67
-        $attributes['class'] = $attributes['className'];
68
-        $shortcode = glsr(Shortcode::class);
69
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
70
-            $attributes = $this->normalize($attributes);
71
-            $this->filterBlockClass();
72
-            $this->filterReviewLinks();
73
-            $this->filterShowMoreLinks('content');
74
-            $this->filterShowMoreLinks('response');
75
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
76
-                $this->filterInterpolation();
77
-            }
78
-        }
79
-        return $shortcode->buildBlock($attributes);
80
-    }
62
+	/**
63
+	 * @return string
64
+	 */
65
+	public function render(array $attributes)
66
+	{
67
+		$attributes['class'] = $attributes['className'];
68
+		$shortcode = glsr(Shortcode::class);
69
+		if ('edit' == filter_input(INPUT_GET, 'context')) {
70
+			$attributes = $this->normalize($attributes);
71
+			$this->filterBlockClass();
72
+			$this->filterReviewLinks();
73
+			$this->filterShowMoreLinks('content');
74
+			$this->filterShowMoreLinks('response');
75
+			if (!$this->hasVisibleFields($shortcode, $attributes)) {
76
+				$this->filterInterpolation();
77
+			}
78
+		}
79
+		return $shortcode->buildBlock($attributes);
80
+	}
81 81
 
82
-    /**
83
-     * @return void
84
-     */
85
-    protected function filterInterpolation()
86
-    {
87
-        add_filter('site-reviews/interpolate/reviews', function ($context) {
88
-            $context['class'] = 'glsr-default glsr-block-disabled';
89
-            $context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews');
90
-            return $context;
91
-        });
92
-    }
82
+	/**
83
+	 * @return void
84
+	 */
85
+	protected function filterInterpolation()
86
+	{
87
+		add_filter('site-reviews/interpolate/reviews', function ($context) {
88
+			$context['class'] = 'glsr-default glsr-block-disabled';
89
+			$context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews');
90
+			return $context;
91
+		});
92
+	}
93 93
 
94
-    /**
95
-     * @return void
96
-     */
97
-    protected function filterReviewLinks()
98
-    {
99
-        add_filter('site-reviews/rendered/template/reviews', function ($template) {
100
-            return str_replace('<a', '<a tabindex="-1"', $template);
101
-        });
102
-    }
94
+	/**
95
+	 * @return void
96
+	 */
97
+	protected function filterReviewLinks()
98
+	{
99
+		add_filter('site-reviews/rendered/template/reviews', function ($template) {
100
+			return str_replace('<a', '<a tabindex="-1"', $template);
101
+		});
102
+	}
103 103
 
104
-    /**
105
-     * @param string $field
106
-     * @return void
107
-     */
108
-    protected function filterShowMoreLinks($field)
109
-    {
110
-        add_filter('site-reviews/review/wrap/'.$field, function ($value) {
111
-            $value = preg_replace(
112
-                '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/s',
113
-                '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5',
114
-                $value
115
-            );
116
-            return $value;
117
-        });
118
-    }
104
+	/**
105
+	 * @param string $field
106
+	 * @return void
107
+	 */
108
+	protected function filterShowMoreLinks($field)
109
+	{
110
+		add_filter('site-reviews/review/wrap/'.$field, function ($value) {
111
+			$value = preg_replace(
112
+				'/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/s',
113
+				'$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5',
114
+				$value
115
+			);
116
+			return $value;
117
+		});
118
+	}
119 119
 }
Please login to merge, or discard this patch.
plugin/Blocks/SiteReviewsSummaryBlock.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -6,73 +6,73 @@
 block discarded – undo
6 6
 
7 7
 class SiteReviewsSummaryBlock extends BlockGenerator
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    public function attributes()
13
-    {
14
-        return [
15
-            'assigned_to' => [
16
-                'default' => '',
17
-                'type' => 'string',
18
-            ],
19
-            'category' => [
20
-                'default' => '',
21
-                'type' => 'string',
22
-            ],
23
-            'className' => [
24
-                'default' => '',
25
-                'type' => 'string',
26
-            ],
27
-            'hide' => [
28
-                'default' => '',
29
-                'type' => 'string',
30
-            ],
31
-            'post_id' => [
32
-                'default' => '',
33
-                'type' => 'string',
34
-            ],
35
-            'rating' => [
36
-                'default' => '1',
37
-                'type' => 'number',
38
-            ],
39
-            'schema' => [
40
-                'default' => false,
41
-                'type' => 'boolean',
42
-            ],
43
-            'type' => [
44
-                'default' => 'local',
45
-                'type' => 'string',
46
-            ],
47
-        ];
48
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	public function attributes()
13
+	{
14
+		return [
15
+			'assigned_to' => [
16
+				'default' => '',
17
+				'type' => 'string',
18
+			],
19
+			'category' => [
20
+				'default' => '',
21
+				'type' => 'string',
22
+			],
23
+			'className' => [
24
+				'default' => '',
25
+				'type' => 'string',
26
+			],
27
+			'hide' => [
28
+				'default' => '',
29
+				'type' => 'string',
30
+			],
31
+			'post_id' => [
32
+				'default' => '',
33
+				'type' => 'string',
34
+			],
35
+			'rating' => [
36
+				'default' => '1',
37
+				'type' => 'number',
38
+			],
39
+			'schema' => [
40
+				'default' => false,
41
+				'type' => 'boolean',
42
+			],
43
+			'type' => [
44
+				'default' => 'local',
45
+				'type' => 'string',
46
+			],
47
+		];
48
+	}
49 49
 
50
-    /**
51
-     * @return string
52
-     */
53
-    public function render(array $attributes)
54
-    {
55
-        $attributes['class'] = $attributes['className'];
56
-        $shortcode = glsr(Shortcode::class);
57
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
58
-            $attributes = $this->normalize($attributes);
59
-            $this->filterBlockClass();
60
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
61
-                $this->filterInterpolation();
62
-            }
63
-        }
64
-        return $shortcode->buildBlock($attributes);
65
-    }
50
+	/**
51
+	 * @return string
52
+	 */
53
+	public function render(array $attributes)
54
+	{
55
+		$attributes['class'] = $attributes['className'];
56
+		$shortcode = glsr(Shortcode::class);
57
+		if ('edit' == filter_input(INPUT_GET, 'context')) {
58
+			$attributes = $this->normalize($attributes);
59
+			$this->filterBlockClass();
60
+			if (!$this->hasVisibleFields($shortcode, $attributes)) {
61
+				$this->filterInterpolation();
62
+			}
63
+		}
64
+		return $shortcode->buildBlock($attributes);
65
+	}
66 66
 
67
-    /**
68
-     * @return void
69
-     */
70
-    protected function filterInterpolation()
71
-    {
72
-        add_filter('site-reviews/interpolate/reviews-summary', function ($context) {
73
-            $context['class'] = 'glsr-default glsr-block-disabled';
74
-            $context['text'] = __('You have hidden all of the fields for this block.', 'site-reviews');
75
-            return $context;
76
-        });
77
-    }
67
+	/**
68
+	 * @return void
69
+	 */
70
+	protected function filterInterpolation()
71
+	{
72
+		add_filter('site-reviews/interpolate/reviews-summary', function ($context) {
73
+			$context['class'] = 'glsr-default glsr-block-disabled';
74
+			$context['text'] = __('You have hidden all of the fields for this block.', 'site-reviews');
75
+			return $context;
76
+		});
77
+	}
78 78
 }
Please login to merge, or discard this patch.
plugin/Blocks/BlockGenerator.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -7,72 +7,72 @@
 block discarded – undo
7 7
 
8 8
 abstract class BlockGenerator
9 9
 {
10
-    /**
11
-     * @return array
12
-     */
13
-    public function attributes()
14
-    {
15
-        return [];
16
-    }
10
+	/**
11
+	 * @return array
12
+	 */
13
+	public function attributes()
14
+	{
15
+		return [];
16
+	}
17 17
 
18
-    /**
19
-     * @return array
20
-     */
21
-    public function normalize(array $attributes)
22
-    {
23
-        $hide = array_flip(explode(',', $attributes['hide']));
24
-        unset($hide['if_empty']);
25
-        $attributes['hide'] = implode(',', array_keys($hide));
26
-        if ('post_id' === Arr::get($attributes, 'assigned_to')) {
27
-            $attributes['assigned_to'] = $attributes['post_id'];
28
-        } elseif ('parent_id' === Arr::get($attributes, 'assigned_to')) {
29
-            $attributes['assigned_to'] = wp_get_post_parent_id($attributes['post_id']);
30
-        }
31
-        return $attributes;
32
-    }
18
+	/**
19
+	 * @return array
20
+	 */
21
+	public function normalize(array $attributes)
22
+	{
23
+		$hide = array_flip(explode(',', $attributes['hide']));
24
+		unset($hide['if_empty']);
25
+		$attributes['hide'] = implode(',', array_keys($hide));
26
+		if ('post_id' === Arr::get($attributes, 'assigned_to')) {
27
+			$attributes['assigned_to'] = $attributes['post_id'];
28
+		} elseif ('parent_id' === Arr::get($attributes, 'assigned_to')) {
29
+			$attributes['assigned_to'] = wp_get_post_parent_id($attributes['post_id']);
30
+		}
31
+		return $attributes;
32
+	}
33 33
 
34
-    /**
35
-     * @return void
36
-     */
37
-    public function register($block)
38
-    {
39
-        if (!function_exists('register_block_type')) {
40
-            return;
41
-        }
42
-        register_block_type(Application::ID.'/'.$block, [
43
-            'attributes' => $this->attributes(),
44
-            'editor_script' => Application::ID.'/blocks',
45
-            'editor_style' => Application::ID.'/blocks',
46
-            'render_callback' => [$this, 'render'],
47
-            'style' => Application::ID,
48
-        ]);
49
-    }
34
+	/**
35
+	 * @return void
36
+	 */
37
+	public function register($block)
38
+	{
39
+		if (!function_exists('register_block_type')) {
40
+			return;
41
+		}
42
+		register_block_type(Application::ID.'/'.$block, [
43
+			'attributes' => $this->attributes(),
44
+			'editor_script' => Application::ID.'/blocks',
45
+			'editor_style' => Application::ID.'/blocks',
46
+			'render_callback' => [$this, 'render'],
47
+			'style' => Application::ID,
48
+		]);
49
+	}
50 50
 
51
-    /**
52
-     * @return void
53
-     */
54
-    abstract public function render(array $attributes);
51
+	/**
52
+	 * @return void
53
+	 */
54
+	abstract public function render(array $attributes);
55 55
 
56
-    /**
57
-     * @return void
58
-     */
59
-    protected function filterBlockClass()
60
-    {
61
-        add_filter('site-reviews/style', function () {
62
-            return 'default';
63
-        });
64
-    }
56
+	/**
57
+	 * @return void
58
+	 */
59
+	protected function filterBlockClass()
60
+	{
61
+		add_filter('site-reviews/style', function () {
62
+			return 'default';
63
+		});
64
+	}
65 65
 
66
-    /**
67
-     * @param mixed $shortcode
68
-     * @return bool
69
-     */
70
-    protected function hasVisibleFields($shortcode, array $attributes)
71
-    {
72
-        $args = $shortcode->normalizeAtts($attributes);
73
-        $defaults = $shortcode->getHideOptions();
74
-        $hide = array_flip($args['hide']);
75
-        unset($defaults['if_empty'], $hide['if_empty']);
76
-        return !empty(array_diff_key($defaults, $hide));
77
-    }
66
+	/**
67
+	 * @param mixed $shortcode
68
+	 * @return bool
69
+	 */
70
+	protected function hasVisibleFields($shortcode, array $attributes)
71
+	{
72
+		$args = $shortcode->normalizeAtts($attributes);
73
+		$defaults = $shortcode->getHideOptions();
74
+		$hide = array_flip($args['hide']);
75
+		unset($defaults['if_empty'], $hide['if_empty']);
76
+		return !empty(array_diff_key($defaults, $hide));
77
+	}
78 78
 }
Please login to merge, or discard this patch.