Skip to content

Instantly share code, notes, and snippets.

@ABooooo
Created September 13, 2019 07:36
Show Gist options
  • Save ABooooo/95121fce1e3830e6d00092e34497a713 to your computer and use it in GitHub Desktop.
Save ABooooo/95121fce1e3830e6d00092e34497a713 to your computer and use it in GitHub Desktop.
// function.php
// option page
add_action('admin_menu', 'option_page_create');
function option_page_create() {
$page_title = 'Theme Option';
$menu_title = 'Theme Option';
$capability = 'edit_posts';
$menu_slug = 'ae_theme_option';
$function = 'ae_theme_option_display';
$icon_url = '';
$position = 2;
add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
}
function ae_theme_option_display() {
if (!current_user_can('manage_options')) {
wp_die('Unauthorized user');
}
if (isset($_POST['logo_subline'])) {
$value = $_POST['logo_subline'];
update_option('logo_subline', $value);
}
$value = get_option('logo_subline');
include 'inc/ae-theme-option-page.php';
}
// form include page
<h1 style="margin-bottom:50px;">urban issues Theme Option Page</h1>
<form method="POST">
<label for="logo_subline">Logo Subline</label><br/><br/>
<!--<input type="text" name="logo_subline" id="logo_subline" value="<?php //echo $value; ?>"><br/><br/>-->
<?php
$content = get_option('logo_subline');
wp_editor( $content, 'logo_subline', $settings = array('textarea_rows'=> '3') );
?>
<br/><br/>
<input type="submit" value="Save" class="button button-primary button-large">
</form>
// template output
<p class="logo-subline"><?php echo get_option( 'logo_subline' ); ?></p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment