Commit Graph

82 Commits

Author SHA1 Message Date
David Anderson f0a10eaca9 Use a WP 3.7+ function conditionally
`wp_get_installed_translations()` was introduced in WP 3.7. This change returns an empty result for the translations list if the function does not exist. (Encountered in the wild, fatal error).
2017-10-13 12:26:16 +00:00
Yahnis Elsts e48d41e30d Remove PUC hooks upon uninstallation to prevent a crash
See #138 for details.
2017-10-11 17:24:23 +03:00
Yahnis Elsts 1cc6a90acf Merge pull request #137 from aaronkirkham/master
GitLab Integration
2017-10-06 10:56:25 +03:00
aaronlad 58e28b8fd7 code style consistency changes 2017-10-05 16:52:41 +01:00
David Anderson aa4272cbcc Correct typo 2017-09-30 16:08:50 +00:00
David Anderson 36eb8e3b10 Use Puc_v4_Factory::normalizePath() 2017-09-30 16:06:46 +00:00
David Anderson 972d649614 Make normalizePath public 2017-09-30 16:03:50 +00:00
aaronkirkham07@gmail.com 50b5d7170e removed getLatestCommit method
removed Factory magic to detect self-hosted gitlab instances
updated readme with gitlab instructions
2017-09-30 16:15:00 +01:00
David Anderson 2f225bdcce Code style consistency 2017-09-30 14:40:07 +00:00
aaronkirkham07@gmail.com a2ca0ba0f2 support gitlab instances installed in a subdirectory
no longer checking for 'gitlab' in the hostname
2017-09-30 15:38:16 +01:00
aaronkirkham07@gmail.com ccc07e9ce3 sprintf consistency 2017-09-30 01:55:37 +01:00
aaronkirkham07@gmail.com 4339460aed fix weird tab/spaces 2017-09-30 01:45:09 +01:00
aaronkirkham07@gmail.com cf2c07a531 support downloads from gitlab
added support for branches
implemented getLatestCommitTime method
2017-09-30 01:32:10 +01:00
aaronkirkham07@gmail.com 84f2efda8f fix spaces 2017-09-30 00:45:46 +01:00
aaronkirkham07@gmail.com 3760c5140e initial support for GitLab 2017-09-30 00:43:58 +01:00
David Anderson fbe1d818c1 Work on WP versions without wp_normalize_path()
WP < 3.9 does not have the wp_normalize_path() function available. This edit restores the ability to work on such versions.
2017-09-29 21:37:31 +00:00
Yahnis Elsts 846d111947 Bump version: Step 2: Rename subdirectory 2017-07-21 14:27:31 +03:00
Yahnis Elsts f74c67145b Bump version number to 4.2 (step 1) 2017-07-21 14:16:21 +03:00
Yahnis Elsts f0cc400fbd Refactor GitHubAPI: Extract URL generation as a method.
The code that builds API URLs is probably complicated enough to warrant a separate method: it performs placeholder substitution, does authentication-related stuff (access_token), and builds the query string.
2017-07-21 12:08:37 +03:00
Yahnis Elsts f352474fd0 Minor: Simplify Utils::get()
Behaviour change: An empty path now returns the collection itself, not the default value. This doesn't really matter for the current version because it only uses constant, non-empty paths.
2017-07-20 20:23:42 +03:00
Yahnis Elsts 4fd8135f17 Minor: Explicit visibility for methods 2017-07-20 19:54:44 +03:00
Yahnis Elsts 2b96d033a5 Minor: Use strict comparisons 2017-07-20 19:52:45 +03:00
David Anderson 7061a5b195 Update UpdateChecker.php
Tweak filter name
2017-07-17 21:27:23 +00:00
David Anderson ef91a9409d Make wp_remote_get result filterable
I want to filter the wp_remote_get result. In my use-case, if https fails, I switch back to http (in case the user had a bad curl setup/obsolete SSL certificates) and try again.

Until now I've been patching the code, but that is, of course, silly!
2017-07-17 14:12:39 +00:00
Yahnis Elsts be797d2f7a Suppress warnings about set_time_limit being disabled.
Some hosts disable set_time_limit() and a few other functions. Calling the disabled function triggers a warning. In our case, using set_time_limit() is optional - PUC will usually work fine even if it can't increase the time limit - so lets just ignore the warning and carry on. 

Reported in #111.
2017-06-17 22:18:41 +03:00
Yahnis Elsts 235a810e90 Fix an issue with Debug Bar 0.9 where the content of some PUC panels was not visible. See issue #102.
Cause: Debug Bar 0.9 now includes an admin bar menu that lists the available panels. This means that the special element that PUC uses to identify its panel titles (<span id="puc-debug-menu-link-$uid">) is no longer unique. This breaks the JS that's supposed to work around the fact that Debug Bar incorrectly assumes that every panel will have a unique PHP class name.
2017-05-16 21:16:08 +03:00
Yahnis Elsts ea2bf49144 Minor: Remove commented-out code. 2017-05-01 13:20:22 +03:00
Yahnis Elsts 22689ce0cc Add GitHub API response to the `Vcs_Reference` instance.
This is intended for use in subclasses, e.g. to change the `downloadUrl` from `zipball_url` to an asset URL.
2017-04-12 12:13:53 +03:00
Yahnis Elsts 164aacf4c1 Bump version number to 4.1
This may look like a lot of changes, but it's essentially a simple search & replace from "v4" to "v4p1". Note that the factory class name stays the same: Puc_v4_Factory. It will only change on a major release.
2017-04-06 16:32:40 +03:00
Yahnis Elsts 28dc39ae58 Minor: Adjust code spacing 2017-04-04 20:29:03 +03:00
Laptop 3 6cabab9179 Add plugin title to admin notice 2017-04-04 01:55:45 -04:00
Yahnis Elsts f812b2d3c0 Fix a rare error caused by a bug get_theme_root()
This is workaround that addresses a potential issue with automagic plugin vs theme detection. A user reports that sometimes get_theme_root() can return an empty string when using AMP. Also, there can be multiple theme roots. 

Instead of dealing with that mess, lets simply look for a style.css file in the same directory as $absolutePath. This approach has low specificity (i.e. a plugin could have a style.css file), so it should have lower priority. I've moved it after the isPluginFile() check.

BC note: This means that when using PUC in a theme, the second argument to buildUpdateChecker() *must* be either the theme directory path, or a path to a file at the root of the theme. That is, all of these will work fine:
 /foo/wp-content/themes/my-theme
 /foo/wp-content/themes/my-theme/functions.php
 /foo/wp-content/themes/my-theme/another-php-file.php
 
 This will NOT work:
 /foo/wp-content/themes/my-theme/includes/something.php 
 
 This shouldn't be an issue for people who followed the documentation.
2017-04-03 17:56:13 +03:00
Yahnis Elsts 5c963ff869 TODO: Work around a WP bug and multiple theme directories 2017-03-30 13:52:18 +03:00
Yahnis Elsts b1d2b98197 Send PHP version and WP locale as query parameters.
Possible uses:
- See when it's safe to raise PHP version requirements.
- Avoid showing users updates that are incompatible with their PHP version.
- Have an LTS branch for people running old PHP versions, and deliver different update packages based on the version.
- Return updates for only those language packs that match the site locale, not all available languages.
2017-02-05 15:46:03 +02:00
Yahnis Elsts e4854cdb38 BitBucket fix: When looking for the latest tags, sort them by commit date in descending order.
Previously, PUC didn't specify any explicit sorting criteria. I incorrectly assumed that BitBucket would return the most recent tags first. As a result, when a repository had enough tags to trigger API response pagination, PUC could miss some recent tags. Related: #48
2017-01-24 12:18:34 +02:00
Yahnis Elsts fbff383b7e Fix downloads from private GitHub repositories.
Cause: GitHub API client didn't sign download URLs (oops!). See #84
2017-01-17 09:13:17 +02:00
Yahnis Elsts 8a04b9679e Improve plugin detection. Related to #82.
Technically, it's possible to place a plugin anywhere outside the WordPress directory and then create a symlink inside /wp-content/plugins that points to the plugin directory. If the plugin developer then passes the real, symlink-resolved path to the PUC factory, PUC will assume it can't be a plugin because it's not inside the expected directory.
  
Semi-fixed by checking if the input file contains a valid plugin header. However, I would still recommend against using symlinks in this manner because it's likely to cause odd bugs elsewhere. For example, __FILE__ resolves symlinks but plugin_basename() doesn't. This means that the basename that WP sees and the basename you generate in your own code might not match.
2017-01-14 12:39:24 +02:00
Yahnis Elsts 467000eb73 Fail immediately if PUC can't tell whether it's being used in a plugin or a theme.
In theory, that should never happen, but the bug reported in #82 shows that it does.
2017-01-14 11:28:30 +02:00
Yahnis Elsts fd62858e90 Fix "Cannot declare class Puc_v4_Autoloader".
Oops, I knew I'd missed something! Well, this is that something.
2017-01-13 18:49:54 +02:00
Yahnis Elsts 1bf50ba942 Merge pull request #79 from YahnisElsts/version4
Fix some BitBucket and compat. bugs that were missed during testing
2017-01-12 11:38:49 +02:00
Yahnis Elsts 385ecf8df4 Fix pre-WP 4.7 compatibility.
get_user_locale() is not available in older WordPress versions. Also, according to WP docs, load_plugin_textdomain (and, presumably, its siblings) should be called in `init` or later.
2017-01-12 11:36:35 +02:00
Nicolas GEHIN e506d65915 Space in path not load language 2017-01-12 08:48:14 +01:00
Yahnis Elsts 0d5de0d4cc Fix zip error when installing update from a private BitBucket repository.
The code that updates the OAuth signature didn't account for the fact that the oauth_signature query parameter would end up in the wrong place. Instead of being sorted alphabetically with the rest of parameters, it must be the *last* one.
2017-01-11 22:17:49 +02:00
Yahnis Elsts 5d60e87cb6 Fix version number parsing.
The code that checks if the first character is a number was just plain wrong. It checked if the whole string is numeric.
2017-01-11 22:15:37 +02:00
Yahnis Elsts 6ba1aeb362 Minor: Move condition so that the fixDirectoryName filter never gets called if there's no valid directory name. 2017-01-10 17:05:07 +02:00
Yahnis Elsts d71578067d Minor: Rename parameter to $collection because it accepts both arrays and objects 2017-01-10 16:20:33 +02:00
Yahnis Elsts 4f1ec59f98 Remove unused property 2017-01-10 16:20:01 +02:00
Yahnis Elsts 57df68d407 Extract state storage as a new class.
Lazy-loading is a bit messy. Could it be improved with magic __get() and __set()?
2017-01-10 15:25:36 +02:00
Yahnis Elsts 844516d1f5 Treat null entries as non-existent. Add a startsWith() method.
This is necessary to avoid fatal errors when trying to retrieve existing but inaccessible properties (i.e. private or protected).
2017-01-10 13:13:01 +02:00
Yahnis Elsts aeeda3c330 Reduce code duplication by moving most similar code from requestUpdate and requestInfo into a new method: requestMetadata. 2017-01-06 10:40:42 +02:00