| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
// Function file that manages pro addons that use to be free. |
| 5 |
require( plugin_dir_path( __FILE__ ) . '/addons/pro-addons.php'); |
| 6 |
|
| 7 |
|
| 8 |
// Upload image function |
| 9 |
function ucd_load_media_files() { |
| 10 |
wp_enqueue_media(); |
| 11 |
} |
| 12 |
add_action( 'admin_enqueue_scripts', 'ucd_load_media_files' ); |
| 13 |
|
| 14 |
add_action( 'admin_init', 'ucd_main_register_options' ); |
| 15 |
function ucd_main_register_options() { |
| 16 |
do_action( 'ucd_create_options' ); |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
// Create custom welcome message template |
| 21 |
function ucd_general_admin_notice(){ |
| 22 |
global $pagenow; |
| 23 |
if ( $pagenow == 'index.php' ) { |
| 24 |
echo '<div class="notice notice-info is-dismissible ucd-client-welcome"> |
| 25 |
<h1 class="title-background">' . get_option('ucd_message_title') . '</h1> |
| 26 |
<div class="ucd-welcome-content">' . get_option( 'ucd_message_body' ) . '</div> |
| 27 |
</div>'; |
| 28 |
} |
| 29 |
} |
| 30 |
add_action('admin_notices', 'ucd_general_admin_notice'); |
| 31 |
|
| 32 |
|
| 33 |
// Customize login logo styling |
| 34 |
function ucd_login_logo() { |
| 35 |
$ucd_login_logo = get_option('ucd_login_logo'); |
| 36 |
if (!empty($ucd_login_logo)) { ?> |
| 37 |
<style type="text/css"> |
| 38 |
body.login div#login h1 a { |
| 39 |
background-image: url(<?php echo get_option('ucd_login_logo') ?>); |
| 40 |
background-size: contain!important; |
| 41 |
background-repeat: no-repeat; |
| 42 |
padding-bottom: 5px; |
| 43 |
width: <?php echo get_option('ucd_logo_width') ?>!important; |
| 44 |
height: <?php echo get_option('ucd_logo_height') ?>!important; |
| 45 |
max-width: 320px!important; |
| 46 |
} |
| 47 |
.login h1 a { |
| 48 |
background-size: contain!important; |
| 49 |
background-repeat: no-repeat; |
| 50 |
width: <?php echo get_option('ucd_logo_width') ?>!important; |
| 51 |
height: <?php echo get_option('ucd_logo_height') ?>!important; |
| 52 |
max-width: 320px!important; |
| 53 |
} |
| 54 |
</style> |
| 55 |
<?php } else {} |
| 56 |
} |
| 57 |
add_action( 'login_enqueue_scripts', 'ucd_login_logo' ); |
| 58 |
|
| 59 |
|
| 60 |
// Customize login background styling |
| 61 |
function ucd_login_footer() { ?> |
| 62 |
<style type="text/css" media="screen"> |
| 63 |
<?php |
| 64 |
$ucd_login_background_color = get_option('ucd_login_background_color'); |
| 65 |
$ucd_login_background_image = get_option('ucd_login_background_image'); |
| 66 |
if (!empty($ucd_login_background_color) || !empty($ucd_login_background_image)) { ?> |
| 67 |
body { |
| 68 |
<?php if (!empty($ucd_login_background_color)) { ?> background: <?php echo get_option('ucd_login_background_color') ?>!important; <?php } ?> |
| 69 |
<?php if (!empty($ucd_login_background_image)) { ?> background-image: url(<?php echo get_option('ucd_login_background_image') ?>)!important; <?php } ?> |
| 70 |
<?php if (!empty($ucd_login_background_image)) { ?> background-size: cover!important; <?php } ?> |
| 71 |
<?php if (!empty($ucd_login_background_image)) { ?> background-repeat: repeat; <?php } ?> |
| 72 |
} |
| 73 |
<?php } |
| 74 |
$ucd_dashboard_accent = get_option('ucd_dashboard_accent'); |
| 75 |
if ( !empty($ucd_dashboard_accent) ) { ?> |
| 76 |
input[type=text]:focus, |
| 77 |
input[type=search]:focus, |
| 78 |
input[type=radio]:focus, |
| 79 |
input[type=tel]:focus, |
| 80 |
input[type=time]:focus, |
| 81 |
input[type=url]:focus, |
| 82 |
input[type=week]:focus, |
| 83 |
input[type=password]:focus, |
| 84 |
input[type=checkbox]:focus, |
| 85 |
input[type=color]:focus, |
| 86 |
input[type=date]:focus, |
| 87 |
input[type=datetime]:focus, |
| 88 |
input[type=datetime-local]:focus, |
| 89 |
input[type=email]:focus, |
| 90 |
input[type=month]:focus, |
| 91 |
input[type=number]:focus, |
| 92 |
select:focus, |
| 93 |
textarea:focus { |
| 94 |
border-color: <?php echo get_option('ucd_dashboard_accent') ?> !important; |
| 95 |
box-shadow: 0 0 2px <?php echo get_option('ucd_dashboard_accent') ?> !important; |
| 96 |
} |
| 97 |
.wp-core-ui .button-group.button-large .button, .wp-core-ui .button.button-large { |
| 98 |
background: <?php echo get_option('ucd_dashboard_accent') ?> !important; |
| 99 |
border-color: <?php echo get_option('ucd_dashboard_accent') ?> !important; |
| 100 |
box-shadow: 0 1px 0 <?php echo get_option('ucd_dashboard_accent') ?> !important; |
| 101 |
text-shadow: none!important; |
| 102 |
} |
| 103 |
<?php } |
| 104 |
$ucd_login_hide_password = get_option('ucd_login_hide_password_link'); |
| 105 |
if ( !empty($ucd_login_hide_password) ) { ?> |
| 106 |
.login #nav { |
| 107 |
display: none!important; |
| 108 |
} |
| 109 |
<?php } |
| 110 |
$ucd_login_hide_main_link = get_option('ucd_login_hide_main_site_link'); |
| 111 |
if ( !empty($ucd_login_hide_main_link) ) { ?> |
| 112 |
.login #backtoblog a { |
| 113 |
display: none!important; |
| 114 |
} |
| 115 |
<?php } |
| 116 |
$ucd_login_body_text_color = get_option('ucd_login_body_text_color'); |
| 117 |
if ( !empty($ucd_login_body_text_color) ) { ?> |
| 118 |
#nav a, #backtoblog a, .privacy-policy-link { |
| 119 |
color: <?php echo get_option('ucd_login_body_text_color') ?>!important; |
| 120 |
} |
| 121 |
.ucd-login-custom-content { |
| 122 |
color: <?php echo get_option('ucd_login_body_text_color') ?>!important; |
| 123 |
padding-top: 40px!important; |
| 124 |
width: 320px!important; |
| 125 |
margin: 0 auto!important; |
| 126 |
display: block!important; |
| 127 |
} |
| 128 |
.ucd-login-custom-content a { |
| 129 |
color: <?php echo get_option('ucd_login_body_text_color') ?>!important; |
| 130 |
} |
| 131 |
<?php } |
| 132 |
$ucd_login_overlay_color = get_option('ucd_login_overlay_color'); |
| 133 |
if (!empty($ucd_login_overlay_color)) { ?> |
| 134 |
body:before { |
| 135 |
content: " "; |
| 136 |
width: 100%; |
| 137 |
height: 100%; |
| 138 |
position: fixed; |
| 139 |
z-index: -1; |
| 140 |
top: 0; |
| 141 |
left: 0; |
| 142 |
background: <?php echo get_option('ucd_login_overlay_color') ?>; |
| 143 |
opacity: <?php echo get_option('ucd_login_overlay_opacity') ?>; |
| 144 |
} |
| 145 |
<?php } |
| 146 |
$ucd_logo_padding_bottom = get_option('ucd_logo_padding_bottom'); |
| 147 |
if ( !empty($ucd_logo_padding_bottom) ) { ?> |
| 148 |
body.login div#login h1 a { |
| 149 |
padding-bottom: <?php echo get_option('ucd_logo_padding_bottom') ?> !important; |
| 150 |
} |
| 151 |
<?php } ?> |
| 152 |
</style> |
| 153 |
<?php |
| 154 |
} |
| 155 |
add_action('login_footer', 'ucd_login_footer'); |
| 156 |
|
| 157 |
|
| 158 |
// Customize login logo url |
| 159 |
function ucd_login_logo_url() { |
| 160 |
$ucd_login_logo_url = get_option('ucd_login_logo_url'); |
| 161 |
if (!empty($ucd_login_logo_url)) { |
| 162 |
return "$ucd_login_logo_url"; |
| 163 |
} else { |
| 164 |
return home_url(); |
| 165 |
} |
| 166 |
} |
| 167 |
add_filter( 'login_headerurl', 'ucd_login_logo_url' ); |
| 168 |
|
| 169 |
|
| 170 |
// Customize login logo title |
| 171 |
function ucd_login_logo_url_title() { |
| 172 |
$ucd_login_logo_title = get_option('ucd_login_logo_title'); |
| 173 |
if (!empty($ucd_login_logo_title)) { |
| 174 |
return "$ucd_login_logo_title"; |
| 175 |
} else { |
| 176 |
return 'powered by Ultimate Client Dash'; |
| 177 |
} |
| 178 |
} |
| 179 |
add_filter( 'login_headertext', 'ucd_login_logo_url_title' ); |
| 180 |
|
| 181 |
|
| 182 |
// Change howdy text on admin bar |
| 183 |
function ucd_howdy_message($text) { |
| 184 |
$ucd_howdy_text_change = get_option('ucd_howdy_text'); |
| 185 |
if (!empty($ucd_howdy_text_change)) { |
| 186 |
$new_message = str_replace('Howdy', "$ucd_howdy_text_change", $text); |
| 187 |
} else { |
| 188 |
$new_message = str_replace('Howdy', "Howdy", $text); |
| 189 |
} |
| 190 |
return $new_message; |
| 191 |
} |
| 192 |
add_filter('gettext', 'ucd_howdy_message', 10, 3); |
| 193 |
|
| 194 |
|
| 195 |
// Creates Custom Widget 1 |
| 196 |
add_action('wp_dashboard_setup', 'ucd_create_custom_widget'); |
| 197 |
function ucd_create_custom_widget() { |
| 198 |
global $wp_meta_boxes; |
| 199 |
$ucd_widget_title_text = get_option('ucd_widget_title'); |
| 200 |
$ucd_widget_enabled = get_option('ucd_custom_widget'); |
| 201 |
if (!empty($ucd_widget_enabled)) { |
| 202 |
wp_add_dashboard_widget('ucd_widget', " $ucd_widget_title_text ", 'ucd_custom_widget'); |
| 203 |
} |
| 204 |
} |
| 205 |
function ucd_custom_widget() { |
| 206 |
$ucd_widget_one_shortcode = get_option('ucd_custom_widget_shortcode'); |
| 207 |
echo '<div class="ucd-custom-widget-content">' . get_option( 'ucd_widget_body' ) . '</div> |
| 208 |
<div class="ucd-widget-shortcode-one">' . do_shortcode("$ucd_widget_one_shortcode") . '</div>'; |
| 209 |
} |
| 210 |
|
| 211 |
|
| 212 |
// Creates Custom Widget 2 |
| 213 |
add_action('wp_dashboard_setup', 'ucd_create_custom_widget_two'); |
| 214 |
function ucd_create_custom_widget_two() { |
| 215 |
global $wp_meta_boxes; |
| 216 |
$ucd_widget_two_title_text = get_option('ucd_widget_two_title'); |
| 217 |
$ucd_widget_two_enabled = get_option('ucd_custom_widget_two'); |
| 218 |
$ucd_widget_count = get_option('ucd_custom_widget_count'); |
| 219 |
if ($ucd_widget_count !== "one") { |
| 220 |
if ($ucd_widget_count == "two" || "three" || "four") { |
| 221 |
if (!empty($ucd_widget_two_enabled)) { |
| 222 |
wp_add_dashboard_widget('ucd_widget_two', " $ucd_widget_two_title_text ", 'ucd_custom_widget_two'); |
| 223 |
} |
| 224 |
} |
| 225 |
} |
| 226 |
} |
| 227 |
function ucd_custom_widget_two() { |
| 228 |
$ucd_widget_two_shortcode = get_option('ucd_custom_widget_two_shortcode'); |
| 229 |
echo '<div class="ucd-custom-widget-content">' . get_option( 'ucd_widget_two_body' ) . '</div> |
| 230 |
<div class="ucd-widget-shortcode-two">' . do_shortcode("$ucd_widget_two_shortcode") . '</div>'; |
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
// Create Custom Widget 3 |
| 235 |
add_action('wp_dashboard_setup', 'ucd_create_custom_widget_three'); |
| 236 |
function ucd_create_custom_widget_three() { |
| 237 |
global $wp_meta_boxes; |
| 238 |
$ucd_widget_three_title_text = get_option('ucd_widget_three_title'); |
| 239 |
$ucd_widget_three_enabled = get_option('ucd_custom_widget_three'); |
| 240 |
$ucd_widget_count = get_option('ucd_custom_widget_count'); |
| 241 |
if ($ucd_widget_count !== "one") { |
| 242 |
if ($ucd_widget_count !== "two") { |
| 243 |
if ($ucd_widget_count == "three" || "four") { |
| 244 |
if (!empty($ucd_widget_three_enabled)) { |
| 245 |
wp_add_dashboard_widget('ucd_widget_three', " $ucd_widget_three_title_text ", 'ucd_custom_widget_three'); |
| 246 |
} |
| 247 |
} |
| 248 |
} |
| 249 |
} |
| 250 |
} |
| 251 |
function ucd_custom_widget_three() { |
| 252 |
$ucd_widget_three_shortcode = get_option('ucd_custom_widget_three_shortcode'); |
| 253 |
echo '<div class="ucd-custom-widget-content">' . get_option( 'ucd_widget_three_body' ) . '</div> |
| 254 |
<div class="ucd-widget-shortcode-three">' . do_shortcode("$ucd_widget_three_shortcode") . '</div>'; |
| 255 |
} |
| 256 |
|
| 257 |
|
| 258 |
// Create Custom Widget 4 |
| 259 |
add_action('wp_dashboard_setup', 'ucd_create_custom_widget_four'); |
| 260 |
function ucd_create_custom_widget_four() { |
| 261 |
global $wp_meta_boxes; |
| 262 |
$ucd_widget_four_title_text = get_option('ucd_widget_four_title'); |
| 263 |
$ucd_widget_four_enabled = get_option('ucd_custom_widget_four'); |
| 264 |
$ucd_widget_count = get_option('ucd_custom_widget_count'); |
| 265 |
if ($ucd_widget_count == "four") { |
| 266 |
if (!empty($ucd_widget_four_enabled)) { |
| 267 |
wp_add_dashboard_widget('ucd_widget_four', " $ucd_widget_four_title_text ", 'ucd_custom_widget_four'); |
| 268 |
} |
| 269 |
} |
| 270 |
} |
| 271 |
|
| 272 |
function ucd_custom_widget_four() { |
| 273 |
$ucd_widget_four_shortcode = get_option('ucd_custom_widget_four_shortcode'); |
| 274 |
echo '<div class="ucd-custom-widget-content">' . get_option( 'ucd_widget_four_body' ) . '</div> |
| 275 |
<div class="ucd-widget-shortcode-four">' . do_shortcode("$ucd_widget_four_shortcode") . '</div>'; |
| 276 |
} |
| 277 |
|
| 278 |
|
| 279 |
// Adds Custom CSS code to website frontend |
| 280 |
function ucd_add_custom_css(){ |
| 281 |
$ucd_custom_css = get_option('ucd_tracking_custom_css'); // GA Property ID |
| 282 |
if (!empty($ucd_custom_css)) { ?> |
| 283 |
<!-- Ultimate Client Dashboard Custom CSS --> |
| 284 |
<style type="text/css"> |
| 285 |
<?php echo $ucd_custom_css; ?> |
| 286 |
</style> |
| 287 |
<?php } |
| 288 |
} |
| 289 |
add_action('wp_head', 'ucd_add_custom_css'); |
| 290 |
|
| 291 |
|
| 292 |
// Add Custom JS code to header |
| 293 |
function ucd_add_custom_js(){ |
| 294 |
$ucd_custom_js = get_option('ucd_tracking_custom_js'); // GA Property ID |
| 295 |
if (!empty($ucd_custom_js)) { ?> |
| 296 |
<!-- Ultimate Client Dashboard Custom JS --> |
| 297 |
<script type="text/javascript"> |
| 298 |
<?php echo $ucd_custom_js; ?> |
| 299 |
</script> |
| 300 |
<?php } |
| 301 |
} |
| 302 |
add_action('wp_head', 'ucd_add_custom_js'); |
| 303 |
|
| 304 |
|
| 305 |
// Add Custom Script to header |
| 306 |
function ucd_add_custom_script(){ |
| 307 |
$ucd_custom_script = get_option('ucd_tracking_custom_script'); |
| 308 |
if (!empty($ucd_custom_script)) { ?> |
| 309 |
<!-- Ultimate Client Dashboard Custom Script --> |
| 310 |
<?php echo $ucd_custom_script; ?> |
| 311 |
<?php } |
| 312 |
} |
| 313 |
add_action('wp_head', 'ucd_add_custom_script'); |
| 314 |
|
| 315 |
|
| 316 |
// Activate WordPress landing Page mode |
| 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 |
add_filter( 'template_include', 'ucd_landing_page_template', 99 ); |
| 339 |
function ucd_landing_page_template( $template ) { |
| 340 |
if(isset($_GET['ucd-preview-landing-page']) && current_user_can('read')) { |
| 341 |
return( plugin_dir_path( __FILE__ ) . 'templates/ucd-landing-page.php' ); |
| 342 |
} |
| 343 |
return $template; |
| 344 |
} |
| 345 |
|
| 346 |
|
| 347 |
// Preview Login Page function |
| 348 |
add_filter( 'template_include', 'ucd_login_page_template', 99 ); |
| 349 |
function ucd_login_page_template( $template ) { |
| 350 |
if(isset($_GET['ucd-preview-login-page']) && current_user_can('read')) { |
| 351 |
return( 'wp-login.php' ); |
| 352 |
} |
| 353 |
return $template; |
| 354 |
} |
| 355 |
|
| 356 |
|
| 357 |
// Add custom text to login page footer |
| 358 |
function ucd_custom_login_content_footer() { |
| 359 |
$ucd_login_footer_content_enabled = get_option('ucd_login_custom_content'); |
| 360 |
if (!empty($ucd_login_footer_content_enabled)) { ?> |
| 361 |
<div class="ucd-login-custom-content"> |
| 362 |
<?php echo get_option('ucd_login_custom_content') ?> |
| 363 |
</div> |
| 364 |
<?php } |
| 365 |
} |
| 366 |
add_action('login_footer','ucd_custom_login_content_footer'); |
| 367 |
|
| 368 |
|
| 369 |
// Change Admin Footer Text |
| 370 |
function ucd_admin_footer_text () { |
| 371 |
$ucd_admin_footer_text = get_option( 'ucd_admin_footer_text' ); |
| 372 |
if (!empty($ucd_admin_footer_text)) { |
| 373 |
echo "$ucd_admin_footer_text"; |
| 374 |
} else { |
| 375 |
$ucd_white_label_wordpress = get_option( 'ucd_dashboard_hide_wp_logo' ); |
| 376 |
if (empty($ucd_white_label_wordpress)) { |
| 377 |
echo '<span id="footer-thankyou">Thank you for creating with <a href="https://wordpress.org/">WordPress</a>.</span>'; |
| 378 |
} |
| 379 |
} |
| 380 |
} |
| 381 |
add_filter('admin_footer_text', 'ucd_admin_footer_text'); |
| 382 |
|
| 383 |
|
| 384 |
// Remove default WordPress widgets from dashboard |
| 385 |
function ucd_remove_default_dashboard_widgets() { |
| 386 |
// Welcome Panel Widget |
| 387 |
$welcome_panel = get_option( 'ucd_widget_welcome' ); |
| 388 |
if (!empty($welcome_panel)) { remove_action( 'welcome_panel','wp_welcome_panel' ); } // Welcome Panel |
| 389 |
// Try Gluentberg Widget |
| 390 |
$try_gutenberg_panel = get_option( 'ucd_widget_glutenberg' ); |
| 391 |
if (!empty($try_gutenberg_panel)) { remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel'); } // Try Gutenberg |
| 392 |
// Wordpress Events & News Widget |
| 393 |
$dashboard_primary = get_option( 'ucd_widget_primary' ); |
| 394 |
if (!empty($dashboard_primary)) { remove_meta_box( 'dashboard_primary','dashboard','side' ); } // Wordpress Events & News |
| 395 |
// Other WordPress News Widget |
| 396 |
$dashboard_secondary = get_option( 'ucd_widget_secondary' ); |
| 397 |
if (!empty($dashboard_secondary)) { remove_meta_box('dashboard_secondary','dashboard','side'); } // Other WordPress News |
| 398 |
// Activity Widget |
| 399 |
$dashboard_activity = get_option( 'ucd_widget_activity' ); |
| 400 |
if (!empty($dashboard_activity)) { remove_meta_box('dashboard_activity','dashboard', 'normal'); } // Activity |
| 401 |
// Right Now Widget |
| 402 |
$dashboard_right_now = get_option( 'ucd_widget_glance' ); |
| 403 |
if (!empty($dashboard_right_now)) { remove_meta_box('dashboard_right_now','dashboard', 'normal' ); } // Right Now |
| 404 |
// Quick Draft Widget |
| 405 |
$dashboard_quick_press = get_option( 'ucd_widget_draft' ); |
| 406 |
if (!empty($dashboard_quick_press)) { remove_meta_box('dashboard_quick_press','dashboard','side'); } // Quick Draft |
| 407 |
// Recent Drafts Widget |
| 408 |
$dashboard_recent_drafts = get_option( 'ucd_widget_recent_drafts' ); |
| 409 |
if (!empty($dashboard_recent_drafts)) { remove_meta_box('dashboard_recent_drafts','dashboard','side'); } // Recent Drafts |
| 410 |
// Incoming Links Widget |
| 411 |
$dashboard_incoming_links = get_option( 'ucd_widget_incoming_links' ); |
| 412 |
if (!empty($dashboard_incoming_links)) { remove_meta_box('dashboard_incoming_links','dashboard','normal'); } // Incoming Links |
| 413 |
// Recent Comments Widget |
| 414 |
$dashboard_recent_comments = get_option( 'ucd_widget_recent_comments' ); |
| 415 |
if (!empty($dashboard_recent_comments)) { remove_meta_box('dashboard_recent_comments','dashboard','normal'); } // Recent Comments |
| 416 |
// WooCommerce Widgets |
| 417 |
$ucd_widget_woocommerce = get_option( 'ucd_widget_woocommerce' ); |
| 418 |
if (!empty($ucd_widget_woocommerce)) { remove_meta_box( 'woocommerce_dashboard_status', 'dashboard', 'normal'); remove_meta_box( 'woocommerce_dashboard_recent_reviews', 'dashboard', 'normal'); } // WooCommerce |
| 419 |
// Gravity Forms Widgets |
| 420 |
$rg_forms_dashboard = get_option( 'ucd_widget_gravity_forms' ); |
| 421 |
if (!empty($rg_forms_dashboard)) { remove_meta_box('rg_forms_dashboard','dashboard','normal'); } // Gravity Forms |
| 422 |
// Yoast SEO Widget |
| 423 |
$yoast_db_widget = get_option( 'ucd_widget_yoast' ); |
| 424 |
if (!empty($yoast_db_widget)) { remove_meta_box('yoast_db_widget','dashboard','normal'); } // Yoast SEO |
| 425 |
// Elementor Widget |
| 426 |
$e_dashboard_overview = get_option( 'ucd_widget_elementor' ); |
| 427 |
if (!empty($e_dashboard_overview)) { remove_meta_box( 'e-dashboard-overview', 'dashboard', 'normal'); } // Elementor Overview |
| 428 |
// Site Health Widget |
| 429 |
$ucd_widget_site_health = get_option( 'ucd_widget_site_health' ); |
| 430 |
if (!empty($ucd_widget_site_health)) { remove_meta_box( 'dashboard_site_health', 'dashboard', 'normal'); } // Site Health |
| 431 |
// PHP Update Required Widget |
| 432 |
$ucd_widget_php_update = get_option( 'ucd_widget_php_update' ); |
| 433 |
if (!empty($ucd_widget_php_update)) { remove_meta_box( 'dashboard_php_nag', 'dashboard', 'normal'); } // Site Health |
| 434 |
|
| 435 |
} |
| 436 |
add_action('wp_dashboard_setup', 'ucd_remove_default_dashboard_widgets', 20); |
| 437 |
add_action('wp_user_dashboard_setup', 'ucd_remove_default_dashboard_widgets', 20); |
| 438 |
|
| 439 |
|
| 440 |
// Function to remove help tab from the WordPress dashboard |
| 441 |
function ucd_remove_help_tab(){ |
| 442 |
$ucd_dashboard_admin_bar_help = get_option('ucd_dashboard_admin_bar_help'); |
| 443 |
if (!empty($ucd_dashboard_admin_bar_help)) { |
| 444 |
if (current_user_can('client')) { |
| 445 |
$screen = get_current_screen(); |
| 446 |
$screen->remove_help_tabs(); |
| 447 |
} |
| 448 |
} |
| 449 |
} |
| 450 |
add_action('admin_head', 'ucd_remove_help_tab'); |
| 451 |
|
| 452 |
// Remove WordPress Footer Version |
| 453 |
function ucd_remove_wordpress_footer_version() { |
| 454 |
$ucd_admin_footer_version = get_option('ucd_admin_footer_version'); |
| 455 |
if (!empty($ucd_admin_footer_version)) { |
| 456 |
remove_filter( 'update_footer', 'core_update_footer' ); |
| 457 |
} |
| 458 |
} |
| 459 |
add_action( 'admin_menu', 'ucd_remove_wordpress_footer_version' ); |
| 460 |
|
| 461 |
|
| 462 |
// Remove WordPress admin bar links |
| 463 |
function ucd_remove_admin_bar_content() { |
| 464 |
global $wp_admin_bar; |
| 465 |
$ucd_dashboard_hide_wp_logo = get_option('ucd_dashboard_hide_wp_logo'); |
| 466 |
if (!empty($ucd_dashboard_hide_wp_logo)) { |
| 467 |
$wp_admin_bar->remove_node( 'wp-logo' ); // Remove the WordPress logo |
| 468 |
} |
| 469 |
$ucd_dashboard_admin_bar_updates_link = get_option('ucd_dashboard_admin_bar_updates_link'); |
| 470 |
if (!empty($ucd_dashboard_admin_bar_updates_link)) { |
| 471 |
if ( current_user_can('client') ) { |
| 472 |
$wp_admin_bar->remove_menu('updates'); // Remove the updates link |
| 473 |
} |
| 474 |
} |
| 475 |
$ucd_dashboard_admin_bar_comments_link = get_option('ucd_dashboard_admin_bar_comments_link'); |
| 476 |
if (!empty($ucd_dashboard_admin_bar_comments_link)) { |
| 477 |
if ( current_user_can('client') ) { |
| 478 |
$wp_admin_bar->remove_menu('comments'); // Remove the comments link |
| 479 |
} |
| 480 |
} |
| 481 |
$ucd_dashboard_admin_bar_add_new_Menu = get_option('ucd_dashboard_admin_bar_add_new_Menu'); |
| 482 |
if (!empty($ucd_dashboard_admin_bar_add_new_Menu)) { |
| 483 |
if ( current_user_can('client') ) { |
| 484 |
$wp_admin_bar->remove_menu('new-content'); // Remove the content link |
| 485 |
} |
| 486 |
} |
| 487 |
} |
| 488 |
add_action( 'admin_bar_menu', 'ucd_remove_admin_bar_content', 999 ); |
| 489 |
|
| 490 |
|
| 491 |
// Apply branding to frontend admin bar |
| 492 |
function ucd_admin_bar_frontend_styling(){ |
| 493 |
// If admin bar frontend styling is enabled |
| 494 |
$ucd_misc_admin_bar_frontend_styling = get_option('ucd_misc_admin_bar_frontend_styling'); |
| 495 |
if ( empty($ucd_misc_admin_bar_frontend_styling) ) { |
| 496 |
// Only add styling when user is logged in to help with site optimization |
| 497 |
if ( is_user_logged_in() ) { ?> |
| 498 |
<style> |
| 499 |
<?php // Start Admin Bar Styling |
| 500 |
$ucd_dashboard_admin_bar_text_color = get_option('ucd_dashboard_admin_bar_text_color'); |
| 501 |
if ( !empty($ucd_dashboard_admin_bar_text_color) ) { ?> |
| 502 |
#wpadminbar span, #wpadminbar a.auto-fold #adminmenu div.wp-menu-image, |
| 503 |
#adminmenu li.current a.menu-top, |
| 504 |
#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, #adminmenu li.current a.menu-top div.wp-menu-image:before, |
| 505 |
#wpadminbar .ab-icon, #wpadminbar .ab-item:before, #wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon,#wpadminbar #adminbarsearch:before, #wpadminbar .ab-icon:before, #wpadminbar .ab-item:before, |
| 506 |
#wpadminbar a.ab-item, |
| 507 |
#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, .wp-menu-name:focus, |
| 508 |
#wpadminbar .ab-empty-item, |
| 509 |
#adminmenu li.wp-has-current-submenu:hover div.wp-menu-image:before { |
| 510 |
color: <?php echo get_option('ucd_dashboard_admin_bar_text_color') ?> !important; |
| 511 |
} |
| 512 |
@media screen and (max-width: 782px) { |
| 513 |
#wpadminbar .ab-icon, #wpadminbar .ab-item:before, #wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon, |
| 514 |
.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before, #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { |
| 515 |
color: <?php echo get_option('ucd_dashboard_admin_bar_text_color') ?> !important; |
| 516 |
} |
| 517 |
} |
| 518 |
<?php } |
| 519 |
$ucd_dashboard_accent = get_option('ucd_dashboard_accent'); |
| 520 |
if ( !empty($ucd_dashboard_accent) ) { ?> |
| 521 |
#wpadminbar .ab-top-menu>#wp-admin-bar-my-account.hover>.ab-item span, #adminmenu li.current a.menu-top:hover div.wp-menu-image:before, #adminmenu li.current a.menu-top:hover, |
| 522 |
#wpadminbar span:hover, #wpadminbar a:hover, |
| 523 |
#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a, #wpadminbar .quicklinks .menupop ul li a:focus, #wpadminbar .quicklinks .menupop ul li a:focus strong, #wpadminbar .quicklinks .menupop ul li a:hover, #wpadminbar .quicklinks .menupop ul li a:hover strong, #wpadminbar .quicklinks .menupop.hover ul li a:focus, #wpadminbar .quicklinks .menupop.hover ul li a:hover, #wpadminbar .quicklinks .menupop.hover ul li div[tabindex]:focus, #wpadminbar .quicklinks .menupop.hover ul li div[tabindex]:hover, #wpadminbar li #adminbarsearch.adminbar-focused:before, #wpadminbar li .ab-item:focus .ab-icon:before, #wpadminbar li .ab-item:focus:before, #wpadminbar li a:focus .ab-icon:before, #wpadminbar li.hover .ab-icon:before, #wpadminbar li.hover .ab-item:before, #wpadminbar li:hover #adminbarsearch:before, #wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, #wpadminbar.mobile .quicklinks .hover .ab-icon:before, #wpadminbar.mobile .quicklinks .hover .ab-item:before, |
| 524 |
#wpadminbar #wp-admin-bar-user-info .display-name:hover, |
| 525 |
#wpadminbar .ab-top-menu>li.hover>.ab-item, #wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus, #wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item, #wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus, |
| 526 |
#wpadminbar .menupop .ab-sub-wrapper:hover, |
| 527 |
#wpadminbar .ab-top-menu>#wp-admin-bar-new-content.hover>.ab-item span, |
| 528 |
#wpadminbar .quicklinks .menupop ul li .ab-item span, |
| 529 |
#wpadminbar .quicklinks .menupop.hover .ab-item span { |
| 530 |
color: <?php echo get_option('ucd_dashboard_accent') ?> !important; |
| 531 |
} |
| 532 |
#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head, #adminmenu .wp-menu-arrow, #adminmenu .wp-menu-arrow div, #adminmenu li.current a.menu-top, #adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, .folded #adminmenu li.current.menu-top, .folded #adminmenu li.wp-has-current-submenu, #adminmenu li a.wp-has-current-submenu .update-plugins, #adminmenu li.current a .awaiting-mod, #wpadminbar { |
| 533 |
background: <?php echo get_option('ucd_dashboard_accent') ?> !important; |
| 534 |
} |
| 535 |
<?php } |
| 536 |
$ucd_dashboard_background_light = get_option('ucd_dashboard_background_light'); |
| 537 |
if ( !empty($ucd_dashboard_background_light) ) { ?> |
| 538 |
#adminmenu .wp-submenu { |
| 539 |
background: <?php echo get_option('ucd_dashboard_background_light') ?> !important; |
| 540 |
} |
| 541 |
#adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu .wp-has-current-submenu .wp-submenu.sub-open, #adminmenu .wp-has-current-submenu.opensub .wp-submenu, #adminmenu a.wp-has-current-submenu:focus+.wp-submenu, .no-js li.wp-has-current-submenu:hover .wp-submenu, #adminmenu div.wp-menu-name:active, #adminmenu li.opensub>a.menu-top,#adminmenu .wp-submenu li:hover, #wpadminbar .shortlink-input,#wpadminbar a.ab-item:hover { |
| 542 |
background: <?php echo get_option('ucd_dashboard_background_light') ?> !important; |
| 543 |
} |
| 544 |
#adminmenu li.menu-top:hover, #adminmenu li.opensub>a.menu-top, #adminmenu li>a.menu-top:focus { |
| 545 |
background: <?php echo get_option('ucd_dashboard_background_light') ?>; |
| 546 |
} |
| 547 |
<?php } |
| 548 |
$ucd_dashboard_background_dark = get_option('ucd_dashboard_background_dark'); |
| 549 |
if ( !empty($ucd_dashboard_background_dark) ) { ?> |
| 550 |
#adminmenu, #adminmenuback, #adminmenuwrap, |
| 551 |
#wpadminbar .menupop .ab-sub-wrapper, |
| 552 |
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, #wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { |
| 553 |
background: <?php echo get_option('ucd_dashboard_background_dark') ?> !important; |
| 554 |
} |
| 555 |
@media screen and (max-width: 782px) { |
| 556 |
.wp-has-submenu.wp-not-current-submenu.menu-top { |
| 557 |
background: <?php echo get_option('ucd_dashboard_background_dark') ?> !important; |
| 558 |
} |
| 559 |
} |
| 560 |
<?php } |
| 561 |
$ucd_dashboard_background_light = get_option('ucd_dashboard_background_light'); |
| 562 |
if ( !empty($ucd_dashboard_background_light) ) { ?> |
| 563 |
#adminmenu li.current a.menu-top:hover,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu:hover { |
| 564 |
background: <?php echo get_option('ucd_dashboard_background_light') ?> !important; |
| 565 |
} |
| 566 |
<?php } |
| 567 |
$ucd_dashboard_background_dark = get_option('ucd_dashboard_background_dark'); |
| 568 |
if ( !empty($ucd_dashboard_background_dark) ) { ?> |
| 569 |
#wpadminbar .ab-top-menu>li.hover>.ab-item, #wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus, #wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item, #wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus, |
| 570 |
#wpadminbar .menupop .ab-sub-wrapper:hover { |
| 571 |
background: <?php echo get_option('ucd_dashboard_background_dark') ?> !important; |
| 572 |
} |
| 573 |
<?php } ?> |
| 574 |
<?php $ucd_dashboard_text_color = get_option('ucd_dashboard_text_color'); |
| 575 |
if ( !empty($ucd_dashboard_text_color) ) { ?> |
| 576 |
#adminmenu li div.wp-menu-image:before, #adminmenu .wp-menu-image img, #collapse-menu span,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, #wpadminbar #wp-admin-bar-user-info .display-name, #wpadminbar .menupop:hover .display-name, |
| 577 |
#wpadminbar .quicklinks .menupop ul li .ab-item, #wpadminbar .ab-topmenu>li.hover>.ab-item, #wpadminbar .ab-topmenu>li:hover>.ab-item, #wpadminbar .ab-topmenu>li.hover>.ab-item:focus, #wpadminbar ul#wp-admin-bar-root-default>li:hover span.ab-label { |
| 578 |
color: <?php echo get_option('ucd_dashboard_text_color') ?> !important; |
| 579 |
} |
| 580 |
#adminmenuwrap a, |
| 581 |
#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu:hover, |
| 582 |
.current.menu-top.menu-top-first.menu-top-last a :hover { |
| 583 |
color: <?php echo get_option('ucd_dashboard_text_color') ?> !important; |
| 584 |
} |
| 585 |
<?php } ?> |
| 586 |
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img { |
| 587 |
float:left; |
| 588 |
margin:5px 15px; |
| 589 |
width:20px; |
| 590 |
height:20px; |
| 591 |
border:1px solid #FFF; |
| 592 |
border-radius:50% |
| 593 |
} |
| 594 |
@media screen and (max-width: 782px) { |
| 595 |
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a { |
| 596 |
width: 70px; |
| 597 |
} |
| 598 |
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img { |
| 599 |
top: 7px; |
| 600 |
} |
| 601 |
} |
| 602 |
#wp-admin-bar-ucd-landing-page-notice a.ab-item { |
| 603 |
color: #fff!important; |
| 604 |
} |
| 605 |
</style> |
| 606 |
<?php } |
| 607 |
} |
| 608 |
} |
| 609 |
add_action('wp_head', 'ucd_admin_bar_frontend_styling'); |
| 610 |
|