refresh_connection(); } } /** * This function will add a dashboard notice to every page, that shows the user when their clone will expire and directs them to UpdraftPlus.com to extend their clones life. * * @return void */ public function all_admin_notices_dashboard_notice() { $date = strtotime(get_site_option('updraftplus_clone_scheduled_removal', '')); if ('' == $date) { $pretty_date = __('Unable to get renew date', 'updraftplus'); } else { $pretty_date = get_date_from_gmt(gmdate('Y-m-d H:i:s', (int) $date), 'M d, Y G:i'); } ?>
process_dash_notice_ajax(); } else { return; } } /** * This function will handle the ajax calls for the UpdraftPlus clone notice mu-plugin. * * @return void */ public function process_dash_notice_ajax() { $return = array('code' => 'fail', 'data' => ''); if (!isset($_POST['subaction'])) { $return['code'] = 'error'; $return['data'] = 'Missing subaction'; echo json_encode($return); die(); } if ('refresh_connection' === $_POST['subaction']) { check_ajax_referer('updraftplus_refresh_connection', 'nonce'); $result = $this->refresh_connection(); if ($result) { $return['code'] = 'success'; $return['data'] = $result; } else { $return['code'] = 'error'; $return['data'] = $result; } echo json_encode($return); die(); } else { $return['code'] = 'error'; $return['data'] = 'Unknown action'; echo json_encode($return); die(); } } /** * This function will refresh the stored clones expire date by calling UpdraftPlus.com and getting the latest value. * Note this function needs three defines to work UPDRAFTPLUS_USER_ID and UPDRAFTPLUS_VPS_ID and UPDRAFTPLUS_UNIQUE_TOKEN. * * @return array - that contains the updated expire data or error information */ public function refresh_connection() { global $updraftplus; if (!defined('UPDRAFTPLUS_USER_ID') || !is_numeric(UPDRAFTPLUS_USER_ID) || !defined('UPDRAFTPLUS_VPS_ID') || !is_numeric(UPDRAFTPLUS_VPS_ID)) { return array('code' => 'error', 'data' => 'No user or VPS ID found'); } if (!defined('UPDRAFTPLUS_UNIQUE_TOKEN')) return array('code' => 'error', 'data' => 'No unique token found'); $user_id = UPDRAFTPLUS_USER_ID; $vps_id = UPDRAFTPLUS_VPS_ID; $token = UPDRAFTPLUS_UNIQUE_TOKEN; $data = array('user_id' => $user_id, 'vps_id' => $vps_id, 'token' => $token); $result = $updraftplus->get_updraftplus_clone()->clone_status($data); $vps_info = $result['data']; if (empty($vps_info['scheduled_removal'])) return array('code' => 'error', 'data' => 'No scheduled removal date found'); update_site_option('updraftplus_clone_scheduled_removal', $vps_info['scheduled_removal']); return array('code' => 'success', 'data' => $vps_info['scheduled_removal']); } } if (defined('UPDRAFTPLUS_THIS_IS_CLONE')) { $updraftplus_temporary_clone_dash_notice = new UpdraftPlus_Temporary_Clone_Dash_Notice(); }