Skip to content

Commit

Permalink
Use admin textdomain
Browse files Browse the repository at this point in the history
  • Loading branch information
powerbuoy committed Dec 10, 2021
1 parent d71eb51 commit d85c2ae
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions sleek-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
####################
# Add settings field
function add_setting ($name, $type = 'text', $label = null) {
$label = $label ?? __(\Sleek\Utils\convert_case($name, 'title'), 'sleek');
$label = $label ?? __(\Sleek\Utils\convert_case($name, 'title'), 'sleek_admin');

add_settings_field(SETTINGS_NAME . '_' . $name, $label, function () use ($name, $type, $label) {
$options = get_option(SETTINGS_NAME);
Expand All @@ -33,14 +33,15 @@ function get_setting ($name) {
################
# Add admin page
add_action('admin_menu', function () {
add_options_page(__('Sleek settings', 'sleek'), 'Sleek', 'manage_options', 'sleek-settings', function () {
# Translators: This is the title of the settings page (Settings -> Sleek inside the WP admin) for the theme Sleek
add_options_page(__('Sleek settings', 'sleek_admin'), 'Sleek', 'manage_options', 'sleek-settings', function () {
?>
<div class="wrap">
<h1><?php _e('Sleek settings', 'sleek') ?></h1>
<h1><?php _ex('Sleek settings', 'settings', 'sleek') ?></h1>
<form method="post" action="options.php">
<?php settings_fields(SETTINGS_NAME) ?>
<?php do_settings_sections(SETTINGS_SECTION_NAME) ?>
<button class="button button-primary"><?php _e('Save settings', 'sleek') ?></button>
<button class="button button-primary"><?php _e('Save settings', 'sleek_admin') ?></button>
</form>
</div>
<?php
Expand All @@ -60,8 +61,8 @@ function get_setting ($name) {
}, SETTINGS_SECTION_NAME); # NOTE: WP Docs says this should be the add_options_page slug but that doesn't work. It needs to be the same as is later passed to do_settings_section

# Built-in fields
add_setting('head_code', 'textarea', esc_html__('Code inside <head>', 'sleek'));
add_setting('foot_code', 'textarea', esc_html__('Code just before </body>', 'sleek'));
add_setting('head_code', 'textarea', esc_html__('Code inside <head>', 'sleek_admin'));
add_setting('foot_code', 'textarea', esc_html__('Code just before </body>', 'sleek_admin'));
});

########
Expand Down

0 comments on commit d85c2ae

Please sign in to comment.