Created
March 16, 2015 16:01
-
-
Save musicalbigfoot/3813889f58db42295f6a to your computer and use it in GitHub Desktop.
Admin Settings
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
add_action('admin_menu', 'cwa_create_menu'); | |
function cwa_create_menu() { | |
add_menu_page( 'Map Settings', 'Map Settings', 'manage_options', 'cwa-map-settings', 'cwa_settings_page', 'dashicons-location-alt', 61); | |
} | |
add_action( 'admin_init', 'register_cwasettings' ); | |
function register_cwasettings() { | |
// register_setting( 'ew-settings-general', 'cwa_analytics_code' ); | |
register_setting( 'cwa-settings', 'map_center_lat' ); | |
register_setting( 'cwa-settings', 'map_center_long' ); | |
register_setting( 'cwa-settings', 'map_zoom' ); | |
} | |
/** | |
* Step 3: Create the markup for the options page | |
*/ | |
function cwa_settings_page() { | |
?> | |
<div class="wrap"> | |
<h2>Map Settings</h2> | |
<form method="post" action="options.php"> | |
<?php if(isset( $_GET['settings-updated'])) { ?> | |
<div class="updated"> | |
<p>Settings updated successfully</p> | |
</div> | |
<?php } ?> | |
<table class="form-table"> | |
<tbody> | |
<tr> | |
<th scope="row"><label for="blogname">Map Zoom Level</label></th> | |
<td><input name="map_zoom" type="text" id="map_zoom" value="<?php echo get_option('map_zoom') ?>" placeholder="2" class="regular-text"> | |
<p class="description">1 = min zoom / 18 = max zoom</p></td> | |
</tr> | |
<tr> | |
<th scope="row" style="padding-bottom:0;"><label for="blogname">Center of Map</label></th> | |
<td style="padding-bottom:0;"><p class="description">Use <a href="http://www.mapcoordinates.net/en" target="_blank">mapcoordinates.net</a> to find lat/long of any location by clicking a map.</p></td> | |
</tr> | |
<tr> | |
<th scope="row"><label for="blogname">Latitude</label></th> | |
<td><input name="map_center_lat" type="text" id="map_center_lat" value="<?php echo get_option('map_center_lat') ?>" placeholder="38.980261" class="regular-text"></td> | |
</tr> | |
<tr> | |
<th scope="row"><label for="blogname">Longitude</label></th> | |
<td><input name="map_center_long" type="text" id="map_center_long" value="<?php echo get_option('map_center_long') ?>" placeholder="-121.080634" class="regular-text"></td> | |
</tr> | |
<?php | |
settings_fields( 'cwa-settings' ); | |
do_settings_sections( 'cwa-settings' ); | |
?> | |
</tbody> | |
</table> | |
<?php submit_button(); ?> | |
</form> | |
</div> | |
<?php } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment