├── LICENSE ├── README.md ├── composer.json ├── package.json └── src ├── App └── Model │ ├── Fields.php │ ├── GitHubReleases.php │ ├── GitHubRepositoryContent.php │ ├── Requester.php │ └── Upgrader.php ├── Bootstrap.php └── languages ├── generic.pot ├── ja.mo └── ja.po /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WP GitHub Theme Updater 2 | 3 | ![CI](https://github.com/inc2734/wp-github-theme-updater/workflows/CI/badge.svg) 4 | [![Latest Stable Version](https://poser.pugx.org/inc2734/wp-github-theme-updater/v/stable)](https://packagist.org/packages/inc2734/wp-github-theme-updater) 5 | [![License](https://poser.pugx.org/inc2734/wp-github-theme-updater/license)](https://packagist.org/packages/inc2734/wp-github-theme-updater) 6 | 7 | ## Install 8 | ``` 9 | $ composer require inc2734/wp-github-theme-updater 10 | ``` 11 | 12 | ## How to use 13 | ``` 14 | /<$repository> 24 | 25 | Customize downloaded package url. 26 | 27 | ``` 28 | add_filter( 29 | 'inc2734_github_theme_updater_zip_url_inc2734/snow-monkey', 30 | function( $url, $user_name, $repository, $tag_name ) { 31 | return $url; 32 | }, 33 | 10, 34 | 4 35 | ); 36 | ``` 37 | 38 | ### inc2734_github_theme_updater_request_url_<$user_name>/<$repository> 39 | 40 | Customize requested api url. 41 | 42 | ``` 43 | add_filter( 44 | 'inc2734_github_theme_updater_request_url_inc2734/snow-monkey', 45 | function( $url, $user_name, $repository ) { 46 | return $url; 47 | }, 48 | 10, 49 | 3 50 | ); 51 | ``` 52 | 53 | ### inc2734_github_theme_updater_transient_response_<$user_name>/<$repository> 54 | 55 | Customize transient response 56 | 57 | ``` 58 | add_filter( 59 | 'inc2734_github_theme_updater_transient_response_inc2734/snow-monkey', 60 | function( $transient_response ) { 61 | return $transient_response; 62 | } 63 | ); 64 | ``` 65 | 66 | ### inc2734_github_theme_updater_repository_content_url_<$user_name>/<$repository> 67 | 68 | Customize contents api url. 69 | 70 | ``` 71 | add_filter( 72 | 'inc2734_github_theme_updater_repository_content_url_inc2734/snow-monkey', 73 | function( $url, $user_name, $repository, $theme_name ) { 74 | return $url; 75 | }, 76 | 10, 77 | 4 78 | ); 79 | ``` 80 | 81 | ### inc2734_github_theme_updater_repository_content_headers_<$user_name>/<$repository> 82 | 83 | Customize fields contents_api. 84 | 85 | ``` 86 | add_filter( 87 | 'inc2734_github_theme_updater_repository_content_headers_inc2734/snow-monkey', 88 | function( $headers ) { 89 | return $headers; 90 | } 91 | ); 92 | ``` 93 | 94 | ### inc2734_github_theme_updater_zip_url 95 | 96 | **Obsolete from v2.0.0** 97 | 98 | Customize downloaded api url. 99 | 100 | ``` 101 | add_filter( 102 | 'inc2734_github_theme_updater_zip_url', 103 | function( $url, $user_name, $repository, $tag_name ) { 104 | if ( 'inc2734' === $user_name && 'snow-monkey-blocks' === $repository ) { 105 | return 'https://example.com/my-custom-updater-zip-url'; 106 | } 107 | return $url; 108 | }, 109 | 10, 110 | 4 111 | ); 112 | ``` 113 | 114 | ### inc2734_github_theme_updater_request_url 115 | 116 | **Obsolete from v2.0.0** 117 | 118 | Customize requested api url. 119 | 120 | ``` 121 | add_filter( 122 | 'inc2734_github_theme_updater_request_url', 123 | function( $url, $user_name, $repository ) { 124 | if ( 'inc2734' === $user_name && 'snow-monkey' === $repository ) { 125 | return 'https://example.com/my-custom-updater-request-url'; 126 | } 127 | return $url; 128 | }, 129 | 10, 130 | 3 131 | ); 132 | ``` 133 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "inc2734/wp-github-theme-updater", 3 | "description": "A library for WordPress that automatic theme updater with GitHub API.", 4 | "license": "GPL-2.0-or-later", 5 | "require": { 6 | "php": ">=7.4" 7 | }, 8 | "require-dev": { 9 | "wp-coding-standards/wpcs": "^3.1", 10 | "dealerdirect/phpcodesniffer-composer-installer": "^1.0", 11 | "phpcompatibility/phpcompatibility-wp": "*", 12 | "yoast/phpunit-polyfills": "^1.1" 13 | }, 14 | "authors": [ 15 | { 16 | "name": "Takashi Kitajima", 17 | "email": "inc@2inc.org" 18 | } 19 | ], 20 | "autoload": { 21 | "psr-4" : { 22 | "Inc2734\\WP_GitHub_Theme_Updater\\" : "src" 23 | } 24 | }, 25 | "scripts": { 26 | "format": "phpcbf --standard=./.phpcs.xml.dist --report-summary --report-source", 27 | "lint": "phpcs --standard=./.phpcs.xml.dist" 28 | }, 29 | "config": { 30 | "allow-plugins": { 31 | "dealerdirect/phpcodesniffer-composer-installer": true 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "engines": { 3 | "node": ">=20.10.0", 4 | "npm": ">=10.2.3" 5 | }, 6 | "volta": { 7 | "node": "20.11.1" 8 | }, 9 | "author": "inc2734", 10 | "license": "GPL-2.0+", 11 | "devDependencies": { 12 | "@wordpress/env": "^10.21.0", 13 | "npm-run-all": "^4.1.5" 14 | }, 15 | "scripts": { 16 | "wp-env": "wp-env", 17 | "start": "wp-env start", 18 | "stop": "wp-env stop", 19 | "cli": "wp-env run --env-cwd=wp-content/plugins/wp-github-theme-updater cli", 20 | "wp": "wp-env run cli --env-cwd=\"wp-content/plugins/wp-github-theme-updater\" wp", 21 | "composer": "wp-env run --env-cwd=\"wp-content/plugins/wp-github-theme-updater\" cli composer", 22 | "pretest": "wp-env start && npm run composer install -- --no-interaction", 23 | "test:lint:php": "wp-env start && npm run composer lint", 24 | "test:lint": "run-s test:lint:*", 25 | "test:unit:php": "wp-env start && wp-env run --env-cwd=\"wp-content/plugins/wp-github-theme-updater\" tests-wordpress vendor/bin/phpunit -c .phpunit.xml.dist --verbose", 26 | "test:unit": "run-s test:unit:*", 27 | "test": "run-s test:*", 28 | "make-pot": "npm run wp i18n -- make-pot ./src ./src/languages/generic.pot --exclude=./src/assets --domain=inc2734-wp-github-theme-updater" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/App/Model/Fields.php: -------------------------------------------------------------------------------- 1 | $value ) { 156 | if ( property_exists( $this, $field ) ) { 157 | $this->$field = $value; 158 | } 159 | } 160 | } 161 | 162 | /** 163 | * Return specific property. 164 | * 165 | * @param string $field Field. 166 | * @return mixed 167 | */ 168 | public function get( $field ) { 169 | if ( property_exists( $this, $field ) ) { 170 | return $this->$field; 171 | } 172 | return false; 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /src/App/Model/GitHubReleases.php: -------------------------------------------------------------------------------- 1 | theme_name = $theme_name; 52 | $this->user_name = $user_name; 53 | $this->repository = $repository; 54 | $this->transient_name = sprintf( 'wp_github_theme_updater_%1$s', $this->theme_name ); 55 | } 56 | 57 | /** 58 | * Get response of GitHub API. 59 | * 60 | * @param string|null $version Version. 61 | * @return array|WP_Error 62 | */ 63 | public function get( $version = null ) { 64 | $transient = get_transient( $this->transient_name ); 65 | if ( is_object( $transient ) ) { 66 | $transient = (array) $transient; 67 | } 68 | if ( ! is_array( $transient ) ) { 69 | $transient = array(); 70 | } 71 | 72 | if ( ! $version && ! empty( $transient['latest'] ) ) { 73 | return $transient['latest']; 74 | } elseif ( ! empty( $transient[ $version ] ) ) { 75 | return $transient[ $version ]; 76 | } 77 | 78 | $response = $this->_request( $version ); 79 | $response = $this->_retrieve( $response ); 80 | 81 | if ( ! is_wp_error( $response ) ) { 82 | if ( ! $version ) { 83 | $transient['latest'] = $response; 84 | } else { 85 | $transient[ $version ] = $response; 86 | } 87 | set_transient( $this->transient_name, $transient, 60 * 5 ); 88 | } else { 89 | $this->delete_transient(); 90 | } 91 | 92 | return $response; 93 | } 94 | 95 | /** 96 | * Delete transient. 97 | */ 98 | public function delete_transient() { 99 | delete_transient( $this->transient_name ); 100 | } 101 | 102 | /** 103 | * Retrive. 104 | * 105 | * @param array|WP_Error $response HTTP response. 106 | * @return array|WP_Error 107 | */ 108 | protected function _retrieve( $response ) { 109 | if ( is_wp_error( $response ) ) { 110 | return $response; 111 | } 112 | 113 | $response_code = wp_remote_retrieve_response_code( $response ); 114 | $response_code = $response_code ? $response_code : 503; 115 | if ( 200 !== (int) $response_code ) { 116 | return new WP_Error( 117 | $response_code, 118 | sprintf( 119 | '[%1$s] Failed to get update response. HTTP status is "%2$s"', 120 | $this->theme_name, 121 | $response_code 122 | ) 123 | ); 124 | } 125 | 126 | $body = json_decode( wp_remote_retrieve_body( $response ) ); 127 | if ( ! is_object( $body ) ) { 128 | return new WP_Error( 129 | $response_code, 130 | sprintf( 131 | '[%1$s] Failed to get update response.', 132 | $this->theme_name 133 | ) 134 | ); 135 | } 136 | 137 | $body->package = ! empty( $body->tag_name ) 138 | ? $this->_get_zip_url( $body ) 139 | : false; 140 | 141 | return $body; 142 | } 143 | 144 | /** 145 | * Request. 146 | * 147 | * @param string|null $version Version. 148 | * @return array|WP_Error 149 | */ 150 | protected function _request( $version = null ) { 151 | $url = ! $version 152 | ? sprintf( 153 | 'https://api.github.com/repos/%1$s/%2$s/releases/latest', 154 | $this->user_name, 155 | $this->repository 156 | ) 157 | : sprintf( 158 | 'https://api.github.com/repos/%1$s/%2$s/releases/tags/%3$s', 159 | $this->user_name, 160 | $this->repository, 161 | $version 162 | ); 163 | 164 | // phpcs:disable WordPress.NamingConventions.ValidHookName.UseUnderscores 165 | $url = apply_filters( 166 | sprintf( 167 | 'inc2734_github_theme_updater_request_url_%1$s/%2$s', 168 | $this->user_name, 169 | $this->repository 170 | ), 171 | $url, 172 | $this->user_name, 173 | $this->repository, 174 | $version 175 | ); 176 | // phpcs:enable 177 | 178 | return Requester::request( 179 | $url, 180 | $this->user_name, 181 | $this->repository 182 | ); 183 | } 184 | 185 | /** 186 | * Get remote zip URL. 187 | * 188 | * @throws \RuntimeException Invalid zip URL. 189 | * 190 | * @param stdClass $response Responser of GitHub API. 191 | * @return string|false 192 | */ 193 | protected function _get_zip_url( $response ) { 194 | $url = false; 195 | 196 | if ( ! empty( $response->assets ) && is_array( $response->assets ) ) { 197 | if ( ! empty( $response->assets[0] ) && is_object( $response->assets[0] ) ) { 198 | if ( ! empty( $response->assets[0]->browser_download_url ) ) { 199 | $url = $response->assets[0]->browser_download_url; 200 | } 201 | } 202 | } 203 | 204 | $tag_name = isset( $response->tag_name ) ? $response->tag_name : null; 205 | 206 | if ( ! $url && $tag_name ) { 207 | $url = sprintf( 208 | 'https://github.com/%1$s/%2$s/releases/download/%3$s/%2$s.zip', 209 | $this->user_name, 210 | $this->repository, 211 | $tag_name 212 | ); 213 | } 214 | 215 | // phpcs:disable WordPress.NamingConventions.ValidHookName.UseUnderscores 216 | $url = apply_filters( 217 | sprintf( 218 | 'inc2734_github_theme_updater_zip_url_%1$s/%2$s', 219 | $this->user_name, 220 | $this->repository 221 | ), 222 | $url, 223 | $this->user_name, 224 | $this->repository, 225 | $tag_name 226 | ); 227 | // phpcs:enable 228 | 229 | try { 230 | if ( ! $url ) { 231 | throw new \RuntimeException( 232 | sprintf( 233 | '[%1$s] Can\'t find zip URL for update.', 234 | $this->theme_name 235 | ) 236 | ); 237 | } 238 | 239 | $http_status_code = $this->get_http_status_code( $url ); 240 | if ( ! in_array( (int) $http_status_code, array( 200, 302 ), true ) ) { 241 | throw new \RuntimeException( 242 | sprintf( 243 | '[%1$s] Can\'t find zip URL for update. HTTP status code is "%2$s"', 244 | $this->theme_name, 245 | $http_status_code 246 | ) 247 | ); 248 | } 249 | } catch ( \Exception $e ) { 250 | error_log( $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log 251 | return false; 252 | } 253 | 254 | return $url; 255 | } 256 | 257 | /** 258 | * Return http status code from $url. 259 | * 260 | * @param string $url Target url. 261 | * @return int 262 | */ 263 | public function get_http_status_code( $url ) { 264 | $response = Requester::head( 265 | $url, 266 | $this->user_name, 267 | $this->repository 268 | ); 269 | 270 | return wp_remote_retrieve_response_code( $response ); 271 | } 272 | } 273 | -------------------------------------------------------------------------------- /src/App/Model/GitHubRepositoryContent.php: -------------------------------------------------------------------------------- 1 | theme_name = $theme_name; 52 | $this->user_name = $user_name; 53 | $this->repository = $repository; 54 | $this->transient_name = sprintf( 'wp_github_theme_updater_repository_data_%1$s', $this->theme_name ); 55 | } 56 | 57 | /** 58 | * Get GitHub repository content. 59 | * 60 | * @param string|null $version Version. 61 | * @return string|WP_Error 62 | */ 63 | public function get( $version = null ) { 64 | $transient = get_transient( $this->transient_name ); 65 | if ( is_object( $transient ) ) { 66 | $transient = (array) $transient; 67 | } 68 | if ( ! is_array( $transient ) ) { 69 | $transient = array(); 70 | } 71 | 72 | if ( ! $version && ! empty( $transient['latest'] ) ) { 73 | return $transient['latest']; 74 | } elseif ( ! empty( $transient[ $version ] ) ) { 75 | return $transient[ $version ]; 76 | } 77 | 78 | $response = $this->_request( $version ); 79 | $response = $this->_retrieve( $response ); 80 | 81 | // phpcs:disable Generic.CodeAnalysis.EmptyStatement.DetectedElse 82 | if ( ! is_wp_error( $response ) ) { 83 | if ( ! $version ) { 84 | $transient['latest'] = $response; 85 | } else { 86 | $transient[ $version ] = $response; 87 | } 88 | set_transient( $this->transient_name, $transient, 60 * 5 ); 89 | } else { 90 | // @todo Since it is not essential for updating, the cache is not erased by the GItHub API rate limitation measures. 91 | // $this->delete_transient(); 92 | } 93 | // phpcs:enable 94 | 95 | return $response; 96 | } 97 | 98 | /** 99 | * Delete transient. 100 | */ 101 | public function delete_transient() { 102 | delete_transient( $this->transient_name ); 103 | } 104 | 105 | /** 106 | * Get HTTP headers. 107 | * 108 | * @see https://developer.wordpress.org/reference/functions/get_file_data/ 109 | * @see https://developer.wordpress.org/reference/functions/wp_get_theme/ 110 | * 111 | * @param string|null $version Version. 112 | * @return array 113 | */ 114 | public function get_headers( $version = null ) { 115 | $headers = array(); 116 | 117 | $content = $this->get( $version ); 118 | 119 | $target_headers = array( 120 | 'RequiresWP' => 'Requires at least', 121 | 'RequiresPHP' => 'Requires PHP', 122 | 'Tested up to' => 'Tested up to', 123 | ); 124 | 125 | if ( null !== $content && ! is_wp_error( $content ) ) { 126 | $content = substr( $content, 0, 8 * KB_IN_BYTES ); 127 | $content = str_replace( "\r", "\n", $content ); 128 | } else { 129 | $content = ''; 130 | } 131 | 132 | foreach ( $target_headers as $field => $regex ) { 133 | if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $content, $match ) && $match[1] ) { 134 | $headers[ $field ] = _cleanup_header_comment( $match[1] ); 135 | } else { 136 | $headers[ $field ] = ''; 137 | } 138 | } 139 | 140 | // phpcs:disable WordPress.NamingConventions.ValidHookName.UseUnderscores 141 | return apply_filters( 142 | sprintf( 143 | 'inc2734_github_theme_updater_repository_content_headers_%1$s/%2$s', 144 | $this->user_name, 145 | $this->repository 146 | ), 147 | $headers, 148 | $this->user_name, 149 | $this->repository, 150 | $version 151 | ); 152 | // phpcs:enable 153 | } 154 | 155 | /** 156 | * Retrieve. 157 | * 158 | * @param array|WP_Error $response HTTP response. 159 | * @return string 160 | */ 161 | protected function _retrieve( $response ) { 162 | if ( is_wp_error( $response ) ) { 163 | return $response; 164 | } 165 | 166 | $response_code = wp_remote_retrieve_response_code( $response ); 167 | $response_code = $response_code ? $response_code : 503; 168 | if ( 200 !== (int) $response_code ) { 169 | return new WP_Error( 170 | $response_code, 171 | sprintf( 172 | '[%1$s] Failed to get GitHub repository content. HTTP status is "%2$s"', 173 | $this->theme_name, 174 | $response_code 175 | ) 176 | ); 177 | } 178 | 179 | $body = json_decode( wp_remote_retrieve_body( $response ) ); 180 | if ( ! is_object( $body ) ) { 181 | return new WP_Error( 182 | $response_code, 183 | sprintf( 184 | '[%1$s] Failed to get GitHub repository content', 185 | $this->theme_name 186 | ) 187 | ); 188 | } 189 | 190 | if ( ! isset( $body->content ) ) { 191 | return null; 192 | } 193 | 194 | return base64_decode( $body->content ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode 195 | } 196 | 197 | /** 198 | * Requesst. 199 | * 200 | * @param string|null $version Version. 201 | * @return array|WP_Error 202 | */ 203 | protected function _request( $version = null ) { 204 | $current = wp_get_theme( $this->theme_name ); 205 | 206 | $url = ! $version 207 | ? sprintf( 208 | 'https://api.github.com/repos/%1$s/%2$s/contents/%3$s', 209 | $this->user_name, 210 | $this->repository, 211 | preg_replace( '|^([^/]*?/)|', '', $current->get( 'Stylesheet' ) ) . '/style.css' 212 | ) 213 | : sprintf( 214 | 'https://api.github.com/repos/%1$s/%2$s/contents/%3$s?ref=%4$s', 215 | $this->user_name, 216 | $this->repository, 217 | preg_replace( '|^([^/]*?/)|', '', $current->get( 'Stylesheet' ) ) . '/style.css', 218 | $version 219 | ); 220 | 221 | // phpcs:disable WordPress.NamingConventions.ValidHookName.UseUnderscores 222 | $url = apply_filters( 223 | sprintf( 224 | 'inc2734_github_theme_updater_repository_content_url_%1$s/%2$s', 225 | $this->user_name, 226 | $this->repository 227 | ), 228 | $url, 229 | $this->user_name, 230 | $this->repository, 231 | $this->theme_name, 232 | $version 233 | ); 234 | // phpcs:enable 235 | 236 | return Requester::request( 237 | $url, 238 | $this->user_name, 239 | $this->repository 240 | ); 241 | } 242 | } 243 | -------------------------------------------------------------------------------- /src/App/Model/Requester.php: -------------------------------------------------------------------------------- 1 | 'WordPress/' . $wp_version, 56 | 'timeout' => 30, 57 | 'headers' => array( 58 | 'Accept-Encoding' => '', 59 | ), 60 | ), 61 | $url, 62 | $user_name, 63 | $repository 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/App/Model/Upgrader.php: -------------------------------------------------------------------------------- 1 | theme_name = $theme_name; 28 | } 29 | 30 | /** 31 | * Filters the installation response before the installation has started. 32 | * 33 | * @param bool|WP_Error $bool Installation response. 34 | * @param array $hook_extra Extra arguments passed to hooked filters. 35 | * @return bool|WP_Error. 36 | */ 37 | public function pre_install( $bool, $hook_extra ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.boolFound 38 | if ( ! isset( $hook_extra['theme'] ) || $this->theme_name !== $hook_extra['theme'] ) { 39 | return $bool; 40 | } 41 | 42 | global $wp_filesystem; 43 | 44 | $theme_dir = trailingslashit( get_theme_root( $this->theme_name ) ) . $this->theme_name; 45 | if ( ! $wp_filesystem->is_writable( $theme_dir ) ) { 46 | return new WP_Error(); 47 | } 48 | 49 | return $bool; 50 | } 51 | 52 | /** 53 | * Filters whether to return the package. 54 | * 55 | * @param bool $reply Whether to bail without returning the package. 56 | * @param string $package The package file name. 57 | * @param WP_Upgrader $upgrader The WP_Upgrader instance. 58 | * @param array $hook_extra Extra arguments passed to hooked filters. 59 | * @return bool 60 | */ 61 | public function upgrader_pre_download( $reply, $package, $upgrader, $hook_extra ) { 62 | if ( ! empty( $hook_extra['theme'] ) && $this->theme_name === $hook_extra['theme'] ) { 63 | $upgrader->strings['downloading_package'] = __( 'Downloading update…', 'inc2734-wp-github-theme-updater' ); 64 | } 65 | return $reply; 66 | } 67 | 68 | /** 69 | * Filters the source file location for the upgrade package. 70 | * 71 | * @param string $source File source location. e.g. /wp-content/upgrade/snow-monkey-EjvQyV/snow-monkey/. 72 | * @param string $remote_source Remote file source location. e.g. /wp-content/upgrade/snow-monkey-EjvQyV. 73 | * @param WP_Upgrader $install WP_Upgrader instance. 74 | * @param array $hook_extra Extra arguments passed to hooked filters. 75 | * @return $source|WP_Error. e.g. /wp-content/upgrade/snow-monkey/. 76 | */ 77 | public function source_selection( $source, $remote_source, $install, $hook_extra ) { 78 | if ( ! isset( $hook_extra['theme'] ) || $this->theme_name !== $hook_extra['theme'] ) { 79 | return $source; 80 | } 81 | 82 | global $wp_filesystem; 83 | 84 | $slash_count = substr_count( $this->theme_name, '/' ); 85 | if ( $slash_count ) { 86 | add_action( 'switch_theme', array( $this, '_re_activate' ), 10, 3 ); 87 | } 88 | 89 | $subdir_name = untrailingslashit( str_replace( trailingslashit( $remote_source ), '', $source ) ); 90 | if ( ! empty( $subdir_name ) && $subdir_name !== $this->theme_name ) { 91 | $from_path = untrailingslashit( $source ); 92 | $to_path = trailingslashit( $remote_source ) . $this->theme_name; 93 | if ( true === $wp_filesystem->move( $from_path, $to_path ) ) { 94 | return $to_path; 95 | } 96 | 97 | return new WP_Error(); 98 | } 99 | 100 | return $source; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/Bootstrap.php: -------------------------------------------------------------------------------- 1 | theme_name = $theme_name; 66 | $this->user_name = $user_name; 67 | $this->repository = $repository; 68 | $this->fields = new Fields( $fields ); 69 | 70 | $upgrader = new App\Model\Upgrader( $theme_name ); 71 | $this->github_releases = new GitHubReleases( $theme_name, $user_name, $repository ); 72 | $this->github_repository_content = new GitHubRepositoryContent( $theme_name, $user_name, $repository ); 73 | 74 | add_filter( 'init', array( $this, '_init' ) ); 75 | add_filter( 'pre_set_site_transient_update_themes', array( $this, '_pre_set_site_transient_update_themes' ) ); 76 | add_filter( 'upgrader_pre_install', array( $upgrader, 'pre_install' ), 10, 2 ); 77 | add_filter( 'upgrader_pre_download', array( $upgrader, 'upgrader_pre_download' ), 10, 4 ); 78 | add_filter( 'upgrader_source_selection', array( $upgrader, 'source_selection' ), 10, 4 ); 79 | add_action( 'upgrader_process_complete', array( $this, '_upgrader_process_complete' ), 10, 2 ); 80 | } 81 | 82 | /** 83 | * Load textdomain. 84 | */ 85 | public function _init() { 86 | load_textdomain( 'inc2734-wp-github-theme-updater', __DIR__ . '/languages/' . get_locale() . '.mo' ); 87 | } 88 | 89 | /** 90 | * Overwrite site_transient_update_themes from GitHub API. 91 | * 92 | * @see 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/ 93 | * 94 | * @throws \RuntimeException Invalid response. 95 | * 96 | * @param false|array $transient New value of site transient. 97 | * @return false|array 98 | */ 99 | public function _pre_set_site_transient_update_themes( $transient ) { 100 | global $wp_version; 101 | 102 | $response = $this->github_releases->get(); 103 | try { 104 | if ( is_wp_error( $response ) ) { 105 | throw new \RuntimeException( $response->get_error_message() ); 106 | } 107 | } catch ( \Exception $e ) { 108 | error_log( $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log 109 | return $transient; 110 | } 111 | 112 | if ( ! isset( $response->tag_name ) ) { 113 | return $transient; 114 | } 115 | 116 | if ( ! $response->package ) { 117 | return $transient; 118 | } 119 | 120 | $remote = $this->github_repository_content->get_headers( $response->tag_name ); 121 | $update = array( 122 | 'theme' => $this->theme_name, 123 | 'new_version' => $response->tag_name, 124 | 'url' => $this->fields->get( 'homepage' ), 125 | 'package' => $response->package, 126 | 'tested' => $this->fields->get( 'tested' ) ? $this->fields->get( 'tested' ) : $remote['Tested up to'], 127 | 'requires' => $this->fields->get( 'requires' ) ? $this->fields->get( 'require' ) : $remote['RequiresWP'], 128 | 'requires_php' => $this->fields->get( 'requires_php' ) ? $this->fields->get( 'requires_php' ) : $remote['RequiresPHP'], 129 | ); 130 | 131 | // phpcs:disable WordPress.NamingConventions.ValidHookName.UseUnderscores 132 | $update = apply_filters( 133 | sprintf( 134 | 'inc2734_github_theme_updater_transient_response_%1$s/%2$s', 135 | $this->user_name, 136 | $this->repository 137 | ), 138 | $update 139 | ); 140 | // phpcs:enable 141 | 142 | $current = wp_get_theme( $this->theme_name ); 143 | 144 | $current_version = $current->get( 'Version' ); 145 | $current_requires_wp = $current->get( 'RequiresWP' ); 146 | $current_requires_php = $current->get( 'RequiresPHP' ); 147 | 148 | $env_info = array( 149 | 'wp_version' => $this->_sanitize_version( $wp_version ), 150 | 'php_version' => $this->_sanitize_version( PHP_VERSION ), 151 | ); 152 | 153 | $current_info = array( 154 | 'version' => $this->_sanitize_version( $current_version ), 155 | 'requires_wp' => $this->_sanitize_version( $current_requires_wp ), 156 | 'requires_php' => $this->_sanitize_version( $current_requires_php ), 157 | ); 158 | 159 | $new_info = array( 160 | 'version' => $this->_sanitize_version( $update['new_version'] ), 161 | 'requires_wp' => $this->_sanitize_version( $update['requires'] ), 162 | 'requires_php' => $this->_sanitize_version( $update['requires_php'] ), 163 | ); 164 | 165 | if ( ! static::should_update( $env_info, $current_info, $new_info ) ) { 166 | if ( false === $transient || null === $transient ) { 167 | $transient = new stdClass(); 168 | } 169 | if ( empty( $transient->no_update ) ) { 170 | $transient->no_update = array(); 171 | } 172 | $transient->no_update[ $this->theme_name ] = $update; 173 | } else { 174 | if ( false === $transient || null === $transient ) { 175 | $transient = new stdClass(); 176 | $transient->response = array(); 177 | } 178 | $transient->response[ $this->theme_name ] = $update; 179 | } 180 | 181 | return $transient; 182 | } 183 | 184 | /** 185 | * Fires when the upgrader process is complete. 186 | * 187 | * @param WP_Upgrader $upgrader_object WP_Upgrader instance. In other contexts this might be a Theme_Upgrader, Plugin_Upgrader, Core_Upgrade, or Language_Pack_Upgrader instance. 188 | * @param array $hook_extra Array of bulk item update data. 189 | */ 190 | public function _upgrader_process_complete( $upgrader_object, $hook_extra ) { 191 | if ( 'update' === $hook_extra['action'] && 'theme' === $hook_extra['type'] ) { 192 | foreach ( $hook_extra['themes'] as $theme ) { 193 | if ( $theme === $this->theme_name ) { 194 | $this->github_releases->delete_transient(); 195 | $this->github_repository_content->delete_transient(); 196 | } 197 | } 198 | } 199 | } 200 | 201 | /** 202 | * If theme position is themes/my-theme/sub-dir/style.css, don't re-activate the theme. 203 | * So, I hooked switch_theme hook point and re-activate the theme. 204 | * 205 | * @param string $new_name Theme slug (NOT INCLUDING SUB DIRECTORY !) or Theme name. 206 | * @param WP_Theme $new_theme New WP_Theme object. 207 | * @param WP_Theme $old_theme Old WP_Theme object. 208 | */ 209 | public function _re_activate( $new_name, $new_theme, $old_theme ) { 210 | remove_action( 'switch_theme', array( $this, '_re_activate' ), 10 ); 211 | if ( ! $old_theme->errors() && $new_theme->errors() ) { 212 | switch_theme( untrailingslashit( $old_theme->get_stylesheet() ) ); 213 | } 214 | } 215 | 216 | /** 217 | * Sanitize version. 218 | * 219 | * @param string $version Version. 220 | * @return string 221 | */ 222 | protected function _sanitize_version( $version ) { 223 | if ( false === $version || null === $version ) { 224 | return ''; 225 | } 226 | 227 | $version = preg_replace( '/^v(.*)$/', '$1', $version ); 228 | return $version; 229 | } 230 | 231 | /** 232 | * If remote version is newer, return true. 233 | * 234 | * @param array $env_info Environment info. 235 | * @param array $current_info Current theme info. 236 | * @param array $new_info New theme info. 237 | * @return bool 238 | */ 239 | public static function should_update( $env_info, $current_info, $new_info ) { 240 | $version_ok = version_compare( 241 | $current_info['version'], 242 | $new_info['version'], 243 | '<' 244 | ); 245 | 246 | // Check whether your current environment meets the WP version required by the new theme. 247 | $wp_ok = true; 248 | if ( $new_info['requires_wp'] ) { 249 | $wp_ok = version_compare( 250 | $env_info['wp_version'], 251 | $new_info['requires_wp'], 252 | '>=' 253 | ); 254 | } 255 | 256 | // Check whether your current environment meets the PHP version required by the new theme. 257 | $php_ok = true; 258 | if ( $new_info['requires_php'] ) { 259 | $php_ok = version_compare( 260 | $env_info['php_version'], 261 | $new_info['requires_php'], 262 | '>=' 263 | ); 264 | } 265 | 266 | return $version_ok && $wp_ok && $php_ok; 267 | } 268 | } 269 | -------------------------------------------------------------------------------- /src/languages/generic.pot: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: \n" 4 | "Report-Msgid-Bugs-To: \n" 5 | "Last-Translator: FULL NAME \n" 6 | "Language-Team: LANGUAGE \n" 7 | "MIME-Version: 1.0\n" 8 | "Content-Type: text/plain; charset=UTF-8\n" 9 | "Content-Transfer-Encoding: 8bit\n" 10 | "POT-Creation-Date: 2024-07-11T00:44:49+00:00\n" 11 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 12 | "X-Generator: WP-CLI 2.9.0\n" 13 | "X-Domain: inc2734-wp-github-theme-updater\n" 14 | 15 | #: App/Model/GitHubReleases.php:119 16 | msgid "Failed to get update response." 17 | msgstr "" 18 | 19 | #. Translators: 1: Theme name, 2: Error message 20 | #: App/Model/GitHubReleases.php:123 21 | msgid "[%1$s] %2$s" 22 | msgstr "" 23 | 24 | #: App/Model/Upgrader.php:63 25 | msgid "Downloading update…" 26 | msgstr "" 27 | -------------------------------------------------------------------------------- /src/languages/ja.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inc2734/wp-github-theme-updater/7cee900102c0338d10a26cdf7317ecb268e5e21e/src/languages/ja.mo -------------------------------------------------------------------------------- /src/languages/ja.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 {package-name} 2 | # This file is distributed under the same license as the {package-name} package. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: \n" 6 | "Report-Msgid-Bugs-To: \n" 7 | "POT-Creation-Date: 2024-07-11T00:44:49+00:00\n" 8 | "PO-Revision-Date: 2024-07-11 09:45+0900\n" 9 | "Last-Translator: inc2734 \n" 10 | "Language-Team: \n" 11 | "Language: ja\n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "Plural-Forms: nplurals=1; plural=0;\n" 16 | "X-Generator: Poedit 3.4.4\n" 17 | 18 | #: App/Model/GitHubReleases.php:119 19 | msgid "Failed to get update response." 20 | msgstr "更新情報の取得に失敗しました。" 21 | 22 | #. Translators: 1: Theme name, 2: Error message 23 | #: App/Model/GitHubReleases.php:123 24 | msgid "[%1$s] %2$s" 25 | msgstr "[%1$s] %2$s" 26 | 27 | #: App/Model/Upgrader.php:63 28 | msgid "Downloading update…" 29 | msgstr "更新をダウンロード中…" 30 | --------------------------------------------------------------------------------