Created
October 8, 2014 15:59
-
-
Save igmoweb/f816e1fae0f8e3cfeab8 to your computer and use it in GitHub Desktop.
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
| <?php | |
| add_action( 'admin_menu', 'fictizia_add_settings_menu' ); | |
| function fictizia_add_settings_menu() { | |
| add_submenu_page( 'fictizia-main', 'Settings', 'Settings', 'manage_options', 'fictizia-settings', 'fictizia_display_settings_menu' ); | |
| } | |
| function fictizia_settings_init() { | |
| register_setting( 'OPTIONS_GROUP', 'OPTIONS_GROUP', 'SANITIZE_CALLBACK' ); | |
| add_settings_section( 'SECTION_ID', __( 'SECTION_TITLE', 'fictizia' ), 'SECTION_CALLBACK', 'MENU_SLUG' ); | |
| add_settings_field( 'FIELD_ID', __( 'FIELD_TITLE', 'fictizia' ), 'FIELD_CALLBACK', 'MENU_SLUG', 'SECTION_ID' ); | |
| } | |
| add_action( 'admin_init', 'fictizia_settings_init' ); | |
| function SECTION_CALLBACK() { | |
| echo __( 'This section description', 'fictizia' ); | |
| } | |
| function fictizia_display_text_field( ) { | |
| ?> | |
| <input type='text' name='OPTIONS_GROUP[NAME_OF_THE_FIELD]' value=""> | |
| <?php | |
| } | |
| function fictizia_display_settings_menu() { | |
| ?> | |
| <div class="wrap"> | |
| <h2><?php echo esc_html( get_admin_page_title() ); ?></h2> | |
| <form action="options.php" method="post"> | |
| <?php settings_fields( 'OPTIONS_GROUP' ); ?> | |
| <?php do_settings_sections( 'MENU_SLUG' ); ?> | |
| <?php submit_button( null, 'primary', 'OPTIONS_GROUP[submit_settings]' ); ?> | |
| </form> | |
| </div> | |
| <?php | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment