diff --git a/confirm-user-registration.php b/confirm-user-registration.php index 782d5d1..cde6387 100644 --- a/confirm-user-registration.php +++ b/confirm-user-registration.php @@ -46,10 +46,7 @@ class Confirm_User_Registration */ function __construct() { - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); - - add_action( 'admin_print_scripts-users_page_confirm-user-registration', array( $this, 'enqueue_scripts' ) ); - add_action( 'admin_print_styles-users_page_confirm-user-registration', array( $this, 'enqueue_styles' ) ); + add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', array( $this, 'admin_menu' ) ); add_action( 'wp_ajax_confirm-user-registration-save_settings', array( $this, 'save_settings' ) ); add_action( 'admin_init', array( $this, 'load_plugin_textdomain' ) ); @@ -85,7 +82,7 @@ public function activation() endif; - add_option( 'confirm-user-registration', array( + add_site_option( 'confirm-user-registration', array( # Notifcation to admin 'administrator' => get_bloginfo('admin_email'), # Notification to users @@ -102,23 +99,23 @@ public function activation() if ( $this->is_upgrade() ) : // Create new option array - add_option( 'confirm-user-registration', array( + add_site_option( 'confirm-user-registration', array( # Notifcation to admin - 'administrator' => get_option( 'cur_administrator' ), + 'administrator' => get_site_option( 'cur_administrator' ), # Notification to users - 'error' => get_option( 'cur_error' ), + 'error' => get_site_option( 'cur_error' ), # Mail - 'from' => get_option( 'cur_from' ), - 'subject' => get_option( 'cur_subject' ), - 'message' => get_option( 'cur_message' ) + 'from' => get_site_option( 'cur_from' ), + 'subject' => get_site_option( 'cur_subject' ), + 'message' => get_site_option( 'cur_message' ) )); // Cleanup - delete_option( 'cur_administrator' ); - delete_option( 'cur_error' ); - delete_option( 'cur_from' ); - delete_option( 'cur_subject' ); - delete_option( 'cur_message' ); + delete_site_option( 'cur_administrator' ); + delete_site_option( 'cur_error' ); + delete_site_option( 'cur_from' ); + delete_site_option( 'cur_subject' ); + delete_site_option( 'cur_message' ); endif; @@ -136,7 +133,17 @@ public function activation() **/ public function admin_menu() { - add_users_page( _x( 'Confirm User Registration', 'Menu title', 'confirm-user-registration' ), _x( 'Confirm User Registration', 'Page title', 'confirm-user-registration' ), 'promote_users', 'confirm-user-registration', array( $this, 'management' ) ); + $page = add_submenu_page( + 'users.php', + _x( 'Confirm User Registration', 'Page title', 'confirm-user-registration' ), + _x( 'Confirm User Registration', 'Menu title', 'confirm-user-registration' ), + is_multisite() ? 'manage_network_users' : 'promote_users', + 'confirm-user-registration', + array( $this, 'management' ) + ); + + add_action( "admin_print_scripts-{$page}", array( $this, 'enqueue_scripts' ) ); + add_action( "admin_print_styles-{$page}", array( $this, 'enqueue_styles' ) ); } @@ -372,7 +379,7 @@ public function is_authenticated( $user_id ) **/ public function is_first_time() { - if ( !get_option( 'cur_from' ) && !get_option( 'confirm-user-registration' ) ) : + if ( !get_site_option( 'cur_from' ) && !get_site_option( 'confirm-user-registration' ) ) : return TRUE; else : return FALSE; @@ -389,7 +396,7 @@ public function is_first_time() **/ public function is_upgrade() { - if ( get_option( 'cur_from' ) ) : + if ( get_site_option( 'cur_from' ) ) : return TRUE; else : return FALSE; @@ -471,7 +478,7 @@ public function management_nav() public function management_settings() { $this->save_settings(); - $options = get_option( 'confirm-user-registration' ); + $options = get_site_option( 'confirm-user-registration' ); ?>

@@ -543,7 +550,7 @@ public function management_users( $tab ) @@ -568,7 +575,7 @@ public function management_users( $tab ) foreach ( $users as $user ) : $class = ( $i % 2 == 1 ) ? 'alternate' : 'default'; $user_data = get_userdata( $user->ID ); - $user_registered = mysql2date(get_option('date_format'), $user->user_registered); + $user_registered = mysql2date( get_option('date_format'), $user->user_registered ); ?> @@ -581,13 +588,13 @@ public function management_users( $tab ) display_name ?>
ID ) ) : ?> - + ID ) && current_user_can( 'delete_user', $user->ID ) && $user_ID != $user->ID ) : ?>  |  ID ) && $user_ID != $user->ID ) : ?> - +
@@ -648,7 +655,7 @@ public function save_settings() ); $options = apply_filters( 'confirm-user-registration-save-options', $options ); - update_option( 'confirm-user-registration', $options); + update_site_option( 'confirm-user-registration', $options); ?>
@@ -670,7 +677,7 @@ public function save_settings() **/ public function send_notification( $user_id ) { - $options = get_option( 'confirm-user-registration' ); + $options = get_site_option( 'confirm-user-registration' ); $user = get_userdata( $user_id ); $headers = 'FROM:' . $options['from'] . "\r\n"; @@ -698,14 +705,29 @@ public function wp_authenticate_user( $user ) return $user[0]; else : $user = new WP_Error(); - $options = get_option( 'confirm-user-registration' ); + $options = get_site_option( 'confirm-user-registration' ); $error_message = apply_filters( 'confirm-user-registration-error-message', $options['error'] ); $user->add( 'error', $error_message ); return $user; endif; } - + /** + * Returns the delete user link used on the CUR users list table. + * + * Multisite-compatible. + * + * @access protected + * @return string + * @author r-a-y + */ + protected function delete_user_link( $user_id = 0 ) { + if ( is_multisite() ) { + return network_admin_url( 'users.php?action=deleteuser&id=' . $user_id . '&_wpnonce=' . wp_create_nonce( 'deleteuser' ) ); + } else { + return admin_url( 'users.php?action=delete&user=' . $user_id . '&_wpnonce=' . wp_create_nonce( 'bulk-users' ) ); + } + } } new Confirm_User_Registration;