PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / includes / class-give-readme-parser.php

class-give-readme-parser.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at includes/class-give-readme-parser.php

63 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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