Passed
Push — master ( 7ac705...f4e23e )
by Paul
05:13
created
plugin/Reviews.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -9,65 +9,65 @@
 block discarded – undo
9 9
 
10 10
 class Reviews extends ArrayObject
11 11
 {
12
-    /**
13
-     * @var array
14
-     */
15
-    public $args;
12
+	/**
13
+	 * @var array
14
+	 */
15
+	public $args;
16 16
 
17
-    /**
18
-     * @var int
19
-     */
20
-    public $max_num_pages;
17
+	/**
18
+	 * @var int
19
+	 */
20
+	public $max_num_pages;
21 21
 
22
-    /**
23
-     * @var array
24
-     */
25
-    public $reviews;
22
+	/**
23
+	 * @var array
24
+	 */
25
+	public $reviews;
26 26
 
27
-    public function __construct(array $reviews, $maxPageCount, array $args)
28
-    {
29
-        $this->args = $args;
30
-        $this->max_num_pages = $maxPageCount;
31
-        $this->reviews = $reviews;
32
-        parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
33
-    }
27
+	public function __construct(array $reviews, $maxPageCount, array $args)
28
+	{
29
+		$this->args = $args;
30
+		$this->max_num_pages = $maxPageCount;
31
+		$this->reviews = $reviews;
32
+		parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
33
+	}
34 34
 
35
-    /**
36
-     * @return string
37
-     */
38
-    public function __toString()
39
-    {
40
-        return (string) $this->build();
41
-    }
35
+	/**
36
+	 * @return string
37
+	 */
38
+	public function __toString()
39
+	{
40
+		return (string) $this->build();
41
+	}
42 42
 
43
-    /**
44
-     * @return ReviewsHtml
45
-     */
46
-    public function build()
47
-    {
48
-        $args = glsr(SiteReviewsDefaults::class)->merge($this->args);
49
-        return glsr(SiteReviewsPartial::class)->build($args, $this);
50
-    }
43
+	/**
44
+	 * @return ReviewsHtml
45
+	 */
46
+	public function build()
47
+	{
48
+		$args = glsr(SiteReviewsDefaults::class)->merge($this->args);
49
+		return glsr(SiteReviewsPartial::class)->build($args, $this);
50
+	}
51 51
 
52
-    /**
53
-     * @param mixed $key
54
-     * @return mixed
55
-     */
56
-    public function offsetGet($key)
57
-    {
58
-        if (property_exists($this, $key)) {
59
-            return $this->$key;
60
-        }
61
-        return array_key_exists($key, $this->reviews)
62
-            ? $this->reviews[$key]
63
-            : null;
64
-    }
52
+	/**
53
+	 * @param mixed $key
54
+	 * @return mixed
55
+	 */
56
+	public function offsetGet($key)
57
+	{
58
+		if (property_exists($this, $key)) {
59
+			return $this->$key;
60
+		}
61
+		return array_key_exists($key, $this->reviews)
62
+			? $this->reviews[$key]
63
+			: null;
64
+	}
65 65
 
66
-    /**
67
-     * @return void
68
-     */
69
-    public function render()
70
-    {
71
-        echo $this->build();
72
-    }
66
+	/**
67
+	 * @return void
68
+	 */
69
+	public function render()
70
+	{
71
+		echo $this->build();
72
+	}
73 73
 }
Please login to merge, or discard this patch.
plugin/Controllers/WelcomeController.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -8,99 +8,99 @@
 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 — 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 — 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' => [
99
-                'context' => [],
100
-            ],
101
-            'http_referer' => (string) wp_get_referer(),
102
-            'tabs' => $tabs,
103
-            'template' => glsr(Template::class),
104
-        ]);
105
-    }
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' => [
99
+				'context' => [],
100
+			],
101
+			'http_referer' => (string) wp_get_referer(),
102
+			'tabs' => $tabs,
103
+			'template' => glsr(Template::class),
104
+		]);
105
+	}
106 106
 }
Please login to merge, or discard this patch.
plugin/Controllers/EditorController.php 1 patch
Indentation   +403 added lines, -403 removed lines patch added patch discarded remove patch
@@ -19,434 +19,434 @@
 block discarded – undo
19 19
 
20 20
 class EditorController extends Controller
21 21
 {
22
-    /**
23
-     * @return void
24
-     * @action admin_enqueue_scripts
25
-     */
26
-    public function customizePostStatusLabels()
27
-    {
28
-        glsr(Labels::class)->customizePostStatusLabels();
29
-    }
22
+	/**
23
+	 * @return void
24
+	 * @action admin_enqueue_scripts
25
+	 */
26
+	public function customizePostStatusLabels()
27
+	{
28
+		glsr(Labels::class)->customizePostStatusLabels();
29
+	}
30 30
 
31
-    /**
32
-     * @param array $settings
33
-     * @return array
34
-     * @filter wp_editor_settings
35
-     */
36
-    public function filterEditorSettings($settings)
37
-    {
38
-        return glsr(Customization::class)->filterEditorSettings(
39
-            glsr(Helper::class)->consolidateArray($settings)
40
-        );
41
-    }
31
+	/**
32
+	 * @param array $settings
33
+	 * @return array
34
+	 * @filter wp_editor_settings
35
+	 */
36
+	public function filterEditorSettings($settings)
37
+	{
38
+		return glsr(Customization::class)->filterEditorSettings(
39
+			glsr(Helper::class)->consolidateArray($settings)
40
+		);
41
+	}
42 42
 
43
-    /**
44
-     * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script.
45
-     * @param string $html
46
-     * @return string
47
-     * @filter the_editor
48
-     */
49
-    public function filterEditorTextarea($html)
50
-    {
51
-        return glsr(Customization::class)->filterEditorTextarea($html);
52
-    }
43
+	/**
44
+	 * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script.
45
+	 * @param string $html
46
+	 * @return string
47
+	 * @filter the_editor
48
+	 */
49
+	public function filterEditorTextarea($html)
50
+	{
51
+		return glsr(Customization::class)->filterEditorTextarea($html);
52
+	}
53 53
 
54
-    /**
55
-     * @param bool $protected
56
-     * @param string $metaKey
57
-     * @param string $metaType
58
-     * @return bool
59
-     * @filter is_protected_meta
60
-     */
61
-    public function filterIsProtectedMeta($protected, $metaKey, $metaType)
62
-    {
63
-        if ('post' == $metaType && Application::POST_TYPE == get_post_type()) {
64
-            $values = glsr(CreateReviewDefaults::class)->unguarded();
65
-            $values = glsr(Helper::class)->prefixArrayKeys($values);
66
-            if (array_key_exists($metaKey, $values)) {
67
-                $protected = false;
68
-            }
69
-        }
70
-        return $protected;
71
-    }
54
+	/**
55
+	 * @param bool $protected
56
+	 * @param string $metaKey
57
+	 * @param string $metaType
58
+	 * @return bool
59
+	 * @filter is_protected_meta
60
+	 */
61
+	public function filterIsProtectedMeta($protected, $metaKey, $metaType)
62
+	{
63
+		if ('post' == $metaType && Application::POST_TYPE == get_post_type()) {
64
+			$values = glsr(CreateReviewDefaults::class)->unguarded();
65
+			$values = glsr(Helper::class)->prefixArrayKeys($values);
66
+			if (array_key_exists($metaKey, $values)) {
67
+				$protected = false;
68
+			}
69
+		}
70
+		return $protected;
71
+	}
72 72
 
73
-    /**
74
-     * @param string $translation
75
-     * @param string $test
76
-     * @param string $domain
77
-     * @return string
78
-     * @filter gettext
79
-     */
80
-    public function filterPostStatusLabels($translation, $text, $domain)
81
-    {
82
-        return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
83
-    }
73
+	/**
74
+	 * @param string $translation
75
+	 * @param string $test
76
+	 * @param string $domain
77
+	 * @return string
78
+	 * @filter gettext
79
+	 */
80
+	public function filterPostStatusLabels($translation, $text, $domain)
81
+	{
82
+		return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
83
+	}
84 84
 
85
-    /**
86
-     * @param string $translation
87
-     * @param string $test
88
-     * @param string $domain
89
-     * @return string
90
-     * @filter gettext_with_context
91
-     */
92
-    public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain)
93
-    {
94
-        return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
95
-    }
85
+	/**
86
+	 * @param string $translation
87
+	 * @param string $test
88
+	 * @param string $domain
89
+	 * @return string
90
+	 * @filter gettext_with_context
91
+	 */
92
+	public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain)
93
+	{
94
+		return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
95
+	}
96 96
 
97
-    /**
98
-     * @param array $messages
99
-     * @return array
100
-     * @filter post_updated_messages
101
-     */
102
-    public function filterUpdateMessages($messages)
103
-    {
104
-        return glsr(Labels::class)->filterUpdateMessages(
105
-            glsr(Helper::class)->consolidateArray($messages)
106
-        );
107
-    }
97
+	/**
98
+	 * @param array $messages
99
+	 * @return array
100
+	 * @filter post_updated_messages
101
+	 */
102
+	public function filterUpdateMessages($messages)
103
+	{
104
+		return glsr(Labels::class)->filterUpdateMessages(
105
+			glsr(Helper::class)->consolidateArray($messages)
106
+		);
107
+	}
108 108
 
109
-    /**
110
-     * @return void
111
-     * @action add_meta_boxes_{Application::POST_TYPE}
112
-     */
113
-    public function registerMetaBoxes($post)
114
-    {
115
-        add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
116
-        add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
117
-        if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) {
118
-            return;
119
-        }
120
-        add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
121
-    }
109
+	/**
110
+	 * @return void
111
+	 * @action add_meta_boxes_{Application::POST_TYPE}
112
+	 */
113
+	public function registerMetaBoxes($post)
114
+	{
115
+		add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
116
+		add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
117
+		if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) {
118
+			return;
119
+		}
120
+		add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
121
+	}
122 122
 
123
-    /**
124
-     * @return void
125
-     * @action admin_print_scripts
126
-     */
127
-    public function removeAutosave()
128
-    {
129
-        glsr(Customization::class)->removeAutosave();
130
-    }
123
+	/**
124
+	 * @return void
125
+	 * @action admin_print_scripts
126
+	 */
127
+	public function removeAutosave()
128
+	{
129
+		glsr(Customization::class)->removeAutosave();
130
+	}
131 131
 
132
-    /**
133
-     * @return void
134
-     * @action admin_menu
135
-     */
136
-    public function removeMetaBoxes()
137
-    {
138
-        glsr(Customization::class)->removeMetaBoxes();
139
-    }
132
+	/**
133
+	 * @return void
134
+	 * @action admin_menu
135
+	 */
136
+	public function removeMetaBoxes()
137
+	{
138
+		glsr(Customization::class)->removeMetaBoxes();
139
+	}
140 140
 
141
-    /**
142
-     * @return void
143
-     */
144
-    public function removePostTypeSupport()
145
-    {
146
-        glsr(Customization::class)->removePostTypeSupport();
147
-    }
141
+	/**
142
+	 * @return void
143
+	 */
144
+	public function removePostTypeSupport()
145
+	{
146
+		glsr(Customization::class)->removePostTypeSupport();
147
+	}
148 148
 
149
-    /**
150
-     * @param WP_Post $post
151
-     * @return void
152
-     * @callback add_meta_box
153
-     */
154
-    public function renderAssignedToMetabox($post)
155
-    {
156
-        if (!$this->isReviewPostType($post)) {
157
-            return;
158
-        }
159
-        $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to');
160
-        wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
161
-        glsr()->render('partials/editor/metabox-assigned-to', [
162
-            'id' => $assignedTo,
163
-            'template' => $this->buildAssignedToTemplate($assignedTo, $post),
164
-        ]);
165
-    }
149
+	/**
150
+	 * @param WP_Post $post
151
+	 * @return void
152
+	 * @callback add_meta_box
153
+	 */
154
+	public function renderAssignedToMetabox($post)
155
+	{
156
+		if (!$this->isReviewPostType($post)) {
157
+			return;
158
+		}
159
+		$assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to');
160
+		wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
161
+		glsr()->render('partials/editor/metabox-assigned-to', [
162
+			'id' => $assignedTo,
163
+			'template' => $this->buildAssignedToTemplate($assignedTo, $post),
164
+		]);
165
+	}
166 166
 
167
-    /**
168
-     * @param WP_Post $post
169
-     * @return void
170
-     * @callback add_meta_box
171
-     */
172
-    public function renderDetailsMetaBox($post)
173
-    {
174
-        if (!$this->isReviewPostType($post)) {
175
-            return;
176
-        }
177
-        $review = glsr_get_review($post);
178
-        glsr()->render('partials/editor/metabox-details', [
179
-            'button' => $this->buildDetailsMetaBoxRevertButton($review, $post),
180
-            'metabox' => $this->normalizeDetailsMetaBox($review),
181
-        ]);
182
-    }
167
+	/**
168
+	 * @param WP_Post $post
169
+	 * @return void
170
+	 * @callback add_meta_box
171
+	 */
172
+	public function renderDetailsMetaBox($post)
173
+	{
174
+		if (!$this->isReviewPostType($post)) {
175
+			return;
176
+		}
177
+		$review = glsr_get_review($post);
178
+		glsr()->render('partials/editor/metabox-details', [
179
+			'button' => $this->buildDetailsMetaBoxRevertButton($review, $post),
180
+			'metabox' => $this->normalizeDetailsMetaBox($review),
181
+		]);
182
+	}
183 183
 
184
-    /**
185
-     * @return void
186
-     * @action post_submitbox_misc_actions
187
-     */
188
-    public function renderPinnedInPublishMetaBox()
189
-    {
190
-        if (!$this->isReviewPostType(get_post())) {
191
-            return;
192
-        }
193
-        glsr(Template::class)->render('partials/editor/pinned', [
194
-            'context' => [
195
-                'no' => __('No', 'site-reviews'),
196
-                'yes' => __('Yes', 'site-reviews'),
197
-            ],
198
-            'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')),
199
-        ]);
200
-    }
184
+	/**
185
+	 * @return void
186
+	 * @action post_submitbox_misc_actions
187
+	 */
188
+	public function renderPinnedInPublishMetaBox()
189
+	{
190
+		if (!$this->isReviewPostType(get_post())) {
191
+			return;
192
+		}
193
+		glsr(Template::class)->render('partials/editor/pinned', [
194
+			'context' => [
195
+				'no' => __('No', 'site-reviews'),
196
+				'yes' => __('Yes', 'site-reviews'),
197
+			],
198
+			'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')),
199
+		]);
200
+	}
201 201
 
202
-    /**
203
-     * @param WP_Post $post
204
-     * @return void
205
-     * @callback add_meta_box
206
-     */
207
-    public function renderResponseMetaBox($post)
208
-    {
209
-        if (!$this->isReviewPostType($post)) {
210
-            return;
211
-        }
212
-        wp_nonce_field('response', '_nonce-response', false);
213
-        glsr()->render('partials/editor/metabox-response', [
214
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
215
-        ]);
216
-    }
202
+	/**
203
+	 * @param WP_Post $post
204
+	 * @return void
205
+	 * @callback add_meta_box
206
+	 */
207
+	public function renderResponseMetaBox($post)
208
+	{
209
+		if (!$this->isReviewPostType($post)) {
210
+			return;
211
+		}
212
+		wp_nonce_field('response', '_nonce-response', false);
213
+		glsr()->render('partials/editor/metabox-response', [
214
+			'response' => glsr(Database::class)->get($post->ID, 'response'),
215
+		]);
216
+	}
217 217
 
218
-    /**
219
-     * @param WP_Post $post
220
-     * @return void
221
-     * @action edit_form_after_title
222
-     */
223
-    public function renderReviewEditor($post)
224
-    {
225
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
226
-            return;
227
-        }
228
-        glsr()->render('partials/editor/review', [
229
-            'post' => $post,
230
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
231
-        ]);
232
-    }
218
+	/**
219
+	 * @param WP_Post $post
220
+	 * @return void
221
+	 * @action edit_form_after_title
222
+	 */
223
+	public function renderReviewEditor($post)
224
+	{
225
+		if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
226
+			return;
227
+		}
228
+		glsr()->render('partials/editor/review', [
229
+			'post' => $post,
230
+			'response' => glsr(Database::class)->get($post->ID, 'response'),
231
+		]);
232
+	}
233 233
 
234
-    /**
235
-     * @return void
236
-     * @action admin_head
237
-     */
238
-    public function renderReviewFields()
239
-    {
240
-        $screen = glsr_current_screen();
241
-        if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) {
242
-            return;
243
-        }
244
-        add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
245
-        add_action('edit_form_top', [$this, 'renderReviewNotice']);
246
-    }
234
+	/**
235
+	 * @return void
236
+	 * @action admin_head
237
+	 */
238
+	public function renderReviewFields()
239
+	{
240
+		$screen = glsr_current_screen();
241
+		if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) {
242
+			return;
243
+		}
244
+		add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
245
+		add_action('edit_form_top', [$this, 'renderReviewNotice']);
246
+	}
247 247
 
248
-    /**
249
-     * @param WP_Post $post
250
-     * @return void
251
-     * @action edit_form_top
252
-     */
253
-    public function renderReviewNotice($post)
254
-    {
255
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
256
-            return;
257
-        }
258
-        glsr(Notice::class)->addWarning(sprintf(
259
-            __('%s reviews are read-only.', 'site-reviews'),
260
-            glsr(Columns::class)->buildColumnReviewType($post->ID)
261
-        ));
262
-        glsr(Template::class)->render('partials/editor/notice', [
263
-            'context' => [
264
-                'notices' => glsr(Notice::class)->get(),
265
-            ],
266
-        ]);
267
-    }
248
+	/**
249
+	 * @param WP_Post $post
250
+	 * @return void
251
+	 * @action edit_form_top
252
+	 */
253
+	public function renderReviewNotice($post)
254
+	{
255
+		if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
256
+			return;
257
+		}
258
+		glsr(Notice::class)->addWarning(sprintf(
259
+			__('%s reviews are read-only.', 'site-reviews'),
260
+			glsr(Columns::class)->buildColumnReviewType($post->ID)
261
+		));
262
+		glsr(Template::class)->render('partials/editor/notice', [
263
+			'context' => [
264
+				'notices' => glsr(Notice::class)->get(),
265
+			],
266
+		]);
267
+	}
268 268
 
269
-    /**
270
-     * @param WP_Post $post
271
-     * @return void
272
-     * @see glsr_categories_meta_box()
273
-     * @callback register_taxonomy
274
-     */
275
-    public function renderTaxonomyMetabox($post)
276
-    {
277
-        if (!$this->isReviewPostType($post)) {
278
-            return;
279
-        }
280
-        glsr()->render('partials/editor/metabox-categories', [
281
-            'post' => $post,
282
-            'tax_name' => Application::TAXONOMY,
283
-            'taxonomy' => get_taxonomy(Application::TAXONOMY),
284
-        ]);
285
-    }
269
+	/**
270
+	 * @param WP_Post $post
271
+	 * @return void
272
+	 * @see glsr_categories_meta_box()
273
+	 * @callback register_taxonomy
274
+	 */
275
+	public function renderTaxonomyMetabox($post)
276
+	{
277
+		if (!$this->isReviewPostType($post)) {
278
+			return;
279
+		}
280
+		glsr()->render('partials/editor/metabox-categories', [
281
+			'post' => $post,
282
+			'tax_name' => Application::TAXONOMY,
283
+			'taxonomy' => get_taxonomy(Application::TAXONOMY),
284
+		]);
285
+	}
286 286
 
287
-    /**
288
-     * @return void
289
-     * @see $this->filterUpdateMessages()
290
-     * @action admin_action_revert
291
-     */
292
-    public function revertReview()
293
-    {
294
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
295
-            return;
296
-        }
297
-        check_admin_referer('revert-review_'.($postId = $this->getPostId()));
298
-        glsr(ReviewManager::class)->revert($postId);
299
-        $this->redirect($postId, 52);
300
-    }
287
+	/**
288
+	 * @return void
289
+	 * @see $this->filterUpdateMessages()
290
+	 * @action admin_action_revert
291
+	 */
292
+	public function revertReview()
293
+	{
294
+		if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
295
+			return;
296
+		}
297
+		check_admin_referer('revert-review_'.($postId = $this->getPostId()));
298
+		glsr(ReviewManager::class)->revert($postId);
299
+		$this->redirect($postId, 52);
300
+	}
301 301
 
302
-    /**
303
-     * @param int $postId
304
-     * @param \WP_Post $post
305
-     * @param bool $isUpdate
306
-     * @return void
307
-     * @action save_post_.Application::POST_TYPE
308
-     */
309
-    public function saveMetaboxes($postId, $post, $isUpdating)
310
-    {
311
-        glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
312
-        glsr(Metaboxes::class)->saveResponseMetabox($postId);
313
-        if ($isUpdating) {
314
-            do_action('site-reviews/review/saved', glsr_get_review($postId));
315
-        }
316
-    }
302
+	/**
303
+	 * @param int $postId
304
+	 * @param \WP_Post $post
305
+	 * @param bool $isUpdate
306
+	 * @return void
307
+	 * @action save_post_.Application::POST_TYPE
308
+	 */
309
+	public function saveMetaboxes($postId, $post, $isUpdating)
310
+	{
311
+		glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
312
+		glsr(Metaboxes::class)->saveResponseMetabox($postId);
313
+		if ($isUpdating) {
314
+			do_action('site-reviews/review/saved', glsr_get_review($postId));
315
+		}
316
+	}
317 317
 
318
-    /**
319
-     * @param string $assignedTo
320
-     * @return string
321
-     */
322
-    protected function buildAssignedToTemplate($assignedTo, WP_Post $post)
323
-    {
324
-        $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo);
325
-        if (!($assignedPost instanceof WP_Post)) {
326
-            return;
327
-        }
328
-        return glsr(Template::class)->build('partials/editor/assigned-post', [
329
-            'context' => [
330
-                'data.url' => (string) get_permalink($assignedPost),
331
-                'data.title' => get_the_title($assignedPost),
332
-            ],
333
-        ]);
334
-    }
318
+	/**
319
+	 * @param string $assignedTo
320
+	 * @return string
321
+	 */
322
+	protected function buildAssignedToTemplate($assignedTo, WP_Post $post)
323
+	{
324
+		$assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo);
325
+		if (!($assignedPost instanceof WP_Post)) {
326
+			return;
327
+		}
328
+		return glsr(Template::class)->build('partials/editor/assigned-post', [
329
+			'context' => [
330
+				'data.url' => (string) get_permalink($assignedPost),
331
+				'data.title' => get_the_title($assignedPost),
332
+			],
333
+		]);
334
+	}
335 335
 
336
-    /**
337
-     * @return string
338
-     */
339
-    protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post)
340
-    {
341
-        $isModified = !glsr(Helper::class)->compareArrays(
342
-            [$review->title, $review->content, $review->date],
343
-            [
344
-                glsr(Database::class)->get($post->ID, 'title'),
345
-                glsr(Database::class)->get($post->ID, 'content'),
346
-                glsr(Database::class)->get($post->ID, 'date'),
347
-            ]
348
-        );
349
-        if ($isModified) {
350
-            $revertUrl = wp_nonce_url(
351
-                admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID),
352
-                'revert-review_'.$post->ID
353
-            );
354
-            return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [
355
-                'class' => 'button button-large',
356
-                'href' => $revertUrl,
357
-                'id' => 'revert',
358
-            ]);
359
-        }
360
-        return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [
361
-            'class' => 'button-large',
362
-            'disabled' => true,
363
-            'id' => 'revert',
364
-        ]);
365
-    }
336
+	/**
337
+	 * @return string
338
+	 */
339
+	protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post)
340
+	{
341
+		$isModified = !glsr(Helper::class)->compareArrays(
342
+			[$review->title, $review->content, $review->date],
343
+			[
344
+				glsr(Database::class)->get($post->ID, 'title'),
345
+				glsr(Database::class)->get($post->ID, 'content'),
346
+				glsr(Database::class)->get($post->ID, 'date'),
347
+			]
348
+		);
349
+		if ($isModified) {
350
+			$revertUrl = wp_nonce_url(
351
+				admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID),
352
+				'revert-review_'.$post->ID
353
+			);
354
+			return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [
355
+				'class' => 'button button-large',
356
+				'href' => $revertUrl,
357
+				'id' => 'revert',
358
+			]);
359
+		}
360
+		return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [
361
+			'class' => 'button-large',
362
+			'disabled' => true,
363
+			'id' => 'revert',
364
+		]);
365
+	}
366 366
 
