Passed
Push — master ( a9546d...6aabd8 )
by Paul
05:58
created
plugin/Modules/Html/Template.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -7,76 +7,76 @@
 block discarded – undo
7 7
 
8 8
 class Template
9 9
 {
10
-    /**
11
-     * @param string $templatePath
12
-     * @return void|string
13
-     */
14
-    public function build($templatePath, array $data = [])
15
-    {
16
-        $data = $this->normalize($data);
17
-        $path = Str::removePrefix('templates/', $templatePath);
18
-        $template = glsr()->build($templatePath, $data);
19
-        $template = apply_filters('site-reviews/build/template/'.$path, $template, $data);
20
-        $template = $this->interpolate($template, $data, $path);
21
-        $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data);
22
-        $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data);
23
-        return $template;
24
-    }
10
+	/**
11
+	 * @param string $templatePath
12
+	 * @return void|string
13
+	 */
14
+	public function build($templatePath, array $data = [])
15
+	{
16
+		$data = $this->normalize($data);
17
+		$path = Str::removePrefix('templates/', $templatePath);
18
+		$template = glsr()->build($templatePath, $data);
19
+		$template = apply_filters('site-reviews/build/template/'.$path, $template, $data);
20
+		$template = $this->interpolate($template, $data, $path);
21
+		$template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data);
22
+		$template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data);
23
+		return $template;
24
+	}
25 25
 
26
-    /**
27
-     * Interpolate context values into template placeholders.
28
-     * @param string $template
29
-     * @param string $templatePath
30
-     * @return string
31
-     */
32
-    public function interpolate($template, array $data = [], $templatePath)
33
-    {
34
-        $context = $this->normalizeContext(Arr::get($data, 'context', []));
35
-        $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data);
36
-        foreach ($context as $key => $value) {
37
-            $template = strtr(
38
-                $template,
39
-                array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value)
40
-            );
41
-        }
42
-        return trim($template);
43
-    }
26
+	/**
27
+	 * Interpolate context values into template placeholders.
28
+	 * @param string $template
29
+	 * @param string $templatePath
30
+	 * @return string
31
+	 */
32
+	public function interpolate($template, array $data = [], $templatePath)
33
+	{
34
+		$context = $this->normalizeContext(Arr::get($data, 'context', []));
35
+		$context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data);
36
+		foreach ($context as $key => $value) {
37
+			$template = strtr(
38
+				$template,
39
+				array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value)
40
+			);
41
+		}
42
+		return trim($template);
43
+	}
44 44
 
45
-    /**
46
-     * @param string $templatePath
47
-     * @return void|string
48
-     */
49
-    public function render($templatePath, array $data = [])
50
-    {
51
-        echo $this->build($templatePath, $data);
52
-    }
45
+	/**
46
+	 * @param string $templatePath
47
+	 * @return void|string
48
+	 */
49
+	public function render($templatePath, array $data = [])
50
+	{
51
+		echo $this->build($templatePath, $data);
52
+	}
53 53
 
54
-    /**
55
-     * @return array
56
-     */
57
-    protected function normalize(array $data)
58
-    {
59
-        $arrayKeys = ['context', 'globals'];
60
-        $data = wp_parse_args($data, array_fill_keys($arrayKeys, []));
61
-        foreach ($arrayKeys as $key) {
62
-            if (is_array($data[$key])) {
63
-                continue;
64
-            }
65
-            $data[$key] = [];
66
-        }
67
-        return $data;
68
-    }
54
+	/**
55
+	 * @return array
56
+	 */
57
+	protected function normalize(array $data)
58
+	{
59
+		$arrayKeys = ['context', 'globals'];
60
+		$data = wp_parse_args($data, array_fill_keys($arrayKeys, []));
61
+		foreach ($arrayKeys as $key) {
62
+			if (is_array($data[$key])) {
63
+				continue;
64
+			}
65
+			$data[$key] = [];
66
+		}
67
+		return $data;
68
+	}
69 69
 
70
-    /**
71
-     * @return array
72
-     */
73
-    protected function normalizeContext(array $context)
74
-    {
75
-        $context = array_filter($context, function ($value) {
76
-            return !is_array($value) && !is_object($value);
77
-        });
78
-        return array_map(function ($value) {
79
-            return (string) $value;
80
-        }, $context);
81
-    }
70
+	/**
71
+	 * @return array
72
+	 */
73
+	protected function normalizeContext(array $context)
74
+	{
75
+		$context = array_filter($context, function ($value) {
76
+			return !is_array($value) && !is_object($value);
77
+		});
78
+		return array_map(function ($value) {
79
+			return (string) $value;
80
+		}, $context);
81
+	}
82 82
 }
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/Pagination.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -10,52 +10,52 @@
 block discarded – undo
10 10
 
11 11
 class Pagination implements PartialContract
12 12
 {
13
-    /**
14
-     * @var array
15
-     */
16
-    protected $args;
13
+	/**
14
+	 * @var array
15
+	 */
16
+	protected $args;
17 17
 
18
-    /**
19
-     * @return string
20
-     */
21
-    public function build(array $args = [])
22
-    {
23
-        $this->args = $this->normalize($args);
24
-        if ($this->args['total'] < 2) {
25
-            return '';
26
-        }
27
-        return glsr(Template::class)->build('templates/pagination', [
28
-            'context' => [
29
-                'links' => apply_filters('site-reviews/paginate_links', $this->buildLinks(), $this->args),
30
-                'loader' => '<div class="glsr-loader"></div>',
31
-                'screen_reader_text' => __('Site Reviews navigation', 'site-reviews'),
32
-            ],
33
-        ]);
34
-    }
18
+	/**
19
+	 * @return string
20
+	 */
21
+	public function build(array $args = [])
22
+	{
23
+		$this->args = $this->normalize($args);
24
+		if ($this->args['total'] < 2) {
25
+			return '';
26
+		}
27
+		return glsr(Template::class)->build('templates/pagination', [
28
+			'context' => [
29
+				'links' => apply_filters('site-reviews/paginate_links', $this->buildLinks(), $this->args),
30
+				'loader' => '<div class="glsr-loader"></div>',
31
+				'screen_reader_text' => __('Site Reviews navigation', 'site-reviews'),
32
+			],
33
+		]);
34
+	}
35 35
 
36
-    /**
37
-     * @return string
38
-     */
39
-    protected function buildLinks()
40
-    {
41
-        $args = glsr(Style::class)->paginationArgs($this->args);
42
-        if ('array' == $args['type']) {
43
-            $args['type'] = 'plain';
44
-        }
45
-        return paginate_links($args);
46
-    }
36
+	/**
37
+	 * @return string
38
+	 */
39
+	protected function buildLinks()
40
+	{
41
+		$args = glsr(Style::class)->paginationArgs($this->args);
42
+		if ('array' == $args['type']) {
43
+			$args['type'] = 'plain';
44
+		}
45
+		return paginate_links($args);
46
+	}
47 47
 
48
-    /**
49
-     * @return array
50
-     */
51
-    protected function normalize(array $args)
52
-    {
53
-        if ($baseUrl = Arr::get($args, 'baseUrl')) {
54
-            $args['base'] = $baseUrl.'%_%';
55
-        }
56
-        return wp_parse_args(array_filter($args), [
57
-            'current' => glsr(QueryBuilder::class)->getPaged(),
58
-            'total' => 1,
59
-        ]);
60
-    }
48
+	/**
49
+	 * @return array
50
+	 */
51
+	protected function normalize(array $args)
52
+	{
53
+		if ($baseUrl = Arr::get($args, 'baseUrl')) {
54
+			$args['base'] = $baseUrl.'%_%';
55
+		}
56
+		return wp_parse_args(array_filter($args), [
57
+			'current' => glsr(QueryBuilder::class)->getPaged(),
58
+			'total' => 1,
59
+		]);
60
+	}
61 61
 }
Please login to merge, or discard this patch.
plugin/Modules/Html/ReviewHtml.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -7,48 +7,48 @@
 block discarded – undo
7 7
 
8 8
 class ReviewHtml extends ArrayObject
