Server IP : 192.158.238.246 / Your IP : 3.15.223.214 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/7779/root/proc/7779/cwd/plugins/give/src/Promotions/InPluginUpsells/ |
Upload File : |
<?php namespace Give\Promotions\InPluginUpsells; /** * @since 2.17.0 */ class AddonsRepository { /** * @var string */ private $endpoint = 'https://givewp.com/downloads/upsells/addons.json'; /** * @var string */ private $transient = 'give-in-plugin-upsells'; /** * @return array */ private function fetchAddons() { $request = wp_remote_get($this->endpoint, [ 'headers' => [ 'Content-Type' => 'application/json', ], ]); if (is_wp_error($request)) { return []; } $body = wp_remote_retrieve_body($request); if (empty($body)) { return []; } $json = json_decode($body, true); // Sanitize JSON array_walk_recursive($json, function (&$item) { $item = wp_kses($item, [ 'strong' => [], ]); }); return $json; } /** * @return array */ public function getAddons() { $cache = get_transient($this->transient); if (false === $cache) { $addons = $this->fetchAddons(); set_transient( $this->transient, serialize($addons), DAY_IN_SECONDS ); return $addons; } return unserialize($cache); } }