PluginProbe
Borderless – Addons and Templates for Elementor / 1.6.1
Borderless – Addons and Templates for Elementor v1.6.1
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 1.6.1, at includes/templates/dashboard.php

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