Beispiel #1
0
 /**
  * @param string $content
  * @param License $license
  *
  * @return string
  */
 private function replace_expiration_vars($content, $license)
 {
     // get user
     $user = get_user_by('id', $license->get_user_id());
     // get first name
     $fname = 'there';
     if (!empty($user) && !empty($user->first_name)) {
         $fname = $user->first_name;
     }
     // get WooCommerce product object
     $wc_product = new \WC_Product($license->get_product_id());
     // get parent product if the product has one
     if (0 != $wc_product->get_parent()) {
         $wc_product = new \WC_Product($wc_product->get_parent());
     }
     $content = str_ireplace(':fname:', $fname, $content);
     $content = str_ireplace(':product:', $wc_product->get_title(), $content);
     $content = str_ireplace(':license-key:', $license->get_key(), $content);
     $content = str_ireplace(':license-expiration-date:', $license->get_date_expires() ? $license->get_date_expires()->format('M d Y') : '', $content);
     $content = str_ireplace(':renewal-link:', $license->get_renewal_url(), $content);
     return $content;
 }