Skip to main content

Add Developer Branding

PropertyValue
descriptionApply frontend and admin developer branding.
tagslib, php, wp, oop
rating

Overview

Add lightweight developer branding to the frontend and WordPress admin.

The snippet outputs a frontend HTML comment in wp_head, replaces the left admin footer text with a linked credit, and removes the WordPress version text from the right admin footer. Customize the author, company, and URL in the branding helper or OOP constants.

Variants

<?php
/**
* Add frontend and admin developer branding.
*/

/**
* Branding data.
*
* @return array{author: string, company: string, url: string}
*/
if ( ! function_exists( 'mac_get_branding_data' ) ) {

function mac_get_branding_data(): array {
return [
'author' => 'Mihai Circea',
'company' => 'All Phase Media',
'url' => 'https://allphasemedia.com',
];
}
}

/**
* Frontend branding comment.
*/
if ( ! function_exists( 'mac_output_frontend_branding_comment' ) ) {

function mac_output_frontend_branding_comment(): void {

$branding = mac_get_branding_data();

$comment = sprintf(
'Built by %s @ %s %s',
$branding['author'],
$branding['company'],
$branding['url']
);

echo "\n<!-- " . esc_html( $comment ) . " -->\n";
}
}

add_action( 'wp_head', 'mac_output_frontend_branding_comment', 0 );

/**
* Admin footer text (left side).
*/
if ( ! function_exists( 'mac_filter_admin_footer_branding' ) ) {

function mac_filter_admin_footer_branding( ?string $text ): string {

$branding = mac_get_branding_data();

return sprintf(
'Built by %s @ <a href="%s" target="_blank" rel="noopener noreferrer">%s</a>',
esc_html( $branding['author'] ),
esc_url( $branding['url'] ),
esc_html( $branding['company'] )
);
}
}

add_filter(
'admin_footer_text',
'mac_filter_admin_footer_branding',
999
);

/**
* Remove WP version text (right side).
*/
add_filter( 'update_footer', '__return_empty_string', 999 );