PluginProbe
WP-Stateless – Google Cloud Storage / 3.0.3
WP-Stateless – Google Cloud Storage v3.0.3
4.4.3 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.3.0 2.3.1 2.3.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 All 62 releases
wp-stateless / vendor / udx / lib-wp-bootstrap / lib / classes / class-dashboard.php

class-dashboard.php in WP-Stateless – Google Cloud Storage 3.0.3, at vendor/udx/lib-wp-bootstrap/lib/classes/class-dashboard.php

129 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Usability Dynamics Dashboard.
4 *
5 * @namespace UsabilityDynamics
6 */
7 namespace UsabilityDynamics\WP {
8
9 if( !class_exists( 'UsabilityDynamics\WP\Dashboard' ) ) {
10
11 /**
12 * UD Plugins/Themes dashboard
13 *
14 * @author korotkov@ud
15 */
16 class Dashboard extends Scaffold {
17
18 /**
19 * Singleton instance
20 *
21 * @var type
22 */
23 static $instance = null;
24
25 /**
26 * Dashboard page slug
27 *
28 * @var string
29 */
30 public $page_slug = 'ud-splash';
31
32 /**
33 * Need splash key
34 *
35 * @var string
36 */
37 public $need_splash_key = 'ud_need_splash';
38
39 /**
40 * Transient key
41 *
42 * @var string
43 */
44 public $transient_key = 'ud_splash_dashboard';
45
46 /**
47 * Singleton
48 *
49 * @return object
50 */
51 static function get_instance() {
52 return self::$instance ? self::$instance : self::$instance = new Dashboard();
53 }
54
55 /**
56 * Maybe redirect to UD Splash Page
57 *
58 * @author korotkov@ud
59 */
60 public function maybe_ud_splash_page() {
61 //** If there is something to show */
62 if ( get_transient( $this->need_splash_key ) && ( !isset( $_REQUEST['page'] ) || $_REQUEST['page'] !== $this->page_slug ) ) {
63 //** Do not redirect anymore */
64 delete_transient( $this->need_splash_key );
65 //** Redirect to UD splash page */
66 wp_redirect( admin_url( 'index.php?page='.$this->page_slug ) );
67 exit;
68 }
69 }
70
71 /**
72 * Register fake page
73 *
74 * @return null
75 */
76 public function add_ud_splash_page() {
77 if ( empty( $_GET['page'] ) ) {
78 return;
79 }
80 if ( $_GET['page'] == $this->page_slug ) {
81 add_dashboard_page( __( 'Welcome to Usability Dynamics, Inc.', $this->domain ), __( 'Welcome', $this->domain ), 'manage_options', $this->page_slug, array( $this, 'ud_splash_page' ) );
82 }
83 }
84
85 /**
86 * Render UD dashboard page
87 *
88 * @author korotkov@ud
89 */
90 public function ud_splash_page() {
91 //** Try to get information to show */
92 $updates = get_transient( $this->transient_key );
93 ?>
94 <div class="wrap about-wrap">
95 <h1><?php _e( 'Usability Dynamics, Inc.', $this->domain ) ?></h1>
96 <div class="about-text"><?php _e( 'Thank you for using our products.', $this->domain ) ?></div>
97 <div class="wp-badge ud-badge"></div>
98 <?php
99 //** If user visited this page directly */
100 if ( !$updates ) {
101 echo '<h2>Keep it up! There are no notices for you in the moment.</h2>';
102
103 //** in other case - show corresponding predefined template if it exists*/
104 } else {
105 foreach( $updates as $key => $page_data ) {
106 update_option( $key . '-splash-version', $page_data['version'] );
107 if ( file_exists( $page_data['content'] ) ) {
108 include $page_data['content'];
109 }
110 }
111 }
112
113
114 ?>
115
116 <div class="return-to-dashboard">
117 <a href="<?php echo esc_url( self_admin_url() ); ?>"><?php is_blog_admin() ? _e( 'Go to Dashboard &rarr; Home' ) : _e( 'Go to Dashboard' ); ?></a>
118 </div>
119
120 </div>
121 <?php
122 delete_transient( $this->need_splash_key );
123 }
124
125 }
126
127 }
128 }
129