Commit Graph

587 Commits

Author SHA1 Message Date
Yahnis Elsts 3004e10f75 Add a way to filter the HTTP options used when making GitHub/BitBucket API requests.
Example: 
 
 $updateChecker->addHttpRequestArgFilter('my_callback');
 
 function my_callback($options) {
     $options['timeout'] = 30;
     return $options;
 }
2016-12-28 17:15:42 +02:00
Yahnis Elsts f41dc30d28 Minor fixes and some comments 2016-12-28 16:09:28 +02:00
Yahnis Elsts cdf2d22243 Refactoring GitHub and BitBucket support.
Move most GitHub and BitBucket stuff to a general "VCS checker" class and put service-specific logic in API classes that follow a common interface.

Rationale: Upon further reflection, there's no need to have different theme & plugin checker implementations for each Git hosting service. The overall update detection algorithm stays the same. Only the API and authentication are different. 
 
 Not entirely happy with the code duplication in Vcs_PluginUpdateChecker and Vcs_ThemeUpdateChecker. Traits would be one solution, but can't use that in PHP 5.2. There's probably a "good enough" way to achieve the same thing through composition, but I haven't figured it out yet. 
 
 For private GH repositories, use setAuthentication('access_token_here') instead of setAccessToken().
2016-12-27 18:03:06 +02:00
Yahnis Elsts cde890f5d4 Minor: Update comments. 2016-12-24 16:03:58 +02:00
Yahnis Elsts f62a3d40fe Simplify tag sorting.
We don't need two different implementation for GitHub and BitBucket, they use the same property name. But lets make the property configurable anyway in case other APIs do differ.
2016-12-24 15:14:34 +02:00
Yahnis Elsts 365792edde Refactor BitBucket and GitHub checkers to be more similar.
In the future, it would probably be possible to add a general base class for repository-based updates.
2016-12-24 15:04:25 +02:00
Yahnis Elsts f64c3170cc BitBucket support is now semi-usable.
More testing required. Could probably refactor to reduce duplication; lots of overlap with GitHub integration.
2016-12-22 19:10:05 +02:00
Yahnis Elsts 3692f5201e Fix autoloading of files in the "vendor" subdirectory.
I was using the wrong directory path, oops.
2016-12-22 18:49:51 +02:00
Yahnis Elsts 5b427b4e28 Minor: Fix typo in a comment. 2016-12-22 16:05:15 +02:00
Yahnis Elsts 55077f4a03 WIP: BitBucket support. Not usable yet! 2016-12-20 17:06:14 +02:00
Yahnis Elsts 16ab2457df Support themes hosted on GitHub.
What should "View version 1.2.3 details" link to? Theme URI, the changelog, the release, or the repository itself?
2016-12-19 19:26:34 +02:00
Yahnis Elsts f1e59b183c Rename DebugBar AJAX actions to prevent conflicts with previous versions. 2016-12-19 19:05:06 +02:00
Yahnis Elsts 8c7b3f80d6 Improve upgrade-in-progress detection for themes. In WP 4.6, AJAX-based upgrades use a different skin that was previously not supported. 2016-12-19 18:41:37 +02:00
Yahnis Elsts 0cd1c51c57 Autoload Parsedown and the readme parser.
Refactor requestUpdate() filtering.
Rename getFilterName to getUniqueName because it's used for more than just filter names.
Added  a couple of utility methods.
2016-12-17 19:04:52 +02:00
Yahnis Elsts 3e11878ac8 DebugBar integration for themes.
Change filter structure from puc_/tuc_* to puc_tag_[theme]-$slug. Not happy with that yet.
Fix a bunch of minor bugs.
2016-12-17 17:57:27 +02:00
Yahnis Elsts 2a176fc665 Move update injection and directory name fixes to the base UpdateChecker class. 2016-12-16 17:53:15 +02:00
Yahnis Elsts f5ae142e63 Translation, localization. Fix a bunch of crashes. 2016-12-14 21:13:51 +02:00
Yahnis Elsts 26c24167ab WIP: Theme updates.
- Refactor the scheduler so that it can be used in themes.
- Add state storage to the base update checker.
- Move the "allow metadata host" workaround to the base class.
- Rename cron hook from "check_plugin_updates-$slug" to "puc_cron_check_updates-$slug" and "tuc_cron_check_updates-$slug".
2016-12-14 11:18:58 +02:00
Yahnis Elsts 9effd33bfa WIP: Theme updates 2016-12-12 16:26:41 +02:00
Yahnis Elsts 79c2439464 Start reorganizing directory structure to comply with PSR-0 (mostly). 2016-12-08 16:56:24 +02:00
Yahnis Elsts 38dabff869 Bump version number to 3.2 2016-12-08 12:22:54 +02:00
Yahnis Elsts 93c9d661d5 Trigger a fatal error if the plugin slug is in use.
Slugs must be unique because they're used for option names, filter names and so on. This is a potentially breaking change.
2016-11-16 12:35:52 +02:00
Yahnis Elsts 3ec4c0b56a Add a note recommending explicit slugs. 2016-11-13 13:18:05 +02:00
Yahnis Elsts ed9d8be9e5 Add Persian translation. Props to @Pro-Style
Closes #72
2016-10-29 12:17:41 +03:00
Yahnis Elsts 73852adb2d Fix parsing of "= version =" headers in readme.txt
The readme.txt format that's used by WordPress is not quite standard Markdown. It includes a couple of features that are not directly supported by popular Markdown parsers. One of those features is parsing "= string =" as "<h4>string</h4>" (the opening "=" must be at the start of the line). Leading whitespace is allowed. This syntax is typically for plugin version numbers in the changelog section.

The problem: the readme parser discards leading whitespace when parsing these headers. This means it can also discard the previous line break character(s). As a result, this markup:
 
 * abc
 
 = 1.2.3 =
 * def
 
 Becomes this:
 
 * abc
 <h4>1.2.3</h4>
 * def
 
 The way that Parsedown handles this markup is to make the H4 a part of the preceding list item. And that's a bug. 
   
 Fixed by keeping leading whitespace instead of throwing it away.

Closes #68
2016-09-14 19:42:09 +03:00
Yahnis Elsts ad3a7a9c2f Merge pull request #65 from rvola/master
Correction Language FR
2016-08-07 13:22:15 +03:00
Nicolas GEHIN ccdc247193 Correction Language FR
plugin > extension
changelog > journal de mise à jour
2016-08-04 21:09:48 +02:00
Yahnis Elsts 4e2ad11aee Minor: Fix line separators 2016-07-28 11:08:49 +03:00
Yahnis Elsts 1b0d2b464b Merge pull request #63 from LastElb/master
Added German translation
2016-06-30 19:04:21 +03:00
Igor Lückel 482a63456f Added german translation 2016-06-29 21:46:16 +02:00
Yahnis Elsts bcade9eb51 Bump version number to 3.1 2016-05-11 18:28:19 +03:00
Yahnis Elsts 653bf723fe Merge remote-tracking branch 'refs/remotes/origin/language-packs' 2016-05-05 16:11:34 +03:00
Yahnis Elsts a9ce2de7cf Merge remote-tracking branch 'refs/remotes/origin/master' into language-packs 2016-05-05 16:06:11 +03:00
Yahnis Elsts c6970fd883 Extract translation update filter as a method. 2016-05-03 18:32:39 +03:00
Yahnis Elsts 531c4d8247 Fix crash when running 3.x together with 2.x or lower while Debug Bar is active.
While most PUC class names use version number suffixes to avoid conflicts with older versions of the library, the classes responsible for Debug Bar integration did not (until now). This is because those classes are fairly simple and they have stayed mostly unchanged since version 1.0. Mostly, but not completely. For example, the debug bar panel depends on the getCronHookName() function, and that function was recently moved to the new PucScheduler class. 

This is a problem because when your site has two plugins using two different versions of this library (e.g. 3.0 and 1.3), you can end up in a situation where PluginUpdateChecker_3_0 unintentionally instantiates the old version of PluginUpdateCheckerPanel (1.3). Then the panel then tries to access a non-existent field or method of PluginUpdateChecker_3_0 and crashes. It produces errors like this:

[26-Apr-2016 13:34:14 UTC] PHP Fatal error:  Call to undefined method PluginUpdateChecker_3_0::getCronHookName() in [redacted]\wp-content\plugins\plugin-name-here\inc\plugin-updates\debug-bar-panel.php on line 58

Fixed by versioning debug bar panel class names.
2016-04-26 17:02:46 +03:00
Yahnis Elsts 0cfe8deaad Minor: Add a @see reference to the WP API that clears the update cache. 2016-04-19 15:42:38 +03:00
Yahnis Elsts 2c6bfc6309 Initial support for translation updates / language packs. Needs polishing and testing. 2016-04-19 13:56:54 +03:00
Yahnis Elsts 026fb99eef Initialize the $sections property with a default value (empty array).
This way we don't need to check if it's initialised.
2016-03-25 11:45:30 +02:00
Yahnis Elsts 8ec6aad7b9 Minor: whitespace 2016-03-24 22:30:11 +02:00
Yahnis Elsts b973ad6452 Simplify a couple of conditions.
In theory, $state and $state->update should always be either NULL or objects. That means isset() fully covers the possibilities and we don't need the additional empty() checks.
2016-03-24 22:27:20 +02:00
Yahnis Elsts 7a1f6d90ab Minor: Fix inconsistent indentation. 2016-03-24 21:46:07 +02:00
Yahnis Elsts de5b1d42a8 Minor: Fix incorrectly capitalized class name ("StdClass" -> "stdClass"). 2016-03-24 21:37:50 +02:00
Yahnis Elsts 43a04cca8c Extract check period calculation as a method. 2016-03-24 21:33:31 +02:00
Yahnis Elsts 71631d1306 Minor: Fix inconsistent whitespace. 2016-03-15 13:56:45 +02:00
Yahnis Elsts 377e7b5030 Merge pull request #57 from lengthofrope/master
Support both PHP 7 and PHP <5.3

Load different versions of the Parsedown library depending on the PHP version. This will only affect plugins that use the GitHub update checker because the usual checker doesn't need to parse Markdown.
2016-03-15 13:48:20 +02:00
Bas de Kort 0b4a9d16cf Add: Parsedown.php (1.6.0) 2016-03-11 06:51:43 +01:00
Bas de Kort d91e930c7b Rename Parsedown.php to ParsedownLegacy.php 2016-03-11 06:51:09 +01:00
Yahnis Elsts 6e5ebbd378 Minor: Fix some coding style issues. 2016-03-08 19:47:39 +02:00
Yahnis Elsts 67fb7c0e6b WP 4.5 compat: Add `tested` to update fields.
It appears that WordPress core developers are planning to add the `tested` and `compatibility` fields to the bulk update check API. Previously WordPress had to make a separate API request for each plugin to retrieve this information. See this Trac ticket for details:
 https://core.trac.wordpress.org/ticket/35301
 
 The `tested` field is used to generate the "Compatibility with WordPress X.Y: 100% (according to its author)" message on the "Dashboard -> Updates" page.
 
 Note: This library doesn't support the `compatibility` field, so that's not included.
2016-03-08 19:41:47 +02:00
Yahnis Elsts 04176ffa38 Merge pull request #55 from rvola/master
Add PO/MO French translation
2016-02-18 13:50:19 +02:00