/**
     * Returns the contens of the dialog
     *
     * @since  1.0.0
     *
     * @return object
     */
    public function get_contents($data)
    {
        $subscription = $data['model'];
        $gateways = MS_Model_Gateway::get_gateway_names(false, true);
        if (isset($gateways[$subscription->gateway_id])) {
            $gateway = $gateways[$subscription->gateway_id];
        } elseif (empty($subscription->gateway_id)) {
            $gateway = __('- No Gateway -', 'membership2');
        } else {
            $gateway = '(' . $subscription->gateway_id . ')';
        }
        $events = MS_Model_Event::get_events(array('topic' => 'membership', 'nopaging' => true, 'relationship_id' => $subscription->id));
        $sub_details = array('title' => __('Subscription Details', 'membership2'), 'type' => MS_Helper_Html::TYPE_HTML_TABLE, 'value' => array(array('Subscription ID', $subscription->id), array('Membership', $subscription->get_membership()->name), array('Payment Gateway', $gateway), array('Payment Type', $subscription->get_payment_description(null, true)), array('Subscription Start', $subscription->start_date), array('Subscription End', $subscription->expire_date), array('Status', $subscription->status)), 'field_options' => array('head_col' => true));
        $evt_details = array();
        foreach ($events as $event) {
            $evt_details[] = array('title' => __('Event Details', 'membership2'), 'type' => MS_Helper_Html::TYPE_HTML_TABLE, 'value' => array(array('Event ID', $event->id), array('Date', $event->date), array('Description', $event->description)), 'field_options' => array('head_col' => true));
        }
        ob_start();
        ?>
		<div>
			<?php 
        MS_Helper_Html::html_element($sub_details);
        MS_Helper_Html::html_separator();
        foreach ($evt_details as $detail) {
            MS_Helper_Html::html_element($detail);
        }
        ?>
		</div>
		<?php 
        $html = ob_get_clean();
        return apply_filters('ms_view_member_subscription_to_html', $html);
    }
    public function to_html()
    {
        $settings = $this->data['settings'];
        $fields = array('plugin_enabled' => array('id' => 'plugin_enabled', 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'title' => __('Content Protection', 'membership2'), 'desc' => __('This setting toggles the content protection on this site.', 'membership2'), 'value' => MS_Plugin::is_enabled(), 'data_ms' => array('action' => MS_Controller_Settings::AJAX_ACTION_TOGGLE_SETTINGS, 'setting' => 'plugin_enabled')), 'hide_admin_bar' => array('id' => 'hide_admin_bar', 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'title' => __('Hide admin toolbar', 'membership2'), 'desc' => __('Hide the admin toolbar for non administrator users.', 'membership2'), 'value' => $settings->hide_admin_bar, 'data_ms' => array('action' => MS_Controller_Settings::AJAX_ACTION_TOGGLE_SETTINGS, 'setting' => 'hide_admin_bar')));
        $fields = apply_filters('ms_view_settings_prepare_general_fields', $fields);
        $setup = MS_Factory::create('MS_View_Settings_Page_Setup');
        $action_url = esc_url_raw(remove_query_arg(array('msg')));
        ob_start();
        MS_Helper_Html::settings_tab_header();
        ?>

		<form action="<?php 
        echo esc_url($action_url);
        ?>
" method="post" class="cf">
			<div class="cf">
				<div class="ms-half">
					<?php 
        MS_Helper_Html::html_element($fields['plugin_enabled']);
        ?>
				</div>
				<div class="ms-half">
					<?php 
        MS_Helper_Html::html_element($fields['hide_admin_bar']);
        ?>
				</div>
			</div>
			<?php 
        MS_Helper_Html::html_separator();
        MS_Helper_Html::html_element($setup->html_full_form());
        ?>
		</form>
		<?php 
        return ob_get_clean();
    }
    /**
     * Returns the HTML code of the Settings form.
     *
     * @since  1.0.0
     * @return string
     */
    public function render_tab()
    {
        $groups = $this->prepare_fields();
        ob_start();
        ?>
		<div class="ms-addon-wrap">
			<?php 
        MS_Helper_Html::settings_tab_header(array('title' => __('Custom Membership Attributes', MS_TEXT_DOMAIN), 'desc' => __('Define custom fields that are available in the Memberships Edit-Page.', MS_TEXT_DOMAIN)));
        foreach ($groups as $key => $fields) {
            echo '<div class="ms-group ms-group-' . esc_attr($key) . '">';
            foreach ($fields as $field) {
                MS_Helper_Html::html_element($field);
            }
            echo '</div>';
        }
        MS_Helper_Html::html_separator();
        $help_link = MS_Controller_Plugin::get_admin_url('help', array('tab' => 'shortcodes'));
        printf('<p>%s</p><ul><li>%s</li><li>%s</li><li>%s</li><li>%s</li></ul>', __('How to use custom attribute values:', MS_TEXT_DOMAIN), sprintf(__('Via the %sshortcode%s %s', MS_TEXT_DOMAIN), '<a href="' . $help_link . '#ms-membership-buy">', '</a>', '<code>[<b>' . MS_Addon_Attributes::SHORTCODE . '</b> slug="slug" id="..."]</code>'), sprintf(__('Via WordPress filter %s', MS_TEXT_DOMAIN), '<code>$val = apply_filters( "<b>ms_membership_attr</b>", "", "slug", $membership_id );</code>'), sprintf(__('Get via php function %s', MS_TEXT_DOMAIN), '<code>$val = <b>ms_membership_attr</b>( "slug", $membership_id );</code>'), sprintf(__('Set via php function %s', MS_TEXT_DOMAIN), '<code><b>ms_membership_attr_set</b>( "slug", $val, $membership_id );</code>'));
        ?>
		</div>
		<?php 
        $html = ob_get_clean();
        echo $html;
    }
    /**
     * Return the HTML form.
     *
     * @since  1.0.0
     * @return string
     */
    public function to_html()
    {
        $comm = $this->data['comm'];
        $fields = $this->get_fields();
        $this->add_action('admin_footer', 'wp_footer');
        $title = __('Automated Email Responses', MS_TEXT_DOMAIN);
        if (isset($this->data['membership'])) {
            $membership = $this->data['membership'];
        } else {
            $membership = false;
        }
        if ($membership instanceof MS_Model_Membership) {
            $settings_url = MS_Controller_Plugin::get_admin_url('settings', array('tab' => MS_Controller_Settings::TAB_EMAILS));
            $desc = sprintf(__('Here you can override %sdefault messages%s for this membership.', MS_TEXT_DOMAIN), '<a href="' . $settings_url . '">', '</a>');
        } else {
            $desc = '';
        }
        ob_start();
        MS_Helper_Html::settings_tab_header(array('title' => $title, 'desc' => $desc));
        ?>

		<form id="ms-comm-type-form" action="" method="post">
			<?php 
        MS_Helper_Html::html_element($fields['load_action']);
        MS_Helper_Html::html_element($fields['load_nonce']);
        MS_Helper_Html::html_element($fields['comm_type']);
        MS_Helper_Html::html_element($fields['switch_comm_type']);
        ?>
		</form>

		<?php 
        MS_Helper_Html::html_separator();
        if (!empty($fields['override'])) {
            MS_Helper_Html::html_element($fields['override']);
        }
        ?>

		<form action="" method="post" class="ms-editor-form">
			<?php 
        if (!empty($fields['membership_id'])) {
            MS_Helper_Html::html_separator();
            MS_Helper_Html::html_element($fields['membership_id']);
        }
        MS_Helper_Html::html_element($fields['action']);
        MS_Helper_Html::html_element($fields['nonce']);
        MS_Helper_Html::html_element($fields['type']);
        if (is_a($comm, 'MS_Model_Communication')) {
            printf('<h3>%1$s %2$s: %3$s</h3><div class="ms-description" style="margin-bottom:20px;">%4$s</div>', $comm->get_title(), __('Message', MS_TEXT_DOMAIN), MS_Helper_Html::html_element($fields['enabled'], true), $comm->get_description());
            if ($comm->period_enabled) {
                echo '<div class="ms-period-wrapper clear">';
                $fields['period_unit'] = $comm->set_period_name($fields['period_unit']);
                MS_Helper_Html::html_element($fields['period_unit']);
                MS_Helper_Html::html_element($fields['period_type']);
                echo '</div>';
            }
        }
        MS_Helper_Html::html_element($fields['subject']);
        MS_Helper_Html::html_element($fields['email_body']);
        MS_Helper_Html::html_element($fields['cc_enabled']);
        echo ' &nbsp; ';
        MS_Helper_Html::html_element($fields['cc_email']);
        MS_Helper_Html::html_separator();
        MS_Helper_Html::html_element($fields['save_email']);
        ?>
		</form>
		<?php 
        return ob_get_clean();
    }
    /**
     * Echo a content list as tag-list.
     *
     * @since  1.0.0
     *
     * @param  array $contents List of content items to display.
     */
    protected function content_box($rule)
    {
        static $row_items = 0;
        $rule_titles = MS_Model_Rule::get_rule_type_titles();
        $title = $rule_titles[$rule->rule_type];
        $contents = (array) $rule->get_contents(null, true);
        $membership_id = $this->data['membership']->id;
        $row_items += 1;
        $new_row = $row_items % 4 === 0;
        $show_sep = ($row_items - 1) % 4 === 0;
        if ($show_sep && $row_items > 1) {
            MS_Helper_Html::html_separator();
        }
        ?>
		<div class="ms-part-4 ms-min-height">
			<?php 
        if (!$new_row) {
            MS_Helper_Html::html_separator('vertical');
        }
        ?>
			<div class="ms-bold">
				<?php 
        printf('%s (%s):', $title, $rule->count_rules());
        ?>
			</div>

			<div class="inside">
				<ul class="ms-content-tag-list ms-group">
				<?php 
        foreach ($contents as $content) {
            if ($content->access) {
                MS_Helper_Html::content_tag($content);
            }
        }
        ?>
				</ul>

				<div class="ms-protection-edit-wrapper">
					<?php 
        $edit_url = MS_Controller_Plugin::get_admin_url('protection', array('tab' => $rule->rule_type, 'membership_id' => $membership_id));
        MS_Helper_Html::html_element(array('id' => 'edit_' . $rule->rule_type, 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'title' => $title, 'value' => sprintf(__('Edit %s Access', 'membership2'), $title), 'url' => $edit_url, 'class' => 'wpmui-field-button button'));
        ?>
				</div>
			</div>
		</div>
		<?php 
        if ($new_row) {
            echo '</div><div class="ms-group">';
        }
    }
Esempio n. 6
0
    /**
     * Display additional fields in the Membership payment options screen.
     *
     * This function is called on the admin screen where Membership payment
     * settings are configured.
     * We can directly output HTML code that is appended to the default form.
     *
     * Note that the payment form has no submit button! All settings must be
     * saved directly via Ajax directly when they are changed.
     *
     * @since  1.0.0
     * @param  MS_View $view The view object that called this function.
     * @param  MS_Model_Membership $membership The membership that is modified.
     */
    public function form($view, $membership)
    {
        $membership_currency = $this->api->settings->currency;
        $affiliate_currency = aff_get_option('affiliate-currency-paypal-masspay', 'USD');
        if ($membership->is_free) {
            $label = __('Reward on subscription', 'affiliate');
        } else {
            $label = __('Reward on first payment', 'affiliate');
        }
        $fields = array();
        $fields['value'] = array('type' => MS_Helper_Html::INPUT_TYPE_NUMBER, 'id' => 'aff_reward_value', 'before' => $label, 'value' => $this->get_value($membership), 'class' => 'ms-text-smallish', 'config' => array('step' => '0.01', 'min' => '0'), 'ajax_data' => array('action' => self::AJAX_ACTION, 'membership_id' => $membership->id));
        $fields['type'] = array('type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'id' => 'aff_reward_type', 'value' => $this->get_type($membership), 'field_options' => array('inv' => __('Percent (payment)', 'affiliate') . '*', 'mem' => __('Percent (price)', 'affiliate') . '**', 'abs' => $affiliate_currency), 'ajax_data' => array('action' => self::AJAX_ACTION, 'membership_id' => $membership->id));
        ?>
		<div class="aff-payment-options">
			<?php 
        MS_Helper_Html::html_separator();
        ?>
			<div class="aff-title">
				<strong><?php 
        _e('Affiliate settings', 'affiliate');
        ?>
</strong>
			</div>
			<div class="aff-inside">
				<?php 
        foreach ($fields as $field) {
            MS_Helper_Html::html_element($field);
        }
        ?>
				<p>
				* <?php 
        _e('Reward is based on the actually paid amount which includes any discounts (but no taxes).', 'affiliate');
        ?>
<br />
				** <?php 
        _e('Reward is based on the current membership price setting.', 'affiliate');
        ?>
				</p>
				<p>
				<?php 
        printf(__('Tipp: There is no currency conversion done. All rewards are paid in %s, regardless of the currency used by Membership2 or the invoice.', 'affiliate'), '<strong>' . $affiliate_currency . '</strong>');
        ?>
				</p>
			</div>
		</div>
		<?php 
    }
    /**
     * Renders the General help contents
     *
     * @since  1.0.0
     * @return string
     */
    public function render_tab_general()
    {
        ob_start();
        ?>
		<h2>
			<?php 
        /*_ex( 'Overview', 'help', MS_TEXT_DOMAIN ); */
        ?>
			<?php 
        _e('You\'re awesome :)', MS_TEXT_DOMAIN);
        ?>
<br />
		</h2>
		<p>
			<em><?php 
        _e('Thank you for using Membership 2', MS_TEXT_DOMAIN);
        ?>
</em>
			<br/ ><br />
			<?php 
        _ex('Here is a quick overview:', 'help', MS_TEXT_DOMAIN);
        ?>
		</p>
		<div>
		<?php 
        printf(_x('You use verion <strong>%s</strong> of Membership 2', 'help', MS_TEXT_DOMAIN), MS_PLUGIN_VERSION);
        if (function_exists('membership2_init_pro_app')) {
            printf('<br />' . _x('Hey, this is the <strong>PRO version</strong> of Membership 2 - thanks a lot for supporting us!', 'help', MS_TEXT_DOMAIN));
        } else {
            printf('<br />' . _x('This is the <strong>Free version</strong> of Membership 2 - did you check out our %sPRO version%s already?', 'help', MS_TEXT_DOMAIN), '<a href="https://premium.wpmudev.org/project/membership/" target="_blank">', '</a>');
        }
        if (is_multisite()) {
            if (MS_Plugin::is_network_wide()) {
                printf('<br />' . _x('Your Protection mode is <strong>%s network-wide</strong>.', 'help', MS_TEXT_DOMAIN), '<i class="wpmui-fa wpmui-fa-globe"></i>');
            } else {
                printf('<br />' . _x('Your Protection covers <strong>%s only this site</strong>.', 'help', MS_TEXT_DOMAIN), '<i class="wpmui-fa wpmui-fa-home"></i>');
            }
        }
        $admin_cap = MS_Plugin::instance()->controller->capability;
        if ($admin_cap) {
            printf('<br />' . _x('All users with capability <strong>%s</strong> are M2 Admin-users.', 'help', MS_TEXT_DOMAIN), $admin_cap);
        } else {
            printf('<br />' . _x('Only the <strong>Network-Admin</strong> can manage M2.', 'help', MS_TEXT_DOMAIN));
        }
        if (defined('MS_STOP_EMAILS') && MS_STOP_EMAILS) {
            printf('<br />' . _x('Currently M2 is configured to <strong>not send</strong> any emails.', 'help', MS_TEXT_DOMAIN));
        }
        if (defined('MS_LOCK_SUBSCRIPTIONS') && MS_LOCK_SUBSCRIPTIONS) {
            printf('<br />' . _x('Currently M2 is configured <strong>not expire/change</strong> any subscription status.', 'help', MS_TEXT_DOMAIN));
        }
        ?>
		</div>
		<?php 
        MS_Helper_Html::html_separator();
        ?>
		<h2>
			<?php 
        _ex('Plugin menu', 'help', MS_TEXT_DOMAIN);
        ?>
		</h2>
		<table cellspacing="0" cellpadding="4" border="0" width="100%">
			<tr>
				<td>
					<span class="top-menu">
					<div class="menu-image dashicons dashicons-lock"></div>
					<?php 
        _e('Membership 2', MS_TEXT_DOMAIN);
        ?>
					</span>
				</td>
				<td></td>
			</tr>
			<tr class="alternate">
				<td><span><?php 
        _e('Memberships', MS_TEXT_DOMAIN);
        ?>
</span></td>
				<td><?php 
        _ex('Create and manage Membership-Plans that users can sign up for', 'help', MS_TEXT_DOMAIN);
        ?>
</td>
			</tr>
			<tr>
				<td><span><?php 
        _e('Protection Rules', MS_TEXT_DOMAIN);
        ?>
</span></td>
				<td><?php 
        _ex('Set the protection options, i.e. which pages are protected by which membership', 'help', MS_TEXT_DOMAIN);
        ?>
</td>
			</tr>
			<tr class="alternate">
				<td><span><?php 
        _e('All Members', MS_TEXT_DOMAIN);
        ?>
</span></td>
				<td><?php 
        _ex('Lists all your WordPress users and allows you to manage their Memberships', 'help', MS_TEXT_DOMAIN);
        ?>
</td>
			</tr>
			<tr>
				<td><span><?php 
        _e('Add Member', MS_TEXT_DOMAIN);
        ?>
</span></td>
				<td><?php 
        _ex('Create a new WP User or edit subscriptions of an existing user', 'help', MS_TEXT_DOMAIN);
        ?>
</td>
			</tr>
			<tr class="alternate">
				<td><span><?php 
        _e('Billing', MS_TEXT_DOMAIN);
        ?>
</span></td>
				<td><?php 
        _ex('Manage sent invoices, including details such as the payment status. <em>Only visible when you have at least one paid membership</em>', 'help', MS_TEXT_DOMAIN);
        ?>
</td>
			</tr>
			<tr>
				<td><span><?php 
        _e('Coupons', MS_TEXT_DOMAIN);
        ?>
</span></td>
				<td><?php 
        _ex('Manage your discount coupons. <em>Requires Add-on "Coupons"</em>', 'help', MS_TEXT_DOMAIN);
        ?>
</td>
			</tr>
			<tr class="alternate">
				<td><span><?php 
        _e('Invitation Codes', MS_TEXT_DOMAIN);
        ?>
</span></td>
				<td><?php 
        _ex('Manage your invitation codes. <em>Requires Add-on "Invitation Codes"</em>', 'help', MS_TEXT_DOMAIN);
        ?>
</td>
			</tr>
			<tr>
				<td><span><?php 
        _e('Add-ons', MS_TEXT_DOMAIN);
        ?>
</span></td>
				<td><?php 
        _ex('Activate Add-ons', 'help', MS_TEXT_DOMAIN);
        ?>
</td>
			</tr>
			<tr class="alternate">
				<td><span><?php 
        _e('Settings', MS_TEXT_DOMAIN);
        ?>
</span></td>
				<td><?php 
        _ex('Global plugin options, such as Membership pages, payment options and email templates', 'help', MS_TEXT_DOMAIN);
        ?>
</td>
			</tr>
		</table>
		<?php 
        return ob_get_clean();
    }
    /**
     * Render the payment box for a single Membership subscription.
     *
     * @since  1.0.0
     */
    public function specific_payment_settings()
    {
        $membership = $this->data['membership'];
        $title = sprintf(__('Payment settings for %s', MS_TEXT_DOMAIN), $membership->get_name_tag());
        $type_class = $this->data['is_global_payments_set'] ? '' : 'ms-half right';
        ?>
		<div class="ms-specific-payment-wrapper <?php 
        echo esc_attr($type_class);
        ?>
">
			<div class="ms-header">
				<div class="ms-settings-tab-title">
					<h3><?php 
        echo $title;
        ?>
</h3>
				</div>
				<?php 
        MS_Helper_Html::html_separator();
        ?>
			</div>

			<div class="inside">
				<?php 
        $view = MS_Factory::create('MS_View_Membership_Tab_Payment');
        $view->data = $this->data;
        echo $view->to_html();
        ?>
			</div>
			<?php 
        MS_Helper_Html::save_text();
        ?>
		</div>
		<?php 
    }
    /**
     * Returns the contens of the dialog
     *
     * @since  1.0.0
     *
     * @return object
     */
    public function get_contents($data)
    {
        $subscription = $data['model'];
        $gateways = MS_Model_Gateway::get_gateway_names();
        $invoices = $subscription->get_invoices();
        $pay_details = array();
        $inv_details = array();
        foreach ($subscription->get_payments() as $payment) {
            if (isset($gateways[$payment['gateway']])) {
                $gateway = $gateways[$payment['gateway']];
            } else {
                $gateway = '(' . $payment['gateway'] . ')';
            }
            $pay_details[] = array('title' => __('Recorded Payment', 'membership2'), 'type' => MS_Helper_Html::TYPE_HTML_TABLE, 'value' => array(0 => array('Payment Date', $payment['date']), 1 => array('Payment Gateway', $gateway), 2 => array('Amount', $payment['amount']), 3 => array('External ID', $payment['external_id'])), 'field_options' => array('head_col' => true));
        }
        $invoice_list = array();
        foreach ($invoices as $invoice) {
            if (isset($gateways[$invoice->gateway_id])) {
                $gateway = $gateways[$invoice->gateway_id];
            } else {
                $gateway = '(' . $invoice->gateway_id . ')';
            }
            $transaction_log = sprintf(' <small>- <a href="%s" target="_blank">%s</a></small>', MS_Controller_Plugin::get_admin_url('billing', array('show' => 'logs', 'invoice' => $invoice->id)), __('Show Transaction', 'membership2'));
            $invoice_list[] = $invoice->id;
            $inv_details[$invoice->id] = array('title' => sprintf(__('Invoice %s', 'membership2'), $invoice->id), 'type' => MS_Helper_Html::TYPE_HTML_TABLE, 'value' => array(0 => array('Invoice ID', $invoice->id . $transaction_log), 2 => array('Create Date', $invoice->invoice_date), 1 => array('Payment Gateway', $gateway), 2 => array('Due Date', $invoice->due_date), 3 => array('Regular amount', $invoice->amount), 4 => array('Total billed', $invoice->total), 5 => array('Status', $invoice->status), 6 => array('Notes', $invoice->description), 7 => array('Checkout IP', $invoice->checkout_ip), 8 => array('Checkout Date', $invoice->checkout_date)), 'field_options' => array('head_col' => true));
            if ($invoice->amount == $invoice->total) {
                unset($inv_details[$invoice->id]['value'][3]);
                $inv_details[$invoice->id]['value'] = array_values($inv_details[$invoice->id]['value']);
            }
        }
        $transaction_url = MS_Controller_Plugin::get_admin_url('billing', array('show' => 'logs', 'invoice' => implode(',', $invoice_list)));
        $transaction_log = array('type' => MS_Helper_Html::TYPE_HTML_LINK, 'value' => __('Show all Transactions for this subscription', 'membership2'), 'url' => $transaction_url, 'target' => '_blank');
        ob_start();
        ?>
		<div class="wpmui-grid-8 ms-payment-infos">
			<div class="col-5">
				<?php 
        foreach ($inv_details as $detail) {
            MS_Helper_Html::html_element($detail);
        }
        ?>
			</div>
			<div class="col-3">
				<?php 
        MS_Helper_Html::html_element($transaction_log);
        MS_Helper_Html::html_separator();
        foreach ($pay_details as $detail) {
            MS_Helper_Html::html_element($detail);
        }
        ?>
			</div>
		</div>
		<?php 
        $html = ob_get_clean();
        return apply_filters('ms_view_member_payment_to_html', $html);
    }
    /**
     * Create view output.
     *
     * @since  1.0.0
     * @return string
     */
    public function to_html()
    {
        $membership = $this->data['membership'];
        $fields = $this->get_fields();
        $gateways_available = 0 != count($fields['gateways']);
        if (isset($this->data['is_global_payments_set'])) {
            if (!$this->data['is_global_payments_set']) {
                $gateways_available = false;
            }
        }
        ob_start();
        ?>
		<div class="ms-payment-form">
			<?php 
        if (!$membership->can_change_payment()) {
            ?>
				<div class="error below-h2">
					<p>
						<?php 
            _e('This membership already has some paying members.', MS_TEXT_DOMAIN);
            ?>
					</p>
					<p>
						<?php 
            _e('Any changes will affect new invoices but not existing ones.', MS_TEXT_DOMAIN);
            ?>
					</p>
				</div>
			<?php 
        }
        ?>
			<div class="cf">
				<div class="ms-payment-structure-wrapper ms-half space">
					<?php 
        MS_Helper_Html::html_element($fields['payment_type']);
        MS_Helper_Html::html_element($fields['price']);
        if (isset($fields['payment_type_val'])) {
            MS_Helper_Html::html_element($fields['payment_type_val']);
        }
        ?>
				</div>
				<div class="ms-payment-types-wrapper ms-half">
					<div class="ms-payment-type-wrapper ms-payment-type-finite ms-period-wrapper">
						<?php 
        MS_Helper_Html::html_element($fields['period_unit']);
        MS_Helper_Html::html_element($fields['period_type']);
        ?>
					</div>
					<!-- Recurring is PRO only -->
					<div class="ms-payment-type-wrapper ms-payment-type-date-range">
						<?php 
        MS_Helper_Html::html_element($fields['period_date_start']);
        MS_Helper_Html::html_element($fields['period_date_end']);
        ?>
					</div>
					<div class="ms-after-end-wrapper">
						<?php 
        MS_Helper_Html::html_element($fields['on_end_membership_id']);
        ?>
					</div>
				</div>
			</div>

			<?php 
        /* Only show the trial option for PAID memberships */
        ?>
			<?php 
        if (!$membership->is_free) {
            ?>
			<div class="cf">
				<?php 
            $show_trial_note = MS_Plugin::instance()->settings->is_first_paid_membership;
            if (!empty($_GET['edit'])) {
                $show_trial_note = false;
            }
            if (MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_TRIAL)) {
                ?>
					<div class="ms-trial-wrapper">
						<?php 
                MS_Helper_Html::html_separator();
                MS_Helper_Html::html_element($fields['trial_period_enabled']);
                $style = $membership->trial_period_enabled ? '' : 'style="display:none"';
                ?>
						<div class="ms-trial-period-details" <?php 
                echo '' . $style;
                ?>
>
							<?php 
                MS_Helper_Html::html_element($fields['trial_period_unit']);
                MS_Helper_Html::html_element($fields['trial_period_type']);
                ?>
						</div>
					</div>
					<?php 
            } else {
                if ($show_trial_note) {
                    ?>
					<div class="ms-trial-wrapper">
						<?php 
                    MS_Helper_Html::html_separator();
                    ?>
						<h4>
							<?php 
                    _e('Well done, you just created your first paid membership!', MS_TEXT_DOMAIN);
                    ?>
						</h4>
						<p>
							<?php 
                    _e('To give visitors an extra incentive to register for this Membership you can offer a free trial period for a limited time. Do you want to enable this feature now?', MS_TEXT_DOMAIN);
                    ?>
						</p>
						<p>
							<?php 
                    MS_Helper_Html::html_element($fields['enable_trial_addon']);
                    ?>
<br />
							<em><?php 
                    _e('This message is only displayed once. Ignore it if you do not want to use trial memberships.', MS_TEXT_DOMAIN);
                    ?>
</em><br />
							<em><?php 
                    _e('You can change this feature anytime by visiting the Add-ons section.', MS_TEXT_DOMAIN);
                    ?>
</em>
						</p>
					</div>
					<?php 
                }
            }
            ?>
			</div>

			<?php 
            if ($gateways_available) {
                ?>
			<div class="cf ms-payment-gateways">
				<?php 
                MS_Helper_Html::html_separator();
                ?>
				<p><strong><?php 
                _e('Allowed payment gateways', MS_TEXT_DOMAIN);
                ?>
</strong></p>
				<?php 
                foreach ($fields['gateways'] as $field) {
                    MS_Helper_Html::html_element($field);
                }
                ?>
			</div>
			<?php 
            }
            ?>

			<?php 
        }
        ?>

			<?php 
        /**
         * This action allows other add-ons or plugins to display custom
         * options in the payment dialog.
         *
         * @since  1.0.0
         */
        do_action('ms_view_membership_tab_payment_form', $this, $membership);
        // Legacy action.
        do_action('ms_view_membership_payment_form', $this, $membership);
        ?>
		</div>
		<?php 
        $html = ob_get_clean();
        echo $html;
    }