| @@ -1,327 +1,327 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -use LearnPress\Helpers\Template; | |
| 4 | -use LearnPress\Models\UserModel; | |
| 5 | -use LearnPress\TemplateHooks\Instructor\SingleInstructorTemplate; | |
| 6 | -use LearnPress\TemplateHooks\Profile\ProfileTemplate; | |
| 7 | -use LearnPress\TemplateHooks\UserTemplate; | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * Class LP_Profile_Template | |
| 11 | - * | |
| 12 | - * Group templates related user profile. | |
| 13 | - * | |
| 14 | - * @since 4.0.0 | |
| 15 | - */ | |
| 16 | -class LP_Template_Profile extends LP_Abstract_Template { | |
| 17 | - public function header( $user ) { | |
| 18 | - learn_press_get_template( 'profile/header.php', array( 'user' => $user ) ); | |
| 19 | - } | |
| 20 | - | |
| 21 | - public function sidebar() { | |
| 22 | - $profile = LP_Profile::instance(); | |
| 23 | - if ( $profile->get_user()->is_guest() ) { | |
| 24 | - return; | |
| 25 | - } | |
| 26 | - | |
| 27 | - if ( $profile->get_user_current()->is_guest() | |
| 28 | - && 'yes' !== LP_Profile::get_option_publish_profile() ) { | |
| 29 | - return; | |
| 30 | - } | |
| 31 | - | |
| 32 | - $user = $profile->get_user(); | |
| 33 | - $userModel = UserModel::find( $user->get_id(), true ); | |
| 34 | - // Display cover image | |
| 35 | - echo ProfileTemplate::instance()->html_cover_image( $userModel ); | |
| 36 | - // Display Sidebar | |
| 37 | - learn_press_get_template( 'profile/sidebar.php' ); | |
| 38 | - } | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * @param LP_Profile $profile | |
| 42 | - * | |
| 43 | - * @since 3.0.0 | |
| 44 | - * @version 1.0.1 | |
| 45 | - */ | |
| 46 | - public function content( LP_Profile $profile ) { | |
| 47 | - $user = $profile->get_user(); | |
| 48 | - $current_tab = $profile->get_current_tab(); | |
| 49 | - $user_can_view = $profile->current_user_can( 'view-tab-' . $current_tab ); | |
| 50 | - if ( ! $user_can_view ) { | |
| 51 | - return; | |
| 52 | - } | |
| 53 | - | |
| 54 | - if ( $profile->get_user_current()->is_guest() ) { | |
| 55 | - return; | |
| 56 | - } | |
| 57 | - | |
| 58 | - $tabs = $profile->get_tabs(); | |
| 59 | - $tab_key = $profile->get_current_tab(); | |
| 60 | - $profile_tab = $tabs->get( $tab_key ); | |
| 61 | - | |
| 62 | - learn_press_get_template( 'profile/content.php', compact( 'user', 'profile_tab', 'tab_key', 'profile' ) ); | |
| 63 | - } | |
| 64 | - | |
| 65 | - /** | |
| 66 | - * Display avatar | |
| 67 | - * | |
| 68 | - * @return void | |
| 69 | - * @version 1.0.1 | |
| 70 | - * @since 3.x.x | |
| 71 | - */ | |
| 72 | - public function avatar() { | |
| 73 | - $lp_profile = LP_Profile::instance(); | |
| 74 | - $user = $lp_profile->get_user(); | |
| 75 | - $userModel = UserModel::find( $user->get_id(), true ); | |
| 76 | - if ( ! $userModel instanceof UserModel ) { | |
| 77 | - return; | |
| 78 | - } | |
| 79 | - | |
| 80 | - $userTemplate = new UserTemplate(); | |
| 81 | - echo $userTemplate->html_avatar_edit( $userModel ); | |
| 82 | - //learn_press_get_template( 'profile/avatar.php' ); | |
| 83 | - } | |
| 84 | - | |
| 85 | - public function socials() { | |
| 86 | - learn_press_get_template( 'profile/socials.php' ); | |
| 87 | - } | |
| 88 | - | |
| 89 | - public function tabs( $user = null ) { | |
| 90 | - $profile = LP_Profile::instance(); | |
| 91 | - if ( $profile->get_user_current()->is_guest() ) { | |
| 92 | - return; | |
| 93 | - } | |
| 94 | - | |
| 95 | - learn_press_get_template( 'profile/tabs.php', compact( 'user', 'profile' ) ); | |
| 96 | - } | |
| 97 | - | |
| 98 | - /** | |
| 99 | - * Get template tab course | |
| 100 | - * | |
| 101 | - * @return void | |
| 102 | - * @since 4.1.5 | |
| 103 | - * @version 1.0.0 | |
| 104 | - * @author tungnx | |
| 105 | - */ | |
| 106 | - public static function tab_courses() { | |
| 107 | - if ( ! LP_Profile::instance()->current_user_can( 'view-tab-courses' ) ) { | |
| 108 | - return; | |
| 109 | - } | |
| 110 | - | |
| 111 | - $user = LP_Profile::instance()->get_user(); | |
| 112 | - | |
| 113 | - $courses_created_tab = apply_filters( | |
| 114 | - 'lp/profile/user_courses_created/subtask', | |
| 115 | - array( | |
| 116 | - '' => esc_html__( 'All', 'learnpress' ), | |
| 117 | - 'publish' => esc_html__( 'Publish', 'learnpress' ), | |
| 118 | - 'pending' => esc_html__( 'Pending', 'learnpress' ), | |
| 119 | - ) | |
| 120 | - ); | |
| 121 | - | |
| 122 | - $args_query_user_courses_created = apply_filters( | |
| 123 | - 'lp/profile/args/user_courses_created', | |
| 124 | - array( | |
| 125 | - 'userID' => $user->get_id(), | |
| 126 | - 'query' => 'own', | |
| 127 | - ) | |
| 128 | - ); | |
| 129 | - | |
| 130 | - $args_query_user_courses_statistic = apply_filters( | |
| 131 | - 'lp/profile/args/user_courses_statistic', | |
| 132 | - array( | |
| 133 | - 'userID' => $user->get_id(), | |
| 134 | - ) | |
| 135 | - ); | |
| 136 | - | |
| 137 | - do_action( | |
| 138 | - 'learn-press/profile/layout/courses', | |
| 139 | - compact( | |
| 140 | - 'user', | |
| 141 | - 'courses_created_tab', | |
| 142 | - 'args_query_user_courses_created', | |
| 143 | - 'args_query_user_courses_statistic' | |
| 144 | - ) | |
| 145 | - ); | |
| 146 | - } | |
| 147 | - | |
| 148 | - public static function tab_my_courses() { | |
| 149 | - if ( ! LP_Profile::instance()->current_user_can( 'view-tab-my-courses' ) ) { | |
| 150 | - return; | |
| 151 | - } | |
| 152 | - | |
| 153 | - $user = LP_Profile::instance()->get_user(); | |
| 154 | - | |
| 155 | - $courses_enrolled_tab = apply_filters( | |
| 156 | - 'lp/profile/user_courses_attend/subtask', | |
| 157 | - array( | |
| 158 | - '' => esc_html__( 'All', 'learnpress' ), | |
| 159 | - 'in-progress' => esc_html__( 'In Progress', 'learnpress' ), | |
| 160 | - 'finished' => esc_html__( 'Finished', 'learnpress' ), | |
| 161 | - 'passed' => esc_html__( 'Passed', 'learnpress' ), | |
| 162 | - 'failed' => esc_html__( 'Failed', 'learnpress' ), | |
| 163 | - ) | |
| 164 | - ); | |
| 165 | - | |
| 166 | - $courses_enrolled_tab_active = apply_filters( 'learnpress/profile/tab/enrolled/subtab-active', ! learn_press_user_maybe_is_a_teacher() ? 'in-progress' : '' ); | |
| 167 | - | |
| 168 | - $args_query_user_courses_attend = apply_filters( | |
| 169 | - 'lp/profile/args/user_courses_attend', | |
| 170 | - array( | |
| 171 | - 'userID' => $user->get_id(), | |
| 172 | - 'query' => 'purchased', | |
| 173 | - 'layout' => 'list', | |
| 174 | - ) | |
| 175 | - ); | |
| 176 | - $args_query_user_courses_statistic = apply_filters( | |
| 177 | - 'lp/profile/args/user_courses_statistic', | |
| 178 | - array( | |
| 179 | - 'userID' => $user->get_id(), | |
| 180 | - ) | |
| 181 | - ); | |
| 182 | - | |
| 183 | - learn_press_get_template( | |
| 184 | - 'profile/tabs/my_courses', | |
| 185 | - compact( | |
| 186 | - 'user', | |
| 187 | - 'courses_enrolled_tab', | |
| 188 | - 'courses_enrolled_tab_active', | |
| 189 | - 'args_query_user_courses_attend', | |
| 190 | - 'args_query_user_courses_statistic' | |
| 191 | - ) | |
| 192 | - ); | |
| 193 | - } | |
| 194 | - | |
| 195 | - /** | |
| 196 | - * Display tab avatar image | |
| 197 | - * | |
| 198 | - * @return void | |
| 199 | - * @since 4.2.8.2 | |
| 200 | - * @version 1.0.0 | |
| 201 | - */ | |
| 202 | - public static function tab_avatar() { | |
| 203 | - if ( ! LP_Profile::instance()->current_user_can( 'view-tab-avatar' ) ) { | |
| 204 | - return; | |
| 205 | - } | |
| 206 | - | |
| 207 | - $user = LP_Profile::instance()->get_user(); | |
| 208 | - $userModel = UserModel::find( $user->get_id(), true ); | |
| 209 | - if ( ! $userModel ) { | |
| 210 | - return; | |
| 211 | - } | |
| 212 | - | |
| 213 | - echo ProfileTemplate::instance()->html_upload_avatar( $userModel ); | |
| 214 | - } | |
| 215 | - | |
| 216 | - /** | |
| 217 | - * Display tab cover image | |
| 218 | - * | |
| 219 | - * @return void | |
| 220 | - * @since 4.2.7.2 | |
| 221 | - * @version 1.0.0 | |
| 222 | - */ | |
| 223 | - public static function tab_cover_image() { | |
| 224 | - if ( ! LP_Profile::instance()->current_user_can( 'view-tab-cover-image' ) ) { | |
| 225 | - return; | |
| 226 | - } | |
| 227 | - | |
| 228 | - $user = LP_Profile::instance()->get_user(); | |
| 229 | - $userModel = UserModel::find( $user->get_id(), true ); | |
| 230 | - if ( ! $userModel ) { | |
| 231 | - return; | |
| 232 | - } | |
| 233 | - | |
| 234 | - echo ProfileTemplate::instance()->html_upload_cover_image( $userModel ); | |
| 235 | - } | |
| 236 | - | |
| 237 | - /** | |
| 238 | - * @deprecated v4.3.2.6 | |
| 239 | - */ | |
| 240 | - public function order_details() { | |
| 241 | - _deprecated_function( __METHOD__, '4.3.2.6' ); | |
| 242 | - return; | |
| 243 | - | |
| 244 | - $profile = LP_Profile::instance(); | |
| 245 | - $order = $profile->get_view_order(); | |
| 246 | - if ( false === $order ) { | |
| 247 | - return; | |
| 248 | - } | |
| 249 | - | |
| 250 | - learn_press_get_template( 'order/order-details.php', array( 'order' => $order ) ); | |
| 251 | - } | |
| 252 | - | |
| 253 | - public function order_recover() { | |
| 254 | - $profile = LP_Profile::instance(); | |
| 255 | - $order = $profile->get_view_order(); | |
| 256 | - | |
| 257 | - if ( false === $order ) { | |
| 258 | - return; | |
| 259 | - } | |
| 260 | - | |
| 261 | - //learn_press_get_template( 'profile/tabs/orders/recover-my-order.php', array( 'order' => $order ) ); | |
| 262 | - } | |
| 263 | - | |
| 264 | - public function order_message() { | |
| 265 | - $profile = LP_Profile::instance(); | |
| 266 | - $order = $profile->get_view_order(); | |
| 267 | - | |
| 268 | - if ( false === $order ) { | |
| 269 | - return; | |
| 270 | - } | |
| 271 | - | |
| 272 | - learn_press_get_template( 'profile/tabs/orders/order-message.php', array( 'order' => $order ) ); | |
| 273 | - } | |
| 274 | - | |
| 275 | - public function dashboard_not_logged_in() { | |
| 276 | - if ( is_user_logged_in() ) { | |
| 277 | - return; | |
| 278 | - } | |
| 279 | - | |
| 280 | - if ( ! LP_Profile::instance()->get_user()->is_guest() ) { | |
| 281 | - return; | |
| 282 | - } | |
| 283 | - | |
| 284 | - if ( 'yes' === LP_Settings::get_option( 'enable_login_profile' ) ) { | |
| 285 | - return; | |
| 286 | - } | |
| 287 | - | |
| 288 | - learn_press_get_template( 'profile/not-logged-in.php' ); | |
| 289 | - } | |
| 290 | - | |
| 291 | - public function login_form() { | |
| 292 | - if ( is_user_logged_in() && ! LP_Page_Controller::is_page_profile() ) { | |
| 293 | - Template::print_message( | |
| 294 | - esc_html__( 'You are already logged in.', 'learnpress' ) | |
| 295 | - ); | |
| 296 | - return; | |
| 297 | - } | |
| 298 | - | |
| 299 | - if ( ! LP_Profile::instance()->get_user()->is_guest() ) { | |
| 300 | - return; | |
| 301 | - } | |
| 302 | - | |
| 303 | - if ( 'yes' !== LP_Settings::get_option( 'enable_login_profile', 'no' ) ) { | |
| 304 | - return; | |
| 305 | - } | |
| 306 | - | |
| 307 | - learn_press_get_template( 'global/form-login.php' ); | |
| 308 | - } | |
| 309 | - | |
| 310 | - public function register_form() { | |
| 311 | - if ( is_user_logged_in() ) { | |
| 312 | - return; | |
| 313 | - } | |
| 314 | - | |
| 315 | - if ( ! LP_Profile::instance()->get_user()->is_guest() ) { | |
| 316 | - return; | |
| 317 | - } | |
| 318 | - | |
| 319 | - if ( 'yes' !== LP_Settings::get_option( 'enable_register_profile' ) || ! get_option( 'users_can_register' ) ) { | |
| 320 | - return; | |
| 321 | - } | |
| 322 | - | |
| 323 | - learn_press_get_template( 'global/form-register.php' ); | |
| 324 | - } | |
| 325 | -} | |
| 326 | - | |
| 327 | -return new LP_Template_Profile(); | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +use LearnPress\Helpers\Template; | |
| 4 | +use LearnPress\Models\UserModel; | |
| 5 | +use LearnPress\TemplateHooks\Instructor\SingleInstructorTemplate; | |
| 6 | +use LearnPress\TemplateHooks\Profile\ProfileTemplate; | |
| 7 | +use LearnPress\TemplateHooks\UserTemplate; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * Class LP_Profile_Template | |
| 11 | + * | |
| 12 | + * Group templates related user profile. | |
| 13 | + * | |
| 14 | + * @since 4.0.0 | |
| 15 | + */ | |
| 16 | +class LP_Template_Profile extends LP_Abstract_Template { | |
| 17 | + public function header( $user ) { | |
| 18 | + learn_press_get_template( 'profile/header.php', array( 'user' => $user ) ); | |
| 19 | + } | |
| 20 | + | |
| 21 | + public function sidebar() { | |
| 22 | + $profile = LP_Profile::instance(); | |
| 23 | + if ( $profile->get_user()->is_guest() ) { | |
| 24 | + return; | |
| 25 | + } | |
| 26 | + | |
| 27 | + if ( $profile->get_user_current()->is_guest() | |
| 28 | + && 'yes' !== LP_Profile::get_option_publish_profile() ) { | |
| 29 | + return; | |
| 30 | + } | |
| 31 | + | |
| 32 | + $user = $profile->get_user(); | |
| 33 | + $userModel = UserModel::find( $user->get_id(), true ); | |
| 34 | + // Display cover image | |
| 35 | + echo ProfileTemplate::instance()->html_cover_image( $userModel ); | |
| 36 | + // Display Sidebar | |
| 37 | + learn_press_get_template( 'profile/sidebar.php' ); | |
| 38 | + } | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * @param LP_Profile $profile | |
| 42 | + * | |
| 43 | + * @since 3.0.0 | |
| 44 | + * @version 1.0.1 | |
| 45 | + */ | |
| 46 | + public function content( LP_Profile $profile ) { | |
| 47 | + $user = $profile->get_user(); | |
| 48 | + $current_tab = $profile->get_current_tab(); | |
| 49 | + $user_can_view = $profile->current_user_can( 'view-tab-' . $current_tab ); | |
| 50 | + if ( ! $user_can_view ) { | |
| 51 | + return; | |
| 52 | + } | |
| 53 | + | |
| 54 | + if ( $profile->get_user_current()->is_guest() ) { | |
| 55 | + return; | |
| 56 | + } | |
| 57 | + | |
| 58 | + $tabs = $profile->get_tabs(); | |
| 59 | + $tab_key = $profile->get_current_tab(); | |
| 60 | + $profile_tab = $tabs->get( $tab_key ); | |
| 61 | + | |
| 62 | + learn_press_get_template( 'profile/content.php', compact( 'user', 'profile_tab', 'tab_key', 'profile' ) ); | |
| 63 | + } | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * Display avatar | |
| 67 | + * | |
| 68 | + * @return void | |
| 69 | + * @version 1.0.1 | |
| 70 | + * @since 3.x.x | |
| 71 | + */ | |
| 72 | + public function avatar() { | |
| 73 | + $lp_profile = LP_Profile::instance(); | |
| 74 | + $user = $lp_profile->get_user(); | |
| 75 | + $userModel = UserModel::find( $user->get_id(), true ); | |
| 76 | + if ( ! $userModel instanceof UserModel ) { | |
| 77 | + return; | |
| 78 | + } | |
| 79 | + | |
| 80 | + $userTemplate = new UserTemplate(); | |
| 81 | + echo $userTemplate->html_avatar_edit( $userModel ); | |
| 82 | + //learn_press_get_template( 'profile/avatar.php' ); | |
| 83 | + } | |
| 84 | + | |
| 85 | + public function socials() { | |
| 86 | + learn_press_get_template( 'profile/socials.php' ); | |
| 87 | + } | |
| 88 | + | |
| 89 | + public function tabs( $user = null ) { | |
| 90 | + $profile = LP_Profile::instance(); | |
| 91 | + if ( $profile->get_user_current()->is_guest() ) { | |
| 92 | + return; | |
| 93 | + } | |
| 94 | + | |
| 95 | + learn_press_get_template( 'profile/tabs.php', compact( 'user', 'profile' ) ); | |
| 96 | + } | |
| 97 | + | |
| 98 | + /** | |
| 99 | + * Get template tab course | |
| 100 | + * | |
| 101 | + * @return void | |
| 102 | + * @since 4.1.5 | |
| 103 | + * @version 1.0.0 | |
| 104 | + * @author tungnx | |
| 105 | + */ | |
| 106 | + public static function tab_courses() { | |
| 107 | + if ( ! LP_Profile::instance()->current_user_can( 'view-tab-courses' ) ) { | |
| 108 | + return; | |
| 109 | + } | |
| 110 | + | |
| 111 | + $user = LP_Profile::instance()->get_user(); | |
| 112 | + | |
| 113 | + $courses_created_tab = apply_filters( | |
| 114 | + 'lp/profile/user_courses_created/subtask', | |
| 115 | + array( | |
| 116 | + '' => esc_html__( 'All', 'learnpress' ), | |
| 117 | + 'publish' => esc_html__( 'Publish', 'learnpress' ), | |
| 118 | + 'pending' => esc_html__( 'Pending', 'learnpress' ), | |
| 119 | + ) | |
| 120 | + ); | |
| 121 | + | |
| 122 | + $args_query_user_courses_created = apply_filters( | |
| 123 | + 'lp/profile/args/user_courses_created', | |
| 124 | + array( | |
| 125 | + 'userID' => $user->get_id(), | |
| 126 | + 'query' => 'own', | |
| 127 | + ) | |
| 128 | + ); | |
| 129 | + | |
| 130 | + $args_query_user_courses_statistic = apply_filters( | |
| 131 | + 'lp/profile/args/user_courses_statistic', | |
| 132 | + array( | |
| 133 | + 'userID' => $user->get_id(), | |
| 134 | + ) | |
| 135 | + ); | |
| 136 | + | |
| 137 | + do_action( | |
| 138 | + 'learn-press/profile/layout/courses', | |
| 139 | + compact( | |
| 140 | + 'user', | |
| 141 | + 'courses_created_tab', | |
| 142 | + 'args_query_user_courses_created', | |
| 143 | + 'args_query_user_courses_statistic' | |
| 144 | + ) | |
| 145 | + ); | |
| 146 | + } | |
| 147 | + | |
| 148 | + public static function tab_my_courses() { | |
| 149 | + if ( ! LP_Profile::instance()->current_user_can( 'view-tab-my-courses' ) ) { | |
| 150 | + return; | |
| 151 | + } | |
| 152 | + | |
| 153 | + $user = LP_Profile::instance()->get_user(); | |
| 154 | + | |
| 155 | + $courses_enrolled_tab = apply_filters( | |
| 156 | + 'lp/profile/user_courses_attend/subtask', | |
| 157 | + array( | |
| 158 | + '' => esc_html__( 'All', 'learnpress' ), | |
| 159 | + 'in-progress' => esc_html__( 'In Progress', 'learnpress' ), | |
| 160 | + 'finished' => esc_html__( 'Finished', 'learnpress' ), | |
| 161 | + 'passed' => esc_html__( 'Passed', 'learnpress' ), | |
| 162 | + 'failed' => esc_html__( 'Failed', 'learnpress' ), | |
| 163 | + ) | |
| 164 | + ); | |
| 165 | + | |
| 166 | + $courses_enrolled_tab_active = apply_filters( 'learnpress/profile/tab/enrolled/subtab-active', ! learn_press_user_maybe_is_a_teacher() ? 'in-progress' : '' ); | |
| 167 | + | |
| 168 | + $args_query_user_courses_attend = apply_filters( | |
| 169 | + 'lp/profile/args/user_courses_attend', | |
| 170 | + array( | |
| 171 | + 'userID' => $user->get_id(), | |
| 172 | + 'query' => 'purchased', | |
| 173 | + 'layout' => 'list', | |
| 174 | + ) | |
| 175 | + ); | |
| 176 | + $args_query_user_courses_statistic = apply_filters( | |
| 177 | + 'lp/profile/args/user_courses_statistic', | |
| 178 | + array( | |
| 179 | + 'userID' => $user->get_id(), | |
| 180 | + ) | |
| 181 | + ); | |
| 182 | + | |
| 183 | + learn_press_get_template( | |
| 184 | + 'profile/tabs/my_courses', | |
| 185 | + compact( | |
| 186 | + 'user', | |
| 187 | + 'courses_enrolled_tab', | |
| 188 | + 'courses_enrolled_tab_active', | |
| 189 | + 'args_query_user_courses_attend', | |
| 190 | + 'args_query_user_courses_statistic' | |
| 191 | + ) | |
| 192 | + ); | |
| 193 | + } | |
| 194 | + | |
| 195 | + /** | |
| 196 | + * Display tab avatar image | |
| 197 | + * | |
| 198 | + * @return void | |
| 199 | + * @since 4.2.8.2 | |
| 200 | + * @version 1.0.0 | |
| 201 | + */ | |
| 202 | + public static function tab_avatar() { | |
| 203 | + if ( ! LP_Profile::instance()->current_user_can( 'view-tab-avatar' ) ) { | |
| 204 | + return; | |
| 205 | + } | |
| 206 | + | |
| 207 | + $user = LP_Profile::instance()->get_user(); | |
| 208 | + $userModel = UserModel::find( $user->get_id(), true ); | |
| 209 | + if ( ! $userModel ) { | |
| 210 | + return; | |
| 211 | + } | |
| 212 | + | |
| 213 | + echo ProfileTemplate::instance()->html_upload_avatar( $userModel ); | |
| 214 | + } | |
| 215 | + | |
| 216 | + /** | |
| 217 | + * Display tab cover image | |
| 218 | + * | |
| 219 | + * @return void | |
| 220 | + * @since 4.2.7.2 | |
| 221 | + * @version 1.0.0 | |
| 222 | + */ | |
| 223 | + public static function tab_cover_image() { | |
| 224 | + if ( ! LP_Profile::instance()->current_user_can( 'view-tab-cover-image' ) ) { | |
| 225 | + return; | |
| 226 | + } | |
| 227 | + | |
| 228 | + $user = LP_Profile::instance()->get_user(); | |
| 229 | + $userModel = UserModel::find( $user->get_id(), true ); | |
| 230 | + if ( ! $userModel ) { | |
| 231 | + return; | |
| 232 | + } | |
| 233 | + | |
| 234 | + echo ProfileTemplate::instance()->html_upload_cover_image( $userModel ); | |
| 235 | + } | |
| 236 | + | |
| 237 | + /** | |
| 238 | + * @deprecated v4.3.2.6 | |
| 239 | + */ | |
| 240 | + public function order_details() { | |
| 241 | + _deprecated_function( __METHOD__, '4.3.2.6' ); | |
| 242 | + return; | |
| 243 | + | |
| 244 | + $profile = LP_Profile::instance(); | |
| 245 | + $order = $profile->get_view_order(); | |
| 246 | + if ( false === $order ) { | |
| 247 | + return; | |
| 248 | + } | |
| 249 | + | |
| 250 | + learn_press_get_template( 'order/order-details.php', array( 'order' => $order ) ); | |
| 251 | + } | |
| 252 | + | |
| 253 | + public function order_recover() { | |
| 254 | + $profile = LP_Profile::instance(); | |
| 255 | + $order = $profile->get_view_order(); | |
| 256 | + | |
| 257 | + if ( false === $order ) { | |
| 258 | + return; | |
| 259 | + } | |
| 260 | + | |
| 261 | + //learn_press_get_template( 'profile/tabs/orders/recover-my-order.php', array( 'order' => $order ) ); | |
| 262 | + } | |
| 263 | + | |
| 264 | + public function order_message() { | |
| 265 | + $profile = LP_Profile::instance(); | |
| 266 | + $order = $profile->get_view_order(); | |
| 267 | + | |
| 268 | + if ( false === $order ) { | |
| 269 | + return; | |
| 270 | + } | |
| 271 | + | |
| 272 | + learn_press_get_template( 'profile/tabs/orders/order-message.php', array( 'order' => $order ) ); | |
| 273 | + } | |
| 274 | + | |
| 275 | + public function dashboard_not_logged_in() { | |
| 276 | + if ( is_user_logged_in() ) { | |
| 277 | + return; | |
| 278 | + } | |
| 279 | + | |
| 280 | + if ( ! LP_Profile::instance()->get_user()->is_guest() ) { | |
| 281 | + return; | |
| 282 | + } | |
| 283 | + | |
| 284 | + if ( 'yes' === LP_Settings::get_option( 'enable_login_profile' ) ) { | |
| 285 | + return; | |
| 286 | + } | |
| 287 | + | |
| 288 | + learn_press_get_template( 'profile/not-logged-in.php' ); | |
| 289 | + } | |
| 290 | + | |
| 291 | + public function login_form() { | |
| 292 | + if ( is_user_logged_in() && ! LP_Page_Controller::is_page_profile() ) { | |
| 293 | + Template::print_message( | |
| 294 | + esc_html__( 'You are already logged in.', 'learnpress' ) | |
| 295 | + ); | |
| 296 | + return; | |
| 297 | + } | |
| 298 | + | |
| 299 | + if ( ! LP_Profile::instance()->get_user()->is_guest() ) { | |
| 300 | + return; | |
| 301 | + } | |
| 302 | + | |
| 303 | + if ( 'yes' !== LP_Settings::get_option( 'enable_login_profile', 'no' ) ) { | |
| 304 | + return; | |
| 305 | + } | |
| 306 | + | |
| 307 | + learn_press_get_template( 'global/form-login.php' ); | |
| 308 | + } | |
| 309 | + | |
| 310 | + public function register_form() { | |
| 311 | + if ( is_user_logged_in() ) { | |
| 312 | + return; | |
| 313 | + } | |
| 314 | + | |
| 315 | + if ( ! LP_Profile::instance()->get_user()->is_guest() ) { | |
| 316 | + return; | |
| 317 | + } | |
| 318 | + | |
| 319 | + if ( 'yes' !== LP_Settings::get_option( 'enable_register_profile' ) || ! get_option( 'users_can_register' ) ) { | |
| 320 | + return; | |
| 321 | + } | |
| 322 | + | |
| 323 | + learn_press_get_template( 'global/form-register.php' ); | |
| 324 | + } | |
| 325 | +} | |
| 326 | + | |
| 327 | +return new LP_Template_Profile(); | |