1
|
|
|
<?php namespace EmailLog\Addon; |
2
|
|
|
|
3
|
|
|
use EmailLog\Core\Loadie; |
4
|
|
|
|
5
|
|
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Upsells add-ons by displaying links to add-ons with context in different parts of admin interface. |
9
|
|
|
* |
10
|
|
|
* @since 2.4.0 |
11
|
|
|
*/ |
12
|
|
|
class Upseller implements Loadie { |
13
|
|
|
|
14
|
|
|
// phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
15
|
|
|
public function load() { |
16
|
|
|
add_action( 'admin_init', [ 'PAnD', 'init' ] ); |
17
|
|
|
|
18
|
|
|
add_action( 'el_before_logs_list_table', [ $this, 'upsell_auto_delete_logs_in_log_list_page' ] ); |
19
|
|
|
add_action( 'el_after_db_size_notification_setting', [ $this, 'upsell_auto_delete_logs_in_settings_page' ] ); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Renders Upsell message for Auto delete logs add-on in Log list page |
24
|
|
|
* if the number of logs is greater than 5000. |
25
|
|
|
* |
26
|
|
|
* @param int $total_logs Total number of logs. |
27
|
|
|
* |
28
|
|
|
* @since 2.4.0 |
29
|
|
|
*/ |
30
|
|
|
public function upsell_auto_delete_logs_in_log_list_page( $total_logs ) { |
31
|
|
|
if ( $total_logs < 5000 ) { |
32
|
|
|
return; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
if ( $this->is_addon_active( 'Auto Delete Logs' ) ) { |
36
|
|
|
return; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
if ( ! class_exists( 'PAnD' ) || ! \PAnD::is_admin_notice_active( 'disable-DL-upsell-notice-5000' ) ) { |
40
|
|
|
return; |
41
|
|
|
} |
42
|
|
|
?> |
43
|
|
|
|
44
|
|
|
<div data-dismissible="disable-DL-upsell-notice-5000" class="notice notice-warning is-dismissible"> |
45
|
|
|
<p> |
46
|
|
|
<?php |
47
|
|
|
/* translators: 1 Auto Delete Logs add-on name. */ |
48
|
|
|
printf( |
49
|
|
|
__( 'You have more than 5000 email logs in the database. You can use our %1s add-on to automatically delete logs as the DB size grows.', 'email-log' ), |
50
|
|
|
'<a href="https://wpemaillog.com/addons/auto-delete-logs/?utm_campaign=Upsell&utm_medium=wpadmin&utm_source=log-list&utm_content=dl">Auto Delete Logs</a>' |
51
|
|
|
); |
52
|
|
|
?> |
53
|
|
|
</p> |
54
|
|
|
</div> |
55
|
|
|
|
56
|
|
|
<?php |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Renders Upsell message for Auto delete logs add-on in Settings page. |
61
|
|
|
* |
62
|
|
|
* @since 2.4.0 |
63
|
|
|
*/ |
64
|
|
|
public function upsell_auto_delete_logs_in_settings_page() { |
65
|
|
|
if ( $this->is_addon_active( 'Auto Delete Logs' ) ) { |
66
|
|
|
return; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
?> |
70
|
|
|
<p> |
71
|
|
|
<em> |
72
|
|
|
<?php _e( 'You can also automatically delete logs if the database size increases using our <a href="https://wpemaillog.com/addons/auto-delete-logs/?utm_campaign=Upsell&utm_medium=wpadmin&utm_source=settings&utm_content=dl" target="_blank">Auto Delete Logs</a> add-on.', 'email-log' ); ?> |
73
|
|
|
</em> |
74
|
|
|
</p> |
75
|
|
|
<?php |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Is an add-on active? |
80
|
|
|
* |
81
|
|
|
* @param string $addon_name Add-on name. |
82
|
|
|
* |
83
|
|
|
* @return bool True if add-on is present and is installed, false otherwise. |
84
|
|
|
*/ |
85
|
|
|
protected function is_addon_active( $addon_name ) { |
86
|
|
|
$licenser = email_log()->get_licenser(); |
87
|
|
|
|
88
|
|
|
if ( $licenser->is_bundle_license_valid() ) { |
89
|
|
|
return true; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
return $licenser->is_addon_active( $addon_name ); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|