Last active
November 22, 2024 21:25
-
-
Save nathaningram/4fe3d1d8ff2be30bfd86ed12225cc0bf to your computer and use it in GitHub Desktop.
Starter Site 2024 Course - MU Dashboard Widgets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Custom Dashboard Widgets | |
Plugin URI: https://wpnathan.com | |
Description: Creates Custom Dashboard Widgets for Client Websites | |
Version: 2024.11 | |
Author: Nathan Ingram | |
Author URI: https://wpnathan.com | |
License: GPL2 | |
*/ | |
// Security Check | |
if (!defined('ABSPATH')) { | |
die(); | |
} | |
// Create Custom Client Dashboard Widget | |
add_action('wp_dashboard_setup', 'ni_custom_dashboard_widget'); | |
function ni_custom_dashboard_widget() { | |
global $wp_meta_boxes; | |
wp_add_dashboard_widget('ni_client_widget', 'Brilliant Web Works', 'ni_client_widget_content'); | |
} | |
function ni_client_widget_content() { | |
$url = get_site_url(); | |
echo '<p style="text-align:center"> | |
<img src="//nathaningram-archive.s3.amazonaws.com/icons/brilliant-logo-250w.png" /> | |
</p> | |
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: center; margin: 1.5em 0;"> | |
<a style="padding: 10px; background: #0073aa; color: white; text-decoration: none; display: inline-block; border-radius: 3px;" class="button" href="#" target="_blank" rel="noopener noreferrer">Google Analytics Instructions</a> | |
<a style="padding: 10px; background: #0073aa; color: white; text-decoration: none; display: inline-block; border-radius: 3px;" class="button" href="#">WordPress Help Videos</a> | |
<a style="padding: 10px; background: #0073aa; color: white; text-decoration: none; display: inline-block; border-radius: 3px;" class="button" href="#">WordPress Manual</a> | |
<a style="padding: 10px; background: #0073aa; color: white; text-decoration: none; display: inline-block; border-radius: 3px;" class="button" href="mailto:[email protected]?Subject=BRIEFLY DESCRIBE YOUR ISSUE&body=Change the subject line above to a summary of your issue, then provide more detail here.">Create a Support Ticket</a> | |
</div>'; | |
} | |
//Add a Support Form Widget | |
function ni_register_custom_dashboard_support_widget() { | |
wp_add_dashboard_widget( | |
'custom_dashboard_widget', | |
'Support Request Form', //Title for Dashboard Widget | |
'ni_custom_dashboard_support_widget_content' | |
); | |
} | |
function ni_custom_dashboard_support_widget_content() { | |
echo do_shortcode('[gravityform id="1" title="false" description="false" ajax="true"]'); | |
//Add your form shortcode above or replace Gravity Form ID with your own | |
} | |
add_action( 'wp_dashboard_setup', 'ni_register_custom_dashboard_support_widget' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment