From 360fe48089a13ad8ac9b7d3bd2ab516beeb01806 Mon Sep 17 00:00:00 2001 From: Keith Solomon Date: Sun, 9 Aug 2026 20:27:58 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8feature:=20Initial=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 + LICENSE | 339 ++++ README.md | 180 ++ admin/admin-settings.php | 169 ++ admin/cpt-taxonomy.php | 53 + admin/metabox.php | 62 + admin/rest-api.php | 133 ++ assets/css/admin-styles.css | 44 + assets/css/style.css | 285 +++ assets/js/buttons.js | 6 + includes/helper-functions.php | 203 +++ .../Puc/v5/PucFactory.php | 10 + .../Puc/v5p4/Autoloader.php | 86 + .../Puc/v5p4/DebugBar/Extension.php | 199 +++ .../Puc/v5p4/DebugBar/Panel.php | 178 ++ .../Puc/v5p4/DebugBar/PluginExtension.php | 40 + .../Puc/v5p4/DebugBar/PluginPanel.php | 41 + .../Puc/v5p4/DebugBar/ThemePanel.php | 25 + .../Puc/v5p4/InstalledPackage.php | 105 ++ .../Puc/v5p4/Metadata.php | 162 ++ .../Puc/v5p4/OAuthSignature.php | 102 ++ .../Puc/v5p4/Plugin/Package.php | 188 ++ .../Puc/v5p4/Plugin/PluginInfo.php | 136 ++ .../Puc/v5p4/Plugin/Ui.php | 294 ++++ .../Puc/v5p4/Plugin/Update.php | 116 ++ .../Puc/v5p4/Plugin/UpdateChecker.php | 425 +++++ .../Puc/v5p4/PucFactory.php | 362 ++++ .../Puc/v5p4/Scheduler.php | 300 ++++ .../Puc/v5p4/StateStore.php | 214 +++ .../Puc/v5p4/Theme/Package.php | 69 + .../Puc/v5p4/Theme/Update.php | 88 + .../Puc/v5p4/Theme/UpdateChecker.php | 159 ++ .../plugin-update-checker/Puc/v5p4/Update.php | 38 + .../Puc/v5p4/UpdateChecker.php | 1029 +++++++++++ .../Puc/v5p4/UpgraderStatus.php | 200 +++ .../plugin-update-checker/Puc/v5p4/Utils.php | 70 + .../Puc/v5p4/Vcs/Api.php | 379 ++++ .../Puc/v5p4/Vcs/BaseChecker.php | 29 + .../Puc/v5p4/Vcs/BitBucketApi.php | 272 +++ .../Puc/v5p4/Vcs/GitHubApi.php | 467 +++++ .../Puc/v5p4/Vcs/GitLabApi.php | 414 +++++ .../Puc/v5p4/Vcs/PluginUpdateChecker.php | 275 +++ .../Puc/v5p4/Vcs/Reference.php | 51 + .../Puc/v5p4/Vcs/ReleaseAssetSupport.php | 83 + .../Puc/v5p4/Vcs/ReleaseFilteringFeature.php | 108 ++ .../Puc/v5p4/Vcs/ThemeUpdateChecker.php | 83 + .../Puc/v5p4/Vcs/VcsCheckerMethods.php | 59 + .../Puc/v5p4/WpCliCheckTrigger.php | 84 + includes/plugin-update-checker/README.md | 372 ++++ includes/plugin-update-checker/composer.json | 23 + .../css/puc-debug-bar.css | 70 + .../plugin-update-checker/js/debug-bar.js | 54 + .../languages/plugin-update-checker-ca.mo | Bin 0 -> 1186 bytes .../languages/plugin-update-checker-ca.po | 48 + .../languages/plugin-update-checker-cs_CZ.mo | Bin 0 -> 1077 bytes .../languages/plugin-update-checker-cs_CZ.po | 45 + .../languages/plugin-update-checker-da_DK.mo | Bin 0 -> 1010 bytes .../languages/plugin-update-checker-da_DK.po | 42 + .../languages/plugin-update-checker-de_DE.mo | Bin 0 -> 980 bytes .../languages/plugin-update-checker-de_DE.po | 38 + .../languages/plugin-update-checker-es_AR.mo | Bin 0 -> 1140 bytes .../languages/plugin-update-checker-es_AR.po | 48 + .../languages/plugin-update-checker-es_CL.mo | Bin 0 -> 1140 bytes .../languages/plugin-update-checker-es_CL.po | 48 + .../languages/plugin-update-checker-es_CO.mo | Bin 0 -> 1140 bytes .../languages/plugin-update-checker-es_CO.po | 48 + .../languages/plugin-update-checker-es_CR.mo | Bin 0 -> 1140 bytes .../languages/plugin-update-checker-es_CR.po | 48 + .../languages/plugin-update-checker-es_DO.mo | Bin 0 -> 1140 bytes .../languages/plugin-update-checker-es_DO.po | 48 + .../languages/plugin-update-checker-es_ES.mo | Bin 0 -> 1140 bytes .../languages/plugin-update-checker-es_ES.po | 48 + .../languages/plugin-update-checker-es_GT.mo | Bin 0 -> 1140 bytes .../languages/plugin-update-checker-es_GT.po | 48 + .../languages/plugin-update-checker-es_HN.mo | Bin 0 -> 1140 bytes .../languages/plugin-update-checker-es_HN.po | 48 + .../languages/plugin-update-checker-es_MX.mo | Bin 0 -> 1140 bytes .../languages/plugin-update-checker-es_MX.po | 48 + .../languages/plugin-update-checker-es_PE.mo | Bin 0 -> 1140 bytes .../languages/plugin-update-checker-es_PE.po | 48 + .../languages/plugin-update-checker-es_PR.mo | Bin 0 -> 1140 bytes .../languages/plugin-update-checker-es_PR.po | 48 + .../languages/plugin-update-checker-es_UY.mo | Bin 0 -> 1140 bytes .../languages/plugin-update-checker-es_UY.po | 48 + .../languages/plugin-update-checker-es_VE.mo | Bin 0 -> 1140 bytes .../languages/plugin-update-checker-es_VE.po | 48 + .../languages/plugin-update-checker-fa_IR.mo | Bin 0 -> 1128 bytes .../languages/plugin-update-checker-fa_IR.po | 38 + .../languages/plugin-update-checker-fr_CA.mo | Bin 0 -> 1208 bytes .../languages/plugin-update-checker-fr_CA.po | 48 + .../languages/plugin-update-checker-fr_FR.mo | Bin 0 -> 1066 bytes .../languages/plugin-update-checker-fr_FR.po | 42 + .../languages/plugin-update-checker-hu_HU.mo | Bin 0 -> 982 bytes .../languages/plugin-update-checker-hu_HU.po | 41 + .../languages/plugin-update-checker-it_IT.mo | Bin 0 -> 1135 bytes .../languages/plugin-update-checker-it_IT.po | 48 + .../languages/plugin-update-checker-ja.mo | Bin 0 -> 1454 bytes .../languages/plugin-update-checker-ja.po | 57 + .../languages/plugin-update-checker-nl_BE.mo | Bin 0 -> 1211 bytes .../languages/plugin-update-checker-nl_BE.po | 48 + .../languages/plugin-update-checker-nl_NL.mo | Bin 0 -> 1211 bytes .../languages/plugin-update-checker-nl_NL.po | 48 + .../languages/plugin-update-checker-pt_BR.mo | Bin 0 -> 1014 bytes .../languages/plugin-update-checker-pt_BR.po | 48 + .../languages/plugin-update-checker-ru_RU.mo | Bin 0 -> 1337 bytes .../languages/plugin-update-checker-ru_RU.po | 48 + .../languages/plugin-update-checker-sl_SI.mo | Bin 0 -> 1203 bytes .../languages/plugin-update-checker-sl_SI.po | 48 + .../languages/plugin-update-checker-sv_SE.mo | Bin 0 -> 1006 bytes .../languages/plugin-update-checker-sv_SE.po | 42 + .../languages/plugin-update-checker-tr_TR.mo | Bin 0 -> 1118 bytes .../languages/plugin-update-checker-tr_TR.po | 48 + .../languages/plugin-update-checker-uk_UA.mo | Bin 0 -> 1309 bytes .../languages/plugin-update-checker-uk_UA.po | 48 + .../languages/plugin-update-checker-zh_CN.mo | Bin 0 -> 1174 bytes .../languages/plugin-update-checker-zh_CN.po | 57 + .../languages/plugin-update-checker.pot | 49 + includes/plugin-update-checker/license.txt | 7 + includes/plugin-update-checker/load-v5p4.php | 34 + .../plugin-update-checker.php | 10 + .../vendor/Parsedown.php | 4 + .../vendor/ParsedownModern.php | 1538 +++++++++++++++++ .../vendor/PucReadmeParser.php | 352 ++++ .../projects-for-wordpress-es_MX.l10n.php | 3 + languages/projects-for-wordpress-es_MX.mo | Bin 0 -> 4988 bytes languages/projects-for-wordpress-es_MX.po | 303 ++++ languages/projects-wp-fr_FR.l10n.php | 3 + languages/projects-wp-fr_FR.mo | Bin 0 -> 5062 bytes languages/projects-wp-fr_FR.po | 303 ++++ languages/projects-wp.pot | 300 ++++ projects-for-wordpress.php | 390 +++++ templates/archive-projects.php | 72 + templates/single-projects.php | 242 +++ templates/taxonomy-project-type.php | 72 + 134 files changed, 14125 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 admin/admin-settings.php create mode 100644 admin/cpt-taxonomy.php create mode 100644 admin/metabox.php create mode 100644 admin/rest-api.php create mode 100644 assets/css/admin-styles.css create mode 100644 assets/css/style.css create mode 100644 assets/js/buttons.js create mode 100644 includes/helper-functions.php create mode 100644 includes/plugin-update-checker/Puc/v5/PucFactory.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Autoloader.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/DebugBar/Extension.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/DebugBar/Panel.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/DebugBar/PluginExtension.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/DebugBar/PluginPanel.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/DebugBar/ThemePanel.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/InstalledPackage.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Metadata.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/OAuthSignature.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Plugin/Package.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Plugin/PluginInfo.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Plugin/Update.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Plugin/UpdateChecker.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/PucFactory.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Scheduler.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/StateStore.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Theme/Package.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Theme/Update.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Theme/UpdateChecker.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Update.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/UpdateChecker.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/UpgraderStatus.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Utils.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Vcs/Api.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Vcs/BaseChecker.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Vcs/BitBucketApi.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Vcs/GitHubApi.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Vcs/GitLabApi.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Vcs/PluginUpdateChecker.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Vcs/Reference.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Vcs/ReleaseAssetSupport.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Vcs/ReleaseFilteringFeature.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Vcs/ThemeUpdateChecker.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/Vcs/VcsCheckerMethods.php create mode 100644 includes/plugin-update-checker/Puc/v5p4/WpCliCheckTrigger.php create mode 100644 includes/plugin-update-checker/README.md create mode 100644 includes/plugin-update-checker/composer.json create mode 100644 includes/plugin-update-checker/css/puc-debug-bar.css create mode 100644 includes/plugin-update-checker/js/debug-bar.js create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-ca.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-ca.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-cs_CZ.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-cs_CZ.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-da_DK.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-da_DK.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-de_DE.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-de_DE.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_AR.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_AR.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_CL.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_CL.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_CO.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_CO.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_CR.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_CR.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_DO.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_DO.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_ES.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_ES.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_GT.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_GT.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_HN.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_HN.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_MX.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_MX.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_PE.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_PE.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_PR.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_PR.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_UY.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_UY.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_VE.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-es_VE.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-fa_IR.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-fa_IR.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-fr_CA.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-fr_CA.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-fr_FR.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-fr_FR.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-hu_HU.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-hu_HU.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-it_IT.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-it_IT.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-ja.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-ja.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-nl_BE.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-nl_BE.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-nl_NL.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-nl_NL.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-pt_BR.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-pt_BR.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-ru_RU.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-ru_RU.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-sl_SI.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-sl_SI.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-sv_SE.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-sv_SE.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-tr_TR.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-tr_TR.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-uk_UA.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-uk_UA.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-zh_CN.mo create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker-zh_CN.po create mode 100644 includes/plugin-update-checker/languages/plugin-update-checker.pot create mode 100644 includes/plugin-update-checker/license.txt create mode 100644 includes/plugin-update-checker/load-v5p4.php create mode 100644 includes/plugin-update-checker/plugin-update-checker.php create mode 100644 includes/plugin-update-checker/vendor/Parsedown.php create mode 100644 includes/plugin-update-checker/vendor/ParsedownModern.php create mode 100644 includes/plugin-update-checker/vendor/PucReadmeParser.php create mode 100644 languages/projects-for-wordpress-es_MX.l10n.php create mode 100644 languages/projects-for-wordpress-es_MX.mo create mode 100644 languages/projects-for-wordpress-es_MX.po create mode 100644 languages/projects-wp-fr_FR.l10n.php create mode 100644 languages/projects-wp-fr_FR.mo create mode 100644 languages/projects-wp-fr_FR.po create mode 100644 languages/projects-wp.pot create mode 100644 projects-for-wordpress.php create mode 100644 templates/archive-projects.php create mode 100644 templates/single-projects.php create mode 100644 templates/taxonomy-project-type.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e50a0a2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.claude/ +.vscode/ +docs/ +notes/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3490a1e --- /dev/null +++ b/README.md @@ -0,0 +1,180 @@ +# Projects for WordPress® + +Create a beautifully structured, developer-first showcase directory for your WordPress® plugins, themes, and patterns - powered by GitHub. + +## What It Does + +**Projects for WordPress®** adds a custom post type (`projects`) and taxonomy (`project-type`) to your WordPress® admin, allowing you to: + +- Add plugins, themes, or patterns as projects. +- Connect each project to a GitHub repository. +- Automatically fetch and display data like: + - Latest version + - Stars, forks, issues + - License and language + - Download counts +- Create a public download URL: `/download/ID/` +- Track and sort download metrics +- Render archive and single views with theme fallbacks or built-in templates +- Customize display settings via a clean settings page +- Provide social sharing buttons using Tabler Icons +- Use built-in REST API endpoints for listing and querying project data + +--- + +## Installation + +### From GitHub + +1. **Download the latest ZIP** from the [GitHub Releases page](https://github.com/robertdevore/projects-portfolio/releases). +2. Go to your WordPress® Dashboard → Plugins → Add New → Upload Plugin. +3. Upload the ZIP and activate the plugin. + +### From [keithsolomon.net](https://keithsolomon.net) + +1. Visit the official plugin page: [Projects for WordPress®](https://keithsolomon.net/projects/projects-portfolio). +2. Download the ZIP. +3. Install it via the WordPress® dashboard like above. + +--- + +## Usage + +### Add a New Project + +1. In the WordPress® admin, go to **Projects → Add New**. +2. Add your project title, description, and featured image. +3. Select a **Project Type**: Plugin, Theme, or Pattern. +4. In the sidebar, paste the GitHub Repository URL (e.g., `https://github.com/username/repo`). +5. Publish. + +### Enable Download Link + +Each project automatically gets a unique download endpoint: + +Example: +`https://example.com/download/123` + +This URL fetches the latest `.zip` release from GitHub and increments the download count. + +## Settings Overview + +Navigate to **Projects → Settings** to configure: + +### General Settings + +- **GitHub API Token** – Recommended for authenticated requests (avoids GitHub rate limits). +- **Telemetry** – Toggle to help improve the plugin. + +### Templates Settings + +Enable/disable the following GitHub data in your project views: + +- Version +- Last Updated +- License +- Language +- Downloads +- Stars / Forks / Issues +- GitHub Owner + +### Archive Settings + +Toggle components for the project archive view: + +- Archive Title +- Project Title +- Project Excerpt +- Project Buttons + +## Connect Your GitHub Repo + +To connect a project to GitHub: + +1. Paste the full repo URL into the **GitHub URL** field when editing a Project. +2. Make sure your GitHub repo has a release with a `.zip` asset or a valid `zipball_url`. + +### Optional: Add a GitHub API Token + +To avoid hitting rate limits or improve reliability: + +1. Go to GitHub → **Settings → Developer Settings → Personal Access Tokens**. +2. Generate a token (no scopes required). +3. Paste it into the settings screen under **GitHub API Token**. + +## How to Zip the Plugin for GitHub Releases + +When attaching the plugin to a GitHub release: + +1. Zip **only the contents of the plugin folder**, not the parent folder. +2. Ensure `projects-portfolio.php` and `/includes`, `/admin`, `/templates`, `/assets` are at the root level of the ZIP. +3. Name the ZIP clearly (e.g. `projects-portfolio-1.0.0.zip`). +4. Go to your GitHub repo → **Releases** → **New Release**. +5. Tag the release with the version number (e.g., `1.0.0`). +6. Upload your correctly structured ZIP as a release asset. + +Your users will be redirected to this file when they use the `/download/` endpoint. + +## REST API Endpoints + +### All Projects + +```http +GET /wp-json/projects/v1/projects +``` + +Supports optional query params: + +- `page` +- `per_page` + +### Popular Projects + +```http +GET /wp-json/projects/v1/popular +``` + +Returns the most downloaded projects. + +## Template Integration + +You can override the plugin templates in your theme: + +- `single-projects.php` +- `archive-projects.php` +- `taxonomy-project-type.php` + +Just copy the templates from the plugin's `/templates/` folder into your theme's root and customize. + +## Social Sharing Buttons + +Each project includes social sharing links for: + +- Facebook +- Twitter/X +- LinkedIn +- Reddit +- Pinterest +- WhatsApp +- Email + +## Developer Notes + +- All public-facing code is translation-ready. +- Full support for Full Site Editing (FSE) and Classic themes. +- REST API ready and easily extendable. +- Clean separation of concerns: CPT/taxonomy, settings, metaboxes, API, styling. + +## Support & Contributions + +Have a feature request or bug report? Open an issue on [GitHub](https://github.com/robertdevore/projects-portfolio/issues) or contribute via pull request. + +## License + +Projects for WordPress® is licensed under the [GNU GPL v2+](http://www.gnu.org/licenses/gpl-2.0.txt). + +## Author + +Built and maintained by [Robert DeVore](https://www.robertdevore.com). + +Follow on [Twitter](https://twitter.com/deviorobert) or sponsor development on [GitHub Sponsors](https://github.com/sponsors/robertdevore). diff --git a/admin/admin-settings.php b/admin/admin-settings.php new file mode 100644 index 0000000..66adf7d --- /dev/null +++ b/admin/admin-settings.php @@ -0,0 +1,169 @@ + esc_html__( 'Version', 'projects-wp' ), + 'last_updated' => esc_html__( 'Last Updated', 'projects-wp' ), + 'license' => esc_html__( 'License', 'projects-wp' ), + 'language' => esc_html__( 'Language', 'projects-wp' ), + 'downloads' => esc_html__( 'Downloads', 'projects-wp' ), + 'forks' => esc_html__( 'Forks', 'projects-wp' ), + 'stargazers_count' => esc_html__( 'Stars', 'projects-wp' ), + 'open_issues_count' => esc_html__( 'Issues', 'projects-wp' ), + 'github_owner' => esc_html__( 'GitHub Owner', 'projects-wp' ), + ]; + + // Archives Settings + $archives_settings = [ + 'archive_title' => esc_html__( 'Archive Title', 'projects-wp' ), + 'project_title' => esc_html__( 'Project Title', 'projects-wp' ), + 'project_excerpt' => esc_html__( 'Project Excerpt', 'projects-wp' ), + 'project_buttons' => esc_html__( 'Project Buttons', 'projects-wp' ), + ]; + + ?> +
+

+
+ + +

+ + + + + +
+ + + +
+ +

+ + $label ) : + $value = get_option( "projects_portfolio_templates_$key", '0' ); ?> + + + + + +
+ +
+ +

+ + $label ) : + $value = get_option( "projects_portfolio_archives_$key", '0' ); ?> + + + + + +
+ +
+ + + +
+
+ [ + 'name' => esc_html__( 'Projects', 'projects-wp' ), + 'singular_name' => esc_html__( 'Project', 'projects-wp' ), + 'add_new_item' => esc_html__( 'Add New Project', 'projects-wp' ), + ], + 'public' => true, + 'has_archive' => true, + 'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt' ], + 'rewrite' => [ 'slug' => 'projects' ], + 'show_in_rest' => true, + 'menu_icon' => 'dashicons-format-gallery' + ] ); + + register_taxonomy( 'project-type', 'projects', [ + 'labels' => [ + 'name' => esc_html__( 'Project Types', 'projects-wp' ), + 'singular_name' => esc_html__( 'Project Type', 'projects-wp' ), + ], + 'hierarchical' => true, + 'show_in_rest' => true, + 'show_admin_column' => true, + 'rewrite' => [ + 'slug' => 'project-type', + 'with_front' => false, + ], + ] ); + + if ( ! term_exists( 'plugin', 'project_type' ) ) { + wp_insert_term( esc_html__( 'Plugin', 'projects-wp' ), 'project_type' ); + } + if ( ! term_exists( 'theme', 'project_type' ) ) { + wp_insert_term( esc_html__( 'Theme', 'projects-wp' ), 'project_type' ); + } + if ( ! term_exists( 'pattern', 'project_type' ) ) { + wp_insert_term( esc_html__( 'Pattern', 'projects-wp' ), 'project_type' ); + } +} +add_action( 'init', 'projects_portfolio_register_cpt_and_taxonomy' ); diff --git a/admin/metabox.php b/admin/metabox.php new file mode 100644 index 0000000..9ffc72b --- /dev/null +++ b/admin/metabox.php @@ -0,0 +1,62 @@ +ID, '_projects_portfolio_github_url', true ); + echo ''; + echo ''; +} + +/** + * Saves the GitHub repository URL meta box data for the Projects WP plugin. + * + * @param int $post_id The ID of the post currently being saved. + * + * @since 1.0.0 + * @return void + */ +function projects_portfolio_save_meta_box( $post_id ) { + if ( ! isset( $_POST['projects_portfolio_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['projects_portfolio_meta_box_nonce'], 'projects_portfolio_save_meta_box' ) ) { + return; + } + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { + return; + } + if ( isset( $_POST['projects_portfolio_github_url'] ) ) { + update_post_meta( $post_id, '_projects_portfolio_github_url', esc_url_raw( $_POST['projects_portfolio_github_url'] ) ); + } +} +add_action( 'save_post', 'projects_portfolio_save_meta_box' ); diff --git a/admin/rest-api.php b/admin/rest-api.php new file mode 100644 index 0000000..29d73f7 --- /dev/null +++ b/admin/rest-api.php @@ -0,0 +1,133 @@ + 'projects', + 'posts_per_page' => $request->get_param( 'per_page' ) ?? 10, + 'paged' => $request->get_param( 'page' ) ?? 1, + ]; + + $query = new WP_Query( $args ); + $projects = []; + + if ( $query->have_posts() ) { + while ( $query->have_posts() ) { + $query->the_post(); + + $project_id = get_the_ID(); + $github_url = get_post_meta( $project_id, '_projects_portfolio_github_url', true ); + $github_data = projects_portfolio_get_github_data( $github_url ); + + // Fetch project-type taxonomy terms (names). + $project_types = wp_get_post_terms( $project_id, 'project-type', [ + 'fields' => 'names', + ] ); + + $projects[] = [ + 'id' => $project_id, + 'title' => get_the_title(), + 'excerpt' => get_the_excerpt(), + 'permalink' => get_permalink(), + 'thumbnail' => get_the_post_thumbnail_url( $project_id, 'large' ), + 'download_count' => (int) get_post_meta( $project_id, '_projects_portfolio_download_count', true ), + 'download_url' => esc_url( site_url( '/download/' . $project_id ) ), + 'github_url' => $github_url, + 'github_data' => [ + 'owner' => [ + 'avatar_url' => $github_data['owner']['avatar_url'] ?? '', + 'name' => $github_data['owner']['login'] ?? '', + 'profile' => $github_data['owner']['html_url'] ?? '', + ], + 'last_updated' => ! empty( $github_data['updated_at'] ) + ? date_i18n( get_option( 'date_format' ), strtotime( $github_data['updated_at'] ) ) + : '', + 'language' => $github_data['language'] ?? '', + 'license' => $github_data['license']['name'] ?? 'None', + 'stars' => $github_data['stargazers_count'] ?? 0, + 'forks' => $github_data['forks_count'] ?? 0, + 'issues' => $github_data['open_issues_count'] ?? 0, + ], + 'version' => projects_portfolio_get_version_from_github( $github_url ), + 'project_types' => $project_types, + 'content' => get_the_content(), + ]; + } + wp_reset_postdata(); + } + + $response = [ + 'projects' => $projects, + 'total' => $query->found_posts, + 'pages' => $query->max_num_pages, + ]; + + return rest_ensure_response( $response ); +} + +/** + * Register REST API endpoint for popular projects. + * + * @since 1.0.0 + * @return VolumeVolumeInfoDimensions + */ +function projects_portfolio_register_popular_endpoint() { + register_rest_route( + 'projects/v1', + '/popular', + [ + 'methods' => 'GET', + 'callback' => 'projects_portfolio_get_popular_projects', + 'permission_callback' => '__return_true', + ] + ); +} + +/** + * Callback function for popular projects endpoint. + * + * @since 1.0.0 + * @return void + */ +function projects_portfolio_get_popular_projects( $data ) { + $args = [ + 'post_type' => 'projects', + 'posts_per_page' => $data->get_param( 'per_page' ) ?? 10, + 'meta_key' => '_projects_portfolio_download_count', + 'orderby' => 'meta_value_num', + 'order' => 'DESC', + ]; + + $query = new WP_Query( $args ); + $projects = []; + + if ( $query->have_posts() ) { + while ( $query->have_posts() ) { + $query->the_post(); + $projects[] = [ + 'id' => get_the_ID(), + 'title' => get_the_title(), + 'download_count' => (int) get_post_meta( get_the_ID(), '_projects_portfolio_download_count', true ), + 'download_url' => esc_url( site_url( '/download/' . get_the_ID() ) ), + 'github_url' => get_post_meta( get_the_ID(), '_projects_portfolio_github_url', true ), + 'permalink' => get_permalink(), + ]; + } + } + + wp_reset_postdata(); + return rest_ensure_response( $projects ); +} +add_action( 'rest_api_init', 'projects_portfolio_register_popular_endpoint' ); diff --git a/assets/css/admin-styles.css b/assets/css/admin-styles.css new file mode 100644 index 0000000..3b4b40b --- /dev/null +++ b/assets/css/admin-styles.css @@ -0,0 +1,44 @@ +.toggle-switch { + position: relative; + display: inline-block; + width: 50px; + height: 24px; +} + +.toggle-switch input { + opacity: 0; + width: 0; + height: 0; +} + +.slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + border-radius: 34px; + transition: .4s; +} + +.slider:before { + position: absolute; + content: ""; + height: 18px; + width: 18px; + left: 4px; + bottom: 3px; + background-color: white; + border-radius: 50%; + transition: .4s; +} + +input:checked + .slider { + background-color: #0073aa; +} + +input:checked + .slider:before { + transform: translateX(26px); +} diff --git a/assets/css/style.css b/assets/css/style.css new file mode 100644 index 0000000..1677f8b --- /dev/null +++ b/assets/css/style.css @@ -0,0 +1,285 @@ +.project-social-sharing { + margin-top: 20px; + display: flex; /* Change to flexbox for horizontal alignment */ + flex-direction: row; /* Align items horizontally */ + align-items: center; + gap: 10px; /* Add spacing between icons */ +} + +.project-social-sharing p { + font-weight: bold; + margin-right: 15px; /* Add spacing from text to icons */ +} + +.project-social-sharing a { + display: inline-flex; + align-items: center; + justify-content: center; + width: 36px; + height: 36px; + border: 1px solid #0073aa; + border-radius: 50%; + text-decoration: none; + transition: background-color 0.3s; +} + +.project-social-sharing a:hover { + background-color: #0073aa; + border-color: #005177; +} + +.project-social-sharing svg { + stroke: #0073aa; + width: 20px; + height: 20px; + transition: stroke 0.3s; +} + +.project-social-sharing a:hover svg { + stroke: #ffffff; +} + +.project-single-container { + max-width: 1544px; + margin: 0 auto; + padding: 20px; +} +.project-header .project-banner img { + width: 100%; + height: auto; + border-radius: 6px; +} +.project-main-content { + display: flex; + flex-wrap: wrap; + gap: 20px; + margin-top: 20px; +} + +.project-sidebar { + flex: 1; + max-width: 380px; + padding: 0px; +} + +.project-meta p { + margin-bottom: 12px; +} + +.project-owner { + margin-top: 15px; + background: #e0e0e0; + border-radius: 5px; + padding: 12px; + display: flex; + flex-direction: row; + justify-content: space-evenly; + align-content: center; + align-items: center; + text-align: left; + gap: 12px; +} + +.project-owner img { + display: block; + margin: 0 auto 0; + max-width: 50px; +} + +.project-owner span:last-of-type { + display: flex; + justify-content: space-between; + flex-direction: column; + flex: 1; + align-items: end; +} + +.project-meta-table th { + text-align: left; + padding: 5px 10px; + font-weight: bold; +} + +.project-meta-table td { + padding: 5px 10px; +} + +.project-buttons .project-download-button { + display: block; + background-color: #0073aa; + color: #fff; + text-align: center; + padding: 10px 15px; + border-radius: 4px; + text-decoration: none; +} + +.project-buttons .project-download-button:hover { + background-color: #005f8d; + color: #FFF; +} + +.project-buttons a.button.project-github-button { + display: block; + background-color: #e0e0e0; + color: #333; + text-align: center; + padding: 10px 15px; + margin: 12px 0; + border-radius: 4px; + text-decoration: none; +} + +.project-buttons a.button.project-github-button:hover { + background-color: #c9c9c9; + color: #333; +} + +.project-description { + flex: 2; +} +.project-title { + margin: 0 0 24px 0; +} +.project-extra-info { + margin-top: 30px; +} +.project-extra-info h2 { + font-size: 22px; + margin-bottom: 15px; +} +.project-extra-info ul { + margin: 0; + padding: 0; + list-style: disc inside; +} + +.project-meta-table { + width: 100%; + border-collapse: collapse; + margin-top: 20px; + font-size: 14px; +} + +.project-meta-table th, +.project-meta-table td { + padding: 10px; + border: 1px solid #ddd; +} + +.project-meta-table th { + text-align: left; + background-color: #f9f9f9; + font-weight: bold; + width: 30%; +} + +.project-meta-table td { + width: 70%; +} + +.project-archive { + width: 100%; + max-width: 1200px; + margin: 24px auto; +} + +.project-archive h1 { + text-align: center; +} + +.project-archive .projects-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); + gap: 20px; + margin-top: 20px; + width: 100%; +} +.project-archive .project-item { + border: 1px solid #ddd; + padding: 15px; + background-color: #fff; + border-radius: 6px; + overflow: hidden; +} +.project-archive .project-item img { + width: 100%; + height: auto; + display: block; + border-radius: 4px; + margin-bottom: 15px; +} +.project-archive .project-title { + font-size: 1.2rem; + font-weight: 600; + margin: 10px 0; + text-align: center; +} +.project-archive .project-item p { + text-align: center; + font-size: 1rem; + line-height: 1.2; +} +.project-archive .project-downloads { + font-size: 0.8rem; + color: #666; + margin-bottom: 15px; + text-align: center; +} +.project-archive .project-buttons { + display: flex; + justify-content: center; + gap: 10px; +} +.project-archive .project-buttons .button { + padding: 10px 15px; + text-decoration: none; + color: #fff; + border-radius: 4px; + text-align: center; + font-size: 0.8rem; + font-weight: bold; +} +.project-archive .project-buttons .project-download-button { + background-color: #0073aa; +} +.project-archive .project-buttons .project-download-button:hover { + background-color: #005f8d; +} +.project-archive .project-buttons .project-view-button { + background-color: #e0e0e0; + color: #333; +} +.project-archive .project-buttons .project-view-button:hover { + background-color: #c9c9c9; + color: #000; +} + +.project-archive .pagination { + text-align: center; + margin-top: 20px; +} + +.project-archive .pagination ul { + display: inline-flex; + list-style: none; + padding: 0; +} + +.project-archive .pagination li { + margin: 0 5px; +} + +.project-archive .pagination a, .pagination span { + display: block; + padding: 8px 12px; + text-decoration: none; + color: #0073aa; + border: 1px solid #0073aa; + border-radius: 4px; +} + +.project-archive .pagination .current { + background: #0073aa; + color: #fff; +} diff --git a/assets/js/buttons.js b/assets/js/buttons.js new file mode 100644 index 0000000..3f45fa4 --- /dev/null +++ b/assets/js/buttons.js @@ -0,0 +1,6 @@ +/*! + * github-buttons v2.29.1 + * (c) 2024 なつき + * @license BSD-2-Clause + */ +!function(){"use strict";var e=window.document,o=e.location,t=window.Math,r=window.HTMLElement,a=window.XMLHttpRequest,n="github-button",i="https://buttons.github.io/buttons.html",c="github.com",l="https://api."+c,d=a&&"prototype"in a&&"withCredentials"in a.prototype,s=d&&r&&"attachShadow"in r.prototype&&!("prototype"in r.prototype.attachShadow),u=function(e,o){for(var t=0,r=e.length;t'}}},download:{heights:{16:{width:16,path:''}}},eye:{heights:{16:{width:16,path:''}}},heart:{heights:{16:{width:16,path:''}}},"issue-opened":{heights:{16:{width:16,path:''}}},"mark-github":{heights:{16:{width:16,path:''}}},package:{heights:{16:{width:16,path:''}}},play:{heights:{16:{width:16,path:''}}},"repo-forked":{heights:{16:{width:16,path:''}}},"repo-template":{heights:{16:{width:16,path:''}}},star:{heights:{16:{width:16,path:''}}}},Z=function(e,o){e=b(e).replace(/^octicon-/,""),p(M,e)||(e="mark-github");var t=o>=24&&24 in M[e].heights?24:16,r=M[e].heights[t];return'"},A={},F=function(e,o){var t=A[e]||(A[e]=[]);if(!(t.push(o)>1)){var r=g((function(){for(delete A[e];o=t.shift();)o.apply(null,arguments)}));if(d){var n=new a;m(n,"abort",r),m(n,"error",r),m(n,"load",(function(){var e;try{e=JSON.parse(this.responseText)}catch(e){return void r(e)}r(200!==this.status,e)})),n.open("GET",e),n.send()}else{var i=this||window;i._=function(e){i._=null,r(200!==e.meta.status,e.data)};var c=f(i.document)("script",{async:!0,src:e+(-1!==e.indexOf("?")?"&":"?")+"callback=_"}),l=function(){i._&&i._({meta:{}})};m(c,"load",l),m(c,"error",l),x(c,/de|m/,l),i.document.getElementsByTagName("head")[0].appendChild(c)}}},E=function(e,o,t){var r=f(e.ownerDocument),a=e.appendChild(r("style",{type:"text/css"})),n="body{margin:0}a{text-decoration:none;outline:0}.widget{display:inline-block;overflow:hidden;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;font-size:0;line-height:0;white-space:nowrap}.btn,.social-count{position:relative;display:inline-block;display:inline-flex;height:14px;padding:2px 5px;font-size:11px;font-weight:600;line-height:14px;vertical-align:bottom;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-repeat:repeat-x;background-position:-1px -1px;background-size:110% 110%;border:1px solid}.btn{border-radius:.25em}.btn:not(:last-child){border-radius:.25em 0 0 .25em}.social-count{border-left:0;border-radius:0 .25em .25em 0}.widget-lg .btn,.widget-lg .social-count{height:16px;padding:5px 10px;font-size:12px;line-height:16px}.octicon{display:inline-block;vertical-align:text-top;fill:currentColor;overflow:visible}"+function(e){if(null==e)return y.light;if(p(y,e))return y[e];var o=v(e,";",":",(function(e){return e.replace(/^[ \t\n\f\r]+|[ \t\n\f\r]+$/g,"")}));return y[p(y,o["no-preference"])?o["no-preference"]:"light"]+C("light",o.light)+C("dark",o.dark)}(o["data-color-scheme"]);a.styleSheet?a.styleSheet.cssText=n:a.appendChild(e.ownerDocument.createTextNode(n));var i="large"===b(o["data-size"]),d=r("a",{className:"btn",href:o.href,rel:"noopener",target:"_blank",title:o.title||void 0,"aria-label":o["aria-label"]||void 0,innerHTML:Z(o["data-icon"],i?16:14)+" "},[r("span",{},[o["data-text"]||""])]),s=e.appendChild(r("div",{className:"widget"+(i?" widget-lg":"")},[d])),u=d.hostname.replace(/\.$/,"");if(("."+u).substring(u.length-10)!=="."+c)return d.removeAttribute("href"),void t(s);var h=(" /"+d.pathname).split(/\/+/);if(((u===c||u==="gist."+c)&&"archive"===h[3]||u===c&&"releases"===h[3]&&("download"===h[4]||"latest"===h[4]&&"download"===h[5])||u==="codeload."+c)&&(d.target="_top"),"true"===b(o["data-show-count"])&&u===c&&"marketplace"!==h[1]&&"sponsors"!==h[1]&&"orgs"!==h[1]&&"users"!==h[1]&&"-"!==h[1]){var g,m;if(!h[2]&&h[1])m="followers",g="?tab=followers";else if(!h[3]&&h[2])m="stargazers_count",g="/stargazers";else if(h[4]||"subscription"!==h[3])if(h[4]||"fork"!==h[3]){if("issues"!==h[3])return void t(s);m="open_issues_count",g="/issues"}else m="forks_count",g="/forks";else m="subscribers_count",g="/watchers";var w=h[2]?"/repos/"+h[1]+"/"+h[2]:"/users/"+h[1];F.call(this,l+w,(function(e,o){if(!e){var a=o[m];s.appendChild(r("a",{className:"social-count",href:o.html_url+g,rel:"noopener",target:"_blank","aria-label":a+" "+m.replace(/_count$/,"").replace("_"," ").slice(0,a<2?-1:void 0)+" on GitHub"},[(""+a).replace(/\B(?=(\d{3})+(?!\d))/g,",")]))}t(s)}))}else t(s)},L=window.devicePixelRatio||1,_=function(e){return(L>1?t.ceil(t.round(e*L)/L*2)/2:t.ceil(e))||0},G=function(e,o){e.style.width=o[0]+"px",e.style.height=o[1]+"px"},T=function(o,r){if(null!=o&&null!=r)if(o.getAttribute&&(o=function(e){var o={href:e.href,title:e.title,"aria-label":e.getAttribute("aria-label")};return u(["icon","color-scheme","text","size","show-count"],(function(t){var r="data-"+t;o[r]=e.getAttribute(r)})),null==o["data-text"]&&(o["data-text"]=e.textContent||e.innerText),o}(o)),s){var a=h("span");E(a.attachShadow({mode:"closed"}),o,(function(){r(a)}))}else{var n=h("iframe",{src:"javascript:0",title:o.title||void 0,allowtransparency:!0,scrolling:"no",frameBorder:0});G(n,[0,0]),n.style.border="none",n.style.colorScheme="light";var c=function(){var a,l=n.contentWindow;try{a=l.document.body}catch(o){return void e.body.appendChild(n.parentNode.removeChild(n))}w(n,"load",c),E.call(l,a,o,(function(e){var a=function(e){var o=e.offsetWidth,r=e.offsetHeight;if(e.getBoundingClientRect){var a=e.getBoundingClientRect();o=t.max(o,_(a.width)),r=t.max(r,_(a.height))}return[o,r]}(e);n.parentNode.removeChild(n),k(n,"load",(function(){G(n,a)})),n.src=i+"#"+(n.name=function(e,o,t,r){null==o&&(o="&"),null==t&&(t="="),null==r&&(r=window.encodeURIComponent);var a=[];for(var n in e){var i=e[n];null!=i&&a.push(r(n)+t+r(i))}return a.join(o)}(o)),r(n)}))};m(n,"load",c),e.body.appendChild(n)}};o.protocol+"//"+o.host+o.pathname===i?E(e.body,v(window.name||o.hash.replace(/^#/,"")),(function(){})):function(o){if("complete"===e.readyState||"loading"!==e.readyState&&!e.documentElement.doScroll)setTimeout(o);else if(e.addEventListener){var t=g(o);k(e,"DOMContentLoaded",t),k(window,"load",t)}else x(e,/m/,o)}((function(){var o,t=e.querySelectorAll?e.querySelectorAll("a."+n):(o=[],u(e.getElementsByTagName("a"),(function(e){-1!==(" "+e.className+" ").replace(/[ \t\n\f\r]+/g," ").indexOf(" "+n+" ")&&o.push(e)})),o);u(t,(function(e){T(e,(function(o){e.parentNode.replaceChild(o,e)}))}))}))}(); \ No newline at end of file diff --git a/includes/helper-functions.php b/includes/helper-functions.php new file mode 100644 index 0000000..819db86 --- /dev/null +++ b/includes/helper-functions.php @@ -0,0 +1,203 @@ + get_option( 'projects_portfolio_github_api_token', '' ), + 'share_telemetry' => get_option( 'projects_portfolio_share_telemetry', '0' ), + 'templates' => [ + 'version' => get_option( 'projects_portfolio_templates_version', '0' ), + 'last_updated' => get_option( 'projects_portfolio_templates_last_updated', '0' ), + 'license' => get_option( 'projects_portfolio_templates_license', '0' ), + 'language' => get_option( 'projects_portfolio_templates_language', '0' ), + 'downloads' => get_option( 'projects_portfolio_templates_downloads', '0' ), + 'forks' => get_option( 'projects_portfolio_templates_forks', '0' ), + 'stargazers_count' => get_option( 'projects_portfolio_templates_stargazers_count', '0' ), + 'open_issues_count' => get_option( 'projects_portfolio_templates_open_issues_count', '0' ), + 'github_owner' => get_option( 'projects_portfolio_templates_github_owner', '0' ), + ], + 'archives' => [ + 'archive_title' => get_option( 'projects_portfolio_archives_archive_title', '0' ), + 'project_title' => get_option( 'projects_portfolio_archives_project_title', '0' ), + 'project_excerpt' => get_option( 'projects_portfolio_archives_project_excerpt', '0' ), + 'project_buttons' => get_option( 'projects_portfolio_archives_project_buttons', '0' ), + ] + ]; + } + + return $settings; +} + +/** + * GitHub API call for owner data + * + * @param mixed $owner_name + * + * @since 1.0.0 + * @return mixed + */ +function projects_portfolio_github_owner( $owner_name = NULL ) { + if ( ! $owner_name ) { return; } + + $owner = 'https://api.github.com/users/' . $owner_name; + + // Set up the context with a User-Agent header (GitHub requires this). + $options = [ + 'http' => [ + 'method' => 'GET', + 'header' => "User-Agent: WORDPRESS\r\n" + ] + ]; + $context = stream_context_create( $options ); + + // Fetch the API response. + $response = file_get_contents( $owner, false, $context ); + + if ( $response === false ) { + die( 'Error fetching data from GitHub API.' ); + } + + // Decode the JSON response to an associative array. + $owner = json_decode( $response, true ); + + if ( json_last_error() !== JSON_ERROR_NONE ) { + die( 'Error decoding JSON data: ' . json_last_error_msg() ); + } + + return $owner; +} + +/** + * Fetch GitHub latest release URL. + * + * @since 1.0.0 + * @return mixed + */ +function projects_portfolio_get_github_release_url( $github_url ) { + $api_token = get_option( 'projects_portfolio_github_api_token', '' ); + $api_url = str_replace( 'https://github.com/', 'https://api.github.com/repos/', rtrim( $github_url, '/' ) ) . '/releases/latest'; + + $headers = [ 'Accept' => 'application/vnd.github.v3+json' ]; + if ( $api_token ) { + $headers['Authorization'] = 'token ' . $api_token; + } + + $response = wp_remote_get( $api_url, [ 'headers' => $headers ] ); + + if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 ) { + return false; + } + + $data = json_decode( wp_remote_retrieve_body( $response ), true ); + + // Check for assets and return the URL of a custom asset if available. + if ( ! empty( $data['assets'] ) && is_array( $data['assets'] ) ) { + foreach ( $data['assets'] as $asset ) { + // For example, check if the asset is a zip file and maybe even match a specific name. + if ( isset( $asset['name'] ) && pathinfo( $asset['name'], PATHINFO_EXTENSION ) === 'zip' ) { + return $asset['browser_download_url']; + } + } + } + + // Fallback to the auto-generated zipball_url. + return $data['zipball_url'] ?? false; +} + +/** + * Retrieves GitHub repository data from the GitHub API with optional token authentication and caching. + * + * @param string $github_url The full URL of the GitHub repository. + * + * @since 1.0.0 + * @return array|null Associative array of GitHub repo data on success, or null on failure. + */ +function projects_portfolio_get_github_data( $github_url ) { + if ( empty( $github_url ) ) { + error_log( 'GitHub URL is empty.' ); + return null; + } + + $api_url = str_replace( 'https://github.com/', 'https://api.github.com/repos/', rtrim( $github_url, '/' ) ); + $api_token = get_option( 'projects_portfolio_github_api_token', '' ); + + $headers = [ 'Accept' => 'application/vnd.github.v3+json' ]; + if ( ! empty( $api_token ) ) { + $headers['Authorization'] = 'token ' . $api_token; + } else { + error_log( 'GitHub API token is missing. Using unauthenticated requests.' ); + } + + $cache_key = 'projects_portfolio_github_data_' . md5( $api_url ); + $cached_data = get_transient( $cache_key ); + if ( $cached_data ) { + return $cached_data; + } + + $response = wp_remote_get( $api_url, [ 'headers' => $headers ] ); + + if ( is_wp_error( $response ) ) { + error_log( 'GitHub API error: ' . $response->get_error_message() ); + return null; + } + + $response_code = wp_remote_retrieve_response_code( $response ); + + if ( $response_code === 403 ) { + $rate_limit_remaining = wp_remote_retrieve_header( $response, 'x-ratelimit-remaining' ); + $rate_limit_reset = wp_remote_retrieve_header( $response, 'x-ratelimit-reset' ); + error_log( 'GitHub API 403: Rate limit exceeded. Remaining: ' . $rate_limit_remaining . ' Reset at: ' . date( 'Y-m-d H:i:s', $rate_limit_reset ) ); + return null; + } elseif ( $response_code !== 200 ) { + error_log( 'GitHub API error: Received status ' . $response_code ); + return null; + } + + $data = json_decode( wp_remote_retrieve_body( $response ), true ); + + if ( empty( $data ) || ! is_array( $data ) ) { + error_log( 'GitHub API error: Invalid data received.' ); + return null; + } + + set_transient( $cache_key, $data, HOUR_IN_SECONDS ); + return $data; +} + +/** + * Fetch the version number from the GitHub API. + * + * @param string $github_url The GitHub repository URL. + * + * @since 1.0.0 + * @return string The version number or 'Unknown'. + */ +function projects_portfolio_get_version_from_github( $github_url ) { + if ( empty( $github_url ) ) { + return 'Unknown'; + } + + $api_url = str_replace( 'https://github.com/', 'https://api.github.com/repos/', rtrim( $github_url, '/' ) ) . '/releases/latest'; + $response = wp_remote_get( $api_url ); + + if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 ) { + return 'Unknown'; + } + + $data = json_decode( wp_remote_retrieve_body( $response ), true ); + + return $data['tag_name'] ?? 'Unknown'; +} diff --git a/includes/plugin-update-checker/Puc/v5/PucFactory.php b/includes/plugin-update-checker/Puc/v5/PucFactory.php new file mode 100644 index 0000000..0bc62ce --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5/PucFactory.php @@ -0,0 +1,10 @@ +rootDir = dirname(__FILE__) . '/'; + + $namespaceWithSlash = __NAMESPACE__ . '\\'; + $this->prefix = $namespaceWithSlash; + + $this->libraryDir = $this->rootDir . '../..'; + if ( !self::isPhar() ) { + $this->libraryDir = realpath($this->libraryDir); + } + $this->libraryDir = $this->libraryDir . '/'; + + //Usually, dependencies like Parsedown are in the global namespace, + //but if someone adds a custom namespace to the entire library, they + //will be in the same namespace as this class. + $isCustomNamespace = ( + substr($namespaceWithSlash, 0, strlen(self::DEFAULT_NS_PREFIX)) !== self::DEFAULT_NS_PREFIX + ); + $libraryPrefix = $isCustomNamespace ? $namespaceWithSlash : ''; + + $this->staticMap = array( + $libraryPrefix . 'PucReadmeParser' => 'vendor/PucReadmeParser.php', + $libraryPrefix . 'Parsedown' => 'vendor/Parsedown.php', + ); + + //Add the generic, major-version-only factory class to the static map. + $versionSeparatorPos = strrpos(__NAMESPACE__, '\\v'); + if ( $versionSeparatorPos !== false ) { + $versionSegment = substr(__NAMESPACE__, $versionSeparatorPos + 1); + $pointPos = strpos($versionSegment, 'p'); + if ( ($pointPos !== false) && ($pointPos > 1) ) { + $majorVersionSegment = substr($versionSegment, 0, $pointPos); + $majorVersionNs = __NAMESPACE__ . '\\' . $majorVersionSegment; + $this->staticMap[$majorVersionNs . '\\PucFactory'] = + 'Puc/' . $majorVersionSegment . '/Factory.php'; + } + } + + spl_autoload_register(array($this, 'autoload')); + } + + /** + * Determine if this file is running as part of a Phar archive. + * + * @return bool + */ + private static function isPhar() { + //Check if the current file path starts with "phar://". + static $pharProtocol = 'phar://'; + return (substr(__FILE__, 0, strlen($pharProtocol)) === $pharProtocol); + } + + public function autoload($className) { + if ( isset($this->staticMap[$className]) && file_exists($this->libraryDir . $this->staticMap[$className]) ) { + include($this->libraryDir . $this->staticMap[$className]); + return; + } + + if ( strpos($className, $this->prefix) === 0 ) { + $path = substr($className, strlen($this->prefix)); + $path = str_replace(array('_', '\\'), '/', $path); + $path = $this->rootDir . $path . '.php'; + + if ( file_exists($path) ) { + include $path; + } + } + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/DebugBar/Extension.php b/includes/plugin-update-checker/Puc/v5p4/DebugBar/Extension.php new file mode 100644 index 0000000..0adb68c --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/DebugBar/Extension.php @@ -0,0 +1,199 @@ +updateChecker = $updateChecker; + if ( isset($panelClass) ) { + $this->panelClass = $panelClass; + } + + if ( (strpos($this->panelClass, '\\') === false) ) { + $this->panelClass = __NAMESPACE__ . '\\' . $this->panelClass; + } + + add_filter('debug_bar_panels', array($this, 'addDebugBarPanel')); + add_action('debug_bar_enqueue_scripts', array($this, 'enqueuePanelDependencies')); + + add_action('wp_ajax_puc_v5_debug_check_now', array($this, 'ajaxCheckNow')); + } + + /** + * Register the PUC Debug Bar panel. + * + * @param array $panels + * @return array + */ + public function addDebugBarPanel($panels) { + if ( $this->updateChecker->userCanInstallUpdates() ) { + $panels[] = new $this->panelClass($this->updateChecker); + } + return $panels; + } + + /** + * Enqueue our Debug Bar scripts and styles. + */ + public function enqueuePanelDependencies() { + wp_enqueue_style( + 'puc-debug-bar-style-v5', + $this->getLibraryUrl("/css/puc-debug-bar.css"), + array('debug-bar'), + '20221008' + ); + + wp_enqueue_script( + 'puc-debug-bar-js-v5', + $this->getLibraryUrl("/js/debug-bar.js"), + array('jquery'), + '20221008' + ); + } + + /** + * Run an update check and output the result. Useful for making sure that + * the update checking process works as expected. + */ + public function ajaxCheckNow() { + //phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce is checked in preAjaxRequest(). + if ( !isset($_POST['uid']) || ($_POST['uid'] !== $this->updateChecker->getUniqueName('uid')) ) { + return; + } + $this->preAjaxRequest(); + $update = $this->updateChecker->checkForUpdates(); + if ( $update !== null ) { + echo "An update is available:"; + //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r -- For debugging output. + echo '
', esc_html(print_r($update, true)), '
'; + } else { + echo 'No updates found.'; + } + + $errors = $this->updateChecker->getLastRequestApiErrors(); + if ( !empty($errors) ) { + printf('

The update checker encountered %d API error%s.

', count($errors), (count($errors) > 1) ? 's' : ''); + + foreach (array_values($errors) as $num => $item) { + $wpError = $item['error']; + /** @var \WP_Error $wpError */ + printf('

%d) %s

', intval($num + 1), esc_html($wpError->get_error_message())); + + echo '
'; + printf('
Error code:
%s
', esc_html($wpError->get_error_code())); + + if ( isset($item['url']) ) { + printf('
Requested URL:
%s
', esc_html($item['url'])); + } + + if ( isset($item['httpResponse']) ) { + if ( is_wp_error($item['httpResponse']) ) { + $httpError = $item['httpResponse']; + /** @var \WP_Error $httpError */ + printf( + '
WordPress HTTP API error:
%s (%s)
', + esc_html($httpError->get_error_message()), + esc_html($httpError->get_error_code()) + ); + } else { + //Status code. + printf( + '
HTTP status:
%d %s
', + esc_html(wp_remote_retrieve_response_code($item['httpResponse'])), + esc_html(wp_remote_retrieve_response_message($item['httpResponse'])) + ); + + //Headers. + echo '
Response headers:
';
+							foreach (wp_remote_retrieve_headers($item['httpResponse']) as $name => $value) {
+								printf("%s: %s\n", esc_html($name), esc_html($value));
+							}
+							echo '
'; + + //Body. + $body = wp_remote_retrieve_body($item['httpResponse']); + if ( $body === '' ) { + $body = '(Empty response.)'; + } else if ( strlen($body) > self::RESPONSE_BODY_LENGTH_LIMIT ) { + $length = strlen($body); + $body = substr($body, 0, self::RESPONSE_BODY_LENGTH_LIMIT) + . sprintf("\n(Long string truncated. Total length: %d bytes.)", $length); + } + + printf('
Response body:
%s
', esc_html($body)); + } + } + echo '
'; + } + } + + exit; + } + + /** + * Check access permissions and enable error display (for debugging). + */ + protected function preAjaxRequest() { + if ( !$this->updateChecker->userCanInstallUpdates() ) { + die('Access denied'); + } + check_ajax_referer('puc-ajax'); + + //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_error_reporting -- Part of a debugging feature. + error_reporting(E_ALL); + //phpcs:ignore WordPress.PHP.IniSet.display_errors_Blacklisted + @ini_set('display_errors', 'On'); + } + + /** + * Remove hooks that were added by this extension. + */ + public function removeHooks() { + remove_filter('debug_bar_panels', array($this, 'addDebugBarPanel')); + remove_action('debug_bar_enqueue_scripts', array($this, 'enqueuePanelDependencies')); + remove_action('wp_ajax_puc_v5_debug_check_now', array($this, 'ajaxCheckNow')); + } + + /** + * @param string $filePath + * @return string + */ + private function getLibraryUrl($filePath) { + $absolutePath = realpath(dirname(__FILE__) . '/../../../' . ltrim($filePath, '/')); + + //Where is the library located inside the WordPress directory structure? + $absolutePath = PucFactory::normalizePath($absolutePath); + + $pluginDir = PucFactory::normalizePath(WP_PLUGIN_DIR); + $muPluginDir = PucFactory::normalizePath(WPMU_PLUGIN_DIR); + $themeDir = PucFactory::normalizePath(get_theme_root()); + + if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) { + //It's part of a plugin. + return plugins_url(basename($absolutePath), $absolutePath); + } else if ( strpos($absolutePath, $themeDir) === 0 ) { + //It's part of a theme. + $relativePath = substr($absolutePath, strlen($themeDir) + 1); + $template = substr($relativePath, 0, strpos($relativePath, '/')); + $baseUrl = get_theme_root_uri($template); + + if ( !empty($baseUrl) && $relativePath ) { + return $baseUrl . '/' . $relativePath; + } + } + + return ''; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/DebugBar/Panel.php b/includes/plugin-update-checker/Puc/v5p4/DebugBar/Panel.php new file mode 100644 index 0000000..b846277 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/DebugBar/Panel.php @@ -0,0 +1,178 @@ +'; + + public function __construct($updateChecker) { + $this->updateChecker = $updateChecker; + $title = sprintf( + 'PUC (%s)', + esc_attr($this->updateChecker->getUniqueName('uid')), + $this->updateChecker->slug + ); + parent::__construct($title); + } + + public function render() { + printf( + '
', + esc_attr($this->updateChecker->getUniqueName('debug-bar-panel')), + esc_attr($this->updateChecker->slug), + esc_attr($this->updateChecker->getUniqueName('uid')), + esc_attr(wp_create_nonce('puc-ajax')) + ); + + $this->displayConfiguration(); + $this->displayStatus(); + $this->displayCurrentUpdate(); + + echo '
'; + } + + private function displayConfiguration() { + echo '

Configuration

'; + echo ''; + $this->displayConfigHeader(); + $this->row('Slug', htmlentities($this->updateChecker->slug)); + $this->row('DB option', htmlentities($this->updateChecker->optionName)); + + $requestInfoButton = $this->getMetadataButton(); + $this->row('Metadata URL', htmlentities($this->updateChecker->metadataUrl) . ' ' . $requestInfoButton . $this->responseBox); + + $scheduler = $this->updateChecker->scheduler; + if ( $scheduler->checkPeriod > 0 ) { + $this->row('Automatic checks', 'Every ' . $scheduler->checkPeriod . ' hours'); + } else { + $this->row('Automatic checks', 'Disabled'); + } + + if ( isset($scheduler->throttleRedundantChecks) ) { + if ( $scheduler->throttleRedundantChecks && ($scheduler->checkPeriod > 0) ) { + $this->row( + 'Throttling', + sprintf( + 'Enabled. If an update is already available, check for updates every %1$d hours instead of every %2$d hours.', + $scheduler->throttledCheckPeriod, + $scheduler->checkPeriod + ) + ); + } else { + $this->row('Throttling', 'Disabled'); + } + } + + $this->updateChecker->onDisplayConfiguration($this); + + echo '
'; + } + + protected function displayConfigHeader() { + //Do nothing. This should be implemented in subclasses. + } + + protected function getMetadataButton() { + return ''; + } + + private function displayStatus() { + echo '

Status

'; + echo ''; + $state = $this->updateChecker->getUpdateState(); + $checkNowButton = ''; + if ( function_exists('get_submit_button') ) { + $checkNowButton = get_submit_button( + 'Check Now', + 'secondary', + 'puc-check-now-button', + false, + array('id' => $this->updateChecker->getUniqueName('check-now-button')) + ); + } + + if ( $state->getLastCheck() > 0 ) { + $this->row('Last check', $this->formatTimeWithDelta($state->getLastCheck()) . ' ' . $checkNowButton . $this->responseBox); + } else { + $this->row('Last check', 'Never'); + } + + $nextCheck = wp_next_scheduled($this->updateChecker->scheduler->getCronHookName()); + $this->row('Next automatic check', $this->formatTimeWithDelta($nextCheck)); + + if ( $state->getCheckedVersion() !== '' ) { + $this->row('Checked version', htmlentities($state->getCheckedVersion())); + $this->row('Cached update', $state->getUpdate()); + } + $this->row('Update checker class', htmlentities(get_class($this->updateChecker))); + echo '
'; + } + + private function displayCurrentUpdate() { + $update = $this->updateChecker->getUpdate(); + if ( $update !== null ) { + echo '

An Update Is Available

'; + echo ''; + $fields = $this->getUpdateFields(); + foreach($fields as $field) { + if ( property_exists($update, $field) ) { + $this->row( + ucwords(str_replace('_', ' ', $field)), + isset($update->$field) ? htmlentities($update->$field) : null + ); + } + } + echo '
'; + } else { + echo '

No updates currently available

'; + } + } + + protected function getUpdateFields() { + return array('version', 'download_url', 'slug',); + } + + private function formatTimeWithDelta($unixTime) { + if ( empty($unixTime) ) { + return 'Never'; + } + + $delta = time() - $unixTime; + $result = human_time_diff(time(), $unixTime); + if ( $delta < 0 ) { + $result = 'after ' . $result; + } else { + $result = $result . ' ago'; + } + $result .= ' (' . $this->formatTimestamp($unixTime) . ')'; + return $result; + } + + private function formatTimestamp($unixTime) { + return gmdate('Y-m-d H:i:s', $unixTime + (get_option('gmt_offset') * 3600)); + } + + public function row($name, $value) { + if ( is_object($value) || is_array($value) ) { + //This is specifically for debugging, so print_r() is fine. + //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r + $value = '
' . htmlentities(print_r($value, true)) . '
'; + } else if ($value === null) { + $value = 'null'; + } + printf( + '%1$s %2$s', + esc_html($name), + //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped above. + $value + ); + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/DebugBar/PluginExtension.php b/includes/plugin-update-checker/Puc/v5p4/DebugBar/PluginExtension.php new file mode 100644 index 0000000..b30f3ee --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/DebugBar/PluginExtension.php @@ -0,0 +1,40 @@ +updateChecker->getUniqueName('uid')) ) { + return; + } + $this->preAjaxRequest(); + $info = $this->updateChecker->requestInfo(); + if ( $info !== null ) { + echo 'Successfully retrieved plugin info from the metadata URL:'; + //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r -- For debugging output. + echo '
', esc_html(print_r($info, true)), '
'; + } else { + echo 'Failed to retrieve plugin info from the metadata URL.'; + } + exit; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/DebugBar/PluginPanel.php b/includes/plugin-update-checker/Puc/v5p4/DebugBar/PluginPanel.php new file mode 100644 index 0000000..4c1d230 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/DebugBar/PluginPanel.php @@ -0,0 +1,41 @@ +row('Plugin file', htmlentities($this->updateChecker->pluginFile)); + parent::displayConfigHeader(); + } + + protected function getMetadataButton() { + $requestInfoButton = ''; + if ( function_exists('get_submit_button') ) { + $requestInfoButton = get_submit_button( + 'Request Info', + 'secondary', + 'puc-request-info-button', + false, + array('id' => $this->updateChecker->getUniqueName('request-info-button')) + ); + } + return $requestInfoButton; + } + + protected function getUpdateFields() { + return array_merge( + parent::getUpdateFields(), + array('homepage', 'upgrade_notice', 'tested',) + ); + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/DebugBar/ThemePanel.php b/includes/plugin-update-checker/Puc/v5p4/DebugBar/ThemePanel.php new file mode 100644 index 0000000..7b9d99a --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/DebugBar/ThemePanel.php @@ -0,0 +1,25 @@ +row('Theme directory', htmlentities($this->updateChecker->directoryName)); + parent::displayConfigHeader(); + } + + protected function getUpdateFields() { + return array_merge(parent::getUpdateFields(), array('details_url')); + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/InstalledPackage.php b/includes/plugin-update-checker/Puc/v5p4/InstalledPackage.php new file mode 100644 index 0000000..341e7a3 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/InstalledPackage.php @@ -0,0 +1,105 @@ +updateChecker = $updateChecker; + } + + /** + * Get the currently installed version of the plugin or theme. + * + * @return string|null Version number. + */ + abstract public function getInstalledVersion(); + + /** + * Get the full path of the plugin or theme directory (without a trailing slash). + * + * @return string + */ + abstract public function getAbsoluteDirectoryPath(); + + /** + * Check whether a regular file exists in the package's directory. + * + * @param string $relativeFileName File name relative to the package directory. + * @return bool + */ + public function fileExists($relativeFileName) { + return is_file( + $this->getAbsoluteDirectoryPath() + . DIRECTORY_SEPARATOR + . ltrim($relativeFileName, '/\\') + ); + } + + /* ------------------------------------------------------------------- + * File header parsing + * ------------------------------------------------------------------- + */ + + /** + * Parse plugin or theme metadata from the header comment. + * + * This is basically a simplified version of the get_file_data() function from /wp-includes/functions.php. + * It's intended as a utility for subclasses that detect updates by parsing files in a VCS. + * + * @param string|null $content File contents. + * @return string[] + */ + public function getFileHeader($content) { + $content = (string)$content; + + //WordPress only looks at the first 8 KiB of the file, so we do the same. + $content = substr($content, 0, 8192); + //Normalize line endings. + $content = str_replace("\r", "\n", $content); + + $headers = $this->getHeaderNames(); + $results = array(); + foreach ($headers as $field => $name) { + $success = preg_match('/^[ \t\/*#@]*' . preg_quote($name, '/') . ':(.*)$/mi', $content, $matches); + + if ( ($success === 1) && $matches[1] ) { + $value = $matches[1]; + if ( function_exists('_cleanup_header_comment') ) { + $value = _cleanup_header_comment($value); + } + $results[$field] = $value; + } else { + $results[$field] = ''; + } + } + + return $results; + } + + /** + * @return array Format: ['HeaderKey' => 'Header Name'] + */ + abstract protected function getHeaderNames(); + + /** + * Get the value of a specific plugin or theme header. + * + * @param string $headerName + * @return string Either the value of the header, or an empty string if the header doesn't exist. + */ + abstract public function getHeaderValue($headerName); + + } +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Metadata.php b/includes/plugin-update-checker/Puc/v5p4/Metadata.php new file mode 100644 index 0000000..2d93d8e --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Metadata.php @@ -0,0 +1,162 @@ + + */ + protected $extraProperties = array(); + + /** + * Create an instance of this class from a JSON document. + * + * @abstract + * @param string $json + * @return self + */ + public static function fromJson($json) { + throw new LogicException('The ' . __METHOD__ . ' method must be implemented by subclasses'); + } + + /** + * @param string $json + * @param self $target + * @return bool + */ + protected static function createFromJson($json, $target) { + /** @var \StdClass $apiResponse */ + $apiResponse = json_decode($json); + if ( empty($apiResponse) || !is_object($apiResponse) ){ + $errorMessage = "Failed to parse update metadata. Try validating your .json file with https://jsonlint.com/"; + do_action('puc_api_error', new WP_Error('puc-invalid-json', $errorMessage)); + //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- For plugin developers. + trigger_error(esc_html($errorMessage), E_USER_NOTICE); + return false; + } + + $valid = $target->validateMetadata($apiResponse); + if ( is_wp_error($valid) ){ + do_action('puc_api_error', $valid); + //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- For plugin developers. + trigger_error(esc_html($valid->get_error_message()), E_USER_NOTICE); + return false; + } + + foreach(get_object_vars($apiResponse) as $key => $value){ + $target->$key = $value; + } + + return true; + } + + /** + * No validation by default! Subclasses should check that the required fields are present. + * + * @param \StdClass $apiResponse + * @return bool|\WP_Error + */ + protected function validateMetadata($apiResponse) { + return true; + } + + /** + * Create a new instance by copying the necessary fields from another object. + * + * @abstract + * @param \StdClass|self $object The source object. + * @return self The new copy. + */ + public static function fromObject($object) { + throw new LogicException('The ' . __METHOD__ . ' method must be implemented by subclasses'); + } + + /** + * Create an instance of StdClass that can later be converted back to an + * update or info container. Useful for serialization and caching, as it + * avoids the "incomplete object" problem if the cached value is loaded + * before this class. + * + * @return \StdClass + */ + public function toStdClass() { + $object = new stdClass(); + $this->copyFields($this, $object); + return $object; + } + + /** + * Transform the metadata into the format used by WordPress core. + * + * @return object + */ + abstract public function toWpFormat(); + + /** + * Copy known fields from one object to another. + * + * @param \StdClass|self $from + * @param \StdClass|self $to + */ + protected function copyFields($from, $to) { + $fields = $this->getFieldNames(); + + if ( property_exists($from, 'slug') && !empty($from->slug) ) { + //Let plugins add extra fields without having to create subclasses. + $fields = apply_filters($this->getPrefixedFilter('retain_fields') . '-' . $from->slug, $fields); + } + + foreach ($fields as $field) { + if ( property_exists($from, $field) ) { + $to->$field = $from->$field; + } + } + } + + /** + * @return string[] + */ + protected function getFieldNames() { + return array(); + } + + /** + * @param string $tag + * @return string + */ + protected function getPrefixedFilter($tag) { + return 'puc_' . $tag; + } + + public function __set($name, $value) { + $this->extraProperties[$name] = $value; + } + + public function __get($name) { + return isset($this->extraProperties[$name]) ? $this->extraProperties[$name] : null; + } + + public function __isset($name) { + return isset($this->extraProperties[$name]); + } + + public function __unset($name) { + unset($this->extraProperties[$name]); + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/OAuthSignature.php b/includes/plugin-update-checker/Puc/v5p4/OAuthSignature.php new file mode 100644 index 0000000..ccb62b4 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/OAuthSignature.php @@ -0,0 +1,102 @@ +consumerKey = $consumerKey; + $this->consumerSecret = $consumerSecret; + } + + /** + * Sign a URL using OAuth 1.0. + * + * @param string $url The URL to be signed. It may contain query parameters. + * @param string $method HTTP method such as "GET", "POST" and so on. + * @return string The signed URL. + */ + public function sign($url, $method = 'GET') { + $parameters = array(); + + //Parse query parameters. + $query = wp_parse_url($url, PHP_URL_QUERY); + if ( !empty($query) ) { + parse_str($query, $parsedParams); + if ( is_array($parsedParams) ) { + $parameters = $parsedParams; + } + //Remove the query string from the URL. We'll replace it later. + $url = substr($url, 0, strpos($url, '?')); + } + + $parameters = array_merge( + $parameters, + array( + 'oauth_consumer_key' => $this->consumerKey, + 'oauth_nonce' => $this->nonce(), + 'oauth_signature_method' => 'HMAC-SHA1', + 'oauth_timestamp' => time(), + 'oauth_version' => '1.0', + ) + ); + unset($parameters['oauth_signature']); + + //Parameters must be sorted alphabetically before signing. + ksort($parameters); + + //The most complicated part of the request - generating the signature. + //The string to sign contains the HTTP method, the URL path, and all of + //our query parameters. Everything is URL encoded. Then we concatenate + //them with ampersands into a single string to hash. + $encodedVerb = urlencode($method); + $encodedUrl = urlencode($url); + $encodedParams = urlencode(http_build_query($parameters, '', '&')); + + $stringToSign = $encodedVerb . '&' . $encodedUrl . '&' . $encodedParams; + + //Since we only have one OAuth token (the consumer secret) we only have + //to use it as our HMAC key. However, we still have to append an & to it + //as if we were using it with additional tokens. + $secret = urlencode($this->consumerSecret) . '&'; + + //The signature is a hash of the consumer key and the base string. Note + //that we have to get the raw output from hash_hmac and base64 encode + //the binary data result. + $parameters['oauth_signature'] = base64_encode(hash_hmac('sha1', $stringToSign, $secret, true)); + + return ($url . '?' . http_build_query($parameters)); + } + + /** + * Generate a random nonce. + * + * @return string + */ + private function nonce() { + $mt = microtime(); + + $rand = null; + if ( is_callable('random_bytes') ) { + try { + $rand = random_bytes(16); + } catch (\Exception $ex) { + //Fall back to mt_rand (below). + } + } + if ( $rand === null ) { + //phpcs:ignore WordPress.WP.AlternativeFunctions.rand_mt_rand + $rand = function_exists('wp_rand') ? wp_rand() : mt_rand(); + } + + return md5($mt . '_' . $rand); + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Plugin/Package.php b/includes/plugin-update-checker/Puc/v5p4/Plugin/Package.php new file mode 100644 index 0000000..30deaee --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Plugin/Package.php @@ -0,0 +1,188 @@ +pluginAbsolutePath = $pluginAbsolutePath; + $this->pluginFile = plugin_basename($this->pluginAbsolutePath); + + parent::__construct($updateChecker); + + //Clear the version number cache when something - anything - is upgraded or WP clears the update cache. + add_filter('upgrader_post_install', array($this, 'clearCachedVersion')); + add_action('delete_site_transient_update_plugins', array($this, 'clearCachedVersion')); + } + + public function getInstalledVersion() { + if ( isset($this->cachedInstalledVersion) ) { + return $this->cachedInstalledVersion; + } + + $pluginHeader = $this->getPluginHeader(); + if ( isset($pluginHeader['Version']) ) { + $this->cachedInstalledVersion = $pluginHeader['Version']; + return $pluginHeader['Version']; + } else { + //This can happen if the filename points to something that is not a plugin. + $this->updateChecker->triggerError( + sprintf( + "Cannot read the Version header for '%s'. The filename is incorrect or is not a plugin.", + $this->updateChecker->pluginFile + ), + E_USER_WARNING + ); + return null; + } + } + + /** + * Clear the cached plugin version. This method can be set up as a filter (hook) and will + * return the filter argument unmodified. + * + * @param mixed $filterArgument + * @return mixed + */ + public function clearCachedVersion($filterArgument = null) { + $this->cachedInstalledVersion = null; + return $filterArgument; + } + + public function getAbsoluteDirectoryPath() { + return dirname($this->pluginAbsolutePath); + } + + /** + * Get the value of a specific plugin or theme header. + * + * @param string $headerName + * @param string $defaultValue + * @return string Either the value of the header, or $defaultValue if the header doesn't exist or is empty. + */ + public function getHeaderValue($headerName, $defaultValue = '') { + $headers = $this->getPluginHeader(); + if ( isset($headers[$headerName]) && ($headers[$headerName] !== '') ) { + return $headers[$headerName]; + } + return $defaultValue; + } + + protected function getHeaderNames() { + return array( + 'Name' => 'Plugin Name', + 'PluginURI' => 'Plugin URI', + 'Version' => 'Version', + 'Description' => 'Description', + 'Author' => 'Author', + 'AuthorURI' => 'Author URI', + 'TextDomain' => 'Text Domain', + 'DomainPath' => 'Domain Path', + 'Network' => 'Network', + + //The newest WordPress version that this plugin requires or has been tested with. + //We support several different formats for compatibility with other libraries. + 'Tested WP' => 'Tested WP', + 'Requires WP' => 'Requires WP', + 'Tested up to' => 'Tested up to', + 'Requires at least' => 'Requires at least', + ); + } + + /** + * Get the translated plugin title. + * + * @return string + */ + public function getPluginTitle() { + $title = ''; + $header = $this->getPluginHeader(); + if ( $header && !empty($header['Name']) && isset($header['TextDomain']) ) { + $title = translate($header['Name'], $header['TextDomain']); + } + return $title; + } + + /** + * Get plugin's metadata from its file header. + * + * @return array + */ + public function getPluginHeader() { + if ( !is_file($this->pluginAbsolutePath) ) { + //This can happen if the plugin filename is wrong. + $this->updateChecker->triggerError( + sprintf( + "Can't to read the plugin header for '%s'. The file does not exist.", + $this->updateChecker->pluginFile + ), + E_USER_WARNING + ); + return array(); + } + + if ( !function_exists('get_plugin_data') ) { + require_once(ABSPATH . '/wp-admin/includes/plugin.php'); + } + return get_plugin_data($this->pluginAbsolutePath, false, false); + } + + public function removeHooks() { + remove_filter('upgrader_post_install', array($this, 'clearCachedVersion')); + remove_action('delete_site_transient_update_plugins', array($this, 'clearCachedVersion')); + } + + /** + * Check if the plugin file is inside the mu-plugins directory. + * + * @return bool + */ + public function isMuPlugin() { + static $cachedResult = null; + + if ( $cachedResult === null ) { + if ( !defined('WPMU_PLUGIN_DIR') || !is_string(WPMU_PLUGIN_DIR) ) { + $cachedResult = false; + return $cachedResult; + } + + //Convert both paths to the canonical form before comparison. + $muPluginDir = realpath(WPMU_PLUGIN_DIR); + $pluginPath = realpath($this->pluginAbsolutePath); + //If realpath() fails, just normalize the syntax instead. + if (($muPluginDir === false) || ($pluginPath === false)) { + $muPluginDir = PucFactory::normalizePath(WPMU_PLUGIN_DIR); + $pluginPath = PucFactory::normalizePath($this->pluginAbsolutePath); + } + + $cachedResult = (strpos($pluginPath, $muPluginDir) === 0); + } + + return $cachedResult; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Plugin/PluginInfo.php b/includes/plugin-update-checker/Puc/v5p4/Plugin/PluginInfo.php new file mode 100644 index 0000000..2428488 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Plugin/PluginInfo.php @@ -0,0 +1,136 @@ +sections = (array)$instance->sections; + $instance->icons = (array)$instance->icons; + + return $instance; + } + + /** + * Very, very basic validation. + * + * @param \StdClass $apiResponse + * @return bool|\WP_Error + */ + protected function validateMetadata($apiResponse) { + if ( + !isset($apiResponse->name, $apiResponse->version) + || empty($apiResponse->name) + || empty($apiResponse->version) + ) { + return new \WP_Error( + 'puc-invalid-metadata', + "The plugin metadata file does not contain the required 'name' and/or 'version' keys." + ); + } + return true; + } + + + /** + * Transform plugin info into the format used by the native WordPress.org API + * + * @return object + */ + public function toWpFormat(){ + $info = new \stdClass; + + //The custom update API is built so that many fields have the same name and format + //as those returned by the native WordPress.org API. These can be assigned directly. + $sameFormat = array( + 'name', 'slug', 'version', 'requires', 'tested', 'rating', 'upgrade_notice', + 'num_ratings', 'downloaded', 'active_installs', 'homepage', 'last_updated', + 'requires_php', + ); + foreach($sameFormat as $field){ + if ( isset($this->$field) ) { + $info->$field = $this->$field; + } else { + $info->$field = null; + } + } + + //Other fields need to be renamed and/or transformed. + $info->download_link = $this->download_url; + $info->author = $this->getFormattedAuthor(); + $info->sections = array_merge(array('description' => ''), $this->sections); + + if ( !empty($this->banners) ) { + //WP expects an array with two keys: "high" and "low". Both are optional. + //Docs: https://wordpress.org/plugins/about/faq/#banners + $info->banners = is_object($this->banners) ? get_object_vars($this->banners) : $this->banners; + $info->banners = array_intersect_key($info->banners, array('high' => true, 'low' => true)); + } + + return $info; + } + + protected function getFormattedAuthor() { + if ( !empty($this->author_homepage) ){ + /** @noinspection HtmlUnknownTarget */ + return sprintf('%s', $this->author_homepage, $this->author); + } + return $this->author; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php b/includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php new file mode 100644 index 0000000..a9cdbda --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php @@ -0,0 +1,294 @@ +updateChecker = $updateChecker; + $this->manualCheckErrorTransient = $this->updateChecker->getUniqueName('manual_check_errors'); + + add_action('admin_init', array($this, 'onAdminInit')); + } + + public function onAdminInit() { + if ( $this->updateChecker->userCanInstallUpdates() ) { + $this->handleManualCheck(); + + add_filter('plugin_row_meta', array($this, 'addViewDetailsLink'), 10, 3); + add_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10, 2); + add_action('all_admin_notices', array($this, 'displayManualCheckResult')); + } + } + + /** + * Add a "View Details" link to the plugin row in the "Plugins" page. By default, + * the new link will appear before the "Visit plugin site" link (if present). + * + * You can change the link text by using the "puc_view_details_link-$slug" filter. + * Returning an empty string from the filter will disable the link. + * + * You can change the position of the link using the + * "puc_view_details_link_position-$slug" filter. + * Returning 'before' or 'after' will place the link immediately before/after + * the "Visit plugin site" link. + * Returning 'append' places the link after any existing links at the time of the hook. + * Returning 'replace' replaces the "Visit plugin site" link. + * Returning anything else disables the link when there is a "Visit plugin site" link. + * + * If there is no "Visit plugin site" link 'append' is always used! + * + * @param array $pluginMeta Array of meta links. + * @param string $pluginFile + * @param array $pluginData Array of plugin header data. + * @return array + */ + public function addViewDetailsLink($pluginMeta, $pluginFile, $pluginData = array()) { + if ( $this->isMyPluginFile($pluginFile) && !isset($pluginData['slug']) ) { + $linkText = apply_filters($this->updateChecker->getUniqueName('view_details_link'), __('View details')); + if ( !empty($linkText) ) { + $viewDetailsLinkPosition = 'append'; + + //Find the "Visit plugin site" link (if present). + $visitPluginSiteLinkIndex = count($pluginMeta) - 1; + if ( $pluginData['PluginURI'] ) { + $escapedPluginUri = esc_url($pluginData['PluginURI']); + foreach ($pluginMeta as $linkIndex => $existingLink) { + if ( strpos($existingLink, $escapedPluginUri) !== false ) { + $visitPluginSiteLinkIndex = $linkIndex; + $viewDetailsLinkPosition = apply_filters( + $this->updateChecker->getUniqueName('view_details_link_position'), + 'before' + ); + break; + } + } + } + + $viewDetailsLink = sprintf('%s', + esc_url(network_admin_url('plugin-install.php?tab=plugin-information&plugin=' . urlencode($this->updateChecker->slug) . + '&TB_iframe=true&width=600&height=550')), + esc_attr(sprintf(__('More information about %s'), $pluginData['Name'])), + esc_attr($pluginData['Name']), + $linkText + ); + switch ($viewDetailsLinkPosition) { + case 'before': + array_splice($pluginMeta, $visitPluginSiteLinkIndex, 0, $viewDetailsLink); + break; + case 'after': + array_splice($pluginMeta, $visitPluginSiteLinkIndex + 1, 0, $viewDetailsLink); + break; + case 'replace': + $pluginMeta[$visitPluginSiteLinkIndex] = $viewDetailsLink; + break; + case 'append': + default: + $pluginMeta[] = $viewDetailsLink; + break; + } + } + } + return $pluginMeta; + } + + /** + * Add a "Check for updates" link to the plugin row in the "Plugins" page. By default, + * the new link will appear after the "Visit plugin site" link if present, otherwise + * after the "View plugin details" link. + * + * You can change the link text by using the "puc_manual_check_link-$slug" filter. + * Returning an empty string from the filter will disable the link. + * + * @param array $pluginMeta Array of meta links. + * @param string $pluginFile + * @return array + */ + public function addCheckForUpdatesLink($pluginMeta, $pluginFile) { + if ( $this->isMyPluginFile($pluginFile) ) { + $linkUrl = wp_nonce_url( + add_query_arg( + array( + 'puc_check_for_updates' => 1, + 'puc_slug' => $this->updateChecker->slug, + ), + self_admin_url('plugins.php') + ), + 'puc_check_for_updates' + ); + + $linkText = apply_filters( + $this->updateChecker->getUniqueName('manual_check_link'), + __('Check for updates', 'plugin-update-checker') + ); + if ( !empty($linkText) ) { + /** @noinspection HtmlUnknownTarget */ + $pluginMeta[] = sprintf('%s', esc_attr($linkUrl), $linkText); + } + } + return $pluginMeta; + } + + protected function isMyPluginFile($pluginFile) { + return ($pluginFile == $this->updateChecker->pluginFile) + || (!empty($this->updateChecker->muPluginFile) && ($pluginFile == $this->updateChecker->muPluginFile)); + } + + /** + * Check for updates when the user clicks the "Check for updates" link. + * + * @see self::addCheckForUpdatesLink() + * + * @return void + */ + public function handleManualCheck() { + $shouldCheck = + isset($_GET['puc_check_for_updates'], $_GET['puc_slug']) + && $_GET['puc_slug'] == $this->updateChecker->slug + && check_admin_referer('puc_check_for_updates'); + + if ( $shouldCheck ) { + $update = $this->updateChecker->checkForUpdates(); + $status = ($update === null) ? 'no_update' : 'update_available'; + $lastRequestApiErrors = $this->updateChecker->getLastRequestApiErrors(); + + if ( ($update === null) && !empty($lastRequestApiErrors) ) { + //Some errors are not critical. For example, if PUC tries to retrieve the readme.txt + //file from GitHub and gets a 404, that's an API error, but it doesn't prevent updates + //from working. Maybe the plugin simply doesn't have a readme. + //Let's only show important errors. + $foundCriticalErrors = false; + $questionableErrorCodes = array( + 'puc-github-http-error', + 'puc-gitlab-http-error', + 'puc-bitbucket-http-error', + ); + + foreach ($lastRequestApiErrors as $item) { + $wpError = $item['error']; + /** @var \WP_Error $wpError */ + if ( !in_array($wpError->get_error_code(), $questionableErrorCodes) ) { + $foundCriticalErrors = true; + break; + } + } + + if ( $foundCriticalErrors ) { + $status = 'error'; + set_site_transient($this->manualCheckErrorTransient, $lastRequestApiErrors, 60); + } + } + + wp_redirect(add_query_arg( + array( + 'puc_update_check_result' => $status, + 'puc_slug' => $this->updateChecker->slug, + ), + self_admin_url('plugins.php') + )); + exit; + } + } + + /** + * Display the results of a manual update check. + * + * @see self::handleManualCheck() + * + * You can change the result message by using the "puc_manual_check_message-$slug" filter. + */ + public function displayManualCheckResult() { + //phpcs:disable WordPress.Security.NonceVerification.Recommended -- Just displaying a message. + if ( isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->updateChecker->slug) ) { + $status = sanitize_key($_GET['puc_update_check_result']); + $title = $this->updateChecker->getInstalledPackage()->getPluginTitle(); + $noticeClass = 'updated notice-success'; + $details = ''; + + if ( $status == 'no_update' ) { + $message = sprintf(_x('The %s plugin is up to date.', 'the plugin title', 'plugin-update-checker'), $title); + } else if ( $status == 'update_available' ) { + $message = sprintf(_x('A new version of the %s plugin is available.', 'the plugin title', 'plugin-update-checker'), $title); + } else if ( $status === 'error' ) { + $message = sprintf(_x('Could not determine if updates are available for %s.', 'the plugin title', 'plugin-update-checker'), $title); + $noticeClass = 'error notice-error'; + + $details = $this->formatManualCheckErrors(get_site_transient($this->manualCheckErrorTransient)); + delete_site_transient($this->manualCheckErrorTransient); + } else { + $message = sprintf(__('Unknown update checker status "%s"', 'plugin-update-checker'), $status); + $noticeClass = 'error notice-error'; + } + + $message = esc_html($message); + + //Plugins can replace the message with their own, including adding HTML. + $message = apply_filters( + $this->updateChecker->getUniqueName('manual_check_message'), + $message, + $status + ); + + printf( + '

%s

%s
', + esc_attr($noticeClass), + //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Was escaped above, and plugins can add HTML. + $message, + //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Contains HTML. Content should already be escaped. + $details + ); + } + //phpcs:enable + } + + /** + * Format the list of errors that were thrown during an update check. + * + * @param array $errors + * @return string + */ + protected function formatManualCheckErrors($errors) { + if ( empty($errors) ) { + return ''; + } + $output = ''; + + $showAsList = count($errors) > 1; + if ( $showAsList ) { + $output .= '
    '; + $formatString = '
  1. %1$s %2$s
  2. '; + } else { + $formatString = '

    %1$s %2$s

    '; + } + foreach ($errors as $item) { + $wpError = $item['error']; + /** @var \WP_Error $wpError */ + $output .= sprintf( + $formatString, + esc_html($wpError->get_error_message()), + esc_html($wpError->get_error_code()) + ); + } + if ( $showAsList ) { + $output .= '
'; + } + + return $output; + } + + public function removeHooks() { + remove_action('admin_init', array($this, 'onAdminInit')); + remove_filter('plugin_row_meta', array($this, 'addViewDetailsLink'), 10); + remove_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10); + remove_action('all_admin_notices', array($this, 'displayManualCheckResult')); + } + } +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Plugin/Update.php b/includes/plugin-update-checker/Puc/v5p4/Plugin/Update.php new file mode 100644 index 0000000..0fb3137 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Plugin/Update.php @@ -0,0 +1,116 @@ +copyFields($object, $update); + return $update; + } + + /** + * @return string[] + */ + protected function getFieldNames() { + return array_merge(parent::getFieldNames(), self::$extraFields); + } + + /** + * Transform the update into the format used by WordPress native plugin API. + * + * @return object + */ + public function toWpFormat() { + $update = parent::toWpFormat(); + + $update->id = $this->id; + $update->url = $this->homepage; + $update->tested = $this->tested; + $update->requires_php = $this->requires_php; + $update->plugin = $this->filename; + + if ( !empty($this->upgrade_notice) ) { + $update->upgrade_notice = $this->upgrade_notice; + } + + if ( !empty($this->icons) && is_array($this->icons) ) { + //This should be an array with up to 4 keys: 'svg', '1x', '2x' and 'default'. + //Docs: https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/#plugin-icons + $icons = array_intersect_key( + $this->icons, + array('svg' => true, '1x' => true, '2x' => true, 'default' => true) + ); + if ( !empty($icons) ) { + $update->icons = $icons; + + //It appears that the 'default' icon isn't used anywhere in WordPress 4.9, + //but lets set it just in case a future release needs it. + if ( !isset($update->icons['default']) ) { + $update->icons['default'] = current($update->icons); + } + } + } + + return $update; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Plugin/UpdateChecker.php b/includes/plugin-update-checker/Puc/v5p4/Plugin/UpdateChecker.php new file mode 100644 index 0000000..6d1aae8 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Plugin/UpdateChecker.php @@ -0,0 +1,425 @@ +pluginAbsolutePath = $pluginFile; + $this->pluginFile = plugin_basename($this->pluginAbsolutePath); + $this->muPluginFile = $muPluginFile; + + //If no slug is specified, use the name of the main plugin file as the slug. + //For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'. + if ( empty($slug) ){ + $slug = basename($this->pluginFile, '.php'); + } + + //Plugin slugs must be unique. + $slugCheckFilter = 'puc_is_slug_in_use-' . $slug; + $slugUsedBy = apply_filters($slugCheckFilter, false); + if ( $slugUsedBy ) { + $this->triggerError(sprintf( + 'Plugin slug "%s" is already in use by %s. Slugs must be unique.', + $slug, + $slugUsedBy + ), E_USER_ERROR); + } + add_filter($slugCheckFilter, array($this, 'getAbsolutePath')); + + parent::__construct($metadataUrl, dirname($this->pluginFile), $slug, $checkPeriod, $optionName); + + //Backwards compatibility: If the plugin is a mu-plugin but no $muPluginFile is specified, assume + //it's the same as $pluginFile given that it's not in a subdirectory (WP only looks in the base dir). + if ( (strpbrk($this->pluginFile, '/\\') === false) && $this->isUnknownMuPlugin() ) { + $this->muPluginFile = $this->pluginFile; + } + + //To prevent a crash during plugin uninstallation, remove updater hooks when the user removes the plugin. + //Details: https://github.com/YahnisElsts/plugin-update-checker/issues/138#issuecomment-335590964 + add_action('uninstall_' . $this->pluginFile, array($this, 'removeHooks')); + + $this->extraUi = new Ui($this); + } + + /** + * Create an instance of the scheduler. + * + * @param int $checkPeriod + * @return Scheduler + */ + protected function createScheduler($checkPeriod) { + $scheduler = new Scheduler($this, $checkPeriod, array('load-plugins.php')); + register_deactivation_hook($this->pluginFile, array($scheduler, 'removeUpdaterCron')); + return $scheduler; + } + + /** + * Install the hooks required to run periodic update checks and inject update info + * into WP data structures. + * + * @return void + */ + protected function installHooks(){ + //Override requests for plugin information + add_filter('plugins_api', array($this, 'injectInfo'), 20, 3); + + parent::installHooks(); + } + + /** + * Remove update checker hooks. + * + * The intent is to prevent a fatal error that can happen if the plugin has an uninstall + * hook. During uninstallation, WP includes the main plugin file (which creates a PUC instance), + * the uninstall hook runs, WP deletes the plugin files and then updates some transients. + * If PUC hooks are still around at this time, they could throw an error while trying to + * autoload classes from files that no longer exist. + * + * The "site_transient_{$transient}" filter is the main problem here, but let's also remove + * most other PUC hooks to be safe. + * + * @internal + */ + public function removeHooks() { + parent::removeHooks(); + $this->extraUi->removeHooks(); + $this->package->removeHooks(); + + remove_filter('plugins_api', array($this, 'injectInfo'), 20); + } + + /** + * Retrieve plugin info from the configured API endpoint. + * + * @uses wp_remote_get() + * + * @param array $queryArgs Additional query arguments to append to the request. Optional. + * @return PluginInfo + */ + public function requestInfo($queryArgs = array()) { + list($pluginInfo, $result) = $this->requestMetadata( + PluginInfo::class, + 'request_info', + $queryArgs + ); + + if ( $pluginInfo !== null ) { + /** @var PluginInfo $pluginInfo */ + $pluginInfo->filename = $this->pluginFile; + $pluginInfo->slug = $this->slug; + } + + $pluginInfo = apply_filters($this->getUniqueName('request_info_result'), $pluginInfo, $result); + return $pluginInfo; + } + + /** + * Retrieve the latest update (if any) from the configured API endpoint. + * + * @uses UpdateChecker::requestInfo() + * + * @return Update|null An instance of Plugin Update, or NULL when no updates are available. + */ + public function requestUpdate() { + //For the sake of simplicity, this function just calls requestInfo() + //and transforms the result accordingly. + $pluginInfo = $this->requestInfo(array('checking_for_updates' => '1')); + if ( $pluginInfo === null ){ + return null; + } + $update = Update::fromPluginInfo($pluginInfo); + + $update = $this->filterUpdateResult($update); + + return $update; + } + + /** + * Intercept plugins_api() calls that request information about our plugin and + * use the configured API endpoint to satisfy them. + * + * @see plugins_api() + * + * @param mixed $result + * @param string $action + * @param array|object $args + * @return mixed + */ + public function injectInfo($result, $action = null, $args = null){ + $relevant = ($action == 'plugin_information') && isset($args->slug) && ( + ($args->slug == $this->slug) || ($args->slug == dirname($this->pluginFile)) + ); + if ( !$relevant ) { + return $result; + } + + $pluginInfo = $this->requestInfo(); + $this->fixSupportedWordpressVersion($pluginInfo); + + $pluginInfo = apply_filters($this->getUniqueName('pre_inject_info'), $pluginInfo); + if ( $pluginInfo ) { + return $pluginInfo->toWpFormat(); + } + + return $result; + } + + protected function shouldShowUpdates() { + //No update notifications for mu-plugins unless explicitly enabled. The MU plugin file + //is usually different from the main plugin file so the update wouldn't show up properly anyway. + return !$this->isUnknownMuPlugin(); + } + + /** + * @param \stdClass|null $updates + * @param \stdClass $updateToAdd + * @return \stdClass + */ + protected function addUpdateToList($updates, $updateToAdd) { + if ( $this->package->isMuPlugin() ) { + //WP does not support automatic update installation for mu-plugins, but we can + //still display a notice. + $updateToAdd->package = null; + } + return parent::addUpdateToList($updates, $updateToAdd); + } + + /** + * @param \stdClass|null $updates + * @return \stdClass|null + */ + protected function removeUpdateFromList($updates) { + $updates = parent::removeUpdateFromList($updates); + if ( !empty($this->muPluginFile) && isset($updates, $updates->response) ) { + unset($updates->response[$this->muPluginFile]); + } + return $updates; + } + + /** + * For plugins, the update array is indexed by the plugin filename relative to the "plugins" + * directory. Example: "plugin-name/plugin.php". + * + * @return string + */ + protected function getUpdateListKey() { + if ( $this->package->isMuPlugin() ) { + return $this->muPluginFile; + } + return $this->pluginFile; + } + + protected function getNoUpdateItemFields() { + return array_merge( + parent::getNoUpdateItemFields(), + array( + 'id' => $this->pluginFile, + 'slug' => $this->slug, + 'plugin' => $this->pluginFile, + 'icons' => array(), + 'banners' => array(), + 'banners_rtl' => array(), + 'tested' => '', + 'compatibility' => new \stdClass(), + ) + ); + } + + /** + * Alias for isBeingUpgraded(). + * + * @deprecated + * @param \WP_Upgrader|null $upgrader The upgrader that's performing the current update. + * @return bool + */ + public function isPluginBeingUpgraded($upgrader = null) { + return $this->isBeingUpgraded($upgrader); + } + + /** + * Is there an update being installed for this plugin, right now? + * + * @param \WP_Upgrader|null $upgrader + * @return bool + */ + public function isBeingUpgraded($upgrader = null) { + return $this->upgraderStatus->isPluginBeingUpgraded($this->pluginFile, $upgrader); + } + + /** + * Get the details of the currently available update, if any. + * + * If no updates are available, or if the last known update version is below or equal + * to the currently installed version, this method will return NULL. + * + * Uses cached update data. To retrieve update information straight from + * the metadata URL, call requestUpdate() instead. + * + * @return Update|null + */ + public function getUpdate() { + $update = parent::getUpdate(); + if ( isset($update) ) { + /** @var Update $update */ + $update->filename = $this->pluginFile; + } + return $update; + } + + /** + * Get the translated plugin title. + * + * @deprecated + * @return string + */ + public function getPluginTitle() { + return $this->package->getPluginTitle(); + } + + /** + * Check if the current user has the required permissions to install updates. + * + * @return bool + */ + public function userCanInstallUpdates() { + return current_user_can('update_plugins'); + } + + /** + * Check if the plugin file is inside the mu-plugins directory. + * + * @deprecated + * @return bool + */ + protected function isMuPlugin() { + return $this->package->isMuPlugin(); + } + + /** + * MU plugins are partially supported, but only when we know which file in mu-plugins + * corresponds to this plugin. + * + * @return bool + */ + protected function isUnknownMuPlugin() { + return empty($this->muPluginFile) && $this->package->isMuPlugin(); + } + + /** + * Get absolute path to the main plugin file. + * + * @return string + */ + public function getAbsolutePath() { + return $this->pluginAbsolutePath; + } + + /** + * Register a callback for filtering query arguments. + * + * The callback function should take one argument - an associative array of query arguments. + * It should return a modified array of query arguments. + * + * @uses add_filter() This method is a convenience wrapper for add_filter(). + * + * @param callable $callback + * @return void + */ + public function addQueryArgFilter($callback){ + $this->addFilter('request_info_query_args', $callback); + } + + /** + * Register a callback for filtering arguments passed to wp_remote_get(). + * + * The callback function should take one argument - an associative array of arguments - + * and return a modified array or arguments. See the WP documentation on wp_remote_get() + * for details on what arguments are available and how they work. + * + * @uses add_filter() This method is a convenience wrapper for add_filter(). + * + * @param callable $callback + * @return void + */ + public function addHttpRequestArgFilter($callback) { + $this->addFilter('request_info_options', $callback); + } + + /** + * Register a callback for filtering the plugin info retrieved from the external API. + * + * The callback function should take two arguments. If the plugin info was retrieved + * successfully, the first argument passed will be an instance of PluginInfo. Otherwise, + * it will be NULL. The second argument will be the corresponding return value of + * wp_remote_get (see WP docs for details). + * + * The callback function should return a new or modified instance of PluginInfo or NULL. + * + * @uses add_filter() This method is a convenience wrapper for add_filter(). + * + * @param callable $callback + * @return void + */ + public function addResultFilter($callback) { + $this->addFilter('request_info_result', $callback, 10, 2); + } + + protected function createDebugBarExtension() { + return new DebugBar\PluginExtension($this); + } + + /** + * Create a package instance that represents this plugin or theme. + * + * @return InstalledPackage + */ + protected function createInstalledPackage() { + return new Package($this->pluginAbsolutePath, $this); + } + + /** + * @return Package + */ + public function getInstalledPackage() { + return $this->package; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/PucFactory.php b/includes/plugin-update-checker/Puc/v5p4/PucFactory.php new file mode 100644 index 0000000..b7cbbb1 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/PucFactory.php @@ -0,0 +1,362 @@ + '', + 'slug' => '', + 'checkPeriod' => 12, + 'optionName' => '', + 'muPluginFile' => '', + ); + $args = array_merge($defaults, array_intersect_key($args, $defaults)); + extract($args, EXTR_SKIP); + + //Check for the service URI + if ( empty($metadataUrl) ) { + $metadataUrl = self::getServiceURI($fullPath); + } + + return self::buildUpdateChecker($metadataUrl, $fullPath, $slug, $checkPeriod, $optionName, $muPluginFile); + } + + /** + * Create a new instance of the update checker. + * + * This method automatically detects if you're using it for a plugin or a theme and chooses + * the appropriate implementation for your update source (JSON file, GitHub, BitBucket, etc). + * + * @see UpdateChecker::__construct + * + * @param string $metadataUrl The URL of the metadata file, a GitHub repository, or another supported update source. + * @param string $fullPath Full path to the main plugin file or to the theme directory. + * @param string $slug Custom slug. Defaults to the name of the main plugin file or the theme directory. + * @param int $checkPeriod How often to check for updates (in hours). + * @param string $optionName Where to store bookkeeping info about update checks. + * @param string $muPluginFile The plugin filename relative to the mu-plugins directory. + * @return Plugin\UpdateChecker|Theme\UpdateChecker|Vcs\BaseChecker + */ + public static function buildUpdateChecker($metadataUrl, $fullPath, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') { + $fullPath = self::normalizePath($fullPath); + $id = null; + + //Plugin or theme? + $themeDirectory = self::getThemeDirectoryName($fullPath); + if ( self::isPluginFile($fullPath) ) { + $type = 'Plugin'; + $id = $fullPath; + } else if ( $themeDirectory !== null ) { + $type = 'Theme'; + $id = $themeDirectory; + } else { + throw new \RuntimeException(sprintf( + 'The update checker cannot determine if "%s" is a plugin or a theme. ' . + 'This is a bug. Please contact the PUC developer.', + htmlentities($fullPath) + )); + } + + //Which hosting service does the URL point to? + $service = self::getVcsService($metadataUrl); + + $apiClass = null; + if ( empty($service) ) { + //The default is to get update information from a remote JSON file. + $checkerClass = $type . '\\UpdateChecker'; + } else { + //You can also use a VCS repository like GitHub. + $checkerClass = 'Vcs\\' . $type . 'UpdateChecker'; + $apiClass = $service . 'Api'; + } + + $checkerClass = self::getCompatibleClassVersion($checkerClass); + if ( $checkerClass === null ) { + //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error + trigger_error( + esc_html(sprintf( + 'PUC %s does not support updates for %ss %s', + self::$latestCompatibleVersion, + strtolower($type), + $service ? ('hosted on ' . $service) : 'using JSON metadata' + )), + E_USER_ERROR + ); + } + + if ( !isset($apiClass) ) { + //Plain old update checker. + return new $checkerClass($metadataUrl, $id, $slug, $checkPeriod, $optionName, $muPluginFile); + } else { + //VCS checker + an API client. + $apiClass = self::getCompatibleClassVersion($apiClass); + if ( $apiClass === null ) { + //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error + trigger_error(esc_html(sprintf( + 'PUC %s does not support %s', + self::$latestCompatibleVersion, + $service + )), E_USER_ERROR); + } + + return new $checkerClass( + new $apiClass($metadataUrl), + $id, + $slug, + $checkPeriod, + $optionName, + $muPluginFile + ); + } + } + + /** + * + * Normalize a filesystem path. Introduced in WP 3.9. + * Copying here allows use of the class on earlier versions. + * This version adapted from WP 4.8.2 (unchanged since 4.5.4) + * + * @param string $path Path to normalize. + * @return string Normalized path. + */ + public static function normalizePath($path) { + if ( function_exists('wp_normalize_path') ) { + return wp_normalize_path($path); + } + $path = str_replace('\\', '/', $path); + $path = preg_replace('|(?<=.)/+|', '/', $path); + if ( substr($path, 1, 1) === ':' ) { + $path = ucfirst($path); + } + return $path; + } + + /** + * Check if the path points to a plugin file. + * + * @param string $absolutePath Normalized path. + * @return bool + */ + protected static function isPluginFile($absolutePath) { + //Is the file inside the "plugins" or "mu-plugins" directory? + $pluginDir = self::normalizePath(WP_PLUGIN_DIR); + $muPluginDir = self::normalizePath(WPMU_PLUGIN_DIR); + if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) { + return true; + } + + //Is it a file at all? Caution: is_file() can fail if the parent dir. doesn't have the +x permission set. + if ( !is_file($absolutePath) ) { + return false; + } + + //Does it have a valid plugin header? + //This is a last-ditch check for plugins symlinked from outside the WP root. + if ( function_exists('get_file_data') ) { + $headers = get_file_data($absolutePath, array('Name' => 'Plugin Name'), 'plugin'); + return !empty($headers['Name']); + } + + return false; + } + + /** + * Get the name of the theme's directory from a full path to a file inside that directory. + * E.g. "/abc/public_html/wp-content/themes/foo/whatever.php" => "foo". + * + * Note that subdirectories are currently not supported. For example, + * "/xyz/wp-content/themes/my-theme/includes/whatever.php" => NULL. + * + * @param string $absolutePath Normalized path. + * @return string|null Directory name, or NULL if the path doesn't point to a theme. + */ + protected static function getThemeDirectoryName($absolutePath) { + if ( is_file($absolutePath) ) { + $absolutePath = dirname($absolutePath); + } + + if ( file_exists($absolutePath . '/style.css') ) { + return basename($absolutePath); + } + return null; + } + + /** + * Get the service URI from the file header. + * + * @param string $fullPath + * @return string + */ + private static function getServiceURI($fullPath) { + //Look for the URI + if ( is_readable($fullPath) ) { + $seek = array( + 'github' => 'GitHub URI', + 'gitlab' => 'GitLab URI', + 'bucket' => 'BitBucket URI', + ); + $seek = apply_filters('puc_get_source_uri', $seek); + $data = get_file_data($fullPath, $seek); + foreach ($data as $key => $uri) { + if ( $uri ) { + return $uri; + } + } + } + + //URI was not found so throw an error. + throw new \RuntimeException( + sprintf('Unable to locate URI in header of "%s"', htmlentities($fullPath)) + ); + } + + /** + * Get the name of the hosting service that the URL points to. + * + * @param string $metadataUrl + * @return string|null + */ + private static function getVcsService($metadataUrl) { + $service = null; + + //Which hosting service does the URL point to? + $host = (string)(wp_parse_url($metadataUrl, PHP_URL_HOST)); + $path = (string)(wp_parse_url($metadataUrl, PHP_URL_PATH)); + + //Check if the path looks like "/user-name/repository". + //For GitLab.com it can also be "/user/group1/group2/.../repository". + $repoRegex = '@^/?([^/]+?)/([^/#?&]+?)/?$@'; + if ( $host === 'gitlab.com' ) { + $repoRegex = '@^/?(?:[^/#?&]++/){1,20}(?:[^/#?&]++)/?$@'; + } + if ( preg_match($repoRegex, $path) ) { + $knownServices = array( + 'github.com' => 'GitHub', + 'bitbucket.org' => 'BitBucket', + 'gitlab.com' => 'GitLab', + ); + if ( isset($knownServices[$host]) ) { + $service = $knownServices[$host]; + } + } + + return apply_filters('puc_get_vcs_service', $service, $host, $path, $metadataUrl); + } + + /** + * Get the latest version of the specified class that has the same major version number + * as this factory class. + * + * @param string $class Partial class name. + * @return string|null Full class name. + */ + protected static function getCompatibleClassVersion($class) { + if ( isset(self::$classVersions[$class][self::$latestCompatibleVersion]) ) { + return self::$classVersions[$class][self::$latestCompatibleVersion]; + } + return null; + } + + /** + * Get the specific class name for the latest available version of a class. + * + * @param string $class + * @return null|string + */ + public static function getLatestClassVersion($class) { + if ( !self::$sorted ) { + self::sortVersions(); + } + + if ( isset(self::$classVersions[$class]) ) { + return reset(self::$classVersions[$class]); + } else { + return null; + } + } + + /** + * Sort available class versions in descending order (i.e. newest first). + */ + protected static function sortVersions() { + foreach ( self::$classVersions as $class => $versions ) { + uksort($versions, array(__CLASS__, 'compareVersions')); + self::$classVersions[$class] = $versions; + } + self::$sorted = true; + } + + protected static function compareVersions($a, $b) { + return -version_compare($a, $b); + } + + /** + * Register a version of a class. + * + * @access private This method is only for internal use by the library. + * + * @param string $generalClass Class name without version numbers, e.g. 'PluginUpdateChecker'. + * @param string $versionedClass Actual class name, e.g. 'PluginUpdateChecker_1_2'. + * @param string $version Version number, e.g. '1.2'. + */ + public static function addVersion($generalClass, $versionedClass, $version) { + if ( empty(self::$myMajorVersion) ) { + $lastNamespaceSegment = substr(__NAMESPACE__, strrpos(__NAMESPACE__, '\\') + 1); + self::$myMajorVersion = substr(ltrim($lastNamespaceSegment, 'v'), 0, 1); + } + + //Store the greatest version number that matches our major version. + $components = explode('.', $version); + if ( $components[0] === self::$myMajorVersion ) { + + if ( + empty(self::$latestCompatibleVersion) + || version_compare($version, self::$latestCompatibleVersion, '>') + ) { + self::$latestCompatibleVersion = $version; + } + + } + + if ( !isset(self::$classVersions[$generalClass]) ) { + self::$classVersions[$generalClass] = array(); + } + self::$classVersions[$generalClass][$version] = $versionedClass; + self::$sorted = false; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Scheduler.php b/includes/plugin-update-checker/Puc/v5p4/Scheduler.php new file mode 100644 index 0000000..e4bc3d0 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Scheduler.php @@ -0,0 +1,300 @@ +updateChecker = $updateChecker; + $this->checkPeriod = $checkPeriod; + + //Set up the periodic update checks + $this->cronHook = $this->updateChecker->getUniqueName('cron_check_updates'); + if ( $this->checkPeriod > 0 ){ + + //Trigger the check via Cron. + //Try to use one of the default schedules if possible as it's less likely to conflict + //with other plugins and their custom schedules. + $defaultSchedules = array( + 1 => 'hourly', + 12 => 'twicedaily', + 24 => 'daily', + ); + if ( array_key_exists($this->checkPeriod, $defaultSchedules) ) { + $scheduleName = $defaultSchedules[$this->checkPeriod]; + } else { + //Use a custom cron schedule. + $scheduleName = 'every' . $this->checkPeriod . 'hours'; + //phpcs:ignore WordPress.WP.CronInterval.ChangeDetected -- WPCS fails to parse the callback. + add_filter('cron_schedules', array($this, '_addCustomSchedule')); + } + + if ( !wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING') ) { + //Randomly offset the schedule to help prevent update server traffic spikes. Without this + //most checks may happen during times of day when people are most likely to install new plugins. + $upperLimit = max($this->checkPeriod * 3600 - 15 * 60, 1); + if ( function_exists('wp_rand') ) { + $randomOffset = wp_rand(0, $upperLimit); + } else { + //This constructor may be called before wp_rand() is available. + //phpcs:ignore WordPress.WP.AlternativeFunctions.rand_rand + $randomOffset = rand(0, $upperLimit); + } + $firstCheckTime = time() - $randomOffset; + $firstCheckTime = apply_filters( + $this->updateChecker->getUniqueName('first_check_time'), + $firstCheckTime + ); + wp_schedule_event($firstCheckTime, $scheduleName, $this->cronHook); + } + add_action($this->cronHook, array($this, 'maybeCheckForUpdates')); + + //In case Cron is disabled or unreliable, we also manually trigger + //the periodic checks while the user is browsing the Dashboard. + add_action( 'admin_init', array($this, 'maybeCheckForUpdates') ); + + //Like WordPress itself, we check more often on certain pages. + /** @see wp_update_plugins */ + add_action('load-update-core.php', array($this, 'maybeCheckForUpdates')); + //phpcs:ignore Squiz.PHP.CommentedOutCode.Found -- Not actually code, just file names. + //"load-update.php" and "load-plugins.php" or "load-themes.php". + $this->hourlyCheckHooks = array_merge($this->hourlyCheckHooks, $hourlyHooks); + foreach($this->hourlyCheckHooks as $hook) { + add_action($hook, array($this, 'maybeCheckForUpdates')); + } + //This hook fires after a bulk update is complete. + add_action('upgrader_process_complete', array($this, 'removeHooksIfLibraryGone'), 1, 0); + add_action('upgrader_process_complete', array($this, 'upgraderProcessComplete'), 11, 2); + + } else { + //Periodic checks are disabled. + wp_clear_scheduled_hook($this->cronHook); + } + } + + /** + * Remove all hooks if this version of PUC has been deleted or overwritten. + * + * Callback for the "upgrader_process_complete" action. + */ + public function removeHooksIfLibraryGone() { + //Cancel all further actions if the current version of PUC has been deleted or overwritten + //by a different version during the upgrade. If we try to do anything more in that situation, + //we could trigger a fatal error by trying to autoload a deleted class. + clearstatcache(); + if ( !file_exists(__FILE__) ) { + $this->removeHooks(); + $this->updateChecker->removeHooks(); + } + } + + /** + * Runs upon the WP action upgrader_process_complete. + * + * We look at the parameters to decide whether to call maybeCheckForUpdates() or not. + * We also check if the update checker has been removed by the update. + * + * @param \WP_Upgrader $upgrader WP_Upgrader instance + * @param array $upgradeInfo extra information about the upgrade + */ + public function upgraderProcessComplete( + /** @noinspection PhpUnusedParameterInspection */ + $upgrader, $upgradeInfo + ) { + //Sanity check and limitation to relevant types. + if ( + !is_array($upgradeInfo) || !isset($upgradeInfo['type'], $upgradeInfo['action']) + || 'update' !== $upgradeInfo['action'] || !in_array($upgradeInfo['type'], array('plugin', 'theme')) + ) { + return; + } + + //Filter out notifications of upgrades that should have no bearing upon whether or not our + //current info is up-to-date. + if ( is_a($this->updateChecker, Theme\UpdateChecker::class) ) { + if ( 'theme' !== $upgradeInfo['type'] || !isset($upgradeInfo['themes']) ) { + return; + } + + //Letting too many things going through for checks is not a real problem, so we compare widely. + if ( !in_array( + strtolower($this->updateChecker->directoryName), + array_map('strtolower', $upgradeInfo['themes']) + ) ) { + return; + } + } + + if ( is_a($this->updateChecker, Plugin\UpdateChecker::class) ) { + if ( 'plugin' !== $upgradeInfo['type'] || !isset($upgradeInfo['plugins']) ) { + return; + } + + //Themes pass in directory names in the information array, but plugins use the relative plugin path. + if ( !in_array( + strtolower($this->updateChecker->directoryName), + array_map('dirname', array_map('strtolower', $upgradeInfo['plugins'])) + ) ) { + return; + } + } + + $this->maybeCheckForUpdates(); + } + + /** + * Check for updates if the configured check interval has already elapsed. + * Will use a shorter check interval on certain admin pages like "Dashboard -> Updates" or when doing cron. + * + * You can override the default behaviour by using the "puc_check_now-$slug" filter. + * The filter callback will be passed three parameters: + * - Current decision. TRUE = check updates now, FALSE = don't check now. + * - Last check time as a Unix timestamp. + * - Configured check period in hours. + * Return TRUE to check for updates immediately, or FALSE to cancel. + * + * This method is declared public because it's a hook callback. Calling it directly is not recommended. + */ + public function maybeCheckForUpdates() { + if ( empty($this->checkPeriod) ){ + return; + } + + $state = $this->updateChecker->getUpdateState(); + $shouldCheck = ($state->timeSinceLastCheck() >= $this->getEffectiveCheckPeriod()); + + if ( $shouldCheck ) { + //Sanity check: Do not proceed if one of the critical classes is missing. + //That can happen - theoretically and extremely rarely - if maybeCheckForUpdates() + //is called before the old version of our plugin has been fully deleted, or + //called from an independent AJAX request during deletion. + if ( !( + class_exists(Utils::class) + && class_exists(Metadata::class) + && class_exists(Plugin\Update::class) + && class_exists(Theme\Update::class) + ) ) { + return; + } + } + + //Let plugin authors substitute their own algorithm. + $shouldCheck = apply_filters( + $this->updateChecker->getUniqueName('check_now'), + $shouldCheck, + $state->getLastCheck(), + $this->checkPeriod + ); + + if ( $shouldCheck ) { + $this->updateChecker->checkForUpdates(); + } + } + + /** + * Calculate the actual check period based on the current status and environment. + * + * @return int Check period in seconds. + */ + protected function getEffectiveCheckPeriod() { + $currentFilter = current_filter(); + if ( in_array($currentFilter, array('load-update-core.php', 'upgrader_process_complete')) ) { + //Check more often when the user visits "Dashboard -> Updates" or does a bulk update. + $period = 60; + } else if ( in_array($currentFilter, $this->hourlyCheckHooks) ) { + //Also check more often on /wp-admin/update.php and the "Plugins" or "Themes" page. + $period = 3600; + } else if ( $this->throttleRedundantChecks && ($this->updateChecker->getUpdate() !== null) ) { + //Check less frequently if it's already known that an update is available. + $period = $this->throttledCheckPeriod * 3600; + } else if ( defined('DOING_CRON') && constant('DOING_CRON') ) { + //WordPress cron schedules are not exact, so let's do an update check even + //if slightly less than $checkPeriod hours have elapsed since the last check. + $cronFuzziness = 20 * 60; + $period = $this->checkPeriod * 3600 - $cronFuzziness; + } else { + $period = $this->checkPeriod * 3600; + } + + return $period; + } + + /** + * Add our custom schedule to the array of Cron schedules used by WP. + * + * @param array $schedules + * @return array + */ + public function _addCustomSchedule($schedules) { + if ( $this->checkPeriod && ($this->checkPeriod > 0) ){ + $scheduleName = 'every' . $this->checkPeriod . 'hours'; + $schedules[$scheduleName] = array( + 'interval' => $this->checkPeriod * 3600, + 'display' => sprintf('Every %d hours', $this->checkPeriod), + ); + } + return $schedules; + } + + /** + * Remove the scheduled cron event that the library uses to check for updates. + * + * @return void + */ + public function removeUpdaterCron() { + wp_clear_scheduled_hook($this->cronHook); + } + + /** + * Get the name of the update checker's WP-cron hook. Mostly useful for debugging. + * + * @return string + */ + public function getCronHookName() { + return $this->cronHook; + } + + /** + * Remove most hooks added by the scheduler. + */ + public function removeHooks() { + remove_filter('cron_schedules', array($this, '_addCustomSchedule')); + remove_action('admin_init', array($this, 'maybeCheckForUpdates')); + remove_action('load-update-core.php', array($this, 'maybeCheckForUpdates')); + + if ( $this->cronHook !== null ) { + remove_action($this->cronHook, array($this, 'maybeCheckForUpdates')); + } + if ( !empty($this->hourlyCheckHooks) ) { + foreach ($this->hourlyCheckHooks as $hook) { + remove_action($hook, array($this, 'maybeCheckForUpdates')); + } + } + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/StateStore.php b/includes/plugin-update-checker/Puc/v5p4/StateStore.php new file mode 100644 index 0000000..3828c1c --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/StateStore.php @@ -0,0 +1,214 @@ +optionName = $optionName; + } + + /** + * Get time elapsed since the last update check. + * + * If there are no recorded update checks, this method returns a large arbitrary number + * (i.e. time since the Unix epoch). + * + * @return int Elapsed time in seconds. + */ + public function timeSinceLastCheck() { + $this->lazyLoad(); + return time() - $this->lastCheck; + } + + /** + * @return int + */ + public function getLastCheck() { + $this->lazyLoad(); + return $this->lastCheck; + } + + /** + * Set the time of the last update check to the current timestamp. + * + * @return $this + */ + public function setLastCheckToNow() { + $this->lazyLoad(); + $this->lastCheck = time(); + return $this; + } + + /** + * @return null|Update + */ + public function getUpdate() { + $this->lazyLoad(); + return $this->update; + } + + /** + * @param Update|null $update + * @return $this + */ + public function setUpdate(Update $update = null) { + $this->lazyLoad(); + $this->update = $update; + return $this; + } + + /** + * @return string + */ + public function getCheckedVersion() { + $this->lazyLoad(); + return $this->checkedVersion; + } + + /** + * @param string $version + * @return $this + */ + public function setCheckedVersion($version) { + $this->lazyLoad(); + $this->checkedVersion = strval($version); + return $this; + } + + /** + * Get translation updates. + * + * @return array + */ + public function getTranslations() { + $this->lazyLoad(); + if ( isset($this->update, $this->update->translations) ) { + return $this->update->translations; + } + return array(); + } + + /** + * Set translation updates. + * + * @param array $translationUpdates + */ + public function setTranslations($translationUpdates) { + $this->lazyLoad(); + if ( isset($this->update) ) { + $this->update->translations = $translationUpdates; + $this->save(); + } + } + + public function save() { + $state = new \stdClass(); + + $state->lastCheck = $this->lastCheck; + $state->checkedVersion = $this->checkedVersion; + + if ( isset($this->update)) { + $state->update = $this->update->toStdClass(); + + $updateClass = get_class($this->update); + $state->updateClass = $updateClass; + $prefix = $this->getLibPrefix(); + if ( Utils::startsWith($updateClass, $prefix) ) { + $state->updateBaseClass = substr($updateClass, strlen($prefix)); + } + } + + update_site_option($this->optionName, $state); + $this->isLoaded = true; + } + + /** + * @return $this + */ + public function lazyLoad() { + if ( !$this->isLoaded ) { + $this->load(); + } + return $this; + } + + protected function load() { + $this->isLoaded = true; + + $state = get_site_option($this->optionName, null); + + if ( + !is_object($state) + //Sanity check: If the Utils class is missing, the plugin is probably in the process + //of being deleted (e.g. the old version gets deleted during an update). + || !class_exists(Utils::class) + ) { + $this->lastCheck = 0; + $this->checkedVersion = ''; + $this->update = null; + return; + } + + $this->lastCheck = intval(Utils::get($state, 'lastCheck', 0)); + $this->checkedVersion = Utils::get($state, 'checkedVersion', ''); + $this->update = null; + + if ( isset($state->update) ) { + //This mess is due to the fact that the want the update class from this version + //of the library, not the version that saved the update. + + $updateClass = null; + if ( isset($state->updateBaseClass) ) { + $updateClass = $this->getLibPrefix() . $state->updateBaseClass; + } else if ( isset($state->updateClass) ) { + $updateClass = $state->updateClass; + } + + $factory = array($updateClass, 'fromObject'); + if ( ($updateClass !== null) && is_callable($factory) ) { + $this->update = call_user_func($factory, $state->update); + } + } + } + + public function delete() { + delete_site_option($this->optionName); + + $this->lastCheck = 0; + $this->checkedVersion = ''; + $this->update = null; + } + + private function getLibPrefix() { + //This assumes that the current class is at the top of the versioned namespace. + return __NAMESPACE__ . '\\'; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Theme/Package.php b/includes/plugin-update-checker/Puc/v5p4/Theme/Package.php new file mode 100644 index 0000000..0b20702 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Theme/Package.php @@ -0,0 +1,69 @@ +stylesheet = $stylesheet; + $this->theme = wp_get_theme($this->stylesheet); + + parent::__construct($updateChecker); + } + + public function getInstalledVersion() { + return $this->theme->get('Version'); + } + + public function getAbsoluteDirectoryPath() { + if ( method_exists($this->theme, 'get_stylesheet_directory') ) { + return $this->theme->get_stylesheet_directory(); //Available since WP 3.4. + } + return get_theme_root($this->stylesheet) . '/' . $this->stylesheet; + } + + /** + * Get the value of a specific plugin or theme header. + * + * @param string $headerName + * @param string $defaultValue + * @return string Either the value of the header, or $defaultValue if the header doesn't exist or is empty. + */ + public function getHeaderValue($headerName, $defaultValue = '') { + $value = $this->theme->get($headerName); + if ( ($headerName === false) || ($headerName === '') ) { + return $defaultValue; + } + return $value; + } + + protected function getHeaderNames() { + return array( + 'Name' => 'Theme Name', + 'ThemeURI' => 'Theme URI', + 'Description' => 'Description', + 'Author' => 'Author', + 'AuthorURI' => 'Author URI', + 'Version' => 'Version', + 'Template' => 'Template', + 'Status' => 'Status', + 'Tags' => 'Tags', + 'TextDomain' => 'Text Domain', + 'DomainPath' => 'Domain Path', + ); + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Theme/Update.php b/includes/plugin-update-checker/Puc/v5p4/Theme/Update.php new file mode 100644 index 0000000..0a69fd6 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Theme/Update.php @@ -0,0 +1,88 @@ + $this->slug, + 'new_version' => $this->version, + 'url' => $this->details_url, + ); + + if ( !empty($this->download_url) ) { + $update['package'] = $this->download_url; + } + + return $update; + } + + /** + * Create a new instance of Theme_Update from its JSON-encoded representation. + * + * @param string $json Valid JSON string representing a theme information object. + * @return self New instance of ThemeUpdate, or NULL on error. + */ + public static function fromJson($json) { + $instance = new self(); + if ( !parent::createFromJson($json, $instance) ) { + return null; + } + return $instance; + } + + /** + * Create a new instance by copying the necessary fields from another object. + * + * @param \StdClass|self $object The source object. + * @return self The new copy. + */ + public static function fromObject($object) { + $update = new self(); + $update->copyFields($object, $update); + return $update; + } + + /** + * Basic validation. + * + * @param \StdClass $apiResponse + * @return bool|\WP_Error + */ + protected function validateMetadata($apiResponse) { + $required = array('version', 'details_url'); + foreach($required as $key) { + if ( !isset($apiResponse->$key) || empty($apiResponse->$key) ) { + return new \WP_Error( + 'tuc-invalid-metadata', + sprintf('The theme metadata is missing the required "%s" key.', $key) + ); + } + } + return true; + } + + protected function getFieldNames() { + return array_merge(parent::getFieldNames(), self::$extraFields); + } + + protected function getPrefixedFilter($tag) { + return parent::getPrefixedFilter($tag) . '_theme'; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Theme/UpdateChecker.php b/includes/plugin-update-checker/Puc/v5p4/Theme/UpdateChecker.php new file mode 100644 index 0000000..80481e6 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Theme/UpdateChecker.php @@ -0,0 +1,159 @@ +stylesheet = $stylesheet; + + parent::__construct( + $metadataUrl, + $stylesheet, + $customSlug ? $customSlug : $stylesheet, + $checkPeriod, + $optionName + ); + } + + /** + * For themes, the update array is indexed by theme directory name. + * + * @return string + */ + protected function getUpdateListKey() { + return $this->directoryName; + } + + /** + * Retrieve the latest update (if any) from the configured API endpoint. + * + * @return Update|null An instance of Update, or NULL when no updates are available. + */ + public function requestUpdate() { + list($themeUpdate, $result) = $this->requestMetadata(Update::class, 'request_update'); + + if ( $themeUpdate !== null ) { + /** @var Update $themeUpdate */ + $themeUpdate->slug = $this->slug; + } + + $themeUpdate = $this->filterUpdateResult($themeUpdate, $result); + return $themeUpdate; + } + + protected function getNoUpdateItemFields() { + return array_merge( + parent::getNoUpdateItemFields(), + array( + 'theme' => $this->directoryName, + 'requires' => '', + ) + ); + } + + public function userCanInstallUpdates() { + return current_user_can('update_themes'); + } + + /** + * Create an instance of the scheduler. + * + * @param int $checkPeriod + * @return Scheduler + */ + protected function createScheduler($checkPeriod) { + return new Scheduler($this, $checkPeriod, array('load-themes.php')); + } + + /** + * Is there an update being installed right now for this theme? + * + * @param \WP_Upgrader|null $upgrader The upgrader that's performing the current update. + * @return bool + */ + public function isBeingUpgraded($upgrader = null) { + return $this->upgraderStatus->isThemeBeingUpgraded($this->stylesheet, $upgrader); + } + + protected function createDebugBarExtension() { + return new DebugBar\Extension($this, DebugBar\ThemePanel::class); + } + + /** + * Register a callback for filtering query arguments. + * + * The callback function should take one argument - an associative array of query arguments. + * It should return a modified array of query arguments. + * + * @param callable $callback + * @return void + */ + public function addQueryArgFilter($callback){ + $this->addFilter('request_update_query_args', $callback); + } + + /** + * Register a callback for filtering arguments passed to wp_remote_get(). + * + * The callback function should take one argument - an associative array of arguments - + * and return a modified array or arguments. See the WP documentation on wp_remote_get() + * for details on what arguments are available and how they work. + * + * @uses add_filter() This method is a convenience wrapper for add_filter(). + * + * @param callable $callback + * @return void + */ + public function addHttpRequestArgFilter($callback) { + $this->addFilter('request_update_options', $callback); + } + + /** + * Register a callback for filtering theme updates retrieved from the external API. + * + * The callback function should take two arguments. If the theme update was retrieved + * successfully, the first argument passed will be an instance of Theme_Update. Otherwise, + * it will be NULL. The second argument will be the corresponding return value of + * wp_remote_get (see WP docs for details). + * + * The callback function should return a new or modified instance of Theme_Update or NULL. + * + * @uses add_filter() This method is a convenience wrapper for add_filter(). + * + * @param callable $callback + * @return void + */ + public function addResultFilter($callback) { + $this->addFilter('request_update_result', $callback, 10, 2); + } + + /** + * Create a package instance that represents this plugin or theme. + * + * @return InstalledPackage + */ + protected function createInstalledPackage() { + return new Package($this->stylesheet, $this); + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Update.php b/includes/plugin-update-checker/Puc/v5p4/Update.php new file mode 100644 index 0000000..6c58510 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Update.php @@ -0,0 +1,38 @@ +slug = $this->slug; + $update->new_version = $this->version; + $update->package = $this->download_url; + + return $update; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/UpdateChecker.php b/includes/plugin-update-checker/Puc/v5p4/UpdateChecker.php new file mode 100644 index 0000000..8833547 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/UpdateChecker.php @@ -0,0 +1,1029 @@ +debugMode = (bool)(constant('WP_DEBUG')); + $this->metadataUrl = $metadataUrl; + $this->directoryName = $directoryName; + $this->slug = !empty($slug) ? $slug : $this->directoryName; + + $this->optionName = $optionName; + if ( empty($this->optionName) ) { + //BC: Initially the library only supported plugin updates and didn't use type prefixes + //in the option name. Lets use the same prefix-less name when possible. + if ( $this->filterSuffix === '' ) { + $this->optionName = 'external_updates-' . $this->slug; + } else { + $this->optionName = $this->getUniqueName('external_updates'); + } + } + + if ( empty($this->translationType) ) { + $this->translationType = $this->componentType; + } + + $this->package = $this->createInstalledPackage(); + $this->scheduler = $this->createScheduler($checkPeriod); + $this->upgraderStatus = new UpgraderStatus(); + $this->updateState = new StateStore($this->optionName); + + if ( did_action('init') ) { + $this->loadTextDomain(); + } else { + add_action('init', array($this, 'loadTextDomain')); + } + + $this->installHooks(); + + if ( ($this->wpCliCheckTrigger === null) && defined('WP_CLI') ) { + $this->wpCliCheckTrigger = new WpCliCheckTrigger($this->componentType, $this->scheduler); + } + } + + /** + * @internal + */ + public function loadTextDomain() { + //We're not using load_plugin_textdomain() or its siblings because figuring out where + //the library is located (plugin, mu-plugin, theme, custom wp-content paths) is messy. + $domain = 'plugin-update-checker'; + $locale = apply_filters( + 'plugin_locale', + (is_admin() && function_exists('get_user_locale')) ? get_user_locale() : get_locale(), + $domain + ); + + $moFile = $domain . '-' . $locale . '.mo'; + $path = realpath(dirname(__FILE__) . '/../../languages'); + + if ($path && file_exists($path)) { + load_textdomain($domain, $path . '/' . $moFile); + } + } + + protected function installHooks() { + //Insert our update info into the update array maintained by WP. + add_filter('site_transient_' . $this->updateTransient, array($this,'injectUpdate')); + + //Insert translation updates into the update list. + add_filter('site_transient_' . $this->updateTransient, array($this, 'injectTranslationUpdates')); + + //Clear translation updates when WP clears the update cache. + //This needs to be done directly because the library doesn't actually remove obsolete plugin updates, + //it just hides them (see getUpdate()). We can't do that with translations - too much disk I/O. + add_action( + 'delete_site_transient_' . $this->updateTransient, + array($this, 'clearCachedTranslationUpdates') + ); + + //Rename the update directory to be the same as the existing directory. + if ( $this->directoryName !== '.' ) { + add_filter('upgrader_source_selection', array($this, 'fixDirectoryName'), 10, 3); + } + + //Allow HTTP requests to the metadata URL even if it's on a local host. + add_filter('http_request_host_is_external', array($this, 'allowMetadataHost'), 10, 2); + + //DebugBar integration. + if ( did_action('plugins_loaded') ) { + $this->maybeInitDebugBar(); + } else { + add_action('plugins_loaded', array($this, 'maybeInitDebugBar')); + } + } + + /** + * Remove hooks that were added by this update checker instance. + */ + public function removeHooks() { + remove_filter('site_transient_' . $this->updateTransient, array($this,'injectUpdate')); + remove_filter('site_transient_' . $this->updateTransient, array($this, 'injectTranslationUpdates')); + remove_action( + 'delete_site_transient_' . $this->updateTransient, + array($this, 'clearCachedTranslationUpdates') + ); + + remove_filter('upgrader_source_selection', array($this, 'fixDirectoryName'), 10); + remove_filter('http_request_host_is_external', array($this, 'allowMetadataHost'), 10); + remove_action('plugins_loaded', array($this, 'maybeInitDebugBar')); + + remove_action('init', array($this, 'loadTextDomain')); + + if ( $this->scheduler ) { + $this->scheduler->removeHooks(); + } + + if ( $this->debugBarExtension ) { + $this->debugBarExtension->removeHooks(); + } + } + + /** + * Check if the current user has the required permissions to install updates. + * + * @return bool + */ + abstract public function userCanInstallUpdates(); + + /** + * Explicitly allow HTTP requests to the metadata URL. + * + * WordPress has a security feature where the HTTP API will reject all requests that are sent to + * another site hosted on the same server as the current site (IP match), a local host, or a local + * IP, unless the host exactly matches the current site. + * + * This feature is opt-in (at least in WP 4.4). Apparently some people enable it. + * + * That can be a problem when you're developing your plugin and you decide to host the update information + * on the same server as your test site. Update requests will mysteriously fail. + * + * We fix that by adding an exception for the metadata host. + * + * @param bool $allow + * @param string $host + * @return bool + */ + public function allowMetadataHost($allow, $host) { + if ( $this->cachedMetadataHost === 0 ) { + $this->cachedMetadataHost = wp_parse_url($this->metadataUrl, PHP_URL_HOST); + } + + if ( is_string($this->cachedMetadataHost) && (strtolower($host) === strtolower($this->cachedMetadataHost)) ) { + return true; + } + return $allow; + } + + /** + * Create a package instance that represents this plugin or theme. + * + * @return InstalledPackage + */ + abstract protected function createInstalledPackage(); + + /** + * @return InstalledPackage + */ + public function getInstalledPackage() { + return $this->package; + } + + /** + * Create an instance of the scheduler. + * + * This is implemented as a method to make it possible for plugins to subclass the update checker + * and substitute their own scheduler. + * + * @param int $checkPeriod + * @return Scheduler + */ + abstract protected function createScheduler($checkPeriod); + + /** + * Check for updates. The results are stored in the DB option specified in $optionName. + * + * @return Update|null + */ + public function checkForUpdates() { + $installedVersion = $this->getInstalledVersion(); + //Fail silently if we can't find the plugin/theme or read its header. + if ( $installedVersion === null ) { + $this->triggerError( + sprintf('Skipping update check for %s - installed version unknown.', $this->slug), + E_USER_WARNING + ); + return null; + } + + //Start collecting API errors. + $this->lastRequestApiErrors = array(); + add_action('puc_api_error', array($this, 'collectApiErrors'), 10, 4); + + $state = $this->updateState; + $state->setLastCheckToNow() + ->setCheckedVersion($installedVersion) + ->save(); //Save before checking in case something goes wrong + + $state->setUpdate($this->requestUpdate()); + $state->save(); + + //Stop collecting API errors. + remove_action('puc_api_error', array($this, 'collectApiErrors'), 10); + + return $this->getUpdate(); + } + + /** + * Load the update checker state from the DB. + * + * @return StateStore + */ + public function getUpdateState() { + return $this->updateState->lazyLoad(); + } + + /** + * Reset update checker state - i.e. last check time, cached update data and so on. + * + * Call this when your plugin is being uninstalled, or if you want to + * clear the update cache. + */ + public function resetUpdateState() { + $this->updateState->delete(); + } + + /** + * Get the details of the currently available update, if any. + * + * If no updates are available, or if the last known update version is below or equal + * to the currently installed version, this method will return NULL. + * + * Uses cached update data. To retrieve update information straight from + * the metadata URL, call requestUpdate() instead. + * + * @return Update|null + */ + public function getUpdate() { + $update = $this->updateState->getUpdate(); + + //Is there an update available? + if ( isset($update) ) { + //Check if the update is actually newer than the currently installed version. + $installedVersion = $this->getInstalledVersion(); + if ( ($installedVersion !== null) && version_compare($update->version, $installedVersion, '>') ){ + return $update; + } + } + return null; + } + + /** + * Retrieve the latest update (if any) from the configured API endpoint. + * + * Subclasses should run the update through filterUpdateResult before returning it. + * + * @return Update An instance of Update, or NULL when no updates are available. + */ + abstract public function requestUpdate(); + + /** + * Filter the result of a requestUpdate() call. + * + * @template T of Update + * @param T|null $update + * @param array|WP_Error|null $httpResult The value returned by wp_remote_get(), if any. + * @return T + */ + protected function filterUpdateResult($update, $httpResult = null) { + //Let plugins/themes modify the update. + $update = apply_filters($this->getUniqueName('request_update_result'), $update, $httpResult); + + $this->fixSupportedWordpressVersion($update); + + if ( isset($update, $update->translations) ) { + //Keep only those translation updates that apply to this site. + $update->translations = $this->filterApplicableTranslations($update->translations); + } + + return $update; + } + + /** + * The "Tested up to" field in the plugin metadata is supposed to be in the form of "major.minor", + * while WordPress core's list_plugin_updates() expects the $update->tested field to be an exact + * version, e.g. "major.minor.patch", to say it's compatible. In other case it shows + * "Compatibility: Unknown". + * The function mimics how wordpress.org API crafts the "tested" field out of "Tested up to". + * + * @param Metadata|null $update + */ + protected function fixSupportedWordpressVersion(Metadata $update = null) { + if ( !isset($update->tested) || !preg_match('/^\d++\.\d++$/', $update->tested) ) { + return; + } + + $actualWpVersions = array(); + + $wpVersion = $GLOBALS['wp_version']; + + if ( function_exists('get_core_updates') ) { + $coreUpdates = get_core_updates(); + if ( is_array($coreUpdates) ) { + foreach ($coreUpdates as $coreUpdate) { + if ( isset($coreUpdate->current) ) { + $actualWpVersions[] = $coreUpdate->current; + } + } + } + } + + $actualWpVersions[] = $wpVersion; + + $actualWpPatchNumber = null; + foreach ($actualWpVersions as $version) { + if ( preg_match('/^(?P\d++\.\d++)(?:\.(?P\d++))?/', $version, $versionParts) ) { + if ( $versionParts['majorMinor'] === $update->tested ) { + $patch = isset($versionParts['patch']) ? intval($versionParts['patch']) : 0; + if ( $actualWpPatchNumber === null ) { + $actualWpPatchNumber = $patch; + } else { + $actualWpPatchNumber = max($actualWpPatchNumber, $patch); + } + } + } + } + if ( $actualWpPatchNumber === null ) { + $actualWpPatchNumber = 999; + } + + if ( $actualWpPatchNumber > 0 ) { + $update->tested .= '.' . $actualWpPatchNumber; + } + } + + /** + * Get the currently installed version of the plugin or theme. + * + * @return string|null Version number. + */ + public function getInstalledVersion() { + return $this->package->getInstalledVersion(); + } + + /** + * Get the full path of the plugin or theme directory. + * + * @return string + */ + public function getAbsoluteDirectoryPath() { + return $this->package->getAbsoluteDirectoryPath(); + } + + /** + * Trigger a PHP error, but only when $debugMode is enabled. + * + * @param string $message + * @param int $errorType + */ + public function triggerError($message, $errorType) { + if ( $this->isDebugModeEnabled() ) { + //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- Only happens in debug mode. + trigger_error(esc_html($message), $errorType); + } + } + + /** + * @return bool + */ + protected function isDebugModeEnabled() { + if ( $this->debugMode === null ) { + $this->debugMode = (bool)(constant('WP_DEBUG')); + } + return $this->debugMode; + } + + /** + * Get the full name of an update checker filter, action or DB entry. + * + * This method adds the "puc_" prefix and the "-$slug" suffix to the filter name. + * For example, "pre_inject_update" becomes "puc_pre_inject_update-plugin-slug". + * + * @param string $baseTag + * @return string + */ + public function getUniqueName($baseTag) { + $name = 'puc_' . $baseTag; + if ( $this->filterSuffix !== '' ) { + $name .= '_' . $this->filterSuffix; + } + return $name . '-' . $this->slug; + } + + /** + * Store API errors that are generated when checking for updates. + * + * @internal + * @param \WP_Error $error + * @param array|null $httpResponse + * @param string|null $url + * @param string|null $slug + */ + public function collectApiErrors($error, $httpResponse = null, $url = null, $slug = null) { + if ( isset($slug) && ($slug !== $this->slug) ) { + return; + } + + $this->lastRequestApiErrors[] = array( + 'error' => $error, + 'httpResponse' => $httpResponse, + 'url' => $url, + ); + } + + /** + * @return array + */ + public function getLastRequestApiErrors() { + return $this->lastRequestApiErrors; + } + + /* ------------------------------------------------------------------- + * PUC filters and filter utilities + * ------------------------------------------------------------------- + */ + + /** + * Register a callback for one of the update checker filters. + * + * Identical to add_filter(), except it automatically adds the "puc_" prefix + * and the "-$slug" suffix to the filter name. For example, "request_info_result" + * becomes "puc_request_info_result-your_plugin_slug". + * + * @param string $tag + * @param callable $callback + * @param int $priority + * @param int $acceptedArgs + */ + public function addFilter($tag, $callback, $priority = 10, $acceptedArgs = 1) { + add_filter($this->getUniqueName($tag), $callback, $priority, $acceptedArgs); + } + + /* ------------------------------------------------------------------- + * Inject updates + * ------------------------------------------------------------------- + */ + + /** + * Insert the latest update (if any) into the update list maintained by WP. + * + * @param \stdClass $updates Update list. + * @return \stdClass Modified update list. + */ + public function injectUpdate($updates) { + //Is there an update to insert? + $update = $this->getUpdate(); + + if ( !$this->shouldShowUpdates() ) { + $update = null; + } + + if ( !empty($update) ) { + //Let plugins filter the update info before it's passed on to WordPress. + $update = apply_filters($this->getUniqueName('pre_inject_update'), $update); + $updates = $this->addUpdateToList($updates, $update->toWpFormat()); + } else { + //Clean up any stale update info. + $updates = $this->removeUpdateFromList($updates); + //Add a placeholder item to the "no_update" list to enable auto-update support. + //If we don't do this, the option to enable automatic updates will only show up + //when an update is available. + $updates = $this->addNoUpdateItem($updates); + } + + return $updates; + } + + /** + * @param \stdClass|null $updates + * @param \stdClass|array $updateToAdd + * @return \stdClass + */ + protected function addUpdateToList($updates, $updateToAdd) { + if ( !is_object($updates) ) { + $updates = new stdClass(); + $updates->response = array(); + } + + $updates->response[$this->getUpdateListKey()] = $updateToAdd; + return $updates; + } + + /** + * @param \stdClass|null $updates + * @return \stdClass|null + */ + protected function removeUpdateFromList($updates) { + if ( isset($updates, $updates->response) ) { + unset($updates->response[$this->getUpdateListKey()]); + } + return $updates; + } + + /** + * See this post for more information: + * @link https://make.wordpress.org/core/2020/07/30/recommended-usage-of-the-updates-api-to-support-the-auto-updates-ui-for-plugins-and-themes-in-wordpress-5-5/ + * + * @param \stdClass|null $updates + * @return \stdClass + */ + protected function addNoUpdateItem($updates) { + if ( !is_object($updates) ) { + $updates = new stdClass(); + $updates->response = array(); + $updates->no_update = array(); + } else if ( !isset($updates->no_update) ) { + $updates->no_update = array(); + } + + $updates->no_update[$this->getUpdateListKey()] = (object) $this->getNoUpdateItemFields(); + + return $updates; + } + + /** + * Subclasses should override this method to add fields that are specific to plugins or themes. + * @return array + */ + protected function getNoUpdateItemFields() { + return array( + 'new_version' => $this->getInstalledVersion(), + 'url' => '', + 'package' => '', + 'requires_php' => '', + ); + } + + /** + * Get the key that will be used when adding updates to the update list that's maintained + * by the WordPress core. The list is always an associative array, but the key is different + * for plugins and themes. + * + * @return string + */ + abstract protected function getUpdateListKey(); + + /** + * Should we show available updates? + * + * Usually the answer is "yes", but there are exceptions. For example, WordPress doesn't + * support automatic updates installation for mu-plugins, so PUC usually won't show update + * notifications in that case. See the plugin-specific subclass for details. + * + * Note: This method only applies to updates that are displayed (or not) in the WordPress + * admin. It doesn't affect APIs like requestUpdate and getUpdate. + * + * @return bool + */ + protected function shouldShowUpdates() { + return true; + } + + /* ------------------------------------------------------------------- + * JSON-based update API + * ------------------------------------------------------------------- + */ + + /** + * Retrieve plugin or theme metadata from the JSON document at $this->metadataUrl. + * + * @param class-string $metaClass Parse the JSON as an instance of this class. It must have a static fromJson method. + * @param string $filterRoot + * @param array $queryArgs Additional query arguments. + * @return array A metadata instance and the value returned by wp_remote_get(). + */ + protected function requestMetadata($metaClass, $filterRoot, $queryArgs = array()) { + //Query args to append to the URL. Plugins can add their own by using a filter callback (see addQueryArgFilter()). + $queryArgs = array_merge( + array( + 'installed_version' => strval($this->getInstalledVersion()), + 'php' => phpversion(), + 'locale' => get_locale(), + ), + $queryArgs + ); + $queryArgs = apply_filters($this->getUniqueName($filterRoot . '_query_args'), $queryArgs); + + //Various options for the wp_remote_get() call. Plugins can filter these, too. + $options = array( + 'timeout' => wp_doing_cron() ? 10 : 3, + 'headers' => array( + 'Accept' => 'application/json', + ), + ); + $options = apply_filters($this->getUniqueName($filterRoot . '_options'), $options); + + //The metadata file should be at 'http://your-api.com/url/here/$slug/info.json' + $url = $this->metadataUrl; + if ( !empty($queryArgs) ){ + $url = add_query_arg($queryArgs, $url); + } + + $result = wp_remote_get($url, $options); + + $result = apply_filters($this->getUniqueName('request_metadata_http_result'), $result, $url, $options); + + //Try to parse the response + $status = $this->validateApiResponse($result); + $metadata = null; + if ( !is_wp_error($status) ){ + if ( (strpos($metaClass, '\\') === false) ) { + $metaClass = __NAMESPACE__ . '\\' . $metaClass; + } + $metadata = call_user_func(array($metaClass, 'fromJson'), $result['body']); + } else { + do_action('puc_api_error', $status, $result, $url, $this->slug); + $this->triggerError( + sprintf('The URL %s does not point to a valid metadata file. ', $url) + . $status->get_error_message(), + E_USER_WARNING + ); + } + + return array($metadata, $result); + } + + /** + * Check if $result is a successful update API response. + * + * @param array|WP_Error $result + * @return true|WP_Error + */ + protected function validateApiResponse($result) { + if ( is_wp_error($result) ) { /** @var WP_Error $result */ + return new WP_Error($result->get_error_code(), 'WP HTTP Error: ' . $result->get_error_message()); + } + + if ( !isset($result['response']['code']) ) { + return new WP_Error( + 'puc_no_response_code', + 'wp_remote_get() returned an unexpected result.' + ); + } + + if ( $result['response']['code'] !== 200 ) { + return new WP_Error( + 'puc_unexpected_response_code', + 'HTTP response code is ' . $result['response']['code'] . ' (expected: 200)' + ); + } + + if ( empty($result['body']) ) { + return new WP_Error('puc_empty_response', 'The metadata file appears to be empty.'); + } + + return true; + } + + /* ------------------------------------------------------------------- + * Language packs / Translation updates + * ------------------------------------------------------------------- + */ + + /** + * Filter a list of translation updates and return a new list that contains only updates + * that apply to the current site. + * + * @param array $translations + * @return array + */ + protected function filterApplicableTranslations($translations) { + $languages = array_flip(array_values(get_available_languages())); + $installedTranslations = $this->getInstalledTranslations(); + + $applicableTranslations = array(); + foreach ($translations as $translation) { + //Does it match one of the available core languages? + $isApplicable = array_key_exists($translation->language, $languages); + //Is it more recent than an already-installed translation? + if ( isset($installedTranslations[$translation->language]) ) { + $updateTimestamp = strtotime($translation->updated); + $installedTimestamp = strtotime($installedTranslations[$translation->language]['PO-Revision-Date']); + $isApplicable = $updateTimestamp > $installedTimestamp; + } + + if ( $isApplicable ) { + $applicableTranslations[] = $translation; + } + } + + return $applicableTranslations; + } + + /** + * Get a list of installed translations for this plugin or theme. + * + * @return array + */ + protected function getInstalledTranslations() { + if ( !function_exists('wp_get_installed_translations') ) { + return array(); + } + $installedTranslations = wp_get_installed_translations($this->translationType . 's'); + if ( isset($installedTranslations[$this->directoryName]) ) { + $installedTranslations = $installedTranslations[$this->directoryName]; + } else { + $installedTranslations = array(); + } + return $installedTranslations; + } + + /** + * Insert translation updates into the list maintained by WordPress. + * + * @param stdClass $updates + * @return stdClass + */ + public function injectTranslationUpdates($updates) { + $translationUpdates = $this->getTranslationUpdates(); + if ( empty($translationUpdates) ) { + return $updates; + } + + //Being defensive. + if ( !is_object($updates) ) { + $updates = new stdClass(); + } + if ( !isset($updates->translations) ) { + $updates->translations = array(); + } + + //In case there's a name collision with a plugin or theme hosted on wordpress.org, + //remove any preexisting updates that match our thing. + $updates->translations = array_values(array_filter( + $updates->translations, + array($this, 'isNotMyTranslation') + )); + + //Add our updates to the list. + foreach($translationUpdates as $update) { + $convertedUpdate = array_merge( + array( + 'type' => $this->translationType, + 'slug' => $this->directoryName, + 'autoupdate' => 0, + //AFAICT, WordPress doesn't actually use the "version" field for anything. + //But lets make sure it's there, just in case. + 'version' => isset($update->version) ? $update->version : ('1.' . strtotime($update->updated)), + ), + (array)$update + ); + + $updates->translations[] = $convertedUpdate; + } + + return $updates; + } + + /** + * Get a list of available translation updates. + * + * This method will return an empty array if there are no updates. + * Uses cached update data. + * + * @return array + */ + public function getTranslationUpdates() { + return $this->updateState->getTranslations(); + } + + /** + * Remove all cached translation updates. + * + * @see wp_clean_update_cache + */ + public function clearCachedTranslationUpdates() { + $this->updateState->setTranslations(array()); + } + + /** + * Filter callback. Keeps only translations that *don't* match this plugin or theme. + * + * @param array $translation + * @return bool + */ + protected function isNotMyTranslation($translation) { + $isMatch = isset($translation['type'], $translation['slug']) + && ($translation['type'] === $this->translationType) + && ($translation['slug'] === $this->directoryName); + + return !$isMatch; + } + + /* ------------------------------------------------------------------- + * Fix directory name when installing updates + * ------------------------------------------------------------------- + */ + + /** + * Rename the update directory to match the existing plugin/theme directory. + * + * When WordPress installs a plugin or theme update, it assumes that the ZIP file will contain + * exactly one directory, and that the directory name will be the same as the directory where + * the plugin or theme is currently installed. + * + * GitHub and other repositories provide ZIP downloads, but they often use directory names like + * "project-branch" or "project-tag-hash". We need to change the name to the actual plugin folder. + * + * This is a hook callback. Don't call it from a plugin. + * + * @access protected + * + * @param string $source The directory to copy to /wp-content/plugins or /wp-content/themes. Usually a subdirectory of $remoteSource. + * @param string $remoteSource WordPress has extracted the update to this directory. + * @param \WP_Upgrader $upgrader + * @return string|WP_Error + */ + public function fixDirectoryName($source, $remoteSource, $upgrader) { + global $wp_filesystem; + /** @var \WP_Filesystem_Base $wp_filesystem */ + + //Basic sanity checks. + if ( !isset($source, $remoteSource, $upgrader, $upgrader->skin, $wp_filesystem) ) { + return $source; + } + + //If WordPress is upgrading anything other than our plugin/theme, leave the directory name unchanged. + if ( !$this->isBeingUpgraded($upgrader) ) { + return $source; + } + + //Rename the source to match the existing directory. + $correctedSource = trailingslashit($remoteSource) . $this->directoryName . '/'; + if ( $source !== $correctedSource ) { + //The update archive should contain a single directory that contains the rest of plugin/theme files. + //Otherwise, WordPress will try to copy the entire working directory ($source == $remoteSource). + //We can't rename $remoteSource because that would break WordPress code that cleans up temporary files + //after update. + if ( $this->isBadDirectoryStructure($remoteSource) ) { + return new WP_Error( + 'puc-incorrect-directory-structure', + sprintf( + 'The directory structure of the update is incorrect. All files should be inside ' . + 'a directory named %s, not at the root of the ZIP archive.', + htmlentities($this->slug) + ) + ); + } + + /** @var \WP_Upgrader_Skin $upgrader ->skin */ + $upgrader->skin->feedback(sprintf( + 'Renaming %s to %s…', + '' . basename($source) . '', + '' . $this->directoryName . '' + )); + + if ( $wp_filesystem->move($source, $correctedSource, true) ) { + $upgrader->skin->feedback('Directory successfully renamed.'); + return $correctedSource; + } else { + return new WP_Error( + 'puc-rename-failed', + 'Unable to rename the update to match the existing directory.' + ); + } + } + + return $source; + } + + /** + * Is there an update being installed right now, for this plugin or theme? + * + * @param \WP_Upgrader|null $upgrader The upgrader that's performing the current update. + * @return bool + */ + abstract public function isBeingUpgraded($upgrader = null); + + /** + * Check for incorrect update directory structure. An update must contain a single directory, + * all other files should be inside that directory. + * + * @param string $remoteSource Directory path. + * @return bool + */ + protected function isBadDirectoryStructure($remoteSource) { + global $wp_filesystem; + /** @var \WP_Filesystem_Base $wp_filesystem */ + + $sourceFiles = $wp_filesystem->dirlist($remoteSource); + if ( is_array($sourceFiles) ) { + $sourceFiles = array_keys($sourceFiles); + $firstFilePath = trailingslashit($remoteSource) . $sourceFiles[0]; + return (count($sourceFiles) > 1) || (!$wp_filesystem->is_dir($firstFilePath)); + } + + //Assume it's fine. + return false; + } + + /* ------------------------------------------------------------------- + * DebugBar integration + * ------------------------------------------------------------------- + */ + + /** + * Initialize the update checker Debug Bar plugin/add-on thingy. + */ + public function maybeInitDebugBar() { + if ( + class_exists('Debug_Bar', false) + && class_exists('Debug_Bar_Panel', false) + && file_exists(dirname(__FILE__) . '/DebugBar') + ) { + $this->debugBarExtension = $this->createDebugBarExtension(); + } + } + + protected function createDebugBarExtension() { + return new DebugBar\Extension($this); + } + + /** + * Display additional configuration details in the Debug Bar panel. + * + * @param DebugBar\Panel $panel + */ + public function onDisplayConfiguration($panel) { + //Do nothing. Subclasses can use this to add additional info to the panel. + } + + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/UpgraderStatus.php b/includes/plugin-update-checker/Puc/v5p4/UpgraderStatus.php new file mode 100644 index 0000000..e8340fd --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/UpgraderStatus.php @@ -0,0 +1,200 @@ +isBeingUpgraded('plugin', $pluginFile, $upgrader); + } + + /** + * Is there an update being installed for a specific theme? + * + * @param string $stylesheet Theme directory name. + * @param \WP_Upgrader|null $upgrader The upgrader that's performing the current update. + * @return bool + */ + public function isThemeBeingUpgraded($stylesheet, $upgrader = null) { + return $this->isBeingUpgraded('theme', $stylesheet, $upgrader); + } + + /** + * Check if a specific theme or plugin is being upgraded. + * + * @param string $type + * @param string $id + * @param \Plugin_Upgrader|\WP_Upgrader|null $upgrader + * @return bool + */ + protected function isBeingUpgraded($type, $id, $upgrader = null) { + if ( isset($upgrader) ) { + list($currentType, $currentId) = $this->getThingBeingUpgradedBy($upgrader); + if ( $currentType !== null ) { + $this->currentType = $currentType; + $this->currentId = $currentId; + } + } + return ($this->currentType === $type) && ($this->currentId === $id); + } + + /** + * Figure out which theme or plugin is being upgraded by a WP_Upgrader instance. + * + * Returns an array with two items. The first item is the type of the thing that's being + * upgraded: "plugin" or "theme". The second item is either the plugin basename or + * the theme directory name. If we can't determine what the upgrader is doing, both items + * will be NULL. + * + * Examples: + * ['plugin', 'plugin-dir-name/plugin.php'] + * ['theme', 'theme-dir-name'] + * + * @param \Plugin_Upgrader|\WP_Upgrader $upgrader + * @return array + */ + private function getThingBeingUpgradedBy($upgrader) { + if ( !isset($upgrader, $upgrader->skin) ) { + return array(null, null); + } + + //Figure out which plugin or theme is being upgraded. + $pluginFile = null; + $themeDirectoryName = null; + + $skin = $upgrader->skin; + if ( isset($skin->theme_info) && ($skin->theme_info instanceof \WP_Theme) ) { + $themeDirectoryName = $skin->theme_info->get_stylesheet(); + } elseif ( $skin instanceof \Plugin_Upgrader_Skin ) { + if ( isset($skin->plugin) && is_string($skin->plugin) && ($skin->plugin !== '') ) { + $pluginFile = $skin->plugin; + } + } elseif ( $skin instanceof \Theme_Upgrader_Skin ) { + if ( isset($skin->theme) && is_string($skin->theme) && ($skin->theme !== '') ) { + $themeDirectoryName = $skin->theme; + } + } elseif ( isset($skin->plugin_info) && is_array($skin->plugin_info) ) { + //This case is tricky because Bulk_Plugin_Upgrader_Skin (etc) doesn't actually store the plugin + //filename anywhere. Instead, it has the plugin headers in $plugin_info. So the best we can + //do is compare those headers to the headers of installed plugins. + $pluginFile = $this->identifyPluginByHeaders($skin->plugin_info); + } + + if ( $pluginFile !== null ) { + return array('plugin', $pluginFile); + } elseif ( $themeDirectoryName !== null ) { + return array('theme', $themeDirectoryName); + } + return array(null, null); + } + + /** + * Identify an installed plugin based on its headers. + * + * @param array $searchHeaders The plugin file header to look for. + * @return string|null Plugin basename ("foo/bar.php"), or NULL if we can't identify the plugin. + */ + private function identifyPluginByHeaders($searchHeaders) { + if ( !function_exists('get_plugins') ){ + require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); + } + + $installedPlugins = get_plugins(); + $matches = array(); + foreach($installedPlugins as $pluginBasename => $headers) { + $diff1 = array_diff_assoc($headers, $searchHeaders); + $diff2 = array_diff_assoc($searchHeaders, $headers); + if ( empty($diff1) && empty($diff2) ) { + $matches[] = $pluginBasename; + } + } + + //It's possible (though very unlikely) that there could be two plugins with identical + //headers. In that case, we can't unambiguously identify the plugin that's being upgraded. + if ( count($matches) !== 1 ) { + return null; + } + + return reset($matches); + } + + /** + * @access private + * + * @param mixed $input + * @param array $hookExtra + * @return mixed Returns $input unaltered. + */ + public function setUpgradedThing($input, $hookExtra) { + if ( !empty($hookExtra['plugin']) && is_string($hookExtra['plugin']) ) { + $this->currentId = $hookExtra['plugin']; + $this->currentType = 'plugin'; + } elseif ( !empty($hookExtra['theme']) && is_string($hookExtra['theme']) ) { + $this->currentId = $hookExtra['theme']; + $this->currentType = 'theme'; + } else { + $this->currentType = null; + $this->currentId = null; + } + return $input; + } + + /** + * @access private + * + * @param array $options + * @return array + */ + public function setUpgradedPluginFromOptions($options) { + if ( isset($options['hook_extra']['plugin']) && is_string($options['hook_extra']['plugin']) ) { + $this->currentType = 'plugin'; + $this->currentId = $options['hook_extra']['plugin']; + } else { + $this->currentType = null; + $this->currentId = null; + } + return $options; + } + + /** + * @access private + * + * @param mixed $input + * @return mixed Returns $input unaltered. + */ + public function clearUpgradedThing($input = null) { + $this->currentId = null; + $this->currentType = null; + return $input; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Utils.php b/includes/plugin-update-checker/Puc/v5p4/Utils.php new file mode 100644 index 0000000..2130996 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Utils.php @@ -0,0 +1,70 @@ +$node) ) { + $currentValue = $currentValue->$node; + } else { + return $default; + } + } + + return $currentValue; + } + + /** + * Get the first array element that is not empty. + * + * @param array $values + * @param mixed|null $default Returns this value if there are no non-empty elements. + * @return mixed|null + */ + public static function findNotEmpty($values, $default = null) { + if ( empty($values) ) { + return $default; + } + + foreach ($values as $value) { + if ( !empty($value) ) { + return $value; + } + } + + return $default; + } + + /** + * Check if the input string starts with the specified prefix. + * + * @param string $input + * @param string $prefix + * @return bool + */ + public static function startsWith($input, $prefix) { + $length = strlen($prefix); + return (substr($input, 0, $length) === $prefix); + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Vcs/Api.php b/includes/plugin-update-checker/Puc/v5p4/Vcs/Api.php new file mode 100644 index 0000000..715f1de --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Vcs/Api.php @@ -0,0 +1,379 @@ +repositoryUrl = $repositoryUrl; + $this->setAuthentication($credentials); + } + + /** + * @return string + */ + public function getRepositoryUrl() { + return $this->repositoryUrl; + } + + /** + * Figure out which reference (i.e. tag or branch) contains the latest version. + * + * @param string $configBranch Start looking in this branch. + * @return null|Reference + */ + public function chooseReference($configBranch) { + $strategies = $this->getUpdateDetectionStrategies($configBranch); + + if ( !empty($this->strategyFilterName) ) { + $strategies = apply_filters( + $this->strategyFilterName, + $strategies, + $this->slug + ); + } + + foreach ($strategies as $strategy) { + $reference = call_user_func($strategy); + if ( !empty($reference) ) { + return $reference; + } + } + return null; + } + + /** + * Get an ordered list of strategies that can be used to find the latest version. + * + * The update checker will try each strategy in order until one of them + * returns a valid reference. + * + * @param string $configBranch + * @return array Array of callables that return Vcs_Reference objects. + */ + abstract protected function getUpdateDetectionStrategies($configBranch); + + /** + * Get the readme.txt file from the remote repository and parse it + * according to the plugin readme standard. + * + * @param string $ref Tag or branch name. + * @return array Parsed readme. + */ + public function getRemoteReadme($ref = 'master') { + $fileContents = $this->getRemoteFile($this->getLocalReadmeName(), $ref); + if ( empty($fileContents) ) { + return array(); + } + + $parser = new PucReadmeParser(); + return $parser->parse_readme_contents($fileContents); + } + + /** + * Get the case-sensitive name of the local readme.txt file. + * + * In most cases it should just be called "readme.txt", but some plugins call it "README.txt", + * "README.TXT", or even "Readme.txt". Most VCS are case-sensitive so we need to know the correct + * capitalization. + * + * Defaults to "readme.txt" (all lowercase). + * + * @return string + */ + public function getLocalReadmeName() { + static $fileName = null; + if ( $fileName !== null ) { + return $fileName; + } + + $fileName = 'readme.txt'; + if ( isset($this->localDirectory) ) { + $files = scandir($this->localDirectory); + if ( !empty($files) ) { + foreach ($files as $possibleFileName) { + if ( strcasecmp($possibleFileName, 'readme.txt') === 0 ) { + $fileName = $possibleFileName; + break; + } + } + } + } + return $fileName; + } + + /** + * Get a branch. + * + * @param string $branchName + * @return Reference|null + */ + abstract public function getBranch($branchName); + + /** + * Get a specific tag. + * + * @param string $tagName + * @return Reference|null + */ + abstract public function getTag($tagName); + + /** + * Get the tag that looks like the highest version number. + * (Implementations should skip pre-release versions if possible.) + * + * @return Reference|null + */ + abstract public function getLatestTag(); + + /** + * Check if a tag name string looks like a version number. + * + * @param string $name + * @return bool + */ + protected function looksLikeVersion($name) { + //Tag names may be prefixed with "v", e.g. "v1.2.3". + $name = ltrim($name, 'v'); + + //The version string must start with a number. + if ( !is_numeric(substr($name, 0, 1)) ) { + return false; + } + + //The goal is to accept any SemVer-compatible or "PHP-standardized" version number. + return (preg_match('@^(\d{1,5}?)(\.\d{1,10}?){0,4}?($|[abrdp+_\-]|\s)@i', $name) === 1); + } + + /** + * Check if a tag appears to be named like a version number. + * + * @param \stdClass $tag + * @return bool + */ + protected function isVersionTag($tag) { + $property = $this->tagNameProperty; + return isset($tag->$property) && $this->looksLikeVersion($tag->$property); + } + + /** + * Sort a list of tags as if they were version numbers. + * Tags that don't look like version number will be removed. + * + * @param \stdClass[] $tags Array of tag objects. + * @return \stdClass[] Filtered array of tags sorted in descending order. + */ + protected function sortTagsByVersion($tags) { + //Keep only those tags that look like version numbers. + $versionTags = array_filter($tags, array($this, 'isVersionTag')); + //Sort them in descending order. + usort($versionTags, array($this, 'compareTagNames')); + + return $versionTags; + } + + /** + * Compare two tags as if they were version number. + * + * @param \stdClass $tag1 Tag object. + * @param \stdClass $tag2 Another tag object. + * @return int + */ + protected function compareTagNames($tag1, $tag2) { + $property = $this->tagNameProperty; + if ( !isset($tag1->$property) ) { + return 1; + } + if ( !isset($tag2->$property) ) { + return -1; + } + return -version_compare(ltrim($tag1->$property, 'v'), ltrim($tag2->$property, 'v')); + } + + /** + * Get the contents of a file from a specific branch or tag. + * + * @param string $path File name. + * @param string $ref + * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error. + */ + abstract public function getRemoteFile($path, $ref = 'master'); + + /** + * Get the timestamp of the latest commit that changed the specified branch or tag. + * + * @param string $ref Reference name (e.g. branch or tag). + * @return string|null + */ + abstract public function getLatestCommitTime($ref); + + /** + * Get the contents of the changelog file from the repository. + * + * @param string $ref + * @param string $localDirectory Full path to the local plugin or theme directory. + * @return null|string The HTML contents of the changelog. + */ + public function getRemoteChangelog($ref, $localDirectory) { + $filename = $this->findChangelogName($localDirectory); + if ( empty($filename) ) { + return null; + } + + $changelog = $this->getRemoteFile($filename, $ref); + if ( $changelog === null ) { + return null; + } + + return Parsedown::instance()->text($changelog); + } + + /** + * Guess the name of the changelog file. + * + * @param string $directory + * @return string|null + */ + protected function findChangelogName($directory = null) { + if ( !isset($directory) ) { + $directory = $this->localDirectory; + } + if ( empty($directory) || !is_dir($directory) || ($directory === '.') ) { + return null; + } + + $possibleNames = array('CHANGES.md', 'CHANGELOG.md', 'changes.md', 'changelog.md'); + $files = scandir($directory); + $foundNames = array_intersect($possibleNames, $files); + + if ( !empty($foundNames) ) { + return reset($foundNames); + } + return null; + } + + /** + * Set authentication credentials. + * + * @param $credentials + */ + public function setAuthentication($credentials) { + $this->credentials = $credentials; + } + + public function isAuthenticationEnabled() { + return !empty($this->credentials); + } + + /** + * @param string $url + * @return string + */ + public function signDownloadUrl($url) { + return $url; + } + + /** + * @param string $filterName + */ + public function setHttpFilterName($filterName) { + $this->httpFilterName = $filterName; + } + + /** + * @param string $filterName + */ + public function setStrategyFilterName($filterName) { + $this->strategyFilterName = $filterName; + } + + /** + * @param string $directory + */ + public function setLocalDirectory($directory) { + if ( empty($directory) || !is_dir($directory) || ($directory === '.') ) { + $this->localDirectory = null; + } else { + $this->localDirectory = $directory; + } + } + + /** + * @param string $slug + */ + public function setSlug($slug) { + $this->slug = $slug; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Vcs/BaseChecker.php b/includes/plugin-update-checker/Puc/v5p4/Vcs/BaseChecker.php new file mode 100644 index 0000000..78e0dde --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Vcs/BaseChecker.php @@ -0,0 +1,29 @@ +[^/]+?)/(?P[^/#?&]+?)/?$@', $path, $matches) ) { + $this->username = $matches['username']; + $this->repository = $matches['repository']; + } else { + throw new \InvalidArgumentException('Invalid BitBucket repository URL: "' . $repositoryUrl . '"'); + } + + parent::__construct($repositoryUrl, $credentials); + } + + protected function getUpdateDetectionStrategies($configBranch) { + $strategies = array( + self::STRATEGY_STABLE_TAG => function () use ($configBranch) { + return $this->getStableTag($configBranch); + }, + ); + + if ( ($configBranch === 'master' || $configBranch === 'main') ) { + $strategies[self::STRATEGY_LATEST_TAG] = array($this, 'getLatestTag'); + } + + $strategies[self::STRATEGY_BRANCH] = function () use ($configBranch) { + return $this->getBranch($configBranch); + }; + return $strategies; + } + + public function getBranch($branchName) { + $branch = $this->api('/refs/branches/' . $branchName); + if ( is_wp_error($branch) || empty($branch) ) { + return null; + } + + //The "/src/{stuff}/{path}" endpoint doesn't seem to handle branch names that contain slashes. + //If we don't encode the slash, we get a 404. If we encode it as "%2F", we get a 401. + //To avoid issues, if the branch name is not URL-safe, let's use the commit hash instead. + $ref = $branch->name; + if ((urlencode($ref) !== $ref) && isset($branch->target->hash)) { + $ref = $branch->target->hash; + } + + return new Reference(array( + 'name' => $ref, + 'updated' => $branch->target->date, + 'downloadUrl' => $this->getDownloadUrl($branch->name), + )); + } + + /** + * Get a specific tag. + * + * @param string $tagName + * @return Reference|null + */ + public function getTag($tagName) { + $tag = $this->api('/refs/tags/' . $tagName); + if ( is_wp_error($tag) || empty($tag) ) { + return null; + } + + return new Reference(array( + 'name' => $tag->name, + 'version' => ltrim($tag->name, 'v'), + 'updated' => $tag->target->date, + 'downloadUrl' => $this->getDownloadUrl($tag->name), + )); + } + + /** + * Get the tag that looks like the highest version number. + * + * @return Reference|null + */ + public function getLatestTag() { + $tags = $this->api('/refs/tags?sort=-target.date'); + if ( !isset($tags, $tags->values) || !is_array($tags->values) ) { + return null; + } + + //Filter and sort the list of tags. + $versionTags = $this->sortTagsByVersion($tags->values); + + //Return the first result. + if ( !empty($versionTags) ) { + $tag = $versionTags[0]; + return new Reference(array( + 'name' => $tag->name, + 'version' => ltrim($tag->name, 'v'), + 'updated' => $tag->target->date, + 'downloadUrl' => $this->getDownloadUrl($tag->name), + )); + } + return null; + } + + /** + * Get the tag/ref specified by the "Stable tag" header in the readme.txt of a given branch. + * + * @param string $branch + * @return null|Reference + */ + protected function getStableTag($branch) { + $remoteReadme = $this->getRemoteReadme($branch); + if ( !empty($remoteReadme['stable_tag']) ) { + $tag = $remoteReadme['stable_tag']; + + //You can explicitly opt out of using tags by setting "Stable tag" to + //"trunk" or the name of the current branch. + if ( ($tag === $branch) || ($tag === 'trunk') ) { + return $this->getBranch($branch); + } + + return $this->getTag($tag); + } + + return null; + } + + /** + * @param string $ref + * @return string + */ + protected function getDownloadUrl($ref) { + return sprintf( + 'https://bitbucket.org/%s/%s/get/%s.zip', + $this->username, + $this->repository, + $ref + ); + } + + /** + * Get the contents of a file from a specific branch or tag. + * + * @param string $path File name. + * @param string $ref + * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error. + */ + public function getRemoteFile($path, $ref = 'master') { + $response = $this->api('src/' . $ref . '/' . ltrim($path)); + if ( is_wp_error($response) || !is_string($response) ) { + return null; + } + return $response; + } + + /** + * Get the timestamp of the latest commit that changed the specified branch or tag. + * + * @param string $ref Reference name (e.g. branch or tag). + * @return string|null + */ + public function getLatestCommitTime($ref) { + $response = $this->api('commits/' . $ref); + if ( isset($response->values, $response->values[0], $response->values[0]->date) ) { + return $response->values[0]->date; + } + return null; + } + + /** + * Perform a BitBucket API 2.0 request. + * + * @param string $url + * @param string $version + * @return mixed|\WP_Error + */ + public function api($url, $version = '2.0') { + $url = ltrim($url, '/'); + $isSrcResource = Utils::startsWith($url, 'src/'); + + $url = implode('/', array( + 'https://api.bitbucket.org', + $version, + 'repositories', + $this->username, + $this->repository, + $url + )); + $baseUrl = $url; + + if ( $this->oauth ) { + $url = $this->oauth->sign($url,'GET'); + } + + $options = array('timeout' => wp_doing_cron() ? 10 : 3); + if ( !empty($this->httpFilterName) ) { + $options = apply_filters($this->httpFilterName, $options); + } + $response = wp_remote_get($url, $options); + if ( is_wp_error($response) ) { + do_action('puc_api_error', $response, null, $url, $this->slug); + return $response; + } + + $code = wp_remote_retrieve_response_code($response); + $body = wp_remote_retrieve_body($response); + if ( $code === 200 ) { + if ( $isSrcResource ) { + //Most responses are JSON-encoded, but src resources just + //return raw file contents. + $document = $body; + } else { + $document = json_decode($body); + } + return $document; + } + + $error = new \WP_Error( + 'puc-bitbucket-http-error', + sprintf('BitBucket API error. Base URL: "%s", HTTP status code: %d.', $baseUrl, $code) + ); + do_action('puc_api_error', $error, $response, $url, $this->slug); + + return $error; + } + + /** + * @param array $credentials + */ + public function setAuthentication($credentials) { + parent::setAuthentication($credentials); + + if ( !empty($credentials) && !empty($credentials['consumer_key']) ) { + $this->oauth = new OAuthSignature( + $credentials['consumer_key'], + $credentials['consumer_secret'] + ); + } else { + $this->oauth = null; + } + } + + public function signDownloadUrl($url) { + //Add authentication data to download URLs. Since OAuth signatures incorporate + //timestamps, we have to do this immediately before inserting the update. Otherwise, + //authentication could fail due to a stale timestamp. + if ( $this->oauth ) { + $url = $this->oauth->sign($url); + } + return $url; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Vcs/GitHubApi.php b/includes/plugin-update-checker/Puc/v5p4/Vcs/GitHubApi.php new file mode 100644 index 0000000..610d932 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Vcs/GitHubApi.php @@ -0,0 +1,467 @@ +[^/]+?)/(?P[^/#?&]+?)/?$@', $path, $matches) ) { + $this->userName = $matches['username']; + $this->repositoryName = $matches['repository']; + } else { + throw new \InvalidArgumentException('Invalid GitHub repository URL: "' . $repositoryUrl . '"'); + } + + parent::__construct($repositoryUrl, $accessToken); + } + + /** + * Get the latest release from GitHub. + * + * @return Reference|null + */ + public function getLatestRelease() { + //The "latest release" endpoint returns one release and always skips pre-releases, + //so we can only use it if that's compatible with the current filter settings. + if ( + $this->shouldSkipPreReleases() + && ( + ($this->releaseFilterMaxReleases === 1) || !$this->hasCustomReleaseFilter() + ) + ) { + //Just get the latest release. + $release = $this->api('/repos/:user/:repo/releases/latest'); + if ( is_wp_error($release) || !is_object($release) || !isset($release->tag_name) ) { + return null; + } + $foundReleases = array($release); + } else { + //Get a list of the most recent releases. + $foundReleases = $this->api( + '/repos/:user/:repo/releases', + array('per_page' => $this->releaseFilterMaxReleases) + ); + if ( is_wp_error($foundReleases) || !is_array($foundReleases) ) { + return null; + } + } + + foreach ($foundReleases as $release) { + //Always skip drafts. + if ( isset($release->draft) && !empty($release->draft) ) { + continue; + } + + //Skip pre-releases unless specifically included. + if ( + $this->shouldSkipPreReleases() + && isset($release->prerelease) + && !empty($release->prerelease) + ) { + continue; + } + + $versionNumber = ltrim($release->tag_name, 'v'); //Remove the "v" prefix from "v1.2.3". + + //Custom release filtering. + if ( !$this->matchesCustomReleaseFilter($versionNumber, $release) ) { + continue; + } + + $reference = new Reference(array( + 'name' => $release->tag_name, + 'version' => $versionNumber, + 'downloadUrl' => $release->zipball_url, + 'updated' => $release->created_at, + 'apiResponse' => $release, + )); + + if ( isset($release->assets[0]) ) { + $reference->downloadCount = $release->assets[0]->download_count; + } + + if ( $this->releaseAssetsEnabled ) { + //Use the first release asset that matches the specified regular expression. + if ( isset($release->assets, $release->assets[0]) ) { + $matchingAssets = array_values(array_filter($release->assets, array($this, 'matchesAssetFilter'))); + } else { + $matchingAssets = array(); + } + + if ( !empty($matchingAssets) ) { + if ( $this->isAuthenticationEnabled() ) { + /** + * Keep in mind that we'll need to add an "Accept" header to download this asset. + * + * @see setUpdateDownloadHeaders() + */ + $reference->downloadUrl = $matchingAssets[0]->url; + } else { + //It seems that browser_download_url only works for public repositories. + //Using an access_token doesn't help. Maybe OAuth would work? + $reference->downloadUrl = $matchingAssets[0]->browser_download_url; + } + + $reference->downloadCount = $matchingAssets[0]->download_count; + } else if ( $this->releaseAssetPreference === Api::REQUIRE_RELEASE_ASSETS ) { + //None of the assets match the filter, and we're not allowed + //to fall back to the auto-generated source ZIP. + return null; + } + } + + if ( !empty($release->body) ) { + $reference->changelog = Parsedown::instance()->text($release->body); + } + + return $reference; + } + + return null; + } + + /** + * Get the tag that looks like the highest version number. + * + * @return Reference|null + */ + public function getLatestTag() { + $tags = $this->api('/repos/:user/:repo/tags'); + + if ( is_wp_error($tags) || !is_array($tags) ) { + return null; + } + + $versionTags = $this->sortTagsByVersion($tags); + if ( empty($versionTags) ) { + return null; + } + + $tag = $versionTags[0]; + return new Reference(array( + 'name' => $tag->name, + 'version' => ltrim($tag->name, 'v'), + 'downloadUrl' => $tag->zipball_url, + 'apiResponse' => $tag, + )); + } + + /** + * Get a branch by name. + * + * @param string $branchName + * @return null|Reference + */ + public function getBranch($branchName) { + $branch = $this->api('/repos/:user/:repo/branches/' . $branchName); + if ( is_wp_error($branch) || empty($branch) ) { + return null; + } + + $reference = new Reference(array( + 'name' => $branch->name, + 'downloadUrl' => $this->buildArchiveDownloadUrl($branch->name), + 'apiResponse' => $branch, + )); + + if ( isset($branch->commit, $branch->commit->commit, $branch->commit->commit->author->date) ) { + $reference->updated = $branch->commit->commit->author->date; + } + + return $reference; + } + + /** + * Get the latest commit that changed the specified file. + * + * @param string $filename + * @param string $ref Reference name (e.g. branch or tag). + * @return \StdClass|null + */ + public function getLatestCommit($filename, $ref = 'master') { + $commits = $this->api( + '/repos/:user/:repo/commits', + array( + 'path' => $filename, + 'sha' => $ref, + ) + ); + if ( !is_wp_error($commits) && isset($commits[0]) ) { + return $commits[0]; + } + return null; + } + + /** + * Get the timestamp of the latest commit that changed the specified branch or tag. + * + * @param string $ref Reference name (e.g. branch or tag). + * @return string|null + */ + public function getLatestCommitTime($ref) { + $commits = $this->api('/repos/:user/:repo/commits', array('sha' => $ref)); + if ( !is_wp_error($commits) && isset($commits[0]) ) { + return $commits[0]->commit->author->date; + } + return null; + } + + /** + * Perform a GitHub API request. + * + * @param string $url + * @param array $queryParams + * @return mixed|\WP_Error + */ + protected function api($url, $queryParams = array()) { + $baseUrl = $url; + $url = $this->buildApiUrl($url, $queryParams); + + $options = array('timeout' => wp_doing_cron() ? 10 : 3); + if ( $this->isAuthenticationEnabled() ) { + $options['headers'] = array('Authorization' => $this->getAuthorizationHeader()); + } + + if ( !empty($this->httpFilterName) ) { + $options = apply_filters($this->httpFilterName, $options); + } + $response = wp_remote_get($url, $options); + if ( is_wp_error($response) ) { + do_action('puc_api_error', $response, null, $url, $this->slug); + return $response; + } + + $code = wp_remote_retrieve_response_code($response); + $body = wp_remote_retrieve_body($response); + if ( $code === 200 ) { + $document = json_decode($body); + return $document; + } + + $error = new \WP_Error( + 'puc-github-http-error', + sprintf('GitHub API error. Base URL: "%s", HTTP status code: %d.', $baseUrl, $code) + ); + do_action('puc_api_error', $error, $response, $url, $this->slug); + + return $error; + } + + /** + * Build a fully qualified URL for an API request. + * + * @param string $url + * @param array $queryParams + * @return string + */ + protected function buildApiUrl($url, $queryParams) { + $variables = array( + 'user' => $this->userName, + 'repo' => $this->repositoryName, + ); + foreach ($variables as $name => $value) { + $url = str_replace('/:' . $name, '/' . urlencode($value), $url); + } + $url = 'https://api.github.com' . $url; + + if ( !empty($queryParams) ) { + $url = add_query_arg($queryParams, $url); + } + + return $url; + } + + /** + * Get the contents of a file from a specific branch or tag. + * + * @param string $path File name. + * @param string $ref + * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error. + */ + public function getRemoteFile($path, $ref = 'master') { + $apiUrl = '/repos/:user/:repo/contents/' . $path; + $response = $this->api($apiUrl, array('ref' => $ref)); + + if ( is_wp_error($response) || !isset($response->content) || ($response->encoding !== 'base64') ) { + return null; + } + return base64_decode($response->content); + } + + /** + * Generate a URL to download a ZIP archive of the specified branch/tag/etc. + * + * @param string $ref + * @return string + */ + public function buildArchiveDownloadUrl($ref = 'master') { + $url = sprintf( + 'https://api.github.com/repos/%1$s/%2$s/zipball/%3$s', + urlencode($this->userName), + urlencode($this->repositoryName), + urlencode($ref) + ); + return $url; + } + + /** + * Get a specific tag. + * + * @param string $tagName + * @return void + */ + public function getTag($tagName) { + //The current GitHub update checker doesn't use getTag, so I didn't bother to implement it. + throw new \LogicException('The ' . __METHOD__ . ' method is not implemented and should not be used.'); + } + + public function setAuthentication($credentials) { + parent::setAuthentication($credentials); + $this->accessToken = is_string($credentials) ? $credentials : null; + + //Optimization: Instead of filtering all HTTP requests, let's do it only when + //WordPress is about to download an update. + add_filter('upgrader_pre_download', array($this, 'addHttpRequestFilter'), 10, 1); //WP 3.7+ + } + + protected function getUpdateDetectionStrategies($configBranch) { + $strategies = array(); + + if ( $configBranch === 'master' || $configBranch === 'main') { + //Use the latest release. + $strategies[self::STRATEGY_LATEST_RELEASE] = array($this, 'getLatestRelease'); + //Failing that, use the tag with the highest version number. + $strategies[self::STRATEGY_LATEST_TAG] = array($this, 'getLatestTag'); + } + + //Alternatively, just use the branch itself. + $strategies[self::STRATEGY_BRANCH] = function () use ($configBranch) { + return $this->getBranch($configBranch); + }; + + return $strategies; + } + + /** + * Get the unchanging part of a release asset URL. Used to identify download attempts. + * + * @return string + */ + protected function getAssetApiBaseUrl() { + return sprintf( + '//api.github.com/repos/%1$s/%2$s/releases/assets/', + $this->userName, + $this->repositoryName + ); + } + + protected function getFilterableAssetName($releaseAsset) { + if ( isset($releaseAsset->name) ) { + return $releaseAsset->name; + } + return null; + } + + /** + * @param bool $result + * @return bool + * @internal + */ + public function addHttpRequestFilter($result) { + if ( !$this->downloadFilterAdded && $this->isAuthenticationEnabled() ) { + //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args -- The callback doesn't change the timeout. + add_filter('http_request_args', array($this, 'setUpdateDownloadHeaders'), 10, 2); + add_action('requests-requests.before_redirect', array($this, 'removeAuthHeaderFromRedirects'), 10, 4); + $this->downloadFilterAdded = true; + } + return $result; + } + + /** + * Set the HTTP headers that are necessary to download updates from private repositories. + * + * See GitHub docs: + * + * @link https://developer.github.com/v3/repos/releases/#get-a-single-release-asset + * @link https://developer.github.com/v3/auth/#basic-authentication + * + * @internal + * @param array $requestArgs + * @param string $url + * @return array + */ + public function setUpdateDownloadHeaders($requestArgs, $url = '') { + //Is WordPress trying to download one of our release assets? + if ( $this->releaseAssetsEnabled && (strpos($url, $this->getAssetApiBaseUrl()) !== false) ) { + $requestArgs['headers']['Accept'] = 'application/octet-stream'; + } + //Use Basic authentication, but only if the download is from our repository. + $repoApiBaseUrl = $this->buildApiUrl('/repos/:user/:repo/', array()); + if ( $this->isAuthenticationEnabled() && (strpos($url, $repoApiBaseUrl)) === 0 ) { + $requestArgs['headers']['Authorization'] = $this->getAuthorizationHeader(); + } + return $requestArgs; + } + + /** + * When following a redirect, the Requests library will automatically forward + * the authorization header to other hosts. We don't want that because it breaks + * AWS downloads and can leak authorization information. + * + * @param string $location + * @param array $headers + * @internal + */ + public function removeAuthHeaderFromRedirects(&$location, &$headers) { + $repoApiBaseUrl = $this->buildApiUrl('/repos/:user/:repo/', array()); + if ( strpos($location, $repoApiBaseUrl) === 0 ) { + return; //This request is going to GitHub, so it's fine. + } + //Remove the header. + if ( isset($headers['Authorization']) ) { + unset($headers['Authorization']); + } + } + + /** + * Generate the value of the "Authorization" header. + * + * @return string + */ + protected function getAuthorizationHeader() { + return 'Basic ' . base64_encode($this->userName . ':' . $this->accessToken); + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Vcs/GitLabApi.php b/includes/plugin-update-checker/Puc/v5p4/Vcs/GitLabApi.php new file mode 100644 index 0000000..2cbd6eb --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Vcs/GitLabApi.php @@ -0,0 +1,414 @@ +repositoryHost = wp_parse_url($repositoryUrl, PHP_URL_HOST) . $port; + + if ( $this->repositoryHost !== 'gitlab.com' ) { + $this->repositoryProtocol = wp_parse_url($repositoryUrl, PHP_URL_SCHEME); + } + + //Find the repository information + $path = wp_parse_url($repositoryUrl, PHP_URL_PATH); + if ( preg_match('@^/?(?P[^/]+?)/(?P[^/#?&]+?)/?$@', $path, $matches) ) { + $this->userName = $matches['username']; + $this->repositoryName = $matches['repository']; + } elseif ( ($this->repositoryHost === 'gitlab.com') ) { + //This is probably a repository in a subgroup, e.g. "/organization/category/repo". + $parts = explode('/', trim($path, '/')); + if ( count($parts) < 3 ) { + throw new \InvalidArgumentException('Invalid GitLab.com repository URL: "' . $repositoryUrl . '"'); + } + $lastPart = array_pop($parts); + $this->userName = implode('/', $parts); + $this->repositoryName = $lastPart; + } else { + //There could be subgroups in the URL: gitlab.domain.com/group/subgroup/subgroup2/repository + if ( $subgroup !== null ) { + $path = str_replace(trailingslashit($subgroup), '', $path); + } + + //This is not a traditional url, it could be gitlab is in a deeper subdirectory. + //Get the path segments. + $segments = explode('/', untrailingslashit(ltrim($path, '/'))); + + //We need at least /user-name/repository-name/ + if ( count($segments) < 2 ) { + throw new \InvalidArgumentException('Invalid GitLab repository URL: "' . $repositoryUrl . '"'); + } + + //Get the username and repository name. + $usernameRepo = array_splice($segments, -2, 2); + $this->userName = $usernameRepo[0]; + $this->repositoryName = $usernameRepo[1]; + + //Append the remaining segments to the host if there are segments left. + if ( count($segments) > 0 ) { + $this->repositoryHost = trailingslashit($this->repositoryHost) . implode('/', $segments); + } + + //Add subgroups to username. + if ( $subgroup !== null ) { + $this->userName = $usernameRepo[0] . '/' . untrailingslashit($subgroup); + } + } + + parent::__construct($repositoryUrl, $accessToken); + } + + /** + * Get the latest release from GitLab. + * + * @return Reference|null + */ + public function getLatestRelease() { + $releases = $this->api('/:id/releases', array('per_page' => $this->releaseFilterMaxReleases)); + if ( is_wp_error($releases) || empty($releases) || !is_array($releases) ) { + return null; + } + + foreach ($releases as $release) { + if ( + //Skip invalid/unsupported releases. + !is_object($release) + || !isset($release->tag_name) + //Skip upcoming releases. + || ( + !empty($release->upcoming_release) + && $this->shouldSkipPreReleases() + ) + ) { + continue; + } + + $versionNumber = ltrim($release->tag_name, 'v'); //Remove the "v" prefix from "v1.2.3". + + //Apply custom filters. + if ( !$this->matchesCustomReleaseFilter($versionNumber, $release) ) { + continue; + } + + $downloadUrl = $this->findReleaseDownloadUrl($release); + if ( empty($downloadUrl) ) { + //The latest release doesn't have valid download URL. + return null; + } + + if ( !empty($this->accessToken) ) { + $downloadUrl = add_query_arg('private_token', $this->accessToken, $downloadUrl); + } + + return new Reference(array( + 'name' => $release->tag_name, + 'version' => $versionNumber, + 'downloadUrl' => $downloadUrl, + 'updated' => $release->released_at, + 'apiResponse' => $release, + )); + } + + return null; + } + + /** + * @param object $release + * @return string|null + */ + protected function findReleaseDownloadUrl($release) { + if ( $this->releaseAssetsEnabled ) { + if ( isset($release->assets, $release->assets->links) ) { + //Use the first asset link where the URL matches the filter. + foreach ($release->assets->links as $link) { + if ( $this->matchesAssetFilter($link) ) { + return $link->url; + } + } + } + + if ( $this->releaseAssetPreference === Api::REQUIRE_RELEASE_ASSETS ) { + //Falling back to source archives is not allowed, so give up. + return null; + } + } + + //Use the first source code archive that's in ZIP format. + foreach ($release->assets->sources as $source) { + if ( isset($source->format) && ($source->format === 'zip') ) { + return $source->url; + } + } + + return null; + } + + /** + * Get the tag that looks like the highest version number. + * + * @return Reference|null + */ + public function getLatestTag() { + $tags = $this->api('/:id/repository/tags'); + if ( is_wp_error($tags) || empty($tags) || !is_array($tags) ) { + return null; + } + + $versionTags = $this->sortTagsByVersion($tags); + if ( empty($versionTags) ) { + return null; + } + + $tag = $versionTags[0]; + return new Reference(array( + 'name' => $tag->name, + 'version' => ltrim($tag->name, 'v'), + 'downloadUrl' => $this->buildArchiveDownloadUrl($tag->name), + 'apiResponse' => $tag, + )); + } + + /** + * Get a branch by name. + * + * @param string $branchName + * @return null|Reference + */ + public function getBranch($branchName) { + $branch = $this->api('/:id/repository/branches/' . $branchName); + if ( is_wp_error($branch) || empty($branch) ) { + return null; + } + + $reference = new Reference(array( + 'name' => $branch->name, + 'downloadUrl' => $this->buildArchiveDownloadUrl($branch->name), + 'apiResponse' => $branch, + )); + + if ( isset($branch->commit, $branch->commit->committed_date) ) { + $reference->updated = $branch->commit->committed_date; + } + + return $reference; + } + + /** + * Get the timestamp of the latest commit that changed the specified branch or tag. + * + * @param string $ref Reference name (e.g. branch or tag). + * @return string|null + */ + public function getLatestCommitTime($ref) { + $commits = $this->api('/:id/repository/commits/', array('ref_name' => $ref)); + if ( is_wp_error($commits) || !is_array($commits) || !isset($commits[0]) ) { + return null; + } + + return $commits[0]->committed_date; + } + + /** + * Perform a GitLab API request. + * + * @param string $url + * @param array $queryParams + * @return mixed|\WP_Error + */ + protected function api($url, $queryParams = array()) { + $baseUrl = $url; + $url = $this->buildApiUrl($url, $queryParams); + + $options = array('timeout' => wp_doing_cron() ? 10 : 3); + if ( !empty($this->httpFilterName) ) { + $options = apply_filters($this->httpFilterName, $options); + } + + $response = wp_remote_get($url, $options); + if ( is_wp_error($response) ) { + do_action('puc_api_error', $response, null, $url, $this->slug); + return $response; + } + + $code = wp_remote_retrieve_response_code($response); + $body = wp_remote_retrieve_body($response); + if ( $code === 200 ) { + return json_decode($body); + } + + $error = new \WP_Error( + 'puc-gitlab-http-error', + sprintf('GitLab API error. URL: "%s", HTTP status code: %d.', $baseUrl, $code) + ); + do_action('puc_api_error', $error, $response, $url, $this->slug); + + return $error; + } + + /** + * Build a fully qualified URL for an API request. + * + * @param string $url + * @param array $queryParams + * @return string + */ + protected function buildApiUrl($url, $queryParams) { + $variables = array( + 'user' => $this->userName, + 'repo' => $this->repositoryName, + 'id' => $this->userName . '/' . $this->repositoryName, + ); + + foreach ($variables as $name => $value) { + $url = str_replace("/:{$name}", '/' . urlencode($value), $url); + } + + $url = substr($url, 1); + $url = sprintf('%1$s://%2$s/api/v4/projects/%3$s', $this->repositoryProtocol, $this->repositoryHost, $url); + + if ( !empty($this->accessToken) ) { + $queryParams['private_token'] = $this->accessToken; + } + + if ( !empty($queryParams) ) { + $url = add_query_arg($queryParams, $url); + } + + return $url; + } + + /** + * Get the contents of a file from a specific branch or tag. + * + * @param string $path File name. + * @param string $ref + * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error. + */ + public function getRemoteFile($path, $ref = 'master') { + $response = $this->api('/:id/repository/files/' . $path, array('ref' => $ref)); + if ( is_wp_error($response) || !isset($response->content) || $response->encoding !== 'base64' ) { + return null; + } + + return base64_decode($response->content); + } + + /** + * Generate a URL to download a ZIP archive of the specified branch/tag/etc. + * + * @param string $ref + * @return string + */ + public function buildArchiveDownloadUrl($ref = 'master') { + $url = sprintf( + '%1$s://%2$s/api/v4/projects/%3$s/repository/archive.zip', + $this->repositoryProtocol, + $this->repositoryHost, + urlencode($this->userName . '/' . $this->repositoryName) + ); + $url = add_query_arg('sha', urlencode($ref), $url); + + if ( !empty($this->accessToken) ) { + $url = add_query_arg('private_token', $this->accessToken, $url); + } + + return $url; + } + + /** + * Get a specific tag. + * + * @param string $tagName + * @return void + */ + public function getTag($tagName) { + throw new \LogicException('The ' . __METHOD__ . ' method is not implemented and should not be used.'); + } + + protected function getUpdateDetectionStrategies($configBranch) { + $strategies = array(); + + if ( ($configBranch === 'main') || ($configBranch === 'master') ) { + $strategies[self::STRATEGY_LATEST_RELEASE] = array($this, 'getLatestRelease'); + $strategies[self::STRATEGY_LATEST_TAG] = array($this, 'getLatestTag'); + } + + $strategies[self::STRATEGY_BRANCH] = function () use ($configBranch) { + return $this->getBranch($configBranch); + }; + + return $strategies; + } + + public function setAuthentication($credentials) { + parent::setAuthentication($credentials); + $this->accessToken = is_string($credentials) ? $credentials : null; + } + + /** + * Use release assets that link to GitLab generic packages (e.g. .zip files) + * instead of automatically generated source archives. + * + * This is included for backwards compatibility with older versions of PUC. + * + * @return void + * @deprecated Use enableReleaseAssets() instead. + * @noinspection PhpUnused -- Public API + */ + public function enableReleasePackages() { + $this->enableReleaseAssets( + /** @lang RegExp */ '/\.zip($|[?&#])/i', + Api::REQUIRE_RELEASE_ASSETS + ); + } + + protected function getFilterableAssetName($releaseAsset) { + if ( isset($releaseAsset->url) ) { + return $releaseAsset->url; + } + return null; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Vcs/PluginUpdateChecker.php b/includes/plugin-update-checker/Puc/v5p4/Vcs/PluginUpdateChecker.php new file mode 100644 index 0000000..f00097f --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Vcs/PluginUpdateChecker.php @@ -0,0 +1,275 @@ +api = $api; + + parent::__construct($api->getRepositoryUrl(), $pluginFile, $slug, $checkPeriod, $optionName, $muPluginFile); + + $this->api->setHttpFilterName($this->getUniqueName('request_info_options')); + $this->api->setStrategyFilterName($this->getUniqueName('vcs_update_detection_strategies')); + $this->api->setSlug($this->slug); + } + + public function requestInfo($unusedParameter = null) { + //We have to make several remote API requests to gather all the necessary info + //which can take a while on slow networks. + if ( function_exists('set_time_limit') ) { + @set_time_limit(60); + } + + $api = $this->api; + $api->setLocalDirectory($this->package->getAbsoluteDirectoryPath()); + + $info = new Plugin\PluginInfo(); + $info->filename = $this->pluginFile; + $info->slug = $this->slug; + + $this->setInfoFromHeader($this->package->getPluginHeader(), $info); + $this->setIconsFromLocalAssets($info); + $this->setBannersFromLocalAssets($info); + + //Pick a branch or tag. + $updateSource = $api->chooseReference($this->branch); + if ( $updateSource ) { + $ref = $updateSource->name; + $info->version = $updateSource->version; + $info->last_updated = $updateSource->updated; + $info->download_url = $updateSource->downloadUrl; + + if ( !empty($updateSource->changelog) ) { + $info->sections['changelog'] = $updateSource->changelog; + } + if ( isset($updateSource->downloadCount) ) { + $info->downloaded = $updateSource->downloadCount; + } + } else { + //There's probably a network problem or an authentication error. + do_action( + 'puc_api_error', + new \WP_Error( + 'puc-no-update-source', + 'Could not retrieve version information from the repository. ' + . 'This usually means that the update checker either can\'t connect ' + . 'to the repository or it\'s configured incorrectly.' + ), + null, null, $this->slug + ); + return null; + } + + //Get headers from the main plugin file in this branch/tag. Its "Version" header and other metadata + //are what the WordPress install will actually see after upgrading, so they take precedence over releases/tags. + $mainPluginFile = basename($this->pluginFile); + $remotePlugin = $api->getRemoteFile($mainPluginFile, $ref); + if ( !empty($remotePlugin) ) { + $remoteHeader = $this->package->getFileHeader($remotePlugin); + $this->setInfoFromHeader($remoteHeader, $info); + } + + //Sanity check: Reject updates that don't have a version number. + //This can happen when we're using a branch, and we either fail to retrieve the main plugin + //file or the file doesn't have a "Version" header. + if ( empty($info->version) ) { + do_action( + 'puc_api_error', + new \WP_Error( + 'puc-no-plugin-version', + 'Could not find the version number in the repository.' + ), + null, null, $this->slug + ); + return null; + } + + //Try parsing readme.txt. If it's formatted according to WordPress.org standards, it will contain + //a lot of useful information like the required/tested WP version, changelog, and so on. + if ( $this->readmeTxtExistsLocally() ) { + $this->setInfoFromRemoteReadme($ref, $info); + } + + //The changelog might be in a separate file. + if ( empty($info->sections['changelog']) ) { + $info->sections['changelog'] = $api->getRemoteChangelog($ref, $this->package->getAbsoluteDirectoryPath()); + if ( empty($info->sections['changelog']) ) { + $info->sections['changelog'] = __('There is no changelog available.', 'plugin-update-checker'); + } + } + + if ( empty($info->last_updated) ) { + //Fetch the latest commit that changed the tag or branch and use it as the "last_updated" date. + $latestCommitTime = $api->getLatestCommitTime($ref); + if ( $latestCommitTime !== null ) { + $info->last_updated = $latestCommitTime; + } + } + + $info = apply_filters($this->getUniqueName('request_info_result'), $info, null); + return $info; + } + + /** + * Check if the currently installed version has a readme.txt file. + * + * @return bool + */ + protected function readmeTxtExistsLocally() { + return $this->package->fileExists($this->api->getLocalReadmeName()); + } + + /** + * Copy plugin metadata from a file header to a Plugin Info object. + * + * @param array $fileHeader + * @param Plugin\PluginInfo $pluginInfo + */ + protected function setInfoFromHeader($fileHeader, $pluginInfo) { + $headerToPropertyMap = array( + 'Version' => 'version', + 'Name' => 'name', + 'PluginURI' => 'homepage', + 'Author' => 'author', + 'AuthorName' => 'author', + 'AuthorURI' => 'author_homepage', + + 'Requires WP' => 'requires', + 'Tested WP' => 'tested', + 'Requires at least' => 'requires', + 'Tested up to' => 'tested', + + 'Requires PHP' => 'requires_php', + ); + foreach ($headerToPropertyMap as $headerName => $property) { + if ( isset($fileHeader[$headerName]) && !empty($fileHeader[$headerName]) ) { + $pluginInfo->$property = $fileHeader[$headerName]; + } + } + + if ( !empty($fileHeader['Description']) ) { + $pluginInfo->sections['description'] = $fileHeader['Description']; + } + } + + /** + * Copy plugin metadata from the remote readme.txt file. + * + * @param string $ref GitHub tag or branch where to look for the readme. + * @param Plugin\PluginInfo $pluginInfo + */ + protected function setInfoFromRemoteReadme($ref, $pluginInfo) { + $readme = $this->api->getRemoteReadme($ref); + if ( empty($readme) ) { + return; + } + + if ( isset($readme['sections']) ) { + $pluginInfo->sections = array_merge($pluginInfo->sections, $readme['sections']); + } + if ( !empty($readme['tested_up_to']) ) { + $pluginInfo->tested = $readme['tested_up_to']; + } + if ( !empty($readme['requires_at_least']) ) { + $pluginInfo->requires = $readme['requires_at_least']; + } + if ( !empty($readme['requires_php']) ) { + $pluginInfo->requires_php = $readme['requires_php']; + } + + if ( isset($readme['upgrade_notice'], $readme['upgrade_notice'][$pluginInfo->version]) ) { + $pluginInfo->upgrade_notice = $readme['upgrade_notice'][$pluginInfo->version]; + } + } + + /** + * Add icons from the currently installed version to a Plugin Info object. + * + * The icons should be in a subdirectory named "assets". Supported image formats + * and file names are described here: + * @link https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/#plugin-icons + * + * @param Plugin\PluginInfo $pluginInfo + */ + protected function setIconsFromLocalAssets($pluginInfo) { + $icons = $this->getLocalAssetUrls(array( + 'icon.svg' => 'svg', + 'icon-256x256.png' => '2x', + 'icon-256x256.jpg' => '2x', + 'icon-128x128.png' => '1x', + 'icon-128x128.jpg' => '1x', + )); + + if ( !empty($icons) ) { + //The "default" key seems to be used only as last-resort fallback in WP core (5.8/5.9), + //but we'll set it anyway in case some code somewhere needs it. + reset($icons); + $firstKey = key($icons); + $icons['default'] = $icons[$firstKey]; + + $pluginInfo->icons = $icons; + } + } + + /** + * Add banners from the currently installed version to a Plugin Info object. + * + * The banners should be in a subdirectory named "assets". Supported image formats + * and file names are described here: + * @link https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/#plugin-headers + * + * @param Plugin\PluginInfo $pluginInfo + */ + protected function setBannersFromLocalAssets($pluginInfo) { + $banners = $this->getLocalAssetUrls(array( + 'banner-772x250.png' => 'high', + 'banner-772x250.jpg' => 'high', + 'banner-1544x500.png' => 'low', + 'banner-1544x500.jpg' => 'low', + )); + + if ( !empty($banners) ) { + $pluginInfo->banners = $banners; + } + } + + /** + * @param array $filesToKeys + * @return array + */ + protected function getLocalAssetUrls($filesToKeys) { + $assetDirectory = $this->package->getAbsoluteDirectoryPath() . DIRECTORY_SEPARATOR . 'assets'; + if ( !is_dir($assetDirectory) ) { + return array(); + } + $assetBaseUrl = trailingslashit(plugins_url('', $assetDirectory . '/imaginary.file')); + + $foundAssets = array(); + foreach ($filesToKeys as $fileName => $key) { + $fullBannerPath = $assetDirectory . DIRECTORY_SEPARATOR . $fileName; + if ( !isset($icons[$key]) && is_file($fullBannerPath) ) { + $foundAssets[$key] = $assetBaseUrl . $fileName; + } + } + + return $foundAssets; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Vcs/Reference.php b/includes/plugin-update-checker/Puc/v5p4/Vcs/Reference.php new file mode 100644 index 0000000..c30bcf7 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Vcs/Reference.php @@ -0,0 +1,51 @@ +properties = $properties; + } + + /** + * @param string $name + * @return mixed|null + */ + public function __get($name) { + return array_key_exists($name, $this->properties) ? $this->properties[$name] : null; + } + + /** + * @param string $name + * @param mixed $value + */ + public function __set($name, $value) { + $this->properties[$name] = $value; + } + + /** + * @param string $name + * @return bool + */ + public function __isset($name) { + return isset($this->properties[$name]); + } + + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Vcs/ReleaseAssetSupport.php b/includes/plugin-update-checker/Puc/v5p4/Vcs/ReleaseAssetSupport.php new file mode 100644 index 0000000..352fc5e --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Vcs/ReleaseAssetSupport.php @@ -0,0 +1,83 @@ +releaseAssetsEnabled = true; + $this->assetFilterRegex = $nameRegex; + $this->releaseAssetPreference = $preference; + } + + /** + * Disable release assets. + * + * @return void + * @noinspection PhpUnused -- Public API + */ + public function disableReleaseAssets() { + $this->releaseAssetsEnabled = false; + $this->assetFilterRegex = null; + } + + /** + * Does the specified asset match the name regex? + * + * @param mixed $releaseAsset Data type and structure depend on the host/API. + * @return bool + */ + protected function matchesAssetFilter($releaseAsset) { + if ( $this->assetFilterRegex === null ) { + //The default is to accept all assets. + return true; + } + + $name = $this->getFilterableAssetName($releaseAsset); + if ( !is_string($name) ) { + return false; + } + return (bool)preg_match($this->assetFilterRegex, $releaseAsset->name); + } + + /** + * Get the part of asset data that will be checked against the filter regex. + * + * @param mixed $releaseAsset + * @return string|null + */ + abstract protected function getFilterableAssetName($releaseAsset); + } + +endif; \ No newline at end of file diff --git a/includes/plugin-update-checker/Puc/v5p4/Vcs/ReleaseFilteringFeature.php b/includes/plugin-update-checker/Puc/v5p4/Vcs/ReleaseFilteringFeature.php new file mode 100644 index 0000000..bbf9c47 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Vcs/ReleaseFilteringFeature.php @@ -0,0 +1,108 @@ + 100 ) { + throw new \InvalidArgumentException(sprintf( + 'The max number of releases is too high (%d). It must be 100 or less.', + $maxReleases + )); + } else if ( $maxReleases < 1 ) { + throw new \InvalidArgumentException(sprintf( + 'The max number of releases is too low (%d). It must be at least 1.', + $maxReleases + )); + } + + $this->releaseFilterCallback = $callback; + $this->releaseFilterByType = $releaseTypes; + $this->releaseFilterMaxReleases = $maxReleases; + return $this; + } + + /** + * Filter releases by their version number. + * + * @param string $regex A regular expression. The release version number must match this regex. + * @param int $releaseTypes + * @param int $maxReleasesToExamine + * @return $this + * @noinspection PhpUnused -- Public API + */ + public function setReleaseVersionFilter( + $regex, + $releaseTypes = Api::RELEASE_FILTER_SKIP_PRERELEASE, + $maxReleasesToExamine = 20 + ) { + return $this->setReleaseFilter( + function ($versionNumber) use ($regex) { + return (preg_match($regex, $versionNumber) === 1); + }, + $releaseTypes, + $maxReleasesToExamine + ); + } + + /** + * @param string $versionNumber The detected release version number. + * @param object $releaseObject Varies depending on the host/API. + * @return bool + */ + protected function matchesCustomReleaseFilter($versionNumber, $releaseObject) { + if ( !is_callable($this->releaseFilterCallback) ) { + return true; //No custom filter. + } + return call_user_func($this->releaseFilterCallback, $versionNumber, $releaseObject); + } + + /** + * @return bool + */ + protected function shouldSkipPreReleases() { + //Maybe this could be a bitfield in the future, if we need to support + //more release types. + return ($this->releaseFilterByType !== Api::RELEASE_FILTER_ALL); + } + + /** + * @return bool + */ + protected function hasCustomReleaseFilter() { + return isset($this->releaseFilterCallback) && is_callable($this->releaseFilterCallback); + } + } + +endif; \ No newline at end of file diff --git a/includes/plugin-update-checker/Puc/v5p4/Vcs/ThemeUpdateChecker.php b/includes/plugin-update-checker/Puc/v5p4/Vcs/ThemeUpdateChecker.php new file mode 100644 index 0000000..3d16f19 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Vcs/ThemeUpdateChecker.php @@ -0,0 +1,83 @@ +api = $api; + + parent::__construct($api->getRepositoryUrl(), $stylesheet, $customSlug, $checkPeriod, $optionName); + + $this->api->setHttpFilterName($this->getUniqueName('request_update_options')); + $this->api->setStrategyFilterName($this->getUniqueName('vcs_update_detection_strategies')); + $this->api->setSlug($this->slug); + } + + public function requestUpdate() { + $api = $this->api; + $api->setLocalDirectory($this->package->getAbsoluteDirectoryPath()); + + $update = new Theme\Update(); + $update->slug = $this->slug; + + //Figure out which reference (tag or branch) we'll use to get the latest version of the theme. + $updateSource = $api->chooseReference($this->branch); + if ( $updateSource ) { + $ref = $updateSource->name; + $update->download_url = $updateSource->downloadUrl; + } else { + do_action( + 'puc_api_error', + new \WP_Error( + 'puc-no-update-source', + 'Could not retrieve version information from the repository. ' + . 'This usually means that the update checker either can\'t connect ' + . 'to the repository or it\'s configured incorrectly.' + ), + null, null, $this->slug + ); + $ref = $this->branch; + } + + //Get headers from the main stylesheet in this branch/tag. Its "Version" header and other metadata + //are what the WordPress install will actually see after upgrading, so they take precedence over releases/tags. + $remoteHeader = $this->package->getFileHeader($api->getRemoteFile('style.css', $ref)); + $update->version = Utils::findNotEmpty(array( + $remoteHeader['Version'], + Utils::get($updateSource, 'version'), + )); + + //The details URL defaults to the Theme URI header or the repository URL. + $update->details_url = Utils::findNotEmpty(array( + $remoteHeader['ThemeURI'], + $this->package->getHeaderValue('ThemeURI'), + $this->metadataUrl, + )); + + if ( empty($update->version) ) { + //It looks like we didn't find a valid update after all. + $update = null; + } + + $update = $this->filterUpdateResult($update); + return $update; + } + } + +endif; diff --git a/includes/plugin-update-checker/Puc/v5p4/Vcs/VcsCheckerMethods.php b/includes/plugin-update-checker/Puc/v5p4/Vcs/VcsCheckerMethods.php new file mode 100644 index 0000000..e5a5608 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/Vcs/VcsCheckerMethods.php @@ -0,0 +1,59 @@ +branch = $branch; + return $this; + } + + /** + * Set authentication credentials. + * + * @param array|string $credentials + * @return $this + */ + public function setAuthentication($credentials) { + $this->api->setAuthentication($credentials); + return $this; + } + + /** + * @return Api + */ + public function getVcsApi() { + return $this->api; + } + + public function getUpdate() { + $update = parent::getUpdate(); + + if ( isset($update) && !empty($update->download_url) ) { + $update->download_url = $this->api->signDownloadUrl($update->download_url); + } + + return $update; + } + + public function onDisplayConfiguration($panel) { + parent::onDisplayConfiguration($panel); + $panel->row('Branch', $this->branch); + $panel->row('Authentication enabled', $this->api->isAuthenticationEnabled() ? 'Yes' : 'No'); + $panel->row('API client', get_class($this->api)); + } + } + +endif; \ No newline at end of file diff --git a/includes/plugin-update-checker/Puc/v5p4/WpCliCheckTrigger.php b/includes/plugin-update-checker/Puc/v5p4/WpCliCheckTrigger.php new file mode 100644 index 0000000..523cca4 --- /dev/null +++ b/includes/plugin-update-checker/Puc/v5p4/WpCliCheckTrigger.php @@ -0,0 +1,84 @@ +componentType = $componentType; + $this->scheduler = $scheduler; + + if ( !defined('WP_CLI') || !class_exists(WP_CLI::class, false) ) { + return; //Nothing to do if WP-CLI is not available. + } + + /* + * We can't hook directly into wp_update_plugins(), but we can hook into the WP-CLI + * commands that call it. We'll use the "before_invoke:xyz" hook to trigger update checks. + */ + foreach ($this->getRelevantCommands() as $command) { + WP_CLI::add_hook('before_invoke:' . $command, [$this, 'triggerUpdateCheckOnce']); + } + } + + private function getRelevantCommands() { + $result = []; + foreach (['status', 'list', 'update'] as $subcommand) { + $result[] = $this->componentType . ' ' . $subcommand; + } + return $result; + } + + /** + * Trigger a potential update check once. + * + * @param mixed $input + * @return mixed The input value, unchanged. + * @internal This method is public so that it can be used as a WP-CLI hook callback. + * It should not be called directly. + * + */ + public function triggerUpdateCheckOnce($input = null) { + if ( $this->wasCheckTriggered ) { + return $input; + } + + $this->wasCheckTriggered = true; + $this->scheduler->maybeCheckForUpdates(); + + return $input; + } +} \ No newline at end of file diff --git a/includes/plugin-update-checker/README.md b/includes/plugin-update-checker/README.md new file mode 100644 index 0000000..4c1c197 --- /dev/null +++ b/includes/plugin-update-checker/README.md @@ -0,0 +1,372 @@ +Plugin Update Checker +===================== + +This is a custom update checker library for WordPress plugins and themes. It lets you add automatic update notifications and one-click upgrades to your commercial plugins, private themes, and so on. All you need to do is put your plugin/theme details in a JSON file, place the file on your server, and pass the URL to the library. The library periodically checks the URL to see if there's a new version available and displays an update notification to the user if necessary. + +From the users' perspective, it works just like with plugins and themes hosted on WordPress.org. The update checker uses the default upgrade UI that is familiar to most WordPress users. + + + +**Table of Contents** + +- [Getting Started](#getting-started) + - [Self-hosted Plugins and Themes](#self-hosted-plugins-and-themes) + - [How to Release an Update](#how-to-release-an-update) + - [Notes](#notes) + - [GitHub Integration](#github-integration) + - [How to Release an Update](#how-to-release-an-update-1) + - [Notes](#notes-1) + - [BitBucket Integration](#bitbucket-integration) + - [How to Release an Update](#how-to-release-an-update-2) + - [GitLab Integration](#gitlab-integration) + - [How to Release a GitLab Update](#how-to-release-a-gitlab-update) +- [Migrating from 4.x](#migrating-from-4x) +- [License Management](#license-management) +- [Resources](#resources) + + + +Getting Started +--------------- + +*Note:* In each of the below examples, part of the instructions are to create an instance of the update checker class. It's recommended to do this either during the `plugins_loaded` action or outside of any hooks. If you do it only during an `admin_*` action, then updates will not be visible to a wide variety of WordPress maanagement tools; they will only be visible to logged-in users on dashboard pages. + +### Self-hosted Plugins and Themes + +1. Download [the latest release](https://github.com/YahnisElsts/plugin-update-checker/releases/latest) and copy the `plugin-update-checker` directory to your plugin or theme. +2. Go to the `examples` subdirectory and open the .json file that fits your project type. Replace the placeholder data with your plugin/theme details. + - Plugin example: + + ```json + { + "name" : "Plugin Name", + "version" : "2.0", + "download_url" : "https://example.com/plugin-name-2.0.zip", + "sections" : { + "description" : "Plugin description here. You can use HTML." + } + } + ``` + + This is a minimal example that leaves out optional fields. See [this table](https://docs.google.com/spreadsheets/d/1eOBbW7Go2qEQXReOOCdidMTf_tDYRq4JfegcO1CBPIs/edit?usp=sharing) for a full list of supported fields and their descriptions. + - Theme example: + + ```json + { + "version": "2.0", + "details_url": "https://example.com/version-2.0-details.html", + "download_url": "https://example.com/example-theme-2.0.zip" + } + ``` + + This is actually a complete example that shows all theme-related fields. `version` and `download_url` should be self-explanatory. The `details_url` key specifies the page that the user will see if they click the "View version 1.2.3 details" link in an update notification. +3. Upload the JSON file to a publicly accessible location. +4. Add the following code to the main plugin file or to the `functions.php` file: + + ```php + require 'path/to/plugin-update-checker/plugin-update-checker.php'; + use YahnisElsts\PluginUpdateChecker\v5\PucFactory; + + $myUpdateChecker = PucFactory::buildUpdateChecker( + 'https://example.com/path/to/details.json', + __FILE__, //Full path to the main plugin file or functions.php. + 'unique-plugin-or-theme-slug' + ); + ``` + Note: If you're using the Composer autoloader, you don't need to explicitly `require` the library. + +#### How to Release an Update + +Change the `version` number in the JSON file and make sure that `download_url` points to the latest version. Update the other fields if necessary. Tip: You can use [wp-update-server](https://github.com/YahnisElsts/wp-update-server) to automate this process. + +By default, the library will check the specified URL for changes every 12 hours. You can force it to check immediately by clicking the "Check for updates" link on the "Plugins" page (it's next to the "Visit plugin site" link). Themes don't have that link, but you can also trigger an update check like this: + + 1. Install [Debug Bar](https://srd.wordpress.org/plugins/debug-bar/). + 2. Click the "Debug" menu in the Admin Bar (a.k.a Toolbar). + 3. Open the "PUC (your-slug)" panel. + 4. Click the "Check Now" button. + +#### Notes +- The second argument passed to `buildUpdateChecker` must be the absolute path to the main plugin file or any file in the theme directory. If you followed the "getting started" instructions, you can just use the `__FILE__` constant. +- The third argument - i.e. the slug - is optional but recommended. In most cases, the slug should be the same as the name of your plugin directory. For example, if your plugin lives in `/wp-content/plugins/my-plugin`, set the slug to `my-plugin`. If the slug is omitted, the update checker will use the name of the main plugin file as the slug (e.g. `my-cool-plugin.php` → `my-cool-plugin`). This can lead to conflicts if your plugin has a generic file name like `plugin.php`. + + This doesn't affect themes because PUC uses the theme directory name as the default slug. Still, if you're planning to use the slug in your own code - e.g. to filter updates or override update checker behaviour - it can be a good idea to set it explicitly. + +### GitHub Integration + +1. Download [the latest release](https://github.com/YahnisElsts/plugin-update-checker/releases/latest) and copy the `plugin-update-checker` directory to your plugin or theme. +2. Add the following code to the main plugin file or `functions.php`: + + ```php + require 'plugin-update-checker/plugin-update-checker.php'; + use YahnisElsts\PluginUpdateChecker\v5\PucFactory; + + $myUpdateChecker = PucFactory::buildUpdateChecker( + 'https://github.com/user-name/repo-name/', + __FILE__, + 'unique-plugin-or-theme-slug' + ); + + //Set the branch that contains the stable release. + $myUpdateChecker->setBranch('stable-branch-name'); + + //Optional: If you're using a private repository, specify the access token like this: + $myUpdateChecker->setAuthentication('your-token-here'); + ``` +3. Plugins only: Add a `readme.txt` file formatted according to the [WordPress.org plugin readme standard](https://wordpress.org/plugins/readme.txt) to your repository. The contents of this file will be shown when the user clicks the "View version 1.2.3 details" link. + +#### How to Release an Update + +This library supports a couple of different ways to release updates on GitHub. Pick the one that best fits your workflow. + +- **GitHub releases** + + Create a new release using the "Releases" feature on GitHub. The tag name and release title don't matter. The description is optional, but if you do provide one, it will be displayed when the user clicks the "View version x.y.z details" link on the "Plugins" page. Note that PUC ignores releases marked as "This is a pre-release". + + If you want to use release assets, call the `enableReleaseAssets()` method after creating the update checker instance: + ```php + $myUpdateChecker->getVcsApi()->enableReleaseAssets(); + ``` + +- **Tags** + + To release version 1.2.3, create a new Git tag named `v1.2.3` or `1.2.3`. That's it. + + PUC doesn't require strict adherence to [SemVer](https://semver.org/). These are all valid tag names: `v1.2.3`, `v1.2-foo`, `1.2.3_rc1-ABC`, `1.2.3.4.5`. However, be warned that it's not smart enough to filter out alpha/beta/RC versions. If that's a problem, you might want to use GitHub releases or branches instead. + +- **Stable branch** + + Point the update checker at a stable, production-ready branch: + ```php + $updateChecker->setBranch('branch-name'); + ``` + PUC will periodically check the `Version` header in the main plugin file or `style.css` and display a notification if it's greater than the installed version. + + Caveat: If you set the branch to `master` (the default), the update checker will look for recent releases and tags first. It'll only use the `master` branch if it doesn't find anything else suitable. + +#### Notes + +The library will pull update details from the following parts of a release/tag/branch: + +- Version number + - The "Version" plugin header. + - The latest GitHub release or tag name. +- Changelog + - The "Changelog" section of `readme.txt`. + - One of the following files: + CHANGES.md, CHANGELOG.md, changes.md, changelog.md + - GitHub release notes. +- Required and tested WordPress versions + - The "Requires at least" and "Tested up to" fields in `readme.txt`. + - The following plugin headers: + `Required WP`, `Tested WP`, `Requires at least`, `Tested up to` +- "Last updated" timestamp + - The creation timestamp of the latest GitHub release. + - The latest commit in the selected tag or branch. +- Number of downloads + - The `download_count` statistic of the latest release. + - If you're not using GitHub releases, there will be no download stats. +- Other plugin details - author, homepage URL, description + - The "Description" section of `readme.txt`. + - Remote plugin headers (i.e. the latest version on GitHub). + - Local plugin headers (i.e. the currently installed version). +- Ratings, banners, screenshots + - Not supported. + +### BitBucket Integration + +1. Download [the latest release](https://github.com/YahnisElsts/plugin-update-checker/releases/latest) and copy the `plugin-update-checker` directory to your plugin or theme. +2. Add the following code to the main plugin file or `functions.php`: + + ```php + require 'plugin-update-checker/plugin-update-checker.php'; + use YahnisElsts\PluginUpdateChecker\v5\PucFactory; + + $myUpdateChecker = PucFactory::buildUpdateChecker( + 'https://bitbucket.org/user-name/repo-name', + __FILE__, + 'unique-plugin-or-theme-slug' + ); + + //Optional: If you're using a private repository, create an OAuth consumer + //and set the authentication credentials like this: + //Note: For now you need to check "This is a private consumer" when + //creating the consumer to work around #134: + // https://github.com/YahnisElsts/plugin-update-checker/issues/134 + $myUpdateChecker->setAuthentication(array( + 'consumer_key' => '...', + 'consumer_secret' => '...', + )); + + //Optional: Set the branch that contains the stable release. + $myUpdateChecker->setBranch('stable-branch-name'); + ``` +3. Optional: Add a `readme.txt` file formatted according to the [WordPress.org plugin readme standard](https://wordpress.org/plugins/readme.txt) to your repository. For plugins, the contents of this file will be shown when the user clicks the "View version 1.2.3 details" link. + +#### How to Release an Update + +BitBucket doesn't have an equivalent to GitHub's releases, so the process is slightly different. You can use any of the following approaches: + +- **`Stable tag` header** + + This is the recommended approach if you're using tags to mark each version. Add a `readme.txt` file formatted according to the [WordPress.org plugin readme standard](https://wordpress.org/plugins/readme.txt) to your repository. Set the "stable tag" header to the tag that represents the latest release. Example: + ```text + Stable tag: v1.2.3 + ``` + The tag doesn't have to start with a "v" or follow any particular format. You can use any name you like as long as it's a valid Git tag. + + Tip: If you explicitly set a stable branch, the update checker will look for a `readme.txt` in that branch. Otherwise it will only look at the `master` branch. + +- **Tags** + + You can skip the "stable tag" bit and just create a new Git tag named `v1.2.3` or `1.2.3`. The update checker will look at the most recent tags and pick the one that looks like the highest version number. + + PUC doesn't require strict adherence to [SemVer](https://semver.org/). These are all valid tag names: `v1.2.3`, `v1.2-foo`, `1.2.3_rc1-ABC`, `1.2.3.4.5`. However, be warned that it's not smart enough to filter out alpha/beta/RC versions. + +- **Stable branch** + + Point the update checker at a stable, production-ready branch: + ```php + $updateChecker->setBranch('branch-name'); + ``` + PUC will periodically check the `Version` header in the main plugin file or `style.css` and display a notification if it's greater than the installed version. Caveat: If you set the branch to `master`, the update checker will still look for tags first. + +### GitLab Integration + +1. Download [the latest release](https://github.com/YahnisElsts/plugin-update-checker/releases/latest) and copy the `plugin-update-checker` directory to your plugin or theme. +2. Add the following code to the main plugin file or `functions.php` and define how you want to check for updates from Gitlab (refer to: [Gitlab: How to Release an Update](#how-to-release-a-gitlab-update)): + + ```php + require 'plugin-update-checker/plugin-update-checker.php'; + use YahnisElsts\PluginUpdateChecker\v5\PucFactory; + + $myUpdateChecker = PucFactory::buildUpdateChecker( + 'https://gitlab.com/user-name/repo-name/', + __FILE__, + 'unique-plugin-or-theme-slug' + ); + + //Optional: If you're using a private repository, specify the access token like this: + $myUpdateChecker->setAuthentication('your-token-here'); + ``` + + Alternatively, if you're using a self-hosted GitLab instance, initialize the update checker like this: + ```php + use YahnisElsts\PluginUpdateChecker\v5p4\Vcs\PluginUpdateChecker; + use YahnisElsts\PluginUpdateChecker\v5p4\Vcs\GitLabApi; + + $myUpdateChecker = new PluginUpdateChecker( + new GitLabApi('https://myserver.com/user-name/repo-name/'), + __FILE__, + 'unique-plugin-or-theme-slug' + ); + //Optional: Add setAuthentication(...) and setBranch(...) as shown above. + ``` + If you're using a self-hosted GitLab instance and [subgroups or nested groups](https://docs.gitlab.com/ce/user/group/subgroups/index.html), you have to tell the update checker which parts of the URL are subgroups: + ```php + use YahnisElsts\PluginUpdateChecker\v5p4\Vcs\PluginUpdateChecker; + use YahnisElsts\PluginUpdateChecker\v5p4\Vcs\GitLabApi; + + $myUpdateChecker = new PluginUpdateChecker( + new GitLabApi( + 'https://myserver.com/group-name/subgroup-level1/subgroup-level2/subgroup-level3/repo-name/', + null, + 'subgroup-level1/subgroup-level2/subgroup-level3' + ), + __FILE__, + 'unique-plugin-or-theme-slug' + ); + ``` + +3. Plugins only: Add a `readme.txt` file formatted according to the [WordPress.org plugin readme standard](https://wordpress.org/plugins/readme.txt) to your repository. The contents of this file will be shown when the user clicks the "View version 1.2.3 details" link. + +#### How to Release a GitLab Update + +A GitLab repository can be checked for updates in 3 different ways. + +- **GitLab releases** + + Create a new release using the "Releases" feature on GitLab. The tag name should match the version number. You can add a `v` prefix to the tag, like `v1.2.3`. Releases that are marked as ["Upcoming Release"](https://docs.gitlab.com/ee/user/project/releases/index.html#upcoming-releases) will be automatically ignored. + + If you want to use custom release assets, call the `enableReleaseAssets()` method after creating the update checker instance: + ```php + $myUpdateChecker->getVcsApi()->enableReleaseAssets(); + ``` + + By default, PUC will use the first available asset link, regardless of type. You can pass a regular expression to `enableReleaseAssets()` to make it pick the first link where the URL matches the regex. For example: + ```php + $myUpdateChecker->getVcsApi()->enableReleaseAssets('/\.zip($|[?&#])/i'); + ``` + + **Tip:** You can use a Gitlab CI/CD Pipeline to automatically generate your update on release using a Generic Package. For more information about generic packages, refer to the following links: + - [Gitlab CI/CD Release Documentation](https://docs.gitlab.com/ee/user/project/releases/#create-release-from-gitlab-ci) + - [Gitlab Release Assets as Generic Package Documentation](https://gitlab.com/gitlab-org/release-cli/-/tree/master/docs/examples/release-assets-as-generic-package/) + - [Example .gitlab-ci.yml file using Release Generic Packages for generating a update package from the Sensei-LMS wordpress plugin](https://gist.github.com/timwiel/9dfd3526c768efad4973254085e065ce) + +- **Tags** + + To release version 1.2.3, create a new Git tag named `v1.2.3` or `1.2.3`. The update checker will look at recent tags and use the one that looks like the highest version number. + + PUC doesn't require strict adherence to [SemVer](https://semver.org/). However, be warned that it's not smart enough to filter out alpha/beta/RC versions. If that's a problem, you might want to use GitLab branches instead. + +- **Stable branch** + + Point the update checker at any stable, production-ready branch: + ```php + $myUpdateChecker->setBranch('stable-branch-name'); + ``` + PUC will periodically check the `Version` header in the main plugin file or `style.css` and display a notification if it's greater than the installed version. Caveat: Even if you set the branch to `main` (the default) or `master` (the historical default), the update checker will still look for recent releases and tags first. + +Migrating from 4.x +------------------ + +Older versions of the library didn't use namespaces. Code that was written for those versions will need to be updated to work with the current version. At a minimum, you'll need to change the factory class name. + +Old code: +```php +$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker( + 'https://example.com/info.json', + __FILE__, + 'my-slug' +); +``` + +New code: +```php +use YahnisElsts\PluginUpdateChecker\v5\PucFactory; + +$myUpdateChecker = PucFactory::buildUpdateChecker( + 'https://example.com/info.json', + __FILE__, + 'my-slug' +); +``` + +Other classes have also been renamed, usually by simply removing the `Puc_vXpY_` prefix and converting `Category_Thing` to `Category\Thing`. Here's a table of the most commonly used classes and their new names: + +| Old class name | New class name | +|-------------------------------------|----------------------------------------------------------------| +| `Puc_v4_Factory` | `YahnisElsts\PluginUpdateChecker\v5\PucFactory` | +| `Puc_v4p13_Factory` | `YahnisElsts\PluginUpdateChecker\v5p4\PucFactory` | +| `Puc_v4p13_Plugin_UpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p4\Plugin\UpdateChecker` | +| `Puc_v4p13_Theme_UpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p4\Theme\UpdateChecker` | +| `Puc_v4p13_Vcs_PluginUpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p4\Vcs\PluginUpdateChecker` | +| `Puc_v4p13_Vcs_ThemeUpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p4\Vcs\ThemeUpdateChecker` | +| `Puc_v4p13_Vcs_GitHubApi` | `YahnisElsts\PluginUpdateChecker\v5p4\Vcs\GitHubApi` | +| `Puc_v4p13_Vcs_GitLabApi` | `YahnisElsts\PluginUpdateChecker\v5p4\Vcs\GitLabApi` | +| `Puc_v4p13_Vcs_BitBucketApi` | `YahnisElsts\PluginUpdateChecker\v5p4\Vcs\BitBucketApi` | + +License Management +------------------ + +Currently, the update checker doesn't have any built-in license management features. It only provides some hooks that you can use to, for example, append license keys to update requests (`$updateChecker->addQueryArgFilter()`). If you're looking for ways to manage and verify licenses, please post your feedback in [this issue](https://github.com/YahnisElsts/plugin-update-checker/issues/222). + +Resources +--------- + +- [This blog post](https://w-shadow.com/blog/2010/09/02/automatic-updates-for-any-plugin/) has more information about the update checker API. *Slightly out of date.* +- [Debug Bar](https://wordpress.org/plugins/debug-bar/) - useful for testing and debugging the update checker. +- [Update format reference](https://docs.google.com/spreadsheets/d/1eOBbW7Go2qEQXReOOCdidMTf_tDYRq4JfegcO1CBPIs/edit?usp=sharing) - describes all fields supported by the JSON-based update information format used by the update checker. Only covers plugins. Themes use a similar but more limited format. +- [Securing download links](https://w-shadow.com/blog/2013/03/19/plugin-updates-securing-download-links/) - a general overview. +- [A GUI for entering download credentials](https://open-tools.net/documentation/tutorial-automatic-updates.html#wordpress) +- [Theme Update Checker](https://w-shadow.com/blog/2011/06/02/automatic-updates-for-commercial-themes/) - an older, theme-only variant of this update checker. diff --git a/includes/plugin-update-checker/composer.json b/includes/plugin-update-checker/composer.json new file mode 100644 index 0000000..f7af7eb --- /dev/null +++ b/includes/plugin-update-checker/composer.json @@ -0,0 +1,23 @@ +{ + "name": "yahnis-elsts/plugin-update-checker", + "type": "library", + "description": "A custom update checker for WordPress plugins and themes. Useful if you can't host your plugin in the official WP repository but still want it to support automatic updates.", + "keywords": ["wordpress", "plugin updates", "automatic updates", "theme updates"], + "homepage": "https://github.com/YahnisElsts/plugin-update-checker/", + "license": "MIT", + "authors": [ + { + "name": "Yahnis Elsts", + "email": "whiteshadow@w-shadow.com", + "homepage": "https://w-shadow.com/", + "role": "Developer" + } + ], + "require": { + "php": ">=5.6.20", + "ext-json": "*" + }, + "autoload": { + "files": ["load-v5p4.php"] + } +} diff --git a/includes/plugin-update-checker/css/puc-debug-bar.css b/includes/plugin-update-checker/css/puc-debug-bar.css new file mode 100644 index 0000000..649db4f --- /dev/null +++ b/includes/plugin-update-checker/css/puc-debug-bar.css @@ -0,0 +1,70 @@ +.puc-debug-bar-panel-v5 pre { + margin-top: 0; +} + +/* Style the debug data table to match "widefat" table style used by WordPress. */ +table.puc-debug-data { + width: 100%; + clear: both; + margin: 0; + + border-spacing: 0; + background-color: #f9f9f9; + + border-radius: 3px; + border: 1px solid #dfdfdf; + border-collapse: separate; +} + +table.puc-debug-data * { + word-wrap: break-word; +} + +table.puc-debug-data th { + width: 11em; + padding: 7px 7px 8px; + text-align: left; + + font-family: "Georgia", "Times New Roman", "Bitstream Charter", "Times", serif; + font-weight: 400; + font-size: 14px; + line-height: 1.3em; + text-shadow: rgba(255, 255, 255, 0.804) 0 1px 0; +} + +table.puc-debug-data td, table.puc-debug-data th { + border-width: 1px 0; + border-style: solid; + + border-top-color: #fff; + border-bottom-color: #dfdfdf; + + text-transform: none; +} + +table.puc-debug-data td { + color: #555; + font-size: 12px; + padding: 4px 7px 2px; + vertical-align: top; +} + +.puc-ajax-response { + border: 1px solid #dfdfdf; + border-radius: 3px; + padding: 0.5em; + margin: 5px 0; + background-color: white; +} + +.puc-ajax-nonce { + display: none; +} + +.puc-ajax-response dt { + margin: 0; +} + +.puc-ajax-response dd { + margin: 0 0 1em; +} diff --git a/includes/plugin-update-checker/js/debug-bar.js b/includes/plugin-update-checker/js/debug-bar.js new file mode 100644 index 0000000..80f53f1 --- /dev/null +++ b/includes/plugin-update-checker/js/debug-bar.js @@ -0,0 +1,54 @@ +jQuery(function($) { + + function runAjaxAction(button, action) { + button = $(button); + var panel = button.closest('.puc-debug-bar-panel-v5'); + var responseBox = button.closest('td').find('.puc-ajax-response'); + + responseBox.text('Processing...').show(); + $.post( + ajaxurl, + { + action : action, + uid : panel.data('uid'), + _wpnonce: panel.data('nonce') + }, + function(data) { + //The response contains HTML that should already be escaped in server-side code. + //phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html + responseBox.html(data); + }, + 'html' + ); + } + + $('.puc-debug-bar-panel-v5 input[name="puc-check-now-button"]').on('click', function() { + runAjaxAction(this, 'puc_v5_debug_check_now'); + return false; + }); + + $('.puc-debug-bar-panel-v5 input[name="puc-request-info-button"]').on('click', function() { + runAjaxAction(this, 'puc_v5_debug_request_info'); + return false; + }); + + + // Debug Bar uses the panel class name as part of its link and container IDs. This means we can + // end up with multiple identical IDs if more than one plugin uses the update checker library. + // Fix it by replacing the class name with the plugin slug. + var panels = $('#debug-menu-targets').find('.puc-debug-bar-panel-v5'); + panels.each(function() { + var panel = $(this); + var uid = panel.data('uid'); + var target = panel.closest('.debug-menu-target'); + + //Change the panel wrapper ID. + target.attr('id', 'debug-menu-target-puc-' + uid); + + //Change the menu link ID as well and point it at the new target ID. + $('#debug-bar-menu').find('.puc-debug-menu-link-' + uid) + .closest('.debug-menu-link') + .attr('id', 'debug-menu-link-puc-' + uid) + .attr('href', '#' + target.attr('id')); + }); +}); \ No newline at end of file diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-ca.mo b/includes/plugin-update-checker/languages/plugin-update-checker-ca.mo new file mode 100644 index 0000000000000000000000000000000000000000..59645faba22e5f3b1358ef076a01d5a7fa3aa534 GIT binary patch literal 1186 zcmZ`&%We}f6g5yD3JU~l7MF@jAn=eGUhPB?f>02mg$Po_u5xE?6T{RV*`7X-koW+0 zhy^>uFR+0P5@LzOC$M16M{p*S5}sDhoY=mPbM5P|$7Ws%jDx^&U;rEjo&)uG2OI_7 z0|a~qW`XZO7dWy8}I`73-}WF&`jfh1$+|or(n2@ z$6kD4Ca@&-k5_~^FyUI~c=Se`J*IW*s48<6*o(o49h3HCEM+5QhFsVosZFH|wN`K> zR?K5#x6H%=Hi*EEd{CkCG&|>KMHn%aMK#ohf(`}GTqVO>w8_qEYsjusZ87I}jgak^ z1b=z=Y*pmY6Da4vZbKUgT;Ekp3VMIKk87Fp(ccPYmReZ*Oiw{rQQ zQJGG}$>w0>q|R3V?m+e&tAI-6bvUP#wByS%j%9Lz;>&3}Inz$sZ5YaXys7Jor*;dn zy&#i|6wjye#l~(4XI!Zv%K@v6lv>NTmKUcY;;7x~Srga|VW$KqCtXwwgL#J#*X-o9%M(OOP zBClzLpCXloN)jJ<-gN!%O{ zB>(p8)gMt|<1=e`ScRtXSByfRLdUq(KfSFJ6!629vGE!UXnOYH)9c?7LY#*cWS6#% cwcF+j&+0z~QHeLF5H1o+|4uN~nyX0s0EpISt^fc4 literal 0 HcmV?d00001 diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-ca.po b/includes/plugin-update-checker/languages/plugin-update-checker-ca.po new file mode 100644 index 0000000..36f3ad7 --- /dev/null +++ b/includes/plugin-update-checker/languages/plugin-update-checker-ca.po @@ -0,0 +1,48 @@ +msgid "" +msgstr "" +"Project-Id-Version: plugin-update-checker\n" +"POT-Creation-Date: 2017-11-24 17:02+0200\n" +"PO-Revision-Date: 2019-09-25 18:15+0200\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.2.3\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"Last-Translator: \n" +"Language: ca\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v4p3/Plugin/UpdateChecker.php:395 +msgid "Check for updates" +msgstr "Comprova si hi ha actualitzacions" + +#: Puc/v4p3/Plugin/UpdateChecker.php:548 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "L’extensió %s està actualitzada." + +#: Puc/v4p3/Plugin/UpdateChecker.php:550 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "Una nova versió de l’extensió %s està disponible." + +#: Puc/v4p3/Plugin/UpdateChecker.php:552 +#, php-format +msgctxt "the plugin title" +msgid "Could not determine if updates are available for %s." +msgstr "No s’ha pogut determinar si hi ha actualitzacions per a %s." + +#: Puc/v4p3/Plugin/UpdateChecker.php:558 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Estat del comprovador d’actualitzacions desconegut \"%s\"" + +#: Puc/v4p3/Vcs/PluginUpdateChecker.php:95 +msgid "There is no changelog available." +msgstr "No hi ha cap registre de canvis disponible." diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-cs_CZ.mo b/includes/plugin-update-checker/languages/plugin-update-checker-cs_CZ.mo new file mode 100644 index 0000000000000000000000000000000000000000..ac6d20ea77cb6c6ad2aa9204312c53c86078e08c GIT binary patch literal 1077 zcmZWoO>fgc5H(P7$gP|Z>S3s;)T*rGq^c+m;iI8N6={juv{b!B8+#f%adxfUb=pSo z8#o~jobm&Z`UiRnH;&x-8(f*KlYWSm#&5^_=Iz_H=g)(guMUm-6mt}Ho6z`_!zIqr z{4)hme4&`9IH#ym{H9o{DPi$ zOoWgoStk}?Vw2#^8xVK`15`Se0^~7R#)6)bXtx_1{8vquZj-YVj0Ee~bs9=`F)(Z^ zWCyvvKapkmk=VpxVHZ=W4BOV7IArTtN3*8%q0soyWHp7{kTv#}G<_(0rDx1rWn~Xa zp1-=X?5%hn5!o&dVta&JJWGYrs=xAl*`raYb8T2taiJ4#r1IfFcFoW4K?Hle8z%5# zKsg4{Yi(0Eko}ibBRU!HAZsG;`%oLwIxOZuzO!}`2TNBh9|Fy4M}1DW(aJMa6z~rO{OP zo11Lynr9DmjEZfDK!&mC_^{TFP2rH$Wgyv}%v6AO&J)rLbc_5QvUey@<+osIz#uXv z)qb&#;UIv|5!G zR$8Zi>1jD2yrF_z1yO_4nMeAxaB00^k4vA49LZK{lU6F7qaIz5l8GE}1H5N4ay#S! zQp-%6LZBG`fKY0arDA;HIy*QN<57QnG3|zl#@P)4s<`Zt9XS|}Y)cHMy^`6Vyo*\n" +"Language-Team: Czech (Czech Republic)\n" +"Language: cs-CZ\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Loco-Source-Locale: cs_CZ\n" +"X-Generator: Loco - https://localise.biz/\n" +"X-Poedit-Basepath: ..\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"X-Poedit-SearchPath-0: .\n" +"X-Loco-Parser: loco_parse_po" + +#: Puc/v4p1/Plugin/UpdateChecker.php:358 +msgid "Check for updates" +msgstr "Zkontrolovat aktualizace" + +#: Puc/v4p1/Plugin/UpdateChecker.php:405 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "Plugin %s je aktuální." + +#: Puc/v4p1/Plugin/UpdateChecker.php:407 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "Nová verze pluginu %s je dostupná." + +#: Puc/v4p1/Plugin/UpdateChecker.php:409 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Neznámý status kontroly aktualizací \"%s\"" + +#: Puc/v4p1/Vcs/PluginUpdateChecker.php:83 +msgid "There is no changelog available." +msgstr "Changelog není dostupný." diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-da_DK.mo b/includes/plugin-update-checker/languages/plugin-update-checker-da_DK.mo new file mode 100644 index 0000000000000000000000000000000000000000..9c59670712307a7dec1419ce48ba2613300f91aa GIT binary patch literal 1010 zcmZWo&u`N(7!5EuloK2gLLWoZK*J&FHf>7P19Tgjwux$VXt&C1zNV&`UD?ilNF4Yl zICDerA0Tnu9f>>QUxAmVTRUOp<@vKee}1uF{@kDY6rkM!9s;|-UEl*ywy(fF;2S`| z4`3en4K#tjfGGPng5Vc01Rj*}tsqzgAA%o&KY~N>XYdp7PcTx)?Izv`gE`>#c%;%Z z=~mPlaBoO`W2qRW(z6RX1GY@ckv7yDNS$$RGLk1!pfh*m{CqBu%cmzSdDC_fzu32xChlg(SsiwzG zik~&61>Ty%_PAB)N~jWcRep!hPmN98u5v!1Znx3pM)xd?r#a!z{8deTEILSHoGs%F|hy=lDlbzO2ta4E_O#F(`Ea literal 0 HcmV?d00001 diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-da_DK.po b/includes/plugin-update-checker/languages/plugin-update-checker-da_DK.po new file mode 100644 index 0000000..8f2bc0d --- /dev/null +++ b/includes/plugin-update-checker/languages/plugin-update-checker-da_DK.po @@ -0,0 +1,42 @@ +msgid "" +msgstr "" +"Project-Id-Version: plugin-update-checker\n" +"POT-Creation-Date: 2017-05-20 10:53+0300\n" +"PO-Revision-Date: 2017-10-17 11:07+0200\n" +"Last-Translator: Mikk3lRo\n" +"Language-Team: Mikk3lRo\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.0.4\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"Language: da_DK\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v4p1/Plugin/UpdateChecker.php:358 +msgid "Check for updates" +msgstr "Undersøg for opdateringer" + +#: Puc/v4p1/Plugin/UpdateChecker.php:405 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "Plugin'et %s er allerede opdateret." + +#: Puc/v4p1/Plugin/UpdateChecker.php:407 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "En ny version af plugin'et %s er tilgængelig." + +#: Puc/v4p1/Plugin/UpdateChecker.php:409 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Ukendt opdateringsstatus: \"%s\"" + +#: Puc/v4p1/Vcs/PluginUpdateChecker.php:83 +msgid "There is no changelog available." +msgstr "Der er ingen ændringslog tilgængelig." diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-de_DE.mo b/includes/plugin-update-checker/languages/plugin-update-checker-de_DE.mo new file mode 100644 index 0000000000000000000000000000000000000000..0734cae2dc9b76d41f5f6f99b1380ec2f685e1be GIT binary patch literal 980 zcmZuv&2AGh7+j!$6i)Plgi!Sn35g$h$wp9>4M9MfqKXtEnj&tIll`(;vauuEn^K9_ z;K+>wJOH=e`U)I4apXA|chjbourxcLcR$aL?fJ91@+H8y0^9;Rz%}4A;Kz61KJWv$ z4*UWL_zTrP?cpW?f-vECFuYrGp(Rw^k1}lK~;K#+1 zPM?>3^@0@d)0~aXv?4tsH_j~0@*>R?p^|f%<#Ld77_`PboX|)cDrSjvY=hpI4f`&o zX*iZDVih)w9nRIf$rqP8yTPf*77=s_*2)zB#3@jUaJ{ZC&MKYCpD zb)1n1$`gw*|dEss6VZzTU9UMR*Qx-jz)0iqd+dJ*0 z@hGfST3R_)5I&f}q2o{P;VhS#YWUMLmR)nNw\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.1\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e\n" +"Language: de_DE\n" +"X-Poedit-SearchPath-0: .\n" + +#: github-checker.php:137 +msgid "There is no changelog available." +msgstr "Es ist keine Liste von Programmänderungen verfügbar." + +#: plugin-update-checker.php:852 +msgid "Check for updates" +msgstr "Nach Update suchen" + +#: plugin-update-checker.php:896 +msgid "This plugin is up to date." +msgstr "Das Plugin ist aktuell." + +#: plugin-update-checker.php:898 +msgid "A new version of this plugin is available." +msgstr "Es ist eine neue Version für das Plugin verfügbar." + +#: plugin-update-checker.php:900 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Unbekannter Update Status \"%s\"" diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-es_AR.mo b/includes/plugin-update-checker/languages/plugin-update-checker-es_AR.mo new file mode 100644 index 0000000000000000000000000000000000000000..85afecd344184a07c3ff0117b87066af6850078c GIT binary patch literal 1140 zcmZ`&O>Yx15H(Oh3I{~bNDP%KQ3)?e3R1OE4ke_hqJ@a2sJF=7ohGImJF>lL%WvR@ z;Ep(Q1ys0DpicaPyK7ZSW>og5QBZ06zf2e&>o1OW-4L1N;eG2mc1Ig6HRixC8Ej;WAm5 z@x*6=BXMR7dj`aHQ;2Q_N=3Pl&Zj9bO-F1v?pUJ87R}|%=Sr*mCn>|#*x@I z`^FxasRL{ffgSmvLhfl{(JzQFU>aq4UmFTKWIVS@h7V}W&TDJP?onZ}=ueH1Z6?75 z@0QK86nX-s9M}!Dfxx{}#iXG3%zaYJqK__WKwOn%Py;7OqI>` z&GvchT2!sHtO;y_>>iB}CGcT*Fv^rRjiT?)b7*dN*W}8%om0l|v6F3+*i@T-Oe?!O zRCeT3HtbZeE~bv_PzGjOdeJ)8FV03Rw1?`T6Q>cc2{A%G!4`dsU+ko({EIQ{$pC7+sScm$Z;R} z9eyZNqK3QLdP=n)S)(Uo+s1&V#n+6IY19;B59^tjCtnOsd}57FG^~$5FZ$!}72lxoiWYRWOg{3oR?75F~?_B?$o%tZJZUT3KE^rHY2NdfYa0mDf z5bz6_1O5U{;Pw?E+Taba1iuG=1bza9{q{8>7Qjc~2KY0$4*mmP0ng3|aSz-D!)3g# z;)%}!N8S2|NW8AoEv z>=}DtCJwMc1a{7<-l&J4Fv9_j(zvU@Z_l)#7K(I`{eG>X1E&!M^1U6sq{c1{_;%TBgUVpDDUF)i=t zP}!Ex*sxQ(_-UOutnL`j2USVaLb0A;*2> zcle=9i5l)`>nYWKWQ`t=Z5soc7GE<;CQ(z2J*=l2lxoiWYRWOg{3oR?75F~?_B?$o%tZJZUT3KE^rHY2NdfYa0mDf z5bz6_1O5U{;Pw?E+Taba1iuG=1bza9{q{8>7Qjc~2KY0$4*mmP0ng3|aSz-D!)3g# z;)%}!N8S2|NW8AoEv z>=}DtCJwMc1a{7<-l&J4Fv9_j(zvU@Z_l)#7K(I`{eG>X1E&!M^1U6sq{c1{_;%TBgUVpDDUF)i=t zP}!Ex*sxQ(_-UOutnL`j2USVaLb0A;*2> zcle=9i5l)`>nYWKWQ`t=Z5soc7GE<;CQ(z2J*=l2lxoiWYRWOg{3oR?75F~?_B?$o%tZJZUT3KE^rHY2NdfYa0mDf z5bz6_1O5U{;Pw?E+Taba1iuG=1bza9{q{8>7Qjc~2KY0$4*mmP0ng3|aSz-D!)3g# z;)%}!N8S2|NW8AoEv z>=}DtCJwMc1a{7<-l&J4Fv9_j(zvU@Z_l)#7K(I`{eG>X1E&!M^1U6sq{c1{_;%TBgUVpDDUF)i=t zP}!Ex*sxQ(_-UOutnL`j2USVaLb0A;*2> zcle=9i5l)`>nYWKWQ`t=Z5soc7GE<;CQ(z2J*=l2lxoiWYRWOg{3oR?75F~?_B?$o%tZJZUT3KE^rHY2NdfYa0mDf z5bz6_1O5U{;Pw?E+Taba1iuG=1bza9{q{8>7Qjc~2KY0$4*mmP0ng3|aSz-D!)3g# z;)%}!N8S2|NW8AoEv z>=}DtCJwMc1a{7<-l&J4Fv9_j(zvU@Z_l)#7K(I`{eG>X1E&!M^1U6sq{c1{_;%TBgUVpDDUF)i=t zP}!Ex*sxQ(_-UOutnL`j2USVaLb0A;*2> zcle=9i5l)`>nYWKWQ`t=Z5soc7GE<;CQ(z2J*=l z*dvxK*??HlF8K%e0X~8=nY2w+Vd=~nd+y`hJJ-KwXFdq5>%eWG3)}$S0mb?T+ycG> z1pET#fWJT!xOqv4Hh3K@!SBHzfu8_jzjZ~31@Ixb0saiGga3e+!Lu_$+yQsNa2c=5 zc;d6bk+?cO5#ri}3!UTD8gQ~pJJwM?N>yMlx&wAh+LN)A43z0}X8WY}l+M(4#*x@G zyTaq4UmFTKWIVG>hWBZYo!8co-J!x_-k%sD+f;%J z-YuJFDf9$NIj|dQ1A#jyib+B5sr$H=c^_TWfWpqF%tsU~6;(%~r!Pr z5hu&W$Vr`*&P(}<_jFN+deYHxRu^TxMzx3WqsOxPuv)FGp>?_Hv+S}O##C8f zU2mVou0_>K%bLI@$nN0?Q34-?2ct}B(tgCyPIaJqw21R^BcCYGBNYZQMNy@b29(>znmPQ7>Mb z_YB=_Qf;Ae7GT5XF5yt*2D`ku`cewrvb(T71nYnM6%7_OPCcdHmJj#3$C+M8o>%%e+7Ofst2a za^6$r2$xpb)HJaV$DhungD{UvkdITAL;K$2lxoiWYRWOg{3oR?75F~?_B?$o%tZJZUT3KE^rHY2NdfYa0mDf z5bz6_1O5U{;Pw?E+Taba1iuG=1bza9{q{8>7Qjc~2KY0$4*mmP0ng3|aSz-D!)3g# z;)%}!N8S2|NW8AoEv z>=}DtCJwMc1a{7<-l&J4Fv9_j(zvU@Z_l)#7K(I`{eG>X1E&!M^1U6sq{c1{_;%TBgUVpDDUF)i=t zP}!Ex*sxQ(_-UOutnL`j2USVaLb0A;*2> zcle=9i5l)`>nYWKWQ`t=Z5soc7GE<;CQ(z2J*=l2lxoiWYRWOg{3oR?75F~?_B?$o%tZJZUT3KE^rHY2NdfYa0mDf z5bz6_1O5U{;Pw?E+Taba1iuG=1bza9{q{8>7Qjc~2KY0$4*mmP0ng3|aSz-D!)3g# z;)%}!N8S2|NW8AoEv z>=}DtCJwMc1a{7<-l&J4Fv9_j(zvU@Z_l)#7K(I`{eG>X1E&!M^1U6sq{c1{_;%TBgUVpDDUF)i=t zP}!Ex*sxQ(_-UOutnL`j2USVaLb0A;*2> zcle=9i5l)`>nYWKWQ`t=Z5soc7GE<;CQ(z2J*=l z*dvxK*??HlF8K%e0X~8=nY2w+Vd=~nd+y`hJJ-KwXFdq5>%eWG3)}$S0mb?T+ycG> z1pET#fWJT!xOqv4Hh3K@!SBHzfu8_jzjZ~31@Ixb0saiGga3e+!Lu_$+yQsNa2c=5 zc;d6bk+?cO5#ri}3!UTD8gQ~pJJwM?N>yMlx&wAh+LN)A43z0}X8WY}l+M(4#*x@G zyTaq4UmFTKWIVG>hWBZYo!8co-J!x_-k%sD+f;%J z-YuJFDf9$NIj|dQ1A#jyib+B5sr$H=c^_TWfWpqF%tsU~6;(%~r!Pr z5hu&W$Vr`*&P(}<_jFN+deYHxRu^TxMzx3WqsOxPuv)FGp>?_Hv+S}O##C8f zU2mVou0_>K%bLI@$nN0?Q34-?2ct}B(tgCyPIaJqw21R^BcCYGBNYZQMNy@b29(>znmPQ7>Mb z_YB=_Qf;Ae7GT5XF5yt*2D`ku`cewrvb(T71nYnM6%7_OPCcdHmJj#3$C+M8o>%%e+7Ofst2a za^6$r2$xpb)HJaV$DhungD{UvkdITAL;K$2lxoiWYRWOg{3oR?75F~?_B?$o%tZJZUT3KE^rHY2NdfYa0mDf z5bz6_1O5U{;Pw?E+Taba1iuG=1bza9{q{8>7Qjc~2KY0$4*mmP0ng3|aSz-D!)3g# z;)%}!N8S2|NW8AoEv z>=}DtCJwMc1a{7<-l&J4Fv9_j(zvU@Z_l)#7K(I`{eG>X1E&!M^1U6sq{c1{_;%TBgUVpDDUF)i=t zP}!Ex*sxQ(_-UOutnL`j2USVaLb0A;*2> zcle=9i5l)`>nYWKWQ`t=Z5soc7GE<;CQ(z2J*=l2lxoiWYRWOg{3oR?75F~?_B?$o%tZJZUT3KE^rHY2NdfYa0mDf z5bz6_1O5U{;Pw?E+Taba1iuG=1bza9{q{8>7Qjc~2KY0$4*mmP0ng3|aSz-D!)3g# z;)%}!N8S2|NW8AoEv z>=}DtCJwMc1a{7<-l&J4Fv9_j(zvU@Z_l)#7K(I`{eG>X1E&!M^1U6sq{c1{_;%TBgUVpDDUF)i=t zP}!Ex*sxQ(_-UOutnL`j2USVaLb0A;*2> zcle=9i5l)`>nYWKWQ`t=Z5soc7GE<;CQ(z2J*=l2lxoiWYRWOg{3oR?75F~?_B?$o%tZJZUT3KE^rHY2NdfYa0mDf z5bz6_1O5U{;Pw?E+Taba1iuG=1bza9{q{8>7Qjc~2KY0$4*mmP0ng3|aSz-D!)3g# z;)%}!N8S2|NW8AoEv z>=}DtCJwMc1a{7<-l&J4Fv9_j(zvU@Z_l)#7K(I`{eG>X1E&!M^1U6sq{c1{_;%TBgUVpDDUF)i=t zP}!Ex*sxQ(_-UOutnL`j2USVaLb0A;*2> zcle=9i5l)`>nYWKWQ`t=Z5soc7GE<;CQ(z2J*=l z*dvxK*??HlF8K%e0X~8=nY2w+Vd=~nd+y`hJJ-KwXFdq5>%eWG3)}$S0mb?T+ycG> z1pET#fWJT!xOqv4Hh3K@!SBHzfu8_jzjZ~31@Ixb0saiGga3e+!Lu_$+yQsNa2c=5 zc;d6bk+?cO5#ri}3!UTD8gQ~pJJwM?N>yMlx&wAh+LN)A43z0}X8WY}l+M(4#*x@G zyTaq4UmFTKWIVG>hWBZYo!8co-J!x_-k%sD+f;%J z-YuJFDf9$NIj|dQ1A#jyib+B5sr$H=c^_TWfWpqF%tsU~6;(%~r!Pr z5hu&W$Vr`*&P(}<_jFN+deYHxRu^TxMzx3WqsOxPuv)FGp>?_Hv+S}O##C8f zU2mVou0_>K%bLI@$nN0?Q34-?2ct}B(tgCyPIaJqw21R^BcCYGBNYZQMNy@b29(>znmPQ7>Mb z_YB=_Qf;Ae7GT5XF5yt*2D`ku`cewrvb(T71nYnM6%7_OPCcdHmJj#3$C+M8o>%%e+7Ofst2a za^6$r2$xpb)HJaV$DhungD{UvkdITAL;K$mQ_tX!08MILH_4soF=HQY2)>b;uw zdPS|CiLzl66*kv37#%ueT?g!tl`B3eu~99!!4m8t^drg#;awKwS$L1a+fhF33&J2k zBbye>v0L_dUl_1_!S(eAeL;VJkelSGVI|FFnsB3Z1YgZctY~`f$>e<+tcxU3BYIgS z+%K!8Vf4#dlh*_*3BD8&oYRb1O#}_bvZ_WJTBWY^V|~;cQI*e6Oy{O1rpAsI4E-QC zs-zJT238x`#E9qSRwLoD9B|*VPK6noEse9nQJ*tf6`GC7vZ}fZ4MwZu zD0_3T@#CW#X1B@5BH7ztuORM>xV2jLi+l1=f3@F`b_U@Vf-R`G-B$m$|9^wdU*s>7 C2(8ip literal 0 HcmV?d00001 diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-fa_IR.po b/includes/plugin-update-checker/languages/plugin-update-checker-fa_IR.po new file mode 100644 index 0000000..20b6938 --- /dev/null +++ b/includes/plugin-update-checker/languages/plugin-update-checker-fa_IR.po @@ -0,0 +1,38 @@ +msgid "" +msgstr "" +"Project-Id-Version: plugin-update-checker\n" +"POT-Creation-Date: 2016-02-17 14:21+0100\n" +"PO-Revision-Date: 2016-10-28 14:30+0330\n" +"Last-Translator: studio RVOLA \n" +"Language-Team: Pro Style \n" +"Language: fa_IR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.8\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e\n" +"X-Poedit-SearchPath-0: .\n" + +#: github-checker.php:120 +msgid "There is no changelog available." +msgstr "شرحی برای تغییرات یافت نشد" + +#: plugin-update-checker.php:637 +msgid "Check for updates" +msgstr "بررسی برای بروزرسانی " + +#: plugin-update-checker.php:681 +msgid "This plugin is up to date." +msgstr "شما از آخرین نسخه استفاده میکنید . به‌روز باشید" + +#: plugin-update-checker.php:683 +msgid "A new version of this plugin is available." +msgstr "نسخه جدیدی برای افزونه ارائه شده است ." + +#: plugin-update-checker.php:685 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "وضعیت ناشناخته برای بروزرسانی \"%s\"" diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-fr_CA.mo b/includes/plugin-update-checker/languages/plugin-update-checker-fr_CA.mo new file mode 100644 index 0000000000000000000000000000000000000000..24639b694e7ba21e2b5f9997b9f12d2d831ac69a GIT binary patch literal 1208 zcmZuwO>Y}F5M>&-1=K^)9{T|d3>Zk!aJ##85MxybNff&LJ!fDKMyPa&$<1lrsRn<7q_YSWChrKqFfjXPxdlxFOM zc9z_TT8pi4VT5Rx0=(tjbB(E>CsM_c{Zv~B99<|T1-&cxc`jQad0PV#doyHHQ*_j3 zoru1754nu;ppp+3DvPB!xhRZW=Gp0gKaf4oDk2kk56%VUX?9a)nasB-yIG|9mua4+ zFqA*=Ot%@Y?RI3E%PglXExyiWdINTcsBxplEC;Nn1$B-Nj`r3fvLx;FoQ-Uw9GumN z7Wr}fsy0g7ZhJvKaNIo}?8}|ComV!D*vmazx=Pz|K|3cpc7BxKvSqKL^9A)CS2|Lj zq{%k^ESB=F3S6r=DJV%gebabl{uqVi|VxZd)2mcduExMcEhKwf}wB_>y}I zSp_Y0txo@r&rY4M!l4eapy9APLq+?eP?k zF)7{j)~a{~jr_28=aLXszMS-ticFDAM?5%x>GeqCr5X-2)dAo0U+EzPivvUU?U zks{TUjh*jWW$@nSmKTOp=}|W|+S-OVL<)_cG3N7DIL2GGu9>kh zylMa(YY-0?$#&imXoc4E^6>}L+J(@DYE@L{FPASLou;Y5sci}?VQ+d 1);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"Last-Translator: Eric Gagnon \n" +"Language: fr_CA\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v4p3/Plugin/UpdateChecker.php:395 +msgid "Check for updates" +msgstr "Vérifier les mises à jour" + +#: Puc/v4p3/Plugin/UpdateChecker.php:548 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "L’extension %s est à jour." + +#: Puc/v4p3/Plugin/UpdateChecker.php:550 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "Une nouvelle version de l’extension %s est disponible." + +#: Puc/v4p3/Plugin/UpdateChecker.php:552 +#, php-format +msgctxt "the plugin title" +msgid "Could not determine if updates are available for %s." +msgstr "Impossible de déterminer si une mise à jour est disponible pour \"%s\"" + +#: Puc/v4p3/Plugin/UpdateChecker.php:558 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Un problème inconnu est survenu \"%s\"" + +#: Puc/v4p3/Vcs/PluginUpdateChecker.php:95 +msgid "There is no changelog available." +msgstr "Il n’y a aucun journal de mise à jour disponible." diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-fr_FR.mo b/includes/plugin-update-checker/languages/plugin-update-checker-fr_FR.mo new file mode 100644 index 0000000000000000000000000000000000000000..a492d96f6eb4b2d988877b0f15c6adc60613195e GIT binary patch literal 1066 zcmZuw&2AGh5H?Ua1TJs|q*0|xAn1R4EshMJY0DWU2&l2I$v2KbMK|0U|;#BAXDl-5v5>kmhg#p{q2ilDF zG=Mae0WCN$eC}X&&doBPB4jEbNDW?kg)=LlaSS80P8toS4~1gRor&nQO9%WHO_u%@ z=NWhdh2Ma6tl7ud^H#!l%ly$aEiYe*PaRe|TV39?C_H)KuP8WzT3B7=Vey0NLiGIE zldu+sB;?yTl7-i+bql4gP1VW80C^Y1Fro_Ni8QdiyVYKS7peDIG(SHcj{`e0N(8YP zE?3S%BIw)R+ID55wXu5PyBdU*rqLd?=iQ@>40=5D^O+J-*NfY*4t-;%yT+F;bXI8B zN6S}rY!ayl5iIRVUwOyZQKJ>!*a$iX6X~HAgh7q|DVO}EaF_|7Mi2y*j>@f2e9hRQ zi$K%$(b6?)^`e?IZ9LMj4AsZ=i}<%Dw=p(LTM?AL&a=P4qp`7xYfI-N==JJ7toIJ1 z>eE_GOqFo-l7)Fydfb#TmC3>S>g(3#r9)8IIPH*49+J@t+dVz8vM;IS6gn76N6*tQ zuuo=KOM(9N@$(S~5P6*I$*vX(5}YW{gpf#=87-#`4Vg82>hyR>jZan7ItO$fTy955 o^GQ$dXrxafAE8os-pQ0!(Rp-9s3)yWJzYdzPT#&tFf|;ozeSTj4gdfE literal 0 HcmV?d00001 diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-fr_FR.po b/includes/plugin-update-checker/languages/plugin-update-checker-fr_FR.po new file mode 100644 index 0000000..9f18e2c --- /dev/null +++ b/includes/plugin-update-checker/languages/plugin-update-checker-fr_FR.po @@ -0,0 +1,42 @@ +msgid "" +msgstr "" +"Project-Id-Version: plugin-update-checker\n" +"POT-Creation-Date: 2017-07-07 14:53+0200\n" +"PO-Revision-Date: 2017-07-07 14:54+0200\n" +"Language-Team: studio RVOLA \n" +"Language: fr_FR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.0.2\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"Last-Translator: Nicolas GEHIN\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v4p1/Plugin/UpdateChecker.php:358 +msgid "Check for updates" +msgstr "Vérifier les mises à jour" + +#: Puc/v4p1/Plugin/UpdateChecker.php:405 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "L’extension %s est à jour." + +#: Puc/v4p1/Plugin/UpdateChecker.php:407 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "Une nouvelle version de l’extension %s est disponible." + +#: Puc/v4p1/Plugin/UpdateChecker.php:409 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Un problème inconnu est survenu \"%s\"" + +#: Puc/v4p1/Vcs/PluginUpdateChecker.php:85 +msgid "There is no changelog available." +msgstr "Il n’y a aucun journal de mise à jour disponible." diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-hu_HU.mo b/includes/plugin-update-checker/languages/plugin-update-checker-hu_HU.mo new file mode 100644 index 0000000000000000000000000000000000000000..4789ef1da358b7fdef2879615c49eac1fb2dad98 GIT binary patch literal 982 zcmZuvO>fgc5M7{v6i#qKAPz$$#7DIzPDNE5f+!)S6)8m2MckroGO^v*yVmYHB@w@X zTMt~gl@mR1LgEit{Rfqs~~X?#;8rCB&Z?SFfx$FSrAE}nHY;G7CSLItQBH^1Vg1EO9#TD zVSb1ji!7<29|{>@tb&sz{=Z^b3RXc;>#%J(l4?)Rw5XiKQG>CCjDN zB0%n=NIaOw9)wwMeY>)`vDrR8k?YhdEhQ~V+HsPSb&K!p{WKPlY!uh34cg|mzs6UN z^9pA})VwYGY7oi5gO#1gR^IaGC{dS|y9x)91=m?|mT9F7`BPyq6*lz1aVp(7(<0_; zN+-qxNzYE9Y1SLXJ=3&#N5ah}xOW@J0$VE6eQcG!JSdILot0K zq7;Shhh5s8*J%F=%RlWFy*G{WZ;&7A5be=EUVSD1gFvNatULm~a8 zlo;jFzMfKm>?J1uRnMEzVeKiY&H7o2REtp|>#z-zQ1e>Sq4nWu+GNF8dgRPZMcI&l E0BAre\n" +"Language-Team: \n" +"Language: hu_HU\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.6\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e\n" +"X-Poedit-SearchPath-0: .\n" + +#: github-checker.php:137 +msgid "There is no changelog available." +msgstr "Nem érhető el a changelog." + +#: plugin-update-checker.php:852 +msgid "Check for updates" +msgstr "Frissítés ellenőrzése" + +#: plugin-update-checker.php:896 +msgid "This plugin is up to date." +msgstr "Ez a plugin naprakész." + +#: plugin-update-checker.php:898 +msgid "A new version of this plugin is available." +msgstr "Új verzió érhető el a kiegészítőhöz" + +#: plugin-update-checker.php:900 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Ismeretlen a frissítés ellenőrző státusza \"%s\"" + +#~ msgid "Every %d hours" +#~ msgstr "Minden %d órában" diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-it_IT.mo b/includes/plugin-update-checker/languages/plugin-update-checker-it_IT.mo new file mode 100644 index 0000000000000000000000000000000000000000..4b40d32304dd2746496014f89ffc22d7a2b97b53 GIT binary patch literal 1135 zcmZWo%We}f6g5yl3JU}aHn6x(hWBZYo!8co?Ne#7)JzW+epTRe#dQ`8==#i{P6h(1u`EFE?qRKj2SEvEYE~`;Ym5uhs z>QU@kHLA3%32cJw9_EM=_#oWRGo?+V?7Q2#*>|?b$?P zy8L+FotSj!wY$esv2w|<1GO@O-ip9==)O)Aslh;7XVeHi)8ZB8D7p3XE2%6g3^^Vk zyTf&ImNAXcA2{L0Q|)tW^o}k^cM~%T6HN(P?`)RYlTpdzgY}6nU^brQEu+X3c2CWQ z7ZEv|%`GMv3QnXbb>S?x-j9=(eq;R@QqL2~(0ja?Qqf!_<@lG%`ECD~W#$oVRr~{k C>Q&|d literal 0 HcmV?d00001 diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-it_IT.po b/includes/plugin-update-checker/languages/plugin-update-checker-it_IT.po new file mode 100644 index 0000000..db62bb1 --- /dev/null +++ b/includes/plugin-update-checker/languages/plugin-update-checker-it_IT.po @@ -0,0 +1,48 @@ +msgid "" +msgstr "" +"Project-Id-Version: plugin-update-checker\n" +"POT-Creation-Date: 2020-08-08 14:36+0300\n" +"PO-Revision-Date: 2022-05-20 00:17+0200\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 3.0\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"Last-Translator: d79\n" +"Language: it_IT\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v4p11/Plugin/Ui.php:128 +msgid "Check for updates" +msgstr "Verifica aggiornamenti" + +#: Puc/v4p11/Plugin/Ui.php:213 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "Il plugin %s è aggiornato." + +#: Puc/v4p11/Plugin/Ui.php:215 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "Una nuova versione del plugin %s è disponibile." + +#: Puc/v4p11/Plugin/Ui.php:217 +#, php-format +msgctxt "the plugin title" +msgid "Could not determine if updates are available for %s." +msgstr "Non è possibile verificare se c'è un aggiornamento disponibile per %s." + +#: Puc/v4p11/Plugin/Ui.php:223 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Stato di controllo aggiornamenti sconosciuto \"%s\"" + +#: Puc/v4p11/Vcs/PluginUpdateChecker.php:98 +msgid "There is no changelog available." +msgstr "Non c'è alcun registro delle modifiche disponibile." diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-ja.mo b/includes/plugin-update-checker/languages/plugin-update-checker-ja.mo new file mode 100644 index 0000000000000000000000000000000000000000..941b6ba2f4d759727a71a177592dc432753d6a85 GIT binary patch literal 1454 zcmZ{i&2QX97{&((Ukeo<7li0xh_olLy}PJv>NJQDQdCHU3)`wEqKS8Q*NxYm8hL6ENf=|LPzzz6q_)`xP z@+|Zc=6i<-c>z8Ge;Mw;IXs3x1OFX<0KN@B49`DG$m{Sn9I40?&?Ar@2qAb)9)})- z^w52v)L=|BxI0H{VN6?5l}RqhbQp8$1$fnD(hCF1X2X`Gc|j@-u0IJHgw$=Ypw9iU zPT4&3d^YQIlN<@=g0LOzq(TgG^Oy?BWJ}QDyci}&J>I5OF0n=s+2AztTXip>(vv

?Y+5Q5_Zx+>QQSw1WxG&* zrLezHK%nsfpZ9cg4~#38`f*cCNTU+7K=@3Cu}vkLqX%#+mrMKJtT(ZFrW-cj$W7rV zv{;=R70#L<*`3?;IGcIb$xR=co*aM{%|dP>3?vVbeK7*2U0m0JT0h z!V+FH^0^^o>_yzDWB1!^(Q;aD&hc9@^NoWz$ik)p7GNsIilh2C;c=`mI)HtTFX}R4 z$`jJ2Gc%(z3wH6)_zu}XeWNoRX?eQRTlbkA>em)ACb{=R#4LnYT#lB)ESN^Ys-yh^`RODR#= z7dlz`tI95^Y<*B9>GX4}*TvxWhZ*s ze#7(MH_zQ(`X(=MBYhn3Zh!aV*2)d=(q1F0DqU0QiY}aVx)+uJdoNJ(`CZgsYh=AR y=?qBkY{yP0=y0v7\n" +"Language-Team: \n" +"Language: ja_JP\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.2.3\n" +"X-Poedit-Basepath: ../../../../../../Applications/XAMPP/xamppfiles/htdocs/" +"kisagai/wordpress/wp-content/plugins/simple-stripe-gateway/Puc\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Poedit-KeywordsList: __;_x:1,2c\n" +"X-Poedit-SearchPath-0: .\n" + +#: v4p7/Plugin/Ui.php:54 +msgid "View details" +msgstr "詳細を表示" + +#: v4p7/Plugin/Ui.php:77 +#, php-format +msgid "More information about %s" +msgstr "%sについての詳細" + +#: v4p7/Plugin/Ui.php:128 +msgid "Check for updates" +msgstr "アップデートを確認" + +#: v4p7/Plugin/Ui.php:213 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "%s プラグインは、最新バージョンです。" + +#: v4p7/Plugin/Ui.php:215 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "%s プラグインの最新バージョンがあります。" + +#: v4p7/Plugin/Ui.php:217 +#, php-format +msgctxt "the plugin title" +msgid "Could not determine if updates are available for %s." +msgstr "%s のアップデートがあるかどうかを判断できませんでした。" + +#: v4p7/Plugin/Ui.php:223 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "バージョンアップの確認で想定外の状態になりました。ステータス:”%s”" + +#: v4p7/Vcs/PluginUpdateChecker.php:98 +msgid "There is no changelog available." +msgstr "更新履歴はありません。" diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-nl_BE.mo b/includes/plugin-update-checker/languages/plugin-update-checker-nl_BE.mo new file mode 100644 index 0000000000000000000000000000000000000000..1cea26dda30ca887087e965d5b494716e48d8416 GIT binary patch literal 1211 zcmah|&59F25N>rQ;T9t9u4ClK@z{3ericUi%PFW*e3e!i-y`f+yUy}&sMoC5~HDc}uIo=?CT;4?tL zH((9;33PzdM}+8sx4;to4*U!F0+jJS9ur~}{2hE1{2P1`yuKnt8~g}d`n?6iWpR$; z7iI!i;`ri5h!aaLbuLbK%E^qz)=`nCDzF!WDLW?Z$yiFJ%1k)36H?nsXKIvjB%Yd? zu{&nz02@SLM?R=fcv@TcYa&dU@~oI>LqUg(S8kKx9olB+wKZhNR9dY2T_a@Mm*9|h z*A`g{J%LgV?B?1);CNRtDd_#{zNls0M~5|_u!AX!oPwpY>PYmReZfhP_fz?-QW-DB z$*M7OS!b>Pa3H&mRX`>3E}Ua()*CHZzapF0sL_fW*DltZ^*RjYW8T(f#s9Rs(yZ(@ z(c?l*SPodtW2$Z4-|Fp&Xhii|*P6g4$ib@|*#f@|m-9?%(=I=d^Bg))2OF}rXXljh zV|KD<5}Rr>iK#Wxq4r$fW5Z4b>tgC#PIaJ0)QYZ04g6PK$UDk&uEI2?D5~|d!l_Jd zSU2}E8GKW``cAW5HV2QL^M+PC)VR>z3-H7iF5zyaET&4@-|!Fk)sA(k-_$MZqVmCOx1&*+}D-m~#^V_d%9vU$*R{TijsRlrF2D6#XK@UB`3 zsoC&OZ=WVsE}8aGmaL<&nkZZ9Y{nQ|o0HL8>~J-oSb?4^=YPU%_HDq3eKOUvky0)a z53v?AHYx9p{Ybx{WEt~N#JJjuDr_0`Kt9@5rX0)z2_9fgU=?tis|+sK8EE~VBXmdN gF4LUZ2XdTXY!*|$SiQwsPx$KxgJsRi;?qd{0TG{S#Q*>R literal 0 HcmV?d00001 diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-nl_BE.po b/includes/plugin-update-checker/languages/plugin-update-checker-nl_BE.po new file mode 100644 index 0000000..e1734bb --- /dev/null +++ b/includes/plugin-update-checker/languages/plugin-update-checker-nl_BE.po @@ -0,0 +1,48 @@ +msgid "" +msgstr "" +"Project-Id-Version: plugin-update-checker\n" +"POT-Creation-Date: 2018-03-25 18:15+0200\n" +"PO-Revision-Date: 2018-03-25 18:32+0200\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.7.1\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"Last-Translator: Frank Goossens \n" +"Language: nl_BE\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v4p3/Plugin/UpdateChecker.php:395 +msgid "Check for updates" +msgstr "Controleer op nieuwe versies" + +#: Puc/v4p3/Plugin/UpdateChecker.php:548 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "De meest recente %s versie is geïnstalleerd." + +#: Puc/v4p3/Plugin/UpdateChecker.php:550 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "Er is een nieuwe versie van %s beschikbaar." + +#: Puc/v4p3/Plugin/UpdateChecker.php:552 +#, php-format +msgctxt "the plugin title" +msgid "Could not determine if updates are available for %s." +msgstr "Kon niet bepalen of er nieuwe versie van %s beschikbaar is." + +#: Puc/v4p3/Plugin/UpdateChecker.php:558 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Ongekende status bij controle op nieuwe versie: \"%s\"" + +#: Puc/v4p3/Vcs/PluginUpdateChecker.php:95 +msgid "There is no changelog available." +msgstr "Er is geen changelog beschikbaar." diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-nl_NL.mo b/includes/plugin-update-checker/languages/plugin-update-checker-nl_NL.mo new file mode 100644 index 0000000000000000000000000000000000000000..16dde622ba6040399cc911e0d5ef1c970a541b88 GIT binary patch literal 1211 zcmah|&59F25N>rYShMgp(iFTo-2 zt}U_@dIF^!*v+(oz|pQ^QqcR?eO}9oj}B`FtAI-6JvhhItT$S+epNQFQ==6(u3xG*>vb5)r@X1livMYMwOQG% zqsN6Bv+T2)#Z=pPu(7%)q7l_=U26iHAp1KxvIX7_SMp40(=I=d^Bg+Q`)jhbXXljh zBX)AtBsSG%98+tkL+z!!&xV}}*2UDboa#W0s1@Ca8u+iekav~mT!l$YQB>6P~&2IFTgWfxP-fvvY0Aqf5SiIoh|E9zpj0VX)tIH zxINg88<(32xVEl5>MZqVmCQ9fPwBq3-m~#^b5y?Hwt3Jq{TijsRKQ61D6z9!@UB`3 zsoCJs`aVspTr%mQELlfkHBq+I*^Du`HYcOG*y3tFu>z~Eoc}Si*|z~h_Q^y~hf29f zJjPl~*`&NX_Cx)Ol10oz5#wqrs<36$1NmrEnQ|}>BzTB5fmOh5t}?h_XQ1_ej?f*6 gdrUKCAINcnv6)Z(eD&sQJ?5_;43;%3i%%o*2Pb`M*Z=?k literal 0 HcmV?d00001 diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-nl_NL.po b/includes/plugin-update-checker/languages/plugin-update-checker-nl_NL.po new file mode 100644 index 0000000..7f57a89 --- /dev/null +++ b/includes/plugin-update-checker/languages/plugin-update-checker-nl_NL.po @@ -0,0 +1,48 @@ +msgid "" +msgstr "" +"Project-Id-Version: plugin-update-checker\n" +"POT-Creation-Date: 2018-03-25 18:15+0200\n" +"PO-Revision-Date: 2018-03-25 18:32+0200\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.7.1\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"Last-Translator: Frank Goossens \n" +"Language: nl_NL\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v4p3/Plugin/UpdateChecker.php:395 +msgid "Check for updates" +msgstr "Controleer op nieuwe versies" + +#: Puc/v4p3/Plugin/UpdateChecker.php:548 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "De meest recente %s versie is geïnstalleerd." + +#: Puc/v4p3/Plugin/UpdateChecker.php:550 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "Er is een nieuwe versie van %s beschikbaar." + +#: Puc/v4p3/Plugin/UpdateChecker.php:552 +#, php-format +msgctxt "the plugin title" +msgid "Could not determine if updates are available for %s." +msgstr "Kon niet bepalen of er nieuwe versie van %s beschikbaar is." + +#: Puc/v4p3/Plugin/UpdateChecker.php:558 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Ongekende status bij controle op nieuwe versie: \"%s\"" + +#: Puc/v4p3/Vcs/PluginUpdateChecker.php:95 +msgid "There is no changelog available." +msgstr "Er is geen changelog beschikbaar." diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-pt_BR.mo b/includes/plugin-update-checker/languages/plugin-update-checker-pt_BR.mo new file mode 100644 index 0000000000000000000000000000000000000000..d1c0f283287da07c7060255756947399fde75ca6 GIT binary patch literal 1014 zcmZuv!EVz)6f{scgcF=V;_y_d5=dPW2P%rAAllGEMM|SKMcksreu>>WyVmYHZ4oE_ zfe%0&fCEQPT#)h`h+lzm97qtXGJgB)+1bhN{J6UG*2B02+yFYjW#BbXj*q|<;1fW= zS6~_V4zz%ufGFqZJntKD3|vFMdZFTNpgW5oypn^Ib=kY}AEddv&Zz?~t zX;s<@N5?eKhKf9vj;+^A*f6D*l%^<=YRH)$k{ru4lP@#&y+d`Z^og1+00#ed~o)yDXkxO01OB=CIb?>xs5u>EJ;;!s3t`_28bUuZiG31#98mK-BNl>mZ7K z9;c<(|MMCZuOqD!JtLLPq|+v(S_kJ<$RUd!%h5s)ORm4UU)$Z;-J07B{Ccgem16~& zvmAaLpSs(5CR5cc58qgJt;627SfBIC?FMYbmWp(os$od$FH={0As(}0Q~Bs>j#Ed0 zzwWQ&OVx@^X*riJ3CZ_s-K;P&6WiL1Y)A^Xh1Rwj&GPUtZQWG#fP!1i`T7H0n26hz zt&l2Tf7GAy*@-r>?WER))bBU@-0Yv?7Y3`1XhDUgiIOgSh&r6qJltA3NF!-z!xb`1 zU&+ab$rmK?+2p;ZWb%%R(LxgA)aF`EK94!`y@Pq^C}taJg*2wI_Pr<5brLBa%W3dR uv0NHSC{;9(zXh@CV~k{HTE@P&w?I3B7+Z&@l4Ogy;7B66h9le{qWB9G2Q7U7 literal 0 HcmV?d00001 diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-pt_BR.po b/includes/plugin-update-checker/languages/plugin-update-checker-pt_BR.po new file mode 100644 index 0000000..70a0f62 --- /dev/null +++ b/includes/plugin-update-checker/languages/plugin-update-checker-pt_BR.po @@ -0,0 +1,48 @@ +msgid "" +msgstr "" +"Project-Id-Version: plugin-update-checker\n" +"POT-Creation-Date: 2017-05-19 15:41-0300\n" +"PO-Revision-Date: 2017-05-19 15:42-0300\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.8\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x;_x:1,2c\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v4p1/Plugin/UpdateChecker.php:358 +msgid "Check for updates" +msgstr "Verificar Atualizações" + +#: Puc/v4p1/Plugin/UpdateChecker.php:401 Puc/v4p1/Plugin/UpdateChecker.php:406 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "O plugin %s já está na sua versão mais recente." + +#: Puc/v4p1/Plugin/UpdateChecker.php:408 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "Há uma nova versão para o plugin %s disponível para download." + +#: Puc/v4p1/Plugin/UpdateChecker.php:410 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Status \"%s\" desconhecido." + +#: Puc/v4p1/Vcs/PluginUpdateChecker.php:83 +msgid "There is no changelog available." +msgstr "Não há um changelog disponível." + +#~ msgid "The %s plugin is up to date." +#~ msgstr "O plugin %s já está na sua versão mais recente." + +#~ msgid "A new version of the %s plugin is available." +#~ msgstr "Há uma nova versão para o plugin %s disponível para download." diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-ru_RU.mo b/includes/plugin-update-checker/languages/plugin-update-checker-ru_RU.mo new file mode 100644 index 0000000000000000000000000000000000000000..50b330e9332d5024e9bf5f931e5b1e76dca7cd7a GIT binary patch literal 1337 zcmZuw&u<$=6dq`R${Y|}xNvxlltO7{+1&&h*4}=9X zJv7OUR;mz!8|uGcN~*d9Q*njM>_5O?z=^+rZ+7zw+L52Xc{|@X?|X0Uzuubpo?*R) zcn8rzypFh!aBG5i6Y&&5h(8gth`$jr;*FOWTL!KGIq*B+$(I@X9r!NtKTa@q4)_nS z3w(cuv3cM(K$kxOo&vu83S*E|3vvcJ!x6*dYQ4IT&S$k+L)p7YYni5E)E7qPtTU8a zQj(L(s5ca9Ak%C>VnZaUxRFYat*VQ+{yefTldmqzOKM8V+NfnyTzdnm7ZnajQB zJ)p7wmMlhOGICvetgW-JWzX;{eSW=m8SR_n^bm`takk(D{w4m~kNnl6Rz7kEpS7Wo7xu zMBw?2R;G+phIej{P|e6&=7Uix64i7sNaxbTtDVby>4>L=%Gadk%c__46E%ov=|*B2 zU-8eRl3JKdN7T+_KQR<~A)eO>|3u_+B+M`(&ug^PLW`7N&h&a7k;3~#n#T)GHyCW= z_taeA$8kWXPm|mFr{W->i{umN$S=gQVxl>Q<%W>fy&lduB3*Q^ ztsbi*h3*a8=$ZTIy20$j@~-{OKC+L2lXAPfPe^~V)9T@#eT?0te8B7vDv)KQ13o-9)+N{JLMh-GwQXgq3H`cx{G|?z%3j!>U_X4doGg p^$6zwr!DW1J9>c)S9aI#RRwYXL(s|fZP{fYnp literal 0 HcmV?d00001 diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-ru_RU.po b/includes/plugin-update-checker/languages/plugin-update-checker-ru_RU.po new file mode 100644 index 0000000..33a1199 --- /dev/null +++ b/includes/plugin-update-checker/languages/plugin-update-checker-ru_RU.po @@ -0,0 +1,48 @@ +msgid "" +msgstr "" +"Project-Id-Version: plugin-update-checker\n" +"POT-Creation-Date: 2020-08-08 14:36+0300\n" +"PO-Revision-Date: 2021-12-20 17:59+0200\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.2\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"Last-Translator: \n" +"Language: ru_RU\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v4p11/Plugin/Ui.php:128 +msgid "Check for updates" +msgstr "Проверить обновления" + +#: Puc/v4p11/Plugin/Ui.php:213 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "Плагин %s обновлён." + +#: Puc/v4p11/Plugin/Ui.php:215 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "Новая версия %s доступна." + +#: Puc/v4p11/Plugin/Ui.php:217 +#, php-format +msgctxt "the plugin title" +msgid "Could not determine if updates are available for %s." +msgstr "Не удалось определить, доступны ли обновления для %s." + +#: Puc/v4p11/Plugin/Ui.php:223 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Неизвестный статус средства проверки обновлений \"%s\"" + +#: Puc/v4p11/Vcs/PluginUpdateChecker.php:98 +msgid "There is no changelog available." +msgstr "Журнал изменений отсутствует." diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-sl_SI.mo b/includes/plugin-update-checker/languages/plugin-update-checker-sl_SI.mo new file mode 100644 index 0000000000000000000000000000000000000000..df47ca7c0a01cff815ffe3965ee4918e72a600fd GIT binary patch literal 1203 zcmZWoO>YxN7@k5(CHH_@u9bL+6a=EP>~5kaT4SnW5)?I|RxzkIYhu5#$63#;W@a}b zzoDEE|E0YkRe}?@{($}hjvRaFvtApg%1F;X`|iA7&pWgKe7p8WV0{IA2lRojf!~38 z{Q-Of{0R{70ayn<0v+J`7eefU55W@r8vHNt7jOgi+p9v{0{;!J_dhLoeNBi*uzTQ} z;MZV;%-0n>;U@4&d^!Ij#I*(2ea=^R!ow3fwvNhTqyl@A$>eqDqKQ<0ZrZ7ArF^V&~j_>?MkURy)u~>Ychy7^#jUP2flZM8mj$W?J`4AYTxrv; z56F2Ao#*{MxwGnW=3 && n%100<=4 ? 2 : 3);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"Last-Translator: Igor Funa\n" +"Language: sl_SI\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v4p3/Plugin/UpdateChecker.php:395 +msgid "Check for updates" +msgstr "Preveri posodobitve" + +#: Puc/v4p3/Plugin/UpdateChecker.php:548 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "Vtičnik %s je že posodobljen." + +#: Puc/v4p3/Plugin/UpdateChecker.php:550 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "Nova različica vtičnika %s je na razpolago." + +#: Puc/v4p3/Plugin/UpdateChecker.php:552 +#, php-format +msgctxt "the plugin title" +msgid "Could not determine if updates are available for %s." +msgstr "Ne morem ugotoviti če se za vtičnik %s na razpolago posodobitve." + +#: Puc/v4p3/Plugin/UpdateChecker.php:558 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Neznan status preverjanja posodobitev za \"%s\"" + +#: Puc/v4p3/Vcs/PluginUpdateChecker.php:95 +msgid "There is no changelog available." +msgstr "Dnevnik sprememb ni na razpolago." diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-sv_SE.mo b/includes/plugin-update-checker/languages/plugin-update-checker-sv_SE.mo new file mode 100644 index 0000000000000000000000000000000000000000..4d06fc14f5bb99ac14bc019543e9edacfb457e36 GIT binary patch literal 1006 zcmZWn!EO^V5H(OZgcF=NfHYK!L{+@(rWC4;a)7i&6|EZ46mg5(WU^VZwIkb`wi1W_ z1UI-<2!5a!PAEUX2Otjp5qR58+aN5xeIEOH{5(6q@6LS`7`K4?z$S1T_y82+D{u$+ z1`zNam1R4EsX5^8kov|_KI$pYPP7MXnNmmEPaDa zh?X_)x$EUdPrfbl$J4a3e3G0xthBbFNsTPF6 zQ|y$Xe5o9dlpn+t1eI2nTb0RmWA|N58vg>JYt-sRX)tX(()6%F(L((y!H&somz$-p zm`Y=p>0k5Ffw4WenK~a+r&I56y>l2xk852pO5yOz!hKenyev*kZrs^fo4JRT?G9S7 zDnpp9h@Hvlkht&BMEU5v3oTx*tXO4F{Zwm5h*{I*ME8m!Zv5guX~VIY|;YsJcM3XG8e7a;khF F{sQ>&EFS;> literal 0 HcmV?d00001 diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-sv_SE.po b/includes/plugin-update-checker/languages/plugin-update-checker-sv_SE.po new file mode 100644 index 0000000..b894814 --- /dev/null +++ b/includes/plugin-update-checker/languages/plugin-update-checker-sv_SE.po @@ -0,0 +1,42 @@ +msgid "" +msgstr "" +"Project-Id-Version: plugin-update-checker\n" +"POT-Creation-Date: 2017-05-20 10:53+0300\n" +"PO-Revision-Date: 2017-10-16 15:02+0200\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.0.4\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"Last-Translator: \n" +"Language: sv_SE\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v4p1/Plugin/UpdateChecker.php:358 +msgid "Check for updates" +msgstr "Sök efter uppdateringar" + +#: Puc/v4p1/Plugin/UpdateChecker.php:405 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "Tillägget %s är uppdaterat." + +#: Puc/v4p1/Plugin/UpdateChecker.php:407 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "Det finns en ny version av tillägget %s." + +#: Puc/v4p1/Plugin/UpdateChecker.php:409 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Okänd status för kontroll av uppdatering “%s”" + +#: Puc/v4p1/Vcs/PluginUpdateChecker.php:83 +msgid "There is no changelog available." +msgstr "Det finns ingen ändringslogg tillgänglig." diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-tr_TR.mo b/includes/plugin-update-checker/languages/plugin-update-checker-tr_TR.mo new file mode 100644 index 0000000000000000000000000000000000000000..58be2f9306dd0e01aa725c03d583ca53bdd536a0 GIT binary patch literal 1118 zcmZWn&uA(EYi8EL z|3fcT#W_dLkt#u@Tq?V#{trF(&_ANz+WCbT?YG~~&U@c{@6G)4+0q+RH zH>2~*AyOlH>8_q_yQT8Vzs6>7pAB>FBwq5t#2acVW{Y|-k9_N(} z`|M@cW-ixukka~|j*T6;#g@H_&ZpFKoa;zy(BF}ZiF~XAk5n9{lq8Lwsk}0B)A=%_ zWN}QGhR$lct{0!3FD!lDq1N5@xxfoo`HVLfu2NdqI+K6KlLP1T@LY$O((Z11m)pCq z)7F=(85oTSsIm5L78biD4y@}7W$9s|y!x(w8C3#4u^bN+aE;g<#7Y2uh1&iB_Og+~Q(_=q9E~m#-@;IwvA`q&lZxM4* h*%@3qXG)dNj%J6mBiduQgCI)C^*rfJ|1>cX{{#HHSPlRH literal 0 HcmV?d00001 diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-tr_TR.po b/includes/plugin-update-checker/languages/plugin-update-checker-tr_TR.po new file mode 100644 index 0000000..ba5e291 --- /dev/null +++ b/includes/plugin-update-checker/languages/plugin-update-checker-tr_TR.po @@ -0,0 +1,48 @@ +msgid "" +msgstr "" +"Project-Id-Version: plugin-update-checker\n" +"POT-Creation-Date: 2017-11-24 17:02+0200\n" +"PO-Revision-Date: 2021-11-15 19:07+0300\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 3.0\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"Last-Translator: Emre Erkan \n" +"Language: tr\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v4p3/Plugin/UpdateChecker.php:395 +msgid "Check for updates" +msgstr "Güncellemeleri kontrol et" + +#: Puc/v4p3/Plugin/UpdateChecker.php:548 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "%s eklentisi güncel." + +#: Puc/v4p3/Plugin/UpdateChecker.php:550 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "%s eklentisinin yeni bir sürümü mevcut." + +#: Puc/v4p3/Plugin/UpdateChecker.php:552 +#, php-format +msgctxt "the plugin title" +msgid "Could not determine if updates are available for %s." +msgstr "%s için güncelleme olup olmadığı belirlenemedi." + +#: Puc/v4p3/Plugin/UpdateChecker.php:558 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Bilinmeyen güncelleme denetleyicisi durumu \"%s\"" + +#: Puc/v4p3/Vcs/PluginUpdateChecker.php:95 +msgid "There is no changelog available." +msgstr "Kullanılabilir bir değişiklik yok." diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-uk_UA.mo b/includes/plugin-update-checker/languages/plugin-update-checker-uk_UA.mo new file mode 100644 index 0000000000000000000000000000000000000000..79494e524ebd28dcba540d54c7f4949d5a436508 GIT binary patch literal 1309 zcmZuwO>YxN7#`a6L*`J?a}O_(LZM-{yPHs=HA@94(heN%>IG?f}VQqrO)i<3(}EaKQpuM^S;mXuKm}?6TdL5 z4-lUqT8QI_M+mz{h!cpH2txdcm_+=I2oWD0V{9I{0OY`*fFHiY*zdqkasK07#^!+k z0KW!KPcZfwPy>GiZUIjM{{@0lF3=g$8LrrS7n+;~Zn09Ae7m55^u^L;)2YDX%eD1sCoe$2Pn+DIVUB`^`s3&+!L@NQ+7OpMK zABgZAx7J9d7E<%podLROaa(^rNTOKQ?F&+w(BWe13ZFa3Q<2P;gyQqElXhd-3ux|U ztZP5;t3nDD=~M;OOhq@=YbLph5`HCBD_KAi?-R!?oT=Nv zU>ly6Q=S`!9-TTxcI%!DJ&(R5mynM0#n9h-bRnFz+mhj4@O-*^x1wD1X3v1)f#RR3 zA1L`Q%~eMhzoN%w4#yF|%c!7x&C_^Q71Wj*16nL}tf~5l_rE9*oVn*kI-{wy(^v z_?gTzvs2tJ9u({5b(#0n?2!4jSOhGx51C-cI*DmKm7sfZ|UStu|vFUgWo2?dJ# zgc^qh{C1>$@u>QfL4lPtBz%E^BAdmA{e{1!XIS;LY0s>hQtXC3j-Uzxi-(oXvt)N~ e(TmOhac^_B%Vwy(g_1+_)VeFXzd5TNhy4cu&FZoM literal 0 HcmV?d00001 diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-uk_UA.po b/includes/plugin-update-checker/languages/plugin-update-checker-uk_UA.po new file mode 100644 index 0000000..b84b16e --- /dev/null +++ b/includes/plugin-update-checker/languages/plugin-update-checker-uk_UA.po @@ -0,0 +1,48 @@ +msgid "" +msgstr "" +"Project-Id-Version: plugin-update-checker\n" +"POT-Creation-Date: 2020-08-08 14:36+0300\n" +"PO-Revision-Date: 2021-12-20 17:55+0200\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.2\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"Last-Translator: \n" +"Language: uk_UA\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v4p11/Plugin/Ui.php:128 +msgid "Check for updates" +msgstr "Перевірити оновлення" + +#: Puc/v4p11/Plugin/Ui.php:213 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "Плагін %s оновлено." + +#: Puc/v4p11/Plugin/Ui.php:215 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "Нова версія %s доступна." + +#: Puc/v4p11/Plugin/Ui.php:217 +#, php-format +msgctxt "the plugin title" +msgid "Could not determine if updates are available for %s." +msgstr "Не вдалося визначити, чи доступні оновлення для %s." + +#: Puc/v4p11/Plugin/Ui.php:223 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Невідомий статус перевірки оновлень \"%s\"" + +#: Puc/v4p11/Vcs/PluginUpdateChecker.php:98 +msgid "There is no changelog available." +msgstr "Немає доступного журналу змін." diff --git a/includes/plugin-update-checker/languages/plugin-update-checker-zh_CN.mo b/includes/plugin-update-checker/languages/plugin-update-checker-zh_CN.mo new file mode 100644 index 0000000000000000000000000000000000000000..86d114472907c99814f248ed3e063f8bd0ce5819 GIT binary patch literal 1174 zcmZ`&U2hXd6dfQGu!_|3hCt{lC@;Wl*DeoXO%Py0#Ye!DfOx{1*b{qUGh^+{Ccsnp zsMHjpBDD|{EI|Z8RfXaT5KkZ;`Um(06$QNJjR*b!XT2c?MT~TGcIMuD?zywO|E=q} z!LZf<8-WV27I+9G>lN@l@ISB~_y7>Fb{S*6UT9mZh$%XHTV(m-SRZ= z-xZ9l!}&|_Ch!|DftUBB@y+1m+y!p|9|dm!UjRdftp-riSvX=VfmOgaos)D9wCb)x zO_tBns17NrSA>;@4e3yluW&RbtgjV`5gl3TGi zN;3M)rzEugtlN_6f{ua;%-N)Y499#0x1*m1BLVY^<(-lHjI-1Oru?#HR41z`xg3WT zLw!b;Ek97-3yvNW;J8)unKkx76C4NR_$OlzfSA13V zsDH$_nN$2HsbrWMEoxcuE#;i;&X0(sTfSEqSr@kEk>g~FK@^IB@5i@fJW_bq*qVWC zKDjhJ4!HSl<#8Q_Wm!lKd6YU@)IB86Pw22>4*SM>R4V05GG999Ww+(Z;LlW~2+Or1 z9B>yNGAzC~8Q+&5h&$xAG5{N27Y*9~;k+P^)GCojH#HiN$c;_b%Ocg+X!\n" +"Language-Team: \n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.4.3\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v4p11/Plugin/Ui.php:54 +msgid "View details" +msgstr "查看详情" + +#: Puc/v4p11/Plugin/Ui.php:77 +#, php-format +msgid "More information about %s" +msgstr "%s 的更多信息" + +#: Puc/v4p11/Plugin/Ui.php:128 +msgid "Check for updates" +msgstr "检查更新" + +#: Puc/v4p11/Plugin/Ui.php:214 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "%s 目前是最新版本。" + +#: Puc/v4p11/Plugin/Ui.php:216 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "%s 当前有可用的更新。" + +#: Puc/v4p11/Plugin/Ui.php:218 +#, php-format +msgctxt "the plugin title" +msgid "Could not determine if updates are available for %s." +msgstr "%s 无法确定是否有可用的更新。" + +#: Puc/v4p11/Plugin/Ui.php:224 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "未知的更新检查状态:%s" + +#: Puc/v4p11/Vcs/PluginUpdateChecker.php:100 +msgid "There is no changelog available." +msgstr "没有可用的更新日志。" diff --git a/includes/plugin-update-checker/languages/plugin-update-checker.pot b/includes/plugin-update-checker/languages/plugin-update-checker.pot new file mode 100644 index 0000000..5b6319c --- /dev/null +++ b/includes/plugin-update-checker/languages/plugin-update-checker.pot @@ -0,0 +1,49 @@ +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: plugin-update-checker\n" +"POT-Creation-Date: 2022-07-29 15:34+0300\n" +"PO-Revision-Date: 2016-01-10 20:59+0100\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 3.1.1\n" +"X-Poedit-Basepath: ..\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"X-Poedit-SearchPath-0: .\n" + +#: Puc/v5p4/Plugin/Ui.php:128 +msgid "Check for updates" +msgstr "" + +#: Puc/v5p4/Plugin/Ui.php:214 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "" + +#: Puc/v5p4/Plugin/Ui.php:216 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "" + +#: Puc/v5p4/Plugin/Ui.php:218 +#, php-format +msgctxt "the plugin title" +msgid "Could not determine if updates are available for %s." +msgstr "" + +#: Puc/v5p4/Plugin/Ui.php:224 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "" + +#: Puc/v5p4/Vcs/PluginUpdateChecker.php:100 +msgid "There is no changelog available." +msgstr "" diff --git a/includes/plugin-update-checker/license.txt b/includes/plugin-update-checker/license.txt new file mode 100644 index 0000000..7fff536 --- /dev/null +++ b/includes/plugin-update-checker/license.txt @@ -0,0 +1,7 @@ +Copyright (c) 2023 Jānis Elsts + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/includes/plugin-update-checker/load-v5p4.php b/includes/plugin-update-checker/load-v5p4.php new file mode 100644 index 0000000..2cd9580 --- /dev/null +++ b/includes/plugin-update-checker/load-v5p4.php @@ -0,0 +1,34 @@ + Plugin\UpdateChecker::class, + 'Theme\\UpdateChecker' => Theme\UpdateChecker::class, + + 'Vcs\\PluginUpdateChecker' => Vcs\PluginUpdateChecker::class, + 'Vcs\\ThemeUpdateChecker' => Vcs\ThemeUpdateChecker::class, + + 'GitHubApi' => Vcs\GitHubApi::class, + 'BitBucketApi' => Vcs\BitBucketApi::class, + 'GitLabApi' => Vcs\GitLabApi::class, + ) + as $pucGeneralClass => $pucVersionedClass +) { + MajorFactory::addVersion($pucGeneralClass, $pucVersionedClass, '5.4'); + //Also add it to the minor-version factory in case the major-version factory + //was already defined by another, older version of the update checker. + MinorFactory::addVersion($pucGeneralClass, $pucVersionedClass, '5.4'); +} + diff --git a/includes/plugin-update-checker/plugin-update-checker.php b/includes/plugin-update-checker/plugin-update-checker.php new file mode 100644 index 0000000..da4cb1e --- /dev/null +++ b/includes/plugin-update-checker/plugin-update-checker.php @@ -0,0 +1,10 @@ +DefinitionData = array(); + + # standardize line breaks + $text = str_replace(array("\r\n", "\r"), "\n", $text); + + # remove surrounding line breaks + $text = trim($text, "\n"); + + # split text into lines + $lines = explode("\n", $text); + + # iterate through lines to identify blocks + $markup = $this->lines($lines); + + # trim line breaks + $markup = trim($markup, "\n"); + + return $markup; + } + + # + # Setters + # + + function setBreaksEnabled($breaksEnabled) + { + $this->breaksEnabled = $breaksEnabled; + + return $this; + } + + protected $breaksEnabled; + + function setMarkupEscaped($markupEscaped) + { + $this->markupEscaped = $markupEscaped; + + return $this; + } + + protected $markupEscaped; + + function setUrlsLinked($urlsLinked) + { + $this->urlsLinked = $urlsLinked; + + return $this; + } + + protected $urlsLinked = true; + + # + # Lines + # + + protected $BlockTypes = array( + '#' => array('Header'), + '*' => array('Rule', 'List'), + '+' => array('List'), + '-' => array('SetextHeader', 'Table', 'Rule', 'List'), + '0' => array('List'), + '1' => array('List'), + '2' => array('List'), + '3' => array('List'), + '4' => array('List'), + '5' => array('List'), + '6' => array('List'), + '7' => array('List'), + '8' => array('List'), + '9' => array('List'), + ':' => array('Table'), + '<' => array('Comment', 'Markup'), + '=' => array('SetextHeader'), + '>' => array('Quote'), + '[' => array('Reference'), + '_' => array('Rule'), + '`' => array('FencedCode'), + '|' => array('Table'), + '~' => array('FencedCode'), + ); + + # ~ + + protected $unmarkedBlockTypes = array( + 'Code', + ); + + # + # Blocks + # + + protected function lines(array $lines) + { + $CurrentBlock = null; + + foreach ($lines as $line) + { + if (chop($line) === '') + { + if (isset($CurrentBlock)) + { + $CurrentBlock['interrupted'] = true; + } + + continue; + } + + if (strpos($line, "\t") !== false) + { + $parts = explode("\t", $line); + + $line = $parts[0]; + + unset($parts[0]); + + foreach ($parts as $part) + { + $shortage = 4 - mb_strlen($line, 'utf-8') % 4; + + $line .= str_repeat(' ', $shortage); + $line .= $part; + } + } + + $indent = 0; + + while (isset($line[$indent]) and $line[$indent] === ' ') + { + $indent ++; + } + + $text = $indent > 0 ? substr($line, $indent) : $line; + + # ~ + + $Line = array('body' => $line, 'indent' => $indent, 'text' => $text); + + # ~ + + if (isset($CurrentBlock['continuable'])) + { + $Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock); + + if (isset($Block)) + { + $CurrentBlock = $Block; + + continue; + } + else + { + if ($this->isBlockCompletable($CurrentBlock['type'])) + { + $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); + } + } + } + + # ~ + + $marker = $text[0]; + + # ~ + + $blockTypes = $this->unmarkedBlockTypes; + + if (isset($this->BlockTypes[$marker])) + { + foreach ($this->BlockTypes[$marker] as $blockType) + { + $blockTypes []= $blockType; + } + } + + # + # ~ + + foreach ($blockTypes as $blockType) + { + $Block = $this->{'block'.$blockType}($Line, $CurrentBlock); + + if (isset($Block)) + { + $Block['type'] = $blockType; + + if ( ! isset($Block['identified'])) + { + $Blocks []= $CurrentBlock; + + $Block['identified'] = true; + } + + if ($this->isBlockContinuable($blockType)) + { + $Block['continuable'] = true; + } + + $CurrentBlock = $Block; + + continue 2; + } + } + + # ~ + + if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted'])) + { + $CurrentBlock['element']['text'] .= "\n".$text; + } + else + { + $Blocks []= $CurrentBlock; + + $CurrentBlock = $this->paragraph($Line); + + $CurrentBlock['identified'] = true; + } + } + + # ~ + + if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type'])) + { + $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); + } + + # ~ + + $Blocks []= $CurrentBlock; + + unset($Blocks[0]); + + # ~ + + $markup = ''; + + foreach ($Blocks as $Block) + { + if (isset($Block['hidden'])) + { + continue; + } + + $markup .= "\n"; + $markup .= isset($Block['markup']) ? $Block['markup'] : $this->element($Block['element']); + } + + $markup .= "\n"; + + # ~ + + return $markup; + } + + protected function isBlockContinuable($Type) + { + return method_exists($this, 'block'.$Type.'Continue'); + } + + protected function isBlockCompletable($Type) + { + return method_exists($this, 'block'.$Type.'Complete'); + } + + # + # Code + + protected function blockCode($Line, $Block = null) + { + if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted'])) + { + return; + } + + if ($Line['indent'] >= 4) + { + $text = substr($Line['body'], 4); + + $Block = array( + 'element' => array( + 'name' => 'pre', + 'handler' => 'element', + 'text' => array( + 'name' => 'code', + 'text' => $text, + ), + ), + ); + + return $Block; + } + } + + protected function blockCodeContinue($Line, $Block) + { + if ($Line['indent'] >= 4) + { + if (isset($Block['interrupted'])) + { + $Block['element']['text']['text'] .= "\n"; + + unset($Block['interrupted']); + } + + $Block['element']['text']['text'] .= "\n"; + + $text = substr($Line['body'], 4); + + $Block['element']['text']['text'] .= $text; + + return $Block; + } + } + + protected function blockCodeComplete($Block) + { + $text = $Block['element']['text']['text']; + + $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8'); + + $Block['element']['text']['text'] = $text; + + return $Block; + } + + # + # Comment + + protected function blockComment($Line) + { + if ($this->markupEscaped) + { + return; + } + + if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!') + { + $Block = array( + 'markup' => $Line['body'], + ); + + if (preg_match('/-->$/', $Line['text'])) + { + $Block['closed'] = true; + } + + return $Block; + } + } + + protected function blockCommentContinue($Line, array $Block) + { + if (isset($Block['closed'])) + { + return; + } + + $Block['markup'] .= "\n" . $Line['body']; + + if (preg_match('/-->$/', $Line['text'])) + { + $Block['closed'] = true; + } + + return $Block; + } + + # + # Fenced Code + + protected function blockFencedCode($Line) + { + if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([\w-]+)?[ ]*$/', $Line['text'], $matches)) + { + $Element = array( + 'name' => 'code', + 'text' => '', + ); + + if (isset($matches[1])) + { + $class = 'language-'.$matches[1]; + + $Element['attributes'] = array( + 'class' => $class, + ); + } + + $Block = array( + 'char' => $Line['text'][0], + 'element' => array( + 'name' => 'pre', + 'handler' => 'element', + 'text' => $Element, + ), + ); + + return $Block; + } + } + + protected function blockFencedCodeContinue($Line, $Block) + { + if (isset($Block['complete'])) + { + return; + } + + if (isset($Block['interrupted'])) + { + $Block['element']['text']['text'] .= "\n"; + + unset($Block['interrupted']); + } + + if (preg_match('/^'.$Block['char'].'{3,}[ ]*$/', $Line['text'])) + { + $Block['element']['text']['text'] = substr($Block['element']['text']['text'], 1); + + $Block['complete'] = true; + + return $Block; + } + + $Block['element']['text']['text'] .= "\n".$Line['body'];; + + return $Block; + } + + protected function blockFencedCodeComplete($Block) + { + $text = $Block['element']['text']['text']; + + $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8'); + + $Block['element']['text']['text'] = $text; + + return $Block; + } + + # + # Header + + protected function blockHeader($Line) + { + if (isset($Line['text'][1])) + { + $level = 1; + + while (isset($Line['text'][$level]) and $Line['text'][$level] === '#') + { + $level ++; + } + + if ($level > 6) + { + return; + } + + $text = trim($Line['text'], '# '); + + $Block = array( + 'element' => array( + 'name' => 'h' . min(6, $level), + 'text' => $text, + 'handler' => 'line', + ), + ); + + return $Block; + } + } + + # + # List + + protected function blockList($Line) + { + list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]'); + + if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches)) + { + $Block = array( + 'indent' => $Line['indent'], + 'pattern' => $pattern, + 'element' => array( + 'name' => $name, + 'handler' => 'elements', + ), + ); + + $Block['li'] = array( + 'name' => 'li', + 'handler' => 'li', + 'text' => array( + $matches[2], + ), + ); + + $Block['element']['text'] []= & $Block['li']; + + return $Block; + } + } + + protected function blockListContinue($Line, array $Block) + { + if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches)) + { + if (isset($Block['interrupted'])) + { + $Block['li']['text'] []= ''; + + unset($Block['interrupted']); + } + + unset($Block['li']); + + $text = isset($matches[1]) ? $matches[1] : ''; + + $Block['li'] = array( + 'name' => 'li', + 'handler' => 'li', + 'text' => array( + $text, + ), + ); + + $Block['element']['text'] []= & $Block['li']; + + return $Block; + } + + if ($Line['text'][0] === '[' and $this->blockReference($Line)) + { + return $Block; + } + + if ( ! isset($Block['interrupted'])) + { + $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']); + + $Block['li']['text'] []= $text; + + return $Block; + } + + if ($Line['indent'] > 0) + { + $Block['li']['text'] []= ''; + + $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']); + + $Block['li']['text'] []= $text; + + unset($Block['interrupted']); + + return $Block; + } + } + + # + # Quote + + protected function blockQuote($Line) + { + if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) + { + $Block = array( + 'element' => array( + 'name' => 'blockquote', + 'handler' => 'lines', + 'text' => (array) $matches[1], + ), + ); + + return $Block; + } + } + + protected function blockQuoteContinue($Line, array $Block) + { + if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) + { + if (isset($Block['interrupted'])) + { + $Block['element']['text'] []= ''; + + unset($Block['interrupted']); + } + + $Block['element']['text'] []= $matches[1]; + + return $Block; + } + + if ( ! isset($Block['interrupted'])) + { + $Block['element']['text'] []= $Line['text']; + + return $Block; + } + } + + # + # Rule + + protected function blockRule($Line) + { + if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text'])) + { + $Block = array( + 'element' => array( + 'name' => 'hr' + ), + ); + + return $Block; + } + } + + # + # Setext + + protected function blockSetextHeader($Line, array $Block = null) + { + if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) + { + return; + } + + if (chop($Line['text'], $Line['text'][0]) === '') + { + $Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2'; + + return $Block; + } + } + + # + # Markup + + protected function blockMarkup($Line) + { + if ($this->markupEscaped) + { + return; + } + + if (preg_match('/^<(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches)) + { + $element = strtolower($matches[1]); + + if (in_array($element, $this->textLevelElements)) + { + return; + } + + $Block = array( + 'name' => $matches[1], + 'depth' => 0, + 'markup' => $Line['text'], + ); + + $length = strlen($matches[0]); + + $remainder = substr($Line['text'], $length); + + if (trim($remainder) === '') + { + if (isset($matches[2]) or in_array($matches[1], $this->voidElements)) + { + $Block['closed'] = true; + + $Block['void'] = true; + } + } + else + { + if (isset($matches[2]) or in_array($matches[1], $this->voidElements)) + { + return; + } + + if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder)) + { + $Block['closed'] = true; + } + } + + return $Block; + } + } + + protected function blockMarkupContinue($Line, array $Block) + { + if (isset($Block['closed'])) + { + return; + } + + if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open + { + $Block['depth'] ++; + } + + if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close + { + if ($Block['depth'] > 0) + { + $Block['depth'] --; + } + else + { + $Block['closed'] = true; + } + } + + if (isset($Block['interrupted'])) + { + $Block['markup'] .= "\n"; + + unset($Block['interrupted']); + } + + $Block['markup'] .= "\n".$Line['body']; + + return $Block; + } + + # + # Reference + + protected function blockReference($Line) + { + if (preg_match('/^\[(.+?)\]:[ ]*?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches)) + { + $id = strtolower($matches[1]); + + $Data = array( + 'url' => $matches[2], + 'title' => null, + ); + + if (isset($matches[3])) + { + $Data['title'] = $matches[3]; + } + + $this->DefinitionData['Reference'][$id] = $Data; + + $Block = array( + 'hidden' => true, + ); + + return $Block; + } + } + + # + # Table + + protected function blockTable($Line, array $Block = null) + { + if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) + { + return; + } + + if (strpos($Block['element']['text'], '|') !== false and chop($Line['text'], ' -:|') === '') + { + $alignments = array(); + + $divider = $Line['text']; + + $divider = trim($divider); + $divider = trim($divider, '|'); + + $dividerCells = explode('|', $divider); + + foreach ($dividerCells as $dividerCell) + { + $dividerCell = trim($dividerCell); + + if ($dividerCell === '') + { + continue; + } + + $alignment = null; + + if ($dividerCell[0] === ':') + { + $alignment = 'left'; + } + + if (substr($dividerCell, - 1) === ':') + { + $alignment = $alignment === 'left' ? 'center' : 'right'; + } + + $alignments []= $alignment; + } + + # ~ + + $HeaderElements = array(); + + $header = $Block['element']['text']; + + $header = trim($header); + $header = trim($header, '|'); + + $headerCells = explode('|', $header); + + foreach ($headerCells as $index => $headerCell) + { + $headerCell = trim($headerCell); + + $HeaderElement = array( + 'name' => 'th', + 'text' => $headerCell, + 'handler' => 'line', + ); + + if (isset($alignments[$index])) + { + $alignment = $alignments[$index]; + + $HeaderElement['attributes'] = array( + 'style' => 'text-align: '.$alignment.';', + ); + } + + $HeaderElements []= $HeaderElement; + } + + # ~ + + $Block = array( + 'alignments' => $alignments, + 'identified' => true, + 'element' => array( + 'name' => 'table', + 'handler' => 'elements', + ), + ); + + $Block['element']['text'] []= array( + 'name' => 'thead', + 'handler' => 'elements', + ); + + $Block['element']['text'] []= array( + 'name' => 'tbody', + 'handler' => 'elements', + 'text' => array(), + ); + + $Block['element']['text'][0]['text'] []= array( + 'name' => 'tr', + 'handler' => 'elements', + 'text' => $HeaderElements, + ); + + return $Block; + } + } + + protected function blockTableContinue($Line, array $Block) + { + if (isset($Block['interrupted'])) + { + return; + } + + if ($Line['text'][0] === '|' or strpos($Line['text'], '|')) + { + $Elements = array(); + + $row = $Line['text']; + + $row = trim($row); + $row = trim($row, '|'); + + preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches); + + foreach ($matches[0] as $index => $cell) + { + $cell = trim($cell); + + $Element = array( + 'name' => 'td', + 'handler' => 'line', + 'text' => $cell, + ); + + if (isset($Block['alignments'][$index])) + { + $Element['attributes'] = array( + 'style' => 'text-align: '.$Block['alignments'][$index].';', + ); + } + + $Elements []= $Element; + } + + $Element = array( + 'name' => 'tr', + 'handler' => 'elements', + 'text' => $Elements, + ); + + $Block['element']['text'][1]['text'] []= $Element; + + return $Block; + } + } + + # + # ~ + # + + protected function paragraph($Line) + { + $Block = array( + 'element' => array( + 'name' => 'p', + 'text' => $Line['text'], + 'handler' => 'line', + ), + ); + + return $Block; + } + + # + # Inline Elements + # + + protected $InlineTypes = array( + '"' => array('SpecialCharacter'), + '!' => array('Image'), + '&' => array('SpecialCharacter'), + '*' => array('Emphasis'), + ':' => array('Url'), + '<' => array('UrlTag', 'EmailTag', 'Markup', 'SpecialCharacter'), + '>' => array('SpecialCharacter'), + '[' => array('Link'), + '_' => array('Emphasis'), + '`' => array('Code'), + '~' => array('Strikethrough'), + '\\' => array('EscapeSequence'), + ); + + # ~ + + protected $inlineMarkerList = '!"*_&[:<>`~\\'; + + # + # ~ + # + + public function line($text) + { + $markup = ''; + + # $excerpt is based on the first occurrence of a marker + + while ($excerpt = strpbrk($text, $this->inlineMarkerList)) + { + $marker = $excerpt[0]; + + $markerPosition = strpos($text, $marker); + + $Excerpt = array('text' => $excerpt, 'context' => $text); + + foreach ($this->InlineTypes[$marker] as $inlineType) + { + $Inline = $this->{'inline'.$inlineType}($Excerpt); + + if ( ! isset($Inline)) + { + continue; + } + + # makes sure that the inline belongs to "our" marker + + if (isset($Inline['position']) and $Inline['position'] > $markerPosition) + { + continue; + } + + # sets a default inline position + + if ( ! isset($Inline['position'])) + { + $Inline['position'] = $markerPosition; + } + + # the text that comes before the inline + $unmarkedText = substr($text, 0, $Inline['position']); + + # compile the unmarked text + $markup .= $this->unmarkedText($unmarkedText); + + # compile the inline + $markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']); + + # remove the examined text + $text = substr($text, $Inline['position'] + $Inline['extent']); + + continue 2; + } + + # the marker does not belong to an inline + + $unmarkedText = substr($text, 0, $markerPosition + 1); + + $markup .= $this->unmarkedText($unmarkedText); + + $text = substr($text, $markerPosition + 1); + } + + $markup .= $this->unmarkedText($text); + + return $markup; + } + + # + # ~ + # + + protected function inlineCode($Excerpt) + { + $marker = $Excerpt['text'][0]; + + if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(? strlen($matches[0]), + 'element' => array( + 'name' => 'code', + 'text' => $text, + ), + ); + } + } + + protected function inlineEmailTag($Excerpt) + { + if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches)) + { + $url = $matches[1]; + + if ( ! isset($matches[2])) + { + $url = 'mailto:' . $url; + } + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'a', + 'text' => $matches[1], + 'attributes' => array( + 'href' => $url, + ), + ), + ); + } + } + + protected function inlineEmphasis($Excerpt) + { + if ( ! isset($Excerpt['text'][1])) + { + return; + } + + $marker = $Excerpt['text'][0]; + + if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches)) + { + $emphasis = 'strong'; + } + elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches)) + { + $emphasis = 'em'; + } + else + { + return; + } + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => $emphasis, + 'handler' => 'line', + 'text' => $matches[1], + ), + ); + } + + protected function inlineEscapeSequence($Excerpt) + { + if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters)) + { + return array( + 'markup' => $Excerpt['text'][1], + 'extent' => 2, + ); + } + } + + protected function inlineImage($Excerpt) + { + if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[') + { + return; + } + + $Excerpt['text']= substr($Excerpt['text'], 1); + + $Link = $this->inlineLink($Excerpt); + + if ($Link === null) + { + return; + } + + $Inline = array( + 'extent' => $Link['extent'] + 1, + 'element' => array( + 'name' => 'img', + 'attributes' => array( + 'src' => $Link['element']['attributes']['href'], + 'alt' => $Link['element']['text'], + ), + ), + ); + + $Inline['element']['attributes'] += $Link['element']['attributes']; + + unset($Inline['element']['attributes']['href']); + + return $Inline; + } + + protected function inlineLink($Excerpt) + { + $Element = array( + 'name' => 'a', + 'handler' => 'line', + 'text' => null, + 'attributes' => array( + 'href' => null, + 'title' => null, + ), + ); + + $extent = 0; + + $remainder = $Excerpt['text']; + + if (preg_match('/\[((?:[^][]|(?R))*)\]/', $remainder, $matches)) + { + $Element['text'] = $matches[1]; + + $extent += strlen($matches[0]); + + $remainder = substr($remainder, $extent); + } + else + { + return; + } + + if (preg_match('/^[(]((?:[^ ()]|[(][^ )]+[)])+)(?:[ ]+("[^"]*"|\'[^\']*\'))?[)]/', $remainder, $matches)) + { + $Element['attributes']['href'] = $matches[1]; + + if (isset($matches[2])) + { + $Element['attributes']['title'] = substr($matches[2], 1, - 1); + } + + $extent += strlen($matches[0]); + } + else + { + if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches)) + { + $definition = strlen($matches[1]) ? $matches[1] : $Element['text']; + $definition = strtolower($definition); + + $extent += strlen($matches[0]); + } + else + { + $definition = strtolower($Element['text']); + } + + if ( ! isset($this->DefinitionData['Reference'][$definition])) + { + return; + } + + $Definition = $this->DefinitionData['Reference'][$definition]; + + $Element['attributes']['href'] = $Definition['url']; + $Element['attributes']['title'] = $Definition['title']; + } + + $Element['attributes']['href'] = str_replace(array('&', '<'), array('&', '<'), $Element['attributes']['href']); + + return array( + 'extent' => $extent, + 'element' => $Element, + ); + } + + protected function inlineMarkup($Excerpt) + { + if ($this->markupEscaped or strpos($Excerpt['text'], '>') === false) + { + return; + } + + if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w*[ ]*>/s', $Excerpt['text'], $matches)) + { + return array( + 'markup' => $matches[0], + 'extent' => strlen($matches[0]), + ); + } + + if ($Excerpt['text'][1] === '!' and preg_match('/^/s', $Excerpt['text'], $matches)) + { + return array( + 'markup' => $matches[0], + 'extent' => strlen($matches[0]), + ); + } + + if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches)) + { + return array( + 'markup' => $matches[0], + 'extent' => strlen($matches[0]), + ); + } + } + + protected function inlineSpecialCharacter($Excerpt) + { + if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text'])) + { + return array( + 'markup' => '&', + 'extent' => 1, + ); + } + + $SpecialCharacter = array('>' => 'gt', '<' => 'lt', '"' => 'quot'); + + if (isset($SpecialCharacter[$Excerpt['text'][0]])) + { + return array( + 'markup' => '&'.$SpecialCharacter[$Excerpt['text'][0]].';', + 'extent' => 1, + ); + } + } + + protected function inlineStrikethrough($Excerpt) + { + if ( ! isset($Excerpt['text'][1])) + { + return; + } + + if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches)) + { + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'del', + 'text' => $matches[1], + 'handler' => 'line', + ), + ); + } + } + + protected function inlineUrl($Excerpt) + { + if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/') + { + return; + } + + if (preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE)) + { + $Inline = array( + 'extent' => strlen($matches[0][0]), + 'position' => $matches[0][1], + 'element' => array( + 'name' => 'a', + 'text' => $matches[0][0], + 'attributes' => array( + 'href' => $matches[0][0], + ), + ), + ); + + return $Inline; + } + } + + protected function inlineUrlTag($Excerpt) + { + if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches)) + { + $url = str_replace(array('&', '<'), array('&', '<'), $matches[1]); + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'a', + 'text' => $url, + 'attributes' => array( + 'href' => $url, + ), + ), + ); + } + } + + # ~ + + protected function unmarkedText($text) + { + if ($this->breaksEnabled) + { + $text = preg_replace('/[ ]*\n/', "
\n", $text); + } + else + { + $text = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "
\n", $text); + $text = str_replace(" \n", "\n", $text); + } + + return $text; + } + + # + # Handlers + # + + protected function element(array $Element) + { + $markup = '<'.$Element['name']; + + if (isset($Element['attributes'])) + { + foreach ($Element['attributes'] as $name => $value) + { + if ($value === null) + { + continue; + } + + $markup .= ' '.$name.'="'.$value.'"'; + } + } + + if (isset($Element['text'])) + { + $markup .= '>'; + + if (isset($Element['handler'])) + { + $markup .= $this->{$Element['handler']}($Element['text']); + } + else + { + $markup .= $Element['text']; + } + + $markup .= ''; + } + else + { + $markup .= ' />'; + } + + return $markup; + } + + protected function elements(array $Elements) + { + $markup = ''; + + foreach ($Elements as $Element) + { + $markup .= "\n" . $this->element($Element); + } + + $markup .= "\n"; + + return $markup; + } + + # ~ + + protected function li($lines) + { + $markup = $this->lines($lines); + + $trimmedMarkup = trim($markup); + + if ( ! in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '

') + { + $markup = $trimmedMarkup; + $markup = substr($markup, 3); + + $position = strpos($markup, "

"); + + $markup = substr_replace($markup, '', $position, 4); + } + + return $markup; + } + + # + # Deprecated Methods + # + + function parse($text) + { + $markup = $this->text($text); + + return $markup; + } + + # + # Static Methods + # + + static function instance($name = 'default') + { + if (isset(self::$instances[$name])) + { + return self::$instances[$name]; + } + + $instance = new static(); + + self::$instances[$name] = $instance; + + return $instance; + } + + private static $instances = array(); + + # + # Fields + # + + protected $DefinitionData; + + # + # Read-Only + + protected $specialCharacters = array( + '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|', + ); + + protected $StrongRegex = array( + '*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s', + '_' => '/^__((?:\\\\_|[^_]|_[^_]*_)+?)__(?!_)/us', + ); + + protected $EmRegex = array( + '*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s', + '_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us', + ); + + protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:[^"\'=<>`\s]+|"[^"]*"|\'[^\']*\'))?'; + + protected $voidElements = array( + 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', + ); + + protected $textLevelElements = array( + 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont', + 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing', + 'i', 'rp', 'del', 'code', 'strike', 'marquee', + 'q', 'rt', 'ins', 'font', 'strong', + 's', 'tt', 'sub', 'mark', + 'u', 'xm', 'sup', 'nobr', + 'var', 'ruby', + 'wbr', 'span', + 'time', + ); +} \ No newline at end of file diff --git a/includes/plugin-update-checker/vendor/PucReadmeParser.php b/includes/plugin-update-checker/vendor/PucReadmeParser.php new file mode 100644 index 0000000..a794c49 --- /dev/null +++ b/includes/plugin-update-checker/vendor/PucReadmeParser.php @@ -0,0 +1,352 @@ +parse_readme_contents( $file_contents ); + } + + function parse_readme_contents( $file_contents ) { + $file_contents = str_replace(array("\r\n", "\r"), "\n", $file_contents); + $file_contents = trim($file_contents); + if ( 0 === strpos( $file_contents, "\xEF\xBB\xBF" ) ) + $file_contents = substr( $file_contents, 3 ); + + // Markdown transformations + $file_contents = preg_replace( "|^###([^#]+)#*?\s*?\n|im", '=$1='."\n", $file_contents ); + $file_contents = preg_replace( "|^##([^#]+)#*?\s*?\n|im", '==$1=='."\n", $file_contents ); + $file_contents = preg_replace( "|^#([^#]+)#*?\s*?\n|im", '===$1==='."\n", $file_contents ); + + // === Plugin Name === + // Must be the very first thing. + if ( !preg_match('|^===(.*)===|', $file_contents, $_name) ) + return array(); // require a name + $name = trim($_name[1], '='); + $name = $this->sanitize_text( $name ); + + $file_contents = $this->chop_string( $file_contents, $_name[0] ); + + + // Requires at least: 1.5 + if ( preg_match('|Requires at least:(.*)|i', $file_contents, $_requires_at_least) ) + $requires_at_least = $this->sanitize_text($_requires_at_least[1]); + else + $requires_at_least = NULL; + + + // Tested up to: 2.1 + if ( preg_match('|Tested up to:(.*)|i', $file_contents, $_tested_up_to) ) + $tested_up_to = $this->sanitize_text( $_tested_up_to[1] ); + else + $tested_up_to = NULL; + + // Requires PHP: 5.2.4 + if ( preg_match('|Requires PHP:(.*)|i', $file_contents, $_requires_php) ) { + $requires_php = $this->sanitize_text( $_requires_php[1] ); + } else { + $requires_php = null; + } + + // Stable tag: 10.4-ride-the-fire-eagle-danger-day + if ( preg_match('|Stable tag:(.*)|i', $file_contents, $_stable_tag) ) + $stable_tag = $this->sanitize_text( $_stable_tag[1] ); + else + $stable_tag = NULL; // we assume trunk, but don't set it here to tell the difference between specified trunk and default trunk + + + // Tags: some tag, another tag, we like tags + if ( preg_match('|Tags:(.*)|i', $file_contents, $_tags) ) { + $tags = preg_split('|,[\s]*?|', trim($_tags[1])); + foreach ( array_keys($tags) as $t ) + $tags[$t] = $this->sanitize_text( $tags[$t] ); + } else { + $tags = array(); + } + + + // Contributors: markjaquith, mdawaffe, zefrank + $contributors = array(); + if ( preg_match('|Contributors:(.*)|i', $file_contents, $_contributors) ) { + $temp_contributors = preg_split('|,[\s]*|', trim($_contributors[1])); + foreach ( array_keys($temp_contributors) as $c ) { + $tmp_sanitized = $this->user_sanitize( $temp_contributors[$c] ); + if ( strlen(trim($tmp_sanitized)) > 0 ) + $contributors[$c] = $tmp_sanitized; + unset($tmp_sanitized); + } + } + + + // Donate Link: URL + if ( preg_match('|Donate link:(.*)|i', $file_contents, $_donate_link) ) + $donate_link = esc_url( $_donate_link[1] ); + else + $donate_link = NULL; + + + // togs, conts, etc are optional and order shouldn't matter. So we chop them only after we've grabbed their values. + foreach ( array('tags', 'contributors', 'requires_at_least', 'tested_up_to', 'stable_tag', 'donate_link') as $chop ) { + if ( $$chop ) { + $_chop = '_' . $chop; + $file_contents = $this->chop_string( $file_contents, ${$_chop}[0] ); + } + } + + $file_contents = trim($file_contents); + + + // short-description fu + if ( !preg_match('/(^(.*?))^[\s]*=+?[\s]*.+?[\s]*=+?/ms', $file_contents, $_short_description) ) + $_short_description = array( 1 => &$file_contents, 2 => &$file_contents ); + $short_desc_filtered = $this->sanitize_text( $_short_description[2] ); + $short_desc_length = strlen($short_desc_filtered); + $short_description = substr($short_desc_filtered, 0, 150); + if ( $short_desc_length > strlen($short_description) ) + $truncated = true; + else + $truncated = false; + if ( $_short_description[1] ) + $file_contents = $this->chop_string( $file_contents, $_short_description[1] ); // yes, the [1] is intentional + + // == Section == + // Break into sections + // $_sections[0] will be the title of the first section, $_sections[1] will be the content of the first section + // the array alternates from there: title2, content2, title3, content3... and so forth + $_sections = preg_split('/^[\s]*==[\s]*(.+?)[\s]*==/m', $file_contents, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); + + $sections = array(); + for ( $i=0; $i < count($_sections); $i +=2 ) { + $title = $this->sanitize_text( $_sections[$i] ); + if ( isset($_sections[$i+1]) ) { + $content = preg_replace('/(^[\s]*)=[\s]+(.+?)[\s]+=/m', '$1

$2

', $_sections[$i+1]); + $content = $this->filter_text( $content, true ); + } else { + $content = ''; + } + $sections[str_replace(' ', '_', strtolower($title))] = array('title' => $title, 'content' => $content); + } + + + // Special sections + // This is where we nab our special sections, so we can enforce their order and treat them differently, if needed + // upgrade_notice is not a section, but parse it like it is for now + $final_sections = array(); + foreach ( array('description', 'installation', 'frequently_asked_questions', 'screenshots', 'changelog', 'change_log', 'upgrade_notice') as $special_section ) { + if ( isset($sections[$special_section]) ) { + $final_sections[$special_section] = $sections[$special_section]['content']; + unset($sections[$special_section]); + } + } + if ( isset($final_sections['change_log']) && empty($final_sections['changelog']) ) + $final_sections['changelog'] = $final_sections['change_log']; + + + $final_screenshots = array(); + if ( isset($final_sections['screenshots']) ) { + preg_match_all('|
  • (.*?)
  • |s', $final_sections['screenshots'], $screenshots, PREG_SET_ORDER); + if ( $screenshots ) { + foreach ( (array) $screenshots as $ss ) + $final_screenshots[] = $ss[1]; + } + } + + // Parse the upgrade_notice section specially: + // 1.0 => blah, 1.1 => fnord + $upgrade_notice = array(); + if ( isset($final_sections['upgrade_notice']) ) { + $split = preg_split( '#

    (.*?)

    #', $final_sections['upgrade_notice'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); + if ( count($split) >= 2 ) { + for ( $i = 0; $i < count( $split ); $i += 2 ) { + $upgrade_notice[$this->sanitize_text( $split[$i] )] = substr( $this->sanitize_text( $split[$i + 1] ), 0, 300 ); + } + } + unset( $final_sections['upgrade_notice'] ); + } + + // No description? + // No problem... we'll just fall back to the old style of description + // We'll even let you use markup this time! + $excerpt = false; + if ( !isset($final_sections['description']) ) { + $final_sections = array_merge(array('description' => $this->filter_text( $_short_description[2], true )), $final_sections); + $excerpt = true; + } + + + // dump the non-special sections into $remaining_content + // their order will be determined by their original order in the readme.txt + $remaining_content = ''; + foreach ( $sections as $s_name => $s_data ) { + $remaining_content .= "\n

    {$s_data['title']}

    \n{$s_data['content']}"; + } + $remaining_content = trim($remaining_content); + + + // All done! + // $r['tags'] and $r['contributors'] are simple arrays + // $r['sections'] is an array with named elements + $r = array( + 'name' => $name, + 'tags' => $tags, + 'requires_at_least' => $requires_at_least, + 'tested_up_to' => $tested_up_to, + 'requires_php' => $requires_php, + 'stable_tag' => $stable_tag, + 'contributors' => $contributors, + 'donate_link' => $donate_link, + 'short_description' => $short_description, + 'screenshots' => $final_screenshots, + 'is_excerpt' => $excerpt, + 'is_truncated' => $truncated, + 'sections' => $final_sections, + 'remaining_content' => $remaining_content, + 'upgrade_notice' => $upgrade_notice + ); + + return $r; + } + + function chop_string( $string, $chop ) { // chop a "prefix" from a string: Agressive! uses strstr not 0 === strpos + if ( $_string = strstr($string, $chop) ) { + $_string = substr($_string, strlen($chop)); + return trim($_string); + } else { + return trim($string); + } + } + + function user_sanitize( $text, $strict = false ) { // whitelisted chars + if ( function_exists('user_sanitize') ) // bbPress native + return user_sanitize( $text, $strict ); + + if ( $strict ) { + $text = preg_replace('/[^a-z0-9-]/i', '', $text); + $text = preg_replace('|-+|', '-', $text); + } else { + $text = preg_replace('/[^a-z0-9_-]/i', '', $text); + } + return $text; + } + + function sanitize_text( $text ) { // not fancy + $text = function_exists('wp_strip_all_tags') + ? wp_strip_all_tags($text) + //phpcs:ignore WordPressVIPMinimum.Functions.StripTags.StripTagsOneParameter -- Using wp_strip_all_tags() if available + : strip_tags($text); + + $text = esc_html($text); + $text = trim($text); + return $text; + } + + function filter_text( $text, $markdown = false ) { // fancy, Markdown + $text = trim($text); + + $text = call_user_func( array( __CLASS__, 'code_trick' ), $text, $markdown ); // A better parser than Markdown's for: backticks -> CODE + + if ( $markdown ) { // Parse markdown. + if ( !class_exists('Parsedown', false) ) { + /** @noinspection PhpIncludeInspection */ + require_once(dirname(__FILE__) . '/Parsedown' . (version_compare(PHP_VERSION, '5.3.0', '>=') ? '' : 'Legacy') . '.php'); + } + $instance = Parsedown::instance(); + $text = $instance->text($text); + } + + $allowed = array( + 'a' => array( + 'href' => array(), + 'title' => array(), + 'rel' => array()), + 'blockquote' => array('cite' => array()), + 'br' => array(), + 'p' => array(), + 'code' => array(), + 'pre' => array(), + 'em' => array(), + 'strong' => array(), + 'ul' => array(), + 'ol' => array(), + 'li' => array(), + 'h3' => array(), + 'h4' => array() + ); + + $text = balanceTags($text); + + $text = wp_kses( $text, $allowed ); + $text = trim($text); + return $text; + } + + function code_trick( $text, $markdown ) { // Don't use bbPress native function - it's incompatible with Markdown + // If doing markdown, first take any user formatted code blocks and turn them into backticks so that + // markdown will preserve things like underscores in code blocks + if ( $markdown ) + $text = preg_replace_callback("!(
    |)(.*?)(
    |)!s", array( __CLASS__,'decodeit'), $text); + + $text = str_replace(array("\r\n", "\r"), "\n", $text); + if ( !$markdown ) { + // This gets the "inline" code blocks, but can't be used with Markdown. + $text = preg_replace_callback("|(`)(.*?)`|", array( __CLASS__, 'encodeit'), $text); + // This gets the "block level" code blocks and converts them to PRE CODE + $text = preg_replace_callback("!(^|\n)`(.*?)`!s", array( __CLASS__, 'encodeit'), $text); + } else { + // Markdown can do inline code, we convert bbPress style block level code to Markdown style + $text = preg_replace_callback("!(^|\n)([ \t]*?)`(.*?)`!s", array( __CLASS__, 'indent'), $text); + } + return $text; + } + + function indent( $matches ) { + $text = $matches[3]; + $text = preg_replace('|^|m', $matches[2] . ' ', $text); + return $matches[1] . $text; + } + + function encodeit( $matches ) { + if ( function_exists('encodeit') ) // bbPress native + return encodeit( $matches ); + + $text = trim($matches[2]); + $text = htmlspecialchars($text, ENT_QUOTES); + $text = str_replace(array("\r\n", "\r"), "\n", $text); + $text = preg_replace("|\n\n\n+|", "\n\n", $text); + $text = str_replace('&lt;', '<', $text); + $text = str_replace('&gt;', '>', $text); + $text = "$text"; + if ( "`" != $matches[1] ) + $text = "
    $text
    "; + return $text; + } + + function decodeit( $matches ) { + if ( function_exists('decodeit') ) // bbPress native + return decodeit( $matches ); + + $text = $matches[2]; + $trans_table = array_flip(get_html_translation_table(HTML_ENTITIES)); + $text = strtr($text, $trans_table); + $text = str_replace('
    ', '', $text); + $text = str_replace('&', '&', $text); + $text = str_replace(''', "'", $text); + if ( '
    ' == $matches[1] )
    +			$text = "\n$text\n";
    +		return "`$text`";
    +	}
    +
    +} // end class
    +
    +endif;
    diff --git a/languages/projects-for-wordpress-es_MX.l10n.php b/languages/projects-for-wordpress-es_MX.l10n.php
    new file mode 100644
    index 0000000..14da0d9
    --- /dev/null
    +++ b/languages/projects-for-wordpress-es_MX.l10n.php
    @@ -0,0 +1,3 @@
    +NULL,'plural-forms'=>'nplurals=2; plural=(n != 1);','language'=>'es_MX','pot-creation-date'=>'2025-04-04 10:12-0400','po-revision-date'=>'2025-04-04 10:13-0400','translation-revision-date'=>'2025-04-04 10:13-0400','project-id-version'=>'Projects for WordPress®','x-generator'=>'Poedit 3.6','messages'=>['Settings'=>'Ajustes','Version'=>'Versión','Last Updated'=>'Última Actualización','License'=>'Licencia','Language'=>'Idioma','Downloads'=>'Descargas','Forks'=>'Horquillas','Stars'=>'Estrellas','Issues'=>'Problemas','GitHub Owner'=>'Propietario de GitHub','Archive Title'=>'Título del archivo','Project Title'=>'Título del Proyecto','Project Excerpt'=>'Estracto de proyecto','Project Buttons'=>'Botones de proyecto','Projects for WordPress Settings'=>'Proyectos para la configuración de WordPress','General Settings'=>'Ajustes Generales','GitHub API Token'=>'Token de la API de GitHub','Templates Settings'=>'Configuración de plantillas','Archives Settings'=>'Ajustes de los archivos','Save Settings'=>'Guardar Ajustes','Settings saved successfully.'=>'Ajustes guardados exitosamente.','Projects'=>'Proyectos','Project'=>'Proyecto','Add New Project'=>'Agregar Proyecto','Project Types'=>'Proyectos','Project Type'=>'Tipo de Proyecto','Plugin'=>'Plugin','Theme'=>'Tema','Pattern'=>'Patron','GitHub URL'=>'GitHub URL','GitHub Repository URL:'=>'URL del repositorio GitHub:','View details'=>'Ver Detalles','More information about %s'=>'Más información sobre %s','Check for updates'=>'Checar por Actualizaciones','the plugin title' . "\4" . 'The %s plugin is up to date.'=>'El plugin %s está actualizado.','the plugin title' . "\4" . 'A new version of the %s plugin is available.'=>'Una nueva versión del plugin %s está disponible.','the plugin title' . "\4" . 'Could not determine if updates are available for %s.'=>'No se pudo determinar si las actualizaciones están disponibles para %s.','Unknown update checker status "%s"'=>'Status de actualización desconocido "%s"','There is no changelog available.'=>'No está disponible la lista de cambios.','Invalid download URL. Please check the GitHub repository.'=>'URL de descarga no válida. Compruebe el repositorio de GitHub.','Download Error'=>'Error','Download Count'=>'Descargar el recuento','0'=>'0','Download'=>'Descargar','View Project'=>'Ver Proyecto','« Previous'=>'« Anterior','Next »'=>'Siguiente »','No projects found.'=>'No se han encontrado proyectos.','Project Banner'=>'Proyecto Banner','Download Now'=>'Descargar Ahora','View on GitHub'=>'Ver en GitHub','GitHub Repository:'=>'Repositorio GitHub:','No repository linked.'=>'Ningún repositorio vinculado.','Version:'=>'Versión:','Updated:'=>'Actualizado:','License:'=>'Licencia:','Language:'=>'Idioma:','Downloads:'=>'Descargas:','Stars:'=>'Estrellas:','Forks:'=>'Horquillas:','Issues:'=>'Problemas:','Follow'=>'Seguir','Projects for WordPress®'=>'Proyectos para WordPress','https://github.com/robertdevore/projects-portfolio/'=>'https://github.com/robertdevore/projects-portfolio/','Create a showcase directory for projects (plugins, themes, patterns) with custom post types, taxonomies, and download functionality.'=>'Crear un directorio de escaparate para proyectos (plugins, temas, patrones) con tipos de post personalizados, taxonomías y funcionalidad de descarga.','Robert DeVore'=>'Robert DeVore','https://www.robertdevore.com'=>'https://www.robertdevore.com']];
    diff --git a/languages/projects-for-wordpress-es_MX.mo b/languages/projects-for-wordpress-es_MX.mo
    new file mode 100644
    index 0000000000000000000000000000000000000000..f2ba195e69cf1fa323d9f276fec982a6903f469d
    GIT binary patch
    literal 4988
    zcmcJRTWlRi8OMj>QgB;HlL9I9GNest8lPi3Nkh7BD2^|QMUtAtZdz2Z#=B#ClRY~p
    zJG;JAMFPPKf)^e@q7n~*2SB0-iHlTF0oCvTLY1Ho@IqB8K$TDhiV&0sB!1uSo;`LF
    zcw=?u{N{f7=07vv%R2|YsQ4xccM=}HK`8^D9N>@dl^d1X0sjEs1h2q%z`w&=;lNvz
    zx()8Ec^~`?=_By1@JI0N@Mkq&g13-<6}}Dr6%N9GL4IoBCZ*_F-3%pt8P*W3@K
    zeE{DDPr#k<<52p!1RsJ=Luvm5$WJ}bpUmgyP{w@`NVWU`Kj;ocMtqA+znrbQvaVd
    zZ)CDW)h;Oeb0-x0JOpL@N1)7ay3T(BYSIgE5BwyQ_FscC?{C%V??IW*^EH17W&Xc~
    zAAo;`GTz-7^%xw3Q*Z;e;7{Oh(8}vj_UETeTJ-U2DCw8rF8D|IZuka#58S~ZUxEi9
    zL#P*^*!5RX*7YhB`@L3|zX2IS-9V)nL1k1s+w(tm;X!@t4(@D9WyI+%bm&siw#pQ!W0nq4U4egcX
    zgu4jxi5A-g%us$}+XDpAir958VVEFyQ$UbCmGAuovFFxrABhhV-dAVJ`H?-FtkYt5
    z(Tc9qVt@JA(o!R3fgw4RbY~g)8x@)pK#4
    z*j~!(b2iW8blIzk6&qgEOD@wzH!`^;C$mr+?N{7dXuQ=?oY9rbHp+V4s%Nk7?sA-oZluf(rqObk~b;71LGfCeF
    zC*u5Mv8cyqXY`!AXj4^ZJi123UgE4}A#rJj`Ln0!rE1jAZn7v=GwCWz*|I<~+j=&!
    zV$iTOI#$zlCt1^XTg`Z1uniRgb;_j6g;};uM6xjGe7RkbIu(aD^%PeO)M=Ml9j9z*
    z$B0F>S#(9N_j+~4uIGARR%%9_ak|;bC2SkDC96LXoy6%yOYUs7scN>|ZPgQ2O?}*?
    zVx%Tny?KxD@FA|CLQvFCNy7MlJP`Tft+`13Hz5Io5tFvy=
    zX1SiUk6{UQ&Y=EA?$<=Lr##ZW2t#^bDv|{Coy$$;tN%dF*-kf+lhN;GPV}z$7fXAc
    zI(C$8vWZ*PX4S-rSxjtO&8HVrbX=dTYS(S1eQxr?>pgq@9#!vRpdPcCXR~@FBi?d~
    z%S2>zy7pBG`&wy7t>k&v2gAe59Jyk#9lFkNR$3sks~BLoTc6h!ifFB2$FA6MxM{bx
    zw$|R-KzdN3&FXmTTyBnmah)=s)oPa7Eyo
    z^udvX54J`Q^V6dv!RR3(BO`-y(pqzwNj(a1S)j?Oj$>=in$DJVpsimx{rKSNnbTAK
    z35>Q!1}9va+mvpQcc635;4pfM(=icE=52m#er~#Tv|mq#Te4YeDh*x4B^~Iai*Y{q
    zc&oa%%6ZH>8^yUk)ILIfm1rI3YT*W633R*N&z(-pvTv;~bKx^|pj#~yMJ@KY!=(JN
    zyjh$N`i;)dp0p;iEcp8BX?It;{o3bTk%e}mT1}v<V`BSlH_=SbB1v|Eo
    z2BSj<#}?KFAvwKBx*i-3hosE;#YMg}y4sL0irp}g?S;PCu4Y<-8!K~LS;DSqv$VO7(fi}u+U-194-e|z>T(N>cnv{tL*Bnr)`(Vemu+z-lwNb$PwVyl}8^JAZ_0ISh_^hq3N286T;h`
    z8Bs$y?6$|>c1-p5XVTSv9dbA2F^{G6P(J=$u8s0(f67Fz?*(i=YrMv(;OS=;@?7Ew
    z&?b^$vt@%DP{(-bdoj&IaYqW&>s0LpG-cx}E;CJC9D%yT2kM+%F5*m`blIgMP7>p{
    zM1#g;wQGPyN=HCulbF&mAXZ2$NgF0vQf`))=quRh)zc0n$|Di)}jD0UrFBT$>qBzfFnDgBM#
    z{BBx#4Pk7W2>!$7W#983!k9|hyG1VOy}XDqHpK9Ds~3Sk!{etdw^hn*5|w^Mr4n2U
    z?yt=srrWHtiu{X&iluLXXtuZ(m8g5_?l~979X>@R=$-=AlxHwbfNVjNx%D*kI#F|I
    zQED|Ay+~=VYNlejDpm=dO=mevtd~JbBhW$Pgj`*_U$EWxI8m4^;#}1SvZt~hHI5zS
    z90_gL@hrWOJDImk)@DnMHnBkQj$Ab#o{==Kw2YHt#DB9s-@MEr_Fb38NI}$_aPb;3
    zKxjIPvEyaMzY!0FEG*c&2V|$^!i%5MyG{cHI-jdEge_Ld=A!KX0E1dXQ~&?~
    
    literal 0
    HcmV?d00001
    
    diff --git a/languages/projects-for-wordpress-es_MX.po b/languages/projects-for-wordpress-es_MX.po
    new file mode 100644
    index 0000000..0da2fab
    --- /dev/null
    +++ b/languages/projects-for-wordpress-es_MX.po
    @@ -0,0 +1,303 @@
    +msgid ""
    +msgstr ""
    +"Project-Id-Version: Projects for WordPress®\n"
    +"POT-Creation-Date: 2025-04-04 10:12-0400\n"
    +"PO-Revision-Date: 2025-04-04 10:13-0400\n"
    +"Last-Translator: \n"
    +"Language-Team: \n"
    +"Language: es_MX\n"
    +"MIME-Version: 1.0\n"
    +"Content-Type: text/plain; charset=UTF-8\n"
    +"Content-Transfer-Encoding: 8bit\n"
    +"X-Generator: Poedit 3.6\n"
    +"X-Poedit-Basepath: ..\n"
    +"X-Poedit-Flags-xgettext: --add-comments=translators:\n"
    +"X-Poedit-WPHeader: projects-portfolio.php\n"
    +"X-Poedit-SourceCharset: UTF-8\n"
    +"X-Poedit-KeywordsList: "
    +"__;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
    +"X-Poedit-SearchPath-0: .\n"
    +"X-Poedit-SearchPathExcluded-0: *.min.js\n"
    +"X-Poedit-SearchPathExcluded-1: includes/plugin-update-checker/vendor\n"
    +
    +#: admin/admin-settings.php:17 admin/admin-settings.php:18
    +msgid "Settings"
    +msgstr "Ajustes"
    +
    +#: admin/admin-settings.php:49
    +msgid "Version"
    +msgstr "Versión"
    +
    +#: admin/admin-settings.php:50
    +msgid "Last Updated"
    +msgstr "Última Actualización"
    +
    +#: admin/admin-settings.php:51
    +msgid "License"
    +msgstr "Licencia"
    +
    +#: admin/admin-settings.php:52
    +msgid "Language"
    +msgstr "Idioma"
    +
    +#: admin/admin-settings.php:53
    +msgid "Downloads"
    +msgstr "Descargas"
    +
    +#: admin/admin-settings.php:54
    +msgid "Forks"
    +msgstr "Horquillas"
    +
    +#: admin/admin-settings.php:55
    +msgid "Stars"
    +msgstr "Estrellas"
    +
    +#: admin/admin-settings.php:56
    +msgid "Issues"
    +msgstr "Problemas"
    +
    +#: admin/admin-settings.php:57
    +msgid "GitHub Owner"
    +msgstr "Propietario de GitHub"
    +
    +#: admin/admin-settings.php:62
    +msgid "Archive Title"
    +msgstr "Título del archivo"
    +
    +#: admin/admin-settings.php:63
    +msgid "Project Title"
    +msgstr "Título del Proyecto"
    +
    +#: admin/admin-settings.php:64
    +msgid "Project Excerpt"
    +msgstr "Estracto de proyecto"
    +
    +#: admin/admin-settings.php:65
    +msgid "Project Buttons"
    +msgstr "Botones de proyecto"
    +
    +#: admin/admin-settings.php:70
    +msgid "Projects for WordPress Settings"
    +msgstr "Proyectos para la configuración de WordPress"
    +
    +#: admin/admin-settings.php:74
    +msgid "General Settings"
    +msgstr "Ajustes Generales"
    +
    +#: admin/admin-settings.php:78
    +msgid "GitHub API Token"
    +msgstr "Token de la API de GitHub"
    +
    +#: admin/admin-settings.php:86
    +msgid "Templates Settings"
    +msgstr "Configuración de plantillas"
    +
    +#: admin/admin-settings.php:102
    +msgid "Archives Settings"
    +msgstr "Ajustes de los archivos"
    +
    +#: admin/admin-settings.php:119
    +msgid "Save Settings"
    +msgstr "Guardar Ajustes"
    +
    +#: admin/admin-settings.php:166
    +msgid "Settings saved successfully."
    +msgstr "Ajustes guardados exitosamente."
    +
    +#: admin/cpt-taxonomy.php:17 templates/archive-projects.php:17
    +msgid "Projects"
    +msgstr "Proyectos"
    +
    +#: admin/cpt-taxonomy.php:18
    +msgid "Project"
    +msgstr "Proyecto"
    +
    +#: admin/cpt-taxonomy.php:19
    +msgid "Add New Project"
    +msgstr "Agregar Proyecto"
    +
    +#: admin/cpt-taxonomy.php:31
    +msgid "Project Types"
    +msgstr "Proyectos"
    +
    +#: admin/cpt-taxonomy.php:32
    +msgid "Project Type"
    +msgstr "Tipo de Proyecto"
    +
    +#: admin/cpt-taxonomy.php:44
    +msgid "Plugin"
    +msgstr "Plugin"
    +
    +#: admin/cpt-taxonomy.php:47
    +msgid "Theme"
    +msgstr "Tema"
    +
    +#: admin/cpt-taxonomy.php:50
    +msgid "Pattern"
    +msgstr "Patron"
    +
    +#: admin/metabox.php:17
    +msgid "GitHub URL"
    +msgstr "GitHub URL"
    +
    +#: admin/metabox.php:39
    +msgid "GitHub Repository URL:"
    +msgstr "URL del repositorio GitHub:"
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:56
    +msgid "View details"
    +msgstr "Ver Detalles"
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:79
    +#, php-format
    +msgid "More information about %s"
    +msgstr "Más información sobre %s"
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:130
    +msgid "Check for updates"
    +msgstr "Checar por Actualizaciones"
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:217
    +#, php-format
    +msgctxt "the plugin title"
    +msgid "The %s plugin is up to date."
    +msgstr "El plugin %s está actualizado."
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:219
    +#, php-format
    +msgctxt "the plugin title"
    +msgid "A new version of the %s plugin is available."
    +msgstr "Una nueva versión del plugin %s está disponible."
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:221
    +#, php-format
    +msgctxt "the plugin title"
    +msgid "Could not determine if updates are available for %s."
    +msgstr ""
    +"No se pudo determinar si las actualizaciones están disponibles para %s."
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:227
    +#, php-format
    +msgid "Unknown update checker status \"%s\""
    +msgstr "Status de actualización desconocido \"%s\""
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Vcs/PluginUpdateChecker.php:113
    +msgid "There is no changelog available."
    +msgstr "No está disponible la lista de cambios."
    +
    +#: projects-portfolio.php:117
    +msgid "Invalid download URL. Please check the GitHub repository."
    +msgstr "URL de descarga no válida. Compruebe el repositorio de GitHub."
    +
    +#: projects-portfolio.php:118
    +msgid "Download Error"
    +msgstr "Error"
    +
    +#: projects-portfolio.php:133
    +msgid "Download Count"
    +msgstr "Descargar el recuento"
    +
    +#: projects-portfolio.php:147
    +msgid "0"
    +msgstr "0"
    +
    +#: templates/archive-projects.php:37 templates/taxonomy-project-type.php:37
    +msgid "Download"
    +msgstr "Descargar"
    +
    +#: templates/archive-projects.php:40 templates/taxonomy-project-type.php:40
    +msgid "View Project"
    +msgstr "Ver Proyecto"
    +
    +#: templates/archive-projects.php:54 templates/taxonomy-project-type.php:54
    +msgid "« Previous"
    +msgstr "« Anterior"
    +
    +#: templates/archive-projects.php:55 templates/taxonomy-project-type.php:55
    +msgid "Next »"
    +msgstr "Siguiente »"
    +
    +#: templates/archive-projects.php:62 templates/taxonomy-project-type.php:62
    +msgid "No projects found."
    +msgstr "No se han encontrado proyectos."
    +
    +#: templates/single-projects.php:95
    +msgid "Project Banner"
    +msgstr "Proyecto Banner"
    +
    +#: templates/single-projects.php:118
    +msgid "Download Now"
    +msgstr "Descargar Ahora"
    +
    +#: templates/single-projects.php:122
    +msgid "View on GitHub"
    +msgstr "Ver en GitHub"
    +
    +#: templates/single-projects.php:125
    +msgid "GitHub Repository:"
    +msgstr "Repositorio GitHub:"
    +
    +#: templates/single-projects.php:125
    +msgid "No repository linked."
    +msgstr "Ningún repositorio vinculado."
    +
    +#: templates/single-projects.php:137
    +msgid "Version:"
    +msgstr "Versión:"
    +
    +#: templates/single-projects.php:143
    +msgid "Updated:"
    +msgstr "Actualizado:"
    +
    +#: templates/single-projects.php:149
    +msgid "License:"
    +msgstr "Licencia:"
    +
    +#: templates/single-projects.php:155
    +msgid "Language:"
    +msgstr "Idioma:"
    +
    +#: templates/single-projects.php:161
    +msgid "Downloads:"
    +msgstr "Descargas:"
    +
    +#: templates/single-projects.php:169
    +msgid "Stars:"
    +msgstr "Estrellas:"
    +
    +#: templates/single-projects.php:175
    +msgid "Forks:"
    +msgstr "Horquillas:"
    +
    +#: templates/single-projects.php:181
    +msgid "Issues:"
    +msgstr "Problemas:"
    +
    +#: templates/single-projects.php:203
    +msgid "Follow"
    +msgstr "Seguir"
    +
    +#. Plugin Name of the plugin/theme
    +msgid "Projects for WordPress®"
    +msgstr "Proyectos para WordPress"
    +
    +#. Plugin URI of the plugin/theme
    +msgid "https://github.com/robertdevore/projects-portfolio/"
    +msgstr "https://github.com/robertdevore/projects-portfolio/"
    +
    +#. Description of the plugin/theme
    +msgid ""
    +"Create a showcase directory for projects (plugins, themes, patterns) with "
    +"custom post types, taxonomies, and download functionality."
    +msgstr ""
    +"Crear un directorio de escaparate para proyectos (plugins, temas, "
    +"patrones) con tipos de post personalizados, taxonomías y funcionalidad de "
    +"descarga."
    +
    +#. Author of the plugin/theme
    +msgid "Robert DeVore"
    +msgstr "Robert DeVore"
    +
    +#. Author URI of the plugin/theme
    +msgid "https://www.robertdevore.com"
    +msgstr "https://www.robertdevore.com"
    diff --git a/languages/projects-wp-fr_FR.l10n.php b/languages/projects-wp-fr_FR.l10n.php
    new file mode 100644
    index 0000000..31d9209
    --- /dev/null
    +++ b/languages/projects-wp-fr_FR.l10n.php
    @@ -0,0 +1,3 @@
    +NULL,'plural-forms'=>'nplurals=2; plural=(n != 1);','language'=>'fr_FR','pot-creation-date'=>'2025-04-04 10:13-0400','po-revision-date'=>'2025-04-04 10:14-0400','translation-revision-date'=>'2025-04-04 10:14-0400','project-id-version'=>'Projects for WordPress®','x-generator'=>'Poedit 3.6','messages'=>['Settings'=>'Paramètres','Version'=>'Version','Last Updated'=>'Dernière mise à jour','License'=>'Licence','Language'=>'Langue','Downloads'=>'Téléchargements','Forks'=>'Fourchettes','Stars'=>'Étoiles','Issues'=>'Problèmes','GitHub Owner'=>'Propriétaire de GitHub','Archive Title'=>'Archive Titre','Project Title'=>'Titre du projet','Project Excerpt'=>'Extrait du projet','Project Buttons'=>'Boutons de projet','Projects for WordPress Settings'=>'Projets pour les réglages de WordPress','General Settings'=>'Réglages généraux','GitHub API Token'=>'Token API GitHub','Templates Settings'=>'¨Paramètres des modèles','Archives Settings'=>'Paramètres des archives','Save Settings'=>'Enregistrer les paramètres','Settings saved successfully.'=>'Réglages bien enregistrés.','Projects'=>'Projets','Project'=>'Projet','Add New Project'=>'Ajouter un nouveau projet','Project Types'=>'Types de projets','Project Type'=>'Type de projet','Plugin'=>'Extension','Theme'=>'Thème','Pattern'=>'Motif','GitHub URL'=>'URL GitHub','GitHub Repository URL:'=>'URL du dépôt GitHub :','View details'=>'Voir les détails','More information about %s'=>'Plus d’informations sur %s','Check for updates'=>'Vérifier les mises à jour','the plugin title' . "\4" . 'The %s plugin is up to date.'=>'Le plugin %s est à jour.','the plugin title' . "\4" . 'A new version of the %s plugin is available.'=>'Une nouvelle version de l\'extension %s est disponible.','the plugin title' . "\4" . 'Could not determine if updates are available for %s.'=>'Impossible de déterminer si des mises à jour sont disponibles pour %s.','Unknown update checker status "%s"'=>'Mise à jour inconnue statut "%s"','There is no changelog available.'=>'Aucun registre de modifications disponible.','Invalid download URL. Please check the GitHub repository.'=>'URL de téléchargement invalide. Veuillez vérifier le dépôt GitHub.','Download Error'=>'Télécharger Erreur','Download Count'=>'Nombre de Téléchargements','0'=>'0','Download'=>'Télécharger','View Project'=>'Voir le projet','« Previous'=>'« Précédent','Next »'=>'Suivant »','No projects found.'=>'Aucun projet trouvé.','Project Banner'=>'Bannière du projet','Download Now'=>'Télécharger maintenant','View on GitHub'=>'Voir sur GitHub','GitHub Repository:'=>'Dépôt GitHub:','No repository linked.'=>'Aucun dépôt n\'est lié.','Version:'=>'Version:','Updated:'=>'Mis à jour :','License:'=>'Licence:','Language:'=>'Langue:','Downloads:'=>'Téléchargements:','Stars:'=>'Étoiles:','Forks:'=>'Forks:','Issues:'=>'Problèmes:','Follow'=>'Suivre','Projects for WordPress®'=>'Projets pour WordPress®','https://github.com/robertdevore/projects-portfolio/'=>'https://github.com/robertdevore/projects-portfolio/','Create a showcase directory for projects (plugins, themes, patterns) with custom post types, taxonomies, and download functionality.'=>'Créer un répertoire de présentation pour les projets (plugins, thèmes, modèles) avec des types d\'articles personnalisés, des taxonomies et des fonctionnalités de téléchargement.','Robert DeVore'=>'Robert DeVore','https://www.robertdevore.com'=>'https://www.robertdevore.com']];
    diff --git a/languages/projects-wp-fr_FR.mo b/languages/projects-wp-fr_FR.mo
    new file mode 100644
    index 0000000000000000000000000000000000000000..a39bef534c8c6c84455f013430bb0230beec7890
    GIT binary patch
    literal 5062
    zcmcJSZ-^aN6~M2$_0QJYHmxRVTd%Q6nws}^H%VhM+q7-r3z~k%Ec{{aUC6K@c>HMG#s+rB?bB!4C>5RwxuLsEE{xNTnd+@661b_cj~-
    z=H=b_-FxT$J@=e5=e@FH4Jhw#
    zp;6|)6TTOYL+L*QW&ZP3eG$qzKLtfTamB}=$mt0v^F3YFzX|!N=XiVw{t)hhuR!Vl
    z&x$v&S&Hg5DED&*6!{#3vi^fm_BT_te-diyOK>-Q9Lo5wL)rH;RsC5g`+2_N&!Fu8
    zCHOJ;M=0yvg;0;fNjMF!zy^E){t{hz4c)-H$a3_m=
    zA0C48{;yEl{{?S{yAYoAZ$Qzj87Sv_7|MB9;f*k>>Ysx$?u$_L4JK
    zV5{mc@HBj*sz1OWnQs=#{EJZJ^avFF3ak2Op~&&`P~`FilzBIy=*9P-ockA0?&r@C
    z5vtdr%=;!3Imw~qT(?);3uT_85D};|kgnvr9cwhmvo{;afc65o~Y`gD{muO7HR2b^>W}T+=vI(4;%7S*Z
    zX7objV$-i#eZe>vB`vE?woS0ASJF)9-OzW2mdrryYuirO1K%1QMj2D3*_EPSx18DP
    zd%AJniV}N3ySC{V*!7(=Sz`C=^~kk#kXx5_bT_q5yDMGk;rxv>Njs60{Up?3x}LvhErN}ifY9Pv
    z#AJRv5W?xmoynK=)ZDCINLNjws)mQw>DaH#8x9f`VpyC%%Pi%fL37>2Yc-p!ag?D0
    z(%95AAC-Uv+Ab#=Ye!+!4tv|{i|RHR=U6bhxglx87XZih6tn!|2=
    z|KhjRe7bBhr%#!SNJ3rk(f(T9w-vPIeW-071kApY$1&P>!TFgjpPpJUoo+0aF_>jR
    z^j+~3Nn4$y+$h&%;>&Zl&*Xw2vI?;l+LKvCZv!K;T=K%)8p9THF?DS{}188#XFgdiuYq$mrZdjd@(A
    zNW5{1;hsJ?e(=7=_+fr}V%(dM!ua^8SXyHt^An2(q?xB_Db2C5VEoQd-P0@C(#-tm
    zx!H5mgAGhH$45`5i8Be)px&N#*x(rY6eW|QG?_K-_~OD$7)mZ$M_d7OG%pD+IRcvi#E0
    zbv4Q@e&%<2R~^=l)nT7yB!K_uZD!F*#1t{joyhX+eN8iM#>c<6SWcA
    zQ8{ruRX2-zn|Szg*Ht@FgAQ{Yav8m6T|Zp#)Tu2Eo|1mUL$(VDr7I#5)6^GD9>uZw
    zj9wekglpC)9O`mh+@<)|s#wJ%RWxGQ2=QLjyUM0Tk!n3EqLHAAN&@;3J#cTYKK_-V
    z$i(v5%_J}p=^^SmHkrx;w7b+T?J~5yx7k!>YhM(}K0_1~BeNzUkBe5+^aeLpd_>vr
    zW#g2DCgt7`VL6*Rf$7WlWid;fHMm+b>0I3d5P(>=PCIN3{9oS5D
    z_bgY3Fy*HTqbd5;&D$cE=_E5PoMu*8YIk7J!^W)!8nzsnM4SFFETyS>U&e$nwYuP`
    z7q4FH8v3S6NFx_sNxHwf9GxDxjG(Z7&K}urnnXpAb8hI`#j#<|xhZ2DSH?K>=<9{P
    zUZ8`E!I$)}<6>E5k-{1z-jNp3luE(>F9FXY5lP`rF^oFQ;o$K;zM7?4N$epyH+=fp
    q4u1-)NJ69}TP~v;HXPA%jeFHNyW#Pb3P`YXwvM-|RVt6%RQ~~)tA5P@
    
    literal 0
    HcmV?d00001
    
    diff --git a/languages/projects-wp-fr_FR.po b/languages/projects-wp-fr_FR.po
    new file mode 100644
    index 0000000..300e2f6
    --- /dev/null
    +++ b/languages/projects-wp-fr_FR.po
    @@ -0,0 +1,303 @@
    +msgid ""
    +msgstr ""
    +"Project-Id-Version: Projects for WordPress®\n"
    +"POT-Creation-Date: 2025-04-04 10:13-0400\n"
    +"PO-Revision-Date: 2025-04-04 10:14-0400\n"
    +"Last-Translator: \n"
    +"Language-Team: \n"
    +"Language: fr_FR\n"
    +"MIME-Version: 1.0\n"
    +"Content-Type: text/plain; charset=UTF-8\n"
    +"Content-Transfer-Encoding: 8bit\n"
    +"X-Generator: Poedit 3.6\n"
    +"X-Poedit-Basepath: ..\n"
    +"X-Poedit-Flags-xgettext: --add-comments=translators:\n"
    +"X-Poedit-WPHeader: projects-portfolio.php\n"
    +"X-Poedit-SourceCharset: UTF-8\n"
    +"X-Poedit-KeywordsList: "
    +"__;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
    +"X-Poedit-SearchPath-0: .\n"
    +"X-Poedit-SearchPathExcluded-0: *.min.js\n"
    +"X-Poedit-SearchPathExcluded-1: includes/plugin-update-checker/vendor\n"
    +
    +#: admin/admin-settings.php:17 admin/admin-settings.php:18
    +msgid "Settings"
    +msgstr "Paramètres"
    +
    +#: admin/admin-settings.php:49
    +msgid "Version"
    +msgstr "Version"
    +
    +#: admin/admin-settings.php:50
    +msgid "Last Updated"
    +msgstr "Dernière mise à jour"
    +
    +#: admin/admin-settings.php:51
    +msgid "License"
    +msgstr "Licence"
    +
    +#: admin/admin-settings.php:52
    +msgid "Language"
    +msgstr "Langue"
    +
    +#: admin/admin-settings.php:53
    +msgid "Downloads"
    +msgstr "Téléchargements"
    +
    +#: admin/admin-settings.php:54
    +msgid "Forks"
    +msgstr "Fourchettes"
    +
    +#: admin/admin-settings.php:55
    +msgid "Stars"
    +msgstr "Étoiles"
    +
    +#: admin/admin-settings.php:56
    +msgid "Issues"
    +msgstr "Problèmes"
    +
    +#: admin/admin-settings.php:57
    +msgid "GitHub Owner"
    +msgstr "Propriétaire de GitHub"
    +
    +#: admin/admin-settings.php:62
    +msgid "Archive Title"
    +msgstr "Archive Titre"
    +
    +#: admin/admin-settings.php:63
    +msgid "Project Title"
    +msgstr "Titre du projet"
    +
    +#: admin/admin-settings.php:64
    +msgid "Project Excerpt"
    +msgstr "Extrait du projet"
    +
    +#: admin/admin-settings.php:65
    +msgid "Project Buttons"
    +msgstr "Boutons de projet"
    +
    +#: admin/admin-settings.php:70
    +msgid "Projects for WordPress Settings"
    +msgstr "Projets pour les réglages de WordPress"
    +
    +#: admin/admin-settings.php:74
    +msgid "General Settings"
    +msgstr "Réglages généraux"
    +
    +#: admin/admin-settings.php:78
    +msgid "GitHub API Token"
    +msgstr "Token API GitHub"
    +
    +#: admin/admin-settings.php:86
    +msgid "Templates Settings"
    +msgstr "¨Paramètres des modèles"
    +
    +#: admin/admin-settings.php:102
    +msgid "Archives Settings"
    +msgstr "Paramètres des archives"
    +
    +#: admin/admin-settings.php:119
    +msgid "Save Settings"
    +msgstr "Enregistrer les paramètres"
    +
    +#: admin/admin-settings.php:166
    +msgid "Settings saved successfully."
    +msgstr "Réglages bien enregistrés."
    +
    +#: admin/cpt-taxonomy.php:17 templates/archive-projects.php:17
    +msgid "Projects"
    +msgstr "Projets"
    +
    +#: admin/cpt-taxonomy.php:18
    +msgid "Project"
    +msgstr "Projet"
    +
    +#: admin/cpt-taxonomy.php:19
    +msgid "Add New Project"
    +msgstr "Ajouter un nouveau projet"
    +
    +#: admin/cpt-taxonomy.php:31
    +msgid "Project Types"
    +msgstr "Types de projets"
    +
    +#: admin/cpt-taxonomy.php:32
    +msgid "Project Type"
    +msgstr "Type de projet"
    +
    +#: admin/cpt-taxonomy.php:44
    +msgid "Plugin"
    +msgstr "Extension"
    +
    +#: admin/cpt-taxonomy.php:47
    +msgid "Theme"
    +msgstr "Thème"
    +
    +#: admin/cpt-taxonomy.php:50
    +msgid "Pattern"
    +msgstr "Motif"
    +
    +#: admin/metabox.php:17
    +msgid "GitHub URL"
    +msgstr "URL GitHub"
    +
    +#: admin/metabox.php:39
    +msgid "GitHub Repository URL:"
    +msgstr "URL du dépôt GitHub :"
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:56
    +msgid "View details"
    +msgstr "Voir les détails"
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:79
    +#, php-format
    +msgid "More information about %s"
    +msgstr "Plus d’informations sur %s"
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:130
    +msgid "Check for updates"
    +msgstr "Vérifier les mises à jour"
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:217
    +#, php-format
    +msgctxt "the plugin title"
    +msgid "The %s plugin is up to date."
    +msgstr "Le plugin %s est à jour."
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:219
    +#, php-format
    +msgctxt "the plugin title"
    +msgid "A new version of the %s plugin is available."
    +msgstr "Une nouvelle version de l'extension %s est disponible."
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:221
    +#, php-format
    +msgctxt "the plugin title"
    +msgid "Could not determine if updates are available for %s."
    +msgstr ""
    +"Impossible de déterminer si des mises à jour sont disponibles pour %s."
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:227
    +#, php-format
    +msgid "Unknown update checker status \"%s\""
    +msgstr "Mise à jour inconnue statut \"%s\""
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Vcs/PluginUpdateChecker.php:113
    +msgid "There is no changelog available."
    +msgstr "Aucun registre de modifications disponible."
    +
    +#: projects-portfolio.php:117
    +msgid "Invalid download URL. Please check the GitHub repository."
    +msgstr "URL de téléchargement invalide. Veuillez vérifier le dépôt GitHub."
    +
    +#: projects-portfolio.php:118
    +msgid "Download Error"
    +msgstr "Télécharger Erreur"
    +
    +#: projects-portfolio.php:133
    +msgid "Download Count"
    +msgstr "Nombre de Téléchargements"
    +
    +#: projects-portfolio.php:147
    +msgid "0"
    +msgstr "0"
    +
    +#: templates/archive-projects.php:37 templates/taxonomy-project-type.php:37
    +msgid "Download"
    +msgstr "Télécharger"
    +
    +#: templates/archive-projects.php:40 templates/taxonomy-project-type.php:40
    +msgid "View Project"
    +msgstr "Voir le projet"
    +
    +#: templates/archive-projects.php:54 templates/taxonomy-project-type.php:54
    +msgid "« Previous"
    +msgstr "« Précédent"
    +
    +#: templates/archive-projects.php:55 templates/taxonomy-project-type.php:55
    +msgid "Next »"
    +msgstr "Suivant »"
    +
    +#: templates/archive-projects.php:62 templates/taxonomy-project-type.php:62
    +msgid "No projects found."
    +msgstr "Aucun projet trouvé."
    +
    +#: templates/single-projects.php:95
    +msgid "Project Banner"
    +msgstr "Bannière du projet"
    +
    +#: templates/single-projects.php:118
    +msgid "Download Now"
    +msgstr "Télécharger maintenant"
    +
    +#: templates/single-projects.php:122
    +msgid "View on GitHub"
    +msgstr "Voir sur GitHub"
    +
    +#: templates/single-projects.php:125
    +msgid "GitHub Repository:"
    +msgstr "Dépôt GitHub:"
    +
    +#: templates/single-projects.php:125
    +msgid "No repository linked."
    +msgstr "Aucun dépôt n'est lié."
    +
    +#: templates/single-projects.php:137
    +msgid "Version:"
    +msgstr "Version:"
    +
    +#: templates/single-projects.php:143
    +msgid "Updated:"
    +msgstr "Mis à jour :"
    +
    +#: templates/single-projects.php:149
    +msgid "License:"
    +msgstr "Licence:"
    +
    +#: templates/single-projects.php:155
    +msgid "Language:"
    +msgstr "Langue:"
    +
    +#: templates/single-projects.php:161
    +msgid "Downloads:"
    +msgstr "Téléchargements:"
    +
    +#: templates/single-projects.php:169
    +msgid "Stars:"
    +msgstr "Étoiles:"
    +
    +#: templates/single-projects.php:175
    +msgid "Forks:"
    +msgstr "Forks:"
    +
    +#: templates/single-projects.php:181
    +msgid "Issues:"
    +msgstr "Problèmes:"
    +
    +#: templates/single-projects.php:203
    +msgid "Follow"
    +msgstr "Suivre"
    +
    +#. Plugin Name of the plugin/theme
    +msgid "Projects for WordPress®"
    +msgstr "Projets pour WordPress®"
    +
    +#. Plugin URI of the plugin/theme
    +msgid "https://github.com/robertdevore/projects-portfolio/"
    +msgstr "https://github.com/robertdevore/projects-portfolio/"
    +
    +#. Description of the plugin/theme
    +msgid ""
    +"Create a showcase directory for projects (plugins, themes, patterns) with "
    +"custom post types, taxonomies, and download functionality."
    +msgstr ""
    +"Créer un répertoire de présentation pour les projets (plugins, thèmes, "
    +"modèles) avec des types d'articles personnalisés, des taxonomies et des "
    +"fonctionnalités de téléchargement."
    +
    +#. Author of the plugin/theme
    +msgid "Robert DeVore"
    +msgstr "Robert DeVore"
    +
    +#. Author URI of the plugin/theme
    +msgid "https://www.robertdevore.com"
    +msgstr "https://www.robertdevore.com"
    diff --git a/languages/projects-wp.pot b/languages/projects-wp.pot
    new file mode 100644
    index 0000000..1f462c2
    --- /dev/null
    +++ b/languages/projects-wp.pot
    @@ -0,0 +1,300 @@
    +#, fuzzy
    +msgid ""
    +msgstr ""
    +"Project-Id-Version: Projects for WordPress®\n"
    +"POT-Creation-Date: 2025-04-04 10:12-0400\n"
    +"PO-Revision-Date: 2025-04-04 10:12-0400\n"
    +"Last-Translator: \n"
    +"Language-Team: \n"
    +"MIME-Version: 1.0\n"
    +"Content-Type: text/plain; charset=UTF-8\n"
    +"Content-Transfer-Encoding: 8bit\n"
    +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
    +"X-Generator: Poedit 3.6\n"
    +"X-Poedit-Basepath: ..\n"
    +"X-Poedit-Flags-xgettext: --add-comments=translators:\n"
    +"X-Poedit-WPHeader: projects-portfolio.php\n"
    +"X-Poedit-SourceCharset: UTF-8\n"
    +"X-Poedit-KeywordsList: "
    +"__;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
    +"X-Poedit-SearchPath-0: .\n"
    +"X-Poedit-SearchPathExcluded-0: *.min.js\n"
    +"X-Poedit-SearchPathExcluded-1: includes/plugin-update-checker/vendor\n"
    +
    +#: admin/admin-settings.php:17 admin/admin-settings.php:18
    +msgid "Settings"
    +msgstr ""
    +
    +#: admin/admin-settings.php:49
    +msgid "Version"
    +msgstr ""
    +
    +#: admin/admin-settings.php:50
    +msgid "Last Updated"
    +msgstr ""
    +
    +#: admin/admin-settings.php:51
    +msgid "License"
    +msgstr ""
    +
    +#: admin/admin-settings.php:52
    +msgid "Language"
    +msgstr ""
    +
    +#: admin/admin-settings.php:53
    +msgid "Downloads"
    +msgstr ""
    +
    +#: admin/admin-settings.php:54
    +msgid "Forks"
    +msgstr ""
    +
    +#: admin/admin-settings.php:55
    +msgid "Stars"
    +msgstr ""
    +
    +#: admin/admin-settings.php:56
    +msgid "Issues"
    +msgstr ""
    +
    +#: admin/admin-settings.php:57
    +msgid "GitHub Owner"
    +msgstr ""
    +
    +#: admin/admin-settings.php:62
    +msgid "Archive Title"
    +msgstr ""
    +
    +#: admin/admin-settings.php:63
    +msgid "Project Title"
    +msgstr ""
    +
    +#: admin/admin-settings.php:64
    +msgid "Project Excerpt"
    +msgstr ""
    +
    +#: admin/admin-settings.php:65
    +msgid "Project Buttons"
    +msgstr ""
    +
    +#: admin/admin-settings.php:70
    +msgid "Projects for WordPress Settings"
    +msgstr ""
    +
    +#: admin/admin-settings.php:74
    +msgid "General Settings"
    +msgstr ""
    +
    +#: admin/admin-settings.php:78
    +msgid "GitHub API Token"
    +msgstr ""
    +
    +#: admin/admin-settings.php:86
    +msgid "Templates Settings"
    +msgstr ""
    +
    +#: admin/admin-settings.php:102
    +msgid "Archives Settings"
    +msgstr ""
    +
    +#: admin/admin-settings.php:119
    +msgid "Save Settings"
    +msgstr ""
    +
    +#: admin/admin-settings.php:166
    +msgid "Settings saved successfully."
    +msgstr ""
    +
    +#: admin/cpt-taxonomy.php:17 templates/archive-projects.php:17
    +msgid "Projects"
    +msgstr ""
    +
    +#: admin/cpt-taxonomy.php:18
    +msgid "Project"
    +msgstr ""
    +
    +#: admin/cpt-taxonomy.php:19
    +msgid "Add New Project"
    +msgstr ""
    +
    +#: admin/cpt-taxonomy.php:31
    +msgid "Project Types"
    +msgstr ""
    +
    +#: admin/cpt-taxonomy.php:32
    +msgid "Project Type"
    +msgstr ""
    +
    +#: admin/cpt-taxonomy.php:44
    +msgid "Plugin"
    +msgstr ""
    +
    +#: admin/cpt-taxonomy.php:47
    +msgid "Theme"
    +msgstr ""
    +
    +#: admin/cpt-taxonomy.php:50
    +msgid "Pattern"
    +msgstr ""
    +
    +#: admin/metabox.php:17
    +msgid "GitHub URL"
    +msgstr ""
    +
    +#: admin/metabox.php:39
    +msgid "GitHub Repository URL:"
    +msgstr ""
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:56
    +msgid "View details"
    +msgstr ""
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:79
    +#, php-format
    +msgid "More information about %s"
    +msgstr ""
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:130
    +msgid "Check for updates"
    +msgstr ""
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:217
    +#, php-format
    +msgctxt "the plugin title"
    +msgid "The %s plugin is up to date."
    +msgstr ""
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:219
    +#, php-format
    +msgctxt "the plugin title"
    +msgid "A new version of the %s plugin is available."
    +msgstr ""
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:221
    +#, php-format
    +msgctxt "the plugin title"
    +msgid "Could not determine if updates are available for %s."
    +msgstr ""
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Plugin/Ui.php:227
    +#, php-format
    +msgid "Unknown update checker status \"%s\""
    +msgstr ""
    +
    +#: includes/plugin-update-checker/Puc/v5p4/Vcs/PluginUpdateChecker.php:113
    +msgid "There is no changelog available."
    +msgstr ""
    +
    +#: projects-portfolio.php:117
    +msgid "Invalid download URL. Please check the GitHub repository."
    +msgstr ""
    +
    +#: projects-portfolio.php:118
    +msgid "Download Error"
    +msgstr ""
    +
    +#: projects-portfolio.php:133
    +msgid "Download Count"
    +msgstr ""
    +
    +#: projects-portfolio.php:147
    +msgid "0"
    +msgstr ""
    +
    +#: templates/archive-projects.php:37 templates/taxonomy-project-type.php:37
    +msgid "Download"
    +msgstr ""
    +
    +#: templates/archive-projects.php:40 templates/taxonomy-project-type.php:40
    +msgid "View Project"
    +msgstr ""
    +
    +#: templates/archive-projects.php:54 templates/taxonomy-project-type.php:54
    +msgid "« Previous"
    +msgstr ""
    +
    +#: templates/archive-projects.php:55 templates/taxonomy-project-type.php:55
    +msgid "Next »"
    +msgstr ""
    +
    +#: templates/archive-projects.php:62 templates/taxonomy-project-type.php:62
    +msgid "No projects found."
    +msgstr ""
    +
    +#: templates/single-projects.php:95
    +msgid "Project Banner"
    +msgstr ""
    +
    +#: templates/single-projects.php:118
    +msgid "Download Now"
    +msgstr ""
    +
    +#: templates/single-projects.php:122
    +msgid "View on GitHub"
    +msgstr ""
    +
    +#: templates/single-projects.php:125
    +msgid "GitHub Repository:"
    +msgstr ""
    +
    +#: templates/single-projects.php:125
    +msgid "No repository linked."
    +msgstr ""
    +
    +#: templates/single-projects.php:137
    +msgid "Version:"
    +msgstr ""
    +
    +#: templates/single-projects.php:143
    +msgid "Updated:"
    +msgstr ""
    +
    +#: templates/single-projects.php:149
    +msgid "License:"
    +msgstr ""
    +
    +#: templates/single-projects.php:155
    +msgid "Language:"
    +msgstr ""
    +
    +#: templates/single-projects.php:161
    +msgid "Downloads:"
    +msgstr ""
    +
    +#: templates/single-projects.php:169
    +msgid "Stars:"
    +msgstr ""
    +
    +#: templates/single-projects.php:175
    +msgid "Forks:"
    +msgstr ""
    +
    +#: templates/single-projects.php:181
    +msgid "Issues:"
    +msgstr ""
    +
    +#: templates/single-projects.php:203
    +msgid "Follow"
    +msgstr ""
    +
    +#. Plugin Name of the plugin/theme
    +msgid "Projects for WordPress®"
    +msgstr ""
    +
    +#. Plugin URI of the plugin/theme
    +msgid "https://github.com/robertdevore/projects-portfolio/"
    +msgstr ""
    +
    +#. Description of the plugin/theme
    +msgid ""
    +"Create a showcase directory for projects (plugins, themes, patterns) with "
    +"custom post types, taxonomies, and download functionality."
    +msgstr ""
    +
    +#. Author of the plugin/theme
    +msgid "Robert DeVore"
    +msgstr ""
    +
    +#. Author URI of the plugin/theme
    +msgid "https://www.robertdevore.com"
    +msgstr ""
    diff --git a/projects-for-wordpress.php b/projects-for-wordpress.php
    new file mode 100644
    index 0000000..b9173d2
    --- /dev/null
    +++ b/projects-for-wordpress.php
    @@ -0,0 +1,390 @@
    +setBranch( 'main' );
    +
    +// Current plugin version.
    +define( 'PROJECTS_PORTFOLIO_VERSION', time() );
    +
    +// Add the required files.
    +require 'admin/admin-settings.php';
    +require 'admin/cpt-taxonomy.php';
    +require 'admin/metabox.php';
    +require 'includes/helper-functions.php';
    +
    +/**
    + * Flush rewrite rules on activation.
    + *
    + * @since  1.0.0
    + * @return void
    + */
    +function projects_portfolio_flush_rewrite_rules() {
    +    projects_portfolio_register_cpt_and_taxonomy();
    +    projects_portfolio_add_rewrite_rules();
    +    flush_rewrite_rules();
    +}
    +register_activation_hook( __FILE__, 'projects_portfolio_flush_rewrite_rules' );
    +
    +/**
    + * Add rewrite rules for download endpoint.
    + *
    + * @since  1.0.0
    + * @return void
    + */
    +function projects_portfolio_add_rewrite_rules() {
    +    add_rewrite_rule(
    +        '^download/([0-9]+)/?$',
    +        'index.php?project_download_id=$matches[1]',
    +        'top'
    +    );
    +}
    +add_action( 'init', 'projects_portfolio_add_rewrite_rules' );
    +
    +/**
    + * WP_Query Vars
    + *
    + * @param array $vars Query variables array.
    + *
    + * @since  1.0.0
    + * @return array
    + */
    +function projects_portfolio_query_vars( $vars ) {
    +    $vars[] = 'project_download_id';
    +    return $vars;
    +}
    +add_filter( 'query_vars', 'projects_portfolio_query_vars' );
    +
    +/**
    + * Handle Download Redirect and Increment Download Count
    + *
    + * @since  1.0.0
    + * @return void
    + */
    +function projects_portfolio_handle_download_redirect() {
    +    $project_id = get_query_var( 'project_download_id' );
    +
    +    if ( $project_id ) {
    +        $github_url   = get_post_meta( $project_id, '_projects_portfolio_github_url', true );
    +        $download_url = projects_portfolio_get_github_release_url( $github_url );
    +
    +        if ( $download_url ) {
    +            // Increment download count.
    +            $download_count = (int) get_post_meta( $project_id, '_projects_portfolio_download_count', true );
    +            ++$download_count;
    +            update_post_meta( $project_id, '_projects_portfolio_download_count', $download_count );
    +
    +            // Redirect to the GitHub ZIP file.
    +            wp_safe_redirect( esc_url_raw( $download_url ) );
    +            exit;
    +        } else {
    +            wp_die(
    +                esc_html__( 'Invalid download URL. Please check the GitHub repository.', 'projects-wp' ),
    +                esc_html__( 'Download Error', 'projects-wp' ),
    +                array( 'response' => 404 )
    +            );
    +        }
    +    }
    +}
    +add_action( 'template_redirect', 'projects_portfolio_handle_download_redirect' );
    +
    +/**
    + * Add Download Count Column to Projects Admin Table
    + *
    + * @since  1.0.0
    + * @param  array $columns The columns array.
    + * @return mixed
    + */
    +function projects_portfolio_add_download_count_column( $columns ) {
    +    $columns['download_count'] = esc_html__( 'Download Count', 'projects-wp' );
    +    return $columns;
    +}
    +add_filter( 'manage_projects_posts_columns', 'projects_portfolio_add_download_count_column' );
    +
    +/**
    + * Display Download Count in Admin Column
    + *
    + * @since  1.0.0
    + * @param  string $column  The column name.
    + * @param  int    $post_id The post ID.
    + * @return void
    + */
    +function projects_portfolio_display_download_count_column( $column, $post_id ) {
    +    if ( 'download_count' === $column ) {
    +        $download_count = (int) get_post_meta( $post_id, '_projects_portfolio_download_count', true );
    +        echo $download_count ? esc_html( $download_count ) : esc_html__( '0', 'projects-wp' );
    +    }
    +}
    +add_action( 'manage_projects_posts_custom_column', 'projects_portfolio_display_download_count_column', 10, 2 );
    +
    +/**
    + * Make the Download Count Column Sortable
    + *
    + * @since  1.0.0
    + * @param  array $columns The columns array.
    + * @return mixed
    + */
    +function projects_portfolio_sortable_columns( $columns ) {
    +    $columns['download_count'] = 'download_count';
    +    return $columns;
    +}
    +add_filter( 'manage_edit-projects_sortable_columns', 'projects_portfolio_sortable_columns' );
    +
    +/**
    + * Handle Sorting for Download Count
    + *
    + * @since  1.0.0
    + * @param  WP_Query $query The query object.
    + * @return void
    + */
    +function projects_portfolio_sort_download_count_column( $query ) {
    +    if ( ! is_admin() || ! $query->is_main_query() ) {
    +        return;
    +    }
    +
    +    if ( 'download_count' === $query->get( 'orderby' ) ) {
    +        $query->set( 'meta_key', '_projects_portfolio_download_count' );
    +        $query->set( 'orderby', 'meta_value_num' );
    +    }
    +}
    +add_action( 'pre_get_posts', 'projects_portfolio_sort_download_count_column' );
    +
    +/**
    + * Register custom REST API endpoint for projects.
    + *
    + * @since  1.0.0
    + * @return void
    + */
    +function projects_portfolio_register_custom_endpoint() {
    +    register_rest_route(
    +        'projects/v1',
    +        '/projects',
    +        array(
    +            'methods'             => WP_REST_Server::READABLE,
    +            'callback'            => 'projects_portfolio_get_projects_data',
    +            'permission_callback' => '__return_true',
    +        )
    +    );
    +}
    +add_action( 'rest_api_init', 'projects_portfolio_register_custom_endpoint' );
    +
    +/**
    + * Load custom templates for single and archive project views.
    + *
    + * @since  1.0.0
    + * @param  string $template The template file path.
    + * @return mixed
    + */
    +function projects_portfolio_template_loader( $template ) {
    +    if ( is_singular( 'projects' ) ) {
    +        // Check for a single-projects.php template in the theme
    +        $theme_template = locate_template( 'single-projects.php' );
    +        return $theme_template ? $theme_template : plugin_dir_path( __FILE__ ) . 'templates/single-projects.php';
    +    }
    +
    +    if ( is_post_type_archive( 'projects' ) ) {
    +        // Check for an archive-projects.php template in the theme
    +        $theme_template = locate_template( 'archive-projects.php' );
    +        return $theme_template ? $theme_template : plugin_dir_path( __FILE__ ) . 'templates/archive-projects.php';
    +    }
    +
    +    if ( is_tax( 'project-type' ) ) {
    +        // Check for a taxonomy-project-type.php template in the theme
    +        $theme_template = locate_template( 'archive-project-type.php' );
    +        return $theme_template ? $theme_template : plugin_dir_path( __FILE__ ) . 'templates/taxonomy-project-type.php';
    +    }
    +
    +    return $template;
    +}
    +add_filter( 'template_include', 'projects_portfolio_template_loader' );
    +
    +/**
    + * Enqueue styles for project single and archive templates.
    + *
    + * @since  1.0.0
    + * @return void
    + */
    +function projects_portfolio_enqueue_project_styles() {
    +    if ( is_singular( 'projects' ) || is_post_type_archive( 'projects' ) || is_tax( 'project-type' ) ) {
    +        $is_fse_theme = wp_theme_has_theme_json() && function_exists( 'wp_is_block_theme' ) && wp_is_block_theme();
    +
    +        // Register stylesheet for both theme types
    +        wp_register_style(
    +            'projects-wp-styles',
    +            plugin_dir_url( __FILE__ ) . 'assets/css/style.css',
    +            array(),
    +            PROJECTS_PORTFOLIO_VERSION
    +        );
    +
    +        if ( $is_fse_theme ) {
    +            // Inline block style enqueue (needed for FSE themes)
    +            add_action(
    +                'wp_footer',
    +                function () {
    +                    echo '';
    +                }
    +            );
    +        } else {
    +            // Classic theme enqueue
    +            wp_enqueue_style( 'projects-wp-styles' );
    +        }
    +    }
    +
    +    if ( is_singular( 'projects' ) ) {
    +        wp_enqueue_script(
    +            'projects-wp-buttons',
    +            plugin_dir_url( __FILE__ ) . 'assets/js/buttons.js',
    +            array(),
    +            PROJECTS_PORTFOLIO_VERSION,
    +            true
    +        );
    +    }
    +}
    +add_action( 'wp_enqueue_scripts', 'projects_portfolio_enqueue_project_styles' );
    +
    +/**
    + * Enqueue admin styles.
    + *
    + * @since  1.0.0
    + * @return void
    + */
    +function projects_portfolio_admin_styles() {
    +    wp_enqueue_style( 'projects-wp-admin-css', plugin_dir_url( __FILE__ ) . 'assets/css/admin-styles.css' );
    +}
    +add_action( 'admin_enqueue_scripts', 'projects_portfolio_admin_styles' );
    +
    +/**
    + * Modify the number of posts per page for the 'projects' post type archive.
    + *
    + * Ensures only the 'projects' archive page is affected without changing global settings.
    + *
    + * @param WP_Query $query The WordPress query object.
    + *
    + * @since  1.0.0
    + * @return void
    + */
    +function projects_portfolio_custom_posts_per_page( $query ) {
    +    if ( is_admin() || ! $query->is_main_query() ) {
    +        return;
    +    }
    +
    +    $projects_per_page = apply_filters( 'projects_portfolio_archives_projects_per_page', 12 );
    +
    +    if ( is_post_type_archive( 'projects' ) ) {
    +        $query->set( 'posts_per_page', $projects_per_page );
    +    }
    +}
    +add_action( 'pre_get_posts', 'projects_portfolio_custom_posts_per_page', 1 );
    +
    +/**
    + * Modify the posts per page for the 'projects' post type archive in Full Site Editing (FSE) themes.
    + *
    + * This function ensures that the 'projects' post type archive displays 12 posts per page,
    + * even when using an FSE theme with a Query Loop block.
    + *
    + * @param array  $query The existing query variables for the Query Loop block.
    + * @param object $block The current block object (not used but available if needed).
    + *
    + * @since  1.0.0
    + * @return array Modified query variables with 'posts_per_page' set for the projects archive.
    + */
    +function modify_projects_posts_per_page_fse( $query, $block ) { // phpcs:ignore
    +    // Ensure we are modifying the archive query for the 'projects' post type.
    +    if ( isset( $query['post_type'] ) && $query['post_type'] === 'projects' ) {
    +        $query['posts_per_page'] = 12;
    +    }
    +
    +    return $query;
    +}
    +add_filter( 'query_loop_block_query_vars', 'modify_projects_posts_per_page_fse', 10, 2 );
    +
    +/**
    + * Add social sharing buttons with Tabler icons.
    + *
    + * @param int $project_id The project post ID.
    + *
    + * @since  1.0.0
    + * @return void
    + */
    +function projects_portfolio_social_sharing_buttons( $project_id ) {
    +    $url   = rawurlencode( get_permalink( $project_id ) );
    +    $title = rawurlencode( get_the_title( $project_id ) );
    +
    +    $html = '';
    +
    +    echo wp_kses_post( $html );
    +}
    +add_action( 'projects_after_download_button', 'projects_portfolio_social_sharing_buttons', 999 );
    diff --git a/templates/archive-projects.php b/templates/archive-projects.php
    new file mode 100644
    index 0000000..89e8916
    --- /dev/null
    +++ b/templates/archive-projects.php
    @@ -0,0 +1,72 @@
    +' );
    +} else {
    +    get_header();
    +}
    +
    +$settings = projects_portfolio_settings();
    +
    +?>
    +
    + +

    + + +
    + +
    + + + + +

    + +

    + + + + + + + +
    + +
    + + + + + +

    + +
    + +' ); +} else { + get_footer(); +} diff --git a/templates/single-projects.php b/templates/single-projects.php new file mode 100644 index 0000000..d2cf810 --- /dev/null +++ b/templates/single-projects.php @@ -0,0 +1,242 @@ +' ); +} else { + get_header(); +} + +$settings = projects_portfolio_settings(); +$project_id = get_the_ID(); +$download_count = (int) get_post_meta( $project_id, '_projects_portfolio_download_count', true ); +$github_url = get_post_meta( $project_id, '_projects_portfolio_github_url', true ); +$version = 'Unknown'; +$github_data = projects_portfolio_get_github_data( $github_url ); + +// Extract specific GitHub data. +$owner_avatar = $github_data['owner']['avatar_url'] ?? ''; +$owner_name = $github_data['owner']['login'] ?? ''; +$owner_url = $github_data['owner']['html_url'] ?? ''; +$last_updated = $github_data['updated_at'] ?? ''; +$language = $github_data['language'] ?? ''; +$license = $github_data['license']['name'] ?? 'None'; + +$owner = projects_portfolio_github_owner( $owner_name ); + +// Fetch the version number from the GitHub API if the URL is set. +if ( $github_url ) { + // Retrieve the GitHub API token from the plugin settings. + $github_token = get_option( 'projects_portfolio_github_api_token', '' ); + + // Prepare the API URL. + $api_url = str_replace( 'https://github.com/', 'https://api.github.com/repos/', rtrim( $github_url, '/' ) ) . '/releases/latest'; + + // Check if the response is cached. + $transient_key = 'github_api_response_' . md5( $api_url ); + $response = get_transient( $transient_key ); + + if ( false === $response ) { + // Prepare the request arguments. + $args = []; + if ( ! empty( $github_token ) ) { + $args['headers'] = [ + 'Authorization' => 'token ' . $github_token, + ]; + } + + // Make the API request. + $response = wp_remote_get( $api_url, $args ); + + // Cache the response for 1 hour if the request is successful. + if ( ! is_wp_error( $response ) && 200 === wp_remote_retrieve_response_code( $response ) ) { + set_transient( $transient_key, $response, HOUR_IN_SECONDS ); + } + } + + // Handle the response. + if ( is_wp_error( $response ) ) { + error_log( 'GitHub API error: ' . $response->get_error_message() ); + } else { + $response_code = wp_remote_retrieve_response_code( $response ); + $response_body = wp_remote_retrieve_body( $response ); + error_log( 'GitHub API response code: ' . $response_code ); + error_log( 'GitHub API response body: ' . $response_body ); + + if ( $response_code === 200 ) { + $data = json_decode( $response_body, true ); + + // Check if tag_name exists in the response. + if ( isset( $data['tag_name'] ) ) { + $version = esc_html( $data['tag_name'] ); + } + } else { + error_log( "GitHub API error: HTTP $response_code for URL $api_url" ); + } + } +} + +// Format last updated date. +if ( $last_updated ) { + $last_updated = date_i18n( get_option( 'date_format' ), strtotime( $last_updated ) ); +} +?> + +> + +
    +
    +
    + + + + <?php esc_attr_e( 'Project Banner', 'projects-wp' ); ?> + +
    +
    + +
    +
    +

    + +

    + +
    +
    +
    + + + + + + + + +

    + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + <?php esc_attr_e( $owner_name ); ?> + + + + + + + + + +
    + + +
    +
    +
    + +' ); +} else { + get_footer(); +} +?> + + +' ); +} else { + get_header(); +} + +$settings = projects_portfolio_settings(); + +?> +
    + +

    + + +
    + +
    + + + + +

    + +

    + + + + + + + +
    + +
    + + + + + +

    + +
    + +' ); +} else { + get_footer(); +}