367
-    /**
368
-     * @param object $review
369
-     * @return string|void
370
-     */
371
-    protected function getReviewType($review)
372
-    {
373
-        if (count(glsr()->reviewTypes) < 2) {
374
-            return;
375
-        }
376
-        $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes)
377
-            ? glsr()->reviewTypes[$review->review_type]
378
-            : __('Unknown', 'site-reviews');
379
-        if (!empty($review->url)) {
380
-            $reviewType = glsr(Builder::class)->a($reviewType, [
381
-                'href' => $review->url,
382
-                'target' => '_blank',
383
-            ]);
384
-        }
385
-        return $reviewType;
386
-    }
367
+	/**
368
+	 * @param object $review
369
+	 * @return string|void
370
+	 */
371
+	protected function getReviewType($review)
372
+	{
373
+		if (count(glsr()->reviewTypes) < 2) {
374
+			return;
375
+		}
376
+		$reviewType = array_key_exists($review->review_type, glsr()->reviewTypes)
377
+			? glsr()->reviewTypes[$review->review_type]
378
+			: __('Unknown', 'site-reviews');
379
+		if (!empty($review->url)) {
380
+			$reviewType = glsr(Builder::class)->a($reviewType, [
381
+				'href' => $review->url,
382
+				'target' => '_blank',
383
+			]);
384
+		}
385
+		return $reviewType;
386
+	}
387 387
 
388
-    /**
389
-     * @return bool
390
-     */
391
-    protected function isReviewEditable($post)
392
-    {
393
-        return $this->isReviewPostType($post)
394
-            && post_type_supports(Application::POST_TYPE, 'title')
395
-            && 'local' == glsr(Database::class)->get($post->ID, 'review_type');
396
-    }
388
+	/**
389
+	 * @return bool
390
+	 */
391
+	protected function isReviewEditable($post)
392
+	{
393
+		return $this->isReviewPostType($post)
394
+			&& post_type_supports(Application::POST_TYPE, 'title')
395
+			&& 'local' == glsr(Database::class)->get($post->ID, 'review_type');
396
+	}
397 397
 
398
-    /**
399
-     * @param mixed $post
400
-     * @return bool
401
-     */
402
-    protected function isReviewPostType($post)
403
-    {
404
-        return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type;
405
-    }
398
+	/**
399
+	 * @param mixed $post
400
+	 * @return bool
401
+	 */
402
+	protected function isReviewPostType($post)
403
+	{
404
+		return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type;
405
+	}
406 406
 
407
-    /**
408
-     * @return array
409
-     */
410
-    protected function normalizeDetailsMetaBox(Review $review)
411
-    {
412
-        $user = empty($review->user_id)
413
-            ? __('Unregistered user', 'site-reviews')
414
-            : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [
415
-                'href' => get_author_posts_url($review->user_id),
416
-            ]);
417
-        $email = empty($review->email)
418
-            ? '&mdash;'
419
-            : glsr(Builder::class)->a($review->email, [
420
-                'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title),
421
-            ]);
422
-        $metabox = [
423
-            __('Rating', 'site-reviews') => glsr_star_rating($review->rating),
424
-            __('Type', 'site-reviews') => $this->getReviewType($review),
425
-            __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'),
426
-            __('Name', 'site-reviews') => $review->author,
427
-            __('Email', 'site-reviews') => $email,
428
-            __('User', 'site-reviews') => $user,
429
-            __('IP Address', 'site-reviews') => $review->ip_address,
430
-            __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
431
-        ];
432
-        return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review));
433
-    }
407
+	/**
408
+	 * @return array
409
+	 */
410
+	protected function normalizeDetailsMetaBox(Review $review)
411
+	{
412
+		$user = empty($review->user_id)
413
+			? __('Unregistered user', 'site-reviews')
414
+			: glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [
415
+				'href' => get_author_posts_url($review->user_id),
416
+			]);
417
+		$email = empty($review->email)
418
+			? '&mdash;'
419
+			: glsr(Builder::class)->a($review->email, [
420
+				'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title),
421
+			]);
422
+		$metabox = [
423
+			__('Rating', 'site-reviews') => glsr_star_rating($review->rating),
424
+			__('Type', 'site-reviews') => $this->getReviewType($review),
425
+			__('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'),
426
+			__('Name', 'site-reviews') => $review->author,
427
+			__('Email', 'site-reviews') => $email,
428
+			__('User', 'site-reviews') => $user,
429
+			__('IP Address', 'site-reviews') => $review->ip_address,
430
+			__('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
431
+		];
432
+		return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review));
433
+	}
434 434
 
435
-    /**
436
-     * @param int $postId
437
-     * @param int $messageIndex
438
-     * @return void
439
-     */
440
-    protected function redirect($postId, $messageIndex)
441
-    {
442
-        $referer = wp_get_referer();
443
-        $hasReferer = !$referer
444
-            || false !== strpos($referer, 'post.php')
445
-            || false !== strpos($referer, 'post-new.php');
446
-        $redirectUri = $hasReferer
447
-            ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
448
-            : get_edit_post_link($postId);
449
-        wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
450
-        exit;
451
-    }
435
+	/**
436
+	 * @param int $postId
437
+	 * @param int $messageIndex
438
+	 * @return void
439
+	 */
440
+	protected function redirect($postId, $messageIndex)
441
+	{
442
+		$referer = wp_get_referer();
443
+		$hasReferer = !$referer
444
+			|| false !== strpos($referer, 'post.php')
445
+			|| false !== strpos($referer, 'post-new.php');
446
+		$redirectUri = $hasReferer
447
+			? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
448
+			: get_edit_post_link($postId);
449
+		wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
450
+		exit;
451
+	}
452 452
 }
Please login to merge, or discard this patch.
plugin/Controllers/RebusifyController.php 1 patch
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -12,231 +12,231 @@
 block discarded – undo
12 12
 
13 13
 class RebusifyController extends Controller
14 14
 {
15
-    protected $apiKey = 'settings.general.rebusify_serial';
16
-    protected $emailKey = 'settings.general.rebusify_email';
17
-    protected $enabledKey = 'settings.general.rebusify';
18
-    protected $rebusifyKey = '_glsr_rebusify';
19
-
20
-    /**
21
-     * @return array
22
-     * @filter site-reviews/settings/callback
23
-     */
24
-    public function filterSettingsCallback(array $settings)
25
-    {
26
-        if ('yes' !== glsr_get($settings, $this->enabledKey)) {
27
-            return $settings;
28
-        }
29
-        $isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings);
30
-        $isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings);
31
-        $isAccountVerified = glsr(OptionManager::class)->getWP($this->rebusifyKey, false);
32
-        if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) {
33
-            $settings = $this->sanitizeRebusifySettings($settings);
34
-        }
35
-        return $settings;
36
-    }
37
-
38
-    /**
39
-     * @param string $template
40
-     * @return array
41
-     * @filter site-reviews/interpolate/partials/form/table-row-multiple
42
-     */
43
-    public function filterSettingsTableRow(array $context, $template, array $data)
44
-    {
45
-        if ($this->enabledKey !== glsr_get($data, 'field.path')) {
46
-            return $context;
47
-        }
48
-        $rebusifyProductType = glsr(OptionManager::class)->getWP($this->rebusifyKey);
49
-        if ('P' === $rebusifyProductType) {
50
-            return $context;
51
-        }
52
-        if ('F' === $rebusifyProductType && 'yes' === glsr_get_option('general.rebusify')) {
53
-            $button = $this->buildUpgradeButton();
54
-        } else {
55
-            $button = $this->buildCreateButton();
56
-        }
57
-        $context['field'].= $button;
58
-        return $context;
59
-    }
60
-
61
-    /**
62
-     * Triggered when a review is created.
63
-     * @return void
64
-     * @action site-reviews/review/created
65
-     */
66
-    public function onCreated(Review $review)
67
-    {
68
-        if (!$this->canPostReview($review)) {
69
-            return;
70
-        }
71
-        $rebusify = glsr(Rebusify::class)->sendReview($review);
72
-        if ($rebusify->success) {
73
-            glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
74
-        }
75
-    }
76
-
77
-    /**
78
-     * Triggered when a review is reverted to its original title/content/date_timestamp.
79
-     * @return void
80
-     * @action site-reviews/review/reverted
81
-     */
82
-    public function onReverted(Review $review)
83
-    {
84
-        if (!$this->canPostReview($review)) {
85
-            return;
86
-        }
87
-        $rebusify = glsr(Rebusify::class)->sendReview($review);
88
-        if ($rebusify->success) {
89
-            glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
90
-        }
91
-    }
92
-
93
-    /**
94
-     * Triggered when an existing review is updated.
95
-     * @return void
96
-     * @action site-reviews/review/saved
97
-     */
98
-    public function onSaved(Review $review)
99
-    {
100
-        if (!$this->canPostReview($review)) {
101
-            return;
102
-        }
103
-        $rebusify = glsr(Rebusify::class)->sendReview($review);
104
-        if ($rebusify->success) {
105
-            glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
106
-        }
107
-    }
108
-
109
-    /**
110
-     * Triggered when a review's response is added or updated.
111
-     * @param int $metaId
112
-     * @param int $postId
113
-     * @param string $metaKey
114
-     * @return void
115
-     * @action updated_postmeta
116
-     */
117
-    public function onUpdatedMeta($metaId, $postId, $metaKey)
118
-    {
119
-        $review = glsr_get_review($postId);
120
-        if (!$this->canPostResponse($review) || '_response' !== $metaKey) {
121
-            return;
122
-        }
123
-        $rebusify = glsr(Rebusify::class)->sendReviewResponse($review);
124
-        if ($rebusify->success) {
125
-            glsr(Database::class)->set($review->ID, 'rebusify_response', true);
126
-        }
127
-    }
128
-
129
-    /**
130
-     * @return string
131
-     */
132
-    protected function buildCreateButton()
133
-    {
134
-        return glsr(Builder::class)->a(__('Create Your Rebusify Account', 'site-reviews'), [
135
-            'class' => 'button',
136
-            'href' => Rebusify::WEB_URL,
137
-            'target' => '_blank',
138
-        ]);
139
-    }
140
-
141
-    /**
142
-     * @return string
143
-     */
144
-    protected function buildUpgradeButton()
145
-    {
146
-        $build = glsr(Builder::class);
147
-        $notice = $build->p(__('Free Rebusify accounts are limited to 500 blockchain transactions per year.', 'site-reviews'));
148
-        $button = $build->a(__('Upgrade Your Rebusify Plan', 'site-reviews'), [
149
-            'class' => 'button',
150
-            'href' => Rebusify::WEB_URL,
151
-            'target' => '_blank',
152
-        ]);
153
-        return $build->div($notice.$button, [
154
-            'class' => 'glsr-notice-inline',
155
-        ]);
156
-    }
157
-
158
-    /**
159
-     * @return bool
160
-     */
161
-    protected function canPostResponse(Review $review)
162
-    {
163
-        $requiredValues = [
164
-            glsr(Database::class)->get($review->ID, 'rebusify'),
165
-            $review->response,
166
-            $review->review_id,
167
-        ];
168
-        return $this->canProceed($review, 'rebusify_response')
169
-            && 'publish' === $review->status
170
-            && 3 === count(array_filter($requiredValues));
171
-    }
172
-
173
-    /**
174
-     * @return bool
175
-     */
176
-    protected function canPostReview(Review $review)
177
-    {
178
-        $requiredValues = [
179
-            $review->author,
180
-            $review->content,
181
-            $review->rating,
182
-            $review->review_id,
183
-            $review->title,
184
-        ];
185
-        return $this->canProceed($review)
186
-            && 'publish' === $review->status
187
-            && 5 === count(array_filter($requiredValues));
188
-    }
189
-
190
-    /**
191
-     * @param string $metaKey
192
-     * @return bool
193
-     */
194
-    protected function canProceed(Review $review, $metaKey = 'rebusify')
195
-    {
196
-        return glsr(OptionManager::class)->getBool($this->enabledKey)
197
-            && $this->isReviewPostId($review->ID)
198
-            && !$this->hasMetaKey($review, $metaKey);
199
-    }
200
-
201
-    /**
202
-     * @param string $metaKey
203
-     * @return bool
204
-     */
205
-    protected function hasMetaKey(Review $review, $metaKey = 'rebusify')
206
-    {
207
-        return '' !== glsr(Database::class)->get($review->ID, $metaKey);
208
-    }
209
-
210
-    /**
211
-     * @param string $key
212
-     * @return bool
213
-     */
214
-    protected function isEmptyOrModified($key, array $settings)
215
-    {
216
-        $oldValue = glsr_get_option($key);
217
-        $newValue = glsr_get($settings, $key);
218
-        return empty($newValue) || $newValue !== $oldValue;
219
-    }
220
-
221
-    /**
222
-     * @return array
223
-     */
224
-    protected function sanitizeRebusifySettings(array $settings)
225
-    {
226
-        $rebusify = glsr(Rebusify::class)->activateKey(
227
-            glsr_get($settings, $this->apiKey),
228
-            glsr_get($settings, $this->emailKey)
229
-        );
230
-        if ($rebusify->success) {
231
-            update_option($this->rebusifyKey, glsr_get($rebusify->response, 'producttype'));
232
-        } else {
233
-            delete_option($this->rebusifyKey);
234
-            $settings = glsr(Helper::class)->dataSet($settings, $this->enabledKey, 'no');
235
-            glsr(Notice::class)->addError(sprintf(
236
-                __('Your Rebusify account details could not be verified, please try again. %s', 'site-reviews'),
237
-                '('.$rebusify->message.')'
238
-            ));
239
-        }
240
-        return $settings;
241
-    }
15
+	protected $apiKey = 'settings.general.rebusify_serial';
16
+	protected $emailKey = 'settings.general.rebusify_email';
17
+	protected $enabledKey = 'settings.general.rebusify';
18
+	protected $rebusifyKey = '_glsr_rebusify';
19
+
20
+	/**
21
+	 * @return array
22
+	 * @filter site-reviews/settings/callback
23
+	 */
24
+	public function filterSettingsCallback(array $settings)
25
+	{
26
+		if ('yes' !== glsr_get($settings, $this->enabledKey)) {
27
+			return $settings;
28
+		}
29
+		$isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings);
30
+		$isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings);
31
+		$isAccountVerified = glsr(OptionManager::class)->getWP($this->rebusifyKey, false);
32
+		if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) {
33
+			$settings = $this->sanitizeRebusifySettings($settings);
34
+		}
35
+		return $settings;
36
+	}
37
+
38
+	/**
39
+	 * @param string $template
40
+	 * @return array
41
+	 * @filter site-reviews/interpolate/partials/form/table-row-multiple
42
+	 */
43
+	public function filterSettingsTableRow(array $context, $template, array $data)
44
+	{
45
+		if ($this->enabledKey !== glsr_get($data, 'field.path')) {
46
+			return $context;
47
+		}
48
+		$rebusifyProductType = glsr(OptionManager::class)->getWP($this->rebusifyKey);
49
+		if ('P' === $rebusifyProductType) {
50
+			return $context;
51
+		}
52
+		if ('F' === $rebusifyProductType && 'yes' === glsr_get_option('general.rebusify')) {
53
+			$button = $this->buildUpgradeButton();
54
+		} else {
55
+			$button = $this->buildCreateButton();
56
+		}
57
+		$context['field'].= $button;
58
+		return $context;
59
+	}
60
+
61
+	/**
62
+	 * Triggered when a review is created.
63
+	 * @return void
64
+	 * @action site-reviews/review/created
65
+	 */
66
+	public function onCreated(Review $review)
67
+	{
68
+		if (!$this->canPostReview($review)) {
69
+			return;
70
+		}
71
+		$rebusify = glsr(Rebusify::class)->sendReview($review);
72
+		if ($rebusify->success) {
73
+			glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
74
+		}
75
+	}
76
+
77
+	/**
78
+	 * Triggered when a review is reverted to its original title/content/date_timestamp.
79
+	 * @return void
80
+	 * @action site-reviews/review/reverted
81
+	 */
82
+	public function onReverted(Review $review)
83
+	{
84
+		if (!$this->canPostReview($review)) {
85
+			return;
86
+		}
87
+		$rebusify = glsr(Rebusify::class)->sendReview($review);
88
+		if ($rebusify->success) {
89
+			glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
90
+		}
91
+	}
92
+
93
+	/**
94
+	 * Triggered when an existing review is updated.
95
+	 * @return void
96
+	 * @action site-reviews/review/saved
97
+	 */
98
+	public function onSaved(Review $review)
99
+	{
100
+		if (!$this->canPostReview($review)) {
101
+			return;
102
+		}
103
+		$rebusify = glsr(Rebusify::class)->sendReview($review);
104
+		if ($rebusify->success) {
105
+			glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
106
+		}
107
+	}
108
+
109
+	/**
110
+	 * Triggered when a review's response is added or updated.
111
+	 * @param int $metaId
112
+	 * @param int $postId
113
+	 * @param string $metaKey
114
+	 * @return void
115
+	 * @action updated_postmeta
116
+	 */
117
+	public function onUpdatedMeta($metaId, $postId, $metaKey)
118
+	{
119
+		$review = glsr_get_review($postId);
120
+		if (!$this->canPostResponse($review) || '_response' !== $metaKey) {
121
+			return;
122
+		}
123
+		$rebusify = glsr(Rebusify::class)->sendReviewResponse($review);
124
+		if ($rebusify->success) {
125
+			glsr(Database::class)->set($review->ID, 'rebusify_response', true);
126
+		}
127
+	}
128
+
129
+	/**
130
+	 * @return string
131
+	 */
132
+	protected function buildCreateButton()
133
+	{
134
+		return glsr(Builder::class)->a(__('Create Your Rebusify Account', 'site-reviews'), [
135
+			'class' => 'button',
136
+			'href' => Rebusify::WEB_URL,
137
+			'target' => '_blank',
138
+		]);
139
+	}
140
+
141
+	/**
142
+	 * @return string
143
+	 */
144
+	protected function buildUpgradeButton()
145
+	{
146
+		$build = glsr(Builder::class);
147
+		$notice = $build->p(__('Free Rebusify accounts are limited to 500 blockchain transactions per year.', 'site-reviews'));
148
+		$button = $build->a(__('Upgrade Your Rebusify Plan', 'site-reviews'), [
149
+			'class' => 'button',
150
+			'href' => Rebusify::WEB_URL,
151
+			'target' => '_blank',
152
+		]);
153
+		return $build->div($notice.$button, [
154
+			'class' => 'glsr-notice-inline',
155
+		]);
156
+	}
157
+
158
+	/**
159
+	 * @return bool
160
+	 */
161
+	protected function canPostResponse(Review $review)
162
+	{
163
+		$requiredValues = [
164
+			glsr(Database::class)->get($review->ID, 'rebusify'),
165
+			$review->response,
166
+			$review->review_id,
167
+		];
168
+		return $this->canProceed($review, 'rebusify_response')
169
+			&& 'publish' === $review->status
170
+			&& 3 === count(array_filter($requiredValues));
171
+	}
172
+
173
+	/**
174
+	 * @return bool
175
+	 */
176
+	protected function canPostReview(Review $review)
177
+	{
178
+		$requiredValues = [
179
+			$review->author,
180
+			$review->content,
181
+			$review->rating,
182
+			$review->review_id,
183
+			$review->title,
184
+		];
185
+		return $this->canProceed($review)
186
+			&& 'publish' === $review->status
187
+			&& 5 === count(array_filter($requiredValues));
188
+	}
189
+
190
+	/**
191
+	 * @param string $metaKey
192
+	 * @return bool
193
+	 */
194
+	protected function canProceed(Review $review, $metaKey = 'rebusify')
195
+	{
196
+		return glsr(OptionManager::class)->getBool($this->enabledKey)
197
+			&& $this->isReviewPostId($review->ID)
198
+			&& !$this->hasMetaKey($review, $metaKey);
199
+	}
200
+
201
+	/**
202
+	 * @param string $metaKey
203
+	 * @return bool
204
+	 */
205
+	protected function hasMetaKey(Review $review, $metaKey = 'rebusify')
206
+	{
207
+		return '' !== glsr(Database::class)->get($review->ID, $metaKey);
208
+	}
209
+
210
+	/**
211
+	 * @param string $key
212
+	 * @return bool
213
+	 */
214
+	protected function isEmptyOrModified($key, array $settings)
215
+	{
216
+		$oldValue = glsr_get_option($key);
217
+		$newValue = glsr_get($settings, $key);
218
+		return empty($newValue) || $newValue !== $oldValue;
219
+	}
220
+
221
+	/**
222
+	 * @return array
223
+	 */
224
+	protected function sanitizeRebusifySettings(array $settings)
225
+	{
226
+		$rebusify = glsr(Rebusify::class)->activateKey(
227
+			glsr_get($settings, $this->apiKey),
228
+			glsr_get($settings, $this->emailKey)
229
+		);
230
+		if ($rebusify->success) {
231
+			update_option($this->rebusifyKey, glsr_get($rebusify->response, 'producttype'));
232
+		} else {
233
+			delete_option($this->rebusifyKey);
234
+			$settings = glsr(Helper::class)->dataSet($settings, $this->enabledKey, 'no');
235
+			glsr(Notice::class)->addError(sprintf(
236
+				__('Your Rebusify account details could not be verified, please try again. %s', 'site-reviews'),
237
+				'('.$rebusify->message.')'
238
+			));
239
+		}
240
+		return $settings;
241
+	}
242 242
 }
Please login to merge, or discard this patch.
plugin/Actions.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -20,108 +20,108 @@
 block discarded – undo
20 20
 
21 21
 class Actions implements HooksContract
22 22
 {
23
-    protected $about;
24
-    protected $admin;
25
-    protected $app;
26
-    protected $blocks;
27
-    protected $console;
28
-    protected $editor;
29
-    protected $listtable;
30
-    protected $menu;
31
-    protected $main;
32
-    protected $notices;
33
-    protected $public;
34
-    protected $rebusify;
35
-    protected $review;
36
-    protected $router;
37
-    protected $settings;
38
-    protected $taxonomy;
39
-    protected $welcome;
23
+	protected $about;
24
+	protected $admin;
25
+	protected $app;
26
+	protected $blocks;
27
+	protected $console;
28
+	protected $editor;
29
+	protected $listtable;
30
+	protected $menu;
31
+	protected $main;
32
+	protected $notices;
33
+	protected $public;
34
+	protected $rebusify;
35
+	protected $review;
36
+	protected $router;
37
+	protected $settings;
38
+	protected $taxonomy;
39
+	protected $welcome;
40 40
 
41
-    public function __construct(Application $app ) {
42
-        $this->app = $app;
43
-        $this->admin = $app->make(AdminController::class);
44
-        $this->blocks = $app->make(BlocksController::class);
45
-        $this->console = $app->make(Console::class);
46
-        $this->editor = $app->make(EditorController::class);
47
-        $this->listtable = $app->make(ListTableController::class);
48
-        $this->main = $app->make(MainController::class);
49
-        $this->menu = $app->make(MenuController::class);
50
-        $this->notices = $app->make(NoticeController::class);
51
-        $this->public = $app->make(PublicController::class);
52
-        $this->rebusify = $app->make(RebusifyController::class);
53
-        $this->review = $app->make(ReviewController::class);
54
-        $this->router = $app->make(Router::class);
55
-        $this->settings = $app->make(SettingsController::class);
56
-        $this->taxonomy = $app->make(TaxonomyController::class);
57
-        $this->welcome = $app->make(WelcomeController::class);
58
-    }
41
+	public function __construct(Application $app ) {
42
+		$this->app = $app;
43
+		$this->admin = $app->make(AdminController::class);
44
+		$this->blocks = $app->make(BlocksController::class);
45
+		$this->console = $app->make(Console::class);
46
+		$this->editor = $app->make(EditorController::class);
47
+		$this->listtable = $app->make(ListTableController::class);
48
+		$this->main = $app->make(MainController::class);
49
+		$this->menu = $app->make(MenuController::class);
50
+		$this->notices = $app->make(NoticeController::class);
51
+		$this->public = $app->make(PublicController::class);
52
+		$this->rebusify = $app->make(RebusifyController::class);
53
+		$this->review = $app->make(ReviewController::class);
54
+		$this->router = $app->make(Router::class);
55
+		$this->settings = $app->make(SettingsController::class);
56
+		$this->taxonomy = $app->make(TaxonomyController::class);
57
+		$this->welcome = $app->make(WelcomeController::class);
58
+	}
59 59
 
60
-    /**
61
-     * @return void
62
-     */
63
-    public function run()
64
-    {
65
-        add_action('admin_enqueue_scripts',                                 [$this->admin, 'enqueueAssets']);
66
-        add_action('admin_init',                                            [$this->admin, 'registerTinymcePopups']);
67
-        add_action('media_buttons',                                         [$this->admin, 'renderTinymceButton'], 11);
68
-        add_action('plugins_loaded',                                        [$this->app, 'getDefaults'], 11);
69
-        add_action('plugins_loaded',                                        [$this->app, 'registerAddons']);
70
-        add_action('plugins_loaded',                                        [$this->app, 'registerLanguages']);
71
-        add_action('plugins_loaded',                                        [$this->app, 'registerReviewTypes']);
72
-        add_action('upgrader_process_complete',                             [$this->app, 'upgraded'], 10, 2);
73
-        add_action('init',                                                  [$this->blocks, 'registerAssets'], 9);
74
-        add_action('init',                                                  [$this->blocks, 'registerBlocks']);
75
-        add_action('admin_footer',                                          [$this->console, 'logOnce']);
76
-        add_action('wp_footer',                                             [$this->console, 'logOnce']);
77
-        add_action('admin_enqueue_scripts',                                 [$this->editor, 'customizePostStatusLabels']);
78
-        add_action('add_meta_boxes_'.Application::POST_TYPE,                [$this->editor, 'registerMetaBoxes']);
79
-        add_action('admin_print_scripts',                                   [$this->editor, 'removeAutosave'], 999);
80
-        add_action('admin_menu',                                            [$this->editor, 'removeMetaBoxes']);
81
-        add_action('current_screen',                                        [$this->editor, 'removePostTypeSupport']);
82
-        add_action('post_submitbox_misc_actions',                           [$this->editor, 'renderPinnedInPublishMetaBox']);
83
-        add_action('admin_head',                                            [$this->editor, 'renderReviewFields']);
84
-        add_action('admin_action_revert',                                   [$this->editor, 'revertReview']);
85
-        add_action('save_post_'.Application::POST_TYPE,                     [$this->editor, 'saveMetaboxes'], 10, 3);
86
-        add_action('admin_action_approve',                                  [$this->listtable, 'approve']);
87
-        add_action('bulk_edit_custom_box',                                  [$this->listtable, 'renderBulkEditFields'], 10, 2);
88
-        add_action('restrict_manage_posts',                                 [$this->listtable, 'renderColumnFilters']);
89
-        add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2);
90
-        add_action('save_post_'.Application::POST_TYPE,                     [$this->listtable, 'saveBulkEditFields']);
91
-        add_action('pre_get_posts',                                         [$this->listtable, 'setQueryForColumn']);
92
-        add_action('admin_action_unapprove',                                [$this->listtable, 'unapprove']);
93
-        add_action('init',                                                  [$this->main, 'registerPostType'], 8);
94
-        add_action('init',                                                  [$this->main, 'registerShortcodes']);
95
-        add_action('init',                                                  [$this->main, 'registerTaxonomy']);
96
-        add_action('widgets_init',                                          [$this->main, 'registerWidgets']);
97
-        add_action('admin_menu',                                            [$this->menu, 'registerMenuCount']);
98
-        add_action('admin_menu',                                            [$this->menu, 'registerSubMenus']);
99
-        add_action('admin_init',                                            [$this->menu, 'setCustomPermissions'], 999);
100
-        add_action('admin_notices',                                         [$this->notices, 'filterAdminNotices']);
101
-        add_action('wp_enqueue_scripts',                                    [$this->public, 'enqueueAssets'], 999);
102
-        add_filter('site-reviews/builder',                                  [$this->public, 'modifyBuilder']);
103
-        add_action('wp_footer',                                             [$this->public, 'renderSchema']);
104
-        add_action('site-reviews/review/created',                           [$this->rebusify, 'onCreated']);
105
-        add_action('site-reviews/review/reverted',                          [$this->rebusify, 'onReverted']);
106
-        add_action('site-reviews/review/saved',                             [$this->rebusify, 'onSaved']);
107
-        add_action('updated_postmeta',                                      [$this->rebusify, 'onUpdatedMeta'], 10, 3);
108
-        add_action('set_object_terms',                                      [$this->review, 'onAfterChangeCategory'], 10, 6);
109
-        add_action('transition_post_status',                                [$this->review, 'onAfterChangeStatus'], 10, 3);
110
-        add_action('site-reviews/review/created',                           [$this->review, 'onAfterCreate']);
111
-        add_action('before_delete_post',                                    [$this->review, 'onBeforeDelete']);
112
-        add_action('update_postmeta',                                       [$this->review, 'onBeforeUpdate'], 10, 4);
113
-        add_action('admin_init',                                            [$this->router, 'routeAdminPostRequest']);
114
-        add_action('wp_ajax_'.Application::PREFIX.'action',                 [$this->router, 'routeAjaxRequest']);
115
-        add_action('wp_ajax_nopriv_'.Application::PREFIX.'action',          [$this->router, 'routeAjaxRequest']);
116
-        add_action('init',                                                  [$this->router, 'routePublicPostRequest']);
117
-        add_action('admin_init',                                            [$this->settings, 'registerSettings']);
118
-        add_action(Application::TAXONOMY.'_term_edit_form_top',             [$this->taxonomy, 'disableParents']);
119
-        add_action(Application::TAXONOMY.'_term_new_form_tag',              [$this->taxonomy, 'disableParents']);
120
-        add_action(Application::TAXONOMY.'_add_form_fields',                [$this->taxonomy, 'enableParents']);
121
-        add_action(Application::TAXONOMY.'_edit_form',                      [$this->taxonomy, 'enableParents']);
122
-        add_action('restrict_manage_posts',                                 [$this->taxonomy, 'renderTaxonomyFilter'], 9);
123
-        add_action('set_object_terms',                                      [$this->taxonomy, 'restrictTermSelection'], 9, 6);
124
-        add_action('activated_plugin',                                      [$this->welcome, 'redirectOnActivation'], 10, 2);
125
-        add_action('admin_menu',                                            [$this->welcome, 'registerPage']);
126
-    }
60
+	/**
61
+	 * @return void
62
+	 */
63
+	public function run()
64
+	{
65
+		add_action('admin_enqueue_scripts',                                 [$this->admin, 'enqueueAssets']);
66
+		add_action('admin_init',                                            [$this->admin, 'registerTinymcePopups']);
67
+		add_action('media_buttons',                                         [$this->admin, 'renderTinymceButton'], 11);
68
+		add_action('plugins_loaded',                                        [$this->app, 'getDefaults'], 11);
69
+		add_action('plugins_loaded',                                        [$this->app, 'registerAddons']);
70
+		add_action('plugins_loaded',                                        [$this->app, 'registerLanguages']);
71
+		add_action('plugins_loaded',                                        [$this->app, 'registerReviewTypes']);
72
+		add_action('upgrader_process_complete',                             [$this->app, 'upgraded'], 10, 2);
73
+		add_action('init',                                                  [$this->blocks, 'registerAssets'], 9);
74
+		add_action('init',                                                  [$this->blocks, 'registerBlocks']);
75
+		add_action('admin_footer',                                          [$this->console, 'logOnce']);
76
+		add_action('wp_footer',                                             [$this->console, 'logOnce']);
77
+		add_action('admin_enqueue_scripts',                                 [$this->editor, 'customizePostStatusLabels']);
78
+		add_action('add_meta_boxes_'.Application::POST_TYPE,                [$this->editor, 'registerMetaBoxes']);
79
+		add_action('admin_print_scripts',                                   [$this->editor, 'removeAutosave'], 999);
80
+		add_action('admin_menu',                                            [$this->editor, 'removeMetaBoxes']);
81
+		add_action('current_screen',                                        [$this->editor, 'removePostTypeSupport']);
82
+		add_action('post_submitbox_misc_actions',                           [$this->editor, 'renderPinnedInPublishMetaBox']);
83
+		add_action('admin_head',                                            [$this->editor, 'renderReviewFields']);
84
+		add_action('admin_action_revert',                                   [$this->editor, 'revertReview']);
85
+		add_action('save_post_'.Application::POST_TYPE,                     [$this->editor, 'saveMetaboxes'], 10, 3);
86
+		add_action('admin_action_approve',                                  [$this->listtable, 'approve']);
87
+		add_action('bulk_edit_custom_box',                                  [$this->listtable, 'renderBulkEditFields'], 10, 2);
88
+		add_action('restrict_manage_posts',                                 [$this->listtable, 'renderColumnFilters']);
89
+		add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2);
90
+		add_action('save_post_'.Application::POST_TYPE,                     [$this->listtable, 'saveBulkEditFields']);
91
+		add_action('pre_get_posts',                                         [$this->listtable, 'setQueryForColumn']);
92
+		add_action('admin_action_unapprove',                                [$this->listtable, 'unapprove']);
93
+		add_action('init',                                                  [$this->main, 'registerPostType'], 8);
94
+		add_action('init',                                                  [$this->main, 'registerShortcodes']);
95
+		add_action('init',                                                  [$this->main, 'registerTaxonomy']);
96
+		add_action('widgets_init',                                          [$this->main, 'registerWidgets']);
97
+		add_action('admin_menu',                                            [$this->menu, 'registerMenuCount']);
98
+		add_action('admin_menu',                                            [$this->menu, 'registerSubMenus']);
99
+		add_action('admin_init',                                            [$this->menu, 'setCustomPermissions'], 999);
100
+		add_action('admin_notices',                                         [$this->notices, 'filterAdminNotices']);
101
+		add_action('wp_enqueue_scripts',                                    [$this->public, 'enqueueAssets'], 999);
102
+		add_filter('site-reviews/builder',                                  [$this->public, 'modifyBuilder']);
103
+		add_action('wp_footer',                                             [$this->public, 'renderSchema']);
104
+		add_action('site-reviews/review/created',                           [$this->rebusify, 'onCreated']);
105
+		add_action('site-reviews/review/reverted',                          [$this->rebusify, 'onReverted']);
106
+		add_action('site-reviews/review/saved',                             [$this->rebusify, 'onSaved']);
107
+		add_action('updated_postmeta',                                      [$this->rebusify, 'onUpdatedMeta'], 10, 3);
108
+		add_action('set_object_terms',                                      [$this->review, 'onAfterChangeCategory'], 10, 6);
109
+		add_action('transition_post_status',                                [$this->review, 'onAfterChangeStatus'], 10, 3);
110
+		add_action('site-reviews/review/created',                           [$this->review, 'onAfterCreate']);
111
+		add_action('before_delete_post',                                    [$this->review, 'onBeforeDelete']);
112
+		add_action('update_postmeta',                                       [$this->review, 'onBeforeUpdate'], 10, 4);
113
+		add_action('admin_init',                                            [$this->router, 'routeAdminPostRequest']);
114
+		add_action('wp_ajax_'.Application::PREFIX.'action',                 [$this->router, 'routeAjaxRequest']);
115
+		add_action('wp_ajax_nopriv_'.Application::PREFIX.'action',          [$this->router, 'routeAjaxRequest']);
116
+		add_action('init',                                                  [$this->router, 'routePublicPostRequest']);
117
+		add_action('admin_init',                                            [$this->settings, 'registerSettings']);
118
+		add_action(Application::TAXONOMY.'_term_edit_form_top',             [$this->taxonomy, 'disableParents']);
119
+		add_action(Application::TAXONOMY.'_term_new_form_tag',              [$this->taxonomy, 'disableParents']);
120
+		add_action(Application::TAXONOMY.'_add_form_fields',                [$this->taxonomy, 'enableParents']);
121
+		add_action(Application::TAXONOMY.'_edit_form',                      [$this->taxonomy, 'enableParents']);
122
+		add_action('restrict_manage_posts',                                 [$this->taxonomy, 'renderTaxonomyFilter'], 9);
123
+		add_action('set_object_terms',                                      [$this->taxonomy, 'restrictTermSelection'], 9, 6);
124
+		add_action('activated_plugin',                                      [$this->welcome, 'redirectOnActivation'], 10, 2);
125
+		add_action('admin_menu',                                            [$this->welcome, 'registerPage']);
126
+	}
127 127
 }
