/**
  * @author Vova Feldman (@svovaf)
  * @since  1.1.7
  *
  * @param object              $api
  * @param FS_Plugin_Plan|null $plan
  *
  * @return string
  */
 private function get_plugin_cta($api, $plan = null)
 {
     if (current_user_can('install_plugins') || current_user_can('update_plugins')) {
         if (!empty($api->checkout_link) && isset($api->plans) && 0 < is_array($api->plans)) {
             if (is_null($plan)) {
                 $plan = $api->plans[0];
             }
             return ' <a class="button button-primary right" href="' . $this->_fs->addon_checkout_url($plan->plugin_id, $plan->pricing[0]->id, $this->get_billing_cycle($plan), $plan->has_trial()) . '" target="_parent">' . (!$plan->has_trial() ? __fs('purchase', $api->slug) : sprintf(__fs('start-free-x', $api->slug), $this->get_trial_period($plan))) . '</a>';
             // @todo Add Cart concept.
             //			echo ' <a class="button right" href="' . $status['url'] . '" target="_parent">' . __( 'Add to Cart' ) . '</a>';
         } else {
             if (!empty($api->download_link)) {
                 $status = install_plugin_install_status($api);
                 // Hosted on WordPress.org.
                 switch ($status['status']) {
                     case 'install':
                         if ($api->external && $this->_fs->is_org_repo_compliant() || !$this->_fs->is_premium()) {
                             /**
                              * Add-on hosted on Freemius, not yet installed, and core
                              * plugin is wordpress.org compliant. Therefore, require a download
                              * since installing external plugins is not allowed by the wp.org guidelines.
                              */
                             return ' <a class="button button-primary right" href="' . esc_url($api->download_link) . '" target="_blank">' . __fs('download-latest', $api->slug) . '</a>';
                         } else {
                             if ($status['url']) {
                                 return '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __('Install Now') . '</a>';
                             }
                         }
                         break;
                     case 'update_available':
                         if ($status['url']) {
                             return '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __('Install Update Now') . '</a>';
                         }
                         break;
                     case 'newer_installed':
                         return '<a class="button button-primary right disabled">' . sprintf(__('Newer Version (%s) Installed'), $status['version']) . '</a>';
                         break;
                     case 'latest_installed':
                         return '<a class="button button-primary right disabled">' . __('Latest Version Installed') . '</a>';
                         break;
                 }
             }
         }
     }
     return '';
 }