< http://mikejolley.com > big kudos to him!!! **************************************************************************************/ /** * Add plugin i18n domain: dnxup * @since 1.1.1 */ load_plugin_textdomain('dnxup', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/'); /** * Include settings options for our plugin * @since 1.1.1 */ function dnxup_settings() { add_options_page('danixland User Panel Settings', __('User Panel Options', 'dnxup'), 'manage_options', 'dnxup_options', 'dnxup_settings_display'); } add_action('admin_menu', 'dnxup_settings' ); /** * The function that outputs our admin page * @since 1.1.1 */ function dnxup_settings_display() { ?>

true, 'logged_out_heading' => 'Howdy Guest', 'logged_in_heading' => 'Howdy %username%', 'logged_in_links' => "" . __('Dashboard','dnxup') . "\n" . __('Profile','dnxup') . "", // database version 'dnxup_DB_VERSION' => '1' ); return $defaults; } // helper function that starts up the DB function dnxup_db_init() { global $dnxup_options; $dnxup_options = get_option('dnxup_options'); if( false === $dnxup_options ) { $dnxup_options = dnxup_db_defaults(); } update_option('dnxup_options', $dnxup_options); } // helper function that performs a DB version update when needed function dnxup_db_update($db_version) { global $dnxup_options; $db_defaults = dnxup_db_defaults(); $merge = wp_parse_args( $dnxup_options, $db_defaults ); // update DB version $merge['dnxup_DB_VERSION'] = $db_version; update_option('dnxup_options', $merge); } // helper function that performs a DB check and then an init/update action function dnxup_db_check() { global $dnxup_options; if(false === $dnxup_options) { dnxup_db_init(); } $old_db_version = $dnxup_options['dnxup_DB_VERSION']; $new_db_version = DNXUP_CURRENT_DB_VERSION; if(empty($old_db_version)) { dnxup_db_init(); } if( intval($old_db_version) < intval($new_db_version) ) { dnxup_db_update( $new_db_version ); } } function dnxup_set_db_version() { // Define plugin database version. This should only change when new settings are added. if ( ! defined( 'DNXUP_CURRENT_DB_VERSION' ) ) { define( 'DNXUP_CURRENT_DB_VERSION', 2 ); } } /** * Add function on plugin activation that'll set our DB version and perform a check for update * @since 1.1.3 */ register_activation_hook( __FILE__, 'dnxup_set_db_version' ); register_activation_hook( __FILE__, 'dnxup_db_check' ); /** * function that returns the actual url for redirection after logout * as seen on sidebar-login by Mike Jolley with small modifications * @since 1.1.3 */ function dnxup_current_url($url = '') { global $wpdb, $post, $cat, $tag, $author, $year, $monthnum, $day, $wp_query; $pageURL = ""; if ( is_home() && $wp_query->is_posts_page==1) { $pageURL = get_permalink(get_option('page_for_posts')); } elseif (is_home() || is_front_page()) { $pageURL = get_bloginfo('url'); } elseif (is_post_type_archive()) { $pageURL = get_post_type_archive_link( get_query_var('post_type') ); } elseif (is_single() || is_page()) { $pageURL = get_permalink($wp_query->post->ID); } elseif (is_category()) { $pageURL = get_category_link($cat); } elseif (is_tag()) { $tag_id = $wpdb->get_var("SELECT ".$wpdb->terms.".term_id FROM $wpdb->term_taxonomy LEFT JOIN $wpdb->terms ON (".$wpdb->term_taxonomy.".term_id = ".$wpdb->terms.".term_id) WHERE ".$wpdb->terms.".slug = '$tag' AND ".$wpdb->term_taxonomy.".taxonomy = 'post_tag' LIMIT 1"); $pageURL = get_tag_link($tag_id); } elseif (is_author()) { $pageURL = get_author_posts_url($author); } elseif (is_date()) { if ($day) { $pageURL = get_day_link( $year, $monthnum, $day); } elseif ($monthnum) { $pageURL = get_month_link( $year, $monthnum, $day); } elseif ($year) { $pageURL = get_year_link( $year, $monthnum, $day); } } elseif (is_search()) { $pageURL = get_bloginfo('wpurl'); if ("/" != substr($pageURL, -1)) $pageURL = $pageURL . "/"; $pageURL .= '?s='.stripslashes(strip_tags($_REQUEST['s'])).''; } if (!$pageURL || $pageURL=="" || !is_string($pageURL)) { $pageURL = ""; $pageURL = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } //————–added by mick if (!strstr(get_bloginfo('url'),'www.')) $pageURL = str_replace('www.','', $pageURL ); //——————– } if ($pageURL && !is_search()) if ("/" != substr($pageURL, -1)) $pageURL = $pageURL . "/"; return $pageURL; } /** * Add function to widgets_init that'll load our widget. * @since 0.1 */ add_action( 'widgets_init', 'danixland_user_panel' ); /** * Register our widget. * 'User_Panel' is the widget class used below. * * @since 0.1 */ function danixland_user_panel() { register_widget( 'User_Panel' ); } /** * User_Panel class. * This class handles everything that needs to be handled with the widget: * the settings, form, display, and update. Nice! * * @since 0.1 */ class User_Panel extends WP_Widget { /** * Widget setup. */ function __construct() { parent::__construct( 'dnx-user-panel', // id_base __('danixland User Panel', 'dnxup' ), // Name array( 'description' => __('An improved version of the meta widget', 'dnxup') ) ); } /** * How to display the widget on the public side of the site. */ public function widget( $args, $instance ) { extract( $args ); global $user_ID, $current_user; $dnxup_options = get_option('dnxup_options'); extract( $dnxup_options ); // Let's use our title if($user_ID != '') { // if user is logged in let's greet him good $current_user = wp_get_current_user(); if( '' != $logged_in_heading ) { $title = apply_filters('widget_title', str_replace('%username%',ucwords($current_user->display_name),$logged_in_heading)); } else { $title = false; } } else { // user is not logged in, let's treat him as a guest if( '' != $logged_out_heading ) { $title = apply_filters('widget_title', str_replace('%username%',ucwords($current_user->display_name),$logged_out_heading)); } else { $title = false; } } /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ( $title ) echo $before_title . $title . $after_title; /** * if user is logged in to your site * @since 0.8 */ if( $user_ID != '' ) { /* If show_gravatar was selected, show the User's Gravatar. */ if ( $show_gravatar ) { echo get_avatar($user_ID, 75); } echo ''; /** * else if user is logged out and registration is disabled * @since 0.8 */ } else { if( ! get_option('users_can_register') ) { echo ''; /** * or if user is still logged out but user registration is enabled * @since 0.9 */ } else { echo ''; } } /* After widget (defined by themes). */ echo $after_widget; } /** * Displays just a quick notice with a link to the Settings page */ public function form( $instance ) { ?>

Settings Page?', 'dnxup'), admin_url('options-general.php?page=dnxup_options') ); ?>