/**
  * Replace comm_vars with corresponding values.
  *
  * @since  1.0.0
  *
  * @param MS_Model_Relationship $subscription The membership relationship to send message to.
  * @param WP_User $wp_user The wordpress user object to get info from.
  * @return array {
  *     Returns array of ( $var_name => $var_replace ).
  *
  *     @type string $var_name The variable name to replace.
  *     @type string $var_replace The variable corresponding replace string.
  * }
  */
 public function get_comm_vars($subscription, $wp_user)
 {
     $currency = MS_Plugin::instance()->settings->currency . ' ';
     $membership = $subscription->get_membership();
     $invoice = null;
     // First try to fetch the current invoice.
     $invoice = $subscription->get_current_invoice(false);
     $prev_invoice = $subscription->get_previous_invoice();
     // If no current invoice exists then fetch the previous invoice.
     if (empty($invoice)) {
         $invoice = $prev_invoice;
     }
     $comm_vars = apply_filters('ms_model_communication_comm_vars', $this->comm_vars);
     foreach ($comm_vars as $key => $description) {
         switch ($key) {
             case self::COMM_VAR_BLOG_NAME:
                 $comm_vars[$key] = get_option('blogname');
                 break;
             case self::COMM_VAR_BLOG_URL:
                 $comm_vars[$key] = get_option('home');
                 break;
             case self::COMM_VAR_USERNAME:
                 $comm_vars[$key] = $wp_user->user_login;
                 break;
             case self::COMM_VAR_USER_DISPLAY_NAME:
                 $comm_vars[$key] = $wp_user->display_name;
                 break;
             case self::COMM_VAR_USER_FIRST_NAME:
                 $comm_vars[$key] = $wp_user->user_firstname;
                 break;
             case self::COMM_VAR_USER_LAST_NAME:
                 $comm_vars[$key] = $wp_user->user_lastname;
                 break;
             case self::COMM_VAR_NET_NAME:
                 $comm_vars[$key] = get_site_option('site_name');
                 break;
             case self::COMM_VAR_NET_URL:
                 $comm_vars[$key] = get_site_option('siteurl');
                 break;
             case self::COMM_VAR_MS_NAME:
                 if ($membership->name) {
                     $comm_vars[$key] = $membership->name;
                 } else {
                     $comm_vars[$key] = '';
                 }
                 break;
             case self::COMM_VAR_MS_INVOICE:
                 if (isset($invoice) && ($invoice->total > 0 || $invoice->uses_trial)) {
                     $attr = array('post_id' => $invoice->id, 'pay_button' => 0);
                     $scode = MS_Factory::load('MS_Controller_Shortcode');
                     $comm_vars[$key] = $scode->membership_invoice($attr);
                 } else {
                     $comm_vars[$key] = '';
                 }
                 break;
             case self::COMM_VAR_MS_ACCOUNT_PAGE_URL:
                 $comm_vars[$key] = sprintf('<a href="%s">%s</a>', MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_ACCOUNT), __('account page', MS_TEXT_DOMAIN));
                 break;
             case self::COMM_VAR_MS_REMAINING_DAYS:
                 $days = $subscription->get_remaining_period();
                 $comm_vars[$key] = sprintf(__('%s day%s', MS_TEXT_DOMAIN), $days, abs($days) > 1 ? 's' : '');
                 break;
             case self::COMM_VAR_MS_REMAINING_TRIAL_DAYS:
                 $days = $subscription->get_remaining_trial_period();
                 $comm_vars[$key] = sprintf(__('%s day%s', MS_TEXT_DOMAIN), $days, abs($days) > 1 ? 's' : '');
                 break;
             case self::COMM_VAR_MS_EXPIRY_DATE:
                 $comm_vars[$key] = $subscription->expire_date;
                 break;
         }
         $comm_vars[$key] = apply_filters('ms_model_communication_send_message_comm_var_' . $key, $comm_vars[$key], $subscription);
     }
     return apply_filters('ms_model_communication_get_comm_vars', $comm_vars);
 }