Passed
Push — master ( 6b35fa...ccb079 )
by Paul
10:24 queued 05:13
created
plugin/Modules/Html/Template.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -7,86 +7,86 @@
 block discarded – undo
7 7
 
8 8
 class Template
9 9
 {
10
-    /**
11
-     * @param string $templatePath
12
-     * @return void|string
13
-     */
14
-    public function build($templatePath, array $data = [])
15
-    {
16
-        $data = $this->normalize($data);
17
-        $path = Str::removePrefix('templates/', $templatePath);
18
-        $template = glsr()->build($templatePath, $data);
19
-        $template = apply_filters('site-reviews/build/template/'.$path, $template, $data);
20
-        $template = $this->interpolate($template, $data, $path);
21
-        $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data);
22
-        $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data);
23
-        return $template;
24
-    }
10
+	/**
11
+	 * @param string $templatePath
12
+	 * @return void|string
13
+	 */
14
+	public function build($templatePath, array $data = [])
15
+	{
16
+		$data = $this->normalize($data);
17
+		$path = Str::removePrefix('templates/', $templatePath);
18
+		$template = glsr()->build($templatePath, $data);
19
+		$template = apply_filters('site-reviews/build/template/'.$path, $template, $data);
20
+		$template = $this->interpolate($template, $data, $path);
21
+		$template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data);
22
+		$template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data);
23
+		return $template;
24
+	}
25 25
 
26
-    /**
27
-     * Interpolate context values into template placeholders.
28
-     * @param string $template
29
-     * @param string $templatePath
30
-     * @return string
31
-     */
32
-    public function interpolate($template, array $data = [], $templatePath)
33
-    {
34
-        $context = $this->normalizeContext(Arr::get($data, 'context', []));
35
-        $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data);
36
-        return $this->interpolateContext($template, $context);
37
-    }
26
+	/**
27
+	 * Interpolate context values into template placeholders.
28
+	 * @param string $template
29
+	 * @param string $templatePath
30
+	 * @return string
31
+	 */
32
+	public function interpolate($template, array $data = [], $templatePath)
33
+	{
34
+		$context = $this->normalizeContext(Arr::get($data, 'context', []));
35
+		$context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data);
36
+		return $this->interpolateContext($template, $context);
37
+	}
38 38
 
39
-    /**
40
-     * Interpolate context values into template placeholders.
41
-     * @param string $text
42
-     * @return string
43
-     */
44
-    public function interpolateContext($text, array $context = [])
45
-    {
46
-        foreach ($context as $key => $value) {
47
-            $text = strtr(
48
-                $text,
49
-                array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value)
50
-            );
51
-        }
52
-        return trim($text);
53
-    }
39
+	/**
40
+	 * Interpolate context values into template placeholders.
41
+	 * @param string $text
42
+	 * @return string
43
+	 */
44
+	public function interpolateContext($text, array $context = [])
45
+	{
46
+		foreach ($context as $key => $value) {
47
+			$text = strtr(
48
+				$text,
49
+				array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value)
50
+			);
51
+		}
52
+		return trim($text);
53
+	}
54 54
 
55
-    /**
56
-     * @param string $templatePath
57
-     * @return void|string
58
-     */
59
-    public function render($templatePath, array $data = [])
60
-    {
61
-        echo $this->build($templatePath, $data);
62
-    }
55
+	/**
56
+	 * @param string $templatePath
57
+	 * @return void|string
58
+	 */
59
+	public function render($templatePath, array $data = [])
60
+	{
61
+		echo $this->build($templatePath, $data);
62
+	}
63 63
 
64
-    /**
65
-     * @return array
66
-     */
67
-    protected function normalize(array $data)
68
-    {
69
-        $arrayKeys = ['context', 'globals'];
70
-        $data = wp_parse_args($data, array_fill_keys($arrayKeys, []));
71
-        foreach ($arrayKeys as $key) {
72
-            if (is_array($data[$key])) {
73
-                continue;
74
-            }
75
-            $data[$key] = [];
76
-        }
77
-        return $data;
78
-    }
64
+	/**
65
+	 * @return array
66
+	 */
67
+	protected function normalize(array $data)
68
+	{
69
+		$arrayKeys = ['context', 'globals'];
70
+		$data = wp_parse_args($data, array_fill_keys($arrayKeys, []));
71
+		foreach ($arrayKeys as $key) {
72
+			if (is_array($data[$key])) {
73
+				continue;
74
+			}
75
+			$data[$key] = [];
76
+		}
77
+		return $data;
78
+	}
79 79
 
80
-    /**
81
-     * @return array
82
-     */
83
-    protected function normalizeContext(array $context)
84
-    {
85
-        $context = array_filter($context, function ($value) {
86
-            return !is_array($value) && !is_object($value);
87
-        });
88
-        return array_map(function ($value) {
89
-            return (string) $value;
90
-        }, $context);
91
-    }
80
+	/**
81
+	 * @return array
82
+	 */
83
+	protected function normalizeContext(array $context)
84
+	{
85
+		$context = array_filter($context, function ($value) {
86
+			return !is_array($value) && !is_object($value);
87
+		});
88
+		return array_map(function ($value) {
89
+			return (string) $value;
90
+		}, $context);
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
      * @param string $templatePath
12 12
      * @return void|string
13 13
      */
14
-    public function build($templatePath, array $data = [])
14
+    public function build( $templatePath, array $data = [] )
15 15
     {
16
-        $data = $this->normalize($data);
17
-        $path = Str::removePrefix('templates/', $templatePath);
18
-        $template = glsr()->build($templatePath, $data);
19
-        $template = apply_filters('site-reviews/build/template/'.$path, $template, $data);
20
-        $template = $this->interpolate($template, $data, $path);
21
-        $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data);
22
-        $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data);
16
+        $data = $this->normalize( $data );
17
+        $path = Str::removePrefix( 'templates/', $templatePath );
18
+        $template = glsr()->build( $templatePath, $data );
19
+        $template = apply_filters( 'site-reviews/build/template/'.$path, $template, $data );
20
+        $template = $this->interpolate( $template, $data, $path );
21
+        $template = apply_filters( 'site-reviews/rendered/template', $template, $templatePath, $data );
22
+        $template = apply_filters( 'site-reviews/rendered/template/'.$path, $template, $data );
23 23
         return $template;
24 24
     }
25 25
 
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
      * @param string $templatePath
30 30
      * @return string
31 31
      */
32
-    public function interpolate($template, array $data = [], $templatePath)
32
+    public function interpolate( $template, array $data = [], $templatePath )
33 33
     {
34
-        $context = $this->normalizeContext(Arr::get($data, 'context', []));
35
-        $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data);
36
-        return $this->interpolateContext($template, $context);
34
+        $context = $this->normalizeContext( Arr::get( $data, 'context', [] ) );
35
+        $context = apply_filters( 'site-reviews/interpolate/'.$templatePath, $context, $template, $data );
36
+        return $this->interpolateContext( $template, $context );
37 37
     }
38 38
 
39 39
     /**
@@ -41,35 +41,35 @@  discard block
 block discarded – undo
41 41
      * @param string $text
42 42
      * @return string
43 43
      */
44
-    public function interpolateContext($text, array $context = [])
44
+    public function interpolateContext( $text, array $context = [] )
45 45
     {
46
-        foreach ($context as $key => $value) {
46
+        foreach( $context as $key => $value ) {
47 47
             $text = strtr(
48 48
                 $text,
49
-                array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value)
49
+                array_fill_keys( ['{'.$key.'}', '{{ '.$key.' }}'], $value )
50 50
             );
51 51
         }
52
-        return trim($text);
52
+        return trim( $text );
53 53
     }
54 54
 
55 55
     /**
56 56
      * @param string $templatePath
57 57
      * @return void|string
58 58
      */
59
-    public function render($templatePath, array $data = [])
59
+    public function render( $templatePath, array $data = [] )
60 60
     {
61
-        echo $this->build($templatePath, $data);
61
+        echo $this->build( $templatePath, $data );
62 62
     }
63 63
 
64 64
     /**
65 65
      * @return array
66 66
      */
67
-    protected function normalize(array $data)
67
+    protected function normalize( array $data )
68 68
     {
69 69
         $arrayKeys = ['context', 'globals'];
70
-        $data = wp_parse_args($data, array_fill_keys($arrayKeys, []));
71
-        foreach ($arrayKeys as $key) {
72
-            if (is_array($data[$key])) {
70
+        $data = wp_parse_args( $data, array_fill_keys( $arrayKeys, [] ) );
71
+        foreach( $arrayKeys as $key ) {
72
+            if( is_array( $data[$key] ) ) {
73 73
                 continue;
74 74
             }
75 75
             $data[$key] = [];
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
     /**
81 81
      * @return array
82 82
      */
83
-    protected function normalizeContext(array $context)
83
+    protected function normalizeContext( array $context )
84 84
     {
85
-        $context = array_filter($context, function ($value) {
86
-            return !is_array($value) && !is_object($value);
85
+        $context = array_filter( $context, function( $value ) {
86
+            return !is_array( $value ) && !is_object( $value );
87 87
         });
88
-        return array_map(function ($value) {
89
-            return (string) $value;
90
-        }, $context);
88
+        return array_map( function( $value ) {
89
+            return (string)$value;
90
+        }, $context );
91 91
     }
92 92
 }
Please login to merge, or discard this patch.
views/pages/tools/general.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,42 +1,42 @@  discard block
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3
-<?php if (glsr()->hasPermission('settings')) : ?>
3
+<?php if( glsr()->hasPermission( 'settings' ) ) : ?>
4 4
 <div class="glsr-card card">
5 5
     <h3>Export Settings</h3>
6 6
     <p>Export the Site Reviews settings for this site to a <code>*.json</code> file. This allows you to easily import the plugin settings into another site.</p>
7
-    <p>To export your Site Reviews' reviews and categories, please use the WordPress <a href="<?= admin_url('export.php'); ?>">Export</a> tool.</p>
7
+    <p>To export your Site Reviews' reviews and categories, please use the WordPress <a href="<?= admin_url( 'export.php' ); ?>">Export</a> tool.</p>
8 8
     <form method="post">
9 9
         <input type="hidden" name="{{ id }}[_action]" value="export-settings">
10
-        <?php wp_nonce_field('export-settings'); ?>
11
-        <?php submit_button(__('Export Settings', 'site-reviews'), 'secondary'); ?>
10
+        <?php wp_nonce_field( 'export-settings' ); ?>
11
+        <?php submit_button( __( 'Export Settings', 'site-reviews' ), 'secondary' ); ?>
12 12
     </form>
13 13
 </div>
14 14
 <?php endif; ?>
15 15
 
16
-<?php if (glsr()->hasPermission('settings')) : ?>
16
+<?php if( glsr()->hasPermission( 'settings' ) ) : ?>
17 17
 <div class="glsr-card card">
18 18
     <h3>Import Settings</h3>
19 19
     <p>Import the Site Reviews settings from a <code>*.json</code> file. This file can be obtained by exporting the settings on another site using the export tool below.</p>
20
-    <p>To import your Site Reviews' reviews and categories from another website, please use the WordPress <a href="<?= admin_url('import.php'); ?>">Import</a> tool.</p>
20
+    <p>To import your Site Reviews' reviews and categories from another website, please use the WordPress <a href="<?= admin_url( 'import.php' ); ?>">Import</a> tool.</p>
21 21
     <form method="post" enctype="multipart/form-data">
22 22
         <input type="file" name="import-file">
23 23
         <input type="hidden" name="{{ id }}[_action]" value="import-settings">
24
-        <?php wp_nonce_field('import-settings'); ?>
25
-        <?php submit_button(__('Import Settings', 'site-reviews'), 'secondary'); ?>
24
+        <?php wp_nonce_field( 'import-settings' ); ?>
25
+        <?php submit_button( __( 'Import Settings', 'site-reviews' ), 'secondary' ); ?>
26 26
     </form>
27 27
 </div>
28 28
 <?php endif; ?>
29 29
 
30
-<?php if (glsr()->hasPermission('settings')) : ?>
30
+<?php if( glsr()->hasPermission( 'settings' ) ) : ?>
31 31
 <div class="glsr-card card">
32 32
     <h3>Migrate Plugin</h3>
33 33
     <p>Run this tool if your reviews stopped working correctly after upgrading the plugin to the latest version (i.e. read-only reviews, zero-star ratings, missing role capabilities, etc.).</p>
34 34
     <form method="post">
35 35
         <input type="hidden" name="{{ id }}[_action]" value="migrate-reviews">
36
-        <?php wp_nonce_field('migrate-reviews'); ?>
36
+        <?php wp_nonce_field( 'migrate-reviews' ); ?>
37 37
         <p class="submit">
38 38
             <button type="submit" class="glsr-button button" name="migrate-reviews" id="migrate-reviews">
39
-                <span data-loading="<?= __('Migrating Reviews, please wait...', 'site-reviews'); ?>"><?= __('Run Migration', 'site-reviews'); ?></span>
39
+                <span data-loading="<?= __( 'Migrating Reviews, please wait...', 'site-reviews' ); ?>"><?= __( 'Run Migration', 'site-reviews' ); ?></span>
40 40
             </button>
41 41
         </p>
42 42
     </form>
@@ -49,26 +49,26 @@  discard block
 block discarded – undo
49 49
     <p>If you suspect that the rating counts are incorrect (perhaps you have cloned a page that had reviews assigned to it, or edited/deleted reviews directly from your database), you can recalculate them here.</p>
50 50
     <form method="post">
51 51
         <input type="hidden" name="{{ id }}[_action]" value="count-reviews">
52
-        <?php wp_nonce_field('count-reviews'); ?>
52
+        <?php wp_nonce_field( 'count-reviews' ); ?>
53 53
         <p class="submit">
54 54
             <button type="submit" class="glsr-button button" name="count-reviews" id="count-reviews">
55
-                <span data-loading="<?= __('Recalculating Counts, please wait...', 'site-reviews'); ?>"><?= __('Recalculate Counts', 'site-reviews'); ?></span>
55
+                <span data-loading="<?= __( 'Recalculating Counts, please wait...', 'site-reviews' ); ?>"><?= __( 'Recalculate Counts', 'site-reviews' ); ?></span>
56 56
             </button>
57 57
         </p>
58 58
     </form>
59 59
 </div>
60 60
 
61
-<?php if (glsr()->hasPermission('settings')) : ?>
61
+<?php if( glsr()->hasPermission( 'settings' ) ) : ?>
62 62
 <div class="glsr-card card">
63 63
     <h3>Reset Permissions</h3>
64 64
     <p>Site Reviews provides custom post_type capabilities that mirror the capabilities of your posts by default. For example, if a user role has permission to edit others posts, then that role will also have permission to edit other users reviews.</p>
65 65
     <p>If you have changed the capabilities of your user roles and you suspect that Site Reviews is not working correctly due to your changes, you may use this tool to reset the Site Reviews capabilities for your user roles.</p>
66 66
     <form method="post">
67 67
         <input type="hidden" name="{{ id }}[_action]" value="reset-permissions">
68
-        <?php wp_nonce_field('reset-permissions'); ?>
68
+        <?php wp_nonce_field( 'reset-permissions' ); ?>
69 69
         <p class="submit">
70 70
             <button type="submit" class="glsr-button button" name="reset-permissions" id="reset-permissions">
71
-                <span data-loading="<?= __('Resetting Permissions, please wait...', 'site-reviews'); ?>"><?= __('Reset Permissions', 'site-reviews'); ?></span>
71
+                <span data-loading="<?= __( 'Resetting Permissions, please wait...', 'site-reviews' ); ?>"><?= __( 'Reset Permissions', 'site-reviews' ); ?></span>
72 72
             </button>
73 73
         </p>
74 74
     </form>
Please login to merge, or discard this patch.