Example #1
0
 /**
  * Logs the original exception message.
  *
  * Provided as a manual override over the default `WP_DEBUG` dependent behaviour.
  *
  * @see Tribe__Exception::handle()
  *
  * @return bool  `true` if the message was logged, `false` otherwise.
  */
 private function log_original_exception_message()
 {
     if (!class_exists('Tribe__Log')) {
         return false;
     }
     $logger = new Tribe__Log();
     $message = $this->original_exception->getMessage();
     $log_type = $this->get_log_type_for_exception_code($this->original_exception->getCode());
     $src = $this->original_exception->getFile() . ':' . $this->original_exception->getLine();
     $logger->log($message, $log_type, $src);
     return true;
 }
 /**
  * Assign linked posts managed by The Events Calendar a language.
  *
  * We use the filter as an action to assign linked posts a language.
  * WPML will not "see" posts that have not a language assigned: here we make sure that linked posts like
  * venues and organizers will be assigned the language of the event they are being linked to.
  *
  * @param int    $id               The linked post ID; this would be `null` by default but we know TEC is inserting
  *                                 the post at priority 10.
  * @param array  $data             Unused, an array of data representing the linked post submission.
  * @param string $linked_post_type The linked post type, e.g. `tribe_venue` or `tribe_organizer`.
  * @param string $post_status      Unused, the linked post type post status.
  * @param int    $event_id         The post ID of the event this post is linked to; this will be null for newly created events.
  *
  * @return int The untouched linked post ID.
  */
 public function filter_tribe_events_linked_post_create($id, $data, $linked_post_type, $post_status, $event_id)
 {
     if (empty($id) || empty($event_id)) {
         return $id;
     }
     $event_language_info = wpml_get_language_information($event_id);
     $language_code = !empty($event_language_info['language_code']) ? $event_language_info['language_code'] : ICL_LANGUAGE_CODE;
     $added = wpml_add_translatable_content('post_' . $linked_post_type, $id, $language_code);
     if (WPML_API_ERROR === $added) {
         $log = new Tribe__Log();
         $entry = "Could not set language for linked post type '{$linked_post_type}' with id '{$id}' to '{$language_code}'";
         $log->log_error($entry, __CLASS__);
     }
     return $id;
 }