-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
~ Added: ProfileOrderTemplate class. ~ Added: get_tabs_arr method on LP_Profile class. ~ Deprecated: learn_press_get_profile_endpoints function. ~ Security: check permission view order detail on Profile.
- Loading branch information
Showing
14 changed files
with
219 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
/** | ||
* Profile tabs | ||
* | ||
* @since 4.2.6.4 | ||
* @version 1.0.0 | ||
*/ | ||
|
||
use LearnPress\TemplateHooks\Profile\ProfileOrdersTemplate; | ||
use LearnPress\TemplateHooks\Profile\ProfileOrderTemplate; | ||
|
||
$settings = LP_Settings::instance(); | ||
$default_settings = array( | ||
'courses' => array( | ||
'title' => esc_html__( 'Courses', 'learnpress' ), | ||
'slug' => $settings->get( 'profile_endpoints.courses', 'courses' ), | ||
'callback' => array( LP_Template_Profile::class, 'tab_courses' ), | ||
'priority' => 1, | ||
'icon' => '<i class="fas fa-book-open"></i>', | ||
), | ||
'my-courses' => array( | ||
'title' => esc_html__( 'My Courses', 'learnpress' ), | ||
'slug' => $settings->get( 'profile_endpoints.my-courses', 'my-courses' ), | ||
'callback' => array( LP_Template_Profile::class, 'tab_my_courses' ), | ||
'priority' => 1, | ||
'icon' => '<i class="fas fa-bars"></i>', | ||
), | ||
'quizzes' => array( | ||
'title' => esc_html__( 'Quizzes', 'learnpress' ), | ||
'slug' => $settings->get( 'profile_endpoints.quizzes', 'quizzes' ), | ||
'callback' => false, | ||
'priority' => 20, | ||
'icon' => '<i class="fas fa-puzzle-piece"></i>', | ||
), | ||
'orders' => array( | ||
'title' => esc_html__( 'Orders', 'learnpress' ), | ||
'slug' => $settings->get( 'profile_endpoints.orders', 'orders' ), | ||
'callback' => [ ProfileOrdersTemplate::class, 'tab_content' ], | ||
'priority' => 25, | ||
'icon' => '<i class="fas fa-shopping-cart"></i>', | ||
), | ||
'order-details' => array( | ||
'title' => esc_html__( 'Order details', 'learnpress' ), | ||
'slug' => $settings->get( 'profile_endpoints.order-details', 'order-details' ), | ||
'hidden' => true, | ||
'callback' => [ ProfileOrderTemplate::class, 'content' ], | ||
'priority' => 30, | ||
), | ||
'settings' => array( | ||
'title' => esc_html__( 'Settings', 'learnpress' ), | ||
'slug' => $settings->get( 'profile_endpoints.settings', 'settings' ), | ||
'callback' => false, | ||
'sections' => array( | ||
'basic-information' => array( | ||
'title' => esc_html__( 'General', 'learnpress' ), | ||
'slug' => $settings->get( 'profile_endpoints.settings-basic-information', 'basic-information' ), | ||
'callback' => false, | ||
'priority' => 10, | ||
'icon' => '<i class="fas fa-home"></i>', | ||
), | ||
'avatar' => array( | ||
'title' => esc_html__( 'Avatar', 'learnpress' ), | ||
'callback' => false, | ||
'slug' => $settings->get( 'profile_endpoints.settings-avatar', 'avatar' ), | ||
'priority' => 20, | ||
'icon' => '<i class="fas fa-user-circle"></i>', | ||
), | ||
'change-password' => array( | ||
'title' => esc_html__( 'Password', 'learnpress' ), | ||
'slug' => $settings->get( 'profile_endpoints.settings-change-password', 'change-password' ), | ||
'callback' => false, | ||
'priority' => 30, | ||
'icon' => '<i class="fas fa-key"></i>', | ||
), | ||
), | ||
'priority' => 90, | ||
'icon' => '<i class="fas fa-cog"></i>', | ||
), | ||
'logout' => array( | ||
'title' => esc_html__( 'Logout', 'learnpress' ), | ||
'slug' => learn_press_profile_logout_slug(), | ||
'icon' => '<i class="fas fa-sign-out-alt"></i>', | ||
'priority' => 100, | ||
), | ||
); | ||
|
||
if ( 'yes' === LP_Profile::get_option_publish_profile() ) { | ||
$default_settings['settings']['sections']['privacy'] = array( | ||
'title' => esc_html__( 'Privacy', 'learnpress' ), | ||
'slug' => $settings->get( 'profile_endpoints.settings-privacy', 'privacy' ), | ||
'priority' => 40, | ||
'callback' => false, | ||
'icon' => '<i class="fas fa-user-secret"></i>', | ||
); | ||
} | ||
|
||
return apply_filters( 'learn-press/profile-tabs', $default_settings ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* Class ProfileOrdersTemplate. | ||
* | ||
* @since 4.2.6.4 | ||
* @version 1.0.0 | ||
*/ | ||
namespace LearnPress\TemplateHooks\Profile; | ||
|
||
use LP_Profile; | ||
|
||
class ProfileOrderTemplate { | ||
public static function instance() { | ||
static $instance = null; | ||
|
||
if ( is_null( $instance ) ) { | ||
$instance = new self(); | ||
} | ||
|
||
return $instance; | ||
} | ||
|
||
public static function content() { | ||
do_action( 'learn-press/profile/layout/order-detail' ); | ||
} | ||
|
||
protected function __construct() { | ||
add_action( 'learn-press/profile/layout/order-detail', [ $this, 'sections' ] ); | ||
} | ||
|
||
public static function init() { | ||
self::instance(); | ||
} | ||
|
||
public function sections() { | ||
$profile = LP_Profile::instance(); | ||
$order = $profile->get_view_order(); | ||
if ( false === $order ) { | ||
return; | ||
} | ||
|
||
$can_view = false; | ||
if ( current_user_can( ADMIN_ROLE )) { | ||
$can_view = true; | ||
} elseif ( (int) $order->get_user_id() === get_current_user_id() ) { | ||
$can_view = true; | ||
} | ||
|
||
if ( ! $can_view ) { | ||
return; | ||
} | ||
|
||
learn_press_get_template( 'order/order-details.php', compact( 'order' ) ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.