@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !class_exists('Puc_v4p4_Factory', false) ): |
|
2 | +if (!class_exists('Puc_v4p4_Factory', false)): |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * A factory that builds update checker instances. |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | |
41 | 41 | //Plugin or theme? |
42 | 42 | $themeDirectory = self::getThemeDirectoryName($fullPath); |
43 | - if ( self::isPluginFile($fullPath) ) { |
|
43 | + if (self::isPluginFile($fullPath)) { |
|
44 | 44 | $type = 'Plugin'; |
45 | 45 | $id = $fullPath; |
46 | - } else if ( $themeDirectory !== null ) { |
|
46 | + } else if ($themeDirectory !== null) { |
|
47 | 47 | $type = 'Theme'; |
48 | 48 | $id = $themeDirectory; |
49 | 49 | } else { |
50 | 50 | throw new RuntimeException(sprintf( |
51 | - 'The update checker cannot determine if "%s" is a plugin or a theme. ' . |
|
51 | + 'The update checker cannot determine if "%s" is a plugin or a theme. '. |
|
52 | 52 | 'This is a bug. Please contact the PUC developer.', |
53 | 53 | htmlentities($fullPath) |
54 | 54 | )); |
@@ -58,36 +58,36 @@ discard block |
||
58 | 58 | $service = self::getVcsService($metadataUrl); |
59 | 59 | |
60 | 60 | $apiClass = null; |
61 | - if ( empty($service) ) { |
|
61 | + if (empty($service)) { |
|
62 | 62 | //The default is to get update information from a remote JSON file. |
63 | - $checkerClass = $type . '_UpdateChecker'; |
|
63 | + $checkerClass = $type.'_UpdateChecker'; |
|
64 | 64 | } else { |
65 | 65 | //You can also use a VCS repository like GitHub. |
66 | - $checkerClass = 'Vcs_' . $type . 'UpdateChecker'; |
|
67 | - $apiClass = $service . 'Api'; |
|
66 | + $checkerClass = 'Vcs_'.$type.'UpdateChecker'; |
|
67 | + $apiClass = $service.'Api'; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $checkerClass = self::getCompatibleClassVersion($checkerClass); |
71 | - if ( $checkerClass === null ) { |
|
71 | + if ($checkerClass === null) { |
|
72 | 72 | trigger_error( |
73 | 73 | sprintf( |
74 | 74 | 'PUC %s does not support updates for %ss %s', |
75 | 75 | htmlentities(self::$latestCompatibleVersion), |
76 | 76 | strtolower($type), |
77 | - $service ? ('hosted on ' . htmlentities($service)) : 'using JSON metadata' |
|
77 | + $service ? ('hosted on '.htmlentities($service)) : 'using JSON metadata' |
|
78 | 78 | ), |
79 | 79 | E_USER_ERROR |
80 | 80 | ); |
81 | 81 | return null; |
82 | 82 | } |
83 | 83 | |
84 | - if ( !isset($apiClass) ) { |
|
84 | + if (!isset($apiClass)) { |
|
85 | 85 | //Plain old update checker. |
86 | 86 | return new $checkerClass($metadataUrl, $id, $slug, $checkPeriod, $optionName, $muPluginFile); |
87 | 87 | } else { |
88 | 88 | //VCS checker + an API client. |
89 | 89 | $apiClass = self::getCompatibleClassVersion($apiClass); |
90 | - if ( $apiClass === null ) { |
|
90 | + if ($apiClass === null) { |
|
91 | 91 | trigger_error(sprintf( |
92 | 92 | 'PUC %s does not support %s', |
93 | 93 | htmlentities(self::$latestCompatibleVersion), |
@@ -117,12 +117,12 @@ discard block |
||
117 | 117 | * @return string Normalized path. |
118 | 118 | */ |
119 | 119 | public static function normalizePath($path) { |
120 | - if ( function_exists('wp_normalize_path') ) { |
|
120 | + if (function_exists('wp_normalize_path')) { |
|
121 | 121 | return wp_normalize_path($path); |
122 | 122 | } |
123 | 123 | $path = str_replace('\\', '/', $path); |
124 | 124 | $path = preg_replace('|(?<=.)/+|', '/', $path); |
125 | - if ( substr($path, 1, 1) === ':' ) { |
|
125 | + if (substr($path, 1, 1) === ':') { |
|
126 | 126 | $path = ucfirst($path); |
127 | 127 | } |
128 | 128 | return $path; |
@@ -138,18 +138,18 @@ discard block |
||
138 | 138 | //Is the file inside the "plugins" or "mu-plugins" directory? |
139 | 139 | $pluginDir = self::normalizePath(WP_PLUGIN_DIR); |
140 | 140 | $muPluginDir = self::normalizePath(WPMU_PLUGIN_DIR); |
141 | - if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) { |
|
141 | + if ((strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0)) { |
|
142 | 142 | return true; |
143 | 143 | } |
144 | 144 | |
145 | 145 | //Is it a file at all? Caution: is_file() can fail if the parent dir. doesn't have the +x permission set. |
146 | - if ( !is_file($absolutePath) ) { |
|
146 | + if (!is_file($absolutePath)) { |
|
147 | 147 | return false; |
148 | 148 | } |
149 | 149 | |
150 | 150 | //Does it have a valid plugin header? |
151 | 151 | //This is a last-ditch check for plugins symlinked from outside the WP root. |
152 | - if ( function_exists('get_file_data') ) { |
|
152 | + if (function_exists('get_file_data')) { |
|
153 | 153 | $headers = get_file_data($absolutePath, array('Name' => 'Plugin Name'), 'plugin'); |
154 | 154 | return !empty($headers['Name']); |
155 | 155 | } |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | * @return string|null Directory name, or NULL if the path doesn't point to a theme. |
169 | 169 | */ |
170 | 170 | protected static function getThemeDirectoryName($absolutePath) { |
171 | - if ( is_file($absolutePath) ) { |
|
171 | + if (is_file($absolutePath)) { |
|
172 | 172 | $absolutePath = dirname($absolutePath); |
173 | 173 | } |
174 | 174 | |
175 | - if ( file_exists($absolutePath . '/style.css') ) { |
|
175 | + if (file_exists($absolutePath.'/style.css')) { |
|
176 | 176 | return basename($absolutePath); |
177 | 177 | } |
178 | 178 | return null; |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | $path = @parse_url($metadataUrl, PHP_URL_PATH); |
193 | 193 | //Check if the path looks like "/user-name/repository". |
194 | 194 | $usernameRepoRegex = '@^/?([^/]+?)/([^/#?&]+?)/?$@'; |
195 | - if ( preg_match($usernameRepoRegex, $path) ) { |
|
195 | + if (preg_match($usernameRepoRegex, $path)) { |
|
196 | 196 | $knownServices = array( |
197 | 197 | 'github.com' => 'GitHub', |
198 | 198 | 'bitbucket.org' => 'BitBucket', |
199 | 199 | 'gitlab.com' => 'GitLab', |
200 | 200 | ); |
201 | - if ( isset($knownServices[$host]) ) { |
|
201 | + if (isset($knownServices[$host])) { |
|
202 | 202 | $service = $knownServices[$host]; |
203 | 203 | } |
204 | 204 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @return string|null Full class name. |
215 | 215 | */ |
216 | 216 | protected static function getCompatibleClassVersion($class) { |
217 | - if ( isset(self::$classVersions[$class][self::$latestCompatibleVersion]) ) { |
|
217 | + if (isset(self::$classVersions[$class][self::$latestCompatibleVersion])) { |
|
218 | 218 | return self::$classVersions[$class][self::$latestCompatibleVersion]; |
219 | 219 | } |
220 | 220 | return null; |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | * @return null|string |
228 | 228 | */ |
229 | 229 | public static function getLatestClassVersion($class) { |
230 | - if ( !self::$sorted ) { |
|
230 | + if (!self::$sorted) { |
|
231 | 231 | self::sortVersions(); |
232 | 232 | } |
233 | 233 | |
234 | - if ( isset(self::$classVersions[$class]) ) { |
|
234 | + if (isset(self::$classVersions[$class])) { |
|
235 | 235 | return reset(self::$classVersions[$class]); |
236 | 236 | } else { |
237 | 237 | return null; |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * Sort available class versions in descending order (i.e. newest first). |
243 | 243 | */ |
244 | 244 | protected static function sortVersions() { |
245 | - foreach ( self::$classVersions as $class => $versions ) { |
|
245 | + foreach (self::$classVersions as $class => $versions) { |
|
246 | 246 | uksort($versions, array(__CLASS__, 'compareVersions')); |
247 | 247 | self::$classVersions[$class] = $versions; |
248 | 248 | } |
@@ -263,14 +263,14 @@ discard block |
||
263 | 263 | * @param string $version Version number, e.g. '1.2'. |
264 | 264 | */ |
265 | 265 | public static function addVersion($generalClass, $versionedClass, $version) { |
266 | - if ( empty(self::$myMajorVersion) ) { |
|
266 | + if (empty(self::$myMajorVersion)) { |
|
267 | 267 | $nameParts = explode('_', __CLASS__, 3); |
268 | 268 | self::$myMajorVersion = substr(ltrim($nameParts[1], 'v'), 0, 1); |
269 | 269 | } |
270 | 270 | |
271 | 271 | //Store the greatest version number that matches our major version. |
272 | 272 | $components = explode('.', $version); |
273 | - if ( $components[0] === self::$myMajorVersion ) { |
|
273 | + if ($components[0] === self::$myMajorVersion) { |
|
274 | 274 | |
275 | 275 | if ( |
276 | 276 | empty(self::$latestCompatibleVersion) |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | } |
283 | 283 | |
284 | - if ( !isset(self::$classVersions[$generalClass]) ) { |
|
284 | + if (!isset(self::$classVersions[$generalClass])) { |
|
285 | 285 | self::$classVersions[$generalClass] = array(); |
286 | 286 | } |
287 | 287 | self::$classVersions[$generalClass][$version] = $versionedClass; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( !class_exists('Puc_v4p4_Autoloader', false) ): |
|
3 | +if (!class_exists('Puc_v4p4_Autoloader', false)): |
|
4 | 4 | |
5 | 5 | class Puc_v4p4_Autoloader { |
6 | 6 | private $prefix = ''; |
@@ -10,16 +10,16 @@ discard block |
||
10 | 10 | private $staticMap; |
11 | 11 | |
12 | 12 | public function __construct() { |
13 | - $this->rootDir = dirname(__FILE__) . '/'; |
|
13 | + $this->rootDir = dirname(__FILE__).'/'; |
|
14 | 14 | $nameParts = explode('_', __CLASS__, 3); |
15 | - $this->prefix = $nameParts[0] . '_' . $nameParts[1] . '_'; |
|
15 | + $this->prefix = $nameParts[0].'_'.$nameParts[1].'_'; |
|
16 | 16 | |
17 | - $this->libraryDir = realpath($this->rootDir . '../..') . '/'; |
|
17 | + $this->libraryDir = realpath($this->rootDir.'../..').'/'; |
|
18 | 18 | $this->staticMap = array( |
19 | 19 | 'PucReadmeParser' => 'vendor/readme-parser.php', |
20 | 20 | 'Parsedown' => 'vendor/ParsedownLegacy.php', |
21 | 21 | ); |
22 | - if ( version_compare(PHP_VERSION, '5.3.0', '>=') ) { |
|
22 | + if (version_compare(PHP_VERSION, '5.3.0', '>=')) { |
|
23 | 23 | $this->staticMap['Parsedown'] = 'vendor/Parsedown.php'; |
24 | 24 | } |
25 | 25 | |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | } |
28 | 28 | |
29 | 29 | public function autoload($className) { |
30 | - if ( isset($this->staticMap[$className]) && file_exists($this->libraryDir . $this->staticMap[$className]) ) { |
|
30 | + if (isset($this->staticMap[$className]) && file_exists($this->libraryDir.$this->staticMap[$className])) { |
|
31 | 31 | /** @noinspection PhpIncludeInspection */ |
32 | - include ($this->libraryDir . $this->staticMap[$className]); |
|
32 | + include ($this->libraryDir.$this->staticMap[$className]); |
|
33 | 33 | return; |
34 | 34 | } |
35 | 35 | |
36 | 36 | if (strpos($className, $this->prefix) === 0) { |
37 | 37 | $path = substr($className, strlen($this->prefix)); |
38 | 38 | $path = str_replace('_', '/', $path); |
39 | - $path = $this->rootDir . $path . '.php'; |
|
39 | + $path = $this->rootDir.$path.'.php'; |
|
40 | 40 | |
41 | 41 | if (file_exists($path)) { |
42 | 42 | /** @noinspection PhpIncludeInspection */ |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !class_exists('Puc_v4p4_DebugBar_Extension', false) ): |
|
2 | +if (!class_exists('Puc_v4p4_DebugBar_Extension', false)): |
|
3 | 3 | |
4 | 4 | class Puc_v4p4_DebugBar_Extension { |
5 | 5 | const RESPONSE_BODY_LENGTH_LIMIT = 4000; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | public function __construct($updateChecker, $panelClass = null) { |
12 | 12 | $this->updateChecker = $updateChecker; |
13 | - if ( isset($panelClass) ) { |
|
13 | + if (isset($panelClass)) { |
|
14 | 14 | $this->panelClass = $panelClass; |
15 | 15 | } |
16 | 16 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @return array |
28 | 28 | */ |
29 | 29 | public function addDebugBarPanel($panels) { |
30 | - if ( $this->updateChecker->userCanInstallUpdates() ) { |
|
30 | + if ($this->updateChecker->userCanInstallUpdates()) { |
|
31 | 31 | $panels[] = new $this->panelClass($this->updateChecker); |
32 | 32 | } |
33 | 33 | return $panels; |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * the update checking process works as expected. |
58 | 58 | */ |
59 | 59 | public function ajaxCheckNow() { |
60 | - if ( $_POST['uid'] !== $this->updateChecker->getUniqueName('uid') ) { |
|
60 | + if ($_POST['uid'] !== $this->updateChecker->getUniqueName('uid')) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | 63 | $this->preAjaxRequest(); |
64 | 64 | $update = $this->updateChecker->checkForUpdates(); |
65 | - if ( $update !== null ) { |
|
65 | + if ($update !== null) { |
|
66 | 66 | echo "An update is available:"; |
67 | 67 | echo '<pre>', htmlentities(print_r($update, true)), '</pre>'; |
68 | 68 | } else { |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | $errors = $this->updateChecker->getLastRequestApiErrors(); |
73 | - if ( !empty($errors) ) { |
|
73 | + if (!empty($errors)) { |
|
74 | 74 | printf('<p>The update checker encountered %d API error%s.</p>', count($errors), (count($errors) > 1) ? 's' : ''); |
75 | 75 | |
76 | 76 | foreach (array_values($errors) as $num => $item) { |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | echo '<dl>'; |
82 | 82 | printf('<dt>Error code:</dt><dd><code>%s</code></dd>', esc_html($wpError->get_error_code())); |
83 | 83 | |
84 | - if ( isset($item['url']) ) { |
|
84 | + if (isset($item['url'])) { |
|
85 | 85 | printf('<dt>Requested URL:</dt><dd><code>%s</code></dd>', esc_html($item['url'])); |
86 | 86 | } |
87 | 87 | |
88 | - if ( isset($item['httpResponse']) ) { |
|
89 | - if ( is_wp_error($item['httpResponse']) ) { |
|
88 | + if (isset($item['httpResponse'])) { |
|
89 | + if (is_wp_error($item['httpResponse'])) { |
|
90 | 90 | $httpError = $item['httpResponse']; |
91 | 91 | /** @var WP_Error $httpError */ |
92 | 92 | printf( |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | |
112 | 112 | //Body. |
113 | 113 | $body = wp_remote_retrieve_body($item['httpResponse']); |
114 | - if ( $body === '' ) { |
|
114 | + if ($body === '') { |
|
115 | 115 | $body = '(Empty response.)'; |
116 | - } else if ( strlen($body) > self::RESPONSE_BODY_LENGTH_LIMIT ) { |
|
116 | + } else if (strlen($body) > self::RESPONSE_BODY_LENGTH_LIMIT) { |
|
117 | 117 | $length = strlen($body); |
118 | 118 | $body = substr($body, 0, self::RESPONSE_BODY_LENGTH_LIMIT) |
119 | 119 | . sprintf("\n(Long string truncated. Total length: %d bytes.)", $length); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * Check access permissions and enable error display (for debugging). |
134 | 134 | */ |
135 | 135 | protected function preAjaxRequest() { |
136 | - if ( !$this->updateChecker->userCanInstallUpdates() ) { |
|
136 | + if (!$this->updateChecker->userCanInstallUpdates()) { |
|
137 | 137 | die('Access denied'); |
138 | 138 | } |
139 | 139 | check_ajax_referer('puc-ajax'); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @return string |
148 | 148 | */ |
149 | 149 | private function getLibraryUrl($filePath) { |
150 | - $absolutePath = realpath(dirname(__FILE__) . '/../../../' . ltrim($filePath, '/')); |
|
150 | + $absolutePath = realpath(dirname(__FILE__).'/../../../'.ltrim($filePath, '/')); |
|
151 | 151 | |
152 | 152 | //Where is the library located inside the WordPress directory structure? |
153 | 153 | $absolutePath = Puc_v4p4_Factory::normalizePath($absolutePath); |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | $muPluginDir = Puc_v4p4_Factory::normalizePath(WPMU_PLUGIN_DIR); |
157 | 157 | $themeDir = Puc_v4p4_Factory::normalizePath(get_theme_root()); |
158 | 158 | |
159 | - if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) { |
|
159 | + if ((strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0)) { |
|
160 | 160 | //It's part of a plugin. |
161 | 161 | return plugins_url(basename($absolutePath), $absolutePath); |
162 | - } else if ( strpos($absolutePath, $themeDir) === 0 ) { |
|
162 | + } else if (strpos($absolutePath, $themeDir) === 0) { |
|
163 | 163 | //It's part of a theme. |
164 | 164 | $relativePath = substr($absolutePath, strlen($themeDir) + 1); |
165 | 165 | $template = substr($relativePath, 0, strpos($relativePath, '/')); |
166 | 166 | $baseUrl = get_theme_root_uri($template); |
167 | 167 | |
168 | - if ( !empty($baseUrl) && $relativePath ) { |
|
169 | - return $baseUrl . '/' . $relativePath; |
|
168 | + if (!empty($baseUrl) && $relativePath) { |
|
169 | + return $baseUrl.'/'.$relativePath; |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( !class_exists('Puc_v4p4_DebugBar_ThemePanel', false) ): |
|
3 | +if (!class_exists('Puc_v4p4_DebugBar_ThemePanel', false)): |
|
4 | 4 | |
5 | 5 | class Puc_v4p4_DebugBar_ThemePanel extends Puc_v4p4_DebugBar_Panel { |
6 | 6 | /** |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( !class_exists('Puc_v4p4_DebugBar_Panel', false) && class_exists('Debug_Bar_Panel', false) ): |
|
3 | +if (!class_exists('Puc_v4p4_DebugBar_Panel', false) && class_exists('Debug_Bar_Panel', false)): |
|
4 | 4 | |
5 | 5 | class Puc_v4p4_DebugBar_Panel extends Debug_Bar_Panel { |
6 | 6 | /** @var Puc_v4p4_UpdateChecker */ |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | $this->row('DB option', htmlentities($this->updateChecker->optionName)); |
43 | 43 | |
44 | 44 | $requestInfoButton = $this->getMetadataButton(); |
45 | - $this->row('Metadata URL', htmlentities($this->updateChecker->metadataUrl) . ' ' . $requestInfoButton . $this->responseBox); |
|
45 | + $this->row('Metadata URL', htmlentities($this->updateChecker->metadataUrl).' '.$requestInfoButton.$this->responseBox); |
|
46 | 46 | |
47 | 47 | $scheduler = $this->updateChecker->scheduler; |
48 | - if ( $scheduler->checkPeriod > 0 ) { |
|
49 | - $this->row('Automatic checks', 'Every ' . $scheduler->checkPeriod . ' hours'); |
|
48 | + if ($scheduler->checkPeriod > 0) { |
|
49 | + $this->row('Automatic checks', 'Every '.$scheduler->checkPeriod.' hours'); |
|
50 | 50 | } else { |
51 | 51 | $this->row('Automatic checks', 'Disabled'); |
52 | 52 | } |
53 | 53 | |
54 | - if ( isset($scheduler->throttleRedundantChecks) ) { |
|
55 | - if ( $scheduler->throttleRedundantChecks && ($scheduler->checkPeriod > 0) ) { |
|
54 | + if (isset($scheduler->throttleRedundantChecks)) { |
|
55 | + if ($scheduler->throttleRedundantChecks && ($scheduler->checkPeriod > 0)) { |
|
56 | 56 | $this->row( |
57 | 57 | 'Throttling', |
58 | 58 | sprintf( |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | echo '<table class="puc-debug-data">'; |
85 | 85 | $state = $this->updateChecker->getUpdateState(); |
86 | 86 | $checkNowButton = ''; |
87 | - if ( function_exists('get_submit_button') ) { |
|
87 | + if (function_exists('get_submit_button')) { |
|
88 | 88 | $checkNowButton = get_submit_button( |
89 | 89 | 'Check Now', |
90 | 90 | 'secondary', |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | ); |
95 | 95 | } |
96 | 96 | |
97 | - if ( $state->getLastCheck() > 0 ) { |
|
98 | - $this->row('Last check', $this->formatTimeWithDelta($state->getLastCheck()) . ' ' . $checkNowButton . $this->responseBox); |
|
97 | + if ($state->getLastCheck() > 0) { |
|
98 | + $this->row('Last check', $this->formatTimeWithDelta($state->getLastCheck()).' '.$checkNowButton.$this->responseBox); |
|
99 | 99 | } else { |
100 | 100 | $this->row('Last check', 'Never'); |
101 | 101 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $nextCheck = wp_next_scheduled($this->updateChecker->scheduler->getCronHookName()); |
104 | 104 | $this->row('Next automatic check', $this->formatTimeWithDelta($nextCheck)); |
105 | 105 | |
106 | - if ( $state->getCheckedVersion() !== '' ) { |
|
106 | + if ($state->getCheckedVersion() !== '') { |
|
107 | 107 | $this->row('Checked version', htmlentities($state->getCheckedVersion())); |
108 | 108 | $this->row('Cached update', $state->getUpdate()); |
109 | 109 | } |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | |
114 | 114 | private function displayCurrentUpdate() { |
115 | 115 | $update = $this->updateChecker->getUpdate(); |
116 | - if ( $update !== null ) { |
|
116 | + if ($update !== null) { |
|
117 | 117 | echo '<h3>An Update Is Available</h3>'; |
118 | 118 | echo '<table class="puc-debug-data">'; |
119 | 119 | $fields = $this->getUpdateFields(); |
120 | - foreach($fields as $field) { |
|
121 | - if ( property_exists($update, $field) ) { |
|
120 | + foreach ($fields as $field) { |
|
121 | + if (property_exists($update, $field)) { |
|
122 | 122 | $this->row(ucwords(str_replace('_', ' ', $field)), htmlentities($update->$field)); |
123 | 123 | } |
124 | 124 | } |
@@ -133,28 +133,28 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | private function formatTimeWithDelta($unixTime) { |
136 | - if ( empty($unixTime) ) { |
|
136 | + if (empty($unixTime)) { |
|
137 | 137 | return 'Never'; |
138 | 138 | } |
139 | 139 | |
140 | 140 | $delta = time() - $unixTime; |
141 | 141 | $result = human_time_diff(time(), $unixTime); |
142 | - if ( $delta < 0 ) { |
|
143 | - $result = 'after ' . $result; |
|
142 | + if ($delta < 0) { |
|
143 | + $result = 'after '.$result; |
|
144 | 144 | } else { |
145 | - $result = $result . ' ago'; |
|
145 | + $result = $result.' ago'; |
|
146 | 146 | } |
147 | - $result .= ' (' . $this->formatTimestamp($unixTime) . ')'; |
|
147 | + $result .= ' ('.$this->formatTimestamp($unixTime).')'; |
|
148 | 148 | return $result; |
149 | 149 | } |
150 | 150 | |
151 | 151 | private function formatTimestamp($unixTime) { |
152 | - return gmdate('Y-m-d H:i:s', $unixTime + (get_option('gmt_offset') * 3600)); |
|
152 | + return gmdate('Y-m-d H:i:s', $unixTime + (get_option('gmt_offset')*3600)); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | public function row($name, $value) { |
156 | - if ( is_object($value) || is_array($value) ) { |
|
157 | - $value = '<pre>' . htmlentities(print_r($value, true)) . '</pre>'; |
|
156 | + if (is_object($value) || is_array($value)) { |
|
157 | + $value = '<pre>'.htmlentities(print_r($value, true)).'</pre>'; |
|
158 | 158 | } else if ($value === null) { |
159 | 159 | $value = '<code>null</code>'; |
160 | 160 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !class_exists('Puc_v4p4_DebugBar_PluginExtension', false) ): |
|
2 | +if (!class_exists('Puc_v4p4_DebugBar_PluginExtension', false)): |
|
3 | 3 | |
4 | 4 | class Puc_v4p4_DebugBar_PluginExtension extends Puc_v4p4_DebugBar_Extension { |
5 | 5 | /** @var Puc_v4p4_Plugin_UpdateChecker */ |
@@ -15,12 +15,12 @@ discard block |
||
15 | 15 | * Request plugin info and output it. |
16 | 16 | */ |
17 | 17 | public function ajaxRequestInfo() { |
18 | - if ( $_POST['uid'] !== $this->updateChecker->getUniqueName('uid') ) { |
|
18 | + if ($_POST['uid'] !== $this->updateChecker->getUniqueName('uid')) { |
|
19 | 19 | return; |
20 | 20 | } |
21 | 21 | $this->preAjaxRequest(); |
22 | 22 | $info = $this->updateChecker->requestInfo(); |
23 | - if ( $info !== null ) { |
|
23 | + if ($info !== null) { |
|
24 | 24 | echo 'Successfully retrieved plugin info from the metadata URL:'; |
25 | 25 | echo '<pre>', htmlentities(print_r($info, true)), '</pre>'; |
26 | 26 | } else { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( !class_exists('Puc_v4p4_DebugBar_PluginPanel', false) ): |
|
3 | +if (!class_exists('Puc_v4p4_DebugBar_PluginPanel', false)): |
|
4 | 4 | |
5 | 5 | class Puc_v4p4_DebugBar_PluginPanel extends Puc_v4p4_DebugBar_Panel { |
6 | 6 | /** |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | protected function getMetadataButton() { |
17 | 17 | $requestInfoButton = ''; |
18 | - if ( function_exists('get_submit_button') ) { |
|
18 | + if (function_exists('get_submit_button')) { |
|
19 | 19 | $requestInfoButton = get_submit_button( |
20 | 20 | 'Request Info', |
21 | 21 | 'secondary', |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !class_exists('Puc_v4p4_Scheduler', false) ): |
|
2 | +if (!class_exists('Puc_v4p4_Scheduler', false)): |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * The scheduler decides when and how often to check for updates. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | //Set up the periodic update checks |
34 | 34 | $this->cronHook = $this->updateChecker->getUniqueName('cron_check_updates'); |
35 | - if ( $this->checkPeriod > 0 ){ |
|
35 | + if ($this->checkPeriod > 0) { |
|
36 | 36 | |
37 | 37 | //Trigger the check via Cron. |
38 | 38 | //Try to use one of the default schedules if possible as it's less likely to conflict |
@@ -42,29 +42,29 @@ discard block |
||
42 | 42 | 12 => 'twicedaily', |
43 | 43 | 24 => 'daily', |
44 | 44 | ); |
45 | - if ( array_key_exists($this->checkPeriod, $defaultSchedules) ) { |
|
45 | + if (array_key_exists($this->checkPeriod, $defaultSchedules)) { |
|
46 | 46 | $scheduleName = $defaultSchedules[$this->checkPeriod]; |
47 | 47 | } else { |
48 | 48 | //Use a custom cron schedule. |
49 | - $scheduleName = 'every' . $this->checkPeriod . 'hours'; |
|
49 | + $scheduleName = 'every'.$this->checkPeriod.'hours'; |
|
50 | 50 | add_filter('cron_schedules', array($this, '_addCustomSchedule')); |
51 | 51 | } |
52 | 52 | |
53 | - if ( !wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING') ) { |
|
53 | + if (!wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING')) { |
|
54 | 54 | wp_schedule_event(time(), $scheduleName, $this->cronHook); |
55 | 55 | } |
56 | 56 | add_action($this->cronHook, array($this, 'maybeCheckForUpdates')); |
57 | 57 | |
58 | 58 | //In case Cron is disabled or unreliable, we also manually trigger |
59 | 59 | //the periodic checks while the user is browsing the Dashboard. |
60 | - add_action( 'admin_init', array($this, 'maybeCheckForUpdates') ); |
|
60 | + add_action('admin_init', array($this, 'maybeCheckForUpdates')); |
|
61 | 61 | |
62 | 62 | //Like WordPress itself, we check more often on certain pages. |
63 | 63 | /** @see wp_update_plugins */ |
64 | 64 | add_action('load-update-core.php', array($this, 'maybeCheckForUpdates')); |
65 | 65 | //"load-update.php" and "load-plugins.php" or "load-themes.php". |
66 | 66 | $this->hourlyCheckHooks = array_merge($this->hourlyCheckHooks, $hourlyHooks); |
67 | - foreach($this->hourlyCheckHooks as $hook) { |
|
67 | + foreach ($this->hourlyCheckHooks as $hook) { |
|
68 | 68 | add_action($hook, array($this, 'maybeCheckForUpdates')); |
69 | 69 | } |
70 | 70 | //This hook fires after a bulk update is complete. |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * |
90 | 90 | * This method is declared public because it's a hook callback. Calling it directly is not recommended. |
91 | 91 | */ |
92 | - public function maybeCheckForUpdates(){ |
|
93 | - if ( empty($this->checkPeriod) ){ |
|
92 | + public function maybeCheckForUpdates() { |
|
93 | + if (empty($this->checkPeriod)) { |
|
94 | 94 | return; |
95 | 95 | } |
96 | 96 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $this->checkPeriod |
106 | 106 | ); |
107 | 107 | |
108 | - if ( $shouldCheck ) { |
|
108 | + if ($shouldCheck) { |
|
109 | 109 | $this->updateChecker->checkForUpdates(); |
110 | 110 | } |
111 | 111 | } |
@@ -117,22 +117,22 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function getEffectiveCheckPeriod() { |
119 | 119 | $currentFilter = current_filter(); |
120 | - if ( in_array($currentFilter, array('load-update-core.php', 'upgrader_process_complete')) ) { |
|
120 | + if (in_array($currentFilter, array('load-update-core.php', 'upgrader_process_complete'))) { |
|
121 | 121 | //Check more often when the user visits "Dashboard -> Updates" or does a bulk update. |
122 | 122 | $period = 60; |
123 | - } else if ( in_array($currentFilter, $this->hourlyCheckHooks) ) { |
|
123 | + } else if (in_array($currentFilter, $this->hourlyCheckHooks)) { |
|
124 | 124 | //Also check more often on /wp-admin/update.php and the "Plugins" or "Themes" page. |
125 | 125 | $period = 3600; |
126 | - } else if ( $this->throttleRedundantChecks && ($this->updateChecker->getUpdate() !== null) ) { |
|
126 | + } else if ($this->throttleRedundantChecks && ($this->updateChecker->getUpdate() !== null)) { |
|
127 | 127 | //Check less frequently if it's already known that an update is available. |
128 | - $period = $this->throttledCheckPeriod * 3600; |
|
129 | - } else if ( defined('DOING_CRON') && constant('DOING_CRON') ) { |
|
128 | + $period = $this->throttledCheckPeriod*3600; |
|
129 | + } else if (defined('DOING_CRON') && constant('DOING_CRON')) { |
|
130 | 130 | //WordPress cron schedules are not exact, so lets do an update check even |
131 | 131 | //if slightly less than $checkPeriod hours have elapsed since the last check. |
132 | - $cronFuzziness = 20 * 60; |
|
133 | - $period = $this->checkPeriod * 3600 - $cronFuzziness; |
|
132 | + $cronFuzziness = 20*60; |
|
133 | + $period = $this->checkPeriod*3600 - $cronFuzziness; |
|
134 | 134 | } else { |
135 | - $period = $this->checkPeriod * 3600; |
|
135 | + $period = $this->checkPeriod*3600; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return $period; |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | * @param array $schedules |
145 | 145 | * @return array |
146 | 146 | */ |
147 | - public function _addCustomSchedule($schedules){ |
|
148 | - if ( $this->checkPeriod && ($this->checkPeriod > 0) ){ |
|
149 | - $scheduleName = 'every' . $this->checkPeriod . 'hours'; |
|
147 | + public function _addCustomSchedule($schedules) { |
|
148 | + if ($this->checkPeriod && ($this->checkPeriod > 0)) { |
|
149 | + $scheduleName = 'every'.$this->checkPeriod.'hours'; |
|
150 | 150 | $schedules[$scheduleName] = array( |
151 | - 'interval' => $this->checkPeriod * 3600, |
|
151 | + 'interval' => $this->checkPeriod*3600, |
|
152 | 152 | 'display' => sprintf('Every %d hours', $this->checkPeriod), |
153 | 153 | ); |
154 | 154 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @return void |
162 | 162 | */ |
163 | - public function removeUpdaterCron(){ |
|
163 | + public function removeUpdaterCron() { |
|
164 | 164 | wp_clear_scheduled_hook($this->cronHook); |
165 | 165 | } |
166 | 166 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( !class_exists('Puc_v4p4_Theme_Update', false) ): |
|
3 | +if (!class_exists('Puc_v4p4_Theme_Update', false)): |
|
4 | 4 | |
5 | 5 | class Puc_v4p4_Theme_Update extends Puc_v4p4_Update { |
6 | 6 | public $details_url = ''; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | 'url' => $this->details_url, |
21 | 21 | ); |
22 | 22 | |
23 | - if ( !empty($this->download_url) ) { |
|
23 | + if (!empty($this->download_url)) { |
|
24 | 24 | $update['package'] = $this->download_url; |
25 | 25 | } |
26 | 26 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function fromJson($json) { |
37 | 37 | $instance = new self(); |
38 | - if ( !parent::createFromJson($json, $instance) ) { |
|
38 | + if (!parent::createFromJson($json, $instance)) { |
|
39 | 39 | return null; |
40 | 40 | } |
41 | 41 | return $instance; |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | */ |
62 | 62 | protected function validateMetadata($apiResponse) { |
63 | 63 | $required = array('version', 'details_url'); |
64 | - foreach($required as $key) { |
|
65 | - if ( !isset($apiResponse->$key) || empty($apiResponse->$key) ) { |
|
64 | + foreach ($required as $key) { |
|
65 | + if (!isset($apiResponse->$key) || empty($apiResponse->$key)) { |
|
66 | 66 | return new WP_Error( |
67 | 67 | 'tuc-invalid-metadata', |
68 | 68 | sprintf('The theme metadata is missing the required "%s" key.', $key) |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | protected function getPrefixedFilter($tag) { |
80 | - return parent::getPrefixedFilter($tag) . '_theme'; |
|
80 | + return parent::getPrefixedFilter($tag).'_theme'; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 |