Created
May 1, 2020 05:09
-
-
Save Daniel-Walsh/cce4f52cd5cd0db765e450b9fb7aca35 to your computer and use it in GitHub Desktop.
Add a client/company name field to general settings #wordpress #php
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 | |
// Add the 'Client/Company Name' field to General Settings. | |
add_filter( | |
'admin_init', | |
function () { | |
register_setting( | |
'general', | |
'namespace_client_name', | |
'esc_attr' | |
); | |
add_settings_field( | |
'namespace_client_name', | |
'<label for="namespace_client_name">Client/Company Name</label>', | |
function () { | |
$value = get_option( 'namespace_client_name', '' ); | |
$field_output = '<input type="text" id="namespace_client_name" name="namespace_client_name" class="regular-text" value="' . $value . '" />'; | |
$field_output .= '<p class="description" id="namespace_client_name-description">The display name of the client or company. To be displayed on the front of the site, for example, in copyright notices.</p>'; | |
echo $field_output; | |
}, | |
'general' | |
); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment