CouponsPage
1 year ago
CustomersPage
5 months ago
DashboardPage
1 year ago
DownloadLogsPage
1 year ago
ExportPage
5 months ago
GroupsPage
1 year ago
OrdersPage
1 year ago
PlansPage
2 months ago
SubscriptionsPage
3 months ago
TaxSettings
3 years ago
views
1 month ago
CheckListHeader.php
3 years ago
CheckoutFieldsManager.php
1 year ago
ContextualStateChangeHelper.php
3 years ago
FileDownloads.php
3 years ago
PaymentMethods.php
1 year ago
PaymentSettings.php
1 month ago
PlanIntegrationsMetabox.php
10 months ago
SettingsFieldsParser.php
1 year ago
index.php
3 years ago
PaymentSettings.php
183 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePress\Core\Admin\SettingsPages\Membership; |
| 4 | |
| 5 | use ProfilePress\Core\Admin\SettingsPages\AbstractSettingsPage; |
| 6 | use ProfilePress\Core\Classes\ExtensionManager; |
| 7 | use ProfilePress\Core\Membership\CheckoutFields; |
| 8 | use ProfilePress\Custom_Settings_Page_Api; |
| 9 | |
| 10 | class PaymentSettings extends AbstractSettingsPage |
| 11 | { |
| 12 | public $settingsPageInstance; |
| 13 | |
| 14 | public function __construct() |
| 15 | { |
| 16 | add_filter('ppress_settings_page_tabs', [$this, 'header_menu_tab']); |
| 17 | add_filter('ppress_settings_page_submenus_tabs', [$this, 'header_sub_menu_tab']); |
| 18 | add_action('ppress_admin_settings_submenu_page_payments_settings', [$this, 'settings_page']); |
| 19 | } |
| 20 | |
| 21 | public function header_menu_tab($tabs) |
| 22 | { |
| 23 | $tabs[35] = ['id' => 'payments', 'url' => add_query_arg('view', 'payments', PPRESS_SETTINGS_SETTING_PAGE), 'label' => esc_html__('Payments', 'wp-user-avatar')]; |
| 24 | |
| 25 | return $tabs; |
| 26 | } |
| 27 | |
| 28 | public function header_sub_menu_tab($tabs) |
| 29 | { |
| 30 | $tabs[172] = ['parent' => 'payments', 'id' => 'settings', 'label' => esc_html__('Settings', 'wp-user-avatar')]; |
| 31 | |
| 32 | return $tabs; |
| 33 | } |
| 34 | |
| 35 | public function settings_page() |
| 36 | { |
| 37 | $page_header = esc_html__('Payment Settings', 'wp-user-avatar'); |
| 38 | |
| 39 | $currency_code_options = ppress_get_currencies(); |
| 40 | |
| 41 | foreach ($currency_code_options as $code => $name) { |
| 42 | $currency_code_options[$code] = $name . ' (' . ppress_get_currency_symbol($code) . ')'; |
| 43 | } |
| 44 | |
| 45 | $settings = [ |
| 46 | [ |
| 47 | 'section_title' => esc_html__('Currency Settings', 'wp-user-avatar'), |
| 48 | 'payment_currency' => [ |
| 49 | 'label' => esc_html__('Currency', 'wp-user-avatar'), |
| 50 | 'description' => esc_html__('Choose your currency. Note that some payment gateways have currency restrictions.', 'wp-user-avatar'), |
| 51 | 'type' => 'select', |
| 52 | 'options' => $currency_code_options |
| 53 | ], |
| 54 | 'currency_position' => [ |
| 55 | 'label' => esc_html__('Currency Position', 'wp-user-avatar'), |
| 56 | 'description' => esc_html__('The position of the currency symbol.', 'wp-user-avatar'), |
| 57 | 'type' => 'select', |
| 58 | 'options' => [ |
| 59 | 'left' => 'Left (' . sprintf('%1$s%2$s', ppress_get_currency_symbol(), 99.99) . ')', |
| 60 | 'right' => 'Right (' . sprintf('%2$s%1$s', ppress_get_currency_symbol(), 99.99) . ')', |
| 61 | 'left_space' => 'Left with Space (' . sprintf('%1$s %2$s', ppress_get_currency_symbol(), 99.99) . ')', |
| 62 | 'right_space' => 'Right with Space (' . sprintf('%2$s %1$s', ppress_get_currency_symbol(), 99.99) . ')', |
| 63 | ] |
| 64 | ], |
| 65 | 'currency_decimal_separator' => [ |
| 66 | 'label' => esc_html__('Decimal Separator', 'wp-user-avatar'), |
| 67 | 'type' => 'select', |
| 68 | 'options' => [ |
| 69 | '.' => 'Period (12.50)', |
| 70 | ',' => 'Comma (12,50)' |
| 71 | ], |
| 72 | ], |
| 73 | 'currency_thousand_separator' => [ |
| 74 | 'label' => esc_html__('Thousand Separator', 'wp-user-avatar'), |
| 75 | 'type' => 'select', |
| 76 | 'options' => [ |
| 77 | ',' => __('Comma (10,000)', 'wp-user-avatar'), |
| 78 | '.' => __('Period (10.000)', 'wp-user-avatar'), |
| 79 | ' ' => __('Space (10 000)', 'wp-user-avatar'), |
| 80 | 'none' => __('None', 'wp-user-avatar') |
| 81 | ], |
| 82 | ], |
| 83 | 'currency_decimal_number' => [ |
| 84 | 'label' => esc_html__('Number of Decimals', 'wp-user-avatar'), |
| 85 | 'type' => 'select', |
| 86 | 'options' => [ |
| 87 | '0' => '0', |
| 88 | '1' => '1', |
| 89 | '2' => '2', |
| 90 | '3' => '3', |
| 91 | '4' => '4', |
| 92 | '5' => '5', |
| 93 | '6' => '6', |
| 94 | '7' => '7', |
| 95 | '8' => '8', |
| 96 | ] |
| 97 | ] |
| 98 | ], |
| 99 | [ |
| 100 | 'section_title' => esc_html__('Checkout Settings', 'wp-user-avatar'), |
| 101 | 'one_time_trial' => [ |
| 102 | 'label' => esc_html__('One Time Trials', 'wp-user-avatar'), |
| 103 | 'description' => esc_html__('Check this if you will like customers to be prevented from using the free trial of a plan multiple times.', 'wp-user-avatar'), |
| 104 | 'type' => 'checkbox' |
| 105 | ], |
| 106 | 'terms_agreement_label' => [ |
| 107 | 'label' => esc_html__('Terms & Conditions Label', 'wp-user-avatar'), |
| 108 | 'description' => sprintf( |
| 109 | esc_html__('Label for the "Agree to Terms" checkbox where "[terms]" is a link to the %sterms and condition page%s', 'wp-user-avatar'), |
| 110 | '<a href="' . PPRESS_SETTINGS_SETTING_GENERAL_PAGE . '#global_pages?terms_page_id_row" target="_blank">', '</a>' |
| 111 | ), |
| 112 | 'type' => 'text' |
| 113 | ], |
| 114 | 'proration_method' => [ |
| 115 | 'label' => esc_html__('Proration Method', 'wp-user-avatar'), |
| 116 | 'description' => sprintf( |
| 117 | esc_html__('Specify how to calculate proration for subscription downgrades and upgrades. %sCost-based calculation is where the value of an upgrade is calculated based on the cost difference between the current and new membership plans. %sTime-based calculation is true proration in which the amount of time remaining on the current subscription plan is calculated to adjust the cost of the new subscription.', 'wp-user-avatar'), |
| 118 | '</p><p class="description">', '</p><p class="description">' |
| 119 | ), |
| 120 | 'type' => 'select', |
| 121 | 'options' => [ |
| 122 | 'cost-based' => esc_html__('Cost-Based Calculation', 'wp-user-avatar'), |
| 123 | 'time-based' => esc_html__('Time-Based Calculation', 'wp-user-avatar') |
| 124 | ] |
| 125 | ], |
| 126 | 'disable_auto_renew' => [ |
| 127 | 'label' => esc_html__('Disable Auto-renewal', 'wp-user-avatar'), |
| 128 | 'checkbox_label' => esc_html__('Disable', 'wp-user-avatar'), |
| 129 | 'description' => esc_html__('Check to disable automatic renewal of subscriptions at the end of a billing cycle', 'wp-user-avatar'), |
| 130 | 'type' => 'checkbox' |
| 131 | ], |
| 132 | 'checkout_auto_renewal_checkbox' => [ |
| 133 | 'label' => esc_html__('Auto-renewal Checkbox', 'wp-user-avatar'), |
| 134 | 'checkbox_label' => esc_html__('Enable', 'wp-user-avatar'), |
| 135 | 'description' => esc_html__('Check to show a checkbox that lets customers enable or disable auto-renewal during checkout.', 'wp-user-avatar'), |
| 136 | 'type' => 'select', |
| 137 | 'options' => [ |
| 138 | 'disabled' => esc_html__('Disabled', 'wp-user-avatar'), |
| 139 | 'opt-out' => esc_html__('Let customers opt-out of auto-renewal', 'wp-user-avatar'), |
| 140 | 'opt-in' => esc_html__('Let customers opt-in to auto-renewal', 'wp-user-avatar') |
| 141 | ] |
| 142 | ], |
| 143 | 'enable_checkout_autologin' => [ |
| 144 | 'label' => esc_html__('Checkout Autologin', 'wp-user-avatar'), |
| 145 | 'checkbox_label' => esc_html__('Enable', 'wp-user-avatar'), |
| 146 | 'description' => esc_html__('Check to automatically log in customers after checkout.', 'wp-user-avatar'), |
| 147 | 'type' => 'checkbox' |
| 148 | ], |
| 149 | ] |
| 150 | ]; |
| 151 | |
| 152 | if (ExtensionManager::is_enabled(ExtensionManager::SOCIAL_LOGIN)) { |
| 153 | $settings[1]['checkout_social_login_buttons'] = [ |
| 154 | 'label' => esc_html__('Checkout Social Login', 'wp-user-avatar'), |
| 155 | 'description' => esc_html__('Select the social login buttons to display on the checkout page.', 'wp-user-avatar'), |
| 156 | 'type' => 'select2', |
| 157 | 'options' => ppress_social_login_networks() |
| 158 | ]; |
| 159 | } |
| 160 | |
| 161 | if ( ! ExtensionManager::is_enabled(ExtensionManager::AUTORENEWAL_CHECKBOX)) { |
| 162 | unset($settings[1]['checkout_auto_renewal_checkbox']); |
| 163 | } |
| 164 | |
| 165 | $settingsPageInstance = Custom_Settings_Page_Api::instance('', PPRESS_SETTINGS_DB_OPTION_NAME); |
| 166 | $settingsPageInstance->page_header($page_header); |
| 167 | $settingsPageInstance->main_content(apply_filters('ppress_payment_admin_settings', $settings)); |
| 168 | $settingsPageInstance->sidebar(AbstractSettingsPage::sidebar_args()); |
| 169 | $settingsPageInstance->build(); |
| 170 | } |
| 171 | |
| 172 | public static function get_instance() |
| 173 | { |
| 174 | static $instance = null; |
| 175 | |
| 176 | if (is_null($instance)) { |
| 177 | $instance = new self(); |
| 178 | } |
| 179 | |
| 180 | return $instance; |
| 181 | } |
| 182 | } |
| 183 |