| 1 |
<?php |
| 2 |
|
| 3 |
// Create custom plugin settings menu |
| 4 |
add_action('admin_menu', 'ca_create_menu'); |
| 5 |
function ca_create_menu() { |
| 6 |
|
| 7 |
// Create a submenu page in the 'Settings' menu |
| 8 |
add_submenu_page( 'options-general.php', 'Customize Admin', 'Customize Admin', 'manage_options', 'customize-admin/customize-admin-options.php', 'ca_settings_page'); |
| 9 |
|
| 10 |
// Call register settings function |
| 11 |
add_action( 'admin_init', 'ca_register_settings' ); |
| 12 |
} |
| 13 |
|
| 14 |
// Register the settings |
| 15 |
function ca_register_settings() { |
| 16 |
register_setting( 'customize-admin-settings-group', 'ca_logo_file' ); |
| 17 |
register_setting( 'customize-admin-settings-group', 'ca_logo_url' ); |
| 18 |
register_setting( 'customize-admin-settings-group', 'ca_remove_shadow' ); |
| 19 |
register_setting( 'customize-admin-settings-group', 'ca_remove_generator' ); |
| 20 |
} |
| 21 |
|
| 22 |
// Include files for media uploader |
| 23 |
function ca_admin_scripts() { |
| 24 |
wp_enqueue_script('media-upload'); |
| 25 |
wp_enqueue_script('thickbox'); |
| 26 |
wp_register_script('my-upload', WP_PLUGIN_URL.'/customize-admin/customize-admin.js', array('jquery','media-upload','thickbox')); |
| 27 |
wp_enqueue_script('my-upload'); |
| 28 |
} |
| 29 |
|
| 30 |
function ca_admin_styles() { |
| 31 |
wp_enqueue_style('thickbox'); |
| 32 |
} |
| 33 |
|
| 34 |
// Only include media uploader scripts and styles on custmize options page |
| 35 |
if (isset($_GET['page']) && $_GET['page'] == 'customize-admin/customize-admin-options.php') { |
| 36 |
add_action('admin_print_scripts', 'ca_admin_scripts'); |
| 37 |
add_action('admin_print_styles', 'ca_admin_styles'); |
| 38 |
} |
| 39 |
|
| 40 |
function ca_settings_page() { ?> |
| 41 |
<div class="wrap"> |
| 42 |
<h2><?php _e('Customize Admin Options') ?></h2> |
| 43 |
<form method="post" action="options.php"> |
| 44 |
<?php settings_fields( 'customize-admin-settings-group' ); ?> |
| 45 |
<table class="form-table"> |
| 46 |
<tr valign="top"> |
| 47 |
<th scope="row"><?php _e('Custom Logo Link') ?></th> |
| 48 |
<td><label for="ca_logo_url"> |
| 49 |
<input type="text" id="ca_logo_url" name="ca_logo_url" value="<?php echo get_option('ca_logo_url'); ?>" /> |
| 50 |
<br /><?php _e('If not specified, clicking on the logo will return you to the homepage.') ?> |
| 51 |
</label> |
| 52 |
</td> |
| 53 |
</tr> |
| 54 |
<tr valign="top"> |
| 55 |
<th scope="row"><?php _e('Custom Logo') ?></th> |
| 56 |
<td><label for="upload_image"> |
| 57 |
<input id="upload_image" type="text" size="36" name="ca_logo_file" value="<?php echo get_option('ca_logo_file'); ?>" /> |
| 58 |
<input id="upload_image_button" type="button" value="Upload Image" /> |
| 59 |
<br /><?php _e('Enter a URL or upload an image for the image. Maximum height: 70px, width: 310px.') ?> |
| 60 |
</label> |
| 61 |
</td> |
| 62 |
</tr> |
| 63 |
<tr valign="top"> |
| 64 |
<th scope="row"><?php _e('Remove Admin Menu Shadow') ?></th> |
| 65 |
<td><label for="ca_remove_shadow"> |
| 66 |
<input id="ca_remove_shadow" type="checkbox" name="ca_remove_shadow" value="1" <?php checked( '1', get_option( 'ca_remove_shadow' ) ); ?> /> |
| 67 |
<br /><?php _e('Selecting this option removes the shadow from the admin menu on the left.') ?> |
| 68 |
</label> |
| 69 |
</td> |
| 70 |
</tr> |
| 71 |
<tr valign="top"> |
| 72 |
<th scope="row"><?php _e('Remove Generator Meta Tag') ?></th> |
| 73 |
<td><label for="ca_remove_generator"> |
| 74 |
<input id="ca_remove_generator" type="checkbox" name="ca_remove_generator" value="1" <?php checked( '1', get_option( 'ca_remove_generator' ) ); ?> /> |
| 75 |
<br /><?php _e('Selecting this option removes the generator meta tag from the html source.') ?> |
| 76 |
</label> |
| 77 |
</td> |
| 78 |
</tr> |
| 79 |
</table> |
| 80 |
<p class="submit"> |
| 81 |
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> |
| 82 |
</p> |
| 83 |
</form> |
| 84 |
</div> |
| 85 |
<?php } ?> |