commit
2f3110bf4c
3 changed files with 37 additions and 9 deletions
|
@ -16,6 +16,7 @@ class LBRY_Admin
|
||||||
{
|
{
|
||||||
add_action('admin_menu', array($this, 'create_options_page'));
|
add_action('admin_menu', array($this, 'create_options_page'));
|
||||||
add_action('admin_init', array($this, 'page_init'));
|
add_action('admin_init', array($this, 'page_init'));
|
||||||
|
add_action('admin_init', array($this, 'wallet_balance_warning'));
|
||||||
add_action('admin_post_lbry_add_channel', array($this, 'add_channel'));
|
add_action('admin_post_lbry_add_channel', array($this, 'add_channel'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,4 +205,27 @@ class LBRY_Admin
|
||||||
wp_safe_redirect($redirect_url);
|
wp_safe_redirect($redirect_url);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks at most once an hour to see if the wallet balance is too low
|
||||||
|
*/
|
||||||
|
// COMBAK: Check user permissions possibly
|
||||||
|
public static function wallet_balance_warning()
|
||||||
|
{
|
||||||
|
// See if we've checked in the past two hours
|
||||||
|
if (!get_transient('lbry_wallet_check')) {
|
||||||
|
$balance = LBRY()->daemon->wallet_balance();
|
||||||
|
if ($balance < LBRY_MIN_BALANCE) {
|
||||||
|
// If LBRY Balance is low, send email, but only once per day
|
||||||
|
if (!get_transient('lbry_wallet_warning_email')) {
|
||||||
|
$email = get_option('admin_email');
|
||||||
|
$subject = 'Your LBRYPress Wallet Balance is Low!';
|
||||||
|
$message = "You LBRY Wallet for your wordpress installation at " . site_url() . " is running very low.\r\n\r\nYou currently have " . $balance . ' LBC left in your wallet. In order to keep publishing to the LBRY network, please add some LBC to your account.';
|
||||||
|
wp_mail($email, $subject, $message);
|
||||||
|
set_transient('lbry_wallet_warning_email', true, DAY_IN_SECONDS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set_transient('lbry_wallet_check', true, 2 * HOUR_IN_SECONDS);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ class LBRY_Admin_Notice
|
||||||
/**
|
/**
|
||||||
* Sets transients for admin errors
|
* Sets transients for admin errors
|
||||||
*/
|
*/
|
||||||
|
// TODO: Make sure we only set one transient at a time per error
|
||||||
public function set_notice($status = 'error', $message = 'Something went wrong', $is_dismissible = false)
|
public function set_notice($status = 'error', $message = 'Something went wrong', $is_dismissible = false)
|
||||||
{
|
{
|
||||||
$notice = array(
|
$notice = array(
|
||||||
|
|
|
@ -108,6 +108,7 @@ class LBRYPress
|
||||||
'license2' => 'License 2',
|
'license2' => 'License 2',
|
||||||
'license3' => 'License 3'
|
'license3' => 'License 3'
|
||||||
));
|
));
|
||||||
|
$this->define('LBRY_MIN_BALANCE', 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,15 +131,6 @@ class LBRYPress
|
||||||
{
|
{
|
||||||
$this->daemon = new LBRY_Daemon();
|
$this->daemon = new LBRY_Daemon();
|
||||||
$this->speech = new LBRY_Speech();
|
$this->speech = new LBRY_Speech();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up all hooks and actions necessary for the plugin to run
|
|
||||||
*/
|
|
||||||
private function init_hooks()
|
|
||||||
{
|
|
||||||
register_activation_hook(LBRY_PLUGIN_FILE, array($this, 'activate'));
|
|
||||||
register_deactivation_hook(LBRY_PLUGIN_FILE, array($this, 'deactivate'));
|
|
||||||
|
|
||||||
// Admin request
|
// Admin request
|
||||||
if (is_admin()) {
|
if (is_admin()) {
|
||||||
|
@ -150,6 +142,15 @@ class LBRYPress
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up all hooks and actions necessary for the plugin to run
|
||||||
|
*/
|
||||||
|
private function init_hooks()
|
||||||
|
{
|
||||||
|
register_activation_hook(LBRY_PLUGIN_FILE, array($this, 'activate'));
|
||||||
|
register_deactivation_hook(LBRY_PLUGIN_FILE, array($this, 'deactivate'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run during plugin activation
|
* Run during plugin activation
|
||||||
*/
|
*/
|
||||||
|
@ -191,6 +192,8 @@ class LBRYPress
|
||||||
*/
|
*/
|
||||||
public function deactivate()
|
public function deactivate()
|
||||||
{
|
{
|
||||||
|
// Deactivate Wallet Balance cron job
|
||||||
|
$this->admin->wallet_balance_deactivate();
|
||||||
error_log('Deactivated');
|
error_log('Deactivated');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue