Passed
Push — master ( ff717e...ba0f3b )
by Paul
08:41 queued 04:33
created
plugin/Widgets/SiteReviewsFormWidget.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -7,55 +7,55 @@
 block discarded – undo
7 7
 
8 8
 class SiteReviewsFormWidget extends Widget
9 9
 {
10
-    /**
11
-     * @param array $instance
12
-     * @return void
13
-     */
14
-    public function form($instance)
15
-    {
16
-        $this->widgetArgs = glsr(SiteReviewsFormShortcode::class)->normalizeAtts($instance);
17
-        $terms = glsr(Database::class)->getTerms();
18
-        $this->renderField('text', [
19
-            'class' => 'widefat',
20
-            'label' => __('Title', 'site-reviews'),
21
-            'name' => 'title',
22
-        ]);
23
-        $this->renderField('textarea', [
24
-            'class' => 'widefat',
25
-            'label' => __('Description', 'site-reviews'),
26
-            'name' => 'description',
27
-        ]);
28
-        $this->renderField('select', [
29
-            'class' => 'widefat',
30
-            'label' => __('Automatically assign a category', 'site-reviews'),
31
-            'name' => 'category',
32
-            'options' => ['' => __('Do not assign a category', 'site-reviews')] + $terms,
33
-        ]);
34
-        $this->renderField('text', [
35
-            'class' => 'widefat',
36
-            'default' => '',
37
-            'description' => sprintf(__('You may also enter %s to assign to the current post.', 'site-reviews'), '<code>post_id</code>'),
38
-            'label' => __('Assign reviews to a custom page/post ID', 'site-reviews'),
39
-            'name' => 'assign_to',
40
-        ]);
41
-        $this->renderField('text', [
42
-            'class' => 'widefat',
43
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
44
-            'name' => 'class',
45
-        ]);
46
-        $this->renderField('checkbox', [
47
-            'name' => 'hide',
48
-            'options' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(),
49
-        ]);
50
-    }
10
+	/**
11
+	 * @param array $instance
12
+	 * @return void
13
+	 */
14
+	public function form($instance)
15
+	{
16
+		$this->widgetArgs = glsr(SiteReviewsFormShortcode::class)->normalizeAtts($instance);
17
+		$terms = glsr(Database::class)->getTerms();
18
+		$this->renderField('text', [
19
+			'class' => 'widefat',
20
+			'label' => __('Title', 'site-reviews'),
21
+			'name' => 'title',
22
+		]);
23
+		$this->renderField('textarea', [
24
+			'class' => 'widefat',
25
+			'label' => __('Description', 'site-reviews'),
26
+			'name' => 'description',
27
+		]);
28
+		$this->renderField('select', [
29
+			'class' => 'widefat',
30
+			'label' => __('Automatically assign a category', 'site-reviews'),
31
+			'name' => 'category',
32
+			'options' => ['' => __('Do not assign a category', 'site-reviews')] + $terms,
33
+		]);
34
+		$this->renderField('text', [
35
+			'class' => 'widefat',
36
+			'default' => '',
37
+			'description' => sprintf(__('You may also enter %s to assign to the current post.', 'site-reviews'), '<code>post_id</code>'),
38
+			'label' => __('Assign reviews to a custom page/post ID', 'site-reviews'),
39
+			'name' => 'assign_to',
40
+		]);
41
+		$this->renderField('text', [
42
+			'class' => 'widefat',
43
+			'label' => __('Enter any custom CSS classes here', 'site-reviews'),
44
+			'name' => 'class',
45
+		]);
46
+		$this->renderField('checkbox', [
47
+			'name' => 'hide',
48
+			'options' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(),
49
+		]);
50
+	}
51 51
 
52
-    /**
53
-     * @param array $args
54
-     * @param array $instance
55
-     * @return void
56
-     */
57
-    public function widget($args, $instance)
58
-    {
59
-        echo glsr(SiteReviewsFormShortcode::class)->build($instance, $args, 'widget');
60
-    }
52
+	/**
53
+	 * @param array $args
54
+	 * @param array $instance
55
+	 * @return void
56
+	 */
57
+	public function widget($args, $instance)
58
+	{
59
+		echo glsr(SiteReviewsFormShortcode::class)->build($instance, $args, 'widget');
60
+	}
61 61
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,42 +11,42 @@  discard block
 block discarded – undo
11 11
      * @param array $instance
12 12
      * @return void
13 13
      */
14
-    public function form($instance)
14
+    public function form( $instance )
15 15
     {
16
-        $this->widgetArgs = glsr(SiteReviewsFormShortcode::class)->normalizeAtts($instance);
17
-        $terms = glsr(Database::class)->getTerms();
18
-        $this->renderField('text', [
16
+        $this->widgetArgs = glsr( SiteReviewsFormShortcode::class )->normalizeAtts( $instance );
17
+        $terms = glsr( Database::class )->getTerms();
18
+        $this->renderField( 'text', [
19 19
             'class' => 'widefat',
20
-            'label' => __('Title', 'site-reviews'),
20
+            'label' => __( 'Title', 'site-reviews' ),
21 21
             'name' => 'title',
22
-        ]);
23
-        $this->renderField('textarea', [
22
+        ] );
23
+        $this->renderField( 'textarea', [
24 24
             'class' => 'widefat',
25
-            'label' => __('Description', 'site-reviews'),
25
+            'label' => __( 'Description', 'site-reviews' ),
26 26
             'name' => 'description',
27
-        ]);
28
-        $this->renderField('select', [
27
+        ] );
28
+        $this->renderField( 'select', [
29 29
             'class' => 'widefat',
30
-            'label' => __('Automatically assign a category', 'site-reviews'),
30
+            'label' => __( 'Automatically assign a category', 'site-reviews' ),
31 31
             'name' => 'category',
32
-            'options' => ['' => __('Do not assign a category', 'site-reviews')] + $terms,
33
-        ]);
34
-        $this->renderField('text', [
32
+            'options' => ['' => __( 'Do not assign a category', 'site-reviews' )] + $terms,
33
+        ] );
34
+        $this->renderField( 'text', [
35 35
             'class' => 'widefat',
36 36
             'default' => '',
37
-            'description' => sprintf(__('You may also enter %s to assign to the current post.', 'site-reviews'), '<code>post_id</code>'),
38
-            'label' => __('Assign reviews to a custom page/post ID', 'site-reviews'),
37
+            'description' => sprintf( __( 'You may also enter %s to assign to the current post.', 'site-reviews' ), '<code>post_id</code>' ),
38
+            'label' => __( 'Assign reviews to a custom page/post ID', 'site-reviews' ),
39 39
             'name' => 'assign_to',
40
-        ]);
41
-        $this->renderField('text', [
40
+        ] );
41
+        $this->renderField( 'text', [
42 42
             'class' => 'widefat',
43
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
43
+            'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ),
44 44
             'name' => 'class',
45
-        ]);
46
-        $this->renderField('checkbox', [
45
+        ] );
46
+        $this->renderField( 'checkbox', [
47 47
             'name' => 'hide',
48
-            'options' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(),
49
-        ]);
48
+            'options' => glsr( SiteReviewsFormShortcode::class )->getHideOptions(),
49
+        ] );
50 50
     }
51 51
 
52 52
     /**
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
      * @param array $instance
55 55
      * @return void
56 56
      */
57
-    public function widget($args, $instance)
57
+    public function widget( $args, $instance )
58 58
     {
59
-        echo glsr(SiteReviewsFormShortcode::class)->build($instance, $args, 'widget');
59
+        echo glsr( SiteReviewsFormShortcode::class )->build( $instance, $args, 'widget' );
60 60
     }
61 61
 }
Please login to merge, or discard this patch.
plugin/Widgets/SiteReviewsSummaryWidget.php 2 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -7,60 +7,60 @@
 block discarded – undo
7 7
 
8 8
 class SiteReviewsSummaryWidget extends Widget
