Skip to content

Commit

Permalink
Whitespace code tidy.
Browse files Browse the repository at this point in the history
  • Loading branch information
benhuson committed Apr 15, 2014
1 parent b3dac40 commit 3bfd2ea
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 106 deletions.
60 changes: 30 additions & 30 deletions admin/class-expire-user-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@
// @todo Add expired role

class Expire_User_Admin {

var $settings = null;

function Expire_User_Admin() {
$this->settings = new Expire_User_Settings();

// Profile Fields
add_action( 'show_user_profile', array( $this, 'extra_user_profile_fields' ) );
add_action( 'edit_user_profile', array( $this, 'extra_user_profile_fields' ) );

// Save Fields
add_action( 'personal_options_update', array( $this, 'save_extra_user_profile_fields' ) );
add_action( 'edit_user_profile_update', array( $this, 'save_extra_user_profile_fields' ) );

// Scripts and Styles
add_action( 'admin_print_styles', array( $this, 'admin_print_styles' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );

// User Columns
add_filter( 'manage_users_columns', array( $this, 'manage_users_columns' ) );
add_action( 'manage_users_custom_column', array( $this, 'manage_users_custom_column' ), 10, 3 );
}

/**
* Manage Users Columns
*/
function manage_users_columns( $columns ) {
$columns['expire_user'] = __( 'Expire Date', 'expire-users' );
return $columns;
}

/**
* Manage Users Custom Column
*/
Expand All @@ -57,7 +57,7 @@ function manage_users_custom_column( $value, $column_name, $user_id ) {
}
return $value;
}

/**
* Check Capabilities
*/
Expand All @@ -68,28 +68,28 @@ function current_expire_user_can( $cap ) {
}
return false;
}

/**
* Save Extra User Profile Fields
*/
function save_extra_user_profile_fields( $user_id ) {
if ( ! current_user_can( 'edit_user', $user_id ) ) {
return false;
}

$user = new Expire_User( $user_id );
$user->set_expire_data( $_POST );
$user->save_user();
}

/**
* Extra User Profile Fields
*/
function extra_user_profile_fields( $user ) {
$can_edit_profile_expiry = $this->current_expire_user_can( 'expire_users_edit' );

$expire_user = new Expire_User( $user->ID );

// Expire Date Field Values
$radio_never = '';
$radio_date = '';
Expand Down Expand Up @@ -125,7 +125,7 @@ function extra_user_profile_fields( $user ) {
<a href="#delete_user_edit_timestamp" class="delete-user-edit-timestamp hide-if-no-js" tabindex='4'><?php _e( 'Edit', 'expire-users' ) ?></a>
<?php } ?>
</div>

<?php if ( $can_edit_profile_expiry ) { ?>
<fieldset class="expire-user-date-options hide-if-js">
<legend class="screen-reader-text"><span><?php _e( 'Expiry Date', 'expire-users' ); ?></span></legend>
Expand All @@ -152,7 +152,7 @@ function extra_user_profile_fields( $user ) {
</label>
</fieldset>
<?php } ?>

</td>
</tr>
<?php if ( $can_edit_profile_expiry ) { ?>
Expand Down Expand Up @@ -195,7 +195,7 @@ function extra_user_profile_fields( $user ) {
</table>
<?php
}

/**
* Date Block Menu Options
*/
Expand All @@ -212,7 +212,7 @@ function date_block_menu_options( $selected = '' ) {
}
return $output;
}

/**
* Month Menu Options
*/
Expand All @@ -237,29 +237,29 @@ function month_menu_options( $selected = '' ) {
}
return $output;
}

/**
* Admin Print Styles
*/
function admin_print_styles() {
$stylesheet_url = plugins_url( 'css/admin.css', dirname( __FILE__ ) );
$stylesheet_file = WP_PLUGIN_DIR . '/expire-users/css/admin.css';
if ( file_exists( $stylesheet_file ) ) {
wp_register_style( 'css-layouts-admin', $stylesheet_url );
wp_enqueue_style( 'css-layouts-admin' );
}
$stylesheet_file = WP_PLUGIN_DIR . '/expire-users/css/admin.css';
if ( file_exists( $stylesheet_file ) ) {
wp_register_style( 'css-layouts-admin', $stylesheet_url );
wp_enqueue_style( 'css-layouts-admin' );
}
}

/**
* Admin Enqueue Scripts
*/
function admin_enqueue_scripts() {
wp_register_script( 'expire-users-admin-user', plugins_url( 'js/admin-user.js', dirname( __FILE__ ) ), array( 'jquery' ), '1.0' );
wp_enqueue_script( 'expire-users-admin-user' );
wp_localize_script( 'expire-users-admin-user', 'expire_users_admin_user_i18n', array(
'cancel' => __( 'Cancel', 'expire-users' ),
'edit' => __( 'Edit', 'expire-users' )
) );
wp_localize_script( 'expire-users-admin-user', 'expire_users_admin_user_i18n', array(
'cancel' => __( 'Cancel', 'expire-users' ),
'edit' => __( 'Edit', 'expire-users' )
) );
}

}
48 changes: 24 additions & 24 deletions admin/settings.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<?php

class Expire_User_Settings {

function Expire_User_Settings() {
add_action( 'admin_init', array( $this, 'register_settings' ) );
add_action( 'admin_menu', array( $this, 'options_page_item' ) );
}

/**
* Create Options Page Item
*/
function options_page_item() {
add_users_page( __( 'Expire Settings', 'expire-users' ), __( 'Expire Settings', 'expire-users' ), 'manage_options', 'expire_users', array( $this, 'options_page' ) );
}

/**
* Register Settings
*/
function register_settings() {
register_setting( 'expire_users_options_group', 'expire_users_default_expire_settings', array( $this, 'validate_expire_settings' ) );
register_setting( 'expire_users_options_group', 'expire_users_notification_message', array( $this, 'validate_email_message' ) );
register_setting( 'expire_users_options_group', 'expire_users_notification_admin_message', array( $this, 'validate_email_message' ) );
register_setting( 'expire_users_options_group', 'expire_users_default_expire_settings', array( $this, 'validate_expire_settings' ) );
register_setting( 'expire_users_options_group', 'expire_users_notification_message', array( $this, 'validate_email_message' ) );
register_setting( 'expire_users_options_group', 'expire_users_notification_admin_message', array( $this, 'validate_email_message' ) );
}

/**
* Validate Expire Settings
*/
Expand All @@ -37,15 +37,15 @@ function validate_expire_settings( $input ) {
$input['expire_timestamp'] = mktime( $defaults['hrs'], $defaults['min'], 0, $defaults['mm'], $defaults['dd'], $defaults['yyyy'] );
return $input;
}

/**
* Validate Email Message
* Strips out HTML and scripts.
*/
function validate_email_message( $input ) {
return wp_kses( $input, array() );
}

/**
* Get Default Expire Settings
*/
Expand All @@ -65,7 +65,7 @@ function get_default_expire_settings() {
$settings = wp_parse_args( get_option( 'expire_users_default_expire_settings', $default_settings ), $default_settings );
return $settings;
}

/**
* Options Page
*/
Expand All @@ -75,37 +75,37 @@ function options_page() {
$_REQUEST['updated'] = false;
}
?>

<div class="wrap">
<?php
screen_icon();
echo '<h2>' . __( 'Expire Users Settings', 'expire-users' ) . '</h2>';
?>

<?php if ( false !== $_REQUEST['updated'] ) : ?>
<div><p><strong><?php _e( 'Options saved' ); ?></strong></p></div>
<?php endif; ?>

<form method="post" action="options.php">

<?php
$expire_settings = $this->get_default_expire_settings();
$notification_message = get_option( 'expire_users_notification_message' );
$notification_admin_message = get_option( 'expire_users_notification_admin_message' );
$expire_timestamp = $expire_settings['expire_timestamp'];
$month_n = date( 'm', $expire_settings['expire_timestamp'] );
?>

<?php settings_fields( 'expire_users_options_group' ); ?>

<h3><?php _e( 'Registered User Expiry Settings', 'expire-users' ); ?></h3>
<p>
<label for="expire_user_auto_expire_registered_users">
<input name="expire_users_default_expire_settings[auto_expire_registered_users]" type="checkbox" id="expire_user_auto_expire_registered_users" value="Y" <?php checked( 'Y', $expire_settings['auto_expire_registered_users'] ); ?>>
<?php _e( 'Automatically set expiry date for new users who register via the registration form.', 'expire-users' ); ?>
</label>
</p>

<table class="form-table expire_user_auto_expire_registered_users_toggle">
<tr valign="top">
<th scope="row"><label for="expire_user_date_type_never"><?php _e( 'Expiry Date', 'expire-users' ); ?></label></th>
Expand Down Expand Up @@ -170,12 +170,12 @@ function options_page() {
</td>
</tr>
</table>

<h3><?php _e( 'Notification Emails', 'expire-users' ); ?></h3>
<p><?php _e( 'These emails are sent if you have checked the checkboxes on a user\'s profile.', 'expire-users' ); ?><br />
<?php _e( 'You may use the following placeholders in the notification email messages below:', 'expire-users' ); ?></p>
<p><code>%%expirydate%%</code> <code>%%username%%</code> <code>%%name%%</code> <code>%%sitename%%</code></p>

<table class="form-table">
<tr valign="top">
<th scope="row"><label for="expire_users_notification_message"><?php _e( 'User Notification Email', 'expire-users' ); ?></label></th>
Expand All @@ -186,14 +186,14 @@ function options_page() {
<td><p><textarea id="expire_users_notification_admin_message" name="expire_users_notification_admin_message" rows="5" cols="50" class="large-text code"><?php echo $notification_admin_message; ?></textarea></p></td>
</tr>
</table>

<p class="submit"><input type="submit" value="<?php _e( 'Save Options' ); ?>" class="button-primary" /></p>

</form>

</div>

<?php
}

}
Loading

0 comments on commit 3bfd2ea

Please sign in to comment.