Created
May 12, 2019 07:04
-
-
Save timelsass/345f810ded211fd6b3e9510bd56ebd9a to your computer and use it in GitHub Desktop.
Adds the post ID's link to edit that page in the dashboard's at a glance widget.
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 At a Glance Item | |
* Description: Adds the post ID's link to edit that page in the dashboard's at a glance widget. | |
* Plugin URI: https://gist.github.com/timelsass/345f810ded211fd6b3e9510bd56ebd9a | |
* Author: Tim Elsass | |
* Author URI: tim.ph | |
*/ | |
/** | |
* Add new link by post ID to dashboard's at a glance widget. | |
* | |
* @param int $id post ID to add link for. | |
*/ | |
function custom_at_a_glance_item( $id ) { | |
add_filter( 'dashboard_glance_items', function( $items ) use( $id ) { | |
$title = get_the_title( $id ); | |
$items[] = '<a href="post.php?post=' . $id . '&action=edit">' . $title . '</a>'; | |
return $items; | |
} ); | |
} | |
// Replace 1 with the post ID of the page/post you want to have a link for in widget. | |
custom_at_a_glance_item( 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment