Passed
Push — master ( e0a59a...75b6ac )
by Paul
06:30 queued 02:41
created
plugin/Widgets/SiteReviewsWidget.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -7,92 +7,92 @@
 block discarded – undo
7 7
 
8 8
 class SiteReviewsWidget extends Widget
9 9
 {
10
-    /**
11
-     * @param array $instance
12
-     * @return void
13
-     */
14
-    public function form($instance)
15
-    {
16
-        $this->widgetArgs = glsr(SiteReviewsShortcode::class)->normalizeAtts($instance);
17
-        $terms = glsr(Database::class)->getTerms();
18
-        $this->renderField('text', [
19
-            'class' => 'widefat',
20
-            'label' => __('Title', 'site-reviews'),
21
-            'name' => 'title',
22
-        ]);
23
-        $this->renderField('number', [
24
-            'class' => 'small-text',
25
-            'default' => 10,
26
-            'label' => __('How many reviews would you like to display?', 'site-reviews'),
27
-            'max' => 100,
28
-            'name' => 'display',
29
-        ]);
30
-        $this->renderField('select', [
31
-            'label' => __('What is the minimum rating to display?', 'site-reviews'),
32
-            'name' => 'rating',
33
-            'options' => [
34
-                '5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5),
35
-                '4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4),
36
-                '3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3),
37
-                '2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2),
38
-                '1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1),
39
-            ],
40
-        ]);
41
-        if (count(glsr()->reviewTypes) > 1) {
42
-            $this->renderField('select', [
43
-                'class' => 'widefat',
44
-                'label' => __('Which type of review would you like to display?', 'site-reviews'),
45
-                'name' => 'type',
46
-                'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes,
47
-            ]);
48
-        }
49
-        if (!empty($terms)) {
50
-            $this->renderField('select', [
51
-                'class' => 'widefat',
52
-                'label' => __('Limit reviews to this category', 'site-reviews'),
53
-                'name' => 'category',
54
-                'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
55
-            ]);
56
-        }
57
-        $this->renderField('text', [
58
-            'class' => 'widefat',
59
-            'default' => '',
60
-            'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
61
-            'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'),
62
-            'name' => 'assigned_to',
63
-        ]);
64
-        $this->renderField('text', [
65
-            'class' => 'widefat',
66
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
67
-            'name' => 'class',
68
-        ]);
69
-        $this->renderField('checkbox', [
70
-            'name' => 'hide',
71
-            'options' => glsr(SiteReviewsShortcode::class)->getHideOptions(),
72
-        ]);
73
-    }
10
+	/**
11
+	 * @param array $instance
12
+	 * @return void
13
+	 */
14
+	public function form($instance)
15
+	{
16
+		$this->widgetArgs = glsr(SiteReviewsShortcode::class)->normalizeAtts($instance);
17
+		$terms = glsr(Database::class)->getTerms();
18
+		$this->renderField('text', [
19
+			'class' => 'widefat',
20
+			'label' => __('Title', 'site-reviews'),
21
+			'name' => 'title',
22
+		]);
23
+		$this->renderField('number', [
24
+			'class' => 'small-text',
25
+			'default' => 10,
26
+			'label' => __('How many reviews would you like to display?', 'site-reviews'),
27
+			'max' => 100,
28
+			'name' => 'display',
29
+		]);
30
+		$this->renderField('select', [
31
+			'label' => __('What is the minimum rating to display?', 'site-reviews'),
32
+			'name' => 'rating',
33
+			'options' => [
34
+				'5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5),
35
+				'4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4),
36
+				'3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3),
37
+				'2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2),
38
+				'1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1),
39
+			],
40
+		]);
41
+		if (count(glsr()->reviewTypes) > 1) {
42
+			$this->renderField('select', [
43
+				'class' => 'widefat',
44
+				'label' => __('Which type of review would you like to display?', 'site-reviews'),
45
+				'name' => 'type',
46
+				'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes,
47
+			]);
48
+		}
49
+		if (!empty($terms)) {
50
+			$this->renderField('select', [
51
+				'class' => 'widefat',
52
+				'label' => __('Limit reviews to this category', 'site-reviews'),
53
+				'name' => 'category',
54
+				'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
55
+			]);
56
+		}
57
+		$this->renderField('text', [
58
+			'class' => 'widefat',
59
+			'default' => '',
60
+			'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
61
+			'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'),
62
+			'name' => 'assigned_to',
63
+		]);
64
+		$this->renderField('text', [
65
+			'class' => 'widefat',
66
+			'label' => __('Enter any custom CSS classes here', 'site-reviews'),
67
+			'name' => 'class',
68
+		]);
69
+		$this->renderField('checkbox', [
70
+			'name' => 'hide',
71
+			'options' => glsr(SiteReviewsShortcode::class)->getHideOptions(),
72
+		]);
73
+	}
74 74
 
75
-    /**
76
-     * @param array $newInstance
77
-     * @param array $oldInstance
78
-     * @return array
79
-     */
80
-    public function update($newInstance, $oldInstance)
81
-    {
82
-        if (!is_numeric($newInstance['display'])) {
83
-            $newInstance['display'] = 10;
84
-        }
85
-        $newInstance['display'] = min(50, max(0, intval($newInstance['display'])));
86
-        return parent::update($newInstance, $oldInstance);
87
-    }
75
+	/**
76
+	 * @param array $newInstance
77
+	 * @param array $oldInstance
78
+	 * @return array
79
+	 */
80
+	public function update($newInstance, $oldInstance)
81
+	{
82
+		if (!is_numeric($newInstance['display'])) {
83
+			$newInstance['display'] = 10;
84
+		}
85
+		$newInstance['display'] = min(50, max(0, intval($newInstance['display'])));
86
+		return parent::update($newInstance, $oldInstance);
87
+	}
88 88
 
89
-    /**
90
-     * @param array $args
91
-     * @param array $instance
92
-     * @return void
93
-     */
94
-    public function widget($args, $instance)
95
-    {
96
-        echo glsr(SiteReviewsShortcode::class)->build($instance, $args, 'widget');
97
-    }
89
+	/**
90
+	 * @param array $args
91
+	 * @param array $instance
92
+	 * @return void
93
+	 */
94
+	public function widget($args, $instance)
95
+	{
96
+		echo glsr(SiteReviewsShortcode::class)->build($instance, $args, 'widget');
97
+	}
98 98
 }
Please login to merge, or discard this patch.
plugin/Blocks/SiteReviewsBlock.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -6,124 +6,124 @@
 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->filterReviewLinks();
72
-            $this->filterShortcodeClass();
73
-            $this->filterShowMoreLinks('content');
74
-            $this->filterShowMoreLinks('response');
75
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
76
-                $this->filterInterpolation();
77
-            }
78
-        }
79
-        return $shortcode->buildShortcode($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->filterReviewLinks();
72
+			$this->filterShortcodeClass();
73
+			$this->filterShowMoreLinks('content');
74
+			$this->filterShowMoreLinks('response');
75
+			if (!$this->hasVisibleFields($shortcode, $attributes)) {
76
+				$this->filterInterpolation();
77
+			}
78
+		}
79
+		return $shortcode->buildShortcode($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
-     * @return void
106
-     */
107
-    protected function filterShortcodeClass()
108
-    {
109
-        add_filter('site-reviews/style', function () {
110
-            return 'default';
111
-        });
112
-    }
104
+	/**
105
+	 * @return void
106
+	 */
107
+	protected function filterShortcodeClass()
108
+	{
109
+		add_filter('site-reviews/style', function () {
110
+			return 'default';
111
+		});
112
+	}
113 113
 
114
-    /**
115
-     * @param string $field
116
-     * @return void
117
-     */
118
-    protected function filterShowMoreLinks($field)
119
-    {
120
-        add_filter('site-reviews/review/wrap/'.$field, function ($value) {
121
-            $value = preg_replace(
122
-                '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/s',
123
-                '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5',
124
-                $value
125
-            );
126
-            return $value;
127
-        });
128
-    }
114
+	/**
115
+	 * @param string $field
116
+	 * @return void
117
+	 */
118
+	protected function filterShowMoreLinks($field)
119
+	{
120
+		add_filter('site-reviews/review/wrap/'.$field, function ($value) {
121
+			$value = preg_replace(
122
+				'/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/s',
123
+				'$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5',
124
+				$value
125
+			);
126
+			return $value;
127
+		});
128
+	}
129 129
 }
Please login to merge, or discard this patch.
plugin/Shortcodes/SiteReviewsPopup.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -4,84 +4,84 @@
 block discarded – undo
4 4
 
5 5
 class SiteReviewsPopup extends TinymcePopupGenerator
6 6
 {
7
-    /**
8
-     * @return array
9
-     */
10
-    public function fields()
11
-    {
12
-        return [[
13
-            'html' => sprintf('<p class="strong">%s</p>', esc_html__('All settings are optional.', 'site-reviews')),
14
-            'minWidth' => 320,
15
-            'type' => 'container',
16
-        ], [
17
-            'label' => esc_html__('Title', 'site-reviews'),
18
-            'name' => 'title',
19
-            'tooltip' => __('Enter a custom shortcode heading.', 'site-reviews'),
20
-            'type' => 'textbox',
21
-        ], [
22
-            'label' => esc_html__('Display', 'site-reviews'),
23
-            'maxLength' => 5,
24
-            'name' => 'display',
25
-            'size' => 3,
26
-            'text' => '10',
27
-            'tooltip' => __('How many reviews would you like to display (default: 10)?', 'site-reviews'),
28
-            'type' => 'textbox',
29
-        ], [
30
-            'label' => esc_html__('Rating', 'site-reviews'),
31
-            'name' => 'rating',
32
-            'options' => [
33
-                '5' => esc_html(sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5)),
34
-                '4' => esc_html(sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4)),
35
-                '3' => esc_html(sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3)),
36
-                '2' => esc_html(sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2)),
37
-                '1' => esc_html(sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1)),
38
-                '0' => esc_html(__('Unrated', 'site-reviews')),
39
-            ],
40
-            'tooltip' => __('What is the minimum rating to display (default: 1 star)?', 'site-reviews'),
41
-            'type' => 'listbox',
42
-        ], [
43
-            'label' => esc_html__('Pagination', 'site-reviews'),
44
-            'name' => 'pagination',
45
-            'options' => [
46
-                'true' => esc_html__('Enable', 'site-reviews'),
47
-                'ajax' => esc_html__('Enable (using ajax)', 'site-reviews'),
48
-                'false' => esc_html__('Disable', 'site-reviews'),
49
-            ],
50
-            'tooltip' => __('When using pagination this shortcode can only be used once on a page. (default: disable)', 'site-reviews'),
51
-            'type' => 'listbox',
52
-        ],
53
-        $this->getTypes(__('Which type of review would you like to display?', 'site-reviews')),
54
-        $this->getCategories(__('Limit reviews to this category.', 'site-reviews')),
55
-        [
56
-            'label' => esc_html__('Assigned To', 'site-reviews'),
57
-            'name' => 'assigned_to',
58
-            'tooltip' => __('Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page, or "parent_id" to use the ID of the parent page.', 'site-reviews'),
59
-            'type' => 'textbox',
60
-        ], [
61
-            'label' => esc_html__('Schema', 'site-reviews'),
62
-            'name' => 'schema',
63
-            'options' => [
64
-                'true' => esc_html__('Enable rich snippets', 'site-reviews'),
65
-                'false' => esc_html__('Disable rich snippets', 'site-reviews'),
66
-            ],
67
-            'tooltip' => __('Rich snippets are disabled by default.', 'site-reviews'),
68
-            'type' => 'listbox',
69
-        ], [
70
-            'label' => esc_html__('Classes', 'site-reviews'),
71
-            'name' => 'class',
72
-            'tooltip' => __('Add custom CSS classes to the shortcode.', 'site-reviews'),
73
-            'type' => 'textbox',
74
-        ], [
75
-            'columns' => 2,
76
-            'items' => $this->getHideOptions(),
77
-            'label' => esc_html__('Hide', 'site-reviews'),
78
-            'layout' => 'grid',
79
-            'spacing' => 5,
80
-            'type' => 'container',
81
-        ], [
82
-            'hidden' => true,
83
-            'name' => 'id',
84
-            'type' => 'textbox',
85
-        ], ];
86
-    }
7
+	/**
8
+	 * @return array
9
+	 */
10
+	public function fields()
11
+	{
12
+		return [[
13
+			'html' => sprintf('<p class="strong">%s</p>', esc_html__('All settings are optional.', 'site-reviews')),
14
+			'minWidth' => 320,
15
+			'type' => 'container',
16
+		], [
17
+			'label' => esc_html__('Title', 'site-reviews'),
18
+			'name' => 'title',
19
+			'tooltip' => __('Enter a custom shortcode heading.', 'site-reviews'),
20
+			'type' => 'textbox',
21
+		], [
22
+			'label' => esc_html__('Display', 'site-reviews'),
23
+			'maxLength' => 5,
24
+			'name' => 'display',
25
+			'size' => 3,
26
+			'text' => '10',
27
+			'tooltip' => __('How many reviews would you like to display (default: 10)?', 'site-reviews'),
28
+			'type' => 'textbox',
29
+		], [
30
+			'label' => esc_html__('Rating', 'site-reviews'),
31
+			'name' => 'rating',
32
+			'options' => [
33
+				'5' => esc_html(sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5)),
34
+				'4' => esc_html(sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4)),
35
+				'3' => esc_html(sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3)),
36
+				'2' => esc_html(sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2)),
37
+				'1' => esc_html(sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1)),
38
+				'0' => esc_html(__('Unrated', 'site-reviews')),
39
+			],
40
+			'tooltip' => __('What is the minimum rating to display (default: 1 star)?', 'site-reviews'),
41
+			'type' => 'listbox',
42
+		], [
43
+			'label' => esc_html__('Pagination', 'site-reviews'),
44
+			'name' => 'pagination',
45
+			'options' => [
46
+				'true' => esc_html__('Enable', 'site-reviews'),
47
+				'ajax' => esc_html__('Enable (using ajax)', 'site-reviews'),
48
+				'false' => esc_html__('Disable', 'site-reviews'),
49
+			],
50
+			'tooltip' => __('When using pagination this shortcode can only be used once on a page. (default: disable)', 'site-reviews'),
51
+			'type' => 'listbox',
52
+		],
53
+		$this->getTypes(__('Which type of review would you like to display?', 'site-reviews')),
54
+		$this->getCategories(__('Limit reviews to this category.', 'site-reviews')),
55
+		[
56
+			'label' => esc_html__('Assigned To', 'site-reviews'),
57
+			'name' => 'assigned_to',
58
+			'tooltip' => __('Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page, or "parent_id" to use the ID of the parent page.', 'site-reviews'),
59
+			'type' => 'textbox',
60
+		], [
61
+			'label' => esc_html__('Schema', 'site-reviews'),
62
+			'name' => 'schema',
63
+			'options' => [
64
+				'true' => esc_html__('Enable rich snippets', 'site-reviews'),
65
+				'false' => esc_html__('Disable rich snippets', 'site-reviews'),
66
+			],
67
+			'tooltip' => __('Rich snippets are disabled by default.', 'site-reviews'),
68
+			'type' => 'listbox',
69
+		], [
70
+			'label' => esc_html__('Classes', 'site-reviews'),
71
+			'name' => 'class',
72
+			'tooltip' => __('Add custom CSS classes to the shortcode.', 'site-reviews'),
73
+			'type' => 'textbox',
74
+		], [
75
+			'columns' => 2,
76
+			'items' => $this->getHideOptions(),
77
+			'label' => esc_html__('Hide', 'site-reviews'),
78
+			'layout' => 'grid',
79
+			'spacing' => 5,
80
+			'type' => 'container',
81
+		], [
82
+			'hidden' => true,
83
+			'name' => 'id',
84
+			'type' => 'textbox',
85
+		], ];
86
+	}
87 87
 }
Please login to merge, or discard this patch.
plugin/Controllers/WelcomeController.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -8,97 +8,97 @@
 block discarded – undo
8 8
 
9 9
 class WelcomeController extends Controller
10 10
 {
11
-    /**
12
-     * @return array
13
-     * @filter plugin_action_links_site-reviews/site-reviews.php
14
-     */
15
-    public function filterActionLinks(array $links)
16
-    {
17
-        $links['welcome'] = glsr(Builder::class)->a(__('About', 'site-reviews'), [
18
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'),
19
-        ]);
20
-        return $links;
21
-    }
11
+	/**
12
+	 * @return array
13
+	 * @filter plugin_action_links_site-reviews/site-reviews.php
14
+	 */
15
+	public function filterActionLinks(array $links)
16
+	{
17
+		$links['welcome'] = glsr(Builder::class)->a(__('About', 'site-reviews'), [
18
+			'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'),
19
+		]);
20
+		return $links;
21
+	}
22 22
 
23
-    /**
24
-     * @return string
25
-     * @filter admin_title
26
-     */
27
-    public function filterAdminTitle($title)
28
-    {
29
-        return Application::POST_TYPE.'_page_welcome' == glsr_current_screen()->id
30
-            ? sprintf(__('Welcome to %s &#8212; WordPress', 'site-reviews'), glsr()->name)
31
-            : $title;
32
-    }
23
+	/**
24
+	 * @return string
25
+	 * @filter admin_title
26
+	 */
27
+	public function filterAdminTitle($title)
28
+	{
29
+		return Application::POST_TYPE.'_page_welcome' == glsr_current_screen()->id
30
+			? sprintf(__('Welcome to %s &#8212; WordPress', 'site-reviews'), glsr()->name)
31
+			: $title;
32
+	}
33 33
 
34
-    /**
35
-     * @param string $text
36
-     * @return string
37
-     * @filter admin_footer_text
38
-     */
39
-    public function filterFooterText($text)
40
-    {
41
-        if (Application::POST_TYPE.'_page_welcome' != glsr_current_screen()->id) {
42
-            return $text;
43
-        }
44
-        $url = 'https://wordpress.org/support/view/plugin-reviews/site-reviews?filter=5#new-post';
45
-        return wp_kses_post(sprintf(
46
-            __('Please rate %s on %s and help us spread the word. Thank you so much!', 'site-reviews'),
47
-            '<strong>'.glsr()->name.'</strong> <a href="'.$url.'" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>',
48
-            '<a href="'.$url.'" target="_blank">wordpress.org</a>'
49
-        ));
50
-    }
34
+	/**
35
+	 * @param string $text
36
+	 * @return string
37
+	 * @filter admin_footer_text
38
+	 */
39
+	public function filterFooterText($text)
40
+	{
41
+		if (Application::POST_TYPE.'_page_welcome' != glsr_current_screen()->id) {
42
+			return $text;
43
+		}
44
+		$url = 'https://wordpress.org/support/view/plugin-reviews/site-reviews?filter=5#new-post';
45
+		return wp_kses_post(sprintf(
46
+			__('Please rate %s on %s and help us spread the word. Thank you so much!', 'site-reviews'),
47
+			'<strong>'.glsr()->name.'</strong> <a href="'.$url.'" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>',
48
+			'<a href="'.$url.'" target="_blank">wordpress.org</a>'
49
+		));
50
+	}
51 51
 
52
-    /**
53
-     * @param string $plugin
54
-     * @param bool $isNetworkActivation
55
-     * @return void
56
-     * @action activated_plugin
57
-     */
58
-    public function redirectOnActivation($plugin, $isNetworkActivation)
59
-    {
60
-        if (!$isNetworkActivation
61
-            && 'cli' !== php_sapi_name()
62
-            && $plugin === plugin_basename(glsr()->file)) {
63
-            wp_safe_redirect(admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'));
64
-            exit;
65
-        }
66
-    }
52
+	/**
53
+	 * @param string $plugin
54
+	 * @param bool $isNetworkActivation
55
+	 * @return void
56
+	 * @action activated_plugin
57
+	 */
58
+	public function redirectOnActivation($plugin, $isNetworkActivation)
59
+	{
60
+		if (!$isNetworkActivation
61
+			&& 'cli' !== php_sapi_name()
62
+			&& $plugin === plugin_basename(glsr()->file)) {
63
+			wp_safe_redirect(admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'));
64
+			exit;
65
+		}
66
+	}
67 67
 
68
-    /**
69
-     * @return void
70
-     * @action admin_menu
71
-     */
72
-    public function registerPage()
73
-    {
74
-        add_submenu_page('edit.php?post_type='.Application::POST_TYPE,
75
-            sprintf(__('Welcome to %s', 'site-reviews'), glsr()->name),
76
-            glsr()->name,
77
-            glsr()->getPermission('welcome'),
78
-            'welcome',
79
-            [$this, 'renderPage']
80
-        );
81
-        remove_submenu_page('edit.php?post_type='.Application::POST_TYPE, 'welcome');
82
-    }
68
+	/**
69
+	 * @return void
70
+	 * @action admin_menu
71
+	 */
72
+	public function registerPage()
73
+	{
74
+		add_submenu_page('edit.php?post_type='.Application::POST_TYPE,
75
+			sprintf(__('Welcome to %s', 'site-reviews'), glsr()->name),
76
+			glsr()->name,
77
+			glsr()->getPermission('welcome'),
78
+			'welcome',
79
+			[$this, 'renderPage']
80
+		);
81
+		remove_submenu_page('edit.php?post_type='.Application::POST_TYPE, 'welcome');
82
+	}
83 83
 
84
-    /**
85
-     * @return void
86
-     * @see $this->registerPage()
87
-     * @callback add_submenu_page
88
-     */
89
-    public function renderPage()
90
-    {
91
-        $tabs = apply_filters('site-reviews/addon/welcome/tabs', [
92
-            'getting-started' => __('Getting Started', 'site-reviews'),
93
-            'whatsnew' => __('What\'s New', 'site-reviews'),
94
-            'upgrade-guide' => __('Upgrade Guide', 'site-reviews'),
95
-            'support' => __('Support', 'site-reviews'),
96
-        ]);
97
-        glsr()->render('pages/welcome/index', [
98
-            'data' => ['context' => []],
99
-            'http_referer' => (string) wp_get_referer(),
100
-            'tabs' => $tabs,
101
-            'template' => glsr(Template::class),
102
-        ]);
103
-    }
84
+	/**
85
+	 * @return void
86
+	 * @see $this->registerPage()
87
+	 * @callback add_submenu_page
88
+	 */
89
+	public function renderPage()
90
+	{
91
+		$tabs = apply_filters('site-reviews/addon/welcome/tabs', [
92
+			'getting-started' => __('Getting Started', 'site-reviews'),
93
+			'whatsnew' => __('What\'s New', 'site-reviews'),
94
+			'upgrade-guide' => __('Upgrade Guide', 'site-reviews'),
95
+			'support' => __('Support', 'site-reviews'),
96
+		]);
97
+		glsr()->render('pages/welcome/index', [
98
+			'data' => ['context' => []],
99
+			'http_referer' => (string) wp_get_referer(),
100
+			'tabs' => $tabs,
101
+			'template' => glsr(Template::class),
102
+		]);
103
+	}
104 104
 }
Please login to merge, or discard this patch.
plugin/Controllers/NoticeController.php 1 patch
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -8,124 +8,124 @@
 block discarded – undo
8 8
 
9 9
 class NoticeController extends Controller
10 10
 {
11
-    const USER_META_KEY = '_glsr_notices';
11
+	const USER_META_KEY = '_glsr_notices';
12 12
 
13
-    /**
14
-     * @var array
15
-     */
16
-    protected $dismissValuesMap;
13
+	/**
14
+	 * @var array
15
+	 */
16
+	protected $dismissValuesMap;
17 17
 
18
-    public function __construct()
19
-    {
20
-        $this->dismissValuesMap = [
21
-            'rebusify' => glsr()->version('major'),
22
-            'welcome' => glsr()->version('minor'),
23
-        ];
24
-    }
18
+	public function __construct()
19
+	{
20
+		$this->dismissValuesMap = [
21
+			'rebusify' => glsr()->version('major'),
22
+			'welcome' => glsr()->version('minor'),
23
+		];
24
+	}
25 25
 
26
-    /**
27
-     * @return void
28
-     * @action admin_notices
29
-     */
30
-    public function filterAdminNotices()
31
-    {
32
-        $screen = glsr_current_screen();
33
-        $this->renderWelcomeNotice($screen->post_type);
34
-        $this->renderRebusifyNotice($screen->post_type);
35
-        $this->renderAddonsNotice($screen->id);
36
-    }
26
+	/**
27
+	 * @return void
28
+	 * @action admin_notices
29
+	 */
30
+	public function filterAdminNotices()
31
+	{
32
+		$screen = glsr_current_screen();
33
+		$this->renderWelcomeNotice($screen->post_type);
34
+		$this->renderRebusifyNotice($screen->post_type);
35
+		$this->renderAddonsNotice($screen->id);
36
+	}
37 37
 
38
-    /**
39
-     * @return void
40
-     */
41
-    public function routerDismissNotice(array $request)
42
-    {
43
-        if ($key = Arr::get($request, 'notice')) {
44
-            $this->dismissNotice($key);
45
-        }
46
-    }
38
+	/**
39
+	 * @return void
40
+	 */
41
+	public function routerDismissNotice(array $request)
42
+	{
43
+		if ($key = Arr::get($request, 'notice')) {
44
+			$this->dismissNotice($key);
45
+		}
46
+	}
47 47
 
48
-    /**
49
-     * @param string $key
50
-     * @return void
51
-     */
52
-    protected function dismissNotice($key)
53
-    {
54
-        $this->setUserMeta($key, $this->getVersionFor($key));
55
-    }
48
+	/**
49
+	 * @param string $key
50
+	 * @return void
51
+	 */
52
+	protected function dismissNotice($key)
53
+	{
54
+		$this->setUserMeta($key, $this->getVersionFor($key));
55
+	}
56 56
 
57
-    /**
58
-     * @param string $key
59
-     * @param mixed $fallback
60
-     * @return mixed
61
-     */
62
-    protected function getUserMeta($key, $fallback)
63
-    {
64
-        $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true);
65
-        return Arr::get($meta, $key, $fallback);
66
-    }
57
+	/**
58
+	 * @param string $key
59
+	 * @param mixed $fallback
60
+	 * @return mixed
61
+	 */
62
+	protected function getUserMeta($key, $fallback)
63
+	{
64
+		$meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true);
65
+		return Arr::get($meta, $key, $fallback);
66
+	}
67 67
 
68
-    /**
69
-     * @param string $noticeKey
70
-     * @return string
71
-     */
72
-    protected function getVersionFor($noticeKey)
73
-    {
74
-        return Arr::get($this->dismissValuesMap, $noticeKey, glsr()->version('major'));
75
-    }
68
+	/**
69
+	 * @param string $noticeKey
70
+	 * @return string
71
+	 */
72
+	protected function getVersionFor($noticeKey)
73
+	{
74
+		return Arr::get($this->dismissValuesMap, $noticeKey, glsr()->version('major'));
75
+	}
76 76
 
77
-    /**
78
-     * @param string $screenId
79
-     * @return void
80
-     */
81
-    protected function renderAddonsNotice($screenId)
82
-    {
83
-        if (Application::POST_TYPE.'_page_addons' == $screenId) {
84
-            echo glsr()->render('partials/notices/addons');
85
-        }
86
-    }
77
+	/**
78
+	 * @param string $screenId
79
+	 * @return void
80
+	 */
81
+	protected function renderAddonsNotice($screenId)
82
+	{
83
+		if (Application::POST_TYPE.'_page_addons' == $screenId) {
84
+			echo glsr()->render('partials/notices/addons');
85
+		}
86
+	}
87 87
 
88
-    /**
89
-     * @param string $screenPostType
90
-     * @return void
91
-     */
92
-    protected function renderRebusifyNotice($screenPostType)
93
-    {
94
-        if (Application::POST_TYPE == $screenPostType
95
-            && version_compare($this->getVersionFor('rebusify'), $this->getUserMeta('rebusify', 0), '>')
96
-            && !glsr(OptionManager::class)->getBool('settings.general.rebusify')) {
97
-            echo glsr()->render('partials/notices/rebusify');
98
-        }
99
-    }
88
+	/**
89
+	 * @param string $screenPostType
90
+	 * @return void
91
+	 */
92
+	protected function renderRebusifyNotice($screenPostType)
93
+	{
94
+		if (Application::POST_TYPE == $screenPostType
95
+			&& version_compare($this->getVersionFor('rebusify'), $this->getUserMeta('rebusify', 0), '>')
96
+			&& !glsr(OptionManager::class)->getBool('settings.general.rebusify')) {
97
+			echo glsr()->render('partials/notices/rebusify');
98
+		}
99
+	}
100 100
 
101
-    /**
102
-     * @param string $screenPostType
103
-     * @return void
104
-     */
105
-    protected function renderWelcomeNotice($screenPostType)
106
-    {
107
-        if (Application::POST_TYPE == $screenPostType
108
-            && version_compare($this->getVersionFor('welcome'), $this->getUserMeta('welcome', 0), '>')) {
109
-            $welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from')
110
-                ? __('Thanks for installing Site Reviews %s, we hope you love it!', 'site-reviews')
111
-                : __('Thanks for updating to Site Reviews %s, we hope you love the changes!', 'site-reviews');
112
-            echo glsr()->render('partials/notices/welcome', [
113
-                'text' => sprintf($welcomeText, glsr()->version),
114
-            ]);
115
-        }
116
-    }
101
+	/**
102
+	 * @param string $screenPostType
103
+	 * @return void
104
+	 */
105
+	protected function renderWelcomeNotice($screenPostType)
106
+	{
107
+		if (Application::POST_TYPE == $screenPostType
108
+			&& version_compare($this->getVersionFor('welcome'), $this->getUserMeta('welcome', 0), '>')) {
109
+			$welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from')
110
+				? __('Thanks for installing Site Reviews %s, we hope you love it!', 'site-reviews')
111
+				: __('Thanks for updating to Site Reviews %s, we hope you love the changes!', 'site-reviews');
112
+			echo glsr()->render('partials/notices/welcome', [
113
+				'text' => sprintf($welcomeText, glsr()->version),
114
+			]);
115
+		}
116
+	}
117 117
 
118
-    /**
119
-     * @param string $key
120
-     * @param mixed $fallback
121
-     * @return mixed
122
-     */
123
-    protected function setUserMeta($key, $value)
124
-    {
125
-        $userId = get_current_user_id();
126
-        $meta = (array) get_user_meta($userId, static::USER_META_KEY, true);
127
-        $meta = array_filter(wp_parse_args($meta, []));
128
-        $meta[$key] = $value;
129
-        update_user_meta($userId, static::USER_META_KEY, $meta);
130
-    }
118
+	/**
119
+	 * @param string $key
120
+	 * @param mixed $fallback
121
+	 * @return mixed
122
+	 */
123
+	protected function setUserMeta($key, $value)
124
+	{
125
+		$userId = get_current_user_id();
126
+		$meta = (array) get_user_meta($userId, static::USER_META_KEY, true);
127
+		$meta = array_filter(wp_parse_args($meta, []));
128
+		$meta[$key] = $value;
129
+		update_user_meta($userId, static::USER_META_KEY, $meta);
130
+	}
131 131
 }
Please login to merge, or discard this patch.
plugin/Controllers/MenuController.php 1 patch
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -14,189 +14,189 @@
 block discarded – undo
14 14
 
15 15
 class MenuController extends Controller
16 16
 {
17
-    /**
18
-     * @return void
19
-     * @action admin_menu
20
-     */
21
-    public function registerMenuCount()
22
-    {
23
-        global $menu, $typenow;
24
-        foreach ($menu as $key => $value) {
25
-            if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) {
26
-                continue;
27
-            }
28
-            $postCount = wp_count_posts(Application::POST_TYPE);
29
-            $pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [
30
-                'class' => 'unapproved-count',
31
-            ]);
32
-            $awaitingModeration = glsr(Builder::class)->span($pendingCount, [
33
-                'class' => 'awaiting-mod count-'.$postCount->pending,
34
-            ]);
35
-            $menu[$key][0].= ' '.$awaitingModeration;
36
-            if (Application::POST_TYPE === $typenow) {
37
-                $menu[$key][4].= ' current';
38
-            }
39
-            break;
40
-        }
41
-    }
17
+	/**
18
+	 * @return void
19
+	 * @action admin_menu
20
+	 */
21
+	public function registerMenuCount()
22
+	{
23
+		global $menu, $typenow;
24
+		foreach ($menu as $key => $value) {
25
+			if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) {
26
+				continue;
27
+			}
28
+			$postCount = wp_count_posts(Application::POST_TYPE);
29
+			$pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [
30
+				'class' => 'unapproved-count',
31
+			]);
32
+			$awaitingModeration = glsr(Builder::class)->span($pendingCount, [
33
+				'class' => 'awaiting-mod count-'.$postCount->pending,
34
+			]);
35
+			$menu[$key][0].= ' '.$awaitingModeration;
36
+			if (Application::POST_TYPE === $typenow) {
37
+				$menu[$key][4].= ' current';
38
+			}
39
+			break;
40
+		}
41
+	}
42 42
 
43
-    /**
44
-     * @return void
45
-     * @action admin_menu
46
-     */
47
-    public function registerSubMenus()
48
-    {
49
-        $pages = $this->parseWithFilter('submenu/pages', [
50
-            'settings' => __('Settings', 'site-reviews'),
51
-            'tools' => __('Tools', 'site-reviews'),
52
-            'addons' => __('Add-ons', 'site-reviews'),
53
-            'documentation' => __('Help', 'site-reviews'),
54
-        ]);
55
-        foreach ($pages as $slug => $title) {
56
-            $method = Helper::buildMethodName('render-'.$slug.'-menu');
57
-            $callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug);
58
-            if (!is_callable($callback)) {
59
-                continue;
60
-            }
61
-            add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback);
62
-        }
63
-    }
43
+	/**
44
+	 * @return void
45
+	 * @action admin_menu
46
+	 */
47
+	public function registerSubMenus()
48
+	{
49
+		$pages = $this->parseWithFilter('submenu/pages', [
50
+			'settings' => __('Settings', 'site-reviews'),
51
+			'tools' => __('Tools', 'site-reviews'),
52
+			'addons' => __('Add-ons', 'site-reviews'),
53
+			'documentation' => __('Help', 'site-reviews'),
54
+		]);
55
+		foreach ($pages as $slug => $title) {
56
+			$method = Helper::buildMethodName('render-'.$slug.'-menu');
57
+			$callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug);
58
+			if (!is_callable($callback)) {
59
+				continue;
60
+			}
61
+			add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback);
62
+		}
63
+	}
64 64
 
65
-    /**
66
-     * @return void
67
-     * @see $this->registerSubMenus()
68
-     * @callback add_submenu_page
69
-     */
70
-    public function renderAddonsMenu()
71
-    {
72
-        $this->renderPage('addons', [
73
-            'template' => glsr(Template::class),
74
-        ]);
75
-    }
65
+	/**
66
+	 * @return void
67
+	 * @see $this->registerSubMenus()
68
+	 * @callback add_submenu_page
69
+	 */
70
+	public function renderAddonsMenu()
71
+	{
72
+		$this->renderPage('addons', [
73
+			'template' => glsr(Template::class),
74
+		]);
75
+	}
76 76
 
77
-    /**
78
-     * @return void
79
-     * @see $this->registerSubMenus()
80
-     * @callback add_submenu_page
81
-     */
82
-    public function renderDocumentationMenu()
83
-    {
84
-        $tabs = $this->parseWithFilter('documentation/tabs', [
85
-            'support' => __('Support', 'site-reviews'),
86
-            'faq' => __('FAQ', 'site-reviews'),
87
-            'shortcodes' => __('Shortcodes', 'site-reviews'),
88
-            'hooks' => __('Hooks', 'site-reviews'),
89
-            'functions' => __('Functions', 'site-reviews'),
90
-            'addons' => __('Addons', 'site-reviews'),
91
-        ]);
92
-        $addons = apply_filters('site-reviews/addon/documentation', []);
93
-        ksort($addons);
94
-        if (empty($addons)) {
95
-            unset($tabs['addons']);
96
-        }
97
-        $this->renderPage('documentation', [
98
-            'addons' => $addons,
99
-            'tabs' => $tabs,
100
-        ]);
101
-    }
77
+	/**
78
+	 * @return void
79
+	 * @see $this->registerSubMenus()
80
+	 * @callback add_submenu_page
81
+	 */
82
+	public function renderDocumentationMenu()
83
+	{
84
+		$tabs = $this->parseWithFilter('documentation/tabs', [
85
+			'support' => __('Support', 'site-reviews'),
86
+			'faq' => __('FAQ', 'site-reviews'),
87
+			'shortcodes' => __('Shortcodes', 'site-reviews'),
88
+			'hooks' => __('Hooks', 'site-reviews'),
89
+			'functions' => __('Functions', 'site-reviews'),
90
+			'addons' => __('Addons', 'site-reviews'),
91
+		]);
92
+		$addons = apply_filters('site-reviews/addon/documentation', []);
93
+		ksort($addons);
94
+		if (empty($addons)) {
95
+			unset($tabs['addons']);
96
+		}
97
+		$this->renderPage('documentation', [
98
+			'addons' => $addons,
99
+			'tabs' => $tabs,
100
+		]);
101
+	}
102 102
 
103
-    /**
104
-     * @return void
105
-     * @see $this->registerSubMenus()
106
-     * @callback add_submenu_page
107
-     */
108
-    public function renderSettingsMenu()
109
-    {
110
-        $tabs = $this->parseWithFilter('settings/tabs', [
111
-            'general' => __('General', 'site-reviews'),
112
-            'reviews' => __('Reviews', 'site-reviews'),
113
-            'submissions' => __('Submissions', 'site-reviews'),
114
-            'schema' => __('Schema', 'site-reviews'),
115
-            'translations' => __('Translations', 'site-reviews'),
116
-            'addons' => __('Addons', 'site-reviews'),
117
-            'licenses' => __('Licenses', 'site-reviews'),
118
-        ]);
119
-        if (empty(Arr::get(glsr()->defaults, 'settings.addons'))) {
120
-            unset($tabs['addons']);
121
-        }
122
-        if (empty(Arr::get(glsr()->defaults, 'settings.licenses'))) {
123
-            unset($tabs['licenses']);
124
-        }
125
-        $this->renderPage('settings', [
126
-            'settings' => glsr(Settings::class),
127
-            'tabs' => $tabs,
128
-        ]);
129
-    }
103
+	/**
104
+	 * @return void
105
+	 * @see $this->registerSubMenus()
106
+	 * @callback add_submenu_page
107
+	 */
108
+	public function renderSettingsMenu()
109
+	{
110
+		$tabs = $this->parseWithFilter('settings/tabs', [
111
+			'general' => __('General', 'site-reviews'),
112
+			'reviews' => __('Reviews', 'site-reviews'),
113
+			'submissions' => __('Submissions', 'site-reviews'),
114
+			'schema' => __('Schema', 'site-reviews'),
115
+			'translations' => __('Translations', 'site-reviews'),
116
+			'addons' => __('Addons', 'site-reviews'),
117
+			'licenses' => __('Licenses', 'site-reviews'),
118
+		]);
119
+		if (empty(Arr::get(glsr()->defaults, 'settings.addons'))) {
120
+			unset($tabs['addons']);
121
+		}
122
+		if (empty(Arr::get(glsr()->defaults, 'settings.licenses'))) {
123
+			unset($tabs['licenses']);
124
+		}
125
+		$this->renderPage('settings', [
126
+			'settings' => glsr(Settings::class),
127
+			'tabs' => $tabs,
128
+		]);
129
+	}
130 130
 
131
-    /**
132
-     * @return void
133
-     * @see $this->registerSubMenus()
134
-     * @callback add_submenu_page
135
-     */
136
-    public function renderToolsMenu()
137
-    {
138
-        $tabs = $this->parseWithFilter('tools/tabs', [
139
-            'general' => __('General', 'site-reviews'),
140
-            'sync' => __('Sync Reviews', 'site-reviews'),
141
-            'console' => __('Console', 'site-reviews'),
142
-            'system-info' => __('System Info', 'site-reviews'),
143
-        ]);
144
-        if (!apply_filters('site-reviews/addon/sync/enable', false)) {
145
-            unset($tabs['sync']);
146
-        }
147
-        $this->renderPage('tools', [
148
-            'data' => [
149
-                'context' => [
150
-                    'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE),
151
-                    'console' => strval(glsr(Console::class)),
152
-                    'id' => Application::ID,
153
-                    'system' => strval(glsr(System::class)),
154
-                ],
155
-                'services' => apply_filters('site-reviews/addon/sync/services', []),
156
-            ],
157
-            'tabs' => $tabs,
158
-            'template' => glsr(Template::class),
159
-        ]);
160
-    }
131
+	/**
132
+	 * @return void
133
+	 * @see $this->registerSubMenus()
134
+	 * @callback add_submenu_page
135
+	 */
136
+	public function renderToolsMenu()
137
+	{
138
+		$tabs = $this->parseWithFilter('tools/tabs', [
139
+			'general' => __('General', 'site-reviews'),
140
+			'sync' => __('Sync Reviews', 'site-reviews'),
141
+			'console' => __('Console', 'site-reviews'),
142
+			'system-info' => __('System Info', 'site-reviews'),
143
+		]);
144
+		if (!apply_filters('site-reviews/addon/sync/enable', false)) {
145
+			unset($tabs['sync']);
146
+		}
147
+		$this->renderPage('tools', [
148
+			'data' => [
149
+				'context' => [
150
+					'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE),
151
+					'console' => strval(glsr(Console::class)),
152
+					'id' => Application::ID,
153
+					'system' => strval(glsr(System::class)),
154
+				],
155
+				'services' => apply_filters('site-reviews/addon/sync/services', []),
156
+			],
157
+			'tabs' => $tabs,
158
+			'template' => glsr(Template::class),
159
+		]);
160
+	}
161 161
 
162
-    /**
163
-     * @return void
164
-     * @action admin_init
165
-     */
166
-    public function setCustomPermissions()
167
-    {
168
-        foreach (wp_roles()->roles as $role => $value) {
169
-            wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE);
170
-        }
171
-    }
162
+	/**
163
+	 * @return void
164
+	 * @action admin_init
165
+	 */
166
+	public function setCustomPermissions()
167
+	{
168
+		foreach (wp_roles()->roles as $role => $value) {
169
+			wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE);
170
+		}
171
+	}
172 172
 
173
-    /**
174
-     * @return string
175
-     */
176
-    protected function getNotices()
177
-    {
178
-        return glsr(Builder::class)->div(glsr(Notice::class)->get(), [
179
-            'id' => 'glsr-notices',
180
-        ]);
181
-    }
173
+	/**
174
+	 * @return string
175
+	 */
176
+	protected function getNotices()
177
+	{
178
+		return glsr(Builder::class)->div(glsr(Notice::class)->get(), [
179
+			'id' => 'glsr-notices',
180
+		]);
181
+	}
182 182
 
183
-    /**
184
-     * @param string $hookSuffix
185
-     * @return array
186
-     */
187
-    protected function parseWithFilter($hookSuffix, array $args = [])
188
-    {
189
-        return apply_filters('site-reviews/addon/'.$hookSuffix, $args);
190
-    }
183
+	/**
184
+	 * @param string $hookSuffix
185
+	 * @return array
186
+	 */
187
+	protected function parseWithFilter($hookSuffix, array $args = [])
188
+	{
189
+		return apply_filters('site-reviews/addon/'.$hookSuffix, $args);
190
+	}
191 191
 
192
-    /**
193
-     * @param string $page
194
-     * @return void
195
-     */
196
-    protected function renderPage($page, array $data = [])
197
-    {
198
-        $data['http_referer'] = (string) wp_get_referer();
199
-        $data['notices'] = $this->getNotices();
200
-        glsr()->render('pages/'.$page.'/index', $data);
201
-    }
192
+	/**
193
+	 * @param string $page
194
+	 * @return void
195
+	 */
196
+	protected function renderPage($page, array $data = [])
197
+	{
198
+		$data['http_referer'] = (string) wp_get_referer();
199
+		$data['notices'] = $this->getNotices();
200
+		glsr()->render('pages/'.$page.'/index', $data);
201
+	}
202 202
 }
Please login to merge, or discard this patch.
plugin/Defaults/SiteReviewsDefaults.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -6,41 +6,41 @@
 block discarded – undo
6 6
 
7 7
 class SiteReviewsDefaults extends Defaults
8 8
 {
9
-    /**
10
-     * @var array
11
-     */
12
-    protected $guarded = [
13
-        'fallback',
14
-        'title',
15
-    ];
9
+	/**
10
+	 * @var array
11
+	 */
12
+	protected $guarded = [
13
+		'fallback',
14
+		'title',
15
+	];
16 16
 
17
-    /**
18
-     * @var array
19
-     */
20
-    protected $mapped = [
21
-        'count' => 'display', // @deprecated since v4.1.0
22
-        'per_page' => 'display',
23
-    ];
17
+	/**
18
+	 * @var array
19
+	 */
20
+	protected $mapped = [
21
+		'count' => 'display', // @deprecated since v4.1.0
22
+		'per_page' => 'display',
23
+	];
24 24
 
25
-    /**
26
-     * @return array
27
-     */
28
-    protected function defaults()
29
-    {
30
-        return [
31
-            'assigned_to' => '',
32
-            'category' => '',
33
-            'class' => '',
34
-            'display' => 5,
35
-            'fallback' => '',
36
-            'hide' => [],
37
-            'id' => '',
38
-            'offset' => '',
39
-            'pagination' => false,
40
-            'rating' => 0,
41
-            'schema' => false,
42
-            'title' => '',
43
-            'type' => 'local',
44
-        ];
45
-    }
25
+	/**
26
+	 * @return array
27
+	 */
28
+	protected function defaults()
29
+	{
30
+		return [
31
+			'assigned_to' => '',
32
+			'category' => '',
33
+			'class' => '',
34
+			'display' => 5,
35
+			'fallback' => '',
36
+			'hide' => [],
37
+			'id' => '',
38
+			'offset' => '',
39
+			'pagination' => false,
40
+			'rating' => 0,
41
+			'schema' => false,
42
+			'title' => '',
43
+			'type' => 'local',
44
+		];
45
+	}
46 46
 }
Please login to merge, or discard this patch.
plugin/Defaults/ReviewsDefaults.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -6,31 +6,31 @@
 block discarded – undo
6 6
 
7 7
 class ReviewsDefaults extends Defaults
8 8
 {
9
-    /**
10
-     * @var array
11
-     */
12
-    protected $mapped = [
13
-        'count' => 'per_page', // @deprecated since v4.1.0
14
-        'display' => 'per_page',
15
-    ];
9
+	/**
10
+	 * @var array
11
+	 */
12
+	protected $mapped = [
13
+		'count' => 'per_page', // @deprecated since v4.1.0
14
+		'display' => 'per_page',
15
+	];
16 16
 
17
-    /**
18
-     * @return array
19
-     */
20
-    protected function defaults()
21
-    {
22
-        return [
23
-            'assigned_to' => '',
24
-            'category' => '',
25
-            'offset' => '',
26
-            'order' => 'DESC',
27
-            'orderby' => 'date',
28
-            'pagination' => false,
29
-            'per_page' => 10,
30
-            'post__in' => [],
31
-            'post__not_in' => [],
32
-            'rating' => '',
33
-            'type' => '',
34
-        ];
35
-    }
17
+	/**
18
+	 * @return array
19
+	 */
20
+	protected function defaults()
21
+	{
22
+		return [
23
+			'assigned_to' => '',
24
+			'category' => '',
25
+			'offset' => '',
26
+			'order' => 'DESC',
27
+			'orderby' => 'date',
28
+			'pagination' => false,
29
+			'per_page' => 10,
30
+			'post__in' => [],
31
+			'post__not_in' => [],
32
+			'rating' => '',
33
+			'type' => '',
34
+		];
35
+	}
36 36
 }
Please login to merge, or discard this patch.
plugin/Defaults/DefaultsAbstract.php 1 patch
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -8,137 +8,137 @@
 block discarded – undo
8 8
 
9 9
 abstract class DefaultsAbstract
10 10
 {
11
-    /**
12
-     * @var array
13
-     */
14
-    protected $callable = [
15
-        'defaults', 'filter', 'merge', 'restrict', 'unguarded',
16
-    ];
17
-
18
-    /**
19
-     * @var array
20
-     */
21
-    protected $guarded = [];
22
-
23
-    /**
24
-     * @var array
25
-     */
26
-    protected $mapped = [];
27
-
28
-    /**
29
-     * @param string $name
30
-     * @return void|array
31
-     */
32
-    public function __call($name, array $args = [])
33
-    {
34
-        if (!method_exists($this, $name) || !in_array($name, $this->callable)) {
35
-            return;
36
-        }
37
-        $args[0] = $this->mapKeys(Arr::get($args, 0, []));
38
-        $defaults = call_user_func_array([$this, $name], $args);
39
-        $hookName = (new ReflectionClass($this))->getShortName();
40
-        $hookName = str_replace('Defaults', '', $hookName);
41
-        $hookName = Str::dashCase($hookName);
42
-        return apply_filters('site-reviews/defaults/'.$hookName, $defaults, $name);
43
-    }
44
-
45
-    /**
46
-     * @return array
47
-     */
48
-    abstract protected function defaults();
49
-
50
-    /**
51
-     * @return array
52
-     */
53
-    protected function filter(array $values = [])
54
-    {
55
-        return $this->normalize($this->merge(array_filter($values)), $values);
56
-    }
57
-
58
-    /**
59
-     * @return string
60
-     */
61
-    protected function filteredJson(array $values = [])
62
-    {
63
-        $defaults = $this->flattenArray(
64
-            array_diff_key($this->defaults(), array_flip($this->guarded))
65
-        );
66
-        $values = $this->flattenArray(
67
-            shortcode_atts($defaults, $values)
68
-        );
69
-        $filtered = array_filter(array_diff_assoc($values, $defaults), function ($value) {
70
-            return !$this->isEmpty($value);
71
-        });
72
-        return json_encode($filtered, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
73
-    }
74
-
75
-    /**
76
-     * @return array
77
-     */
78
-    protected function flattenArray(array $values)
79
-    {
80
-        array_walk($values, function (&$value) {
81
-            if (!is_array($value)) {
82
-                return;
83
-            }
84
-            $value = implode(',', $value);
85
-        });
86
-        return $values;
87
-    }
88
-
89
-    /**
90
-     * @param mixed $var
91
-     * @return bool
92
-     */
93
-    protected function isEmpty($var)
94
-    {
95
-        return !is_numeric($var) && !is_bool($var) && empty($var);
96
-    }
97
-
98
-    /**
99
-     * @return array
100
-     */
101
-    protected function mapKeys(array $args)
102
-    {
103
-        foreach ($this->mapped as $old => $new) {
104
-            if (array_key_exists($old, $args)) {
105
-                $args[$new] = $args[$old];
106
-                unset($args[$old]);
107
-            }
108
-        }
109
-        return $args;
110
-    }
111
-
112
-    /**
113
-     * @return array
114
-     */
115
-    protected function merge(array $values = [])
116
-    {
117
-        return $this->normalize(wp_parse_args($values, $this->defaults()), $values);
118
-    }
119
-
120
-    /**
121
-     * @return array
122
-     */
123
-    protected function normalize(array $values, array $originalValues)
124
-    {
125
-        $values['json'] = $this->filteredJson($originalValues);
126
-        return $values;
127
-    }
128
-
129
-    /**
130
-     * @return array
131
-     */
132
-    protected function restrict(array $values = [])
133
-    {
134
-        return $this->normalize(shortcode_atts($this->defaults(), $values), $values);
135
-    }
136
-
137
-    /**
138
-     * @return array
139
-     */
140
-    protected function unguarded()
141
-    {
142
-        return array_diff_key($this->defaults(), array_flip($this->guarded));
143
-    }
11
+	/**
12
+	 * @var array
13
+	 */
14
+	protected $callable = [
15
+		'defaults', 'filter', 'merge', 'restrict', 'unguarded',
16
+	];
17
+
18
+	/**
19
+	 * @var array
20
+	 */
21
+	protected $guarded = [];
22
+
23
+	/**
24
+	 * @var array
25
+	 */
26
+	protected $mapped = [];
27
+
28
+	/**
29
+	 * @param string $name
30
+	 * @return void|array
31
+	 */
32
+	public function __call($name, array $args = [])
33
+	{
34
+		if (!method_exists($this, $name) || !in_array($name, $this->callable)) {
35
+			return;
36
+		}
37
+		$args[0] = $this->mapKeys(Arr::get($args, 0, []));
38
+		$defaults = call_user_func_array([$this, $name], $args);
39
+		$hookName = (new ReflectionClass($this))->getShortName();
40
+		$hookName = str_replace('Defaults', '', $hookName);
41
+		$hookName = Str::dashCase($hookName);
42
+		return apply_filters('site-reviews/defaults/'.$hookName, $defaults, $name);
43
+	}
44
+
45
+	/**
46
+	 * @return array
47
+	 */
48
+	abstract protected function defaults();
49
+
50
+	/**
51
+	 * @return array
52
+	 */
53
+	protected function filter(array $values = [])
54
+	{
55
+		return $this->normalize($this->merge(array_filter($values)), $values);
56
+	}
57
+
58
+	/**
59
+	 * @return string
60
+	 */
61
+	protected function filteredJson(array $values = [])
62
+	{
63
+		$defaults = $this->flattenArray(
64
+			array_diff_key($this->defaults(), array_flip($this->guarded))
65
+		);
66
+		$values = $this->flattenArray(
67
+			shortcode_atts($defaults, $values)
68
+		);
69
+		$filtered = array_filter(array_diff_assoc($values, $defaults), function ($value) {
70
+			return !$this->isEmpty($value);
71
+		});
72
+		return json_encode($filtered, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
73
+	}
74
+
75
+	/**
76
+	 * @return array
77
+	 */
78
+	protected function flattenArray(array $values)
79
+	{
80
+		array_walk($values, function (&$value) {
81
+			if (!is_array($value)) {
82
+				return;
83
+			}
84
+			$value = implode(',', $value);
85
+		});
86
+		return $values;
87
+	}
88
+
89
+	/**
90
+	 * @param mixed $var
91
+	 * @return bool
92
+	 */
93
+	protected function isEmpty($var)
94
+	{
95
+		return !is_numeric($var) && !is_bool($var) && empty($var);
96
+	}
97
+
98
+	/**
99
+	 * @return array
100
+	 */
101
+	protected function mapKeys(array $args)
102
+	{
103
+		foreach ($this->mapped as $old => $new) {
104
+			if (array_key_exists($old, $args)) {
105
+				$args[$new] = $args[$old];
106
+				unset($args[$old]);
107
+			}
108
+		}
109
+		return $args;
110
+	}
111
+
112
+	/**
113
+	 * @return array
114
+	 */
115
+	protected function merge(array $values = [])
116
+	{
117
+		return $this->normalize(wp_parse_args($values, $this->defaults()), $values);
118
+	}
119
+
120
+	/**
121
+	 * @return array
122
+	 */
123
+	protected function normalize(array $values, array $originalValues)
124
+	{
125
+		$values['json'] = $this->filteredJson($originalValues);
126
+		return $values;
127
+	}
128
+
129
+	/**
130
+	 * @return array
131
+	 */
132
+	protected function restrict(array $values = [])
133
+	{
134
+		return $this->normalize(shortcode_atts($this->defaults(), $values), $values);
135
+	}
136
+
137
+	/**
138
+	 * @return array
139
+	 */
140
+	protected function unguarded()
141
+	{
142
+		return array_diff_key($this->defaults(), array_flip($this->guarded));
143
+	}
144 144
 }
Please login to merge, or discard this patch.