9 9
 {
10
-    /**
11
-     * @var Review
12
-     */
13
-    public $review;
10
+	/**
11
+	 * @var Review
12
+	 */
13
+	public $review;
14 14
 
15
-    /**
16
-     * @var array
17
-     */
18
-    public $values;
15
+	/**
16
+	 * @var array
17
+	 */
18
+	public $values;
19 19
 
20
-    public function __construct(Review $review, array $values = [])
21
-    {
22
-        $this->review = $review;
23
-        $this->values = $values;
24
-        parent::__construct($values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
25
-    }
20
+	public function __construct(Review $review, array $values = [])
21
+	{
22
+		$this->review = $review;
23
+		$this->values = $values;
24
+		parent::__construct($values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
25
+	}
26 26
 
27
-    /**
28
-     * @return string|void
29
-     */
30
-    public function __toString()
31
-    {
32
-        if (empty($this->values)) {
33
-            return;
34
-        }
35
-        return glsr(Template::class)->build('templates/review', [
36
-            'context' => $this->values,
37
-            'review' => $this->review,
38
-        ]);
39
-    }
27
+	/**
28
+	 * @return string|void
29
+	 */
30
+	public function __toString()
31
+	{
32
+		if (empty($this->values)) {
33
+			return;
34
+		}
35
+		return glsr(Template::class)->build('templates/review', [
36
+			'context' => $this->values,
37
+			'review' => $this->review,
38
+		]);
39
+	}
40 40
 
41
-    /**
42
-     * @param mixed $key
43
-     * @return mixed
44
-     */
45
-    public function offsetGet($key)
46
-    {
47
-        if (array_key_exists($key, $this->values)) {
48
-            return $this->values[$key];
49
-        }
50
-        return property_exists($this, $key)
51
-            ? $this->$key
52
-            : null;
53
-    }
41
+	/**
42
+	 * @param mixed $key
43
+	 * @return mixed
44
+	 */
45
+	public function offsetGet($key)
46
+	{
47
+		if (array_key_exists($key, $this->values)) {
48
+			return $this->values[$key];
49
+		}
50
+		return property_exists($this, $key)
51
+			? $this->$key
52
+			: null;
53
+	}
54 54
 }
Please login to merge, or discard this patch.
plugin/Modules/Html/ReviewsHtml.php 1 patch
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -8,135 +8,135 @@
 block discarded – undo
8 8
 
9 9
 class ReviewsHtml extends ArrayObject
10 10
 {
11
-    /**
12
-     * @var array
13
-     */
14
-    public $args;
11
+	/**
12
+	 * @var array
13
+	 */
14
+	public $args;
15 15
 
16
-    /**
17
-     * @var int
18
-     */
19
-    public $max_num_pages;
16
+	/**
17
+	 * @var int
18
+	 */
19
+	public $max_num_pages;
20 20
 
21
-    /**
22
-     * @var string
23
-     */
24
-    public $pagination;
21
+	/**
22
+	 * @var string
23
+	 */
24
+	public $pagination;
25 25
 
26
-    /**
27
-     * @var array
28
-     */
29
-    public $reviews;
26
+	/**
27
+	 * @var array
28
+	 */
29
+	public $reviews;
30 30
 
31
-    public function __construct(array $renderedReviews, $maxPageCount, array $args)
32
-    {
33
-        $this->args = $args;
34
-        $this->max_num_pages = $maxPageCount;
35
-        $this->reviews = $renderedReviews;
36
-        $this->pagination = $this->buildPagination();
37
-        parent::__construct($renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
38
-    }
31
+	public function __construct(array $renderedReviews, $maxPageCount, array $args)
32
+	{
33
+		$this->args = $args;
34
+		$this->max_num_pages = $maxPageCount;
35
+		$this->reviews = $renderedReviews;
36
+		$this->pagination = $this->buildPagination();
37
+		parent::__construct($renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
38
+	}
39 39
 
40
-    /**
41
-     * @return string
42
-     */
43
-    public function __toString()
44
-    {
45
-        return glsr(Template::class)->build('templates/reviews', [
46
-            'args' => $this->args,
47
-            'context' => [
48
-                'assigned_to' => $this->args['assigned_to'],
49
-                'category' => $this->args['category'],
50
-                'class' => $this->getClass(),
51
-                'id' => $this->args['id'],
52
-                'pagination' => $this->getPagination(),
53
-                'reviews' => $this->getReviews(),
54
-            ],
55
-        ]);
56
-    }
40
+	/**
41
+	 * @return string
42
+	 */
43
+	public function __toString()
44
+	{
45
+		return glsr(Template::class)->build('templates/reviews', [
46
+			'args' => $this->args,
47
+			'context' => [
48
+				'assigned_to' => $this->args['assigned_to'],
49
+				'category' => $this->args['category'],
50
+				'class' => $this->getClass(),
51
+				'id' => $this->args['id'],
52
+				'pagination' => $this->getPagination(),
53
+				'reviews' => $this->getReviews(),
54
+			],
55
+		]);
56
+	}
57 57
 
58
-    /**
59
-     * @return string
60
-     */
61
-    public function getPagination()
62
-    {
63
-        return wp_validate_boolean($this->args['pagination'])
64
-            ? $this->pagination
65
-            : '';
66
-    }
58
+	/**
59
+	 * @return string
60
+	 */
61
+	public function getPagination()
62
+	{
63
+		return wp_validate_boolean($this->args['pagination'])
64
+			? $this->pagination
65
+			: '';
66
+	}
67 67
 
68
-    /**
69
-     * @return string
70
-     */
71
-    public function getReviews()
72
-    {
73
-        $html = empty($this->reviews)
74
-            ? $this->getReviewsFallback()
75
-            : implode(PHP_EOL, $this->reviews);
76
-        $wrapper = '<div class="glsr-reviews">%s</div>';
77
-        $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
78
-        return sprintf($wrapper, $html);
79
-    }
68
+	/**
69
+	 * @return string
70
+	 */
71
+	public function getReviews()
72
+	{
73
+		$html = empty($this->reviews)
74
+			? $this->getReviewsFallback()
75
+			: implode(PHP_EOL, $this->reviews);
76
+		$wrapper = '<div class="glsr-reviews">%s</div>';
77
+		$wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
78
+		return sprintf($wrapper, $html);
79
+	}
80 80
 
81
-    /**
82
-     * @param mixed $key
83
-     * @return mixed
84
-     */
85
-    public function offsetGet($key)
86
-    {
87
-        if ('navigation' == $key) {
88
-            glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
89
-            return $this->pagination;
90
-        }
91
-        if (array_key_exists($key, $this->reviews)) {
92
-            return $this->reviews[$key];
93
-        }
94
-        return property_exists($this, $key)
95
-            ? $this->$key
96
-            : null;
97
-    }
81
+	/**
82
+	 * @param mixed $key
83
+	 * @return mixed
84
+	 */
85
+	public function offsetGet($key)
86
+	{
87
+		if ('navigation' == $key) {
88
+			glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
89
+			return $this->pagination;
90
+		}
91
+		if (array_key_exists($key, $this->reviews)) {
92
+			return $this->reviews[$key];
93
+		}
94
+		return property_exists($this, $key)
95
+			? $this->$key
96
+			: null;
97
+	}
98 98
 
99
-    /**
100
-     * @return string
101
-     */
102
-    protected function buildPagination()
103
-    {
104
-        $html = glsr(Partial::class)->build('pagination', [
105
-            'baseUrl' => Arr::get($this->args, 'pagedUrl'),
106
-            'current' => Arr::get($this->args, 'paged'),
107
-            'total' => $this->max_num_pages,
108
-        ]);
109
-        $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
110
-        $wrapper = '<div class="glsr-pagination">%s</div>';
111
-        $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
112
-        return sprintf($wrapper, $html);
113
-    }
99
+	/**
100
+	 * @return string
101
+	 */
102
+	protected function buildPagination()
103
+	{
104
+		$html = glsr(Partial::class)->build('pagination', [
105
+			'baseUrl' => Arr::get($this->args, 'pagedUrl'),
106
+			'current' => Arr::get($this->args, 'paged'),
107
+			'total' => $this->max_num_pages,
108
+		]);
109
+		$html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
110
+		$wrapper = '<div class="glsr-pagination">%s</div>';
111
+		$wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
112
+		return sprintf($wrapper, $html);
113
+	}
114 114
 
115
-    /**
116
-     * @return string
117
-     */
118
-    protected function getClass()
119
-    {
120
-        $defaults = [
121
-            'glsr-default',
122
-        ];
123
-        if ('ajax' == $this->args['pagination']) {
124
-            $defaults[] = 'glsr-ajax-pagination';
125
-        }
126
-        $classes = explode(' ', $this->args['class']);
127
-        $classes = array_unique(array_merge($defaults, array_filter($classes)));
128
-        return implode(' ', $classes);
129
-    }
115
+	/**
116
+	 * @return string
117
+	 */
118
+	protected function getClass()
119
+	{
120
+		$defaults = [
121
+			'glsr-default',
122
+		];
123
+		if ('ajax' == $this->args['pagination']) {
124
+			$defaults[] = 'glsr-ajax-pagination';
125
+		}
126
+		$classes = explode(' ', $this->args['class']);
127
+		$classes = array_unique(array_merge($defaults, array_filter($classes)));
128
+		return implode(' ', $classes);
129
+	}
130 130
 
131
-    /**
132
-     * @return string
133
-     */
134
-    protected function getReviewsFallback()
135
-    {
136
-        if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
137
-            $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
138
-        }
139
-        $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
140
-        return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
141
-    }
131
+	/**
132
+	 * @return string
133
+	 */
134
+	protected function getReviewsFallback()
135
+	{
136
+		if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
137
+			$this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
138
+		}
139
+		$fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
140
+		return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
141
+	}
142 142
 }
Please login to merge, or discard this patch.
plugin/Contracts/PartialContract.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 
5 5
 interface PartialContract
6 6
 {
7
-    /**
8
-     * @return string
9
-     */
10
-    public function build(array $args = []);
7
+	/**
8
+	 * @return string
9
+	 */
10
+	public function build(array $args = []);
11 11
 }
Please login to merge, or discard this patch.
uninstall.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 require_once $file;
7 7
 
8 8
 if (!(new GL_Plugin_Check_v4($file))->isValid()) {
9
-    return;
9
+	return;
10 10
 }
11 11
 delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(3));
12 12
 delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(4));
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/StarRating.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -8,54 +8,54 @@
 block discarded – undo
8 8
 
9 9
 class StarRating implements PartialContract
10 10
 {
11
-    protected $prefix;
12
-    protected $rating;
11
+	protected $prefix;
12
+	protected $rating;
13 13
 
14
-    /**
15
-     * @return string
16
-     */
17
-    public function build(array $args = [])
18
-    {
19
-        $this->setProperties($args);
20
-        $fullStars = intval(floor($this->rating));
21
-        $halfStars = intval(ceil($this->rating - $fullStars));
22
-        $emptyStars = max(0, glsr()->constant('MAX_RATING', Rating::class) - $fullStars - $halfStars);
23
-        return glsr(Template::class)->build('templates/rating/stars', [
24
-            'context' => [
25
-                'empty_stars' => $this->getTemplate('empty-star', $emptyStars),
26
-                'full_stars' => $this->getTemplate('full-star', $fullStars),
27
-                'half_stars' => $this->getTemplate('half-star', $halfStars),
28
-                'prefix' => $this->prefix,
29
-                'title' => sprintf(__('%s rating', 'site-reviews'), number_format_i18n($this->rating, 1)),
30
-            ],
31
-        ]);
32
-    }
14
+	/**
15
+	 * @return string
16
+	 */
17
+	public function build(array $args = [])
18
+	{
19
+		$this->setProperties($args);
20
+		$fullStars = intval(floor($this->rating));
21
+		$halfStars = intval(ceil($this->rating - $fullStars));
22
+		$emptyStars = max(0, glsr()->constant('MAX_RATING', Rating::class) - $fullStars - $halfStars);
23
+		return glsr(Template::class)->build('templates/rating/stars', [
24
+			'context' => [
25
+				'empty_stars' => $this->getTemplate('empty-star', $emptyStars),
26
+				'full_stars' => $this->getTemplate('full-star', $fullStars),
27
+				'half_stars' => $this->getTemplate('half-star', $halfStars),
28
+				'prefix' => $this->prefix,
29
+				'title' => sprintf(__('%s rating', 'site-reviews'), number_format_i18n($this->rating, 1)),
30
+			],
31
+		]);
32
+	}
33 33
 
34
-    /**
35
-     * @param string $templateName
36
-     * @param int $timesRepeated
37
-     * @return string
38
-     */
39
-    protected function getTemplate($templateName, $timesRepeated)
40
-    {
41
-        $template = glsr(Template::class)->build('templates/rating/'.$templateName, [
42
-            'context' => [
43
-                'prefix' => $this->prefix,
44
-            ],
45
-        ]);
46
-        return str_repeat($template, $timesRepeated);
47
-    }
34
+	/**
35
+	 * @param string $templateName
36
+	 * @param int $timesRepeated
37
+	 * @return string
38
+	 */
39
+	protected function getTemplate($templateName, $timesRepeated)
40
+	{
41
+		$template = glsr(Template::class)->build('templates/rating/'.$templateName, [
42
+			'context' => [
43
+				'prefix' => $this->prefix,
44
+			],
45
+		]);
46
+		return str_repeat($template, $timesRepeated);
47
+	}
48 48
 
49
-    /**
50
-     * @return array
51
-     */
52
-    protected function setProperties(array $args)
53
-    {
54
-        $args = wp_parse_args($args, [
55
-            'prefix' => glsr()->isAdmin() ? '' : 'glsr-',
56
-            'rating' => 0,
57
-        ]);
58
-        $this->prefix = $args['prefix'];
59
-        $this->rating = (float) str_replace(',', '.', $args['rating']);
60
-    }
49
+	/**
50
+	 * @return array
51
+	 */
52
+	protected function setProperties(array $args)
53
+	{
54
+		$args = wp_parse_args($args, [
55
+			'prefix' => glsr()->isAdmin() ? '' : 'glsr-',
56
+			'rating' => 0,
57
+		]);
58
+		$this->prefix = $args['prefix'];
59
+		$this->rating = (float) str_replace(',', '.', $args['rating']);
60
+	}
61 61
 }
Please login to merge, or discard this patch.
activate.php 1 patch
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -8,141 +8,141 @@
 block discarded – undo
8 8
  */
9 9
 class GL_Plugin_Check_v4
