Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( function_exists('register_sidebar') ) {
- register_sidebar(array(
- 'before_widget' => '<li>',
- 'after_widget' => '</li>',
- 'before_title' => '<h2 class="widgettitle">',
- 'after_title' => '</h2>',
- ));
- register_sidebar(array(
- 'name' => __( 'Language Picker'),
- 'id' => 'wpml',
- 'before_widget' => '',
- 'after_widget' => '',
- ));
- register_sidebar(array(
- 'name' => __( 'Inner Pages Widgets'),
- 'id' => 'inner',
- 'before_widget' => '',
- 'after_widget' => '',
- ));
- register_sidebar(array(
- 'name' => __( 'Copyright Widgets'),
- 'id' => 'copyright',
- 'before_widget' => '',
- 'after_widget' => '',
- ));
- }
- add_custom_background();
- register_post_type('profile', array(
- 'label' => __('Profiles'),
- 'singular_label' => __('Profile'),
- 'public' => true,
- 'show_ui' => false, // UI in admin panel
- 'capability_type' => 'post',
- 'hierarchical' => true,
- 'rewrite' => array("slug" => "user-profile"), // Permalinks format
- 'supports' => array('title', 'editor','page-attributes','author')
- ));
- add_action("template_redirect", 'my_template_redirect');
- // Template selection
- function my_template_redirect()
- {
- global $wp;
- global $wp_query;
- if (isset($_REQUEST['post_type']))
- {
- if ($_REQUEST['post_type']=="signup")
- {
- // Let's look for the register.php template file in the current theme
- if (have_posts())
- {
- include(TEMPLATEPATH . '/register.php');
- die();
- }
- else
- {
- $wp_query->is_404 = true;
- }
- }else if ($_REQUEST['post_type']=="user-profile")
- {
- // Let's look for the viewprofile.php template file in the current theme
- //http://kovshenin.com/2010/extending-custom-post-types-in-wordpress-3-0/
- //if (have_posts())
- //{
- include(TEMPLATEPATH . '/viewprofile.php');
- // die();
- //}
- //else
- //{
- // $wp_query->is_404 = true;
- //}
- }
- }
- }
- add_theme_support('post-thumbnails');
- add_filter( 'show_admin_bar', '__return_false' );
- function yoast_hide_admin_bar_settings() {
- ?>
- <style type="text/css">
- .show-admin-bar {
- display: none;
- }
- </style>
- <?php
- }
- /*********************************************************************
- HIDE DASHBOARD MENU ITEMS
- *********************************************************************/
- function remove_menus () {
- global $menu;
- $restricted = array( __('Posts'), __('Links'),__('Comments')); //, __('Tools')
- end ($menu);
- while (prev($menu)){
- $value = explode(' ',$menu[key($menu)][0]);
- if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
- }
- }
- add_action('admin_menu', 'remove_menus');
- add_action( 'save_post', 'delete_get_calendar_cache' );
- add_action( 'delete_post', 'delete_get_calendar_cache' );
- add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
- add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
- add_action( 'show_user_profile', 'extra_user_profile_fields' );
- add_action( 'edit_user_profile', 'extra_user_profile_fields' );
- /*********************************************************************
- ACCESS KEY GENERATOR
- *********************************************************************/
- add_action( 'init', 'accesskeygen_func' );
- function accesskeygen_func() {
- $phpfile = explode('/', $_SERVER['PHP_SELF']);
- $phpfile = $phpfile[count($phpfile)-1];
- if (($phpfile=='profile.php') && isset($_GET['accesskeygen'])) {
- echo wp_generate_password();
- exit;
- }
- }
- /*********************************************************************
- CALENDAR HOOKS
- **********************************************************************/
- // js hook to include calendar
- add_action('admin_head', 'calendar_load');
- function calendar_load() {
- echo '<link href="'.get_bloginfo('template_directory').'/js/calendar.css" type="text/css" rel="stylesheet" />'."\n";
- echo '<script src="'.get_bloginfo('template_directory').'/js/cal.js" type="text/javascript"></script>'."\n\n";
- }
- /********************************************************************
- Image Uploader Necessary Scripts
- *********************************************************************/
- function my_upload_scripts() {
- wp_enqueue_script('media-upload');
- }
- add_action('admin_print_scripts', 'my_upload_scripts');
- /********************************************************************
- Profile Image Upload Field Code
- *********************************************************************/
- require_once( STYLESHEETPATH . '/img_upload_resize_crop.php' );
- add_action( 'init', 'custom_img_uploader' );
- function custom_img_uploader () {
- global $profilePicture;
- if (isset($_FILES['profilePicture']['name'])!= "" ) {
- if ( $_FILES['profilePicture']['name']!="" ) {
- $your_image = new _image;
- $upload_dir = wp_upload_dir();
- //To Upload
- $your_image->uploadTo = $upload_dir['basedir'].'/';
- $upload = $your_image->upload($_FILES['profilePicture']);
- //To Resize
- $your_image->newPath = $upload_dir['basedir'].'/thumbs/';
- $your_image->newWidth = 150;
- $your_image->newHeight = 200;
- $resized = $your_image->resize();
- $profilePicture=str_replace($upload_dir['basedir'].'/thumbs/', "", $resized );
- unlink($upload);
- }else{
- $profilePicture='';
- }
- }
- }
- /***********************************************************************
- EXTRA PROFILE FIELDS
- http://bavotasan.com/2009/adding-extra-fields-to-the-wordpress-user-profile/
- ************************************************************************/
- function extra_user_profile_fields( $user ) {
- //global $profilePicture;
- ?>
- <h3><?php _e("Extra profile information", "blank"); ?></h3>
- <script type="text/javascript">
- jQuery(function($) {
- $("#myaccesskeygen").click( function() {
- var url = 'profile.php?accesskeygen=true';
- $.ajax({url:url,async:true,type:'GET',dataType:'html', success: function(newaccesskey){
- $("#myaccesskey").val(newaccesskey);
- }});
- });
- $("#dateofbirth").simpleDatepicker({startdate:'01/01/1930', enddate:'12/01/2012'});
- });
- </script>
- <table class="form-table">
- <tr>
- <th><label for="city"><?php _e("Birth Date"); ?></label></th>
- <td>
- <input type="text" name="dateofbirth" id="dateofbirth" value="<?php echo esc_attr( get_the_author_meta( 'dateofbirth', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your birth date."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="city"><?php _e("Birth Place"); ?></label></th>
- <td>
- <input type="text" name="birthplace" id="birthplace" value="<?php echo esc_attr( get_the_author_meta( 'birthplace', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your birth place."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="realage"><?php _e("Age"); ?></label></th>
- <td>
- <input type="text" name="realage" id="realage" value="<?php echo esc_attr( get_the_author_meta( 'realage', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your age"); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="province"><?php _e("Current City"); ?></label></th>
- <td>
- <input type="text" name="currentcity" id="currentcity" value="<?php echo esc_attr( get_the_author_meta( 'currentcity', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your current city."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="favouritecolour"><?php _e("Favourite Colour"); ?></label></th>
- <td>
- <input type="text" name="favouritecolour" id="favouritecolour" value="<?php echo esc_attr( get_the_author_meta( 'favouritecolour', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your favourite colour."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="favouritebook"><?php _e("Favourite Book"); ?></label></th>
- <td>
- <input type="text" name="favouritebook" id="favouritebook" value="<?php echo esc_attr( get_the_author_meta( 'favouritebook', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your favourite book."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="favouritefilm"><?php _e("Favourite Film"); ?></label></th>
- <td>
- <input type="text" name="favouritefilm" id="favouritefilm" value="<?php echo esc_attr( get_the_author_meta( 'favouritefilm', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your favourite film."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="favouriterestaurant"><?php _e("Favourite Restaurant"); ?></label></th>
- <td>
- <input type="text" name="favouriterestaurant" id="favouriterestaurant" value="<?php echo esc_attr( get_the_author_meta( 'favouriterestaurant', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your favourite restaurant."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="favouritequote"><?php _e("Favourite Quote"); ?></label></th>
- <td>
- <input type="text" name="favouritequote" id="favouritequote" value="<?php echo esc_attr( get_the_author_meta( 'favouritequote', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your favourite quote."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="favouritequalityinaperson"><?php _e("Favourite Quality in a Person"); ?></label></th>
- <td>
- <input type="text" name="favouritequalityinaperson" id="favouritequalityinaperson" value="<?php echo esc_attr( get_the_author_meta( 'favouritequalityinaperson', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your favourite quality in a person."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="myfavouritetvprograms"><?php _e("Favourite TV Programs"); ?></label></th>
- <td>
- <input type="text" name="myfavouritetvprograms" id="myfavouritetvprograms" value="<?php echo esc_attr( get_the_author_meta( 'myfavouritetvprograms', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your favourite TV programs."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="myfavouritegroups"><?php _e("Favourite Groups"); ?></label></th>
- <td>
- <input type="text" name="myfavouritegroups" id="myfavouritegroups" value="<?php echo esc_attr( get_the_author_meta( 'myfavouritegroups', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your favourite groups."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="myfavouritelinks"><?php _e("Favourite Links"); ?></label></th>
- <td>
- <input type="text" name="myfavouritelinks" id="myfavouritelinks" value="<?php echo esc_attr( get_the_author_meta( 'myfavouritelinks', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your favourite links."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="zodiac"><?php _e("Zodiac"); ?></label></th>
- <td>
- <input type="text" name="zodiac" id="zodiac" value="<?php echo esc_attr( get_the_author_meta( 'zodiac', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your Zodiac"); ?></span>
- </td>
- </tr>
- <!-- begin image uploader field -->
- <tr>
- <th><label for="profilePicture"><?php _e("Profile Image"); ?></label></th>
- <td>
- <input type="file" name="profilePicture" id="profilePicture" style="float:left;" />
- </td>
- </tr>
- <!-- begin access key -->
- </tr>
- <th><label for="myaccesskey"><?php _e("Access Key"); ?></label></th>
- <td>
- <input type="text" name="myaccesskey" id="myaccesskey" value="<?php echo esc_attr( get_the_author_meta( 'myaccesskey', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description">
- <input type="button" class="button-secondary" id="myaccesskeygen" value="Generate Access Key"/>
- <?php _e("Please click the button generate access key."); ?>
- </span>
- </td>
- </tr>
- <!-- end access key -->
- </table>
- <?php }
- add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
- add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
- function save_extra_user_profile_fields( $user_id ) {
- if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }
- //update_user_meta user_id, key, value, previous
- update_user_meta( $user_id, 'dateofbirth', $_POST['dateofbirth']);
- update_user_meta( $user_id, 'realage', $_POST['realage']);
- update_user_meta( $user_id, 'birthplace', $_POST['birthplace'] );
- update_user_meta( $user_id, 'currentcity', $_POST['currentcity'] );
- update_user_meta( $user_id, 'favouritecolour', $_POST['favouritecolour'] );
- update_user_meta( $user_id, 'favouritebook', $_POST['favouritebook'] );
- update_user_meta( $user_id, 'favouritefilm', $_POST['favouritefilm'] );
- update_user_meta( $user_id, 'favouriterestaurant', $_POST['favouriterestaurant'] );
- update_user_meta( $user_id, 'favouritequote', $_POST['favouritequote'] );
- update_user_meta( $user_id, 'favouritequalityinaperson', $_POST['favouritequalityinaperson'] );
- update_user_meta( $user_id, 'myfavouritetvprograms', $_POST['myfavouritetvprograms'] );
- update_user_meta( $user_id, 'myfavouritegroups', $_POST['myfavouritegroups'] );
- update_user_meta( $user_id, 'myfavouritelinks', $_POST['myfavouritelinks'] );
- update_user_meta( $user_id, 'zodiac', $_POST['zodiac'] );
- update_user_meta( $user_id, 'userphoto_thumb_height', 59);
- update_user_meta( $user_id, 'userphoto_thumb_width', 80 );
- update_user_meta( $user_id, 'userphoto_thumb_file', $profilePicture );
- update_user_meta( $user_id, 'myaccesskey', $_POST['myaccesskey']);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement