|
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
|
|
|
* The name part of the add-on file without .php extension. |
|
19
|
|
|
* |
|
20
|
|
|
* The base class already has a slug property but it is private. |
|
21
|
|
|
* So we have to create a duplicate to handle that. |
|
22
|
|
|
* |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $addon_slug; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Directory and filename of the add-on. |
|
29
|
|
|
* |
|
30
|
|
|
* The base class already has a slug property but it is private. |
|
31
|
|
|
* So we have to create a duplicate to handle that. |
|
32
|
|
|
* |
|
33
|
|
|
* @since 2.2.4 |
|
34
|
|
|
* |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $addon_name; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Extract add-on slug alone and then pass everything to parent. |
|
41
|
|
|
* |
|
42
|
|
|
* @param string $_api_url The URL pointing to the custom API endpoint. |
|
43
|
|
|
* @param string $_plugin_file Path to the plugin file. |
|
44
|
|
|
* @param array|null $_api_data Optional data to send with API calls. |
|
45
|
|
|
*/ |
|
46
|
|
|
public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
47
|
|
|
$this->addon_slug = basename( $_plugin_file, '.php' ); |
|
48
|
|
|
$this->addon_name = plugin_basename( $_plugin_file ); |
|
49
|
|
|
|
|
50
|
|
|
parent::__construct( $_api_url, $_plugin_file, $_api_data ); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Overridden to disable `check_update` on the add-ons that are not installed. |
|
55
|
|
|
* |
|
56
|
|
|
* @inheritdoc |
|
57
|
|
|
* |
|
58
|
|
|
* @since 2.2.0 |
|
59
|
|
|
*/ |
|
60
|
|
|
public function init() { |
|
61
|
|
|
parent::init(); |
|
62
|
|
|
|
|
63
|
|
|
$installed_plugins = array_keys( get_plugins() ); |
|
64
|
|
|
|
|
65
|
|
|
if ( in_array( $this->get_name(), $installed_plugins, true ) ) { |
|
66
|
|
|
return; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Get add-on slug. |
|
74
|
|
|
* |
|
75
|
|
|
* The name part of the add-on file without .php extension. |
|
76
|
|
|
* |
|
77
|
|
|
* @return string Add-on slug. |
|
78
|
|
|
*/ |
|
79
|
|
|
public function get_slug() { |
|
80
|
|
|
return $this->addon_slug; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Get the add-on name. |
|
85
|
|
|
* |
|
86
|
|
|
* Directory and filename of the add-on. |
|
87
|
|
|
* |
|
88
|
|
|
* @since 2.2.4 |
|
89
|
|
|
* |
|
90
|
|
|
* @return string Add-on name. |
|
91
|
|
|
*/ |
|
92
|
|
|
public function get_name() { |
|
93
|
|
|
return $this->addon_name; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Get Download URL. |
|
98
|
|
|
* |
|
99
|
|
|
* We can't call `api_request` method directly since it is declared as private in parent class. |
|
100
|
|
|
* So we call the `plugins_api_filter` method instead. |
|
101
|
|
|
* |
|
102
|
|
|
* @return string Download url. |
|
103
|
|
|
*/ |
|
104
|
|
|
public function get_download_url() { |
|
105
|
|
|
$args = new \stdClass(); |
|
106
|
|
|
$args->slug = $this->get_slug(); |
|
107
|
|
|
|
|
108
|
|
|
$response = $this->plugins_api_filter( null, 'plugin_information', $args ); |
|
109
|
|
|
|
|
110
|
|
|
if ( ! $response instanceof \stdClass || ! property_exists( $response, 'package' ) ) { |
|
111
|
|
|
return ''; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
return $response->package; |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths