Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function remove_footer_admin () {
- echo "I'm in ur footer deleting the copyrights.";
- }
- add_filter('admin_footer_text', 'remove_footer_admin');
- ?>
- <?php
- $themename = "Theme";
- $shortname = "theme";
- $options = array (
- array( "name" => "Settings",
- "type" => "title"),
- array( "type" => "open"),
- array( "name" => "Header information:",
- "desc" => "Appears above navigation.",
- "id" => $shortname."_headerinfo",
- "std" => "",
- "type" => "text"),
- array( "name" => "Footer information:",
- "desc" => "Appears at the bottom of page.",
- "id" => $shortname."_footerinfo",
- "std" => "",
- "type" => "textarea"),
- array( "name" => "Page Exclude:",
- "desc" => "Enter page ID# numbers to exclude from main menu.",
- "id" => $shortname."_page",
- "std" => "",
- "type" => "text"),
- array( "name" => "Home Image 1:",
- "desc" => "Enter URL for image. Dimensions should be 960x425",
- "id" => $shortname."_image1",
- "std" => "",
- "type" => "text"),
- array( "name" => "Home Image 2:",
- "desc" => "Enter URL for image. Dimensions should be 960x425",
- "id" => $shortname."_image2",
- "std" => "",
- "type" => "text"),
- array( "name" => "Home Image 3:",
- "desc" => "Enter URL for image. Dimensions should be 960x425",
- "id" => $shortname."_image3",
- "std" => "",
- "type" => "text"),
- array( "name" => "Home Image 4:",
- "desc" => "Enter URL for image. Dimensions should be 960x425",
- "id" => $shortname."_image4",
- "std" => "",
- "type" => "text"),
- array( "name" => "Home Image 5:",
- "desc" => "Enter URL for image. Dimensions should be 960x425",
- "id" => $shortname."_image5",
- "std" => "",
- "type" => "text"),
- 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." Settings", "".$themename." Settings", 'edit_themes', basename(__FILE__), 'mytheme_admin');
- }
- function mytheme_admin() {
- global $themename, $shortname, $options;
- 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">
- <h2><?php echo $themename; ?> settings</h2>
- <form method="post">
- <?php foreach ($options as $value) {
- switch ( $value['type'] ) {case "open":?>
- <table width="100%" border="0">
- <br />
- <?php break;case "close":?>
- </table><br />
- <?php break;case "title":?>
- <table width="100%" border="0">
- <?php break;case 'text':?>
- <tr>
- <td width="20%"><?php echo $value['name']; ?></td>
- <td width="80%"><input style="width:200px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>" /> <small><?php echo $value['desc']; ?></small></td>
- </tr>
- <tr><td colspan="2" style="margin-bottom:5px;"> </td></tr>
- <?php break;case 'textarea':?>
- <tr>
- <td width="20%" rowspan="2" valign="middle"><?php echo $value['name']; ?></td>
- <td width="80%"><textarea name="<?php echo $value['id']; ?>" style="width:400px; height:80px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?></textarea></td>
- </tr>
- <tr>
- <td><small><?php echo $value['desc']; ?></small></td>
- </tr><tr><td colspan="2" style="margin-bottom:5px;"> </td></tr>
- <?php break;case 'select':?>
- <tr>
- <td width="20%" rowspan="2" valign="middle"><?php echo $value['name']; ?></td>
- <td width="80%"><select style="width:240px;" 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"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select></td>
- </tr>
- <tr>
- <td><small><?php echo $value['desc']; ?></small></td>
- </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr>
- <?php break;case "checkbox":?>
- <tr>
- <td width="20%"><?php echo $value['name']; ?></td>
- <td width="80%"><? if(get_settings($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></td>
- </tr>
- <tr><td colspan="2" style="margin-bottom:5px;"> </td></tr>
- <?php break;} }?>
- <!--</table>-->
- <p class="submit">
- <input name="save" type="submit" value="Save changes" />
- <input type="hidden" name="action" value="save" />
- </p>
- </form>
- <?php } add_action('admin_menu', 'mytheme_add_admin'); ?>
- <?php //SIDEBAR GENERATOR (FOR SIDEBAR AND FOOTER)-----------------------------------------------
- if ( function_exists('register_sidebar') )
- register_sidebar(array('name'=>'Blog Widgets',
- 'before_widget' => '<li id="%1$s" class="widget %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h2 class="widgettitle">',
- 'after_title' => '</h2>',
- ));
- register_sidebar(array('name'=>'Contact Us Widgets',
- 'before_widget' => '<li id="%1$s" class="widget %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h2 class="widgettitle">',
- 'after_title' => '</h2>',
- ));
- ?>
- <?php
- $key = "key";
- $meta_boxes = array(
- "custom_header" => array(
- "name" => "custom_header",
- "title" => "Post/Page Header Image URL",
- "description" => "Dimensions: Pages = 960x246. Portfolio = 960x460."),
- "custom_option" => array(
- "name" => "custom_thumb",
- "title" => "Post/Page Image URL",
- "description" => "Dimensions: Pages = 399x266. Client Review posts = 370x245. Home posts = 100x100. Portfolio posts = 67x40."),
- "custom_project" => array(
- "name" => "custom_project",
- "title" => "Type of project",
- "description" => "Example: Pool Construction"),
- "custom_client" => array(
- "name" => "custom_client",
- "title" => "Client name",
- "description" => "Example: John Doe")
- );
- function create_meta_box() {
- global $key;
- if( function_exists( 'add_meta_box' ) ) {
- add_meta_box( 'new-meta-boxes', ' Custom Post Options', 'display_meta_box', 'post', 'normal', 'high' );
- add_meta_box( 'new-meta-boxes', ' Custom Post Options', 'display_meta_box', 'page', 'normal', 'high' );
- }
- }
- function display_meta_box() {
- global $post, $meta_boxes, $key;
- ?>
- <div class="form-wrap">
- <?php
- wp_nonce_field( plugin_basename( __FILE__ ), $key . '_wpnonce', false, true );
- foreach($meta_boxes as $meta_box) {
- $data = get_post_meta($post->ID, $key, true);
- ?>
- <div class="form-field form-required">
- <label for="<?php echo $meta_box[ 'name' ]; ?>"><?php echo $meta_box[ 'title' ]; ?></label>
- <input type="text" name="<?php echo $meta_box[ 'name' ]; ?>" value="<?php echo htmlspecialchars( $data[ $meta_box[ 'name' ] ] ); ?>" />
- <p><?php echo $meta_box[ 'description' ]; ?></p>
- </div>
- <?php } ?>
- </div>
- <?php
- }
- function save_meta_box( $post_id ) {
- global $post, $meta_boxes, $key;
- foreach( $meta_boxes as $meta_box ) {
- $data[ $meta_box[ 'name' ] ] = $_POST[ $meta_box[ 'name' ] ];
- }
- if ( !wp_verify_nonce( $_POST[ $key . '_wpnonce' ], plugin_basename(__FILE__) ) )
- return $post_id;
- if ( !current_user_can( 'edit_post', $post_id ))
- return $post_id;
- update_post_meta( $post_id, $key, $data );
- }
- add_action( 'admin_menu', 'create_meta_box' );
- add_action( 'save_post', 'save_meta_box' );
- ?>
Add Comment
Please, Sign In to add comment