/**
  * Shows the  metabox for the error logs
  * @since 1.1
  */
 public function error_logs()
 {
     /**
      * @var wpdb $wpdb
      */
     global $wpdb;
     $total_file_entries = $wpdb->get_var('SELECT COUNT(*) FROM ' . $wpdb->prefix . 'wpbgdc_files');
     $total_synced_files = $wpdb->get_var('SELECT COUNT(*) FROM ' . $wpdb->prefix . 'wpbgdc_files WHERE file_drive_url != "" ');
     $total_unsynced_files = $wpdb->get_var('SELECT COUNT(*) FROM ' . $wpdb->prefix . 'wpbgdc_files WHERE file_drive_url = "" ');
     echo '<h4>' . __('Statistics', $this->_google_drive_cdn->get_textdomain()) . '</h4>';
     echo '<p><code>' . $total_file_entries . '</code> ' . __('Number of total file entries in the cache database.', $this->_google_drive_cdn->get_textdomain()) . '</p>';
     echo '<p><code>' . $total_synced_files . '</code> ' . __('Number of synced files.', $this->_google_drive_cdn->get_textdomain()) . '</p>';
     echo '<p><code>' . $total_unsynced_files . '</code> ' . __('Number of files that have not yet been synced or can\'t be synced.', $this->_google_drive_cdn->get_textdomain()) . '</p>';
     echo '<p><code>' . date_i18n(get_option('date_format') . ' ' . get_option('time_format'), wp_next_scheduled('wpbgdc_hourly_event')) . '</code> ' . __('Date of the next automatic sync/update process.', $this->_google_drive_cdn->get_textdomain()) . '</p>';
     $errors = get_option('wpbgdc_error_log', array());
     if (!is_array($errors)) {
         return;
     }
     if (count($errors)) {
         echo '<h4>' . __('Errors & Hints', $this->_google_drive_cdn->get_textdomain()) . '</h4>';
     }
     krsort($errors);
     foreach ($errors as $error) {
         echo $error . '<br />';
     }
     if (count($errors)) {
         echo ' <a class="button" href="' . admin_url('options-general.php?page=wpbgdc&action=delete_error_logs&wpbgdc_nonce=' . wp_create_nonce('wpbgdc_delete_error_logs')) . '">' . __('Delete Logs', $this->_google_drive_cdn->get_textdomain()) . '</a>';
     }
 }
 /**
  * Adds the "Only upload new files"
  *
  * @since 1.5
  * @return void
  */
 public function field_wpbgdc_upload_new_files_only()
 {
     $options = get_option('wpbgdc');
     if (!isset($options['upload_new_files_only'])) {
         $options['upload_new_files_only'] = 0;
     }
     echo "<input id='wpbgdc_upload_new_files_only' name='wpbgdc[upload_new_files_only]' type='checkbox' value='1' " . checked((bool) $options['upload_new_files_only'], true, false) . " />";
     echo '<p class="description">' . __('If this is checked, the plugin will never sync your media library. It will only upload new files that haven\'t been uploaded yet. Great for very large websites.', $this->_google_drive_cdn->get_textdomain()) . '</p>';
 }
 /**
  * Runs through the css file and searches for image files
  * @since 1.2
  *
  * @param string $file The file path to the CSS file
  * @param string $url  The full live (original) file url of the CSS file
  *
  * @return string
  */
 public function invoke_css_file($file, $url)
 {
     $file_content = file_get_contents($file);
     // if this is a CSS file that is on Google Drive already, do not invoke it again
     if (false !== stripos($url, 'https://googledrive.com')) {
         return $file_content;
     }
     $this->_google_drive_cdn->_is_buffer_css_file = true;
     $this->_google_drive_cdn->_buffer_css_file_path = $file;
     $this->_google_drive_cdn->_buffer_css_file_url = $url;
     $file_content = $this->_google_drive_cdn->buffer($file_content);
     $this->_google_drive_cdn->_is_buffer_css_file = false;
     return $file_content;
 }