Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--Help sections-->
- <?php
- add_action('admin_menu', 'help_menu');
- add_action('admin_init', 'help_menu_add_init');
- function help_menu() {
- add_options_page('Help Menu Options', 'Help Section', 'manage_options', 'my-unique-identifier', 'help_menu_options');
- }
- function help_menu_options() {
- if (!current_user_can('manage_options')) {
- wp_die( __('You do not have sufficient permissions to access this page.') );
- }
- include ($TEMPLATEPATH . 'functions/help.php');
- }
- function help_menu_add_init() {
- $file_dir=get_bloginfo('template_directory');
- wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, "1.0", "all");
- wp_enqueue_script("help", $file_dir."/functions/help.js", false, "1.0");
- }
- ?>
- <!--Theme Custom Menu-->
- <?php
- $themename = "Site Options";
- $shortname = "nt";
- $categories = get_categories('hide_empty=0&orderby=name');
- $wp_cats = array();
- foreach ($categories as $category_list ) {
- $wp_cats[$category_list->cat_ID] = $category_list->cat_name;
- }
- array_unshift($wp_cats, "Choose a category");
- $options = array (
- array( "name" => $themename." Options",
- "type" => "title"),
- array( "name" => "Customization",
- "type" => "section"),
- array( "type" => "open"),
- array( "name" => "Header Contact Name",
- "desc" => "Enter a name for the Header Contact info",
- "id" => $shortname."_head_name",
- "type" => "text",
- "std" => ""),
- array( "name" => "Header Contact Info",
- "desc" => "Enter a number or email for the Header Contact info",
- "id" => $shortname."_head_contact",
- "type" => "text",
- "std" => ""),
- array( "name" => "Header Logo",
- "desc" => "Enter the URL for the Header Logo",
- "id" => $shortname."_header_logo",
- "type" => "text",
- "std" => ""),
- array( "name" => "Picture 1",
- "desc" => "Enter a URL for a picture for the 1st spot",
- "id" => $shortname."_picture_1",
- "type" => "text",
- "std" => ""),
- array( "name" => "Name Above Picture 1 Description",
- "desc" => "Enter a name to be displayed above the first picture description",
- "id" => $shortname."_footer_name_1",
- "type" => "text",
- "std" => ""),
- array( "name" => "Picture 1 Description",
- "desc" => "Enter some text to display below the first picture",
- "id" => $shortname."_footer_text_1",
- "type" => "text",
- "std" => ""),
- array( "name" => "Picture 2",
- "desc" => "Enter a URL for a picture for the 2nd spot",
- "id" => $shortname."_picture_2",
- "type" => "text",
- "std" => ""),
- array( "name" => "Name Above Picture 2 Description",
- "desc" => "Enter a name to be displayed above the second picture description",
- "id" => $shortname."_footer_name_2",
- "type" => "text",
- "std" => ""),
- array( "name" => "Picture 2 Description",
- "desc" => "Enter some text to display below the second picture",
- "id" => $shortname."_footer_text_2",
- "type" => "text",
- "std" => ""),
- array( "name" => "Picture 3",
- "desc" => "Enter a URL for a picture for the 3rd spot",
- "id" => $shortname."_picture_3",
- "type" => "text",
- "std" => ""),
- array( "name" => "Name Above Picture 3 Description",
- "desc" => "Enter a name to be displayed above the third picture description",
- "id" => $shortname."_footer_name_3",
- "type" => "text",
- "std" => ""),
- array( "name" => "Picture 3 Description",
- "desc" => "Enter some text to display below the third picture",
- "id" => $shortname."_footer_text_3",
- "type" => "text",
- "std" => ""),
- array( "name" => "Picture 4",
- "desc" => "Enter a URL for a picture for the 4th spot",
- "id" => $shortname."_picture_4",
- "type" => "text",
- "std" => ""),
- array( "name" => "Name Above Picture 4 Description",
- "desc" => "Enter a name to be displayed above the fourth picture description",
- "id" => $shortname."_footer_name_4",
- "type" => "text",
- "std" => ""),
- array( "name" => "Picture 4 Description",
- "desc" => "Enter some text to display below the fourth picture",
- "id" => $shortname."_footer_text_4",
- "type" => "text",
- "std" => ""),
- array( "name" => "Name Above Email",
- "desc" => "Enter a name to be displayed above the email",
- "id" => $shortname."_footer_name",
- "type" => "text",
- "std" => ""),
- array( "name" => "Address",
- "desc" => "Enter your address if you would like to display it",
- "id" => $shortname."_display_address",
- "std" => "",
- "type" => "text"),
- array( "name" => "Phone",
- "desc" => "Enter your phone number if you would like to display it",
- "id" => $shortname."_display_phone",
- "std" => "",
- "type" => "text"),
- array( "name" => "Fax",
- "desc" => "Enter your number if you would like to display it",
- "id" => $shortname."_display_fax",
- "std" => "",
- "type" => "text"),
- array( "name" => "Email",
- "desc" => "Enter your email address if you would like to display it",
- "id" => $shortname."_display_email",
- "std" => "",
- "type" => "text"),
- array( "name" => "Google Analytics Code",
- "desc" => "You can paste your Google Analytics or other tracking code in this box. This will be automatically added to the footer.",
- "id" => $shortname."_ga_code",
- "type" => "textarea",
- "std" => ""),
- array( "type" => "close")
- );
- function mytheme_add_admin() {
- global $themename, $shortname, $options;
- if ( $_GET['page'] == basename(__FILE__) ) {
- if ( 'save' == $_REQUEST['action'] ) {
- foreach ($options as $value) {
- update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
- foreach ($options as $value) {
- if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }
- header("Location: themes.php?page=functions.php&saved=true");
- die;
- }
- else if( 'reset' == $_REQUEST['action'] ) {
- foreach ($options as $value) {
- delete_option( $value['id'] ); }
- header("Location: themes.php?page=functions.php&reset=true");
- die;
- }
- }
- add_menu_page($themename, $themename, 'administrator', basename(__FILE__), 'mytheme_admin');
- }
- function mytheme_add_init() {
- $file_dir=get_bloginfo('template_directory');
- wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, "1.0", "all");
- wp_enqueue_script("rm_script", $file_dir."/functions/rm_script.js", false, "1.0");
- }
- function mytheme_admin() {
- global $themename, $shortname, $options;
- $i=0;
- if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
- if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
- ?>
- <div class="wrap rm_wrap">
- <h2><?php echo $themename; ?> Settings</h2>
- <div class="rm_opts">
- <form method="post">
- <?php foreach ($options as $value) {
- switch ( $value['type'] ) {
- case "open":
- ?>
- <?php break;
- case "close":
- ?>
- </div>
- </div>
- <br />
- <?php break;
- case "title":
- ?>
- <p>To easily use the <?php echo $themename;?> theme, you can use the menu below.</p>
- <?php break;
- case 'text':
- ?>
- <div class="rm_input rm_text">
- <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
- <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?>" />
- <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
- </div>
- <?php
- break;
- case 'textarea':
- ?>
- <div class="rm_input rm_textarea">
- <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
- <textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?></textarea>
- <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
- </div>
- <?php
- break;
- case 'select':
- ?>
- <div class="rm_input rm_select">
- <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
- <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
- <?php foreach ($value['options'] as $option) { ?>
- <option <?php if (get_settings( $value['id'] ) == $option) { echo 'selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?>
- </select>
- <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
- </div>
- <?php
- break;
- case "checkbox":
- ?>
- <div class="rm_input rm_checkbox">
- <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
- <?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
- <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
- <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
- </div>
- <?php break;
- case "section":
- $i++;
- ?>
- <div class="rm_section">
- <div class="rm_title"><h3><img src="<?php bloginfo('template_directory')?>/functions/images/trans.png" class="inactive" alt="""><?php echo $value['name']; ?></h3><span class="submit"><input name="save<?php echo $i; ?>" type="submit" value="Save changes" />
- </span><div class="clearfix"></div></div>
- <div class="rm_options">
- <?php break;
- }
- }
- ?>
- <input type="hidden" name="action" value="save" />
- </form>
- <form method="post">
- <p class="submit">
- <input name="reset" type="submit" value="Reset" />
- <input type="hidden" name="action" value="reset" />
- </p>
- </form>
- <div style="font-size:9px; margin-bottom:10px;">Icons: <a href="http://www.woothemes.com/2009/09/woofunction/">WooFunction</a></div>
- </div>
- <?php
- }
- ?>
- <!--Theme Custom Menu-->
- <?php
- add_action('admin_init', 'mytheme_add_init');
- add_action('admin_menu', 'mytheme_add_admin');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement