billing
2 weeks ago
reviews
1 month ago
settings
1 month ago
withdrawal
1 month ago
billing.php
3 weeks ago
profile.php
1 month ago
reviews.php
1 month ago
settings.php
3 days ago
withdrawals.php
1 month ago
settings.php
192 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Settings Template for Account |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage Dashboard |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @since 4.0.0 |
| 10 | * |
| 11 | * These variables are inherited from parent templates: |
| 12 | * template: templates/account.php |
| 13 | * |
| 14 | * @var string $back_url |
| 15 | */ |
| 16 | |
| 17 | defined( 'ABSPATH' ) || exit; |
| 18 | |
| 19 | use TUTOR\Icon; |
| 20 | use TUTOR\User; |
| 21 | |
| 22 | $settings_tab_data = array( |
| 23 | 'account' => array( |
| 24 | 'id' => 'account', |
| 25 | 'label' => __( 'Account', 'tutor' ), |
| 26 | 'icon' => Icon::USER_CIRCLE, |
| 27 | 'text' => __( 'Name, email, phone number, profiles', 'tutor' ), |
| 28 | 'template' => 'dashboard.account.settings.account', |
| 29 | 'role' => false, |
| 30 | ), |
| 31 | 'security' => array( |
| 32 | 'id' => 'security', |
| 33 | 'label' => __( 'Security', 'tutor' ), |
| 34 | 'icon' => Icon::SECURITY, |
| 35 | 'text' => __( 'Password, 2FA', 'tutor' ), |
| 36 | 'template' => 'dashboard.account.settings.security', |
| 37 | 'role' => false, |
| 38 | ), |
| 39 | 'social-accounts' => array( |
| 40 | 'id' => 'social-accounts', |
| 41 | 'label' => __( 'Social Accounts', 'tutor' ), |
| 42 | 'icon' => Icon::GLOBE, |
| 43 | 'text' => __( 'Linked social media profiles', 'tutor' ), |
| 44 | 'template' => 'dashboard.account.settings.social-accounts', |
| 45 | 'role' => false, |
| 46 | ), |
| 47 | 'withdraw' => array( |
| 48 | 'id' => 'withdraw', |
| 49 | 'label' => __( 'Withdraw', 'tutor' ), |
| 50 | 'icon' => Icon::WITHDRAW, |
| 51 | 'text' => __( 'Withdrawal and refund', 'tutor' ), |
| 52 | 'template' => 'dashboard.account.settings.withdraw', |
| 53 | 'role' => User::INSTRUCTOR, |
| 54 | ), |
| 55 | 'preferences' => array( |
| 56 | 'id' => 'preferences', |
| 57 | 'label' => __( 'Preferences', 'tutor' ), |
| 58 | 'icon' => Icon::FILTER_2, |
| 59 | 'text' => __( 'Sound effects, animations, theme', 'tutor' ), |
| 60 | 'template' => 'dashboard.account.settings.preferences', |
| 61 | 'role' => false, |
| 62 | ), |
| 63 | ); |
| 64 | |
| 65 | // phpcs:ignore WordPress.NamingConventions.ValidHookName |
| 66 | $settings_tab_data = apply_filters( 'tutor_dashboard/nav_items/settings/nav_items', $settings_tab_data ); |
| 67 | |
| 68 | $settings_tab_data = array_values( |
| 69 | array_filter( |
| 70 | $settings_tab_data, |
| 71 | function ( $tab ) { |
| 72 | return 'account' === $tab['id'] || ! $tab['role'] || ( User::INSTRUCTOR === $tab['role'] && current_user_can( tutor()->instructor_role ) && User::is_instructor_view() ); |
| 73 | } |
| 74 | ) |
| 75 | ); |
| 76 | |
| 77 | ?> |
| 78 | |
| 79 | <section x-data="tutorSettings()"> |
| 80 | <div |
| 81 | x-data='(() => { |
| 82 | const initialTab = new URL(window.location.href).searchParams.get("tab"); |
| 83 | const tabs = tutorTabs({ |
| 84 | tabs: <?php echo wp_json_encode( $settings_tab_data ); ?>, |
| 85 | orientation: "vertical", |
| 86 | defaultTab: window.innerWidth >= 768 ? "account" : "none", |
| 87 | urlParams: { |
| 88 | enabled: true, |
| 89 | paramName: "tab", |
| 90 | } |
| 91 | }); |
| 92 | |
| 93 | return { |
| 94 | ...tabs, |
| 95 | backUrl: <?php echo wp_json_encode( $back_url ); ?>, |
| 96 | viewportWidth: window.innerWidth, |
| 97 | hasInitialUrlTab: tabs.tabs.some((tab) => tab.id === initialTab), |
| 98 | handleViewportResize() { |
| 99 | const wasDesktop = this.viewportWidth >= 768; |
| 100 | const isDesktop = window.innerWidth >= 768; |
| 101 | |
| 102 | this.viewportWidth = window.innerWidth; |
| 103 | |
| 104 | if (wasDesktop === isDesktop || this.hasInitialUrlTab) { |
| 105 | return; |
| 106 | } |
| 107 | |
| 108 | if (isDesktop && this.activeTab === "none") { |
| 109 | this.selectTab("account"); |
| 110 | } else if (!isDesktop && this.activeTab !== "none") { |
| 111 | this.selectTab("none"); |
| 112 | } |
| 113 | }, |
| 114 | selectTab(tabId) { |
| 115 | if (tabId === "none") { |
| 116 | this.activeTab = "none"; |
| 117 | |
| 118 | if (this.urlParamsConfig.enabled) { |
| 119 | const url = new URL(window.location.href); |
| 120 | url.searchParams.delete(this.urlParamsConfig.paramName); |
| 121 | window.history.replaceState({}, "", url.toString()); |
| 122 | } |
| 123 | |
| 124 | return; |
| 125 | } |
| 126 | |
| 127 | return tabs.selectTab.call(this, tabId); |
| 128 | }, |
| 129 | handleClose() { |
| 130 | if (window.innerWidth < 768 && this.activeTab !== "none") { |
| 131 | this.selectTab("none"); |
| 132 | return; |
| 133 | } |
| 134 | |
| 135 | window.location.href = this.backUrl; |
| 136 | }, |
| 137 | }; |
| 138 | })()' |
| 139 | class="tutor-profile-settings-section" |
| 140 | > |
| 141 | <?php tutor_load_template( 'dashboard.account.settings.header', array( 'back_url' => $back_url ) ); ?> |
| 142 | |
| 143 | <div class="tutor-account-container"> |
| 144 | <div |
| 145 | @resize.window="handleViewportResize()" |
| 146 | x-cloak |
| 147 | class="tutor-gap-8" |
| 148 | > |
| 149 | <div class="tutor-flex tutor-gap-8 tutor-my-9 tutor-sm-my-6"> |
| 150 | <div x-ref="tablist" role="tablist" aria-orientation="vertical" class="tutor-tabs-nav tutor-profile-settings-tab tutor-p-5"> |
| 151 | <template x-for="tab in tabs" :key="tab.id"> |
| 152 | <button |
| 153 | type="button" |
| 154 | role="tab" |
| 155 | :class='getTabClass(tab)' |
| 156 | x-bind:aria-selected="isActive(tab.id)" |
| 157 | :disabled="tab.disabled ? true : false" |
| 158 | @click="selectTab(tab.id)" |
| 159 | > |
| 160 | <span x-data="tutorIcon({ name: tab.icon, width: 20, height: 20})"></span> |
| 161 | <div class="tutor-flex tutor-flex-column tutor-items-start"> |
| 162 | <span x-text="tab.label" class="tutor-text-small"></span> |
| 163 | <span x-text="tab.text" class="tutor-text-tiny tutor-hidden tutor-md-block tutor-text-subdued"></span> |
| 164 | </div> |
| 165 | </button> |
| 166 | </template> |
| 167 | </div> |
| 168 | |
| 169 | <div |
| 170 | role="main" |
| 171 | :class="activeTab !== null && activeTab !== 'none' ? 'tutor-profile-tab-activated' : ''" |
| 172 | class="tutor-profile-settings-tab-content tutor-w-full" |
| 173 | > |
| 174 | <?php foreach ( $settings_tab_data as $settings_tab ) : ?> |
| 175 | <div x-show="activeTab === '<?php echo esc_attr( $settings_tab['id'] ); ?>'" x-cloak class="tutor-tab-panel" role="tabpanel"> |
| 176 | <?php |
| 177 | $form_id = "tutor-{$settings_tab['id']}-form"; |
| 178 | tutor_load_template( |
| 179 | $settings_tab['template'], |
| 180 | array( 'form_id' => $form_id ), |
| 181 | isset( $settings_tab['is_pro'] ) && $settings_tab['is_pro'] ? true : false |
| 182 | ); |
| 183 | ?> |
| 184 | </div> |
| 185 | <?php endforeach; ?> |
| 186 | </div> |
| 187 | </div> |
| 188 | </div> |
| 189 | </div> |
| 190 | </div> |
| 191 | </section> |
| 192 |