Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 30 additions & 20 deletions plugin.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
<?php
/*
Plugin Name: Mock Plugin
Description: A simple mock WordPress plugin for testing purposes.
Version: 1.0.0
Author: Your Name
Plugin Name: Hello From My Plugin
Description: Puts "Hello from my plugin" into the admin bar where Hello, Dolly normally shows quotes.
Version: 0.1
Author: You
Text Domain: hfmp
*/

add_action( 'init', function() {
} );

add_action( 'wp_head', function() {
echo '<script>console.log("hello world");</script>';
} );
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/* Replace Hello Dolly's node (if present) and add our own in the admin bar. */
add_action( 'admin_bar_menu', function( $wp_admin_bar ) {
// only run when the admin bar is actually showing
if ( ! is_admin_bar_showing() ) {
return;
}

// if Hello Dolly exists, remove it so our string takes the same id/position
$wp_admin_bar->remove_node( 'hello-dolly' );

// add a simple, non-linked text node
$wp_admin_bar->add_node( [
'id' => 'hello-dolly', // reuse the same id so placement mirrors Hello Dolly
'title' => __( 'Hello from my plugin', 'hfmp' ),
'href' => false,
'meta' => [
'class' => 'hfmp-hello ab-item',
'title' => __( 'Hello from my plugin', 'hfmp' ),
],
] );
}, 999 );