Ejemplo n.º 1
0
 /**
  * Prepare Items
  */
 function prepare_items()
 {
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = array();
     $this->_column_headers = array($columns, $hidden, $sortable);
     $this->items = Expire_User_Notifications_Admin::get_notifications();
 }
Ejemplo n.º 2
0
    /**
     * Options Page
     */
    function options_page()
    {
        global $expire_users, $wp_version;
        if (!isset($_REQUEST['updated'])) {
            $_REQUEST['updated'] = false;
        }
        ?>

		<div class="wrap">
			<?php 
        screen_icon();
        $tag = version_compare($wp_version, '4.3', '<') ? 'h2' : 'h1';
        echo '<' . $tag . '>' . esc_html__('Expire Users Settings', 'expire-users') . '</' . $tag . '>';
        ?>

			<?php 
        if (false !== $_REQUEST['updated']) {
            ?>
				<div><p><strong><?php 
            esc_html_e('Options saved', 'expire-users');
            ?>
</strong></p></div>
			<?php 
        }
        ?>

			<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 
        esc_html_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 
        esc_html_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 
        esc_html_e('Expiry Date', 'expire-users');
        ?>
</label></th>
						<td>
							<fieldset class="expire-user-date-options hide-if-js" style="display: block; ">
								<legend class="screen-reader-text"><span><?php 
        esc_html_e('Expiry Date', 'expire-users');
        ?>
</span></legend>
								<label for="expire_user_date_type_never">
									<input name="expire_users_default_expire_settings[expire_user_date_type]" type="radio" id="expire_user_date_type_never" value="never" <?php 
        checked('never', $expire_settings['expire_user_date_type']);
        ?>
>
									<?php 
        echo esc_html_x('Never', 'expire date type', 'expire-users');
        ?>
								</label><br>
								<label for="expire_user_date_type_in">
									<input name="expire_users_default_expire_settings[expire_user_date_type]" type="radio" id="expire_user_date_type_in" value="in" <?php 
        checked('in', $expire_settings['expire_user_date_type']);
        ?>
>
									<?php 
        echo esc_html_x('In', 'expire date type', 'expire-users');
        ?>
 <input type="text" id="expire_user_date_in_num" name="expire_users_default_expire_settings[expire_user_date_in_num]" value="<?php 
        echo esc_attr($expire_settings['expire_user_date_in_num']);
        ?>
" size="3" maxlength="3" tabindex="4" autocomplete="off">
									<select name="expire_users_default_expire_settings[expire_user_date_in_block]" id="expire_user_date_in_block">
										<?php 
        echo $expire_users->admin->date_block_menu_options($expire_settings['expire_user_date_in_block']);
        ?>
									</select>
								</label><br>
								<label for="expire_user_date_type_date">
									<input name="expire_users_default_expire_settings[expire_user_date_type]" type="radio" id="expire_user_date_type_date" value="on" <?php 
        checked('on', $expire_settings['expire_user_date_type']);
        ?>
>
									<?php 
        echo esc_html_x('On', 'expire date type', 'expire-users');
        ?>
 <select id="expire_users_default_expire_settings_expire_timestamp_mm" name="expire_users_default_expire_settings[expire_timestamp][mm]" tabindex="4">
										<?php 
        echo $expire_users->admin->month_menu_options($month_n);
        ?>
									</select>
									<input type="text" id="expire_users_default_expire_settings_expire_timestamp_dd" name="expire_users_default_expire_settings[expire_timestamp][dd]" value="<?php 
        echo esc_attr(date('d', $expire_timestamp));
        ?>
" size="2" maxlength="2" tabindex="4" autocomplete="off">, 
									<input type="text" id="expire_users_default_expire_settings_expire_timestamp_yyyy" name="expire_users_default_expire_settings[expire_timestamp][yyyy]" value="<?php 
        echo esc_attr(date('Y', $expire_timestamp));
        ?>
" size="4" maxlength="4" tabindex="4" autocomplete="off">
									@ <input type="text" id="expire_users_default_expire_settings_expire_timestamp_hrs" name="expire_users_default_expire_settings[expire_timestamp][hrs]" value="<?php 
        echo esc_attr(date('H', $expire_timestamp));
        ?>
" size="2" maxlength="2" tabindex="4" autocomplete="off">
									: <input type="text" id="expire_users_default_expire_settings_expire_timestamp_min" name="expire_users_default_expire_settings[expire_timestamp][min]" value="<?php 
        echo esc_attr(date('i', $expire_timestamp));
        ?>
" size="2" maxlength="2" tabindex="4" autocomplete="off">
								</label>
							</fieldset>
						</td>
					</tr>
					<tr>
						<th><label for="expire_user_role"><?php 
        esc_html_e('On Expire, Default to Role', 'expire-users');
        ?>
</label></th>
						<td>
							<select name="expire_users_default_expire_settings[expire_user_role]" id="expire_user_role">
								<option value="" <?php 
        selected('', $expire_settings['expire_user_role']);
        ?>
><?php 
        esc_html_e('Don\'t change role', 'expire-users');
        ?>
</option>
								<?php 
        wp_dropdown_roles($expire_settings['expire_user_role']);
        ?>
							</select>
						</td>
					</tr>
					<tr>
						<th><label for="postalcode"><?php 
        esc_html_e('Expire Actions', 'expire-users');
        ?>
</label></th>
						<td>
							<fieldset>
								<legend class="screen-reader-text"><span><?php 
        esc_html_e('Expire Actions', 'expire-users');
        ?>
</span></legend>
								<label for="expire_user_reset_password">
									<input name="expire_users_default_expire_settings[expire_user_reset_password]" type="checkbox" id="expire_user_reset_password" value="Y" <?php 
        checked('Y', $expire_settings['expire_user_reset_password']);
        ?>
>
									<?php 
        esc_html_e('Replace user\'s password with a randomly generated one', 'expire-users');
        ?>
								</label><br>
								<label for="expire_user_remove_expiry">
									<input name="expire_users_default_expire_settings[expire_user_remove_expiry]" type="checkbox" id="expire_user_remove_expiry" value="Y" <?php 
        checked('Y', $expire_settings['expire_user_remove_expiry']);
        ?>
>
									<?php 
        esc_html_e('Remove expiry details and allow user to continue to login', 'expire-users');
        ?>
								</label>
							</fieldset>
						</td>
					</tr>
					<tr>
						<th><label><?php 
        esc_html_e('Email Notifications', 'expire-users');
        ?>
</label></th>
						<td>
							<fieldset>
								<legend class="screen-reader-text"><span><?php 
        esc_html_e('Email Notifications', 'expire-users');
        ?>
</span></legend>
								<?php 
        $notifications = Expire_User_Notifications_Admin::get_notifications();
        foreach ($notifications as $notification) {
            $checked = '';
            $name = $notification['name'];
            if ('expire_users_notification_message' == $name) {
                $name = 'expire_user_email';
                $checked = checked('Y', $expire_settings['expire_user_email'], false);
            } elseif ('expire_users_notification_admin_message' == $name) {
                $name = 'expire_user_email_admin';
                $checked = checked('Y', $expire_settings['expire_user_email_admin'], false);
            }
            ?>
									<label for="<?php 
            echo esc_attr($name);
            ?>
" title="<?php 
            echo esc_attr($notification['description']);
            ?>
">
										<input name="expire_users_default_expire_settings[<?php 
            echo esc_attr($name);
            ?>
]" type="checkbox" id="<?php 
            echo esc_attr($name);
            ?>
" value="Y"<?php 
            echo $checked;
            ?>
 />
										<?php 
            echo esc_html($notification['notification']);
            ?>
									</label><br />
									<?php 
        }
        ?>
							</fieldset>
						</td>
					</tr>
				</table>

				<h3><?php 
        esc_html_e('Notification Emails', 'expire-users');
        ?>
</h3>
				<p><?php 
        esc_html_e('These emails are sent if you have checked the checkboxes on a user\'s profile.', 'expire-users');
        ?>
<br />
					<?php 
        esc_html_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>
				<?php 
        Expire_User_Notifications_Admin::admin_table();
        ?>

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

			</form>

		</div>

		<?php 
    }
Ejemplo n.º 3
0
    /**
     * Profile Fields
     *
     * @param  object|null  $user  Instance of WP_User.
     */
    public function profile_fields($user = null)
    {
        $can_edit_profile_expiry = $this->current_expire_user_can('expire_users_edit');
        if ($user) {
            $expire_user = new Expire_User($user->ID);
        } else {
            $expire_user = new Expire_User();
        }
        // Default Expire Date Field Values
        $radio_never = '';
        $radio_date = '';
        $days_n = 7;
        $date_in_block = 'days';
        $expire_timestamp = current_time('timestamp') + WEEK_IN_SECONDS;
        $month_n = '';
        if (isset($expire_user->expire_timestamp) && is_numeric($expire_user->expire_timestamp)) {
            $radio_date = checked(true, true, false);
            $days_n2 = floor(($expire_user->expire_timestamp - current_time('timestamp')) / DAY_IN_SECONDS);
            if ($days_n2 > 0) {
                $days_n = $days_n2;
            }
            $expire_timestamp = $expire_user->expire_timestamp;
            $days_n = ceil(($expire_timestamp - current_time('timestamp')) / DAY_IN_SECONDS);
            if ($days_n % 7 == 0) {
                $days_n = $days_n / 7;
                $date_in_block = 'weeks';
            }
        } else {
            $radio_never = checked(true, true, false);
        }
        $month_n = date('m', $expire_timestamp);
        ?>

		<h3><?php 
        esc_html_e('User Expiry Information', 'expire-users');
        ?>
</h3>

		<table class="form-table">
			<tr>
				<th><label for="address"><?php 
        esc_html_e('Expire Date', 'expire-users');
        ?>
</label></th>
				<td>

					<?php 
        if ($expire_user->user_id > 0) {
            ?>
						<div class="misc-pub-section curtime misc-pub-section-last" style="padding-left:0px;">
							<span id="timestamp"><?php 
            echo $expire_user->get_expire_date_display();
            ?>
</span>
							<?php 
            if ($can_edit_profile_expiry) {
                ?>
								<a href="#delete_user_edit_timestamp" class="delete-user-edit-timestamp hide-if-no-js" tabindex='4'><?php 
                esc_html_e('Edit', 'expire-users');
                ?>
</a>
							<?php 
            }
            ?>
						</div>
					<?php 
        }
        ?>

					<?php 
        if ($can_edit_profile_expiry) {
            ?>
						<fieldset class="expire-user-date-options <?php 
            if ($expire_user->user_id > 0) {
                echo 'hide-if-js';
            }
            ?>
">
							<legend class="screen-reader-text"><span><?php 
            esc_html_e('Expiry Date', 'expire-users');
            ?>
</span></legend>
							<label for="expire_user_date_type_never">
								<input name="expire_user_date_type" type="radio" id="expire_user_date_type_never" value="never" <?php 
            echo $radio_never;
            ?>
>
								<?php 
            esc_html_e('Never', 'expire-users');
            ?>
							</label><br />
							<label for="expire_user_date_type_in">
								<input name="expire_user_date_type" type="radio" id="expire_user_date_type_in" value="in">
								<?php 
            esc_html_e('In', 'expire-users');
            ?>
 <input type="text" id="expire_user_date_in_num" name="expire_user_date_in_num" value="<?php 
            echo $days_n;
            ?>
" size="3" maxlength="3" tabindex="4" autocomplete="off">
								<select name="expire_user_date_in_block" id="expire_user_date_in_block">
									<?php 
            echo $this->date_block_menu_options($date_in_block);
            ?>
								</select>
							</label><br />
							<label for="expire_user_date_type_date">
								<input name="expire_user_date_type" type="radio" id="expire_user_date_type_date" value="on" <?php 
            echo $radio_date;
            ?>
>
								<?php 
            esc_html_e('On', 'expire-users');
            ?>
 <select id="expire_user_date_on_mm" name="expire_user_date_on_mm" tabindex="4">
									<?php 
            echo $this->month_menu_options($month_n);
            ?>
								</select>
								<input type="text" id="expire_user_date_on_dd" name="expire_user_date_on_dd" value="<?php 
            echo esc_attr(date('d', $expire_timestamp));
            ?>
" size="2" maxlength="2" tabindex="4" autocomplete="off">, 
								<input type="text" id="expire_user_date_on_yyyy" name="expire_user_date_on_yyyy" value="<?php 
            echo esc_attr(date('Y', $expire_timestamp));
            ?>
" size="4" maxlength="4" tabindex="4" autocomplete="off">
								@ <input type="text" id="expire_user_date_on_hrs" name="expire_user_date_on_hrs" value="<?php 
            echo esc_attr(date('H', $expire_timestamp));
            ?>
" size="2" maxlength="2" tabindex="4" autocomplete="off">
								: <input type="text" id="expire_user_date_on_min" name="expire_user_date_on_min" value="<?php 
            echo esc_attr(date('i', $expire_timestamp));
            ?>
" size="2" maxlength="2" tabindex="4" autocomplete="off">
							</label>
						</fieldset>
					<?php 
        }
        ?>

				</td>
			</tr>
			<?php 
        if ($can_edit_profile_expiry) {
            ?>
				<tr>
					<th><label for="role"><?php 
            esc_attr_e('On Expire, Default to Role', 'expire-users');
            ?>
</label></th>
					<td>
						<select name="expire_user_role" id="expire_user_role">
							<?php 
            echo '<option value="">' . __("Don't change role", 'expire-users') . '</option>';
            wp_dropdown_roles($expire_user->on_expire_default_to_role);
            ?>
						</select>
					</td>
				</tr>
				<tr>
					<th><label><?php 
            esc_attr_e('Expire Actions', 'expire-users');
            ?>
</label></th>
					<td>
						<fieldset>
							<legend class="screen-reader-text"><span><?php 
            esc_attr_e('Expire Actions', 'expire-users');
            ?>
</span></legend>
							<label for="expire_user_reset_password">
								<input name="expire_user_reset_password" type="checkbox" id="expire_user_reset_password" value="Y" <?php 
            checked($expire_user->on_expire_user_reset_password);
            ?>
>
								<?php 
            esc_attr_e('Replace user\'s password with a randomly generated one', 'expire-users');
            ?>
</a>
							</label><br>
							<label for="expire_user_remove_expiry">
								<input name="expire_user_remove_expiry" type="checkbox" id="expire_user_remove_expiry" value="Y" <?php 
            checked($expire_user->on_expire_user_remove_expiry);
            ?>
>
								<?php 
            esc_attr_e('Remove expiry details and allow user to continue to login', 'expire-users');
            ?>
							</label>
						</fieldset>
					</td>
				</tr>
				<tr>
					<th><label><?php 
            esc_attr_e('Email Notifications', 'expire-users');
            ?>
</label></th>
					<td>
						<fieldset>
							<legend class="screen-reader-text"><span><?php 
            esc_attr_e('Email Notifications', 'expire-users');
            ?>
</span></legend>
							<?php 
            $notifications = Expire_User_Notifications_Admin::get_notifications();
            foreach ($notifications as $notification) {
                $checked = '';
                $name = $notification['name'];
                if ('expire_users_notification_message' == $name) {
                    $name = 'expire_user_email';
                    $checked = checked(1, $expire_user->on_expire_user_email, false);
                } elseif ('expire_users_notification_admin_message' == $name) {
                    $name = 'expire_user_email_admin';
                    $checked = checked(1, $expire_user->on_expire_user_email_admin, false);
                }
                ?>
								<label for="<?php 
                echo esc_attr($name);
                ?>
" title="<?php 
                echo esc_attr($notification['description']);
                ?>
">
									<input name="<?php 
                echo esc_attr($name);
                ?>
" type="checkbox" id="<?php 
                echo esc_attr($name);
                ?>
" value="Y"<?php 
                echo $checked;
                ?>
 />
									<?php 
                echo esc_html($notification['notification']);
                ?>
								</label><br />
								<?php 
            }
            ?>
							<br /><a href="<?php 
            echo admin_url('users.php?page=expire_users');
            ?>
"><?php 
            esc_attr_e('View and configure messages', 'expire-users');
            ?>
</a>
						</fieldset>
					</td>
				</tr>
			<?php 
        }
        ?>
		</table>

		<?php 
    }