CouponsPage
4 years ago
CustomersPage
4 years ago
DashboardPage
4 years ago
OrdersPage
4 years ago
PlansPage
4 years ago
SubscriptionsPage
4 years ago
TaxSettings
4 years ago
views
4 years ago
CheckListHeader.php
4 years ago
CheckoutFieldsManager.php
4 years ago
ContextualStateChangeHelper.php
4 years ago
PaymentMethods.php
4 years ago
PaymentSettings.php
4 years ago
SettingsFieldsParser.php
4 years ago
index.php
4 years ago
PaymentSettings.php
133 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePress\Core\Admin\SettingsPages\Membership; |
| 4 | |
| 5 | use ProfilePress\Core\Admin\SettingsPages\AbstractSettingsPage; |
| 6 | use ProfilePress\Core\Membership\CheckoutFields; |
| 7 | use ProfilePress\Custom_Settings_Page_Api; |
| 8 | |
| 9 | class PaymentSettings extends AbstractSettingsPage |
| 10 | { |
| 11 | public $settingsPageInstance; |
| 12 | |
| 13 | public function __construct() |
| 14 | { |
| 15 | add_filter('ppress_settings_page_tabs', [$this, 'header_menu_tab']); |
| 16 | add_filter('ppress_settings_page_submenus_tabs', [$this, 'header_sub_menu_tab']); |
| 17 | add_action('ppress_admin_settings_submenu_page_payments_settings', [$this, 'settings_page']); |
| 18 | } |
| 19 | |
| 20 | public function header_menu_tab($tabs) |
| 21 | { |
| 22 | $tabs[35] = ['id' => 'payments', 'url' => add_query_arg('view', 'payments', PPRESS_SETTINGS_SETTING_PAGE), 'label' => esc_html__('Payments', 'wp-user-avatar')]; |
| 23 | |
| 24 | return $tabs; |
| 25 | } |
| 26 | |
| 27 | public function header_sub_menu_tab($tabs) |
| 28 | { |
| 29 | $tabs[172] = ['parent' => 'payments', 'id' => 'settings', 'label' => esc_html__('Settings', 'wp-user-avatar')]; |
| 30 | |
| 31 | return $tabs; |
| 32 | } |
| 33 | |
| 34 | public function settings_page() |
| 35 | { |
| 36 | $page_header = esc_html__('Payment Settings', 'wp-user-avatar'); |
| 37 | |
| 38 | $currency_code_options = ppress_get_currencies(); |
| 39 | |
| 40 | foreach ($currency_code_options as $code => $name) { |
| 41 | $currency_code_options[$code] = $name . ' (' . ppress_get_currency_symbol($code) . ')'; |
| 42 | } |
| 43 | |
| 44 | $settings = [ |
| 45 | [ |
| 46 | 'section_title' => esc_html__('Currency Settings', 'wp-user-avatar'), |
| 47 | 'payment_currency' => [ |
| 48 | 'label' => esc_html__('Currency', 'wp-user-avatar'), |
| 49 | 'description' => esc_html__('Choose your currency. Note that some payment gateways have currency restrictions.', 'wp-user-avatar'), |
| 50 | 'type' => 'select', |
| 51 | 'options' => $currency_code_options |
| 52 | ], |
| 53 | 'currency_position' => [ |
| 54 | 'label' => esc_html__('Currency Position', 'wp-user-avatar'), |
| 55 | 'description' => esc_html__('The position of the currency symbol.', 'wp-user-avatar'), |
| 56 | 'type' => 'select', |
| 57 | 'options' => [ |
| 58 | 'left' => 'Left (' . sprintf('%1$s%2$s', ppress_get_currency_symbol(), 99.99) . ')', |
| 59 | 'right' => 'Right (' . sprintf('%2$s%1$s', ppress_get_currency_symbol(), 99.99) . ')', |
| 60 | 'left_space' => 'Left with Space (' . sprintf('%1$s %2$s', ppress_get_currency_symbol(), 99.99) . ')', |
| 61 | 'right_space' => 'Right with Space (' . sprintf('%2$s %1$s', ppress_get_currency_symbol(), 99.99) . ')', |
| 62 | ] |
| 63 | ], |
| 64 | 'currency_decimal_separator' => [ |
| 65 | 'label' => esc_html__('Decimal Separator', 'wp-user-avatar'), |
| 66 | 'type' => 'select', |
| 67 | 'options' => [ |
| 68 | '.' => 'Period (12.50)', |
| 69 | ',' => 'Comma (12,50)' |
| 70 | ], |
| 71 | ], |
| 72 | 'currency_thousand_separator' => [ |
| 73 | 'label' => esc_html__('Thousand Separator', 'wp-user-avatar'), |
| 74 | 'type' => 'select', |
| 75 | 'options' => [ |
| 76 | ',' => __('Comma (10,000)', 'wp-user-avatar'), |
| 77 | '.' => __('Period (10.000)', 'wp-user-avatar'), |
| 78 | ' ' => __('Space (10 000)', 'wp-user-avatar'), |
| 79 | 'none' => __('None', 'wp-user-avatar') |
| 80 | ], |
| 81 | ], |
| 82 | 'currency_decimal_number' => [ |
| 83 | 'label' => esc_html__('Number of Decimals', 'wp-user-avatar'), |
| 84 | 'type' => 'select', |
| 85 | 'options' => [ |
| 86 | '0' => '0', |
| 87 | '1' => '1', |
| 88 | '2' => '2', |
| 89 | '3' => '3', |
| 90 | '4' => '4', |
| 91 | '5' => '5', |
| 92 | '6' => '6', |
| 93 | '7' => '7', |
| 94 | '8' => '8', |
| 95 | ] |
| 96 | ] |
| 97 | ], |
| 98 | [ |
| 99 | 'section_title' => esc_html__('Checkout Settings', 'wp-user-avatar'), |
| 100 | 'one_time_trial' => [ |
| 101 | 'label' => esc_html__('One Time Trials', 'wp-user-avatar'), |
| 102 | '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'), |
| 103 | 'type' => 'checkbox' |
| 104 | ], |
| 105 | 'terms_agreement_label' => [ |
| 106 | 'label' => esc_html__('Terms & Conditions Label', 'wp-user-avatar'), |
| 107 | 'description' => sprintf( |
| 108 | esc_html__('Label for the "Agree to Terms" checkbox where "[terms]" is a link to the %sterms and condition page%s', 'wp-user-avatar'), |
| 109 | '<a href="' . PPRESS_SETTINGS_SETTING_PAGE . '#global_pages?terms_page_id_row" target="_blank">', '</a>' |
| 110 | ), |
| 111 | 'type' => 'text' |
| 112 | ] |
| 113 | ] |
| 114 | ]; |
| 115 | |
| 116 | $settingsPageInstance = Custom_Settings_Page_Api::instance('', PPRESS_SETTINGS_DB_OPTION_NAME); |
| 117 | $settingsPageInstance->page_header($page_header); |
| 118 | $settingsPageInstance->main_content($settings); |
| 119 | $settingsPageInstance->sidebar(AbstractSettingsPage::sidebar_args()); |
| 120 | $settingsPageInstance->build(); |
| 121 | } |
| 122 | |
| 123 | public static function get_instance() |
| 124 | { |
| 125 | static $instance = null; |
| 126 | |
| 127 | if (is_null($instance)) { |
| 128 | $instance = new self(); |
| 129 | } |
| 130 | |
| 131 | return $instance; |
| 132 | } |
| 133 | } |