Please login to merge, or discard this patch.
plugin/Widgets/Widget.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -7,54 +7,54 @@
 block discarded – undo
7 7
 
8 8
 abstract class Widget extends WP_Widget
9 9
 {
10
-    /**
11
-     * @var array
12
-     */
13
-    protected $widgetArgs;
10
+	/**
11
+	 * @var array
12
+	 */
13
+	protected $widgetArgs;
14 14
 
15
-    public function __construct($idBase, $name, $values)
16
-    {
17
-        $controlOptions = $widgetOptions = [];
18
-        if (isset($values['class'])) {
19
-            $widgetOptions['classname'] = $values['class'];
20
-        }
21
-        if (isset($values['description'])) {
22
-            $widgetOptions['description'] = $values['description'];
23
-        }
24
-        if (isset($values['width'])) {
25
-            $controlOptions['width'] = $values['width'];
26
-        }
27
-        parent::__construct($idBase, $name, $widgetOptions, $controlOptions);
28
-    }
15
+	public function __construct($idBase, $name, $values)
16
+	{
17
+		$controlOptions = $widgetOptions = [];
18
+		if (isset($values['class'])) {
19
+			$widgetOptions['classname'] = $values['class'];
20
+		}
21
+		if (isset($values['description'])) {
22
+			$widgetOptions['description'] = $values['description'];
23
+		}
24
+		if (isset($values['width'])) {
25
+			$controlOptions['width'] = $values['width'];
26
+		}
27
+		parent::__construct($idBase, $name, $widgetOptions, $controlOptions);
28
+	}
29 29
 
30
-    /**
31
-     * @param string $tag
32
-     * @return void
33
-     */
34
-    protected function renderField($tag, array $args = [])
35
-    {
36
-        $args = $this->normalizeFieldAttributes($tag, $args);
37
-        $field = glsr(Builder::class)->$tag($args['name'], $args);
38
-        echo glsr(Builder::class)->div($field, [
39
-            'class' => 'glsr-field',
40
-        ]);
41
-    }
30
+	/**
31
+	 * @param string $tag
32
+	 * @return void
33
+	 */
34
+	protected function renderField($tag, array $args = [])
35
+	{
36
+		$args = $this->normalizeFieldAttributes($tag, $args);
37
+		$field = glsr(Builder::class)->$tag($args['name'], $args);
38
+		echo glsr(Builder::class)->div($field, [
39
+			'class' => 'glsr-field',
40
+		]);
41
+	}
42 42
 
43
-    /**
44
-     * @param string $tag
45
-     * @return array
46
-     */
47
-    protected function normalizeFieldAttributes($tag, array $args)
48
-    {
49
-        if (empty($args['value'])) {
50
-            $args['value'] = $this->widgetArgs[$args['name']];
51
-        }
52
-        if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) {
53
-            $args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]);
54
-        }
55
-        $args['id'] = $this->get_field_id($args['name']);
56
-        $args['name'] = $this->get_field_name($args['name']);
57
-        $args['is_widget'] = true;
58
-        return $args;
59
-    }
43
+	/**
44
+	 * @param string $tag
45
+	 * @return array
46
+	 */
47
+	protected function normalizeFieldAttributes($tag, array $args)
48
+	{
49
+		if (empty($args['value'])) {
50
+			$args['value'] = $this->widgetArgs[$args['name']];
51
+		}
52
+		if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) {
53
+			$args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]);
54
+		}
55
+		$args['id'] = $this->get_field_id($args['name']);
56
+		$args['name'] = $this->get_field_name($args['name']);
57
+		$args['is_widget'] = true;
58
+		return $args;
59
+	}
60 60
 }
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 (property_exists($this, $key)) {
48
-            return $this->$key;
49
-        }
50
-        return array_key_exists($key, $this->values)
51
-            ? $this->values[$key]
52
-            : null;
53
-    }
41
+	/**
42
+	 * @param mixed $key
43
+	 * @return mixed
44
+	 */
45
+	public function offsetGet($key)
46
+	{
47
+		if (property_exists($this, $key)) {
48
+			return $this->$key;
49
+		}
50
+		return array_key_exists($key, $this->values)
51
+			? $this->values[$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
@@ -7,135 +7,135 @@
 block discarded – undo
7 7
 
8 8
 class ReviewsHtml extends ArrayObject
9 9
 {
10
-    /**
11
-     * @var array
12
-     */
13
-    public $args;
10
+	/**
11
+	 * @var array
12
+	 */
13
+	public $args;
14 14
 
15
-    /**
16
-     * @var int
17
-     */
18
-    public $max_num_pages;
15
+	/**
16
+	 * @var int
17
+	 */
18
+	public $max_num_pages;
19 19
 
20
-    /**
21
-     * @var string
22
-     */
23
-    public $pagination;
20
+	/**
21
+	 * @var string
22
+	 */
23
+	public $pagination;
24 24
 
25
-    /**
26
-     * @var array
27
-     */
28
-    public $reviews;
25
+	/**
26
+	 * @var array
27
+	 */
28
+	public $reviews;
29 29
 
30
-    public function __construct(array $reviews, $maxPageCount, array $args)
31
-    {
32
-        $this->args = $args;
33
-        $this->max_num_pages = $maxPageCount;
34
-        $this->reviews = $reviews;
35
-        $this->pagination = $this->buildPagination();
36
-        parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
37
-    }
30
+	public function __construct(array $reviews, $maxPageCount, array $args)
31
+	{
32
+		$this->args = $args;
33
+		$this->max_num_pages = $maxPageCount;
34
+		$this->reviews = $reviews;
35
+		$this->pagination = $this->buildPagination();
36
+		parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
37
+	}
38 38
 
39
-    /**
40
-     * @return string
41
-     */
42
-    public function __toString()
43
-    {
44
-        return glsr(Template::class)->build('templates/reviews', [
45
-            'args' => $this->args,
46
-            'context' => [
47
-                'assigned_to' => $this->args['assigned_to'],
48
-                'category' => $this->args['category'],
49
-                'class' => $this->getClass(),
50
-                'id' => $this->args['id'],
51
-                'pagination' => $this->getPagination(),
52
-                'reviews' => $this->getReviews(),
53
-            ],
54
-        ]);
55
-    }
39
+	/**
40
+	 * @return string
41
+	 */
42
+	public function __toString()
43
+	{
44
+		return glsr(Template::class)->build('templates/reviews', [
45
+			'args' => $this->args,
46
+			'context' => [
47
+				'assigned_to' => $this->args['assigned_to'],
48
+				'category' => $this->args['category'],
49
+				'class' => $this->getClass(),
50
+				'id' => $this->args['id'],
51
+				'pagination' => $this->getPagination(),
52
+				'reviews' => $this->getReviews(),
53
+			],
54
+		]);
55
+	}
56 56
 
57
-    /**
58
-     * @return string
59
-     */
60
-    public function getPagination()
61
-    {
62
-        return wp_validate_boolean($this->args['pagination'])
63
-            ? $this->pagination
64
-            : '';
65
-    }
57
+	/**
58
+	 * @return string
59
+	 */
60
+	public function getPagination()
61
+	{
62
+		return wp_validate_boolean($this->args['pagination'])
63
+			? $this->pagination
64
+			: '';
65
+	}
66 66
 
67
-    /**
68
-     * @return string
69
-     */
70
-    public function getReviews()
71
-    {
72
-        $html = empty($this->reviews)
73
-            ? $this->getReviewsFallback()
74
-            : implode(PHP_EOL, $this->reviews);
75
-        $wrapper = '<div class="glsr-reviews">%s</div>';
76
-        $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
77
-        return sprintf($wrapper, $html);
78
-    }
67
+	/**
68
+	 * @return string
69
+	 */
70
+	public function getReviews()
71
+	{
72
+		$html = empty($this->reviews)
73
+			? $this->getReviewsFallback()
74
+			: implode(PHP_EOL, $this->reviews);
75
+		$wrapper = '<div class="glsr-reviews">%s</div>';
76
+		$wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
77
+		return sprintf($wrapper, $html);
78
+	}
79 79
 
80
-    /**
81
-     * @param mixed $key
82
-     * @return mixed
83
-     */
84
-    public function offsetGet($key)
85
-    {
86
-        if ('navigation' == $key) {
87
-            glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
88
-            return $this->pagination;
89
-        }
90
-        if (property_exists($this, $key)) {
91
-            return $this->$key;
92
-        }
93
-        return array_key_exists($key, $this->reviews)
94
-            ? $this->reviews[$key]
95
-            : null;
96
-    }
80
+	/**
81
+	 * @param mixed $key
82
+	 * @return mixed
83
+	 */
84
+	public function offsetGet($key)
85
+	{
86
+		if ('navigation' == $key) {
87
+			glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
88
+			return $this->pagination;
89
+		}
90
+		if (property_exists($this, $key)) {
91
+			return $this->$key;
92
+		}
93
+		return array_key_exists($key, $this->reviews)
94
+			? $this->reviews[$key]
95
+			: null;
96
+	}
97 97
 
98
-    /**
99
-     * @return string
100
-     */
101
-    protected function buildPagination()
102
-    {
103
-        $html = glsr(Partial::class)->build('pagination', [
104
-            'baseUrl' => glsr_get($this->args, 'pagedUrl'),
105
-            'current' => glsr_get($this->args, 'paged'),
106
-            'total' => $this->max_num_pages,
107
-        ]);
108
-        $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
109
-        $wrapper = '<div class="glsr-pagination">%s</div>';
110
-        $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
111
-        return sprintf($wrapper, $html);
112
-    }
98
+	/**
99
+	 * @return string
100
+	 */
101
+	protected function buildPagination()
102
+	{
103
+		$html = glsr(Partial::class)->build('pagination', [
104
+			'baseUrl' => glsr_get($this->args, 'pagedUrl'),
105
+			'current' => glsr_get($this->args, 'paged'),
106
+			'total' => $this->max_num_pages,
107
+		]);
108
+		$html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
109
+		$wrapper = '<div class="glsr-pagination">%s</div>';
110
+		$wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
111
+		return sprintf($wrapper, $html);
112
+	}
113 113
 
114
-    /**
115
-     * @return string
116
-     */
117
-    protected function getClass()
118
-    {
119
-        $defaults = [
120
-            'glsr-default',
121
-        ];
122
-        if ('ajax' == $this->args['pagination']) {
123
-            $defaults[] = 'glsr-ajax-pagination';
124
-        }
125
-        $classes = explode(' ', $this->args['class']);
126
-        $classes = array_unique(array_merge($defaults, array_filter($classes)));
127
-        return implode(' ', $classes);
128
-    }
114
+	/**
115
+	 * @return string
116
+	 */
117
+	protected function getClass()
118
+	{
119
+		$defaults = [
120
+			'glsr-default',
121
+		];
122
+		if ('ajax' == $this->args['pagination']) {
123
+			$defaults[] = 'glsr-ajax-pagination';
124
+		}
125
+		$classes = explode(' ', $this->args['class']);
126
+		$classes = array_unique(array_merge($defaults, array_filter($classes)));
127
+		return implode(' ', $classes);
128
+	}
129 129
 
130
-    /**
131
-     * @return string
132
-     */
133
-    protected function getReviewsFallback()
134
-    {
135
-        if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
136
-            $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
137
-        }
138
-        $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
139
-        return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
140
-    }
130
+	/**
131
+	 * @return string
132
+	 */
133
+	protected function getReviewsFallback()
134
+	{
135
+		if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
136
+			$this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
137
+		}
138
+		$fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
139
+		return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
140
+	}
141 141
 }
Please login to merge, or discard this patch.
plugin/Modules/System.php 1 patch
Indentation   +346 added lines, -346 removed lines patch added patch discarded remove patch
@@ -10,371 +10,371 @@
 block discarded – undo
10 10
 
11 11
 class System
12 12
 {
13
-    const PAD = 40;
13
+	const PAD = 40;
14 14
 
15
-    /**
16
-     * @return string
17
-     */
18
-    public function __toString()
19
-    {
20
-        return $this->get();
21
-    }
15
+	/**
16
+	 * @return string
17
+	 */
18
+	public function __toString()
19
+	{
20
+		return $this->get();
21
+	}
22 22
 
23
-    /**
24
-     * @return string
25
-     */
26
-    public function get()
27
-    {
28
-        $details = [
29
-            'plugin' => 'Plugin Details',
30
-            'addon' => 'Addon Details',
31
-            'browser' => 'Browser Details',
32
-            'server' => 'Server Details',
33
-            'php' => 'PHP Configuration',
34
-            'wordpress' => 'WordPress Configuration',
35
-            'mu-plugin' => 'Must-Use Plugins',
36
-            'multisite-plugin' => 'Network Active Plugins',
37
-            'active-plugin' => 'Active Plugins',
38
-            'inactive-plugin' => 'Inactive Plugins',
39
-            'setting' => 'Plugin Settings',
40
-            'reviews' => 'Review Counts',
41
-        ];
42
-        $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
43
-            $methodName = glsr(Helper::class)->buildMethodName('get-'.$key.'-details');
44
-            if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
45
-                return $carry.$this->implode(
46
-                    strtoupper($details[$key]),
47
-                    apply_filters('site-reviews/system/'.$key, $systemDetails)
48
-                );
49
-            }
50
-            return $carry;
51
-        });
52
-        return trim($systemInfo);
53
-    }
23
+	/**
24
+	 * @return string
25
+	 */
26
+	public function get()
27
+	{
28
+		$details = [
29
+			'plugin' => 'Plugin Details',
30
+			'addon' => 'Addon Details',
31
+			'browser' => 'Browser Details',
32
+			'server' => 'Server Details',
33
+			'php' => 'PHP Configuration',
34
+			'wordpress' => 'WordPress Configuration',
35
+			'mu-plugin' => 'Must-Use Plugins',
36
+			'multisite-plugin' => 'Network Active Plugins',
37
+			'active-plugin' => 'Active Plugins',
38
+			'inactive-plugin' => 'Inactive Plugins',
39
+			'setting' => 'Plugin Settings',
40
+			'reviews' => 'Review Counts',
41
+		];
42
+		$systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
43
+			$methodName = glsr(Helper::class)->buildMethodName('get-'.$key.'-details');
44
+			if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
45
+				return $carry.$this->implode(
46
+					strtoupper($details[$key]),
47
+					apply_filters('site-reviews/system/'.$key, $systemDetails)
48
+				);
49
+			}
50
+			return $carry;
51
+		});
52
+		return trim($systemInfo);
53
+	}
54 54
 
55
-    /**
56
-     * @return array
57
-     */
58
-    public function getActivePluginDetails()
59
-    {
60
-        $plugins = get_plugins();
61
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
62
-        $inactive = array_diff_key($plugins, array_flip($activePlugins));
63
-        return $this->normalizePluginList(array_diff_key($plugins, $inactive));
64
-    }
55
+	/**
56
+	 * @return array
57
+	 */
58
+	public function getActivePluginDetails()
59
+	{
60
+		$plugins = get_plugins();
61
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
62
+		$inactive = array_diff_key($plugins, array_flip($activePlugins));
63
+		return $this->normalizePluginList(array_diff_key($plugins, $inactive));
64
+	}
65 65
 
66
-    /**
67
-     * @return array
68
-     */
69
-    public function getAddonDetails()
70
-    {
71
-        $details = apply_filters('site-reviews/addon/system-info', []);
72
-        ksort($details);
73
-        return $details;
74
-    }
66
+	/**
67
+	 * @return array
68
+	 */
69
+	public function getAddonDetails()
70
+	{
71
+		$details = apply_filters('site-reviews/addon/system-info', []);
72
+		ksort($details);
73
+		return $details;
74
+	}
75 75
 
76
-    /**
77
-     * @return array
78
-     */
79
-    public function getBrowserDetails()
80
-    {
81
-        $browser = new Browser();
82
-        $name = esc_attr($browser->getName());
83
-        $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
84
-        $version = esc_attr($browser->getVersion());
85
-        return [
86
-            'Browser Name' => sprintf('%s %s', $name, $version),
87
-            'Browser UA' => $userAgent,
88
-        ];
89
-    }
76
+	/**
77
+	 * @return array
78
+	 */
79
+	public function getBrowserDetails()
80
+	{
81
+		$browser = new Browser();
82
+		$name = esc_attr($browser->getName());
83
+		$userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
84
+		$version = esc_attr($browser->getVersion());
85
+		return [
86
+			'Browser Name' => sprintf('%s %s', $name, $version),
87
+			'Browser UA' => $userAgent,
88
+		];
89
+	}
90 90
 
91
-    /**
92
-     * @return array
93
-     */
94
-    public function getInactivePluginDetails()
95
-    {
96
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
97
-        $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
98
-        $multisitePlugins = $this->getMultisitePluginDetails();
99
-        return empty($multisitePlugins)
100
-            ? $inactivePlugins
101
-            : array_diff($inactivePlugins, $multisitePlugins);
102
-    }
91
+	/**
92
+	 * @return array
93
+	 */
94
+	public function getInactivePluginDetails()
95
+	{
96
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
97
+		$inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
98
+		$multisitePlugins = $this->getMultisitePluginDetails();
99
+		return empty($multisitePlugins)
100
+			? $inactivePlugins
101
+			: array_diff($inactivePlugins, $multisitePlugins);
102
+	}
103 103
 
104
-    /**
105
-     * @return array
106
-     */
107
-    public function getMuPluginDetails()
108
-    {
109
-        if (empty($plugins = get_mu_plugins())) {
110
-            return [];
111
-        }
112
-        return $this->normalizePluginList($plugins);
113
-    }
104
+	/**
105
+	 * @return array
106
+	 */
107
+	public function getMuPluginDetails()
108
+	{
109
+		if (empty($plugins = get_mu_plugins())) {
110
+			return [];
111
+		}
112
+		return $this->normalizePluginList($plugins);
113
+	}
114 114
 
115
-    /**
116
-     * @return array
117
-     */
118
-    public function getMultisitePluginDetails()
119
-    {
120
-        $activePlugins = (array) get_site_option('active_sitewide_plugins', []);
121
-        if (!is_multisite() || empty($activePlugins)) {
122
-            return [];
123
-        }
124
-        return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
125
-    }
115
+	/**
116
+	 * @return array
117
+	 */
118
+	public function getMultisitePluginDetails()
119
+	{
120
+		$activePlugins = (array) get_site_option('active_sitewide_plugins', []);
121
+		if (!is_multisite() || empty($activePlugins)) {
122
+			return [];
123
+		}
124
+		return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
125
+	}
126 126
 
127
-    /**
128
-     * @return array
129
-     */
130
-    public function getPhpDetails()
131
-    {
132
-        $displayErrors = ini_get('display_errors')
133
-            ? 'On ('.ini_get('display_errors').')'
134
-            : 'N/A';
135
-        $intlSupport = extension_loaded('intl')
136
-            ? phpversion('intl')
137
-            : 'false';
138
-        return [
139
-            'cURL' => var_export(function_exists('curl_init'), true),
140
-            'Default Charset' => ini_get('default_charset'),
141
-            'Display Errors' => $displayErrors,
142
-            'fsockopen' => var_export(function_exists('fsockopen'), true),
143
-            'Intl' => $intlSupport,
144
-            'IPv6' => var_export(defined('AF_INET6'), true),
145
-            'Max Execution Time' => ini_get('max_execution_time'),
146
-            'Max Input Nesting Level' => ini_get('max_input_nesting_level'),
147
-            'Max Input Vars' => ini_get('max_input_vars'),
148
-            'Memory Limit' => ini_get('memory_limit'),
149
-            'Post Max Size' => ini_get('post_max_size'),
150
-            'Sendmail Path' => ini_get('sendmail_path'),
151
-            'Session Cookie Path' => esc_html(ini_get('session.cookie_path')),
152
-            'Session Name' => esc_html(ini_get('session.name')),
153
-            'Session Save Path' => esc_html(ini_get('session.save_path')),
154
-            'Session Use Cookies' => var_export(wp_validate_boolean(ini_get('session.use_cookies')), true),
155
-            'Session Use Only Cookies' => var_export(wp_validate_boolean(ini_get('session.use_only_cookies')), true),
156
-            'Upload Max Filesize' => ini_get('upload_max_filesize'),
157
-        ];
158
-    }
127
+	/**
128
+	 * @return array
129
+	 */
130
+	public function getPhpDetails()
131
+	{
132
+		$displayErrors = ini_get('display_errors')
133
+			? 'On ('.ini_get('display_errors').')'
134
+			: 'N/A';
135
+		$intlSupport = extension_loaded('intl')
136
+			? phpversion('intl')
137
+			: 'false';
138
+		return [
139
+			'cURL' => var_export(function_exists('curl_init'), true),
140
+			'Default Charset' => ini_get('default_charset'),
141
+			'Display Errors' => $displayErrors,
142
+			'fsockopen' => var_export(function_exists('fsockopen'), true),
143
+			'Intl' => $intlSupport,
144
+			'IPv6' => var_export(defined('AF_INET6'), true),
145
+			'Max Execution Time' => ini_get('max_execution_time'),
146
+			'Max Input Nesting Level' => ini_get('max_input_nesting_level'),
147
+			'Max Input Vars' => ini_get('max_input_vars'),
148
+			'Memory Limit' => ini_get('memory_limit'),
149
+			'Post Max Size' => ini_get('post_max_size'),
150
+			'Sendmail Path' => ini_get('sendmail_path'),
151
+			'Session Cookie Path' => esc_html(ini_get('session.cookie_path')),
152
+			'Session Name' => esc_html(ini_get('session.name')),
153
+			'Session Save Path' => esc_html(ini_get('session.save_path')),
154
+			'Session Use Cookies' => var_export(wp_validate_boolean(ini_get('session.use_cookies')), true),
155
+			'Session Use Only Cookies' => var_export(wp_validate_boolean(ini_get('session.use_only_cookies')), true),
156
+			'Upload Max Filesize' => ini_get('upload_max_filesize'),
157
+		];
158
+	}
159 159
 
160
-    /**
161
-     * @return array
162
-     */
163
-    public function getReviewsDetails()
164
-    {
165
-        $counts = glsr(CountsManager::class)->getCounts();
166
-        $counts = glsr(Helper::class)->flattenArray($counts);
167
-        array_walk($counts, function (&$ratings) use ($counts) {
168
-            if (!is_array($ratings)) {
169
-                glsr_log()
170
-                    ->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
171
-                    ->debug($ratings)
172
-                    ->debug($counts);
173
-                return;
174
-            }
175
-            $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
176
-        });
177
-        ksort($counts);
178
-        return $counts;
179
-    }
160
+	/**
161
+	 * @return array
162
+	 */
163
+	public function getReviewsDetails()
164
+	{
165
+		$counts = glsr(CountsManager::class)->getCounts();
166
+		$counts = glsr(Helper::class)->flattenArray($counts);
167
+		array_walk($counts, function (&$ratings) use ($counts) {
168
+			if (!is_array($ratings)) {
169
+				glsr_log()
170
+					->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
171
+					->debug($ratings)
172
+					->debug($counts);
173
+				return;
174
+			}
175
+			$ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
176
+		});
177
+		ksort($counts);
178
+		return $counts;
179
+	}
180 180
 
181
-    /**
182
-     * @return array
183
-     */
184
-    public function getServerDetails()
185
-    {
186
-        global $wpdb;
187
-        return [
188
-            'Host Name' => $this->getHostName(),
189
-            'MySQL Version' => $wpdb->db_version(),
190
-            'PHP Version' => PHP_VERSION,
191
-            'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
192
-        ];
193
-    }
181
+	/**
182
+	 * @return array
183
+	 */
184
+	public function getServerDetails()
185
+	{
186
+		global $wpdb;
187
+		return [
188
+			'Host Name' => $this->getHostName(),
189
+			'MySQL Version' => $wpdb->db_version(),
190
+			'PHP Version' => PHP_VERSION,
191
+			'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
192
+		];
193
+	}
194 194
 
195
-    /**
196
-     * @return array
197
-     */
198
-    public function getSettingDetails()
199
-    {
200
-        $helper = glsr(Helper::class);
201
-        $settings = glsr(OptionManager::class)->get('settings', []);
202
-        $settings = $helper->flattenArray($settings, true);
203
-        $settings = $this->purgeSensitiveData($settings);
204
-        ksort($settings);
205
-        $details = [];
206
-        foreach ($settings as $key => $value) {
207
-            if ($helper->startsWith('strings', $key) && $helper->endsWith('id', $key)) {
208
-                continue;
209
-            }
210
-            $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
211
-            $details[$key] = $value;
212
-        }
213
-        return $details;
214
-    }
195
+	/**
196
+	 * @return array
197
+	 */
198
+	public function getSettingDetails()
199
+	{
200
+		$helper = glsr(Helper::class);
201
+		$settings = glsr(OptionManager::class)->get('settings', []);
202
+		$settings = $helper->flattenArray($settings, true);
203
+		$settings = $this->purgeSensitiveData($settings);
204
+		ksort($settings);
205
+		$details = [];
206
+		foreach ($settings as $key => $value) {
207
+			if ($helper->startsWith('strings', $key) && $helper->endsWith('id', $key)) {
208
+				continue;
209
+			}
210
+			$value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
211
+			$details[$key] = $value;
212
+		}
213
+		return $details;
214
+	}
215 215
 
216
-    /**
217
-     * @return array
218
-     */
219
-    public function getPluginDetails()
220
-    {
221
-        return [
222
-            'Console level' => glsr(Console::class)->humanLevel(),
223
-            'Console size' => glsr(Console::class)->humanSize('0'),
224
-            'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
225
-            'Version (current)' => glsr()->version,
226
-            'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
227
-        ];
228
-    }
216
+	/**
217
+	 * @return array
218
+	 */
219
+	public function getPluginDetails()
220
+	{
221
+		return [
222
+			'Console level' => glsr(Console::class)->humanLevel(),
223
+			'Console size' => glsr(Console::class)->humanSize('0'),
224
+			'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
225
+			'Version (current)' => glsr()->version,
226
+			'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
227
+		];
228
+	}
229 229
 
230
-    /**
231
-     * @return array
232
-     */
233
-    public function getWordpressDetails()
234
-    {
235
-        global $wpdb;
236
-        $theme = wp_get_theme();
237
-        return [
238
-            'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
239
-            'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
240
-            'Home URL' => home_url(),
241
-            'Language' => get_locale(),
242
-            'Memory Limit' => WP_MEMORY_LIMIT,
243
-            'Multisite' => var_export(is_multisite(), true),
244
-            'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
245
-            'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
246
-            'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
247
-            'Post Stati' => implode(', ', get_post_stati()),
248
-            'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
249
-            'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
250
-            'Site URL' => site_url(),
251
-            'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', ini_get('date.timezone').' (PHP)'),
252
-            'Version' => get_bloginfo('version'),
253
-            'WP Debug' => var_export(defined('WP_DEBUG'), true),
254
-            'WP Max Upload Size' => size_format(wp_max_upload_size()),
255
-            'WP Memory Limit' => WP_MEMORY_LIMIT,
256
-        ];
257
-    }
230
+	/**
231
+	 * @return array
232
+	 */
233
+	public function getWordpressDetails()
234
+	{
235
+		global $wpdb;
236
+		$theme = wp_get_theme();
237
+		return [
238
+			'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
239
+			'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
240
+			'Home URL' => home_url(),
241
+			'Language' => get_locale(),
242
+			'Memory Limit' => WP_MEMORY_LIMIT,
243
+			'Multisite' => var_export(is_multisite(), true),
244
+			'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
245
+			'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
246
+			'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
247
+			'Post Stati' => implode(', ', get_post_stati()),
248
+			'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
249
+			'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
250
+			'Site URL' => site_url(),
251
+			'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', ini_get('date.timezone').' (PHP)'),
252
+			'Version' => get_bloginfo('version'),
253
+			'WP Debug' => var_export(defined('WP_DEBUG'), true),
254
+			'WP Max Upload Size' => size_format(wp_max_upload_size()),
255
+			'WP Memory Limit' => WP_MEMORY_LIMIT,
256
+		];
257
+	}
258 258
 
259
-    /**
260
-     * @return string
261
-     */
262
-    protected function detectWebhostProvider()
263
-    {
264
-        $checks = [
265
-            '.accountservergroup.com' => 'Site5',
266
-            '.gridserver.com' => 'MediaTemple Grid',
267
-            '.inmotionhosting.com' => 'InMotion Hosting',
268
-            '.ovh.net' => 'OVH',
269
-            '.pair.com' => 'pair Networks',
270
-            '.stabletransit.com' => 'Rackspace Cloud',
271
-            '.stratoserver.net' => 'STRATO',
272
-            '.sysfix.eu' => 'SysFix.eu Power Hosting',
273
-            'bluehost.com' => 'Bluehost',
274
-            'DH_USER' => 'DreamHost',
275
-            'Flywheel' => 'Flywheel',
276
-            'ipagemysql.com' => 'iPage',
277
-            'ipowermysql.com' => 'IPower',
278
-            'localhost:/tmp/mysql5.sock' => 'ICDSoft',
279
-            'mysqlv5' => 'NetworkSolutions',
280
-            'PAGELYBIN' => 'Pagely',
281
-            'secureserver.net' => 'GoDaddy',
282
-            'WPE_APIKEY' => 'WP Engine',
283
-        ];
284
-        foreach ($checks as $key => $value) {
285
-            if (!$this->isWebhostCheckValid($key)) {
286
-                continue;
287
-            }
288
-            return $value;
289
-        }
290
-        return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
291
-    }
259
+	/**
260
+	 * @return string
261
+	 */
262
+	protected function detectWebhostProvider()
263
+	{
264
+		$checks = [
265
+			'.accountservergroup.com' => 'Site5',
266
+			'.gridserver.com' => 'MediaTemple Grid',
267
+			'.inmotionhosting.com' => 'InMotion Hosting',
268
+			'.ovh.net' => 'OVH',
269
+			'.pair.com' => 'pair Networks',
270
+			'.stabletransit.com' => 'Rackspace Cloud',
271
+			'.stratoserver.net' => 'STRATO',
272
+			'.sysfix.eu' => 'SysFix.eu Power Hosting',
273
+			'bluehost.com' => 'Bluehost',
274
+			'DH_USER' => 'DreamHost',
275
+			'Flywheel' => 'Flywheel',
276
+			'ipagemysql.com' => 'iPage',
277
+			'ipowermysql.com' => 'IPower',
278
+			'localhost:/tmp/mysql5.sock' => 'ICDSoft',
279
+			'mysqlv5' => 'NetworkSolutions',
280
+			'PAGELYBIN' => 'Pagely',
281
+			'secureserver.net' => 'GoDaddy',
282
+			'WPE_APIKEY' => 'WP Engine',
283
+		];
284
+		foreach ($checks as $key => $value) {
285
+			if (!$this->isWebhostCheckValid($key)) {
286
+				continue;
287
+			}
288
+			return $value;
289
+		}
290
+		return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
291
+	}
292 292
 
293
-    /**
294
-     * @return string
295
-     */
296
-    protected function getHostName()
297
-    {
298
-        return sprintf('%s (%s)',
299
-            $this->detectWebhostProvider(),
300
-            glsr(Helper::class)->getIpAddress()
301
-        );
302
-    }
293
+	/**
294
+	 * @return string
295
+	 */
296
+	protected function getHostName()
297
+	{
298
+		return sprintf('%s (%s)',
299
+			$this->detectWebhostProvider(),
300
+			glsr(Helper::class)->getIpAddress()
301
+		);
302
+	}
303 303
 
304
-    /**
305
-     * @return array
306
-     */
307
-    protected function getWordpressPlugins()
308
-    {
309
-        $plugins = get_plugins();
310
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
311
-        $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
312
-        $active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
313
-        return $active + $inactive;
314
-    }
304
+	/**
305
+	 * @return array
306
+	 */
307
+	protected function getWordpressPlugins()
308
+	{
309
+		$plugins = get_plugins();
310
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
311
+		$inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
312
+		$active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
313
+		return $active + $inactive;
314
+	}
315 315
 
316
-    /**
317
-     * @param string $title
318
-     * @return string
319
-     */
320
-    protected function implode($title, array $details)
321
-    {
322
-        $strings = ['['.$title.']'];
323
-        $padding = max(array_map('strlen', array_keys($details)));
324
-        $padding = max([$padding, static::PAD]);
325
-        foreach ($details as $key => $value) {
326
-            $strings[] = is_string($key)
327
-                ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
328
-                : ' - '.$value;
329
-        }
330
-        return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
331
-    }
316
+	/**
317
+	 * @param string $title
318
+	 * @return string
319
+	 */
320
+	protected function implode($title, array $details)
321
+	{
322
+		$strings = ['['.$title.']'];
323
+		$padding = max(array_map('strlen', array_keys($details)));
324
+		$padding = max([$padding, static::PAD]);
325
+		foreach ($details as $key => $value) {
326
+			$strings[] = is_string($key)
327
+				? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
328
+				: ' - '.$value;
329
+		}
330
+		return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
331
+	}
332 332
 
333
-    /**
334
-     * @param string $key
335
-     * @return bool
336
-     */
337
-    protected function isWebhostCheckValid($key)
338
-    {
339
-        return defined($key)
340
-            || filter_input(INPUT_SERVER, $key)
341
-            || false !== strpos(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
342
-            || false !== strpos(DB_HOST, $key)
343
-            || false !== strpos(php_uname(), $key);
344
-    }
333
+	/**
334
+	 * @param string $key
335
+	 * @return bool
336
+	 */
337
+	protected function isWebhostCheckValid($key)
338
+	{
339
+		return defined($key)
340
+			|| filter_input(INPUT_SERVER, $key)
341
+			|| false !== strpos(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
342
+			|| false !== strpos(DB_HOST, $key)
343
+			|| false !== strpos(php_uname(), $key);
344
+	}
345 345
 
346
-    /**
347
-     * @return array
348
-     */
349
-    protected function normalizePluginList(array $plugins)
350
-    {
351
-        $plugins = array_map(function ($plugin) {
352
-            return sprintf('%s v%s', glsr_get($plugin, 'Name'), glsr_get($plugin, 'Version'));
353
-        }, $plugins);
354
-        natcasesort($plugins);
355
-        return array_flip($plugins);
356
-    }
346
+	/**
347
+	 * @return array
348
+	 */
349
+	protected function normalizePluginList(array $plugins)
350
+	{
351
+		$plugins = array_map(function ($plugin) {
352
+			return sprintf('%s v%s', glsr_get($plugin, 'Name'), glsr_get($plugin, 'Version'));
353
+		}, $plugins);
354
+		natcasesort($plugins);
355
+		return array_flip($plugins);
356
+	}
357 357
 
358
-    /**
359
-     * @return array
360
-     */
361
-    protected function purgeSensitiveData(array $settings)
362
-    {
363
-        $keys = [
364
-            'general.rebusify_serial',
365
-            'licenses.',
366
-            'submissions.recaptcha.key',
367
-            'submissions.recaptcha.secret',
368
-        ];
369
-        array_walk($settings, function (&$value, $setting) use ($keys) {
370
-            foreach ($keys as $key) {
371
-                if (!glsr(Helper::class)->startsWith($key, $setting) || empty($value)) {
372
-                    continue;
373
-                }
374
-                $value = str_repeat('•', 13);
375
-                return;
376
-            }
377
-        });
378
-        return $settings;
379
-    }
358
+	/**
359
+	 * @return array
360
+	 */
361
+	protected function purgeSensitiveData(array $settings)
362
+	{
363
+		$keys = [
364
+			'general.rebusify_serial',
365
+			'licenses.',
366
+			'submissions.recaptcha.key',
367
+			'submissions.recaptcha.secret',
368
+		];
369
+		array_walk($settings, function (&$value, $setting) use ($keys) {
370
+			foreach ($keys as $key) {
371
+				if (!glsr(Helper::class)->startsWith($key, $setting) || empty($value)) {
372
+					continue;
373
+				}
374
+				$value = str_repeat('•', 13);
375
+				return;
376
+			}
377
+		});
378
+		return $settings;
379
+	}
380 380
 }
Please login to merge, or discard this patch.