@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <table class="form-table"> |
4 | 4 | <tbody> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <table class="form-table"> |
4 | 4 | <tbody> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <table class="form-table"> |
4 | 4 | <tbody> |
@@ -8,137 +8,137 @@ |
||
8 | 8 | */ |
9 | 9 | class GL_Plugin_Check_v3 |
10 | 10 | { |
11 | - const MIN_PHP_VERSION = '5.6.0'; |
|
12 | - const MIN_WORDPRESS_VERSION = '4.7.0'; |
|
11 | + const MIN_PHP_VERSION = '5.6.0'; |
|
12 | + const MIN_WORDPRESS_VERSION = '4.7.0'; |
|
13 | 13 | |
14 | - /** |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $file; |
|
14 | + /** |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $file; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected $versions; |
|
19 | + /** |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected $versions; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @param string $file |
|
26 | - */ |
|
27 | - public function __construct($file, array $versions = array()) |
|
28 | - { |
|
29 | - $this->file = realpath($file); |
|
30 | - $this->versions = wp_parse_args($versions, array( |
|
31 | - 'php' => static::MIN_PHP_VERSION, |
|
32 | - 'wordpress' => static::MIN_WORDPRESS_VERSION, |
|
33 | - )); |
|
34 | - } |
|
24 | + /** |
|
25 | + * @param string $file |
|
26 | + */ |
|
27 | + public function __construct($file, array $versions = array()) |
|
28 | + { |
|
29 | + $this->file = realpath($file); |
|
30 | + $this->versions = wp_parse_args($versions, array( |
|
31 | + 'php' => static::MIN_PHP_VERSION, |
|
32 | + 'wordpress' => static::MIN_WORDPRESS_VERSION, |
|
33 | + )); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @return bool |
|
38 | - */ |
|
39 | - public function canProceed() |
|
40 | - { |
|
41 | - if ($this->isValid()) { |
|
42 | - return true; |
|
43 | - } |
|
44 | - add_action('activated_plugin', array($this, 'deactivate')); |
|
45 | - add_action('admin_notices', array($this, 'deactivate')); |
|
46 | - return false; |
|
47 | - } |
|
36 | + /** |
|
37 | + * @return bool |
|
38 | + */ |
|
39 | + public function canProceed() |
|
40 | + { |
|
41 | + if ($this->isValid()) { |
|
42 | + return true; |
|
43 | + } |
|
44 | + add_action('activated_plugin', array($this, 'deactivate')); |
|
45 | + add_action('admin_notices', array($this, 'deactivate')); |
|
46 | + return false; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return bool |
|
51 | - */ |
|
52 | - public function isPhpValid() |
|
53 | - { |
|
54 | - return !version_compare(PHP_VERSION, $this->versions['php'], '<'); |
|
55 | - } |
|
49 | + /** |
|
50 | + * @return bool |
|
51 | + */ |
|
52 | + public function isPhpValid() |
|
53 | + { |
|
54 | + return !version_compare(PHP_VERSION, $this->versions['php'], '<'); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return bool |
|
59 | - */ |
|
60 | - public function isValid() |
|
61 | - { |
|
62 | - return $this->isPhpValid() && $this->isWpValid(); |
|
63 | - } |
|
57 | + /** |
|
58 | + * @return bool |
|
59 | + */ |
|
60 | + public function isValid() |
|
61 | + { |
|
62 | + return $this->isPhpValid() && $this->isWpValid(); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return bool |
|
67 | - */ |
|
68 | - public function isWpValid() |
|
69 | - { |
|
70 | - global $wp_version; |
|
71 | - return !version_compare($wp_version, $this->versions['wordpress'], '<'); |
|
72 | - } |
|
65 | + /** |
|
66 | + * @return bool |
|
67 | + */ |
|
68 | + public function isWpValid() |
|
69 | + { |
|
70 | + global $wp_version; |
|
71 | + return !version_compare($wp_version, $this->versions['wordpress'], '<'); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @param string $plugin |
|
76 | - * @return void |
|
77 | - */ |
|
78 | - public function deactivate($plugin) |
|
79 | - { |
|
80 | - if ($this->isValid()) { |
|
81 | - return; |
|
82 | - } |
|
83 | - $pluginSlug = plugin_basename($this->file); |
|
84 | - if ($plugin == $pluginSlug) { |
|
85 | - $this->redirect(); //exit |
|
86 | - } |
|
87 | - $pluginData = get_file_data($this->file, array('name' => 'Plugin Name'), 'plugin'); |
|
88 | - deactivate_plugins($pluginSlug); |
|
89 | - $this->printNotice($pluginData['name']); |
|
90 | - } |
|
74 | + /** |
|
75 | + * @param string $plugin |
|
76 | + * @return void |
|
77 | + */ |
|
78 | + public function deactivate($plugin) |
|
79 | + { |
|
80 | + if ($this->isValid()) { |
|
81 | + return; |
|
82 | + } |
|
83 | + $pluginSlug = plugin_basename($this->file); |
|
84 | + if ($plugin == $pluginSlug) { |
|
85 | + $this->redirect(); //exit |
|
86 | + } |
|
87 | + $pluginData = get_file_data($this->file, array('name' => 'Plugin Name'), 'plugin'); |
|
88 | + deactivate_plugins($pluginSlug); |
|
89 | + $this->printNotice($pluginData['name']); |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * @return array |
|
94 | - */ |
|
95 | - protected function getMessages() |
|
96 | - { |
|
97 | - return array( |
|
98 | - __('The %s plugin was deactivated.', 'site-reviews'), |
|
99 | - __('This plugin requires %s or greater in order to work properly.', 'site-reviews'), |
|
100 | - __('Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'site-reviews'), |
|
101 | - __('PHP version', 'site-reviews'), |
|
102 | - __('WordPress version', 'site-reviews'), |
|
103 | - __('Update WordPress', 'site-reviews'), |
|
104 | - __('You can use the %s plugin to restore %s to the previous version.', 'site-reviews'), |
|
105 | - ); |
|
106 | - } |
|
92 | + /** |
|
93 | + * @return array |
|
94 | + */ |
|
95 | + protected function getMessages() |
|
96 | + { |
|
97 | + return array( |
|
98 | + __('The %s plugin was deactivated.', 'site-reviews'), |
|
99 | + __('This plugin requires %s or greater in order to work properly.', 'site-reviews'), |
|
100 | + __('Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'site-reviews'), |
|
101 | + __('PHP version', 'site-reviews'), |
|
102 | + __('WordPress version', 'site-reviews'), |
|
103 | + __('Update WordPress', 'site-reviews'), |
|
104 | + __('You can use the %s plugin to restore %s to the previous version.', 'site-reviews'), |
|
105 | + ); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * @param string $pluginName |
|
110 | - * @return void |
|
111 | - */ |
|
112 | - protected function printNotice($pluginName) |
|
113 | - { |
|
114 | - $noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>'; |
|
115 | - $messages = $this->getMessages(); |
|
116 | - $rollbackMessage = sprintf('<strong>'.$messages[6].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName); |
|
117 | - if (!$this->isPhpValid()) { |
|
118 | - printf($noticeTemplate, |
|
119 | - sprintf($messages[0], $pluginName), |
|
120 | - sprintf($messages[1], $messages[3].' '.$this->versions['php']), |
|
121 | - sprintf($messages[2], PHP_VERSION).'</p><p>'.$rollbackMessage |
|
122 | - ); |
|
123 | - } elseif (!$this->isWpValid()) { |
|
124 | - printf($noticeTemplate, |
|
125 | - sprintf($messages[0], $pluginName), |
|
126 | - sprintf($messages[1], $messages[4].' '.$this->versions['wordpress']), |
|
127 | - $rollbackMessage.'</p><p>'.sprintf('<a href="%s">%s</a>', admin_url('update-core.php'), $messages[5]) |
|
128 | - ); |
|
129 | - } |
|
130 | - } |
|
108 | + /** |
|
109 | + * @param string $pluginName |
|
110 | + * @return void |
|
111 | + */ |
|
112 | + protected function printNotice($pluginName) |
|
113 | + { |
|
114 | + $noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>'; |
|
115 | + $messages = $this->getMessages(); |
|
116 | + $rollbackMessage = sprintf('<strong>'.$messages[6].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName); |
|
117 | + if (!$this->isPhpValid()) { |
|
118 | + printf($noticeTemplate, |
|
119 | + sprintf($messages[0], $pluginName), |
|
120 | + sprintf($messages[1], $messages[3].' '.$this->versions['php']), |
|
121 | + sprintf($messages[2], PHP_VERSION).'</p><p>'.$rollbackMessage |
|
122 | + ); |
|
123 | + } elseif (!$this->isWpValid()) { |
|
124 | + printf($noticeTemplate, |
|
125 | + sprintf($messages[0], $pluginName), |
|
126 | + sprintf($messages[1], $messages[4].' '.$this->versions['wordpress']), |
|
127 | + $rollbackMessage.'</p><p>'.sprintf('<a href="%s">%s</a>', admin_url('update-core.php'), $messages[5]) |
|
128 | + ); |
|
129 | + } |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * @return void |
|
134 | - */ |
|
135 | - protected function redirect() |
|
136 | - { |
|
137 | - wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s', |
|
138 | - filter_input(INPUT_GET, 'plugin_status'), |
|
139 | - filter_input(INPUT_GET, 'paged'), |
|
140 | - filter_input(INPUT_GET, 's') |
|
141 | - ))); |
|
142 | - exit; |
|
143 | - } |
|
132 | + /** |
|
133 | + * @return void |
|
134 | + */ |
|
135 | + protected function redirect() |
|
136 | + { |
|
137 | + wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s', |
|
138 | + filter_input(INPUT_GET, 'plugin_status'), |
|
139 | + filter_input(INPUT_GET, 'paged'), |
|
140 | + filter_input(INPUT_GET, 's') |
|
141 | + ))); |
|
142 | + exit; |
|
143 | + } |
|
144 | 144 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -defined('WPINC') || die; |
|
3 | +defined( 'WPINC' ) || die; |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Check for minimum system requirments on plugin activation. |
@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @param string $file |
26 | 26 | */ |
27 | - public function __construct($file, array $versions = array()) |
|
27 | + public function __construct( $file, array $versions = array() ) |
|
28 | 28 | { |
29 | - $this->file = realpath($file); |
|
30 | - $this->versions = wp_parse_args($versions, array( |
|
29 | + $this->file = realpath( $file ); |
|
30 | + $this->versions = wp_parse_args( $versions, array( |
|
31 | 31 | 'php' => static::MIN_PHP_VERSION, |
32 | 32 | 'wordpress' => static::MIN_WORDPRESS_VERSION, |
33 | - )); |
|
33 | + ) ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function canProceed() |
40 | 40 | { |
41 | - if ($this->isValid()) { |
|
41 | + if( $this->isValid() ) { |
|
42 | 42 | return true; |
43 | 43 | } |
44 | - add_action('activated_plugin', array($this, 'deactivate')); |
|
45 | - add_action('admin_notices', array($this, 'deactivate')); |
|
44 | + add_action( 'activated_plugin', array( $this, 'deactivate' ) ); |
|
45 | + add_action( 'admin_notices', array( $this, 'deactivate' ) ); |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function isPhpValid() |
53 | 53 | { |
54 | - return !version_compare(PHP_VERSION, $this->versions['php'], '<'); |
|
54 | + return !version_compare( PHP_VERSION, $this->versions['php'], '<' ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -68,25 +68,25 @@ discard block |
||
68 | 68 | public function isWpValid() |
69 | 69 | { |
70 | 70 | global $wp_version; |
71 | - return !version_compare($wp_version, $this->versions['wordpress'], '<'); |
|
71 | + return !version_compare( $wp_version, $this->versions['wordpress'], '<' ); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @param string $plugin |
76 | 76 | * @return void |
77 | 77 | */ |
78 | - public function deactivate($plugin) |
|
78 | + public function deactivate( $plugin ) |
|
79 | 79 | { |
80 | - if ($this->isValid()) { |
|
80 | + if( $this->isValid() ) { |
|
81 | 81 | return; |
82 | 82 | } |
83 | - $pluginSlug = plugin_basename($this->file); |
|
84 | - if ($plugin == $pluginSlug) { |
|
83 | + $pluginSlug = plugin_basename( $this->file ); |
|
84 | + if( $plugin == $pluginSlug ) { |
|
85 | 85 | $this->redirect(); //exit |
86 | 86 | } |
87 | - $pluginData = get_file_data($this->file, array('name' => 'Plugin Name'), 'plugin'); |
|
88 | - deactivate_plugins($pluginSlug); |
|
89 | - $this->printNotice($pluginData['name']); |
|
87 | + $pluginData = get_file_data( $this->file, array( 'name' => 'Plugin Name' ), 'plugin' ); |
|
88 | + deactivate_plugins( $pluginSlug ); |
|
89 | + $this->printNotice( $pluginData['name'] ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | protected function getMessages() |
96 | 96 | { |
97 | 97 | return array( |
98 | - __('The %s plugin was deactivated.', 'site-reviews'), |
|
99 | - __('This plugin requires %s or greater in order to work properly.', 'site-reviews'), |
|
100 | - __('Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'site-reviews'), |
|
101 | - __('PHP version', 'site-reviews'), |
|
102 | - __('WordPress version', 'site-reviews'), |
|
103 | - __('Update WordPress', 'site-reviews'), |
|
104 | - __('You can use the %s plugin to restore %s to the previous version.', 'site-reviews'), |
|
98 | + __( 'The %s plugin was deactivated.', 'site-reviews' ), |
|
99 | + __( 'This plugin requires %s or greater in order to work properly.', 'site-reviews' ), |
|
100 | + __( 'Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'site-reviews' ), |
|
101 | + __( 'PHP version', 'site-reviews' ), |
|
102 | + __( 'WordPress version', 'site-reviews' ), |
|
103 | + __( 'Update WordPress', 'site-reviews' ), |
|
104 | + __( 'You can use the %s plugin to restore %s to the previous version.', 'site-reviews' ), |
|
105 | 105 | ); |
106 | 106 | } |
107 | 107 | |
@@ -109,22 +109,22 @@ discard block |
||
109 | 109 | * @param string $pluginName |
110 | 110 | * @return void |
111 | 111 | */ |
112 | - protected function printNotice($pluginName) |
|
112 | + protected function printNotice( $pluginName ) |
|
113 | 113 | { |
114 | 114 | $noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>'; |
115 | 115 | $messages = $this->getMessages(); |
116 | - $rollbackMessage = sprintf('<strong>'.$messages[6].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName); |
|
117 | - if (!$this->isPhpValid()) { |
|
118 | - printf($noticeTemplate, |
|
119 | - sprintf($messages[0], $pluginName), |
|
120 | - sprintf($messages[1], $messages[3].' '.$this->versions['php']), |
|
121 | - sprintf($messages[2], PHP_VERSION).'</p><p>'.$rollbackMessage |
|
116 | + $rollbackMessage = sprintf( '<strong>'.$messages[6].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName ); |
|
117 | + if( !$this->isPhpValid() ) { |
|
118 | + printf( $noticeTemplate, |
|
119 | + sprintf( $messages[0], $pluginName ), |
|
120 | + sprintf( $messages[1], $messages[3].' '.$this->versions['php'] ), |
|
121 | + sprintf( $messages[2], PHP_VERSION ).'</p><p>'.$rollbackMessage |
|
122 | 122 | ); |
123 | - } elseif (!$this->isWpValid()) { |
|
124 | - printf($noticeTemplate, |
|
125 | - sprintf($messages[0], $pluginName), |
|
126 | - sprintf($messages[1], $messages[4].' '.$this->versions['wordpress']), |
|
127 | - $rollbackMessage.'</p><p>'.sprintf('<a href="%s">%s</a>', admin_url('update-core.php'), $messages[5]) |
|
123 | + } elseif( !$this->isWpValid() ) { |
|
124 | + printf( $noticeTemplate, |
|
125 | + sprintf( $messages[0], $pluginName ), |
|
126 | + sprintf( $messages[1], $messages[4].' '.$this->versions['wordpress'] ), |
|
127 | + $rollbackMessage.'</p><p>'.sprintf( '<a href="%s">%s</a>', admin_url( 'update-core.php' ), $messages[5] ) |
|
128 | 128 | ); |
129 | 129 | } |
130 | 130 | } |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function redirect() |
136 | 136 | { |
137 | - wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s', |
|
138 | - filter_input(INPUT_GET, 'plugin_status'), |
|
139 | - filter_input(INPUT_GET, 'paged'), |
|
140 | - filter_input(INPUT_GET, 's') |
|
141 | - ))); |
|
137 | + wp_safe_redirect( self_admin_url( sprintf( 'plugins.php?plugin_status=%s&paged=%s&s=%s', |
|
138 | + filter_input( INPUT_GET, 'plugin_status' ), |
|
139 | + filter_input( INPUT_GET, 'paged' ), |
|
140 | + filter_input( INPUT_GET, 's' ) |
|
141 | + ) ) ); |
|
142 | 142 | exit; |
143 | 143 | } |
144 | 144 | } |
@@ -120,7 +120,8 @@ |
||
120 | 120 | sprintf($messages[1], $messages[3].' '.$this->versions['php']), |
121 | 121 | sprintf($messages[2], PHP_VERSION).'</p><p>'.$rollbackMessage |
122 | 122 | ); |
123 | - } elseif (!$this->isWpValid()) { |
|
123 | + } |
|
124 | + elseif (!$this->isWpValid()) { |
|
124 | 125 | printf($noticeTemplate, |
125 | 126 | sprintf($messages[0], $pluginName), |
126 | 127 | sprintf($messages[1], $messages[4].' '.$this->versions['wordpress']), |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-form-wrap"> |
4 | 4 | <form class="{{ class }}" id="{{ id }}" method="post" enctype="multipart/form-data"> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-form-message {{ class }}"> |
4 | 4 | {{ message }} |
@@ -5,23 +5,23 @@ |
||
5 | 5 | require_once ABSPATH.WPINC.'/class-phpass.php'; |
6 | 6 | |
7 | 7 | spl_autoload_register(function ($className) { |
8 | - $namespaces = [ |
|
9 | - 'GeminiLabs\\SiteReviews\\' => __DIR__.'/plugin/', |
|
10 | - 'GeminiLabs\\SiteReviews\\Tests\\' => __DIR__.'/tests/', |
|
11 | - 'GeminiLabs\\Sepia\\PoParser\\' => __DIR__.'/vendors/sepia/po-parser/', |
|
12 | - 'GeminiLabs\\Sinergi\\BrowserDetector\\' => __DIR__.'/vendors/sinergi/browser-detector/', |
|
13 | - 'GeminiLabs\\Vectorface\\Whip\\' => __DIR__.'/vendors/vectorface/whip/', |
|
14 | - ]; |
|
15 | - foreach ($namespaces as $prefix => $baseDir) { |
|
16 | - $len = strlen($prefix); |
|
17 | - if (0 !== strncmp($prefix, $className, $len)) { |
|
18 | - continue; |
|
19 | - } |
|
20 | - $file = $baseDir.str_replace('\\', '/', substr($className, $len)).'.php'; |
|
21 | - if (!file_exists($file)) { |
|
22 | - continue; |
|
23 | - } |
|
24 | - require $file; |
|
25 | - break; |
|
26 | - } |
|
8 | + $namespaces = [ |
|
9 | + 'GeminiLabs\\SiteReviews\\' => __DIR__.'/plugin/', |
|
10 | + 'GeminiLabs\\SiteReviews\\Tests\\' => __DIR__.'/tests/', |
|
11 | + 'GeminiLabs\\Sepia\\PoParser\\' => __DIR__.'/vendors/sepia/po-parser/', |
|
12 | + 'GeminiLabs\\Sinergi\\BrowserDetector\\' => __DIR__.'/vendors/sinergi/browser-detector/', |
|
13 | + 'GeminiLabs\\Vectorface\\Whip\\' => __DIR__.'/vendors/vectorface/whip/', |
|
14 | + ]; |
|
15 | + foreach ($namespaces as $prefix => $baseDir) { |
|
16 | + $len = strlen($prefix); |
|
17 | + if (0 !== strncmp($prefix, $className, $len)) { |
|
18 | + continue; |
|
19 | + } |
|
20 | + $file = $baseDir.str_replace('\\', '/', substr($className, $len)).'.php'; |
|
21 | + if (!file_exists($file)) { |
|
22 | + continue; |
|
23 | + } |
|
24 | + require $file; |
|
25 | + break; |
|
26 | + } |
|
27 | 27 | }); |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -defined('WPINC') || die; |
|
3 | +defined( 'WPINC' ) || die; |
|
4 | 4 | |
5 | 5 | require_once ABSPATH.WPINC.'/class-phpass.php'; |
6 | 6 | |
7 | -spl_autoload_register(function ($className) { |
|
7 | +spl_autoload_register( function( $className ) { |
|
8 | 8 | $namespaces = [ |
9 | 9 | 'GeminiLabs\\SiteReviews\\' => __DIR__.'/plugin/', |
10 | 10 | 'GeminiLabs\\SiteReviews\\Tests\\' => __DIR__.'/tests/', |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | 'GeminiLabs\\Sinergi\\BrowserDetector\\' => __DIR__.'/vendors/sinergi/browser-detector/', |
13 | 13 | 'GeminiLabs\\Vectorface\\Whip\\' => __DIR__.'/vendors/vectorface/whip/', |
14 | 14 | ]; |
15 | - foreach ($namespaces as $prefix => $baseDir) { |
|
16 | - $len = strlen($prefix); |
|
17 | - if (0 !== strncmp($prefix, $className, $len)) { |
|
15 | + foreach( $namespaces as $prefix => $baseDir ) { |
|
16 | + $len = strlen( $prefix ); |
|
17 | + if( 0 !== strncmp( $prefix, $className, $len ) ) { |
|
18 | 18 | continue; |
19 | 19 | } |
20 | - $file = $baseDir.str_replace('\\', '/', substr($className, $len)).'.php'; |
|
21 | - if (!file_exists($file)) { |
|
20 | + $file = $baseDir.str_replace( '\\', '/', substr( $className, $len ) ).'.php'; |
|
21 | + if( !file_exists( $file ) ) { |
|
22 | 22 | continue; |
23 | 23 | } |
24 | 24 | require $file; |
@@ -8,10 +8,10 @@ discard block |
||
8 | 8 | * @see https://www.elegantthemes.com/gallery/divi/ |
9 | 9 | */ |
10 | 10 | add_action('site-reviews/customize/divi', function ($instance) { |
11 | - if ('label' != $instance->tag || 'checkbox' != $instance->args['type']) { |
|
12 | - return; |
|
13 | - } |
|
14 | - $instance->args['text'] = '<i></i>'.$instance->args['text']; |
|
11 | + if ('label' != $instance->tag || 'checkbox' != $instance->args['type']) { |
|
12 | + return; |
|
13 | + } |
|
14 | + $instance->args['text'] = '<i></i>'.$instance->args['text']; |
|
15 | 15 | }); |
16 | 16 | |
17 | 17 | /* |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | * @see https://wordpress.org/plugins/wp-super-cache/ |
23 | 23 | */ |
24 | 24 | add_action('site-reviews/review/created', function ($review, $request) { |
25 | - if (!function_exists('wp_cache_post_change')) { |
|
26 | - return; |
|
27 | - } |
|
28 | - wp_cache_post_change($request->post_id); |
|
29 | - if (empty($review->assigned_to) || $review->assigned_to == $request->post_id) { |
|
30 | - return; |
|
31 | - } |
|
32 | - wp_cache_post_change($review->assigned_to); |
|
25 | + if (!function_exists('wp_cache_post_change')) { |
|
26 | + return; |
|
27 | + } |
|
28 | + wp_cache_post_change($request->post_id); |
|
29 | + if (empty($review->assigned_to) || $review->assigned_to == $request->post_id) { |
|
30 | + return; |
|
31 | + } |
|
32 | + wp_cache_post_change($review->assigned_to); |
|
33 | 33 | }, 10, 2); |
34 | 34 | |
35 | 35 | /* |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * @see https://wordpress.org/plugins/speed-booster-pack/ |
39 | 39 | */ |
40 | 40 | add_filter('sbp_exclude_defer_scripts', function ($scriptHandles) { |
41 | - $scriptHandles[] = 'site-reviews/google-recaptcha'; |
|
42 | - return array_keys(array_flip($scriptHandles)); |
|
41 | + $scriptHandles[] = 'site-reviews/google-recaptcha'; |
|
42 | + return array_keys(array_flip($scriptHandles)); |
|
43 | 43 | }); |
44 | 44 | |
45 | 45 | /* |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @see https://searchandfilter.com/ |
50 | 50 | */ |
51 | 51 | add_filter('sf_edit_query_args', function ($query) { |
52 | - if (!empty($query['meta_key']) && '_glsr_ranking' == $query['meta_key']) { |
|
53 | - unset($query['meta_key']); |
|
54 | - $query['meta_query'] = [ |
|
55 | - 'relation' => 'OR', |
|
56 | - ['key' => '_glsr_ranking', 'compare' => 'NOT EXISTS'], // this comes first! |
|
57 | - ['key' => '_glsr_ranking', 'compare' => 'EXISTS'], |
|
58 | - ]; |
|
59 | - } |
|
60 | - return $query; |
|
52 | + if (!empty($query['meta_key']) && '_glsr_ranking' == $query['meta_key']) { |
|
53 | + unset($query['meta_key']); |
|
54 | + $query['meta_query'] = [ |
|
55 | + 'relation' => 'OR', |
|
56 | + ['key' => '_glsr_ranking', 'compare' => 'NOT EXISTS'], // this comes first! |
|
57 | + ['key' => '_glsr_ranking', 'compare' => 'EXISTS'], |
|
58 | + ]; |
|
59 | + } |
|
60 | + return $query; |
|
61 | 61 | }, 20); |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -defined('WPINC') || die; |
|
3 | +defined( 'WPINC' ) || die; |
|
4 | 4 | |
5 | 5 | /* |
6 | 6 | * @param \GeminiLabs\SiteReviews\Modules\Html\Builder $instance |
7 | 7 | * @return void |
8 | 8 | * @see https://www.elegantthemes.com/gallery/divi/ |
9 | 9 | */ |
10 | -add_action('site-reviews/customize/divi', function ($instance) { |
|
11 | - if ('label' != $instance->tag || 'checkbox' != $instance->args['type']) { |
|
10 | +add_action( 'site-reviews/customize/divi', function( $instance ) { |
|
11 | + if( 'label' != $instance->tag || 'checkbox' != $instance->args['type'] ) { |
|
12 | 12 | return; |
13 | 13 | } |
14 | 14 | $instance->args['text'] = '<i></i>'.$instance->args['text']; |
@@ -21,25 +21,25 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | * @see https://wordpress.org/plugins/wp-super-cache/ |
23 | 23 | */ |
24 | -add_action('site-reviews/review/created', function ($review, $request) { |
|
25 | - if (!function_exists('wp_cache_post_change')) { |
|
24 | +add_action( 'site-reviews/review/created', function( $review, $request ) { |
|
25 | + if( !function_exists( 'wp_cache_post_change' ) ) { |
|
26 | 26 | return; |
27 | 27 | } |
28 | - wp_cache_post_change($request->post_id); |
|
29 | - if (empty($review->assigned_to) || $review->assigned_to == $request->post_id) { |
|
28 | + wp_cache_post_change( $request->post_id ); |
|
29 | + if( empty($review->assigned_to) || $review->assigned_to == $request->post_id ) { |
|
30 | 30 | return; |
31 | 31 | } |
32 | - wp_cache_post_change($review->assigned_to); |
|
33 | -}, 10, 2); |
|
32 | + wp_cache_post_change( $review->assigned_to ); |
|
33 | +}, 10, 2 ); |
|
34 | 34 | |
35 | 35 | /* |
36 | 36 | * @param array $scriptHandles |
37 | 37 | * @return array |
38 | 38 | * @see https://wordpress.org/plugins/speed-booster-pack/ |
39 | 39 | */ |
40 | -add_filter('sbp_exclude_defer_scripts', function ($scriptHandles) { |
|
40 | +add_filter( 'sbp_exclude_defer_scripts', function( $scriptHandles ) { |
|
41 | 41 | $scriptHandles[] = 'site-reviews/google-recaptcha'; |
42 | - return array_keys(array_flip($scriptHandles)); |
|
42 | + return array_keys( array_flip( $scriptHandles ) ); |
|
43 | 43 | }); |
44 | 44 | |
45 | 45 | /* |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * @return array |
49 | 49 | * @see https://searchandfilter.com/ |
50 | 50 | */ |
51 | -add_filter('sf_edit_query_args', function ($query) { |
|
52 | - if (!empty($query['meta_key']) && '_glsr_ranking' == $query['meta_key']) { |
|
51 | +add_filter( 'sf_edit_query_args', function( $query ) { |
|
52 | + if( !empty($query['meta_key']) && '_glsr_ranking' == $query['meta_key'] ) { |
|
53 | 53 | unset($query['meta_key']); |
54 | 54 | $query['meta_query'] = [ |
55 | 55 | 'relation' => 'OR', |
@@ -58,4 +58,4 @@ discard block |
||
58 | 58 | ]; |
59 | 59 | } |
60 | 60 | return $query; |
61 | -}, 20); |
|
61 | +}, 20 ); |
@@ -100,7 +100,8 @@ |
||
100 | 100 | if (1 == count($vars)) { |
101 | 101 | $value = htmlspecialchars(print_r($vars[0], true), ENT_QUOTES, 'UTF-8'); |
102 | 102 | printf('<div class="glsr-debug"><pre>%s</pre></div>', $value); |
103 | - } else { |
|
103 | + } |
|
104 | + else { |
|
104 | 105 | echo '<div class="glsr-debug-group">'; |
105 | 106 | foreach ($vars as $var) { |
106 | 107 | glsr_debug($var); |
@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | * @return mixed |
10 | 10 | */ |
11 | 11 | add_filter('plugins_loaded', function () { |
12 | - $hooks = array( |
|
13 | - 'glsr_calculate_ratings' => 1, |
|
14 | - 'glsr_create_review' => 2, |
|
15 | - 'glsr_debug' => 10, |
|
16 | - 'glsr_get' => 4, |
|
17 | - 'glsr_get_option' => 4, |
|
18 | - 'glsr_get_options' => 1, |
|
19 | - 'glsr_get_review' => 2, |
|
20 | - 'glsr_get_reviews' => 2, |
|
21 | - 'glsr_log' => 3, |
|
22 | - 'glsr_star_rating' => 2, |
|
23 | - ); |
|
24 | - foreach ($hooks as $function => $acceptedArgs) { |
|
25 | - add_filter($function, function () use ($function) { |
|
26 | - $args = func_get_args(); |
|
27 | - array_shift($args); // remove the fallback value |
|
28 | - return call_user_func_array($function, $args); |
|
29 | - }, 10, $acceptedArgs); |
|
30 | - } |
|
12 | + $hooks = array( |
|
13 | + 'glsr_calculate_ratings' => 1, |
|
14 | + 'glsr_create_review' => 2, |
|
15 | + 'glsr_debug' => 10, |
|
16 | + 'glsr_get' => 4, |
|
17 | + 'glsr_get_option' => 4, |
|
18 | + 'glsr_get_options' => 1, |
|
19 | + 'glsr_get_review' => 2, |
|
20 | + 'glsr_get_reviews' => 2, |
|
21 | + 'glsr_log' => 3, |
|
22 | + 'glsr_star_rating' => 2, |
|
23 | + ); |
|
24 | + foreach ($hooks as $function => $acceptedArgs) { |
|
25 | + add_filter($function, function () use ($function) { |
|
26 | + $args = func_get_args(); |
|
27 | + array_shift($args); // remove the fallback value |
|
28 | + return call_user_func_array($function, $args); |
|
29 | + }, 10, $acceptedArgs); |
|
30 | + } |
|
31 | 31 | }); |
32 | 32 | |
33 | 33 | /** |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function glsr($alias = null) |
37 | 37 | { |
38 | - $app = \GeminiLabs\SiteReviews\Application::load(); |
|
39 | - return !empty($alias) |
|
40 | - ? $app->make($alias) |
|
41 | - : $app; |
|
38 | + $app = \GeminiLabs\SiteReviews\Application::load(); |
|
39 | + return !empty($alias) |
|
40 | + ? $app->make($alias) |
|
41 | + : $app; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | */ |
49 | 49 | function glsr_array_column(array $array, $column) |
50 | 50 | { |
51 | - $result = array(); |
|
52 | - foreach ($array as $subarray) { |
|
53 | - $subarray = (array) $subarray; |
|
54 | - if (!isset($subarray[$column])) { |
|
55 | - continue; |
|
56 | - } |
|
57 | - $result[] = $subarray[$column]; |
|
58 | - } |
|
59 | - return $result; |
|
51 | + $result = array(); |
|
52 | + foreach ($array as $subarray) { |
|
53 | + $subarray = (array) $subarray; |
|
54 | + if (!isset($subarray[$column])) { |
|
55 | + continue; |
|
56 | + } |
|
57 | + $result[] = $subarray[$column]; |
|
58 | + } |
|
59 | + return $result; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | */ |
65 | 65 | function glsr_calculate_ratings() |
66 | 66 | { |
67 | - glsr('Controllers\AdminController')->routerCountReviews(false); |
|
68 | - glsr_log()->notice(__('Recalculated rating counts.', 'site-reviews')); |
|
67 | + glsr('Controllers\AdminController')->routerCountReviews(false); |
|
68 | + glsr_log()->notice(__('Recalculated rating counts.', 'site-reviews')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | */ |
74 | 74 | function glsr_create_review($reviewValues = array()) |
75 | 75 | { |
76 | - $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( |
|
77 | - \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($reviewValues) |
|
78 | - ); |
|
79 | - return glsr('Database\ReviewManager')->create($review); |
|
76 | + $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( |
|
77 | + \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($reviewValues) |
|
78 | + ); |
|
79 | + return glsr('Database\ReviewManager')->create($review); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function glsr_current_screen() |
86 | 86 | { |
87 | - if (function_exists('get_current_screen')) { |
|
88 | - $screen = get_current_screen(); |
|
89 | - } |
|
90 | - return empty($screen) |
|
91 | - ? (object) array_fill_keys(['base', 'id', 'post_type'], null) |
|
92 | - : $screen; |
|
87 | + if (function_exists('get_current_screen')) { |
|
88 | + $screen = get_current_screen(); |
|
89 | + } |
|
90 | + return empty($screen) |
|
91 | + ? (object) array_fill_keys(['base', 'id', 'post_type'], null) |
|
92 | + : $screen; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | */ |
99 | 99 | function glsr_debug(...$vars) |
100 | 100 | { |
101 | - if (1 == count($vars)) { |
|
102 | - $value = htmlspecialchars(print_r($vars[0], true), ENT_QUOTES, 'UTF-8'); |
|
103 | - printf('<div class="glsr-debug"><pre>%s</pre></div>', $value); |
|
104 | - } else { |
|
105 | - echo '<div class="glsr-debug-group">'; |
|
106 | - foreach ($vars as $var) { |
|
107 | - glsr_debug($var); |
|
108 | - } |
|
109 | - echo '</div>'; |
|
110 | - } |
|
101 | + if (1 == count($vars)) { |
|
102 | + $value = htmlspecialchars(print_r($vars[0], true), ENT_QUOTES, 'UTF-8'); |
|
103 | + printf('<div class="glsr-debug"><pre>%s</pre></div>', $value); |
|
104 | + } else { |
|
105 | + echo '<div class="glsr-debug-group">'; |
|
106 | + foreach ($vars as $var) { |
|
107 | + glsr_debug($var); |
|
108 | + } |
|
109 | + echo '</div>'; |
|
110 | + } |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | function glsr_get($array, $path = '', $fallback = '') |
120 | 120 | { |
121 | - return \GeminiLabs\SiteReviews\Helpers\Arr::get($array, $path, $fallback); |
|
121 | + return \GeminiLabs\SiteReviews\Helpers\Arr::get($array, $path, $fallback); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | */ |
130 | 130 | function glsr_get_option($path = '', $fallback = '', $cast = '') |
131 | 131 | { |
132 | - return is_string($path) |
|
133 | - ? glsr('Database\OptionManager')->get(\GeminiLabs\SiteReviews\Helpers\Str::prefix('settings.', $path), $fallback, $cast) |
|
134 | - : $fallback; |
|
132 | + return is_string($path) |
|
133 | + ? glsr('Database\OptionManager')->get(\GeminiLabs\SiteReviews\Helpers\Str::prefix('settings.', $path), $fallback, $cast) |
|
134 | + : $fallback; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | function glsr_get_options() |
141 | 141 | { |
142 | - return glsr('Database\OptionManager')->get('settings'); |
|
142 | + return glsr('Database\OptionManager')->get('settings'); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | */ |
149 | 149 | function glsr_get_review($post) |
150 | 150 | { |
151 | - if (is_numeric($post)) { |
|
152 | - $post = get_post($post); |
|
153 | - } |
|
154 | - if (!($post instanceof WP_Post)) { |
|
155 | - $post = new WP_Post((object) []); |
|
156 | - } |
|
157 | - return glsr('Database\ReviewManager')->single($post); |
|
151 | + if (is_numeric($post)) { |
|
152 | + $post = get_post($post); |
|
153 | + } |
|
154 | + if (!($post instanceof WP_Post)) { |
|
155 | + $post = new WP_Post((object) []); |
|
156 | + } |
|
157 | + return glsr('Database\ReviewManager')->single($post); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | function glsr_get_reviews($args = array()) |
164 | 164 | { |
165 | - return glsr('Database\ReviewManager')->get(\GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($args)); |
|
165 | + return glsr('Database\ReviewManager')->get(\GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($args)); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | */ |
171 | 171 | function glsr_log() |
172 | 172 | { |
173 | - $args = func_get_args(); |
|
174 | - $console = glsr('Modules\Console'); |
|
175 | - if ($value = \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '0')) { |
|
176 | - return $console->debug($value, \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '1', [])); |
|
177 | - } |
|
178 | - return $console; |
|
173 | + $args = func_get_args(); |
|
174 | + $console = glsr('Modules\Console'); |
|
175 | + if ($value = \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '0')) { |
|
176 | + return $console->debug($value, \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '1', [])); |
|
177 | + } |
|
178 | + return $console; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -183,5 +183,5 @@ discard block |
||
183 | 183 | */ |
184 | 184 | function glsr_star_rating($rating) |
185 | 185 | { |
186 | - return glsr('Modules\Html\Partial')->build('star-rating', ['rating' => $rating]); |
|
186 | + return glsr('Modules\Html\Partial')->build('star-rating', ['rating' => $rating]); |
|
187 | 187 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -defined('WPINC') || die; |
|
3 | +defined( 'WPINC' ) || die; |
|
4 | 4 | |
5 | 5 | /* |
6 | 6 | * Alternate method of using the functions without having to use `function_exists()` |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @param mixed ... |
9 | 9 | * @return mixed |
10 | 10 | */ |
11 | -add_filter('plugins_loaded', function () { |
|
11 | +add_filter( 'plugins_loaded', function() { |
|
12 | 12 | $hooks = array( |
13 | 13 | 'glsr_calculate_ratings' => 1, |
14 | 14 | 'glsr_create_review' => 2, |
@@ -21,23 +21,23 @@ discard block |
||
21 | 21 | 'glsr_log' => 3, |
22 | 22 | 'glsr_star_rating' => 2, |
23 | 23 | ); |
24 | - foreach ($hooks as $function => $acceptedArgs) { |
|
25 | - add_filter($function, function () use ($function) { |
|
24 | + foreach( $hooks as $function => $acceptedArgs ) { |
|
25 | + add_filter( $function, function() use ($function) { |
|
26 | 26 | $args = func_get_args(); |
27 | - array_shift($args); // remove the fallback value |
|
28 | - return call_user_func_array($function, $args); |
|
29 | - }, 10, $acceptedArgs); |
|
27 | + array_shift( $args ); // remove the fallback value |
|
28 | + return call_user_func_array( $function, $args ); |
|
29 | + }, 10, $acceptedArgs ); |
|
30 | 30 | } |
31 | 31 | }); |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @return mixed |
35 | 35 | */ |
36 | -function glsr($alias = null) |
|
36 | +function glsr( $alias = null ) |
|
37 | 37 | { |
38 | 38 | $app = \GeminiLabs\SiteReviews\Application::load(); |
39 | 39 | return !empty($alias) |
40 | - ? $app->make($alias) |
|
40 | + ? $app->make( $alias ) |
|
41 | 41 | : $app; |
42 | 42 | } |
43 | 43 | |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @param $column string |
47 | 47 | * @return array |
48 | 48 | */ |
49 | -function glsr_array_column(array $array, $column) |
|
49 | +function glsr_array_column( array $array, $column ) |
|
50 | 50 | { |
51 | 51 | $result = array(); |
52 | - foreach ($array as $subarray) { |
|
53 | - $subarray = (array) $subarray; |
|
54 | - if (!isset($subarray[$column])) { |
|
52 | + foreach( $array as $subarray ) { |
|
53 | + $subarray = (array)$subarray; |
|
54 | + if( !isset($subarray[$column]) ) { |
|
55 | 55 | continue; |
56 | 56 | } |
57 | 57 | $result[] = $subarray[$column]; |
@@ -64,19 +64,19 @@ discard block |
||
64 | 64 | */ |
65 | 65 | function glsr_calculate_ratings() |
66 | 66 | { |
67 | - glsr('Controllers\AdminController')->routerCountReviews(false); |
|
68 | - glsr_log()->notice(__('Recalculated rating counts.', 'site-reviews')); |
|
67 | + glsr( 'Controllers\AdminController' )->routerCountReviews( false ); |
|
68 | + glsr_log()->notice( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @return \GeminiLabs\SiteReviews\Review|false |
73 | 73 | */ |
74 | -function glsr_create_review($reviewValues = array()) |
|
74 | +function glsr_create_review( $reviewValues = array() ) |
|
75 | 75 | { |
76 | 76 | $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( |
77 | - \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($reviewValues) |
|
77 | + \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray( $reviewValues ) |
|
78 | 78 | ); |
79 | - return glsr('Database\ReviewManager')->create($review); |
|
79 | + return glsr( 'Database\ReviewManager' )->create( $review ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function glsr_current_screen() |
86 | 86 | { |
87 | - if (function_exists('get_current_screen')) { |
|
87 | + if( function_exists( 'get_current_screen' ) ) { |
|
88 | 88 | $screen = get_current_screen(); |
89 | 89 | } |
90 | 90 | return empty($screen) |
91 | - ? (object) array_fill_keys(['base', 'id', 'post_type'], null) |
|
91 | + ? (object)array_fill_keys( ['base', 'id', 'post_type'], null ) |
|
92 | 92 | : $screen; |
93 | 93 | } |
94 | 94 | |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | * @param mixed ...$vars |
97 | 97 | * @return void |
98 | 98 | */ |
99 | -function glsr_debug(...$vars) |
|
99 | +function glsr_debug( ...$vars ) |
|
100 | 100 | { |
101 | - if (1 == count($vars)) { |
|
102 | - $value = htmlspecialchars(print_r($vars[0], true), ENT_QUOTES, 'UTF-8'); |
|
103 | - printf('<div class="glsr-debug"><pre>%s</pre></div>', $value); |
|
101 | + if( 1 == count( $vars ) ) { |
|
102 | + $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
|
103 | + printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
|
104 | 104 | } else { |
105 | 105 | echo '<div class="glsr-debug-group">'; |
106 | - foreach ($vars as $var) { |
|
107 | - glsr_debug($var); |
|
106 | + foreach( $vars as $var ) { |
|
107 | + glsr_debug( $var ); |
|
108 | 108 | } |
109 | 109 | echo '</div>'; |
110 | 110 | } |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * @param mixed $fallback |
117 | 117 | * @return mixed |
118 | 118 | */ |
119 | -function glsr_get($array, $path = '', $fallback = '') |
|
119 | +function glsr_get( $array, $path = '', $fallback = '' ) |
|
120 | 120 | { |
121 | - return \GeminiLabs\SiteReviews\Helpers\Arr::get($array, $path, $fallback); |
|
121 | + return \GeminiLabs\SiteReviews\Helpers\Arr::get( $array, $path, $fallback ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | * @param string $cast |
128 | 128 | * @return string|array |
129 | 129 | */ |
130 | -function glsr_get_option($path = '', $fallback = '', $cast = '') |
|
130 | +function glsr_get_option( $path = '', $fallback = '', $cast = '' ) |
|
131 | 131 | { |
132 | - return is_string($path) |
|
133 | - ? glsr('Database\OptionManager')->get(\GeminiLabs\SiteReviews\Helpers\Str::prefix('settings.', $path), $fallback, $cast) |
|
132 | + return is_string( $path ) |
|
133 | + ? glsr( 'Database\OptionManager' )->get( \GeminiLabs\SiteReviews\Helpers\Str::prefix( 'settings.', $path ), $fallback, $cast ) |
|
134 | 134 | : $fallback; |
135 | 135 | } |
136 | 136 | |
@@ -139,30 +139,30 @@ discard block |
||
139 | 139 | */ |
140 | 140 | function glsr_get_options() |
141 | 141 | { |
142 | - return glsr('Database\OptionManager')->get('settings'); |
|
142 | + return glsr( 'Database\OptionManager' )->get( 'settings' ); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * @param \WP_Post|int $post |
147 | 147 | * @return \GeminiLabs\SiteReviews\Review |
148 | 148 | */ |
149 | -function glsr_get_review($post) |
|
149 | +function glsr_get_review( $post ) |
|
150 | 150 | { |
151 | - if (is_numeric($post)) { |
|
152 | - $post = get_post($post); |
|
151 | + if( is_numeric( $post ) ) { |
|
152 | + $post = get_post( $post ); |
|
153 | 153 | } |
154 | - if (!($post instanceof WP_Post)) { |
|
155 | - $post = new WP_Post((object) []); |
|
154 | + if( !($post instanceof WP_Post) ) { |
|
155 | + $post = new WP_Post( (object)[] ); |
|
156 | 156 | } |
157 | - return glsr('Database\ReviewManager')->single($post); |
|
157 | + return glsr( 'Database\ReviewManager' )->single( $post ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
161 | 161 | * @return array |
162 | 162 | */ |
163 | -function glsr_get_reviews($args = array()) |
|
163 | +function glsr_get_reviews( $args = array() ) |
|
164 | 164 | { |
165 | - return glsr('Database\ReviewManager')->get(\GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($args)); |
|
165 | + return glsr( 'Database\ReviewManager' )->get( \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray( $args ) ); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | function glsr_log() |
172 | 172 | { |
173 | 173 | $args = func_get_args(); |
174 | - $console = glsr('Modules\Console'); |
|
175 | - if ($value = \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '0')) { |
|
176 | - return $console->debug($value, \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '1', [])); |
|
174 | + $console = glsr( 'Modules\Console' ); |
|
175 | + if( $value = \GeminiLabs\SiteReviews\Helpers\Arr::get( $args, '0' ) ) { |
|
176 | + return $console->debug( $value, \GeminiLabs\SiteReviews\Helpers\Arr::get( $args, '1', [] ) ); |
|
177 | 177 | } |
178 | 178 | return $console; |
179 | 179 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | /** |
182 | 182 | * @return string |
183 | 183 | */ |
184 | -function glsr_star_rating($rating) |
|
184 | +function glsr_star_rating( $rating ) |
|
185 | 185 | { |
186 | - return glsr('Modules\Html\Partial')->build('star-rating', ['rating' => $rating]); |
|
186 | + return glsr( 'Modules\Html\Partial' )->build( 'star-rating', ['rating' => $rating] ); |
|
187 | 187 | } |