Skip to content

Instantly share code, notes, and snippets.

@ironprogrammer
Last active December 13, 2025 01:12
Show Gist options
  • Select an option

  • Save ironprogrammer/5e7c974731f77173aa71ee953c0b33f8 to your computer and use it in GitHub Desktop.

Select an option

Save ironprogrammer/5e7c974731f77173aa71ee953c0b33f8 to your computer and use it in GitHub Desktop.
Indicate plugins symlinked or under source control
<?php
/**
* Adds indicators to plugin actions menu if plugin is symlinked and/or under
* source control.
*
* Why do this?
* Because until https://core.trac.wordpress.org/ticket/36710 is resolved,
* it's too easy to accidentally update or delete a symlinked plugin
* (which is likely also under source control 🤯).
*
* Related:
* - https://core.trac.wordpress.org/ticket/29408
* - https://wordpress.org/plugins/local-development/
*/
add_filter( 'plugin_action_links', 'add_symlink_git_status_actions', 10, 2 );
function add_symlink_git_status_actions( $actions, $plugin_file ) {
$plugin_dir = dirname( WP_PLUGIN_DIR . '/' . $plugin_file );
if ( is_link( $plugin_dir ) ) {
$symlink_status = 'Symlinked';
$actions['symlinked'] = $symlink_status;
}
if ( is_plugin_under_git( $plugin_dir ) ) {
$git_status = 'Git';
$actions['git'] = $git_status;
}
return $actions;
}
/**
* Checks if a directory is under Git version control.
*
* @param string $directory The directory to check.
* @return bool True if the directory is under Git version control, false otherwise.
*/
function is_plugin_under_git( $directory ) {
return is_dir( $directory . '/.git' );
}
@ironprogrammer

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment