コード例 #1
0
ファイル: log.php プロジェクト: pelmered/woocommerce
 /**
  * Test clear().
  *
  * @since 2.4
  */
 public function test_clear()
 {
     $log = wc_get_logger();
     $log->add('unit-tests', 'this is a message');
     $log->clear('unit-tests');
     $this->assertEquals('', $this->read_content('unit-tests'));
 }
コード例 #2
0
 /**
  * Logging method.
  * @param string $message
  */
 public static function log($message)
 {
     if (self::$log_enabled) {
         if (empty(self::$log)) {
             self::$log = wc_get_logger();
         }
         self::$log->add('paypal', $message);
     }
 }
コード例 #3
0
 /**
  * Push all needed DB updates to the queue for processing.
  */
 private static function update()
 {
     $current_db_version = get_option('woocommerce_db_version');
     $logger = wc_get_logger();
     $update_queued = false;
     foreach (self::$db_updates as $version => $update_callbacks) {
         if (version_compare($current_db_version, $version, '<')) {
             foreach ($update_callbacks as $update_callback) {
                 $logger->add('wc_db_updates', sprintf('Queuing %s - %s', $version, $update_callback));
                 self::$background_updater->push_to_queue($update_callback);
                 $update_queued = true;
             }
         }
     }
     if ($update_queued) {
         self::$background_updater->save()->dispatch();
     }
 }
コード例 #4
0
 /**
  * Apply inline styles to dynamic content.
  *
  * @param string|null $content
  * @return string
  */
 public function style_inline($content)
 {
     // make sure we only inline CSS for html emails
     if (in_array($this->get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) {
         ob_start();
         wc_get_template('emails/email-styles.php');
         $css = apply_filters('woocommerce_email_styles', ob_get_clean());
         // apply CSS styles inline for picky email clients
         try {
             $emogrifier = new Emogrifier($content, $css);
             $content = $emogrifier->emogrify();
         } catch (Exception $e) {
             $logger = wc_get_logger();
             $logger->add('emogrifier', $e->getMessage());
         }
     }
     return $content;
 }
コード例 #5
0
 /**
  * Remove/delete the chosen file.
  */
 public static function remove_log()
 {
     if (empty($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], 'remove_log')) {
         wp_die(__('Action failed. Please refresh the page and retry.', 'woocommerce'));
     }
     if (!empty($_REQUEST['handle'])) {
         $logger = wc_get_logger();
         $logger->remove($_REQUEST['handle']);
     }
     wp_safe_redirect(esc_url_raw(admin_url('admin.php?page=wc-status&tab=logs')));
     exit;
 }
コード例 #6
0
 /**
  * Logging method.
  *
  * @param string $message
  */
 public static function log($message)
 {
     if (empty(self::$log)) {
         self::$log = wc_get_logger();
     }
     self::$log->add('geoip', $message);
 }
コード例 #7
0
 /**
  * Complete
  *
  * Override if applicable, but ensure that the below actions are
  * performed, or, call parent::complete().
  */
 protected function complete()
 {
     $logger = wc_get_logger();
     $logger->add('wc_db_updates', 'Data update complete');
     WC_Install::update_db_version();
     parent::complete();
 }
コード例 #8
0
 /**
  * Update geoip database. Adapted from https://wordpress.org/plugins/geoip-detect/.
  */
 public static function update_database()
 {
     $logger = wc_get_logger();
     if (!is_callable('gzopen')) {
         $logger->add('geolocation', 'Server does not support gzopen');
         return;
     }
     require_once ABSPATH . 'wp-admin/includes/file.php';
     $tmp_databases = array('v4' => download_url(self::GEOLITE_DB), 'v6' => download_url(self::GEOLITE_IPV6_DB));
     foreach ($tmp_databases as $tmp_database_version => $tmp_database_path) {
         if (!is_wp_error($tmp_database_path)) {
             $gzhandle = @gzopen($tmp_database_path, 'r');
             $handle = @fopen(self::get_local_database_path($tmp_database_version), 'w');
             if ($gzhandle && $handle) {
                 while ($string = gzread($gzhandle, 4096)) {
                     fwrite($handle, $string, strlen($string));
                 }
                 gzclose($gzhandle);
                 fclose($handle);
             } else {
                 $logger->add('geolocation', 'Unable to open database file');
             }
             @unlink($tmp_database_path);
         } else {
             $logger->add('geolocation', 'Unable to download GeoIP Database: ' . $tmp_database_path->get_error_message());
         }
     }
 }