/**
  * creates the content for the howto-metabox
  *
  * @access public
  *
  * @return void
  * @since  1.0
  */
 public function connect()
 {
     $helper = new WPB_Google_Drive_Cdn_Service_Helper($this->_google_drive_cdn);
     $is_api_working = $helper->is_api_working();
     $client = $this->_google_drive_cdn->get_google_client();
     $client->setState('got_code');
     // get offline access
     $client->setAccessType('offline');
     // makes the UI window appear ALWAYS
     $client->setApprovalPrompt('force');
     echo '<p>' . __('Please note: you will be redirected to a Google\'s authorization page. Please press the blue button to give this application the right to upload files.', $this->_google_drive_cdn->get_textdomain()) . '</p>';
     echo '<a class="button-primary" href="' . $client->createAuthUrl() . '">' . __('Grant writing permissions to your Google Drive', $this->_google_drive_cdn->get_textdomain()) . '</a>';
     if (!$is_api_working) {
         echo '<div class="error"><p>', __('The Google Drive API is currently not working.', $this->_google_drive_cdn->get_textdomain()), ' ' . __('Try to (re-)authenticate by using the button "Grant writing permissions to your Google Drive" button.', $this->_google_drive_cdn->get_textdomain()), '</p></div>';
     }
 }
 /**
  * Searches for the upload folder on the Google Drive.
  * If there is no such folder it will be created
  * @since 1.0
  */
 public function search_folder()
 {
     if (!isset($_REQUEST['action'])) {
         return;
     }
     if ('search_folder' != $_REQUEST['action']) {
         return;
     }
     $helper = new WPB_Google_Drive_Cdn_Service_Helper($this);
     // search for the folder. if the folder does not exist, create it
     $helper->search_folder();
     if ($helper->is_api_working()) {
         // empty error log
         update_option('wpbgdc_error_log', array());
     }
     wp_redirect(admin_url('options-general.php?page=wpbgdc'));
 }
Exemplo n.º 3
0
 /**
  * Starts the output buffering
  * @since 1.0
  */
 public function ob_start()
 {
     $helper = new WPB_Google_Drive_Cdn_Service_Helper($this);
     // do not start buffering if the api isn't working
     if (!$helper->is_api_working()) {
         return;
     }
     ob_start(array($this, 'buffer'));
 }