PluginProbe
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More / 2.2.0
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More v2.2.0
2.3.0 2.2.0 2.1.1 2.1.0 2.0.0 1.10.0 1.9.1 1.9.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 All 59 releases
storeengine / includes / shortcode / frontend-dashboard.php

frontend-dashboard.php in StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More 2.2.0, at includes/shortcode/frontend-dashboard.php

48 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace StoreEngine\Shortcode;
4
5 use StoreEngine\Utils\Helper;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit();
9 }
10
11 class FrontendDashboard {
12 public function __construct() {
13 add_shortcode( 'storeengine_dashboard', array( $this, 'frontend_dashboard' ) );
14 }
15 public function frontend_dashboard() {
16 ob_start();
17
18 do_action( 'storeengine/shortcode/before_storeengine_dashboard' );
19
20 if ( ! is_user_logged_in() ) {
21 // Some endpoints (e.g. `forgot-password`) are intentionally
22 // reachable by logged-out visitors and need their own template
23 // to render — falling back to the login form here would
24 // effectively hijack those URLs.
25 //
26 // sanitize_key() before splicing into the action name: even
27 // though the array lookup already constrains $endpoint to known
28 // menu keys, feeding an unsanitized query var into do_action()'s
29 // hook name is fragile (a weird query string could produce a
30 // hook name with quotes/whitespace). Same defensive treatment
31 // the standard router applies in functions.php:794.
32 $endpoint = sanitize_key( (string) get_query_var( 'storeengine_dashboard_page' ) );
33 $items = Helper::get_frontend_dashboard_menu_items();
34 if ( $endpoint && ! empty( $items[ $endpoint ]['guest_accessible'] ) ) {
35 do_action( 'storeengine/frontend/dashboard_' . $endpoint . '_endpoint', get_query_var( 'storeengine_dashboard_sub_page' ) );
36 } else {
37 echo do_shortcode( '[storeengine_login_form]' );
38 }
39 } else {
40 Helper::get_template( 'shortcode/frontend-dashboard.php' );
41 }
42
43 do_action( 'storeengine/shortcode/after_storeengine_dashboard' );
44
45 return apply_filters( 'storeengine/templates/shortcode/dashboard', Helper::remove_tag_space( Helper::remove_line_break( ob_get_clean() ) ) );
46 }
47 }
48