/**
  * Initiate sync process.
  *
  * @access public
  * @return void
  */
 public function sync()
 {
     global $DC_Woodle;
     $user_id = get_current_user_id();
     if ($user_id <= 0) {
         return;
     }
     if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
         return;
     }
     if (empty($_POST['dc_dc_woodle_sync_settings_name']['action']) || 'sync_courses_and_categories' !== $_POST['dc_dc_woodle_sync_settings_name']['action']) {
         return;
     }
     if (empty($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'dc-sync_courses_and_categories')) {
         return;
     }
     if (empty($_POST['dc_dc_woodle_sync_settings_name']['sync_now']) || $_POST['dc_dc_woodle_sync_settings_name']['sync_now'] == 'no') {
         return;
     }
     if (empty(woodle_get_settings('access_url', 'dc_woodle_general'))) {
         woodle_add_notice('<strong>Synchronization can not be done.</strong> Moodle access url is not set. <a href="' . admin_url('admin.php?page=dc-woodle-setting-admin') . '"> Set it now &nbsp;&raquo;</a>');
         return;
     }
     if (empty(woodle_get_settings('ws_token', 'dc_woodle_general'))) {
         woodle_add_notice('<strong>Synchronization can not be done.</strong> Moodle web service token is not set.<a href="' . admin_url('admin.php?page=dc-woodle-setting-admin') . '"> Set it now &nbsp;&raquo;</a>');
         return;
     }
     $this->sync_categories();
     $this->sync_courses();
     if (!$this->has_error) {
         woodle_add_notice('<strong>Synchronization is complete.</strong>', 'updated');
     } else {
         woodle_add_notice('<strong>Error ! Synchronization cannot be done.</strong>', 'error');
     }
 }
 function woodle_wc_inactive_notice()
 {
     global $DC_Woodle;
     woodle_add_notice(__('<strong>Woocommerce is inactive.</strong> The <a target="_blank" href="https://wordpress.org/plugins/woocommerce/">Woocommerce plugin</a> must be active for the Woo Moodle Course Purchaser to work. Please <a href="' . admin_url('plugins.php') . '">install & activate Woocommerce &nbsp;&raquo;</a>', $DC_Woodle->text_domain));
 }