コード例 #1
0
/**
 * Initialized global and local variables
 */
global $wpdb;
$totalDaysRemaining = 0;
/**
 * Instantiate classes
 */
$service_bgl360 = new ServiceBgl360($wpdb, $current_user->ID);
$authentication_bgl360 = new AuthenticationBgl360();
$resource_request_bgl360 = new ResourceRequestBgl360();
$time = new Time();
/**
 * Get all access token saved to database
 */
$accessData = $service_bgl360->getAccessTokens();
foreach ($accessData as $accessToken) {
    echo "id = " . $accessToken['id'] . "<br>";
    echo " current date " . $time->getCurrentDate() . '<br>';
    echo " expired at date " . $time->toDate($accessToken['expired_at']) . '<br>';
    echo " Total remaining days " . $time->getTotalRemainingDays($time->getCurrentDate(), $time->toDate($accessToken['expired_at'])) . '<br>';
    /**
     * Get total days remaining
     */
    if ($time->getTotalRemainingDays($time->getCurrentDate(), $time->toDate($accessToken['expired_at'])) == 0) {
        /**
         * Update access token because total days passed days is 6
         */
        echo "<hr>";
        $accessToken = new AccessToken($wpdb, $accessToken['user_id']);
        $accessToken->refreshAndUpdateAccessToken();