PluginProbe
Email Log / 2.1.0
Email Log v2.1.0
2.63 2.4.8 2.4.9 2.6 2.61 2.62 trunk 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.8.1 0.9 0.9.1 0.9.2 1.1 1.5 1.5.1 1.5.2 1.5.3 1.5.4 All 61 releases
email-log / include / Addon / API / EDDUpdater.php

EDDUpdater.php in Email Log 2.1.0, at include/Addon/API/EDDUpdater.php

68 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace EmailLog\Addon\API;
2
3 defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
4
5 if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
6 $email_log = email_log();
7 require_once $email_log->get_plugin_path() . 'include/libraries/EDD_SL_Plugin_Updater.php';
8 }
9
10 /**
11 * Update add-on using EDD API.
12 *
13 * @since 2.0.0
14 */
15 class EDDUpdater extends \EDD_SL_Plugin_Updater {
16
17 /**
18 * Add-on slug.
19 * The base class already has a slug property but it is private.
20 * So we have to create a duplicate to handle that.
21 *
22 * @var string
23 */
24 protected $addon_slug;
25
26 /**
27 * Extract add-on slug alone and then pass everything to parent.
28 *
29 * @param string $_api_url The URL pointing to the custom API endpoint.
30 * @param string $_plugin_file Path to the plugin file.
31 * @param array|null $_api_data Optional data to send with API calls.
32 */
33 public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
34 $this->addon_slug = basename( $_plugin_file, '.php' );
35
36 parent::__construct( $_api_url, $_plugin_file, $_api_data );
37 }
38
39 /**
40 * Get add-on slug.
41 *
42 * @return string Add-on slug.
43 */
44 public function get_slug() {
45 return $this->addon_slug;
46 }
47
48 /**
49 * Get Download URL.
50 * We can't call `api_request` method directly since it is declared as private in parent class.
51 * So we call the `plugins_api_filter` method instead.
52 *
53 * @return string Download url.
54 */
55 public function get_download_url() {
56 $args = new \stdClass();
57 $args->slug = $this->addon_slug;
58
59 $response = $this->plugins_api_filter( null, 'plugin_information', $args );
60
61 if ( ! $response instanceof \stdClass || ! property_exists( $response, 'package' ) ) {
62 return '';
63 }
64
65 return $response->package;
66 }
67 }
68