10 10
 {
11
-    const MIN_PHP_VERSION = '5.6.0';
12
-    const MIN_WORDPRESS_VERSION = '4.7.0';
11
+	const MIN_PHP_VERSION = '5.6.0';
12
+	const MIN_WORDPRESS_VERSION = '4.7.0';
13 13
 
14
-    /**
15
-     * @var array
16
-     */
17
-    public $versions;
14
+	/**
15
+	 * @var array
16
+	 */
17
+	public $versions;
18 18
 
19
-    /**
20
-     * @var string
21
-     */
22
-    protected $file;
19
+	/**
20
+	 * @var string
21
+	 */
22
+	protected $file;
23 23
 
24
-    /**
25
-     * @param string $file
26
-     */
27
-    public function __construct($file)
28
-    {
29
-        $this->file = realpath($file);
30
-        $versionRequirements = get_file_data($this->file, [
31
-            'php' => 'Requires PHP',
32
-            'wordpress' => 'Requires at least',
33
-        ]);
34
-        $this->versions = wp_parse_args(array_filter($versionRequirements), [
35
-            'php' => static::MIN_PHP_VERSION,
36
-            'wordpress' => static::MIN_WORDPRESS_VERSION,
37
-        ]);
38
-    }
24
+	/**
25
+	 * @param string $file
26
+	 */
27
+	public function __construct($file)
28
+	{
29
+		$this->file = realpath($file);
30
+		$versionRequirements = get_file_data($this->file, [
31
+			'php' => 'Requires PHP',
32
+			'wordpress' => 'Requires at least',
33
+		]);
34
+		$this->versions = wp_parse_args(array_filter($versionRequirements), [
35
+			'php' => static::MIN_PHP_VERSION,
36
+			'wordpress' => static::MIN_WORDPRESS_VERSION,
37
+		]);
38
+	}
39 39
 
40
-    /**
41
-     * @return bool
42
-     */
43
-    public function canProceed()
44
-    {
45
-        if ($this->isValid()) {
46
-            return true;
47
-        }
48
-        add_action('activated_plugin', [$this, 'deactivate']);
49
-        add_action('admin_notices', [$this, 'deactivate']);
50
-        return false;
51
-    }
40
+	/**
41
+	 * @return bool
42
+	 */
43
+	public function canProceed()
44
+	{
45
+		if ($this->isValid()) {
46
+			return true;
47
+		}
48
+		add_action('activated_plugin', [$this, 'deactivate']);
49
+		add_action('admin_notices', [$this, 'deactivate']);
50
+		return false;
51
+	}
52 52
 
53
-    /**
54
-     * @return bool
55
-     */
56
-    public function isPhpValid()
57
-    {
58
-        return !version_compare(PHP_VERSION, $this->versions['php'], '<');
59
-    }
53
+	/**
54
+	 * @return bool
55
+	 */
56
+	public function isPhpValid()
57
+	{
58
+		return !version_compare(PHP_VERSION, $this->versions['php'], '<');
59
+	}
60 60
 
61
-    /**
62
-     * @return bool
63
-     */
64
-    public function isValid()
65
-    {
66
-        return $this->isPhpValid() && $this->isWpValid();
67
-    }
61
+	/**
62
+	 * @return bool
63
+	 */
64
+	public function isValid()
65
+	{
66
+		return $this->isPhpValid() && $this->isWpValid();
67
+	}
68 68
 
69
-    /**
70
-     * @return bool
71
-     */
72
-    public function isWpValid()
73
-    {
74
-        global $wp_version;
75
-        return !version_compare($wp_version, $this->versions['wordpress'], '<');
76
-    }
69
+	/**
70
+	 * @return bool
71
+	 */
72
+	public function isWpValid()
73
+	{
74
+		global $wp_version;
75
+		return !version_compare($wp_version, $this->versions['wordpress'], '<');
76
+	}
77 77
 
78
-    /**
79
-     * @param string $plugin
80
-     * @return void
81
-     */
82
-    public function deactivate($plugin)
83
-    {
84
-        if ($this->isValid()) {
85
-            return;
86
-        }
87
-        $pluginSlug = plugin_basename($this->file);
88
-        if ($plugin == $pluginSlug) {
89
-            $this->redirect(); //exit
90
-        }
91
-        $pluginData = get_file_data($this->file, ['name' => 'Plugin Name'], 'plugin');
92
-        deactivate_plugins($pluginSlug);
93
-        $this->printNotice($pluginData['name']);
94
-    }
78
+	/**
79
+	 * @param string $plugin
80
+	 * @return void
81
+	 */
82
+	public function deactivate($plugin)
83
+	{
84
+		if ($this->isValid()) {
85
+			return;
86
+		}
87
+		$pluginSlug = plugin_basename($this->file);
88
+		if ($plugin == $pluginSlug) {
89
+			$this->redirect(); //exit
90
+		}
91
+		$pluginData = get_file_data($this->file, ['name' => 'Plugin Name'], 'plugin');
92
+		deactivate_plugins($pluginSlug);
93
+		$this->printNotice($pluginData['name']);
94
+	}
95 95
 
96
-    /**
97
-     * @return array
98
-     */
99
-    protected function getMessages()
100
-    {
101
-        return [
102
-            'notice' => __('The %s plugin was deactivated.', 'site-reviews'),
103
-            'php_version' => __('PHP version', 'site-reviews'),
104
-            'rollback' => __('You can use the %s plugin to restore %s to the previous version.', 'site-reviews'),
105
-            'update_php' => __('Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'site-reviews'),
106
-            'update_wp' => __('Update WordPress', 'site-reviews'),
107
-            'wp_version' => __('WordPress version', 'site-reviews'),
108
-            'wrong_version' => __('This plugin requires %s or greater in order to work properly.', 'site-reviews'),
109
-        ];
110
-    }
96
+	/**
97
+	 * @return array
98
+	 */
99
+	protected function getMessages()
100
+	{
101
+		return [
102
+			'notice' => __('The %s plugin was deactivated.', 'site-reviews'),
103
+			'php_version' => __('PHP version', 'site-reviews'),
104
+			'rollback' => __('You can use the %s plugin to restore %s to the previous version.', 'site-reviews'),
105
+			'update_php' => __('Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'site-reviews'),
106
+			'update_wp' => __('Update WordPress', 'site-reviews'),
107
+			'wp_version' => __('WordPress version', 'site-reviews'),
108
+			'wrong_version' => __('This plugin requires %s or greater in order to work properly.', 'site-reviews'),
109
+		];
110
+	}
111 111
 
112
-    /**
113
-     * @param string $pluginName
114
-     * @return void
115
-     */
116
-    protected function printNotice($pluginName)
117
-    {
118
-        $noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>';
119
-        $messages = $this->getMessages();
120
-        $rollbackMessage = sprintf('<strong>'.$messages['rollback'].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName);
121
-        if (!$this->isPhpValid()) {
122
-            printf($noticeTemplate,
123
-                sprintf($messages['notice'], $pluginName),
124
-                sprintf($messages['wrong_version'], $messages['php_version'].' '.$this->versions['php']),
125
-                sprintf($messages['update_php'], PHP_VERSION).'</p><p>'.$rollbackMessage
126
-            );
127
-        } elseif (!$this->isWpValid()) {
128
-            printf($noticeTemplate,
129
-                sprintf($messages['notice'], $pluginName),
130
-                sprintf($messages['wrong_version'], $messages['wp_version'].' '.$this->versions['wordpress']),
131
-                $rollbackMessage.'</p><p>'.sprintf('<a href="%s">%s</a>', admin_url('update-core.php'), $messages['update_wp'])
132
-            );
133
-        }
134
-    }
112
+	/**
113
+	 * @param string $pluginName
114
+	 * @return void
115
+	 */
116
+	protected function printNotice($pluginName)
117
+	{
118
+		$noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>';
119
+		$messages = $this->getMessages();
120
+		$rollbackMessage = sprintf('<strong>'.$messages['rollback'].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName);
121
+		if (!$this->isPhpValid()) {
122
+			printf($noticeTemplate,
123
+				sprintf($messages['notice'], $pluginName),
124
+				sprintf($messages['wrong_version'], $messages['php_version'].' '.$this->versions['php']),
125
+				sprintf($messages['update_php'], PHP_VERSION).'</p><p>'.$rollbackMessage
126
+			);
127
+		} elseif (!$this->isWpValid()) {
128
+			printf($noticeTemplate,
129
+				sprintf($messages['notice'], $pluginName),
130
+				sprintf($messages['wrong_version'], $messages['wp_version'].' '.$this->versions['wordpress']),
131
+				$rollbackMessage.'</p><p>'.sprintf('<a href="%s">%s</a>', admin_url('update-core.php'), $messages['update_wp'])
132
+			);
133
+		}
134
+	}
135 135
 
136
-    /**
137
-     * @return void
138
-     */
139
-    protected function redirect()
140
-    {
141
-        wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s',
142
-            filter_input(INPUT_GET, 'plugin_status'),
143
-            filter_input(INPUT_GET, 'paged'),
144
-            filter_input(INPUT_GET, 's')
145
-        )));
146
-        exit;
147
-    }
136
+	/**
137
+	 * @return void
138
+	 */
139
+	protected function redirect()
140
+	{
141
+		wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s',
142
+			filter_input(INPUT_GET, 'plugin_status'),
143
+			filter_input(INPUT_GET, 'paged'),
144
+			filter_input(INPUT_GET, 's')
145
+		)));
146
+		exit;
147
+	}
148 148
 }
Please login to merge, or discard this patch.
plugin/Shortcodes/Shortcode.php 1 patch
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -11,227 +11,227 @@
 block discarded – undo
11 11
 
12 12
 abstract class Shortcode implements ShortcodeContract
13 13
 {
14
-    /**
15
-     * @var string
16
-     */
17
-    protected $partialName;
18
-
19
-    /**
20
-     * @var string
21
-     */
22
-    protected $shortcodeName;
23
-
24
-    public function __construct()
25
-    {
26
-        $this->partialName = $this->getShortcodePartialName();
27
-        $this->shortcodeName = $this->getShortcodeName();
28
-    }
29
-
30
-    /**
31
-     * @param string|array $atts
32
-     * @param string $type
33
-     * @return string
34
-     */
35
-    public function build($atts, array $args = [], $type = 'shortcode')
36
-    {
37
-        $args = $this->normalizeArgs($args, $type);
38
-        $atts = $this->normalizeAtts($atts, $type);
39
-        $partial = glsr(Partial::class)->build($this->partialName, $atts);
40
-        $title = !empty($atts['title'])
41
-            ? $args['before_title'].$atts['title'].$args['after_title']
42
-            : '';
43
-        $debug = sprintf('<glsr-%1$s hidden data-atts=\'%2$s\'></glsr-%1$s>', $type, $atts['json']);
44
-        return $args['before_widget'].$title.$partial.$debug.$args['after_widget'];
45
-    }
46
-
47
-    /**
48
-     * @param string|array $atts
49
-     * @return string
50
-     */
51
-    public function buildShortcode($atts = [])
52
-    {
53
-        return $this->build($atts);
54
-    }
55
-
56
-    /**
57
-     * @return array
58
-     */
59
-    public function getDefaults($atts)
60
-    {
61
-        return glsr($this->getShortcodeDefaultsClassName())->restrict(wp_parse_args($atts));
62
-    }
63
-
64
-    /**
65
-     * @return array
66
-     */
67
-    public function getHideOptions()
68
-    {
69
-        $options = $this->hideOptions();
70
-        return apply_filters('site-reviews/shortcode/hide-options', $options, $this->shortcodeName);
71
-    }
72
-
73
-    /**
74
-     * @return string
75
-     */
76
-    public function getShortcodeClassName($replace = '', $search = 'Shortcode')
77
-    {
78
-        return str_replace($search, $replace, (new ReflectionClass($this))->getShortName());
79
-    }
80
-
81
-    /**
82
-     * @return string
83
-     */
84
-    public function getShortcodeDefaultsClassName()
85
-    {
86
-        return Helper::buildClassName(
87
-            $this->getShortcodeClassName('Defaults'),
88
-            'Defaults'
89
-        );
90
-    }
91
-
92
-    /**
93
-     * @return string
94
-     */
95
-    public function getShortcodeName()
96
-    {
97
-        return Str::snakeCase($this->getShortcodeClassName());
98
-    }
99
-
100
-    /**
101
-     * @return string
102
-     */
103
-    public function getShortcodePartialName()
104
-    {
105
-        return Str::dashCase($this->getShortcodeClassName());
106
-    }
107
-
108
-    /**
109
-     * @param array|string $args
110
-     * @param string $type
111
-     * @return array
112
-     */
113
-    public function normalizeArgs($args, $type = 'shortcode')
114
-    {
115
-        $args = wp_parse_args($args, [
116
-            'before_widget' => '<div class="glsr-'.$type.' '.$type.'-'.$this->partialName.'">',
117
-            'after_widget' => '</div>',
118
-            'before_title' => '<h3 class="glsr-'.$type.'-title">',
119
-            'after_title' => '</h3>',
120
-        ]);
121
-        return apply_filters('site-reviews/shortcode/args', $args, $type, $this->partialName);
122
-    }
123
-
124
-    /**
125
-     * @param array|string $atts
126
-     * @param string $type
127
-     * @return array
128
-     */
129
-    public function normalizeAtts($atts, $type = 'shortcode')
130
-    {
131
-        $atts = apply_filters('site-reviews/shortcode/atts', $atts, $type, $this->partialName);
132
-        $atts = $this->getDefaults($atts);
133
-        array_walk($atts, function (&$value, $key) {
134
-            $methodName = Helper::buildMethodName($key, 'normalize');
135
-            if (!method_exists($this, $methodName)) {
136
-                return;
137
-            }
138
-            $value = $this->$methodName($value);
139
-        });
140
-        return $atts;
141
-    }
142
-
143
-    /**
144
-     * @return array
145
-     */
146
-    abstract protected function hideOptions();
147
-
148
-    /**
149
-     * @param string $postId
150
-     * @return int|string
151
-     */
152
-    protected function normalizeAssignedTo($postId)
153
-    {
154
-        if ('parent_id' == $postId) {
155
-            $postId = intval(wp_get_post_parent_id(intval(get_the_ID())));
156
-        } elseif ('post_id' == $postId) {
157
-            $postId = intval(get_the_ID());
158
-        }
159
-        return $postId;
160
-    }
161
-
162
-    /**
163
-     * @param string $postId
164
-     * @return int|string
165
-     */
166
-    protected function normalizeAssignTo($postId)
167
-    {
168
-        return $this->normalizeAssignedTo($postId);
169
-    }
170
-
171
-    /**
172
-     * @param string|array $hide
173
-     * @return array
174
-     */
175
-    protected function normalizeHide($hide)
176
-    {
177
-        if (is_string($hide)) {
178
-            $hide = explode(',', $hide);
179
-        }
180
-        $hideKeys = array_keys($this->getHideOptions());
181
-        return array_filter(array_map('trim', $hide), function ($value) use ($hideKeys) {
182
-            return in_array($value, $hideKeys);
183
-        });
184
-    }
185
-
186
-    /**
187
-     * @param string $id
188
-     * @return string
189
-     */
190
-    protected function normalizeId($id)
191
-    {
192
-        return sanitize_title($id);
193
-    }
194
-
195
-    /**
196
-     * @param string $labels
197
-     * @return array
198
-     */
199
-    protected function normalizeLabels($labels)
200
-    {
201
-        $defaults = [
202
-            __('Excellent', 'site-reviews'),
203
-            __('Very good', 'site-reviews'),
204
-            __('Average', 'site-reviews'),
205
-            __('Poor', 'site-reviews'),
206
-            __('Terrible', 'site-reviews'),
207
-        ];
208
-        $maxRating = (int) glsr()->constant('MAX_RATING', Rating::class);
209
-        $defaults = array_pad(array_slice($defaults, 0, $maxRating), $maxRating, '');
210
-        $labels = array_map('trim', explode(',', $labels));
211
-        foreach ($defaults as $i => $label) {
212
-            if (empty($labels[$i])) {
213
-                continue;
214
-            }
215
-            $defaults[$i] = $labels[$i];
216
-        }
217
-        return array_combine(range($maxRating, 1), $defaults);
218
-    }
219
-
220
-    /**
221
-     * @param string $schema
222
-     * @return bool
223
-     */
224
-    protected function normalizeSchema($schema)
225
-    {
226
-        return wp_validate_boolean($schema);
227
-    }
228
-
229
-    /**
230
-     * @param string $text
231
-     * @return string
232
-     */
233
-    protected function normalizeText($text)
234
-    {
235
-        return trim($text);
236
-    }
14
+	/**
15
+	 * @var string
16
+	 */
17
+	protected $partialName;
18
+
19
+	/**
20
+	 * @var string
21
+	 */
22
+	protected $shortcodeName;
23
+
24
+	public function __construct()
25
+	{
26
+		$this->partialName = $this->getShortcodePartialName();
27
+		$this->shortcodeName = $this->getShortcodeName();
28
+	}
29
+
30
+	/**
31
+	 * @param string|array $atts
32
+	 * @param string $type
33
+	 * @return string
34
+	 */
35
+	public function build($atts, array $args = [], $type = 'shortcode')
36
+	{
37
+		$args = $this->normalizeArgs($args, $type);
38
+		$atts = $this->normalizeAtts($atts, $type);
39
+		$partial = glsr(Partial::class)->build($this->partialName, $atts);
40
+		$title = !empty($atts['title'])
41
+			? $args['before_title'].$atts['title'].$args['after_title']
42
+			: '';
43
+		$debug = sprintf('<glsr-%1$s hidden data-atts=\'%2$s\'></glsr-%1$s>', $type, $atts['json']);
44
+		return $args['before_widget'].$title.$partial.$debug.$args['after_widget'];
45
+	}
46
+
47
+	/**
48
+	 * @param string|array $atts
49
+	 * @return string
50
+	 */
51
+	public function buildShortcode($atts = [])
52
+	{
53
+		return $this->build($atts);
54
+	}
55
+
56
+	/**
57
+	 * @return array
58
+	 */
59
+	public function getDefaults($atts)
60
+	{
61
+		return glsr($this->getShortcodeDefaultsClassName())->restrict(wp_parse_args($atts));
62
+	}
63
+
64
+	/**
65
+	 * @return array
66
+	 */
67
+	public function getHideOptions()
68
+	{
69
+		$options = $this->hideOptions();
70
+		return apply_filters('site-reviews/shortcode/hide-options', $options, $this->shortcodeName);
71
+	}
72
+
73
+	/**
74
+	 * @return string
75
+	 */
76
+	public function getShortcodeClassName($replace = '', $search = 'Shortcode')
77
+	{
78
+		return str_replace($search, $replace, (new ReflectionClass($this))->getShortName());
79
+	}
80
+
81
+	/**
82
+	 * @return string
83
+	 */
84
+	public function getShortcodeDefaultsClassName()
85
+	{
86
+		return Helper::buildClassName(
87
+			$this->getShortcodeClassName('Defaults'),
88
+			'Defaults'
89
+		);
90
+	}
91
+
92
+	/**
93
+	 * @return string
94
+	 */
95
+	public function getShortcodeName()
96
+	{
97
+		return Str::snakeCase($this->getShortcodeClassName());
98
+	}
99
+
100
+	/**
101
+	 * @return string
102
+	 */
103
+	public function getShortcodePartialName()
104
+	{
105
+		return Str::dashCase($this->getShortcodeClassName());
106
+	}
107
+
108
+	/**
109
+	 * @param array|string $args
110
+	 * @param string $type
111
+	 * @return array
112
+	 */
113
+	public function normalizeArgs($args, $type = 'shortcode')
114
+	{
115
+		$args = wp_parse_args($args, [
116
+			'before_widget' => '<div class="glsr-'.$type.' '.$type.'-'.$this->partialName.'">',
117
+			'after_widget' => '</div>',
118
+			'before_title' => '<h3 class="glsr-'.$type.'-title">',
119
+			'after_title' => '</h3>',
120
+		]);
121
+		return apply_filters('site-reviews/shortcode/args', $args, $type, $this->partialName);
122
+	}
123
+
124
+	/**
125
+	 * @param array|string $atts
126
+	 * @param string $type
127
+	 * @return array
128
+	 */
129
+	public function normalizeAtts($atts, $type = 'shortcode')
130
+	{
131
+		$atts = apply_filters('site-reviews/shortcode/atts', $atts, $type, $this->partialName);
132
+		$atts = $this->getDefaults($atts);
133
+		array_walk($atts, function (&$value, $key) {
134
+			$methodName = Helper::buildMethodName($key, 'normalize');
135
+			if (!method_exists($this, $methodName)) {
136
+				return;
137
+			}
138
+			$value = $this->$methodName($value);
139
+		});
140
+		return $atts;
141
+	}
142
+
143
+	/**
144
+	 * @return array
145
+	 */
146
+	abstract protected function hideOptions();
147
+
148
+	/**
149
+	 * @param string $postId
150
+	 * @return int|string
151
+	 */
152
+	protected function normalizeAssignedTo($postId)
153
+	{
154
+		if ('parent_id' == $postId) {
155
+			$postId = intval(wp_get_post_parent_id(intval(get_the_ID())));
156
+		} elseif ('post_id' == $postId) {
157
+			$postId = intval(get_the_ID());
158
+		}
159
+		return $postId;
160
+	}
161
+
162
+	/**
163
+	 * @param string $postId
164
+	 * @return int|string
165
+	 */
166
+	protected function normalizeAssignTo($postId)
167
+	{
168
+		return $this->normalizeAssignedTo($postId);
169
+	}
170
+
171
+	/**
172
+	 * @param string|array $hide
173
+	 * @return array
174
+	 */
175
+	protected function normalizeHide($hide)
176
+	{
177
+		if (is_string($hide)) {
178
+			$hide = explode(',', $hide);
179
+		}
180
+		$hideKeys = array_keys($this->getHideOptions());
181
+		return array_filter(array_map('trim', $hide), function ($value) use ($hideKeys) {
182
+			return in_array($value, $hideKeys);
183
+		});
184
+	}
185
+
186
+	/**
187
+	 * @param string $id
188
+	 * @return string
189
+	 */
190
+	protected function normalizeId($id)
191
+	{
192
+		return sanitize_title($id);
193
+	}
194
+
195
+	/**
196
+	 * @param string $labels
197
+	 * @return array
198
+	 */
199
+	protected function normalizeLabels($labels)
200
+	{
201
+		$defaults = [
202
+			__('Excellent', 'site-reviews'),
203
+			__('Very good', 'site-reviews'),
204
+			__('Average', 'site-reviews'),
205
+			__('Poor', 'site-reviews'),
206
+			__('Terrible', 'site-reviews'),
207
+		];
208
+		$maxRating = (int) glsr()->constant('MAX_RATING', Rating::class);
209
+		$defaults = array_pad(array_slice($defaults, 0, $maxRating), $maxRating, '');
210
+		$labels = array_map('trim', explode(',', $labels));
211
+		foreach ($defaults as $i => $label) {
212
+			if (empty($labels[$i])) {
213
+				continue;
214
+			}
215
+			$defaults[$i] = $labels[$i];
216
+		}
217
+		return array_combine(range($maxRating, 1), $defaults);
218
+	}
219
+
220
+	/**
221
+	 * @param string $schema
222
+	 * @return bool
223
+	 */
224
+	protected function normalizeSchema($schema)
225
+	{
226
+		return wp_validate_boolean($schema);
227
+	}
228
+
229
+	/**
230
+	 * @param string $text
231
+	 * @return string
232
+	 */
233
+	protected function normalizeText($text)
234
+	{
235
+		return trim($text);
236
+	}
237 237
 }
Please login to merge, or discard this patch.