9 9
 {
10
-    /**
11
-     * @param array $instance
12
-     * @return void
13
-     */
14
-    public function form($instance)
15
-    {
16
-        $this->widgetArgs = glsr(SiteReviewsSummaryShortcode::class)->normalizeAtts($instance);
17
-        $terms = glsr(Database::class)->getTerms();
18
-        $this->renderField('text', [
19
-            'class' => 'widefat',
20
-            'label' => __('Title', 'site-reviews'),
21
-            'name' => 'title',
22
-        ]);
23
-        if (count(glsr()->reviewTypes) > 1) {
24
-            $this->renderField('select', [
25
-                'class' => 'widefat',
26
-                'label' => __('Which type of review would you like to use?', 'site-reviews'),
27
-                'name' => 'type',
28
-                'options' => ['' => __('All review types', 'site-reviews')] + glsr()->reviewTypes,
29
-            ]);
30
-        }
31
-        if (!empty($terms)) {
32
-            $this->renderField('select', [
33
-                'class' => 'widefat',
34
-                'label' => __('Limit summary to this category', 'site-reviews'),
35
-                'name' => 'category',
36
-                'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
37
-            ]);
38
-        }
39
-        $this->renderField('text', [
40
-            'class' => 'widefat',
41
-            'default' => '',
42
-            'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
43
-            'label' => __('Limit summary to reviews assigned to a page/post ID', 'site-reviews'),
44
-            'name' => 'assigned_to',
45
-        ]);
46
-        $this->renderField('text', [
47
-            'class' => 'widefat',
48
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
49
-            'name' => 'class',
50
-        ]);
51
-        $this->renderField('checkbox', [
52
-            'name' => 'hide',
53
-            'options' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(),
54
-        ]);
55
-    }
10
+	/**
11
+	 * @param array $instance
12
+	 * @return void
13
+	 */
14
+	public function form($instance)
15
+	{
16
+		$this->widgetArgs = glsr(SiteReviewsSummaryShortcode::class)->normalizeAtts($instance);
17
+		$terms = glsr(Database::class)->getTerms();
18
+		$this->renderField('text', [
19
+			'class' => 'widefat',
20
+			'label' => __('Title', 'site-reviews'),
21
+			'name' => 'title',
22
+		]);
23
+		if (count(glsr()->reviewTypes) > 1) {
24
+			$this->renderField('select', [
25
+				'class' => 'widefat',
26
+				'label' => __('Which type of review would you like to use?', 'site-reviews'),
27
+				'name' => 'type',
28
+				'options' => ['' => __('All review types', 'site-reviews')] + glsr()->reviewTypes,
29
+			]);
30
+		}
31
+		if (!empty($terms)) {
32
+			$this->renderField('select', [
33
+				'class' => 'widefat',
34
+				'label' => __('Limit summary to this category', 'site-reviews'),
35
+				'name' => 'category',
36
+				'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
37
+			]);
38
+		}
39
+		$this->renderField('text', [
40
+			'class' => 'widefat',
41
+			'default' => '',
42
+			'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
43
+			'label' => __('Limit summary to reviews assigned to a page/post ID', 'site-reviews'),
44
+			'name' => 'assigned_to',
45
+		]);
46
+		$this->renderField('text', [
47
+			'class' => 'widefat',
48
+			'label' => __('Enter any custom CSS classes here', 'site-reviews'),
49
+			'name' => 'class',
50
+		]);
51
+		$this->renderField('checkbox', [
52
+			'name' => 'hide',
53
+			'options' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(),
54
+		]);
55
+	}
56 56
 
57
-    /**
58
-     * @param array $args
59
-     * @param array $instance
60
-     * @return void
61
-     */
62
-    public function widget($args, $instance)
63
-    {
64
-        echo glsr(SiteReviewsSummaryShortcode::class)->build($instance, $args, 'widget');
65
-    }
57
+	/**
58
+	 * @param array $args
59
+	 * @param array $instance
60
+	 * @return void
61
+	 */
62
+	public function widget($args, $instance)
63
+	{
64
+		echo glsr(SiteReviewsSummaryShortcode::class)->build($instance, $args, 'widget');
65
+	}
66 66
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -11,47 +11,47 @@  discard block
 block discarded – undo
11 11
      * @param array $instance
12 12
      * @return void
13 13
      */
14
-    public function form($instance)
14
+    public function form( $instance )
15 15
     {
16
-        $this->widgetArgs = glsr(SiteReviewsSummaryShortcode::class)->normalizeAtts($instance);
17
-        $terms = glsr(Database::class)->getTerms();
18
-        $this->renderField('text', [
16
+        $this->widgetArgs = glsr( SiteReviewsSummaryShortcode::class )->normalizeAtts( $instance );
17
+        $terms = glsr( Database::class )->getTerms();
18
+        $this->renderField( 'text', [
19 19
             'class' => 'widefat',
20
-            'label' => __('Title', 'site-reviews'),
20
+            'label' => __( 'Title', 'site-reviews' ),
21 21
             'name' => 'title',
22
-        ]);
23
-        if (count(glsr()->reviewTypes) > 1) {
24
-            $this->renderField('select', [
22
+        ] );
23
+        if( count( glsr()->reviewTypes ) > 1 ) {
24
+            $this->renderField( 'select', [
25 25
                 'class' => 'widefat',
26
-                'label' => __('Which type of review would you like to use?', 'site-reviews'),
26
+                'label' => __( 'Which type of review would you like to use?', 'site-reviews' ),
27 27
                 'name' => 'type',
28
-                'options' => ['' => __('All review types', 'site-reviews')] + glsr()->reviewTypes,
29
-            ]);
28
+                'options' => ['' => __( 'All review types', 'site-reviews' )] + glsr()->reviewTypes,
29
+            ] );
30 30
         }
31
-        if (!empty($terms)) {
32
-            $this->renderField('select', [
31
+        if( !empty($terms) ) {
32
+            $this->renderField( 'select', [
33 33
                 'class' => 'widefat',
34
-                'label' => __('Limit summary to this category', 'site-reviews'),
34
+                'label' => __( 'Limit summary to this category', 'site-reviews' ),
35 35
                 'name' => 'category',
36
-                'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
37
-            ]);
36
+                'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms,
37
+            ] );
38 38
         }
39
-        $this->renderField('text', [
39
+        $this->renderField( 'text', [
40 40
             'class' => 'widefat',
41 41
             'default' => '',
42
-            'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
43
-            'label' => __('Limit summary to reviews assigned to a page/post ID', 'site-reviews'),
42
+            'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ),
43
+            'label' => __( 'Limit summary to reviews assigned to a page/post ID', 'site-reviews' ),
44 44
             'name' => 'assigned_to',
45
-        ]);
46
-        $this->renderField('text', [
45
+        ] );
46
+        $this->renderField( 'text', [
47 47
             'class' => 'widefat',
48
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
48
+            'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ),
49 49
             'name' => 'class',
50
-        ]);
51
-        $this->renderField('checkbox', [
50
+        ] );
51
+        $this->renderField( 'checkbox', [
52 52
             'name' => 'hide',
53
-            'options' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(),
54
-        ]);
53
+            'options' => glsr( SiteReviewsSummaryShortcode::class )->getHideOptions(),
54
+        ] );
55 55
     }
56 56
 
57 57
     /**
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
      * @param array $instance
60 60
      * @return void
61 61
      */
62
-    public function widget($args, $instance)
62
+    public function widget( $args, $instance )
63 63
     {
64
-        echo glsr(SiteReviewsSummaryShortcode::class)->build($instance, $args, 'widget');
64
+        echo glsr( SiteReviewsSummaryShortcode::class )->build( $instance, $args, 'widget' );
65 65
     }
66 66
 }
Please login to merge, or discard this patch.
plugin/Modules/Html/Fields/Button.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@
 block discarded – undo
4 4
 
5 5
 class Button extends Field
6 6
 {
7
-    /**
8
-     * @return array
9
-     */
10
-    public static function defaults()
11
-    {
12
-        return [
13
-            'class' => 'button',
14
-        ];
15
-    }
7
+	/**
8
+	 * @return array
9
+	 */
10
+	public static function defaults()
11
+	{
12
+		return [
13
+			'class' => 'button',
14
+		];
15
+	}
16 16
 }
Please login to merge, or discard this patch.
plugin/Controllers/EditorController/Labels.php 2 patches
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -7,123 +7,123 @@
 block discarded – undo
7 7
 
8 8
 class Labels
9 9
 {
10
-    /**
11
-     * @return void
12
-     */
13
-    public function customizePostStatusLabels()
14
-    {
15
-        global $wp_scripts;
16
-        $strings = [
17
-            'savePending' => __('Save as Unapproved', 'site-reviews'),
18
-            'published' => __('Approved', 'site-reviews'),
19
-        ];
20
-        if ($this->canModifyTranslation() && isset($wp_scripts->registered['post']->extra['data'])) {
21
-            $l10n = &$wp_scripts->registered['post']->extra['data'];
22
-            foreach ($strings as $search => $replace) {
23
-                $l10n = preg_replace('/("'.$search.'":")([^"]+)/', '$1'.$replace, $l10n);
24
-            }
25
-        }
26
-    }
10
+	/**
11
+	 * @return void
12
+	 */
13
+	public function customizePostStatusLabels()
14
+	{
15
+		global $wp_scripts;
16
+		$strings = [
17
+			'savePending' => __('Save as Unapproved', 'site-reviews'),
18
+			'published' => __('Approved', 'site-reviews'),
19
+		];
20
+		if ($this->canModifyTranslation() && isset($wp_scripts->registered['post']->extra['data'])) {
21
+			$l10n = &$wp_scripts->registered['post']->extra['data'];
22
+			foreach ($strings as $search => $replace) {
23
+				$l10n = preg_replace('/("'.$search.'":")([^"]+)/', '$1'.$replace, $l10n);
24
+			}
25
+		}
26
+	}
27 27
 
28
-    /**
29
-     * @param string $translation
30
-     * @param string $test
31
-     * @param string $domain
32
-     * @return string
33
-     */
34
-    public function filterPostStatusLabels($translation, $text, $domain)
35
-    {
36
-        if ($this->canModifyTranslation($domain)) {
37
-            $replacements = $this->getStatusLabels();
38
-            if (array_key_exists($text, $replacements)) {
39
-                $translation = $replacements[$text];
40
-            }
41
-        }
42
-        return $translation;
43
-    }
28
+	/**
29
+	 * @param string $translation
30
+	 * @param string $test
31
+	 * @param string $domain
32
+	 * @return string
33
+	 */
34
+	public function filterPostStatusLabels($translation, $text, $domain)
35
+	{
36
+		if ($this->canModifyTranslation($domain)) {
37
+			$replacements = $this->getStatusLabels();
38
+			if (array_key_exists($text, $replacements)) {
39
+				$translation = $replacements[$text];
40
+			}
41
+		}
42
+		return $translation;
43
+	}
44 44
 
45
-    /**
46
-     * @return array
47
-     */
48
-    public function filterUpdateMessages(array $messages)
49
-    {
50
-        $post = get_post();
51
-        if (!($post instanceof WP_Post)) {
52
-            return;
53
-        }
54
-        $strings = $this->getReviewLabels();
55
-        $restored = filter_input(INPUT_GET, 'revision');
56
-        if ($revisionTitle = wp_post_revision_title(intval($restored), false)) {
57
-            $restored = sprintf($strings['restored'], $revisionTitle);
58
-        }
59
-        $scheduled_date = date_i18n('M j, Y @ H:i', strtotime($post->post_date));
60
-        $messages[Application::POST_TYPE] = [
61
-             1 => $strings['updated'],
62
-             4 => $strings['updated'],
63
-             5 => $restored,
64
-             6 => $strings['published'],
65
-             7 => $strings['saved'],
66
-             8 => $strings['submitted'],
67
-             9 => sprintf($strings['scheduled'], '<strong>'.$scheduled_date.'</strong>'),
68
-            10 => $strings['draft_updated'],
69
-            50 => $strings['approved'],
70
-            51 => $strings['unapproved'],
71
-            52 => $strings['reverted'],
72
-        ];
73
-        return $messages;
74
-    }
45
+	/**
46
+	 * @return array
47
+	 */
48
+	public function filterUpdateMessages(array $messages)
49
+	{
50
+		$post = get_post();
51
+		if (!($post instanceof WP_Post)) {
52
+			return;
53
+		}
54
+		$strings = $this->getReviewLabels();
55
+		$restored = filter_input(INPUT_GET, 'revision');
56
+		if ($revisionTitle = wp_post_revision_title(intval($restored), false)) {
57
+			$restored = sprintf($strings['restored'], $revisionTitle);
58
+		}
59
+		$scheduled_date = date_i18n('M j, Y @ H:i', strtotime($post->post_date));
60
+		$messages[Application::POST_TYPE] = [
61
+			 1 => $strings['updated'],
62
+			 4 => $strings['updated'],
63
+			 5 => $restored,
64
+			 6 => $strings['published'],
65
+			 7 => $strings['saved'],
66
+			 8 => $strings['submitted'],
67
+			 9 => sprintf($strings['scheduled'], '<strong>'.$scheduled_date.'</strong>'),
68
+			10 => $strings['draft_updated'],
69
+			50 => $strings['approved'],
70
+			51 => $strings['unapproved'],
71
+			52 => $strings['reverted'],
72
+		];
73
+		return $messages;
74
+	}
75 75
 
76
-    /**
77
-     * @param string $domain
78
-     * @return bool
79
-     */
80
-    protected function canModifyTranslation($domain = 'default')
81
-    {
82
-        if ('default' != $domain || empty(glsr_current_screen()->base)) {
83
-            return false;
84
-        }
85
-        return Application::POST_TYPE == glsr_current_screen()->post_type
86
-            && in_array(glsr_current_screen()->base, ['edit', 'post']);
87
-    }
76
+	/**
77
+	 * @param string $domain
78
+	 * @return bool
79
+	 */
80
+	protected function canModifyTranslation($domain = 'default')
81
+	{
82
+		if ('default' != $domain || empty(glsr_current_screen()->base)) {
83
+			return false;
84
+		}
85
+		return Application::POST_TYPE == glsr_current_screen()->post_type
86
+			&& in_array(glsr_current_screen()->base, ['edit', 'post']);
87
+	}
88 88
 
89
-    /**
90
-     * @return array
91
-     */
92
-    protected function getReviewLabels()
93
-    {
94
-        return [
95
-            'approved' => __('Review has been approved and published.', 'site-reviews'),
96
-            'draft_updated' => __('Review draft updated.', 'site-reviews'),
97
-            'preview' => __('Preview review', 'site-reviews'),
98
-            'published' => __('Review approved and published.', 'site-reviews'),
99
-            'restored' => __('Review restored to revision from %s.', 'site-reviews'),
100
-            'reverted' => __('Review has been reverted to its original submission state (title, content, and submission date).', 'site-reviews'),
101
-            'saved' => __('Review saved.', 'site-reviews'),
102
-            'scheduled' => __('Review scheduled for: %s.', 'site-reviews'),
103
-            'submitted' => __('Review submitted.', 'site-reviews'),
104
-            'unapproved' => __('Review has been unapproved and is now pending.', 'site-reviews'),
105
-            'updated' => __('Review updated.', 'site-reviews'),
106
-            'view' => __('View review', 'site-reviews'),
107
-        ];
108
-    }
89
+	/**
90
+	 * @return array
91
+	 */
92
+	protected function getReviewLabels()
93
+	{
94
+		return [
95
+			'approved' => __('Review has been approved and published.', 'site-reviews'),
96
+			'draft_updated' => __('Review draft updated.', 'site-reviews'),
97
+			'preview' => __('Preview review', 'site-reviews'),
98
+			'published' => __('Review approved and published.', 'site-reviews'),
99
+			'restored' => __('Review restored to revision from %s.', 'site-reviews'),
100
+			'reverted' => __('Review has been reverted to its original submission state (title, content, and submission date).', 'site-reviews'),
101
+			'saved' => __('Review saved.', 'site-reviews'),
102
+			'scheduled' => __('Review scheduled for: %s.', 'site-reviews'),
103
+			'submitted' => __('Review submitted.', 'site-reviews'),
104
+			'unapproved' => __('Review has been unapproved and is now pending.', 'site-reviews'),
105
+			'updated' => __('Review updated.', 'site-reviews'),
106
+			'view' => __('View review', 'site-reviews'),
107
+		];
108
+	}
109 109
 
110
-    /**
111
-     * Store the labels to avoid unnecessary loops.
112
-     * @return array
113
-     */
114
-    protected function getStatusLabels()
115
-    {
116
-        static $labels;
117
-        if (empty($labels)) {
118
-            $labels = [
119
-                'Pending' => __('Unapproved', 'site-reviews'),
120
-                'Pending Review' => __('Unapproved', 'site-reviews'),
121
-                'Privately Published' => __('Privately Approved', 'site-reviews'),
122
-                'Publish' => __('Approve', 'site-reviews'),
123
-                'Published' => __('Approved', 'site-reviews'),
124
-                'Save as Pending' => __('Save as Unapproved', 'site-reviews'),
125
-            ];
126
-        }
127
-        return $labels;
128
-    }
110
+	/**
111
+	 * Store the labels to avoid unnecessary loops.
112
+	 * @return array
113
+	 */
114
+	protected function getStatusLabels()
115
+	{
116
+		static $labels;
117
+		if (empty($labels)) {
118
+			$labels = [
119
+				'Pending' => __('Unapproved', 'site-reviews'),
120
+				'Pending Review' => __('Unapproved', 'site-reviews'),
121
+				'Privately Published' => __('Privately Approved', 'site-reviews'),
122
+				'Publish' => __('Approve', 'site-reviews'),
123
+				'Published' => __('Approved', 'site-reviews'),
124
+				'Save as Pending' => __('Save as Unapproved', 'site-reviews'),
125
+			];
126
+		}
127
+		return $labels;
128
+	}
129 129
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
     {
15 15
         global $wp_scripts;
16 16
         $strings = [
17
-            'savePending' => __('Save as Unapproved', 'site-reviews'),
18
-            'published' => __('Approved', 'site-reviews'),
17
+            'savePending' => __( 'Save as Unapproved', 'site-reviews' ),
18
+            'published' => __( 'Approved', 'site-reviews' ),
19 19
         ];
20
-        if ($this->canModifyTranslation() && isset($wp_scripts->registered['post']->extra['data'])) {
20
+        if( $this->canModifyTranslation() && isset($wp_scripts->registered['post']->extra['data']) ) {
21 21
             $l10n = &$wp_scripts->registered['post']->extra['data'];
22
-            foreach ($strings as $search => $replace) {
23
-                $l10n = preg_replace('/("'.$search.'":")([^"]+)/', '$1'.$replace, $l10n);
22
+            foreach( $strings as $search => $replace ) {
23
+                $l10n = preg_replace( '/("'.$search.'":")([^"]+)/', '$1'.$replace, $l10n );
24 24
             }
25 25
         }
26 26
     }
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
      * @param string $domain
32 32
      * @return string
33 33
      */
34
-    public function filterPostStatusLabels($translation, $text, $domain)
34
+    public function filterPostStatusLabels( $translation, $text, $domain )
35 35
     {
36
-        if ($this->canModifyTranslation($domain)) {
36
+        if( $this->canModifyTranslation( $domain ) ) {
37 37
             $replacements = $this->getStatusLabels();
38
-            if (array_key_exists($text, $replacements)) {
38
+            if( array_key_exists( $text, $replacements ) ) {
39 39
                 $translation = $replacements[$text];
40 40
             }
41 41
         }
@@ -45,18 +45,18 @@  discard block
 block discarded – undo
45 45
     /**
46 46
      * @return array
47 47
      */
48
-    public function filterUpdateMessages(array $messages)
48
+    public function filterUpdateMessages( array $messages )
49 49
     {
50 50
         $post = get_post();
51
-        if (!($post instanceof WP_Post)) {
51
+        if( !($post instanceof WP_Post) ) {
52 52
             return;
53 53
         }
54 54
         $strings = $this->getReviewLabels();
55
-        $restored = filter_input(INPUT_GET, 'revision');
56
-        if ($revisionTitle = wp_post_revision_title(intval($restored), false)) {
57
-            $restored = sprintf($strings['restored'], $revisionTitle);
55
+        $restored = filter_input( INPUT_GET, 'revision' );
56
+        if( $revisionTitle = wp_post_revision_title( intval( $restored ), false ) ) {
57
+            $restored = sprintf( $strings['restored'], $revisionTitle );
58 58
         }
59
-        $scheduled_date = date_i18n('M j, Y @ H:i', strtotime($post->post_date));
59
+        $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date ) );
60 60
         $messages[Application::POST_TYPE] = [
61 61
              1 => $strings['updated'],
62 62
              4 => $strings['updated'],
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
              6 => $strings['published'],
65 65
              7 => $strings['saved'],
66 66
              8 => $strings['submitted'],
67
-             9 => sprintf($strings['scheduled'], '<strong>'.$scheduled_date.'</strong>'),
67
+             9 => sprintf( $strings['scheduled'], '<strong>'.$scheduled_date.'</strong>' ),
68 68
             10 => $strings['draft_updated'],
69 69
             50 => $strings['approved'],
70 70
             51 => $strings['unapproved'],
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
      * @param string $domain
78 78
      * @return bool
79 79
      */
80
-    protected function canModifyTranslation($domain = 'default')
80
+    protected function canModifyTranslation( $domain = 'default' )
81 81
     {
82
-        if ('default' != $domain || empty(glsr_current_screen()->base)) {
82
+        if( 'default' != $domain || empty(glsr_current_screen()->base) ) {
83 83
             return false;
84 84
         }
85 85
         return Application::POST_TYPE == glsr_current_screen()->post_type
86
-            && in_array(glsr_current_screen()->base, ['edit', 'post']);
86
+            && in_array( glsr_current_screen()->base, ['edit', 'post'] );
87 87
     }
88 88
 
89 89
     /**
@@ -92,18 +92,18 @@  discard block
 block discarded – undo
92 92
     protected function getReviewLabels()
93 93
     {
94 94
         return [
95
-            'approved' => __('Review has been approved and published.', 'site-reviews'),
96
-            'draft_updated' => __('Review draft updated.', 'site-reviews'),
97
-            'preview' => __('Preview review', 'site-reviews'),
98
-            'published' => __('Review approved and published.', 'site-reviews'),
99
-            'restored' => __('Review restored to revision from %s.', 'site-reviews'),
100
-            'reverted' => __('Review has been reverted to its original submission state (title, content, and submission date).', 'site-reviews'),
101
-            'saved' => __('Review saved.', 'site-reviews'),
102
-            'scheduled' => __('Review scheduled for: %s.', 'site-reviews'),
103
-            'submitted' => __('Review submitted.', 'site-reviews'),
104
-            'unapproved' => __('Review has been unapproved and is now pending.', 'site-reviews'),
105
-            'updated' => __('Review updated.', 'site-reviews'),
106
-            'view' => __('View review', 'site-reviews'),
95
+            'approved' => __( 'Review has been approved and published.', 'site-reviews' ),
96
+            'draft_updated' => __( 'Review draft updated.', 'site-reviews' ),
97
+            'preview' => __( 'Preview review', 'site-reviews' ),
98
+            'published' => __( 'Review approved and published.', 'site-reviews' ),
99
+            'restored' => __( 'Review restored to revision from %s.', 'site-reviews' ),
100
+            'reverted' => __( 'Review has been reverted to its original submission state (title, content, and submission date).', 'site-reviews' ),
101
+            'saved' => __( 'Review saved.', 'site-reviews' ),
102
+            'scheduled' => __( 'Review scheduled for: %s.', 'site-reviews' ),
103
+            'submitted' => __( 'Review submitted.', 'site-reviews' ),
104
+            'unapproved' => __( 'Review has been unapproved and is now pending.', 'site-reviews' ),
105
+            'updated' => __( 'Review updated.', 'site-reviews' ),
106
+            'view' => __( 'View review', 'site-reviews' ),
107 107
         ];
108 108
     }
109 109
 
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
     protected function getStatusLabels()
115 115
     {
116 116
         static $labels;
117
-        if (empty($labels)) {
117
+        if( empty($labels) ) {
118 118
             $labels = [
119
-                'Pending' => __('Unapproved', 'site-reviews'),
120
-                'Pending Review' => __('Unapproved', 'site-reviews'),
121
-                'Privately Published' => __('Privately Approved', 'site-reviews'),
122
-                'Publish' => __('Approve', 'site-reviews'),
123
-                'Published' => __('Approved', 'site-reviews'),
124
-                'Save as Pending' => __('Save as Unapproved', 'site-reviews'),
119
+                'Pending' => __( 'Unapproved', 'site-reviews' ),
120
+                'Pending Review' => __( 'Unapproved', 'site-reviews' ),
121
+                'Privately Published' => __( 'Privately Approved', 'site-reviews' ),
122
+                'Publish' => __( 'Approve', 'site-reviews' ),
123
+                'Published' => __( 'Approved', 'site-reviews' ),
124
+                'Save as Pending' => __( 'Save as Unapproved', 'site-reviews' ),
125 125
             ];
126 126
         }
127 127
         return $labels;
Please login to merge, or discard this patch.
uninstall.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 require_once __DIR__.'/site-reviews.php';
6 6
 
7 7
 if (!(new GL_Plugin_Check_v3(__FILE__))->isValid()) {
8
-    return;
8
+	return;
9 9
 }
10 10
 delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(3));
11 11
 delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(4));
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-defined('WP_UNINSTALL_PLUGIN') || die;
3
+defined( 'WP_UNINSTALL_PLUGIN' ) || die;
4 4
 
5 5
 require_once __DIR__.'/site-reviews.php';
6 6
 
7
-if (!(new GL_Plugin_Check_v3(__FILE__))->isValid()) {
7
+if( !(new GL_Plugin_Check_v3( __FILE__ ))->isValid() ) {
8 8
     return;
9 9
 }
10
-delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(3));
11
-delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(4));
12
-delete_option('_glsr_rebusify');
13
-delete_option('widget_'.glsr()->id.'_site-reviews');
14
-delete_option('widget_'.glsr()->id.'_site-reviews-form');
15
-delete_option('widget_'.glsr()->id.'_site-reviews-summary');
16
-delete_transient(glsr()->id.'_cloudflare_ips');
17
-delete_transient(glsr()->id.'_remote_post_test');
18
-wp_cache_delete(glsr()->id);
10
+delete_option( GeminiLabs\SiteReviews\Database\OptionManager::databaseKey( 3 ) );
11
+delete_option( GeminiLabs\SiteReviews\Database\OptionManager::databaseKey( 4 ) );
12
+delete_option( '_glsr_rebusify' );
13
+delete_option( 'widget_'.glsr()->id.'_site-reviews' );
14
+delete_option( 'widget_'.glsr()->id.'_site-reviews-form' );
15
+delete_option( 'widget_'.glsr()->id.'_site-reviews-summary' );
16
+delete_transient( glsr()->id.'_cloudflare_ips' );
17
+delete_transient( glsr()->id.'_remote_post_test' );
18
+wp_cache_delete( glsr()->id );
19 19
 
20 20
 global $wpdb;
21 21
 
22
-$wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key = '_glsr_notices'");
22
+$wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = '_glsr_notices'" );
Please login to merge, or discard this patch.
plugin/Handlers/TogglePinned.php 3 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@
 block discarded – undo
8 8
 
9 9
 class TogglePinned
10 10
 {
11
-    /**
12
-     * @return bool
13
-     */
14
-    public function handle(Command $command)
15
-    {
16
-        if (!get_post($command->id)) {
17
-            return false;
18
-        }
19
-        if (is_null($command->pinned)) {
20
-            $meta = glsr(Database::class)->get($command->id, 'pinned');
21
-            $command->pinned = !wp_validate_boolean($meta);
22
-        } else {
23
-            $notice = $command->pinned
24
-                ? __('Review pinned.', 'site-reviews')
25
-                : __('Review unpinned.', 'site-reviews');
26
-            glsr(Notice::class)->addSuccess($notice);
27
-        }
28
-        glsr(Database::class)->update($command->id, 'pinned', $command->pinned);
29
-        return $command->pinned;
30
-    }
11
+	/**
12
+	 * @return bool
13
+	 */
14
+	public function handle(Command $command)
15
+	{
16
+		if (!get_post($command->id)) {
17
+			return false;
18
+		}
19
+		if (is_null($command->pinned)) {
20
+			$meta = glsr(Database::class)->get($command->id, 'pinned');
21
+			$command->pinned = !wp_validate_boolean($meta);
22
+		} else {
23
+			$notice = $command->pinned
24
+				? __('Review pinned.', 'site-reviews')
25
+				: __('Review unpinned.', 'site-reviews');
26
+			glsr(Notice::class)->addSuccess($notice);
27
+		}
28
+		glsr(Database::class)->update($command->id, 'pinned', $command->pinned);
29
+		return $command->pinned;
30
+	}
31 31
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,21 +11,21 @@
 block discarded – undo
11 11
     /**
12 12
      * @return bool
13 13
      */
14
-    public function handle(Command $command)
14
+    public function handle( Command $command )
15 15
     {
16
-        if (!get_post($command->id)) {
16
+        if( !get_post( $command->id ) ) {
17 17
             return false;
18 18
         }
19
-        if (is_null($command->pinned)) {
20
-            $meta = glsr(Database::class)->get($command->id, 'pinned');
21
-            $command->pinned = !wp_validate_boolean($meta);
19
+        if( is_null( $command->pinned ) ) {
20
+            $meta = glsr( Database::class )->get( $command->id, 'pinned' );
21
+            $command->pinned = !wp_validate_boolean( $meta );
22 22
         } else {
23 23
             $notice = $command->pinned
24
-                ? __('Review pinned.', 'site-reviews')
25
-                : __('Review unpinned.', 'site-reviews');
26
-            glsr(Notice::class)->addSuccess($notice);
24
+                ? __( 'Review pinned.', 'site-reviews' )
25
+                : __( 'Review unpinned.', 'site-reviews' );
26
+            glsr( Notice::class )->addSuccess( $notice );
27 27
         }
28
-        glsr(Database::class)->update($command->id, 'pinned', $command->pinned);
28
+        glsr( Database::class )->update( $command->id, 'pinned', $command->pinned );
29 29
         return $command->pinned;
30 30
     }
31 31
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,8 @@
 block discarded – undo
19 19
         if (is_null($command->pinned)) {
20 20
             $meta = glsr(Database::class)->get($command->id, 'pinned');
21 21
             $command->pinned = !wp_validate_boolean($meta);
22
-        } else {
22
+        }
23
+        else {
23 24
             $notice = $command->pinned
24 25
                 ? __('Review pinned.', 'site-reviews')
25 26
                 : __('Review unpinned.', 'site-reviews');
Please login to merge, or discard this patch.
plugin/Modules/Akismet.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -7,82 +7,82 @@
 block discarded – undo
7 7
 
8 8
 class Akismet
9 9
 {
10
-    /**
11
-     * @return bool
12
-     */
13
-    public function isSpam(array $review)
14
-    {
15
-        if (!$this->isActive()) {
16
-            return false;
17
-        }
18
-        $submission = [
19
-            'blog' => glsr(OptionManager::class)->getWP('home'),
20
-            'blog_charset' => glsr(OptionManager::class)->getWP('blog_charset', 'UTF-8'),
21
-            'blog_lang' => get_locale(),
22
-            'comment_author' => $review['name'],
23
-            'comment_author_email' => $review['email'],
24
-            'comment_content' => $review['title']."\n\n".$review['content'],
25
-            'comment_type' => 'review',
26
-            'referrer' => filter_input(INPUT_SERVER, 'HTTP_REFERER'),
27
-            'user_agent' => filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'),
28
-            'user_ip' => $review['ip_address'],
29
-            // 'user_role' => 'administrator',
30
-            // 'is_test' => 1,
31
-        ];
32
-        foreach ($_SERVER as $key => $value) {
33
-            if (is_array($value) || in_array($key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'])) {
34
-                continue;
35
-            }
36
-            $submission[$key] = $value;
37
-        }
38
-        return $this->check(apply_filters('site-reviews/akismet/submission', $submission, $review));
39
-    }
10
+	/**
11
+	 * @return bool
12
+	 */
13
+	public function isSpam(array $review)
14
+	{
15
+		if (!$this->isActive()) {
16
+			return false;
17
+		}
18
+		$submission = [
19
+			'blog' => glsr(OptionManager::class)->getWP('home'),
20
+			'blog_charset' => glsr(OptionManager::class)->getWP('blog_charset', 'UTF-8'),
21
+			'blog_lang' => get_locale(),
22
+			'comment_author' => $review['name'],
23
+			'comment_author_email' => $review['email'],
24
+			'comment_content' => $review['title']."\n\n".$review['content'],
25
+			'comment_type' => 'review',
26
+			'referrer' => filter_input(INPUT_SERVER, 'HTTP_REFERER'),
27
+			'user_agent' => filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'),
28
+			'user_ip' => $review['ip_address'],
29
+			// 'user_role' => 'administrator',
30
+			// 'is_test' => 1,
31
+		];
32
+		foreach ($_SERVER as $key => $value) {
33
+			if (is_array($value) || in_array($key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'])) {
34
+				continue;
35
+			}
36
+			$submission[$key] = $value;
37
+		}
38
+		return $this->check(apply_filters('site-reviews/akismet/submission', $submission, $review));
39
+	}
40 40
 
41
-    /**
42
-     * @return bool
43
-     */
44
-    protected function check(array $submission)
45
-    {
46
-        $response = AkismetPlugin::http_post($this->buildQuery($submission), 'comment-check');
47
-        return apply_filters('site-reviews/akismet/is-spam',
48
-            'true' == $response[1],
49
-            $submission,
50
-            $response
51
-        );
52
-    }
41
+	/**
42
+	 * @return bool
43
+	 */
44
+	protected function check(array $submission)
45
+	{
46
+		$response = AkismetPlugin::http_post($this->buildQuery($submission), 'comment-check');
47
+		return apply_filters('site-reviews/akismet/is-spam',
48
+			'true' == $response[1],
49
+			$submission,
50
+			$response
51
+		);
52
+	}
53 53
 
54
-    /**
55
-     * @return string
56
-     */
57
-    protected function buildQuery(array $data)
58
-    {
59
-        $query = [];
60
-        foreach ($data as $key => $value) {
61
-            if (is_array($value) || is_object($value)) {
62
-                continue;
63
-            }
64
-            if (false === $value) {
65
-                $value = '0';
66
-            }
67
-            $value = trim($value);
68
-            if (!strlen($value)) {
69
-                continue;
70
-            }
71
-            $query[] = urlencode($key).'='.urlencode($value);
72
-        }
73
-        return implode('&', $query);
74
-    }
54
+	/**
55
+	 * @return string
56
+	 */
57
+	protected function buildQuery(array $data)
58
+	{
59
+		$query = [];
60
+		foreach ($data as $key => $value) {
61
+			if (is_array($value) || is_object($value)) {
62
+				continue;
63
+			}
64
+			if (false === $value) {
65
+				$value = '0';
66
+			}
67
+			$value = trim($value);
68
+			if (!strlen($value)) {
69
+				continue;
70
+			}
71
+			$query[] = urlencode($key).'='.urlencode($value);
72
+		}
73
+		return implode('&', $query);
74
+	}
75 75
 
76
-    /**
77
-     * @return bool
78
-     */
79
-    protected function isActive()
80
-    {
81
-        $check = !glsr(OptionManager::class)->getBool('settings.submissions.akismet')
82
-            || !is_callable(['Akismet', 'get_api_key'])
83
-            || !is_callable(['Akismet', 'http_post'])
84
-            ? false
85
-            : (bool) AkismetPlugin::get_api_key();
86
-        return apply_filters('site-reviews/akismet/is-active', $check);
87
-    }
76
+	/**
77
+	 * @return bool
78
+	 */
79
+	protected function isActive()
80
+	{
81
+		$check = !glsr(OptionManager::class)->getBool('settings.submissions.akismet')
82
+			|| !is_callable(['Akismet', 'get_api_key'])
83
+			|| !is_callable(['Akismet', 'http_post'])
84
+			? false
85
+			: (bool) AkismetPlugin::get_api_key();
86
+		return apply_filters('site-reviews/akismet/is-active', $check);
87
+	}
88 88
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -10,41 +10,41 @@  discard block
 block discarded – undo
10 10
     /**
11 11
      * @return bool
12 12
      */
13
-    public function isSpam(array $review)
13
+    public function isSpam( array $review )
14 14
     {
15
-        if (!$this->isActive()) {
15
+        if( !$this->isActive() ) {
16 16
             return false;
17 17
         }
18 18
         $submission = [
19
-            'blog' => glsr(OptionManager::class)->getWP('home'),
20
-            'blog_charset' => glsr(OptionManager::class)->getWP('blog_charset', 'UTF-8'),
19
+            'blog' => glsr( OptionManager::class )->getWP( 'home' ),
20
+            'blog_charset' => glsr( OptionManager::class )->getWP( 'blog_charset', 'UTF-8' ),
21 21
             'blog_lang' => get_locale(),
22 22
             'comment_author' => $review['name'],
23 23
             'comment_author_email' => $review['email'],
24 24
             'comment_content' => $review['title']."\n\n".$review['content'],
25 25
             'comment_type' => 'review',
26
-            'referrer' => filter_input(INPUT_SERVER, 'HTTP_REFERER'),
27
-            'user_agent' => filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'),
26
+            'referrer' => filter_input( INPUT_SERVER, 'HTTP_REFERER' ),
27
+            'user_agent' => filter_input( INPUT_SERVER, 'HTTP_USER_AGENT' ),
28 28
             'user_ip' => $review['ip_address'],
29 29
             // 'user_role' => 'administrator',
30 30
             // 'is_test' => 1,
31 31
         ];
32
-        foreach ($_SERVER as $key => $value) {
33
-            if (is_array($value) || in_array($key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'])) {
32
+        foreach( $_SERVER as $key => $value ) {
33
+            if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] ) ) {
34 34
                 continue;
35 35
             }
36 36
             $submission[$key] = $value;
37 37
         }
38
-        return $this->check(apply_filters('site-reviews/akismet/submission', $submission, $review));
38
+        return $this->check( apply_filters( 'site-reviews/akismet/submission', $submission, $review ) );
39 39
     }
40 40
 
41 41
     /**
42 42
      * @return bool
43 43
      */
44
-    protected function check(array $submission)
44
+    protected function check( array $submission )
45 45
     {
46
-        $response = AkismetPlugin::http_post($this->buildQuery($submission), 'comment-check');
47
-        return apply_filters('site-reviews/akismet/is-spam',
46
+        $response = AkismetPlugin::http_post( $this->buildQuery( $submission ), 'comment-check' );
47
+        return apply_filters( 'site-reviews/akismet/is-spam',
48 48
             'true' == $response[1],
49 49
             $submission,
50 50
             $response
@@ -54,23 +54,23 @@  discard block
 block discarded – undo
54 54
     /**
55 55
      * @return string
56 56
      */
57
-    protected function buildQuery(array $data)
57
+    protected function buildQuery( array $data )
58 58
     {
59 59
         $query = [];
60
-        foreach ($data as $key => $value) {
61
-            if (is_array($value) || is_object($value)) {
60
+        foreach( $data as $key => $value ) {
61
+            if( is_array( $value ) || is_object( $value ) ) {
62 62
                 continue;
63 63
             }
64
-            if (false === $value) {
64
+            if( false === $value ) {
65 65
                 $value = '0';
66 66
             }
67
-            $value = trim($value);
68
-            if (!strlen($value)) {
67
+            $value = trim( $value );
68
+            if( !strlen( $value ) ) {
69 69
                 continue;
70 70
             }
71
-            $query[] = urlencode($key).'='.urlencode($value);
71
+            $query[] = urlencode( $key ).'='.urlencode( $value );
72 72
         }
73
-        return implode('&', $query);
73
+        return implode( '&', $query );
74 74
     }
75 75
 
76 76
     /**
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
      */
79 79
     protected function isActive()
80 80
     {
81
-        $check = !glsr(OptionManager::class)->getBool('settings.submissions.akismet')
82
-            || !is_callable(['Akismet', 'get_api_key'])
83
-            || !is_callable(['Akismet', 'http_post'])
81
+        $check = !glsr( OptionManager::class )->getBool( 'settings.submissions.akismet' )
82
+            || !is_callable( ['Akismet', 'get_api_key'] )
83
+            || !is_callable( ['Akismet', 'http_post'] )
84 84
             ? false
85
-            : (bool) AkismetPlugin::get_api_key();
86
-        return apply_filters('site-reviews/akismet/is-active', $check);
85
+            : (bool)AkismetPlugin::get_api_key();
86
+        return apply_filters( 'site-reviews/akismet/is-active', $check );
87 87
     }
88 88
 }
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/SiteReviews.php 3 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -194,7 +194,8 @@
 block discarded – undo
194 194
         $dateFormat = $this->getOption('settings.reviews.date.format', 'default');
195 195
         if ('relative' == $dateFormat) {
196 196
             $date = glsr(Date::class)->relative($value);
197
-        } else {
197
+        }
198
+        else {
198 199
             $format = 'custom' == $dateFormat
199 200
                 ? $this->getOption('settings.reviews.date.custom', 'M j, Y')
200 201
                 : glsr(OptionManager::class)->getWP('date_format', 'F j, Y');
Please login to merge, or discard this patch.
Indentation   +353 added lines, -353 removed lines patch added patch discarded remove patch
@@ -21,382 +21,382 @@
 block discarded – undo
21 21
 
22 22
 class SiteReviews
23 23
 {
24
-    /**
25
-     * @var array
26
-     */
27
-    public $args;
24
+	/**
25
+	 * @var array
26
+	 */
27
+	public $args;
28 28
 
29
-    /**
30
-     * @var Review
31
-     */
32
-    public $current;
29
+	/**
30
+	 * @var Review
31
+	 */
32
+	public $current;
33 33
 
34
-    /**
35
-     * @var array
36
-     */
37
-    public $options;
34
+	/**
35
+	 * @var array
36
+	 */
37
+	public $options;
38 38
 
39
-    /**
40
-     * @var Reviews
41
-     */
42
-    protected $reviews;
39
+	/**
40
+	 * @var Reviews
41
+	 */
42
+	protected $reviews;
43 43
 
44
-    /**
45
-     * @param Reviews|null $reviews
46
-     * @return ReviewsHtml
47
-     */
48
-    public function build(array $args = [], $reviews = null)
49
-    {
50
-        $this->args = glsr(SiteReviewsDefaults::class)->merge($args);
51
-        $this->options = Arr::flattenArray(glsr(OptionManager::class)->all());
52
-        $this->reviews = $reviews instanceof Reviews
53
-            ? $reviews
54
-            : glsr(ReviewManager::class)->get($this->args);
55
-        $this->generateSchema();
56
-        return $this->buildReviews();
57
-    }
44
+	/**
45
+	 * @param Reviews|null $reviews
46
+	 * @return ReviewsHtml
47
+	 */
48
+	public function build(array $args = [], $reviews = null)
49
+	{
50
+		$this->args = glsr(SiteReviewsDefaults::class)->merge($args);
51
+		$this->options = Arr::flattenArray(glsr(OptionManager::class)->all());
52
+		$this->reviews = $reviews instanceof Reviews
53
+			? $reviews
54
+			: glsr(ReviewManager::class)->get($this->args);
55
+		$this->generateSchema();
56
+		return $this->buildReviews();
57
+	}
58 58
 
59
-    /**
60
-     * @return ReviewHtml
61
-     */
62
-    public function buildReview(Review $review)
63
-    {
64
-        $review = apply_filters('site-reviews/review/build/before', $review);
65
-        $this->current = $review;
66
-        $renderedFields = [];
67
-        foreach ($review as $key => $value) {
68
-            $method = Helper::buildMethodName($key, 'buildOption');
69
-            $field = method_exists($this, $method)
70
-                ? $this->$method($key, $value)
71
-                : false;
72
-            $field = apply_filters('site-reviews/review/build/'.$key, $field, $value, $this, $review);
73
-            if (false === $field) {
74
-                continue;
75
-            }
76
-            $renderedFields[$key] = $field;
77
-        }
78
-        $this->wrap($renderedFields, $review);
79
-        $renderedFields = apply_filters('site-reviews/review/build/after', $renderedFields, $review, $this);
80
-        $this->current = null;
81
-        return new ReviewHtml($review, (array) $renderedFields);
82
-    }
59
+	/**
60
+	 * @return ReviewHtml
61
+	 */
62
+	public function buildReview(Review $review)
63
+	{
64
+		$review = apply_filters('site-reviews/review/build/before', $review);
65
+		$this->current = $review;
66
+		$renderedFields = [];
67
+		foreach ($review as $key => $value) {
68
+			$method = Helper::buildMethodName($key, 'buildOption');
69
+			$field = method_exists($this, $method)
70
+				? $this->$method($key, $value)
71
+				: false;
72
+			$field = apply_filters('site-reviews/review/build/'.$key, $field, $value, $this, $review);
73
+			if (false === $field) {
74
+				continue;
75
+			}
76
+			$renderedFields[$key] = $field;
77
+		}
78
+		$this->wrap($renderedFields, $review);
79
+		$renderedFields = apply_filters('site-reviews/review/build/after', $renderedFields, $review, $this);
80
+		$this->current = null;
81
+		return new ReviewHtml($review, (array) $renderedFields);
82
+	}
83 83
 
84
-    /**
85
-     * @return ReviewsHtml
86
-     */
87
-    public function buildReviews()
88
-    {
89
-        $renderedReviews = [];
90
-        foreach ($this->reviews as $index => $review) {
91
-            $renderedReviews[] = $this->buildReview($review);
92
-        }
93
-        return new ReviewsHtml($renderedReviews, $this->reviews->max_num_pages, $this->args);
94
-    }
84
+	/**
85
+	 * @return ReviewsHtml
86
+	 */
87
+	public function buildReviews()
88
+	{
89
+		$renderedReviews = [];
90
+		foreach ($this->reviews as $index => $review) {
91
+			$renderedReviews[] = $this->buildReview($review);
92
+		}
93
+		return new ReviewsHtml($renderedReviews, $this->reviews->max_num_pages, $this->args);
94
+	}
95 95
 
96
-    /**
97
-     * @return void
98
-     */
99
-    public function generateSchema()
100
-    {
101
-        if (!wp_validate_boolean($this->args['schema'])) {
102
-            return;
103
-        }
104
-        glsr(Schema::class)->store(
105
-            glsr(Schema::class)->build($this->args)
106
-        );
107
-    }
96
+	/**
97
+	 * @return void
98
+	 */
99
+	public function generateSchema()
100
+	{
101
+		if (!wp_validate_boolean($this->args['schema'])) {
102
+			return;
103
+		}
104
+		glsr(Schema::class)->store(
105
+			glsr(Schema::class)->build($this->args)
106
+		);
107
+	}
108 108
 
109
-    /**
110
-     * @param string $key
111
-     * @param string $path
112
-     * @return bool
113
-     */
114
-    public function isHidden($key, $path = '')
115
-    {
116
-        $isOptionEnabled = !empty($path)
117
-            ? $this->isOptionEnabled($path)
118
-            : true;
119
-        return in_array($key, $this->args['hide']) || !$isOptionEnabled;
120
-    }
109
+	/**
110
+	 * @param string $key
111
+	 * @param string $path
112
+	 * @return bool
113
+	 */
114
+	public function isHidden($key, $path = '')
115
+	{
116
+		$isOptionEnabled = !empty($path)
117
+			? $this->isOptionEnabled($path)
118
+			: true;
119
+		return in_array($key, $this->args['hide']) || !$isOptionEnabled;
120
+	}
121 121
 
122
-    /**
123
-     * @param string $key
124
-     * @param string $value
125
-     * @return void|string
126
-     */
127
-    protected function buildOptionAssignedTo($key, $value)
128
-    {
129
-        if ($this->isHidden($key, 'settings.reviews.assigned_links')) {
130
-            return;
131
-        }
132
-        $post = glsr(Polylang::class)->getPost($value);
133
-        if (!($post instanceof WP_Post)) {
134
-            return;
135
-        }
136
-        $permalink = glsr(Builder::class)->a(get_the_title($post->ID), [
137
-            'href' => get_the_permalink($post->ID),
138
-        ]);
139
-        $assignedTo = sprintf(__('Review of %s', 'site-reviews'), $permalink);
140
-        return '<span>'.$assignedTo.'</span>';
141
-    }
122
+	/**
123
+	 * @param string $key
124
+	 * @param string $value
125
+	 * @return void|string
126
+	 */
127
+	protected function buildOptionAssignedTo($key, $value)
128
+	{
129
+		if ($this->isHidden($key, 'settings.reviews.assigned_links')) {
130
+			return;
131
+		}
132
+		$post = glsr(Polylang::class)->getPost($value);
133
+		if (!($post instanceof WP_Post)) {
134
+			return;
135
+		}
136
+		$permalink = glsr(Builder::class)->a(get_the_title($post->ID), [
137
+			'href' => get_the_permalink($post->ID),
138
+		]);
139
+		$assignedTo = sprintf(__('Review of %s', 'site-reviews'), $permalink);
140
+		return '<span>'.$assignedTo.'</span>';
141
+	}
142 142
 
143
-    /**
144
-     * @param string $key
145
-     * @param string $value
146
-     * @return void|string
147
-     */
148
-    protected function buildOptionAuthor($key, $value)
149
-    {
150
-        if (!$this->isHidden($key)) {
151
-            $name = Str::convertName(
152
-                $value,
153
-                glsr_get_option('reviews.name.format'),
154
-                glsr_get_option('reviews.name.initial')
155
-            );
156
-            return '<span>'.$name.'</span>';
157
-        }
158
-    }
143
+	/**
144
+	 * @param string $key
145
+	 * @param string $value
146
+	 * @return void|string
147
+	 */
148
+	protected function buildOptionAuthor($key, $value)
149
+	{
150
+		if (!$this->isHidden($key)) {
151
+			$name = Str::convertName(
152
+				$value,
153
+				glsr_get_option('reviews.name.format'),
154
+				glsr_get_option('reviews.name.initial')
155
+			);
156
+			return '<span>'.$name.'</span>';
157
+		}
158
+	}
159 159
 
160
-    /**
161
-     * @param string $key
162
-     * @param string $value
163
-     * @return void|string
164
-     */
165
-    protected function buildOptionAvatar($key, $value)
166
-    {
167
-        if ($this->isHidden($key, 'settings.reviews.avatars')) {
168
-            return;
169
-        }
170
-        $size = $this->getOption('settings.reviews.avatars_size', 40);
171
-        return glsr(Builder::class)->img([
172
-            'height' => $size,
173
-            'src' => $this->generateAvatar($value),
174
-            'style' => sprintf('width:%1$spx; height:%1$spx;', $size),
175
-            'width' => $size,
176
-        ]);
177
-    }
160
+	/**
161
+	 * @param string $key
162
+	 * @param string $value
163
+	 * @return void|string
164
+	 */
165
+	protected function buildOptionAvatar($key, $value)
166
+	{
167
+		if ($this->isHidden($key, 'settings.reviews.avatars')) {
168
+			return;
169
+		}
170
+		$size = $this->getOption('settings.reviews.avatars_size', 40);
171
+		return glsr(Builder::class)->img([
172
+			'height' => $size,
173
+			'src' => $this->generateAvatar($value),
174
+			'style' => sprintf('width:%1$spx; height:%1$spx;', $size),
175
+			'width' => $size,
176
+		]);
177
+	}
178 178
 
179
-    /**
180
-     * @param string $key
181
-     * @param string $value
182
-     * @return void|string
183
-     */
184
-    protected function buildOptionContent($key, $value)
185
-    {
186
-        $text = $this->normalizeText($value);
187
-        if (!$this->isHiddenOrEmpty($key, $text)) {
188
-            return '<p>'.$text.'</p>';
189
-        }
190
-    }
179
+	/**
180
+	 * @param string $key
181
+	 * @param string $value
182
+	 * @return void|string
183
+	 */
184
+	protected function buildOptionContent($key, $value)
185
+	{
186
+		$text = $this->normalizeText($value);
187
+		if (!$this->isHiddenOrEmpty($key, $text)) {
188
+			return '<p>'.$text.'</p>';
189
+		}
190
+	}
191 191
 
192
-    /**
193
-     * @param string $key
194
-     * @param string $value
195
-     * @return void|string
196
-     */
197
-    protected function buildOptionDate($key, $value)
198
-    {
199
-        if ($this->isHidden($key)) {
200
-            return;
201
-        }
202
-        $dateFormat = $this->getOption('settings.reviews.date.format', 'default');
203
-        if ('relative' == $dateFormat) {
204
-            $date = glsr(Date::class)->relative($value);
205
-        } else {
206
-            $format = 'custom' == $dateFormat
207
-                ? $this->getOption('settings.reviews.date.custom', 'M j, Y')
208
-                : glsr(OptionManager::class)->getWP('date_format', 'F j, Y');
209
-            $date = date_i18n($format, strtotime($value));
210
-        }
211
-        return '<span>'.$date.'</span>';
212
-    }
192
+	/**
193
+	 * @param string $key
194
+	 * @param string $value
195
+	 * @return void|string
196
+	 */
197
+	protected function buildOptionDate($key, $value)
198
+	{
199
+		if ($this->isHidden($key)) {
200
+			return;
201
+		}
202
+		$dateFormat = $this->getOption('settings.reviews.date.format', 'default');
203
+		if ('relative' == $dateFormat) {
204
+			$date = glsr(Date::class)->relative($value);
205
+		} else {
206
+			$format = 'custom' == $dateFormat
207
+				? $this->getOption('settings.reviews.date.custom', 'M j, Y')
208
+				: glsr(OptionManager::class)->getWP('date_format', 'F j, Y');
209
+			$date = date_i18n($format, strtotime($value));
210
+		}
211
+		return '<span>'.$date.'</span>';
212
+	}
213 213
 
214
-    /**
215
-     * @param string $key
216
-     * @param string $value
217
-     * @return void|string
218
-     */
219
-    protected function buildOptionRating($key, $value)
220
-    {
221
-        if (!$this->isHiddenOrEmpty($key, $value)) {
222
-            return glsr_star_rating($value);
223
-        }
224
-    }
214
+	/**
215
+	 * @param string $key
216
+	 * @param string $value
217
+	 * @return void|string
218
+	 */
219
+	protected function buildOptionRating($key, $value)
220
+	{
221
+		if (!$this->isHiddenOrEmpty($key, $value)) {
222
+			return glsr_star_rating($value);
223
+		}
224
+	}
225 225
 
226
-    /**
227
-     * @param string $key
228
-     * @param string $value
229
-     * @return void|string
230
-     */
231
-    protected function buildOptionResponse($key, $value)
232
-    {
233
-        if ($this->isHiddenOrEmpty($key, $value)) {
234
-            return;
235
-        }
236
-        $title = sprintf(__('Response from %s', 'site-reviews'), get_bloginfo('name'));
237
-        $text = $this->normalizeText($value);
238
-        $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>';
239
-        $response = glsr(Builder::class)->div($text, ['class' => 'glsr-review-response-inner']);
240
-        $background = glsr(Builder::class)->div(['class' => 'glsr-review-response-background']);
241
-        return $response.$background;
242
-    }
226
+	/**
227
+	 * @param string $key
228
+	 * @param string $value
229
+	 * @return void|string
230
+	 */
231
+	protected function buildOptionResponse($key, $value)
232
+	{
233
+		if ($this->isHiddenOrEmpty($key, $value)) {
234
+			return;
235
+		}
236
+		$title = sprintf(__('Response from %s', 'site-reviews'), get_bloginfo('name'));
237
+		$text = $this->normalizeText($value);
238
+		$text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>';
239
+		$response = glsr(Builder::class)->div($text, ['class' => 'glsr-review-response-inner']);
240
+		$background = glsr(Builder::class)->div(['class' => 'glsr-review-response-background']);
241
+		return $response.$background;
242
+	}
243 243
 
244
-    /**
245
-     * @param string $key
246
-     * @param string $value
247
-     * @return void|string
248
-     */
249
-    protected function buildOptionTitle($key, $value)
250
-    {
251
-        if ($this->isHidden($key)) {
252
-            return;
253
-        }
254
-        if (empty($value)) {
255
-            $value = __('No Title', 'site-reviews');
256
-        }
257
-        return '<h3>'.$value.'</h3>';
258
-    }
244
+	/**
245
+	 * @param string $key
246
+	 * @param string $value
247
+	 * @return void|string
248
+	 */
249
+	protected function buildOptionTitle($key, $value)
250
+	{
251
+		if ($this->isHidden($key)) {
252
+			return;
253
+		}
254
+		if (empty($value)) {
255
+			$value = __('No Title', 'site-reviews');
256
+		}
257
+		return '<h3>'.$value.'</h3>';
258
+	}
259 259
 
260
-    /**
261
-     * @param string $avatarUrl
262
-     * @return string
263
-     */
264
-    protected function generateAvatar($avatarUrl)
265
-    {
266
-        if (!$this->isOptionEnabled('settings.reviews.avatars_regenerate') || 'local' != $this->current->review_type) {
267
-            return $avatarUrl;
268
-        }
269
-        $authorIdOrEmail = get_the_author_meta('ID', $this->current->user_id);
270
-        if (empty($authorIdOrEmail)) {
271
-            $authorIdOrEmail = $this->current->email;
272
-        }
273
-        if ($newAvatar = get_avatar_url($authorIdOrEmail)) {
274
-            return $newAvatar;
275
-        }
276
-        return $avatarUrl;
277
-    }
260
+	/**
261
+	 * @param string $avatarUrl
262
+	 * @return string
263
+	 */
264
+	protected function generateAvatar($avatarUrl)
265
+	{
266
+		if (!$this->isOptionEnabled('settings.reviews.avatars_regenerate') || 'local' != $this->current->review_type) {
267
+			return $avatarUrl;
268
+		}
269
+		$authorIdOrEmail = get_the_author_meta('ID', $this->current->user_id);
270
+		if (empty($authorIdOrEmail)) {
271
+			$authorIdOrEmail = $this->current->email;
272
+		}
273
+		if ($newAvatar = get_avatar_url($authorIdOrEmail)) {
274
+			return $newAvatar;
275
+		}
276
+		return $avatarUrl;
277
+	}
278 278
 
279
-    /**
280
-     * @param string $text
281
-     * @return string
282
-     */
283
-    protected function getExcerpt($text)
284
-    {
285
-        $limit = intval($this->getOption('settings.reviews.excerpts_length', 55));
286
-        $split = extension_loaded('intl')
287
-            ? $this->getExcerptIntlSplit($text, $limit)
288
-            : $this->getExcerptSplit($text, $limit);
289
-        $hiddenText = substr($text, $split);
290
-        if (!empty($hiddenText)) {
291
-            $showMore = glsr(Builder::class)->span($hiddenText, [
292
-                'class' => 'glsr-hidden glsr-hidden-text',
293
-                'data-show-less' => __('Show less', 'site-reviews'),
294
-                'data-show-more' => __('Show more', 'site-reviews'),
295
-            ]);
296
-            $text = ltrim(substr($text, 0, $split)).$showMore;
297
-        }
298
-        return $text;
299
-    }
279
+	/**
280
+	 * @param string $text
281
+	 * @return string
282
+	 */
283
+	protected function getExcerpt($text)
284
+	{
285
+		$limit = intval($this->getOption('settings.reviews.excerpts_length', 55));
286
+		$split = extension_loaded('intl')
287
+			? $this->getExcerptIntlSplit($text, $limit)
288
+			: $this->getExcerptSplit($text, $limit);
289
+		$hiddenText = substr($text, $split);
290
+		if (!empty($hiddenText)) {
291
+			$showMore = glsr(Builder::class)->span($hiddenText, [
292
+				'class' => 'glsr-hidden glsr-hidden-text',
293
+				'data-show-less' => __('Show less', 'site-reviews'),
294
+				'data-show-more' => __('Show more', 'site-reviews'),
295
+			]);
296
+			$text = ltrim(substr($text, 0, $split)).$showMore;
297
+		}
298
+		return $text;
299
+	}
300 300
 
301
-    /**
302
-     * @param string $text
303
-     * @param int $limit
304
-     * @return int
305
-     */
306
-    protected function getExcerptIntlSplit($text, $limit)
307
-    {
308
-        $words = IntlRuleBasedBreakIterator::createWordInstance('');
309
-        $words->setText($text);
310
-        $count = 0;
311
-        foreach ($words as $offset) {
312
-            if (IntlRuleBasedBreakIterator::WORD_NONE === $words->getRuleStatus()) {
313
-                continue;
314
-            }
315
-            ++$count;
316
-            if ($count != $limit) {
317
-                continue;
318
-            }
319
-            return $offset;
320
-        }
321
-        return strlen($text);
322
-    }
301
+	/**
302
+	 * @param string $text
303
+	 * @param int $limit
304
+	 * @return int
305
+	 */
306
+	protected function getExcerptIntlSplit($text, $limit)
307
+	{
308
+		$words = IntlRuleBasedBreakIterator::createWordInstance('');
309
+		$words->setText($text);
310
+		$count = 0;
311
+		foreach ($words as $offset) {
312
+			if (IntlRuleBasedBreakIterator::WORD_NONE === $words->getRuleStatus()) {
313
+				continue;
314
+			}
315
+			++$count;
316
+			if ($count != $limit) {
317
+				continue;
318
+			}
319
+			return $offset;
320
+		}
321
+		return strlen($text);
322
+	}
323 323
 
324
-    /**
325
-     * @param string $text
326
-     * @param int $limit
327
-     * @return int
328
-     */
329
-    protected function getExcerptSplit($text, $limit)
330
-    {
331
-        if (str_word_count($text, 0) > $limit) {
332
-            $words = array_keys(str_word_count($text, 2));
333
-            return $words[$limit];
334
-        }
335
-        return strlen($text);
336
-    }
324
+	/**
325
+	 * @param string $text
326
+	 * @param int $limit
327
+	 * @return int
328
+	 */
329
+	protected function getExcerptSplit($text, $limit)
330
+	{
331
+		if (str_word_count($text, 0) > $limit) {
332
+			$words = array_keys(str_word_count($text, 2));
333
+			return $words[$limit];
334
+		}
335
+		return strlen($text);
336
+	}
337 337
 
338
-    /**
339
-     * @param string $path
340
-     * @param mixed $fallback
341
-     * @return mixed
342
-     */
343
-    protected function getOption($path, $fallback = '')
344
-    {
345
-        if (array_key_exists($path, $this->options)) {
346
-            return $this->options[$path];
347
-        }
348
-        return $fallback;
349
-    }
338
+	/**
339
+	 * @param string $path
340
+	 * @param mixed $fallback
341
+	 * @return mixed
342
+	 */
343
+	protected function getOption($path, $fallback = '')
344
+	{
345
+		if (array_key_exists($path, $this->options)) {
346
+			return $this->options[$path];
347
+		}
348
+		return $fallback;
349
+	}
350 350
 
351
-    /**
352
-     * @param string $key
353
-     * @param string $value
354
-     * @return bool
355
-     */
356
-    protected function isHiddenOrEmpty($key, $value)
357
-    {
358
-        return $this->isHidden($key) || empty($value);
359
-    }
351
+	/**
352
+	 * @param string $key
353
+	 * @param string $value
354
+	 * @return bool
355
+	 */
356
+	protected function isHiddenOrEmpty($key, $value)
357
+	{
358
+		return $this->isHidden($key) || empty($value);
359
+	}
360 360
 
361
-    /**
362
-     * @param string $path
363
-     * @return bool
364
-     */
365
-    protected function isOptionEnabled($path)
366
-    {
367
-        return 'yes' == $this->getOption($path);
368
-    }
361
+	/**
362
+	 * @param string $path
363
+	 * @return bool
364
+	 */
365
+	protected function isOptionEnabled($path)
366
+	{
367
+		return 'yes' == $this->getOption($path);
368
+	}
369 369
 
370
-    /**
371
-     * @param string $text
372
-     * @return string
373
-     */
374
-    protected function normalizeText($text)
375
-    {
376
-        $text = wp_kses($text, wp_kses_allowed_html());
377
-        $text = convert_smilies(strip_shortcodes($text));
378
-        $text = str_replace(']]>', ']]&gt;', $text);
379
-        $text = preg_replace('/(\R){2,}/', '$1', $text);
380
-        if ($this->isOptionEnabled('settings.reviews.excerpts')) {
381
-            $text = $this->getExcerpt($text);
382
-        }
383
-        return wptexturize(nl2br($text));
384
-    }
370
+	/**
371
+	 * @param string $text
372
+	 * @return string
373
+	 */
374
+	protected function normalizeText($text)
375
+	{
376
+		$text = wp_kses($text, wp_kses_allowed_html());
377
+		$text = convert_smilies(strip_shortcodes($text));
378
+		$text = str_replace(']]>', ']]&gt;', $text);
379
+		$text = preg_replace('/(\R){2,}/', '$1', $text);
380
+		if ($this->isOptionEnabled('settings.reviews.excerpts')) {
381
+			$text = $this->getExcerpt($text);
382
+		}
383
+		return wptexturize(nl2br($text));
384
+	}
385 385
 
386
-    /**
387
-     * @return void
388
-     */
389
-    protected function wrap(array &$renderedFields, Review $review)
390
-    {
391
-        $renderedFields = apply_filters('site-reviews/review/wrap', $renderedFields, $review, $this);
392
-        array_walk($renderedFields, function (&$value, $key) use ($review) {
393
-            $value = apply_filters('site-reviews/review/wrap/'.$key, $value, $review);
394
-            if (empty($value)) {
395
-                return;
396
-            }
397
-            $value = glsr(Builder::class)->div($value, [
398
-                'class' => 'glsr-review-'.$key,
399
-            ]);
400
-        });
401
-    }
386
+	/**
387
+	 * @return void
388
+	 */
389
+	protected function wrap(array &$renderedFields, Review $review)
390
+	{
391
+		$renderedFields = apply_filters('site-reviews/review/wrap', $renderedFields, $review, $this);
392
+		array_walk($renderedFields, function (&$value, $key) use ($review) {
393
+			$value = apply_filters('site-reviews/review/wrap/'.$key, $value, $review);
394
+			if (empty($value)) {
395
+				return;
396
+			}
397
+			$value = glsr(Builder::class)->div($value, [
398
+				'class' => 'glsr-review-'.$key,
399
+			]);
400
+		});
401
+	}
402 402
 }
Please login to merge, or discard this patch.
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
      * @param Reviews|null $reviews
46 46
      * @return ReviewsHtml
47 47
      */
48
-    public function build(array $args = [], $reviews = null)
48
+    public function build( array $args = [], $reviews = null )
49 49
     {
50
-        $this->args = glsr(SiteReviewsDefaults::class)->merge($args);
51
-        $this->options = Arr::flattenArray(glsr(OptionManager::class)->all());
50
+        $this->args = glsr( SiteReviewsDefaults::class )->merge( $args );
51
+        $this->options = Arr::flattenArray( glsr( OptionManager::class )->all() );
52 52
         $this->reviews = $reviews instanceof Reviews
53 53
             ? $reviews
54
-            : glsr(ReviewManager::class)->get($this->args);
54
+            : glsr( ReviewManager::class )->get( $this->args );
55 55
         $this->generateSchema();
56 56
         return $this->buildReviews();
57 57
     }
@@ -59,26 +59,26 @@  discard block
 block discarded – undo
59 59
     /**
60 60
      * @return ReviewHtml
61 61
      */
62
-    public function buildReview(Review $review)
62
+    public function buildReview( Review $review )
63 63
     {
64
-        $review = apply_filters('site-reviews/review/build/before', $review);
64
+        $review = apply_filters( 'site-reviews/review/build/before', $review );
65 65
         $this->current = $review;
66 66
         $renderedFields = [];
67
-        foreach ($review as $key => $value) {
68
-            $method = Helper::buildMethodName($key, 'buildOption');
69
-            $field = method_exists($this, $method)
70
-                ? $this->$method($key, $value)
67
+        foreach( $review as $key => $value ) {
68
+            $method = Helper::buildMethodName( $key, 'buildOption' );
69
+            $field = method_exists( $this, $method )
70
+                ? $this->$method( $key, $value )
71 71
                 : false;
72
-            $field = apply_filters('site-reviews/review/build/'.$key, $field, $value, $this, $review);
73
-            if (false === $field) {
72
+            $field = apply_filters( 'site-reviews/review/build/'.$key, $field, $value, $this, $review );
73
+            if( false === $field ) {
74 74
                 continue;
75 75
             }
76 76
             $renderedFields[$key] = $field;
77 77
         }
78
-        $this->wrap($renderedFields, $review);
79
-        $renderedFields = apply_filters('site-reviews/review/build/after', $renderedFields, $review, $this);
78
+        $this->wrap( $renderedFields, $review );
79
+        $renderedFields = apply_filters( 'site-reviews/review/build/after', $renderedFields, $review, $this );
80 80
         $this->current = null;
81
-        return new ReviewHtml($review, (array) $renderedFields);
81
+        return new ReviewHtml( $review, (array)$renderedFields );
82 82
     }
83 83
 
84 84
     /**
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
     public function buildReviews()
88 88
     {
89 89
         $renderedReviews = [];
90
-        foreach ($this->reviews as $index => $review) {
91
-            $renderedReviews[] = $this->buildReview($review);
90
+        foreach( $this->reviews as $index => $review ) {
91
+            $renderedReviews[] = $this->buildReview( $review );
92 92
         }
93
-        return new ReviewsHtml($renderedReviews, $this->reviews->max_num_pages, $this->args);
93
+        return new ReviewsHtml( $renderedReviews, $this->reviews->max_num_pages, $this->args );
94 94
     }
95 95
 
96 96
     /**
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function generateSchema()
100 100
     {
101
-        if (!wp_validate_boolean($this->args['schema'])) {
101
+        if( !wp_validate_boolean( $this->args['schema'] ) ) {
102 102
             return;
103 103
         }
104
-        glsr(Schema::class)->store(
105
-            glsr(Schema::class)->build($this->args)
104
+        glsr( Schema::class )->store(
105
+            glsr( Schema::class )->build( $this->args )
106 106
         );
107 107
     }
108 108
 
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
      * @param string $path
112 112
      * @return bool
113 113
      */
114
-    public function isHidden($key, $path = '')
114
+    public function isHidden( $key, $path = '' )
115 115
     {
116 116
         $isOptionEnabled = !empty($path)
117
-            ? $this->isOptionEnabled($path)
117
+            ? $this->isOptionEnabled( $path )
118 118
             : true;
119
-        return in_array($key, $this->args['hide']) || !$isOptionEnabled;
119
+        return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled;
120 120
     }
121 121
 
122 122
     /**
@@ -124,19 +124,19 @@  discard block
 block discarded – undo
124 124
      * @param string $value
125 125
      * @return void|string
126 126
      */
127
-    protected function buildOptionAssignedTo($key, $value)
127
+    protected function buildOptionAssignedTo( $key, $value )
128 128
     {
129
-        if ($this->isHidden($key, 'settings.reviews.assigned_links')) {
129
+        if( $this->isHidden( $key, 'settings.reviews.assigned_links' ) ) {
130 130
             return;
131 131
         }
132
-        $post = glsr(Polylang::class)->getPost($value);
133
-        if (!($post instanceof WP_Post)) {
132
+        $post = glsr( Polylang::class )->getPost( $value );
133
+        if( !($post instanceof WP_Post) ) {
134 134
             return;
135 135
         }
136
-        $permalink = glsr(Builder::class)->a(get_the_title($post->ID), [
137
-            'href' => get_the_permalink($post->ID),
138
-        ]);
139
-        $assignedTo = sprintf(__('Review of %s', 'site-reviews'), $permalink);
136
+        $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [
137
+            'href' => get_the_permalink( $post->ID ),
138
+        ] );
139
+        $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink );
140 140
         return '<span>'.$assignedTo.'</span>';
141 141
     }
142 142
 
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
      * @param string $value
146 146
      * @return void|string
147 147
      */
148
-    protected function buildOptionAuthor($key, $value)
148
+    protected function buildOptionAuthor( $key, $value )
149 149
     {
150
-        if (!$this->isHidden($key)) {
150
+        if( !$this->isHidden( $key ) ) {
151 151
             $name = Str::convertName(
152 152
                 $value,
153
-                glsr_get_option('reviews.name.format'),
154
-                glsr_get_option('reviews.name.initial')
153
+                glsr_get_option( 'reviews.name.format' ),
154
+                glsr_get_option( 'reviews.name.initial' )
155 155
             );
156 156
             return '<span>'.$name.'</span>';
157 157
         }
@@ -162,18 +162,18 @@  discard block
 block discarded – undo
162 162
      * @param string $value
163 163
      * @return void|string
164 164
      */
165
-    protected function buildOptionAvatar($key, $value)
165
+    protected function buildOptionAvatar( $key, $value )
166 166
     {
167
-        if ($this->isHidden($key, 'settings.reviews.avatars')) {
167
+        if( $this->isHidden( $key, 'settings.reviews.avatars' ) ) {
168 168
             return;
169 169
         }
170
-        $size = $this->getOption('settings.reviews.avatars_size', 40);
171
-        return glsr(Builder::class)->img([
170
+        $size = $this->getOption( 'settings.reviews.avatars_size', 40 );
171
+        return glsr( Builder::class )->img( [
172 172
             'height' => $size,
173
-            'src' => $this->generateAvatar($value),
174
-            'style' => sprintf('width:%1$spx; height:%1$spx;', $size),
173
+            'src' => $this->generateAvatar( $value ),
174
+            'style' => sprintf( 'width:%1$spx; height:%1$spx;', $size ),
175 175
             'width' => $size,
176
-        ]);
176
+        ] );
177 177
     }
178 178
 
179 179
     /**
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
      * @param string $value
182 182
      * @return void|string
183 183
      */
184
-    protected function buildOptionContent($key, $value)
184
+    protected function buildOptionContent( $key, $value )
185 185
     {
186
-        $text = $this->normalizeText($value);
187
-        if (!$this->isHiddenOrEmpty($key, $text)) {
186
+        $text = $this->normalizeText( $value );
187
+        if( !$this->isHiddenOrEmpty( $key, $text ) ) {
188 188
             return '<p>'.$text.'</p>';
189 189
         }
190 190
     }
@@ -194,19 +194,19 @@  discard block
 block discarded – undo
194 194
      * @param string $value
195 195
      * @return void|string
196 196
      */
197
-    protected function buildOptionDate($key, $value)
197
+    protected function buildOptionDate( $key, $value )
198 198
     {
199
-        if ($this->isHidden($key)) {
199
+        if( $this->isHidden( $key ) ) {
200 200
             return;
201 201
         }
202
-        $dateFormat = $this->getOption('settings.reviews.date.format', 'default');
203
-        if ('relative' == $dateFormat) {
204
-            $date = glsr(Date::class)->relative($value);
202
+        $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' );
203
+        if( 'relative' == $dateFormat ) {
204
+            $date = glsr( Date::class )->relative( $value );
205 205
         } else {
206 206
             $format = 'custom' == $dateFormat
207
-                ? $this->getOption('settings.reviews.date.custom', 'M j, Y')
208
-                : glsr(OptionManager::class)->getWP('date_format', 'F j, Y');
209
-            $date = date_i18n($format, strtotime($value));
207
+                ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' )
208
+                : glsr( OptionManager::class )->getWP( 'date_format', 'F j, Y' );
209
+            $date = date_i18n( $format, strtotime( $value ) );
210 210
         }
211 211
         return '<span>'.$date.'</span>';
212 212
     }
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
      * @param string $value
217 217
      * @return void|string
218 218
      */
219
-    protected function buildOptionRating($key, $value)
219
+    protected function buildOptionRating( $key, $value )
220 220
     {
221
-        if (!$this->isHiddenOrEmpty($key, $value)) {
222
-            return glsr_star_rating($value);
221
+        if( !$this->isHiddenOrEmpty( $key, $value ) ) {
222
+            return glsr_star_rating( $value );
223 223
         }
224 224
     }
225 225
 
@@ -228,16 +228,16 @@  discard block
 block discarded – undo
228 228
      * @param string $value
229 229
      * @return void|string
230 230
      */
231
-    protected function buildOptionResponse($key, $value)
231
+    protected function buildOptionResponse( $key, $value )
232 232
     {
233
-        if ($this->isHiddenOrEmpty($key, $value)) {
233
+        if( $this->isHiddenOrEmpty( $key, $value ) ) {
234 234
             return;
235 235
         }
236
-        $title = sprintf(__('Response from %s', 'site-reviews'), get_bloginfo('name'));
237
-        $text = $this->normalizeText($value);
236
+        $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) );
237
+        $text = $this->normalizeText( $value );
238 238
         $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>';
239
-        $response = glsr(Builder::class)->div($text, ['class' => 'glsr-review-response-inner']);
240
-        $background = glsr(Builder::class)->div(['class' => 'glsr-review-response-background']);
239
+        $response = glsr( Builder::class )->div( $text, ['class' => 'glsr-review-response-inner'] );
240
+        $background = glsr( Builder::class )->div( ['class' => 'glsr-review-response-background'] );
241 241
         return $response.$background;
242 242
     }
243 243
 
@@ -246,13 +246,13 @@  discard block
 block discarded – undo
246 246
      * @param string $value
247 247
      * @return void|string
248 248
      */
249
-    protected function buildOptionTitle($key, $value)
249
+    protected function buildOptionTitle( $key, $value )
250 250
     {
251
-        if ($this->isHidden($key)) {
251
+        if( $this->isHidden( $key ) ) {
252 252
             return;
253 253
         }
254
-        if (empty($value)) {
255
-            $value = __('No Title', 'site-reviews');
254
+        if( empty($value) ) {
255
+            $value = __( 'No Title', 'site-reviews' );
256 256
         }
257 257
         return '<h3>'.$value.'</h3>';
258 258
     }
@@ -261,16 +261,16 @@  discard block
 block discarded – undo
261 261
      * @param string $avatarUrl
262 262
      * @return string
263 263
      */
264
-    protected function generateAvatar($avatarUrl)
264
+    protected function generateAvatar( $avatarUrl )
265 265
     {
266
-        if (!$this->isOptionEnabled('settings.reviews.avatars_regenerate') || 'local' != $this->current->review_type) {
266
+        if( !$this->isOptionEnabled( 'settings.reviews.avatars_regenerate' ) || 'local' != $this->current->review_type ) {
267 267
             return $avatarUrl;
268 268
         }
269
-        $authorIdOrEmail = get_the_author_meta('ID', $this->current->user_id);
270
-        if (empty($authorIdOrEmail)) {
269
+        $authorIdOrEmail = get_the_author_meta( 'ID', $this->current->user_id );
270
+        if( empty($authorIdOrEmail) ) {
271 271
             $authorIdOrEmail = $this->current->email;
272 272
         }
273
-        if ($newAvatar = get_avatar_url($authorIdOrEmail)) {
273
+        if( $newAvatar = get_avatar_url( $authorIdOrEmail ) ) {
274 274
             return $newAvatar;
275 275
         }
276 276
         return $avatarUrl;
@@ -280,20 +280,20 @@  discard block
 block discarded – undo
280 280
      * @param string $text
281 281
      * @return string
282 282
      */
283
-    protected function getExcerpt($text)
283
+    protected function getExcerpt( $text )
284 284
     {
285
-        $limit = intval($this->getOption('settings.reviews.excerpts_length', 55));
286
-        $split = extension_loaded('intl')
287
-            ? $this->getExcerptIntlSplit($text, $limit)
288
-            : $this->getExcerptSplit($text, $limit);
289
-        $hiddenText = substr($text, $split);
290
-        if (!empty($hiddenText)) {
291
-            $showMore = glsr(Builder::class)->span($hiddenText, [
285
+        $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 ) );
286
+        $split = extension_loaded( 'intl' )
287
+            ? $this->getExcerptIntlSplit( $text, $limit )
288
+            : $this->getExcerptSplit( $text, $limit );
289
+        $hiddenText = substr( $text, $split );
290
+        if( !empty($hiddenText) ) {
291
+            $showMore = glsr( Builder::class )->span( $hiddenText, [
292 292
                 'class' => 'glsr-hidden glsr-hidden-text',
293
-                'data-show-less' => __('Show less', 'site-reviews'),
294
-                'data-show-more' => __('Show more', 'site-reviews'),
295
-            ]);
296
-            $text = ltrim(substr($text, 0, $split)).$showMore;
293
+                'data-show-less' => __( 'Show less', 'site-reviews' ),
294
+                'data-show-more' => __( 'Show more', 'site-reviews' ),
295
+            ] );
296
+            $text = ltrim( substr( $text, 0, $split ) ).$showMore;
297 297
         }
298 298
         return $text;
299 299
     }
@@ -303,22 +303,22 @@  discard block
 block discarded – undo
303 303
      * @param int $limit
304 304
      * @return int
305 305
      */
306
-    protected function getExcerptIntlSplit($text, $limit)
306
+    protected function getExcerptIntlSplit( $text, $limit )
307 307
     {
308
-        $words = IntlRuleBasedBreakIterator::createWordInstance('');
309
-        $words->setText($text);
308
+        $words = IntlRuleBasedBreakIterator::createWordInstance( '' );
309
+        $words->setText( $text );
310 310
         $count = 0;
311
-        foreach ($words as $offset) {
312
-            if (IntlRuleBasedBreakIterator::WORD_NONE === $words->getRuleStatus()) {
311
+        foreach( $words as $offset ) {
312
+            if( IntlRuleBasedBreakIterator::WORD_NONE === $words->getRuleStatus() ) {
313 313
                 continue;
314 314
             }
315 315
             ++$count;
316
-            if ($count != $limit) {
316
+            if( $count != $limit ) {
317 317
                 continue;
318 318
             }
319 319
             return $offset;
320 320
         }
321
-        return strlen($text);
321
+        return strlen( $text );
322 322
     }
323 323
 
324 324
     /**
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
      * @param int $limit
327 327
      * @return int
328 328
      */
329
-    protected function getExcerptSplit($text, $limit)
329
+    protected function getExcerptSplit( $text, $limit )
330 330
     {
331
-        if (str_word_count($text, 0) > $limit) {
332
-            $words = array_keys(str_word_count($text, 2));
331
+        if( str_word_count( $text, 0 ) > $limit ) {
332
+            $words = array_keys( str_word_count( $text, 2 ) );
333 333
             return $words[$limit];
334 334
         }
335
-        return strlen($text);
335
+        return strlen( $text );
336 336
     }
337 337
 
338 338
     /**
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
      * @param mixed $fallback
341 341
      * @return mixed
342 342
      */
343
-    protected function getOption($path, $fallback = '')
343
+    protected function getOption( $path, $fallback = '' )
344 344
     {
345
-        if (array_key_exists($path, $this->options)) {
345
+        if( array_key_exists( $path, $this->options ) ) {
346 346
             return $this->options[$path];
347 347
         }
348 348
         return $fallback;
@@ -353,50 +353,50 @@  discard block
 block discarded – undo
353 353
      * @param string $value
354 354
      * @return bool
355 355
      */
356
-    protected function isHiddenOrEmpty($key, $value)
356
+    protected function isHiddenOrEmpty( $key, $value )
357 357
     {
358
-        return $this->isHidden($key) || empty($value);
358
+        return $this->isHidden( $key ) || empty($value);
359 359
     }
360 360
 
361 361
     /**
362 362
      * @param string $path
363 363
      * @return bool
364 364
      */
365
-    protected function isOptionEnabled($path)
365
+    protected function isOptionEnabled( $path )
366 366
     {
367
-        return 'yes' == $this->getOption($path);
367
+        return 'yes' == $this->getOption( $path );
368 368
     }
369 369
 
370 370
     /**
371 371
      * @param string $text
372 372
      * @return string
373 373
      */
374
-    protected function normalizeText($text)
374
+    protected function normalizeText( $text )
375 375
     {
376
-        $text = wp_kses($text, wp_kses_allowed_html());
377
-        $text = convert_smilies(strip_shortcodes($text));
378
-        $text = str_replace(']]>', ']]&gt;', $text);
379
-        $text = preg_replace('/(\R){2,}/', '$1', $text);
380
-        if ($this->isOptionEnabled('settings.reviews.excerpts')) {
381
-            $text = $this->getExcerpt($text);
376
+        $text = wp_kses( $text, wp_kses_allowed_html() );
377
+        $text = convert_smilies( strip_shortcodes( $text ) );
378
+        $text = str_replace( ']]>', ']]&gt;', $text );
379
+        $text = preg_replace( '/(\R){2,}/', '$1', $text );
380
+        if( $this->isOptionEnabled( 'settings.reviews.excerpts' ) ) {
381
+            $text = $this->getExcerpt( $text );
382 382
         }
383
-        return wptexturize(nl2br($text));
383
+        return wptexturize( nl2br( $text ) );
384 384
     }
385 385
 
386 386
     /**
387 387
      * @return void
388 388
      */
389
-    protected function wrap(array &$renderedFields, Review $review)
389
+    protected function wrap( array &$renderedFields, Review $review )
390 390
     {
391
-        $renderedFields = apply_filters('site-reviews/review/wrap', $renderedFields, $review, $this);
392
-        array_walk($renderedFields, function (&$value, $key) use ($review) {
393
-            $value = apply_filters('site-reviews/review/wrap/'.$key, $value, $review);
394
-            if (empty($value)) {
391
+        $renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review, $this );
392
+        array_walk( $renderedFields, function( &$value, $key ) use ($review) {
393
+            $value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review );
394
+            if( empty($value) ) {
395 395
                 return;
396 396
             }
397
-            $value = glsr(Builder::class)->div($value, [
397
+            $value = glsr( Builder::class )->div( $value, [
398 398
                 'class' => 'glsr-review-'.$key,
399
-            ]);
399
+            ] );
400 400
         });
401 401
     }
402 402
 }
Please login to merge, or discard this patch.
plugin/Modules/Blacklist.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -6,54 +6,54 @@
 block discarded – undo
6 6
 
7 7
 class Blacklist
8 8
 {
9
-    /**
10
-     * @return bool
11
-     */
12
-    public function isBlacklisted(array $review)
13
-    {
14
-        $target = implode("\n", array_filter([
15
-            $review['name'],
16
-            $review['content'],
17
-            $review['email'],
18
-            $review['ip_address'],
19
-            $review['title'],
20
-        ]));
21
-        return (bool) apply_filters('site-reviews/blacklist/is-blacklisted',
22
-            $this->check($target),
23
-            $review,
24
-            $target
25
-        );
26
-    }
9
+	/**
10
+	 * @return bool
11
+	 */
12
+	public function isBlacklisted(array $review)
13
+	{
14
+		$target = implode("\n", array_filter([
15
+			$review['name'],
16
+			$review['content'],
17
+			$review['email'],
18
+			$review['ip_address'],
19
+			$review['title'],
20
+		]));
21
+		return (bool) apply_filters('site-reviews/blacklist/is-blacklisted',
22
+			$this->check($target),
23
+			$review,
24
+			$target
25
+		);
26
+	}
27 27
 
28
-    /**
29
-     * @param string $target
30
-     * @return bool
31
-     */
32
-    protected function check($target)
33
-    {
34
-        $blacklist = $this->getBlacklist();
35
-        if (empty($blacklist)) {
36
-            return false;
37
-        }
38
-        $lines = explode("\n", $blacklist);
39
-        foreach ((array) $lines as $line) {
40
-            $line = trim($line);
41
-            if (empty($line) || 256 < strlen($line)) {
42
-                continue;
43
-            }
44
-            $pattern = sprintf('#%s#i', preg_quote($line, '#'));
45
-            if (preg_match($pattern, $target)) {
46
-                return true;
47
-            }
48
-        }
49
-        return false;
50
-    }
28
+	/**
29
+	 * @param string $target
30
+	 * @return bool
31
+	 */
32
+	protected function check($target)
33
+	{
34
+		$blacklist = $this->getBlacklist();
35
+		if (empty($blacklist)) {
36
+			return false;
37
+		}
38
+		$lines = explode("\n", $blacklist);
39
+		foreach ((array) $lines as $line) {
40
+			$line = trim($line);
41
+			if (empty($line) || 256 < strlen($line)) {
42
+				continue;
43
+			}
44
+			$pattern = sprintf('#%s#i', preg_quote($line, '#'));
45
+			if (preg_match($pattern, $target)) {
46
+				return true;
47
+			}
48
+		}
49
+		return false;
50
+	}
51 51
 
52
-    protected function getBlacklist()
53
-    {
54
-        $option = glsr(OptionManager::class)->get('settings.submissions.blacklist.integration');
55
-        return $option == 'comments'
56
-            ? trim(glsr(OptionManager::class)->getWP('blacklist_keys'))
57
-            : trim(glsr(OptionManager::class)->get('settings.submissions.blacklist.entries'));
58
-    }
52
+	protected function getBlacklist()
53
+	{
54
+		$option = glsr(OptionManager::class)->get('settings.submissions.blacklist.integration');
55
+		return $option == 'comments'
56
+			? trim(glsr(OptionManager::class)->getWP('blacklist_keys'))
57
+			: trim(glsr(OptionManager::class)->get('settings.submissions.blacklist.entries'));
58
+	}
59 59
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -9,17 +9,17 @@  discard block
 block discarded – undo
9 9
     /**
10 10
      * @return bool
11 11
      */
12
-    public function isBlacklisted(array $review)
12
+    public function isBlacklisted( array $review )
13 13
     {
14
-        $target = implode("\n", array_filter([
14
+        $target = implode( "\n", array_filter( [
15 15
             $review['name'],
16 16
             $review['content'],
17 17
             $review['email'],
18 18
             $review['ip_address'],
19 19
             $review['title'],
20
-        ]));
21
-        return (bool) apply_filters('site-reviews/blacklist/is-blacklisted',
22
-            $this->check($target),
20
+        ] ) );
21
+        return (bool)apply_filters( 'site-reviews/blacklist/is-blacklisted',
22
+            $this->check( $target ),
23 23
             $review,
24 24
             $target
25 25
         );
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
      * @param string $target
30 30
      * @return bool
31 31
      */
32
-    protected function check($target)
32
+    protected function check( $target )
33 33
     {
34 34
         $blacklist = $this->getBlacklist();
35
-        if (empty($blacklist)) {
35
+        if( empty($blacklist) ) {
36 36
             return false;
37 37
         }
38
-        $lines = explode("\n", $blacklist);
39
-        foreach ((array) $lines as $line) {
40
-            $line = trim($line);
41
-            if (empty($line) || 256 < strlen($line)) {
38
+        $lines = explode( "\n", $blacklist );
39
+        foreach( (array)$lines as $line ) {
40
+            $line = trim( $line );
41
+            if( empty($line) || 256 < strlen( $line ) ) {
42 42
                 continue;
43 43
             }
44
-            $pattern = sprintf('#%s#i', preg_quote($line, '#'));
45
-            if (preg_match($pattern, $target)) {
44
+            $pattern = sprintf( '#%s#i', preg_quote( $line, '#' ) );
45
+            if( preg_match( $pattern, $target ) ) {
46 46
                 return true;
47 47
             }
48 48
         }
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 
52 52
     protected function getBlacklist()
53 53
     {
54
-        $option = glsr(OptionManager::class)->get('settings.submissions.blacklist.integration');
54
+        $option = glsr( OptionManager::class )->get( 'settings.submissions.blacklist.integration' );
55 55
         return $option == 'comments'
56
-            ? trim(glsr(OptionManager::class)->getWP('blacklist_keys'))
57
-            : trim(glsr(OptionManager::class)->get('settings.submissions.blacklist.entries'));
56
+            ? trim( glsr( OptionManager::class )->getWP( 'blacklist_keys' ) )
57
+            : trim( glsr( OptionManager::class )->get( 'settings.submissions.blacklist.entries' ) );
58 58
     }
59 59
 }
Please login to merge, or discard this patch.