function wiziapp_upgrading_finish()
{
    $GLOBALS['WiziappLog']->write('debug', "The upgrading is finished, letting the admin know", "post_upgrade.wiziapp_upgrading_finish");
    // Send the profile again, and allow it to fail since it's just an update
    $cms = new WiziappCms();
    $cms->activate();
    $status = TRUE;
    $header = array('action' => 'upgrading_finish', 'status' => $status, 'code' => $status ? 200 : 500, 'message' => '');
    echo json_encode(array('header' => $header));
    exit;
}
 public function install()
 {
     // Check for capability
     if (!current_user_can('activate_plugins')) {
         return;
     }
     WiziappDB::getInstance()->install();
     WiziappConfig::getInstance()->install();
     // Register tasks
     if (!wp_next_scheduled('wiziapp_daily_function_hook')) {
         wp_schedule_event(time(), 'daily', 'wiziapp_daily_function_hook');
         wp_schedule_event(time(), 'weekly', 'wiziapp_weekly_function_hook');
         wp_schedule_event(time(), 'monthly', 'wiziapp_monthly_function_hook');
     }
     // Activate the blog with the global services
     $cms = new WiziappCms();
     $cms->activate();
 }
 public function testToken()
 {
     // If we don't have a token, try to get it again
     $activated = !empty(WiziappConfig::getInstance()->app_token);
     if (!$activated) {
         $cms = new WiziappCms();
         $activated = $cms->activate();
     }
     if (!$activated) {
         $errors = new WiziappError();
         if (!$this->testedConnection) {
             $connTest = $this->testConnection();
             if (WiziappError::isError($connTest)) {
                 $errors = $connTest;
             }
         }
         if (!$this->hadConnectionError) {
             // If we already had connections errors, we are showing the problems from those errors
             // Else...
             $this->critical = TRUE;
             $errors->add('missing_token', __('Oops! It seems that the main server is not responding. Please make sure that your internet connection is working, and try again.', 'wiziapp'));
         }
         return $errors;
     }
     return TRUE;
 }
function wiziapp_batch_processing_finish()
{
    $GLOBALS['WiziappLog']->write('debug', "The batch processing is finished, marking as finished", "post_install.wiziapp_batch_processing_finish");
    // Send the profile again, and allow it to fail since it's just an update
    $cms = new WiziappCms();
    $cms->activate();
    // Mark the processing as finished
    WiziappConfig::getInstance()->finished_processing = TRUE;
    $status = TRUE;
    $header = array('action' => 'batch_processing_finish', 'status' => $status, 'code' => $status ? 200 : 500, 'message' => '');
    $GLOBALS['WiziappLog']->write('debug', "The batch processing is finished, marked as finished", "post_install.wiziapp_batch_processing_finish");
    echo json_encode(array('header' => $header));
    exit;
}