Last active
April 14, 2024 14:10
-
-
Save nathaningram/020381bd2b04bed2b5218bfa235ffae5 to your computer and use it in GitHub Desktop.
Creating a Starter Site - Custom Functions - Dashboard Widgets
This file contains 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://nathaningram.com | |
Description: Creates Custom Dashboard Widgets for Client Websites | |
Version: 2023.11 | |
Author: Nathan Ingram | |
Author URI: https://nathaningram.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> | |
<p style="margin: 1.5em 0;"><a style="min-width:45%; text-align:center;float:left;margin:5px;" class="button" href="#" target="_blank" rel="noopener noreferrer"> Google Analytics Instructions</a></p> | |
<p style="margin: 1.5em 0;"><a style="min-width:45%; text-align:center;float:left;margin:5px;" class="button" href="#">WordPress Help Videos</a></p> | |
<p style="margin: 1.5em 0;"><a style="min-width:45%; text-align:center;float:left;margin:5px;" class="button" href="#">WordPress Manual</a></p> | |
<p style="margin: 1.5em 0;"><a style="min-width:45%; text-align:center;float:left;margin:5px;" class="button" href="mailto | |
:support@wpnathan.com?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></p> | |
<div style="clear:both;float:none;"></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