PluginProbe
Ultimate Client Dash / 3.7
Ultimate Client Dash v3.7
trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.7.5 1.8 1.8.5 1.9 2.0 2.1 2.2 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 All 35 releases
ulimate-client-dash / include / plugin-functions.php

plugin-functions.php in Ultimate Client Dash 3.7, at include/plugin-functions.php

450 lines 16.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 // Function file that manages pro addons that use to be free.
5
6 require( plugin_dir_path( __FILE__ ) . '/addons/pro-addons.php');
7
8
9 // Upload Image Function
10
11 function ucd_load_media_files() {
12 wp_enqueue_media();
13 }
14 add_action( 'admin_enqueue_scripts', 'ucd_load_media_files' );
15
16
17 add_action( 'admin_init', 'ucd_main_register_options' );
18 function ucd_main_register_options() {
19 do_action( 'ucd_create_options' );
20 }
21
22
23 // Custom Message Template
24
25 function ucd_general_admin_notice(){
26 global $pagenow;
27 if ( $pagenow == 'index.php' ) {
28 echo '<div class="notice notice-info is-dismissible ucd-client-welcome">
29 <h1 class="title-background">' . get_option('ucd_message_title') . '</h1>
30 <div class="ucd-welcome-content">' . get_option( 'ucd_message_body' ) . '</div>
31 </div>';
32 }
33 }
34 add_action('admin_notices', 'ucd_general_admin_notice');
35
36
37 // Change Login Logo Styling
38
39 function ucd_login_logo() {
40 $brand_change_login = get_option('ucd_login_logo');
41 if (!empty($brand_change_login)) { ?>
42 <style type="text/css">
43 body.login div#login h1 a {
44 background-image: url(<?php echo get_option('ucd_login_logo') ?>);
45 background-size: contain!important;
46 background-repeat: no-repeat;
47 padding-bottom: 5px;
48 width: <?php echo get_option('ucd_logo_width') ?>!important;
49 height: <?php echo get_option('ucd_logo_height') ?>!important;
50 max-width: 320px!important;
51 }
52 .login h1 a {
53 background-size: contain!important;
54 background-repeat: no-repeat;
55 width: <?php echo get_option('ucd_logo_width') ?>!important;
56 height: <?php echo get_option('ucd_logo_height') ?>!important;
57 max-width: 320px!important;
58 }
59 </style>
60 <?php } else {}
61 }
62 add_action( 'login_enqueue_scripts', 'ucd_login_logo' );
63
64 function ucd_login_footer() { ?>
65 <style type="text/css" media="screen">
66 body {
67 background: <?php echo get_option('ucd_login_background_color') ?> !important;
68 background-image: url(<?php echo get_option('ucd_login_background_image') ?>)!important;
69 background-size: cover!important;
70 background-repeat: repeat;
71 }
72 input[type=text]:focus,
73 input[type=search]:focus,
74 input[type=radio]:focus,
75 input[type=tel]:focus,
76 input[type=time]:focus,
77 input[type=url]:focus,
78 input[type=week]:focus,
79 input[type=password]:focus,
80 input[type=checkbox]:focus,
81 input[type=color]:focus,
82 input[type=date]:focus,
83 input[type=datetime]:focus,
84 input[type=datetime-local]:focus,
85 input[type=email]:focus,
86 input[type=month]:focus,
87 input[type=number]:focus,
88 select:focus,
89 textarea:focus {
90 border-color: <?php echo get_option('ucd_dashboard_accent') ?> !important;
91 box-shadow: 0 0 2px <?php echo get_option('ucd_dashboard_accent') ?> !important;
92 }
93 <?php
94 $ucd_login_hide_password = get_option('ucd_login_hide_password_link');
95 if (!empty($ucd_login_hide_password)) { ?>
96 .login #nav {
97 display: none!important;
98 }
99 <?php } ?>
100 <?php
101 $ucd_login_hide_main_link = get_option('ucd_login_hide_main_site_link');
102 if (!empty($ucd_login_hide_main_link)) { ?>
103 .login #backtoblog a {
104 display: none!important;
105 }
106 <?php } ?>
107 #nav a, #backtoblog a, .privacy-policy-link {
108 color: <?php echo get_option('ucd_login_body_text_color') ?>!important;
109 }
110 .wp-core-ui .button-group.button-large .button, .wp-core-ui .button.button-large {
111 background: <?php echo get_option('ucd_dashboard_accent') ?> !important;
112 border-color: <?php echo get_option('ucd_dashboard_accent') ?> !important;
113 box-shadow: 0 1px 0 <?php echo get_option('ucd_dashboard_accent') ?> !important;
114 text-shadow: none!important;
115 }
116 body:before {
117 content: " ";
118 width: 100%;
119 height: 100%;
120 position: fixed;
121 z-index: -1;
122 top: 0;
123 left: 0;
124 background: <?php echo get_option('ucd_login_overlay_color') ?>;
125 opacity: <?php echo get_option('ucd_login_overlay_opacity') ?>;
126 }
127 .ucd-login-custom-content {
128 color: <?php echo get_option('ucd_login_body_text_color') ?>!important;
129 padding-top: 40px!important;
130 width: 320px!important;
131 margin: 0 auto!important;
132 display: block!important;
133 }
134 .ucd-login-custom-content a {
135 color: <?php echo get_option('ucd_login_body_text_color') ?>!important;
136 }
137 body.login div#login h1 a {
138 padding-bottom: <?php echo get_option('ucd_logo_padding_bottom') ?> !important;
139 }
140 </style>
141 <?php
142 }
143 add_action('login_footer', 'ucd_login_footer');
144
145
146 // Change login Logo url
147
148 function ucd_login_logo_url() {
149 $ucd_login_logo_url = get_option('ucd_login_logo_url');
150 if (!empty($ucd_login_logo_url)) {
151 return "$ucd_login_logo_url";
152 } else {
153 return home_url();
154 }
155 }
156 add_filter( 'login_headerurl', 'ucd_login_logo_url' );
157
158
159 // Change login logo title
160
161 function ucd_login_logo_url_title() {
162 $ucd_login_logo_title = get_option('ucd_login_logo_title');
163 if (!empty($ucd_login_logo_title)) {
164 return "$ucd_login_logo_title";
165 } else {
166 return 'powered by Ultimate Client Dash';
167 }
168 }
169 add_filter( 'login_headertext', 'ucd_login_logo_url_title' );
170
171
172 // Change howdy text on admin bar
173
174 function ucd_howdy_message($text) {
175 $ucd_howdy_text_change = get_option('ucd_howdy_text');
176 if (!empty($ucd_howdy_text_change)) {
177 $new_message = str_replace('Howdy', "$ucd_howdy_text_change", $text);
178 } else {
179 $new_message = str_replace('Howdy', "Howdy", $text);
180 }
181 return $new_message;
182 }
183 add_filter('gettext', 'ucd_howdy_message', 10, 3);
184
185
186 // Creates Custom Widget 1
187
188 add_action('wp_dashboard_setup', 'ucd_create_custom_widget');
189 function ucd_create_custom_widget() {
190 global $wp_meta_boxes;
191 $ucd_widget_title_text = get_option('ucd_widget_title');
192 $ucd_widget_enabled = get_option('ucd_custom_widget');
193 if (!empty($ucd_widget_enabled)) {
194 wp_add_dashboard_widget('ucd_widget', " $ucd_widget_title_text ", 'ucd_custom_widget');
195 }
196 }
197 function ucd_custom_widget() {
198 $ucd_widget_one_shortcode = get_option('ucd_custom_widget_shortcode');
199 echo '<div class="ucd-custom-widget-content">' . get_option( 'ucd_widget_body' ) . '</div>
200 <div class="ucd-widget-shortcode-one">' . do_shortcode("$ucd_widget_one_shortcode") . '</div>';
201 }
202
203
204 // Creates Custom Widget 2
205
206 add_action('wp_dashboard_setup', 'ucd_create_custom_widget_two');
207 function ucd_create_custom_widget_two() {
208 global $wp_meta_boxes;
209 $ucd_widget_two_title_text = get_option('ucd_widget_two_title');
210 $ucd_widget_two_enabled = get_option('ucd_custom_widget_two');
211 $ucd_widget_count = get_option('ucd_custom_widget_count');
212 if ($ucd_widget_count !== "one") {
213 if ($ucd_widget_count == "two" || "three" || "four") {
214 if (!empty($ucd_widget_two_enabled)) {
215 wp_add_dashboard_widget('ucd_widget_two', " $ucd_widget_two_title_text ", 'ucd_custom_widget_two');
216 }
217 }
218 }
219 }
220 function ucd_custom_widget_two() {
221 $ucd_widget_two_shortcode = get_option('ucd_custom_widget_two_shortcode');
222 echo '<div class="ucd-custom-widget-content">' . get_option( 'ucd_widget_two_body' ) . '</div>
223 <div class="ucd-widget-shortcode-two">' . do_shortcode("$ucd_widget_two_shortcode") . '</div>';
224 }
225
226
227 // Create Custom Widget 3
228
229 add_action('wp_dashboard_setup', 'ucd_create_custom_widget_three');
230 function ucd_create_custom_widget_three() {
231 global $wp_meta_boxes;
232 $ucd_widget_three_title_text = get_option('ucd_widget_three_title');
233 $ucd_widget_three_enabled = get_option('ucd_custom_widget_three');
234 $ucd_widget_count = get_option('ucd_custom_widget_count');
235 if ($ucd_widget_count !== "one") {
236 if ($ucd_widget_count !== "two") {
237 if ($ucd_widget_count == "three" || "four") {
238 if (!empty($ucd_widget_three_enabled)) {
239 wp_add_dashboard_widget('ucd_widget_three', " $ucd_widget_three_title_text ", 'ucd_custom_widget_three');
240 }
241 }
242 }
243 }
244 }
245 function ucd_custom_widget_three() {
246 $ucd_widget_three_shortcode = get_option('ucd_custom_widget_three_shortcode');
247 echo '<div class="ucd-custom-widget-content">' . get_option( 'ucd_widget_three_body' ) . '</div>
248 <div class="ucd-widget-shortcode-three">' . do_shortcode("$ucd_widget_three_shortcode") . '</div>';
249 }
250
251
252 // Create Custom Widget 4
253
254 add_action('wp_dashboard_setup', 'ucd_create_custom_widget_four');
255 function ucd_create_custom_widget_four() {
256 global $wp_meta_boxes;
257 $ucd_widget_four_title_text = get_option('ucd_widget_four_title');
258 $ucd_widget_four_enabled = get_option('ucd_custom_widget_four');
259 $ucd_widget_count = get_option('ucd_custom_widget_count');
260 if ($ucd_widget_count == "four") {
261 if (!empty($ucd_widget_four_enabled)) {
262 wp_add_dashboard_widget('ucd_widget_four', " $ucd_widget_four_title_text ", 'ucd_custom_widget_four');
263 }
264 }
265 }
266
267 function ucd_custom_widget_four() {
268 $ucd_widget_four_shortcode = get_option('ucd_custom_widget_four_shortcode');
269 echo '<div class="ucd-custom-widget-content">' . get_option( 'ucd_widget_four_body' ) . '</div>
270 <div class="ucd-widget-shortcode-four">' . do_shortcode("$ucd_widget_four_shortcode") . '</div>';
271 }
272
273
274 // Adds Custom CSS code to header
275
276 function ucd_add_custom_css(){
277 $ucd_custom_css = get_option('ucd_tracking_custom_css'); // GA Property ID
278 if (!empty($ucd_custom_css)) { ?>
279 <!-- Ultimate Client Dashboard Custom CSS -->
280 <style type="text/css">
281 <?php echo $ucd_custom_css; ?>
282 </style>
283 <?php }
284 }
285 add_action('wp_head', 'ucd_add_custom_css');
286
287
288 // Add Custom JS code to header
289
290 function ucd_add_custom_js(){
291 $ucd_custom_js = get_option('ucd_tracking_custom_js'); // GA Property ID
292 if (!empty($ucd_custom_js)) { ?>
293 <!-- Ultimate Client Dashboard Custom JS -->
294 <script type="text/javascript">
295 <?php echo $ucd_custom_js; ?>
296 </script>
297 <?php }
298 }
299 add_action('wp_head', 'ucd_add_custom_js');
300
301
302 // Add Custom Script to header
303
304 function ucd_add_custom_script(){
305
306 $ucd_custom_script = get_option('ucd_tracking_custom_script');
307 if (!empty($ucd_custom_script)) { ?>
308 <!-- Ultimate Client Dashboard Custom Script -->
309 <?php echo $ucd_custom_script; ?>
310 <?php }
311 }
312 add_action('wp_head', 'ucd_add_custom_script');
313
314
315 // Activate WordPress landing Page mode
316
317 function ucd_landing_page_mode(){
318 global $pagenow;
319 $ucd_enable_constructions = get_option('ucd_under_construction_disable');
320 if (!empty($ucd_enable_constructions)) {
321 if ( $pagenow !== 'wp-login.php' && !is_user_logged_in() && !is_admin() ) {
322 header( $_SERVER["SERVER_PROTOCOL"] . ' 503 Service Temporarily Unavailable', true, 503 );
323 header( 'Content-Type: text/html; charset=utf-8' );
324 if ( file_exists( plugin_dir_path( __FILE__ ) . 'templates/ucd-landing-page.php' ) ) {
325 require_once( plugin_dir_path( __FILE__ ) . 'templates/ucd-landing-page.php' );
326 }
327 die();
328 }
329 }
330 else {
331 // Don't display landing page
332 }
333 }
334 add_action('wp_loaded', 'ucd_landing_page_mode');
335
336
337 // Preview landing Page function
338
339 add_filter( 'template_include', 'ucd_landing_page_template', 99 );
340 function ucd_landing_page_template( $template ) {
341 if(isset($_GET['ucd-preview-landing-page']) && current_user_can('read')) {
342 return( plugin_dir_path( __FILE__ ) . 'templates/ucd-landing-page.php' );
343 }
344 return $template;
345 }
346
347
348 // Preview Login Page function
349
350 add_filter( 'template_include', 'ucd_login_page_template', 99 );
351 function ucd_login_page_template( $template ) {
352 if(isset($_GET['ucd-preview-login-page']) && current_user_can('read')) {
353 return( 'wp-login.php' );
354 }
355 return $template;
356 }
357
358
359 // Add custom text to login page footer
360
361 function ucd_custom_login_content_footer() {
362 $ucd_login_footer_content_enabled = get_option('ucd_login_custom_content');
363 if (!empty($ucd_login_footer_content_enabled)) { ?>
364 <div class="ucd-login-custom-content">
365 <?php echo get_option('ucd_login_custom_content') ?>
366 </div>
367 <?php }
368 }
369 add_action('login_footer','ucd_custom_login_content_footer');
370
371
372 // Change Admin Footer Text
373
374 function ucd_admin_footer_text () {
375 $ucd_admin_footer_text = get_option( 'ucd_admin_footer_text' );
376 if (!empty($ucd_admin_footer_text)) {
377 echo "$ucd_admin_footer_text";
378 } else {
379 $ucd_white_label_wordpress = get_option( 'ucd_dashboard_hide_wp_logo' );
380 if (empty($ucd_white_label_wordpress)) {
381 echo '<span id="footer-thankyou">Thank you for creating with <a href="https://wordpress.org/">WordPress</a>.</span>';
382 }
383 }
384 }
385 add_filter('admin_footer_text', 'ucd_admin_footer_text');
386
387
388 // Remove Default WordPress widgets from dashboard
389
390 function remove_dashboard_meta() {
391 // Welcome Panel Widget
392 $welcome_panel = get_option( 'ucd_widget_welcome' );
393 if (!empty($welcome_panel)) { remove_action( 'welcome_panel','wp_welcome_panel' ); } // Welcome Panel
394
395 // Try Gluentberg Widget
396 $try_gutenberg_panel = get_option( 'ucd_widget_glutenberg' );
397 if (!empty($try_gutenberg_panel)) { remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel'); } // Try Gutenberg
398
399 // Wordpress Events & News Widget
400 $dashboard_primary = get_option( 'ucd_widget_primary' );
401 if (!empty($dashboard_primary)) { remove_meta_box( 'dashboard_primary','dashboard','side' ); } // Wordpress Events & News
402
403 // Other WordPress News Widget
404 $dashboard_secondary = get_option( 'ucd_widget_secondary' );
405 if (!empty($dashboard_secondary)) { remove_meta_box('dashboard_secondary','dashboard','side'); } // Other WordPress News
406
407 // Activity Widget
408 $dashboard_activity = get_option( 'ucd_widget_activity' );
409 if (!empty($dashboard_activity)) { remove_meta_box('dashboard_activity','dashboard', 'normal'); } // Activity
410
411 // Right Now Widget
412 $dashboard_right_now = get_option( 'ucd_widget_glance' );
413 if (!empty($dashboard_right_now)) { remove_meta_box('dashboard_right_now','dashboard', 'normal' ); } // Right Now
414
415 // Quick Draft Widget
416 $dashboard_quick_press = get_option( 'ucd_widget_draft' );
417 if (!empty($dashboard_quick_press)) { remove_meta_box('dashboard_quick_press','dashboard','side'); } // Quick Draft
418
419 // Recent Drafts Widget
420 $dashboard_recent_drafts = get_option( 'ucd_widget_recent_drafts' );
421 if (!empty($dashboard_recent_drafts)) { remove_meta_box('dashboard_recent_drafts','dashboard','side'); } // Recent Drafts
422
423 // Incoming Links Widget
424 $dashboard_incoming_links = get_option( 'ucd_widget_incoming_links' );
425 if (!empty($dashboard_incoming_links)) { remove_meta_box('dashboard_incoming_links','dashboard','normal'); } // Incoming Links
426
427 // Recent Comments Widget
428 $dashboard_recent_comments = get_option( 'ucd_widget_recent_comments' );
429 if (!empty($dashboard_recent_comments)) { remove_meta_box('dashboard_recent_comments','dashboard','normal'); } // Recent Comments
430
431 // WooCommerce Widgets
432 $ucd_widget_woocommerce = get_option( 'ucd_widget_woocommerce' );
433 if (!empty($ucd_widget_woocommerce)) { remove_meta_box( 'woocommerce_dashboard_status', 'dashboard', 'normal'); remove_meta_box( 'woocommerce_dashboard_recent_reviews', 'dashboard', 'normal'); } // WooCommerce
434
435 // Gravity Forms Widgets
436 $rg_forms_dashboard = get_option( 'ucd_widget_gravity_forms' );
437 if (!empty($rg_forms_dashboard)) { remove_meta_box('rg_forms_dashboard','dashboard','normal'); } // Gravity Forms
438
439 // Yoast SEO Widgets
440 $yoast_db_widget = get_option( 'ucd_widget_yoast' );
441 if (!empty($yoast_db_widget)) { remove_meta_box('yoast_db_widget','dashboard','normal'); } // Yoast SEO
442
443 // Yoast SEO Widgets
444 $e_dashboard_overview = get_option( 'ucd_widget_elementor' );
445 if (!empty($e_dashboard_overview)) { remove_meta_box( 'e-dashboard-overview', 'dashboard', 'normal'); } // Elementor Overview
446
447 }
448 add_action('wp_dashboard_setup', 'remove_dashboard_meta', 20);
449 add_action('wp_user_dashboard_setup', 'remove_dashboard_meta', 20);
450