$login_label = apply_filters('show_me_the_admin_login_text', __('Login to WordPress', 'show-me-the-admin')); // Print the button ?> <a id="show-me-the-admin-login" href="<?php echo wp_login_url(site_url($login_redirect)); ?> "><?php echo $login_label; ?> </a><?php } } } } /** * Returns the instance of our main Show_Me_The_Admin class. * * Will come in handy when we need to access the * class to retrieve data throughout the plugin. * * @since 1.0.0 * @access public * @return Show_Me_The_Admin */ function show_me_the_admin() { return Show_Me_The_Admin::instance(); } // Let's get this show on the road show_me_the_admin();
/** * Adds custom user profile settings. * * @access public * @since 1.0.0 * @param WP_User - $profile_user - the current WP_User object */ public function add_user_profile_settings($profile_user) { // Get site settings $site_settings = show_me_the_admin()->get_unmodified_settings(); // If blank and network active, merge with network settings if (!is_array($site_settings) && show_me_the_admin()->is_network_active) { // Make it an array $site_settings = array(); // Get network settings $network_settings = show_me_the_admin()->get_unmodified_settings(true); // Make sure its an array if (empty($network_settings)) { $network_settings = array(); } // Remove empty values for merging $site_settings = array_filter($site_settings); $network_settings = array_filter($network_settings); // Merge site with network settings $site_settings = wp_parse_args($site_settings, $network_settings); } // Disable if the user role isn't allowed $user = get_userdata($profile_user->ID); if (isset($site_settings['user_roles']) && !($user->roles && is_array($site_settings['user_roles']) && array_intersect($user->roles, $site_settings['user_roles']))) { $site_settings['disable'] = true; } // If this user can't have the functionality, then no point in showing the settings if (isset($site_settings['disable']) && $site_settings['disable'] == true) { return; } // Get the user settings $user_settings = show_me_the_admin()->get_user_settings($profile_user->ID); // Set the selected features $user_features = isset($user_settings['features']) ? $user_settings['features'] : array(); // Set the default phrases $default_show_phrase = !empty($site_settings['show_phrase']) ? $site_settings['show_phrase'] : SHOW_ME_THE_ADMIN_SHOW_PHRASE; $default_hide_phrase = !empty($site_settings['hide_phrase']) ? $site_settings['hide_phrase'] : SHOW_ME_THE_ADMIN_HIDE_PHRASE; // Make sure we don't show the notice anymore since they've viewed their profile settings $this->add_user_notice(); ?> <div id="smta-user-profile-settings"> <h2><?php _e('Show Me The Admin Toolbar', 'show-me-the-admin'); ?> </h2> <p><?php _e('The toolbar makes it really easy to move back and forth between viewing your site and editing your site but sometimes the toolbar itself can be intrusive. This functionality hides your toolbar and enables you to make it appear, and disappear, using a variety of methods. <strong><em>Your "Show Toolbar when viewing site" setting must be enabled.</em></strong>', 'show-me-the-admin'); ?> </p> <table id="show-me-the-admin-user-profile" class="form-table show-me-the-admin-settings smta-user-profile-settings"> <tbody> <tr> <td> <fieldset> <legend><strong><?php _e('What features would you like to enable?', 'show-me-the-admin'); ?> </strong></legend> <div class="smta-choices vertical"> <label><?php _e('#1', 'show-me-the-admin'); ?> - <input type="checkbox" name="show_me_the_admin[features][]" value="keyphrase"<?php checked(isset($user_features) && is_array($user_features) && in_array('keyphrase', $user_features)); ?> /> <?php _e('Hide toolbar and make it appear by typing a phrase (<em>customize the phrases below</em>)', 'show-me-the-admin'); ?> </label> <label><?php _e('#2', 'show-me-the-admin'); ?> - <input type="checkbox" name="show_me_the_admin[features][]" value="button"<?php checked(isset($user_features) && is_array($user_features) && in_array('button', $user_features)); ?> /> <?php _e('Hide toolbar and show WordPress button in top left corner to click to appear', 'show-me-the-admin'); ?> </label> <label><?php _e('#3', 'show-me-the-admin'); ?> - <input type="checkbox" name="show_me_the_admin[features][]" value="hover"<?php checked(isset($user_features) && is_array($user_features) && in_array('hover', $user_features)); ?> /> <?php _e('Hide toolbar and make it appear when mouse hovers near top of window', 'show-me-the-admin'); ?> </label> </div> </fieldset> </td> </tr> <tr> <td id="smta-features-disable-td"> <fieldset> <legend class="screen-reader-text"> <span><?php _e('Disable all features', 'show-me-the-admin'); ?> </span> </legend> <div class="smta-choices vertical"> <label for="smta-features-disable">* <input name="show_me_the_admin[disable]" type="checkbox" id="smta-features-disable" value="1"<?php checked(isset($user_settings['disable']) && $user_settings['disable'] == true); ?> /> <strong><?php _e('Disable all features', 'show-me-the-admin'); ?> </strong></label> <p class="description"><?php _e('If you leave all features unchecked, it will implement the site\'s selected features. Use this setting if you would like to disable this toolbar functionality for when you are logged in.', 'show-me-the-admin'); ?> </p> </div> </fieldset> </td> </tr> </tbody> </table> <h3><?php _e('Settings For Feature #1 - Hide toolbar and make it appear by typing a phrase', 'show-me-the-admin'); ?> </h3> <table id="show-me-the-admin-user-profile-keyphrase" class="form-table show-me-the-admin-settings smta-user-profile-settings"> <tbody> <tr> <td> <label for="smta-show-phrase"><strong><?php _e('Phrase to type to show the toolbar', 'show-me-the-admin'); ?> </strong></label> <input name="show_me_the_admin[show_phrase]" type="text" id="smta-show-phrase" value="<?php esc_attr(isset($user_settings['show_phrase']) ? $user_settings['show_phrase'] : null); ?> " placeholder="<?php esc_attr($default_show_phrase); ?> " class="regular-text" /> <p class="description"><?php printf(__('If left blank, will use your site\'s default phrase "%s".', 'show-me-the-admin'), $default_show_phrase); ?> </p> </td> </tr> <tr> <td> <label for="smta-hide-phrase"><strong><?php _e('Phrase to type to hide the toolbar', 'show-me-the-admin'); ?> </strong></label> <input name="show_me_the_admin[hide_phrase]" type="text" id="smta-hide-phrase" value="<?php esc_attr(isset($user_settings['hide_phrase']) ? $user_settings['hide_phrase'] : null); ?> " placeholder="<?php esc_attr($default_hide_phrase); ?> " class="regular-text" /> <p class="description"><?php printf(__('If left blank, will use your site\'s default phrase "%s".', 'show-me-the-admin'), $default_hide_phrase); ?> </p> </td> </tr> </tbody> </table> </div><?php }