Created
May 18, 2017 13:56
-
-
Save qwersk/9c4d849eeb97110c31df978f6501e22b to your computer and use it in GitHub Desktop.
CREATE THEME SETTINGS PAGE #WP #WORDPRESS
This file contains hidden or 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
// https://www.sitepoint.com/create-a-wordpress-theme-settings-page-with-the-settings-api/ | |
function theme_settings_page() | |
{ | |
?> | |
<div class="wrap"> | |
<h1>Настройка темы</h1> | |
<form method="post" action="options.php"> | |
<?php | |
settings_fields("section"); | |
do_settings_sections("theme-options"); | |
submit_button(); | |
?> | |
</form> | |
</div> | |
<?php | |
} | |
function add_theme_menu_item() | |
{ | |
add_menu_page("Настройка темы", "Настройка темы", "manage_options", "theme-panel", "theme_settings_page", null, 99); | |
} | |
add_action("admin_menu", "add_theme_menu_item"); | |
function display_email() | |
{ | |
?> | |
<input type="text" name="email" id="email" value="<?php echo get_option('email'); ?>" style="width: 50%;" /> | |
<?php | |
} | |
function display_theme_panel_fields() | |
{ | |
add_settings_section("section", "All Settings", null, "theme-options"); | |
add_settings_field("email", "Эл. почта", "display_email", "theme-options", "section"); | |
register_setting("section", "email"); | |
} | |
add_action("admin_init", "display_theme_panel_fields"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment