admin
1 year ago
api
3 years ago
database
2 years ago
deprecated
3 years ago
donors
1 year ago
emails
3 years ago
forms
1 year ago
frontend
6 years ago
gateways
1 year ago
libraries
2 years ago
payments
1 year ago
actions.php
5 years ago
ajax-functions.php
2 years ago
class-give-async-process.php
1 year ago
class-give-background-updater.php
2 years ago
class-give-cache-setting.php
2 years ago
class-give-cache.php
3 years ago
class-give-cli-commands.php
3 years ago
class-give-comment.php
6 years ago
class-give-cron.php
6 years ago
class-give-donate-form.php
1 year ago
class-give-donor.php
2 years ago
class-give-email-access.php
5 years ago
class-give-license-handler.php
1 year ago
class-give-logging.php
5 years ago
class-give-readme-parser.php
4 years ago
class-give-roles.php
6 years ago
class-give-scripts.php
2 years ago
class-give-session.php
5 years ago
class-give-stats.php
6 years ago
class-give-template-loader.php
6 years ago
class-give-tooltips.php
6 years ago
class-give-translation.php
4 years ago
class-notices.php
2 years ago
country-functions.php
1 year ago
currencies-list.php
3 years ago
currency-functions.php
3 years ago
error-tracking.php
6 years ago
filters.php
3 years ago
formatting.php
1 year ago
install.php
2 years ago
login-register.php
2 years ago
misc-functions.php
1 year ago
plugin-compatibility.php
6 years ago
post-types.php
1 year ago
price-functions.php
6 years ago
process-donation.php
1 year ago
setting-functions.php
6 years ago
shortcodes.php
1 year ago
template-functions.php
4 years ago
user-functions.php
3 years ago
class-give-readme-parser.php
63 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Give Readme Parser |
| 5 | * |
| 6 | * @package Give |
| 7 | * @since 2.1.4 |
| 8 | * @copyright Copyright (c) 2018, GiveWP |
| 9 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
| 10 | * @subpackage Admin/Readme_Parser |
| 11 | */ |
| 12 | class Give_Readme_Parser |
| 13 | { |
| 14 | /** |
| 15 | * Readme file url |
| 16 | * |
| 17 | * @since 2.1.4 |
| 18 | * @access private |
| 19 | * @var |
| 20 | */ |
| 21 | private $file_url; |
| 22 | |
| 23 | /** |
| 24 | * Give_Readme_Parser constructor. |
| 25 | * |
| 26 | * @param string $file_url |
| 27 | */ |
| 28 | public function __construct(string $file_url) |
| 29 | { |
| 30 | $this->file_url = $file_url; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Get required Give core minimum version for addon |
| 35 | * |
| 36 | * @since 2.1.4 |
| 37 | * @access public |
| 38 | * |
| 39 | * @return string |
| 40 | */ |
| 41 | public function requires_at_least() |
| 42 | { |
| 43 | // Regex to extract Give core minimum version from the readme.txt file. |
| 44 | preg_match('/Requires (Give|GiveWP):(.*)/i', $this->get_readme_file_content(), $_requires_at_least); |
| 45 | |
| 46 | if (is_array($_requires_at_least) && 3 === count($_requires_at_least)) { |
| 47 | $_requires_at_least = trim($_requires_at_least[2]); |
| 48 | } else { |
| 49 | $_requires_at_least = null; |
| 50 | } |
| 51 | |
| 52 | return $_requires_at_least; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * @since 2.21.0 |
| 57 | */ |
| 58 | protected function get_readme_file_content(): string |
| 59 | { |
| 60 | return wp_remote_retrieve_body(wp_remote_get($this->file_url)); |
| 61 | } |
| 62 | } |
| 63 |