PluginProbe
Borderless – Addons and Templates for Elementor / trunk
Borderless – Addons and Templates for Elementor vtrunk
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 All 78 releases
borderless / includes / templates / dashboard.php

dashboard.php in Borderless – Addons and Templates for Elementor trunk, at includes/templates/dashboard.php

298 lines 11.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // don't load directly
4 defined( 'ABSPATH' ) || exit;
5
6
7 /*-----------------------------------------------------------------------------------*/
8 /* *. Borderless Dashboard
9 /*-----------------------------------------------------------------------------------*/
10
11 class Borderless_Dashboard {
12
13 public function __construct() {
14
15 add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
16 add_action( 'admin_init', array( $this, 'init_settings' ) );
17
18 }
19
20 public function add_admin_menu() {
21
22 add_menu_page(
23 esc_html__( 'Borderless', 'borderless' ),
24 esc_html__( 'Borderless', 'borderless' ),
25 'manage_options',
26 'borderless.php',
27 array( $this, 'page_layout' ),
28 BORDERLESS__URL . '/assets/img/borderless.svg',
29 3
30 );
31
32 add_submenu_page(
33 'borderless.php', // parent slug
34 esc_html__( 'Settings', 'borderless' ), // page title
35 esc_html__( 'Settings', 'borderless' ), // menu title
36 'manage_options', // capability
37 'borderless.php' // slug
38 );
39
40 add_menu_page(
41 esc_html__( 'Post Types', 'borderless' ),
42 esc_html__( 'Post Types', 'borderless' ),
43 'manage_options',
44 'edit.php?post_type=borderless_cpt',
45 '',
46 BORDERLESS__URL . '/assets/img/post-type.svg',
47 3.1
48 );
49
50 add_menu_page(
51 esc_html__( 'Templates Library', 'borderless' ),
52 esc_html__( 'Templates Library', 'borderless' ),
53 'manage_options',
54 'admin.php?page=borderless-library',
55 '',
56 BORDERLESS__URL . '/assets/img/library.svg',
57 3.2
58 );
59
60 add_action('admin_enqueue_scripts', 'borderless_dashboard_style');
61
62
63 function borderless_dashboard_style($hook)
64 {
65
66 $current_screen = get_current_screen();
67
68 if ( strpos($current_screen->base, 'toplevel_page_borderless') === false) {
69 return;
70 } else {
71
72 wp_enqueue_style('borderless_backend_style', BORDERLESS__URL . '/assets/styles/dashboard.min.css', array(), BORDERLESS__VERSION );
73 }
74 }
75
76 add_action( 'admin_menu', 'borderless_icon_fonts_submenu', 50 );
77
78 if ( ! function_exists( 'borderless_icon_fonts_submenu' ) ) {
79 function borderless_icon_fonts_submenu() {
80 $icon_manager_page = add_submenu_page(
81 'borderless.php',
82 esc_html__( "Icon Fonts", "borderless" ),
83 esc_html__( "Icon Fonts", "borderless" ),
84 'manage_options',
85 'borderless-fonts',
86 'borderless_custom_icons_menu'
87 );
88 $Borderless_IF = new Borderless_IF;
89 add_action('admin_print_styles-' . $icon_manager_page, array( $Borderless_IF, 'admin_scripts' ) );
90 }
91 }
92
93 add_submenu_page(
94 'borderless.php',
95 esc_html__( 'System Info', 'borderless' ),
96 esc_html__( 'System Info', 'borderless' ),
97 'manage_options',
98 'borderless-system-info',
99 'Borderless_System_Info',
100 99
101 );
102
103 }
104
105 public function init_settings() {
106
107 register_setting(
108 'settings_group',
109 'borderless'
110 );
111
112 add_settings_section(
113 'borderless_section',
114 '',
115 false,
116 'borderless'
117 );
118
119 add_settings_field(
120 'primary_color',
121 __( 'Primary Color', 'borderless' ),
122 array( $this, 'render_primary_color_field' ),
123 'borderless',
124 'borderless_section'
125 );
126 add_settings_field(
127 'secondary_color',
128 __( 'Secondary Color', 'borderless' ),
129 array( $this, 'render_secondary_color_field' ),
130 'borderless',
131 'borderless_section'
132 );
133 add_settings_field(
134 'tertiary_color',
135 __( 'Tertiary Color', 'borderless' ),
136 array( $this, 'render_tertiary_color_field' ),
137 'borderless',
138 'borderless_section'
139 );
140 add_settings_field(
141 'text_color',
142 __( 'Text Color', 'borderless' ),
143 array( $this, 'render_text_color_field' ),
144 'borderless',
145 'borderless_section'
146 );
147 add_settings_field(
148 'related_posts',
149 __( 'Related Posts', 'borderless' ),
150 array( $this, 'render_related_posts_field' ),
151 'borderless',
152 'borderless_section'
153 );
154
155 }
156
157 public function page_layout() {
158
159 // Check required user capability
160 if ( !current_user_can( 'manage_options' ) ) {
161 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'borderless' ) );
162 }
163
164 $current_user = wp_get_current_user();
165 $time = date('H');
166 $timezone = date('e');
167 $hi = __('Good Evening, ', 'borderless');
168 $avatar = wp_get_current_user();
169 if($time < '12'){
170 $hi = __('Good Morning, ', 'borderless');
171 }elseif($time >= '12' && $time < '17'){
172 $hi = __('Good Afternoon, ', 'borderless');
173 }
174
175 // Admin Page Layout
176
177 ?><div class="wrap borderless-page-welcome about-wrap">
178
179 <!-- Welcome to Borderless -->
180 <div class="borderless-dashboard-header">
181 <div class="borderless-dashboard-howdy">
182 <div class="borderless-dashboard-avatar"><?php echo get_avatar( $current_user->ID, 64 ); ?></div>
183 <div class="borderless-dashboard-title-subtitle">
184 <h1 class="borderless-dashboard-title"><?php echo $hi .'<strong>'.$current_user->display_name.'</strong>'; ?></h1>
185 <h2 class="borderless-dashboard-subtitle"><?php _e('You are running Borderless ', 'borderless'); echo BORDERLESS__VERSION; ?></h2>
186 </div>
187 </div>
188 <p class="about-text"><?php _e('Within minutes you can build complex layouts on the basis of our content elements and without touching a single line of code.', 'borderless') ?></p>
189 </div>
190 <div class="wp-badge borderless-page-logo">
191 <?php echo sprintf( __( 'Version %s', 'borderless' ), BORDERLESS__VERSION ) ?>
192 </div>
193 <p class="borderless-page-actions">
194 <a href="https://twitter.com/share" class="twitter-share-button"
195 data-via="visualmodo"
196 data-text="Take full control over your WordPress site with Borderless"
197 data-url="https://visualmodo.com" data-size="large">Tweet</a>
198 <script>! function ( d, s, id ) {
199 var js, fjs = d.getElementsByTagName( s )[ 0 ], p = /^http:/.test( d.location ) ? 'http' : 'https';
200 if ( ! d.getElementById( id ) ) {
201 js = d.createElement( s );
202 js.id = id;
203 js.src = p + '://platform.twitter.com/widgets.js';
204 fjs.parentNode.insertBefore( js, fjs );
205 }
206 }( document, 'script', 'twitter-wjs' );</script>
207 </p>
208
209 <?php
210 echo '<div class="borderless-dashboard-settings">' . "\n";
211 echo '<h3>Settings</h3>' . "\n";
212 echo ' <form action="options.php" method="post">' . "\n";
213
214 settings_fields( 'settings_group' );
215 do_settings_sections( 'borderless' );
216 submit_button();
217
218 echo '</form>' . "\n";
219 echo '</div>' . "\n";
220 echo '</div>' . "\n";
221
222 ?></div><?php
223
224 }
225
226 function render_primary_color_field() {
227
228 // Retrieve data from the database.
229 $options = get_option( 'borderless' );
230
231 // Set default value.
232 $value = isset( $options['primary_color'] ) ? $options['primary_color'] : '#0000FF';
233
234 // Field output.
235 echo '<input type="color" name="borderless[primary_color]" class="regular-text primary_color_field" placeholder="' . esc_attr__( '', 'borderless' ) . '" value="' . esc_attr( $value ) . '">';
236 echo '<span class="description">' . __( 'Pick a primary color for the elements.', 'borderless' ) . '</span>';
237
238 }
239
240 function render_secondary_color_field() {
241
242 // Retrieve data from the database.
243 $options = get_option( 'borderless' );
244
245 // Set default value.
246 $value = isset( $options['secondary_color'] ) ? $options['secondary_color'] : '#FF6819';
247
248 // Field output.
249 echo '<input type="color" name="borderless[secondary_color]" class="regular-text secondary_color_field" placeholder="' . esc_attr__( '', 'borderless' ) . '" value="' . esc_attr( $value ) . '">';
250 echo '<span class="description">' . __( 'Pick a secondary color for the elements.', 'borderless' ) . '</span>';
251
252 }
253
254 function render_tertiary_color_field() {
255
256 // Retrieve data from the database.
257 $options = get_option( 'borderless' );
258
259 // Set default value.
260 $value = isset( $options['tertiary_color'] ) ? $options['tertiary_color'] : '#3FCC14';
261
262 // Field output.
263 echo '<input type="color" name="borderless[tertiary_color]" class="regular-text tertiary_color_field" placeholder="' . esc_attr__( '', 'borderless' ) . '" value="' . esc_attr( $value ) . '">';
264 echo '<span class="description">' . __( 'Pick a tertiary color for the elements.', 'borderless' ) . '</span>';
265
266 }
267
268 function render_text_color_field() {
269
270 // Retrieve data from the database.
271 $options = get_option( 'borderless' );
272
273 // Set default value.
274 $value = isset( $options['text_color'] ) ? $options['text_color'] : '';
275
276 // Field output.
277 echo '<input type="color" name="borderless[text_color]" class="regular-text text_color_field" placeholder="' . esc_attr__( '', 'borderless' ) . '" value="' . esc_attr( $value ) . '">';
278 echo '<span class="description">' . __( 'Pick a text color for the elements.', 'borderless' ) . '</span>';
279
280 }
281
282 function render_related_posts_field() {
283
284 // Retrieve data from the database.
285 $options = get_option( 'borderless' );
286
287 // Set default value.
288 $value = isset( $options['related_posts'] ) ? $options['related_posts'] : '';
289
290 // Field output.
291 echo '<input type="checkbox" name="borderless[related_posts]" class="switch related_posts_field" value="checked" ' . checked( $value, 'checked', false ) . '> ' . __( '', 'borderless' );
292 echo '<span class="description">' . __( 'Related Posts.', 'borderless' ) . '</span>';
293
294 }
295
296 }
297
298 new Borderless_Dashboard;