/**
     * Displays the widget control options in the Widgets admin screen.
     *
     * @since 0.1.0
     * @access public
     * @param  array  $instance
     * @return void
     */
    function form($instance)
    {
        // Merge the user-selected arguments with the defaults.
        $instance = wp_parse_args((array) $instance, $this->defaults);
        $order = array('ASC' => esc_attr__('Ascending', 'members'), 'DESC' => esc_attr__('Descending', 'members'));
        $orderby = array('display_name' => esc_attr__('Display Name', 'members'), 'email' => esc_attr__('Email', 'members'), 'ID' => esc_attr__('ID', 'members'), 'nicename' => esc_attr__('Nice Name', 'members'), 'post_count' => esc_attr__('Post Count', 'members'), 'registered' => esc_attr__('Registered', 'members'), 'url' => esc_attr__('URL', 'members'), 'user_login' => esc_attr__('Login', 'members'));
        $meta_key = array_merge(array(''), (array) members_get_user_meta_keys());
        $roles = members_get_role_names();
        asort($roles);
        $roles = array_merge(array('' => ''), $roles);
        ?>

		<div style="float: left;width: 48%;">

		<p>
			<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        esc_html_e('Title:', 'members');
        ?>
</label>
			<input type="text" class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" value="<?php 
        echo esc_attr($instance['title']);
        ?>
" />
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('orderby');
        ?>
"><?php 
        esc_html_e('Order By:', 'members');
        ?>
</label>
			<select class="widefat" id="<?php 
        echo $this->get_field_id('orderby');
        ?>
" name="<?php 
        echo $this->get_field_name('orderby');
        ?>
">
				<?php 
        foreach ($orderby as $option_value => $option_label) {
            ?>
					<option value="<?php 
            echo esc_attr($option_value);
            ?>
" <?php 
            selected($instance['orderby'], $option_value);
            ?>
><?php 
            echo esc_html($option_label);
            ?>
</option>
				<?php 
        }
        ?>
			</select>
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('order');
        ?>
"><?php 
        esc_html_e('Order:', 'members');
        ?>
</label>
			<select class="widefat" id="<?php 
        echo $this->get_field_id('order');
        ?>
" name="<?php 
        echo $this->get_field_name('order');
        ?>
">
				<?php 
        foreach ($order as $option_value => $option_label) {
            ?>
					<option value="<?php 
            echo esc_attr($option_value);
            ?>
" <?php 
            selected($instance['order'], $option_value);
            ?>
><?php 
            echo esc_html($option_label);
            ?>
</option>
				<?php 
        }
        ?>
			</select>
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('role');
        ?>
"><?php 
        esc_html_e('Role:', 'members');
        ?>
</label>
			<select class="widefat" id="<?php 
        echo $this->get_field_id('role');
        ?>
" name="<?php 
        echo $this->get_field_name('role');
        ?>
">
				<?php 
        foreach ($roles as $role => $name) {
            ?>
					<option value="<?php 
            echo esc_attr($role);
            ?>
" <?php 
            selected($instance['role'], $role);
            ?>
><?php 
            echo esc_html($name);
            ?>
</option>
				<?php 
        }
        ?>
			</select>
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('number');
        ?>
"><?php 
        esc_html_e('Limit:', 'members');
        ?>
</label>
			<input type="number" min="0" class="widefat code" id="<?php 
        echo $this->get_field_id('number');
        ?>
" name="<?php 
        echo $this->get_field_name('number');
        ?>
" value="<?php 
        echo esc_attr($instance['number']);
        ?>
" />
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('offset');
        ?>
"><?php 
        esc_html_e('Offset:', 'members');
        ?>
</label>
			<input type="number" min="1" class="widefat code" id="<?php 
        echo $this->get_field_id('offset');
        ?>
" name="<?php 
        echo $this->get_field_name('offset');
        ?>
" value="<?php 
        echo esc_attr($instance['offset']);
        ?>
" />
		</p>

		</div>
		<div style="float: right; width: 48%;">

		<p>
			<label for="<?php 
        echo $this->get_field_id('include');
        ?>
"><?php 
        esc_html_e('Include:', 'members');
        ?>
</label>
			<input type="text" class="widefat code" id="<?php 
        echo $this->get_field_id('include');
        ?>
" name="<?php 
        echo $this->get_field_name('include');
        ?>
" value="<?php 
        echo esc_attr($instance['include']);
        ?>
" />
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('exclude');
        ?>
"><?php 
        esc_html_e('Exclude:', 'members');
        ?>
</label>
			<input type="text" class="widefat code" id="<?php 
        echo $this->get_field_id('exclude');
        ?>
" name="<?php 
        echo $this->get_field_name('exclude');
        ?>
" value="<?php 
        echo esc_attr($instance['exclude']);
        ?>
" />
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('search');
        ?>
"><?php 
        esc_html_e('Search:', 'members');
        ?>
</label>
			<input type="text" class="widefat code" id="<?php 
        echo $this->get_field_id('search');
        ?>
" name="<?php 
        echo $this->get_field_name('search');
        ?>
" value="<?php 
        echo esc_attr($instance['search']);
        ?>
" />
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('meta_key');
        ?>
"><?php 
        esc_html_e('Meta Key:', 'members');
        ?>
</label>
			<select class="widefat" id="<?php 
        echo $this->get_field_id('meta_key');
        ?>
" name="<?php 
        echo $this->get_field_name('meta_key');
        ?>
">
				<?php 
        foreach ($meta_key as $meta) {
            ?>
					<option value="<?php 
            echo esc_attr($meta);
            ?>
" <?php 
            selected($instance['meta_key'], $meta);
            ?>
><?php 
            echo esc_html($meta);
            ?>
</option>
				<?php 
        }
        ?>
			</select>
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('meta_value');
        ?>
"><?php 
        esc_html_e('Meta Value:', 'members');
        ?>
</label>
			<input type="text" class="widefat code" id="<?php 
        echo $this->get_field_id('meta_value');
        ?>
" name="<?php 
        echo $this->get_field_name('meta_value');
        ?>
" value="<?php 
        echo esc_attr($instance['meta_value']);
        ?>
" />
		</p>

		</div>

		<div style="clear:both;">&nbsp;</div>
	<?php 
    }
예제 #2
0
/**
 * Returns an array of the role names of roles that do not have users.
 *
 * @since  1.0.0
 * @access public
 * @return array
 */
function members_get_inactive_role_names()
{
    return array_diff(members_get_role_names(), members_get_active_role_names());
}
예제 #3
0
 /**
  * Register a new object.
  *
  * @since  1.0.0
  * @access public
  * @param  string  $name
  * @param  array   $args  {
  *     @type string  $label        Internationalized text label.
  *     @type string  $icon         Count label in admin.
  *     @type array   $roles        Array of roles in the group.
  * }
  * @return void
  */
 public function __construct($name, $args = array())
 {
     $name = sanitize_key($name);
     $defaults = array('label' => '', 'label_count' => '', 'roles' => array(), 'show_in_view_list' => true);
     $this->args = wp_parse_args($args, $defaults);
     // Get the roles that exist.
     $existing_roles = array_keys(members_get_role_names());
     // Remove roles that don't exist.
     if ($this->args['roles']) {
         $this->args['roles'] = array_intersect($existing_roles, $this->args['roles']);
     }
     // Set the name.
     $this->args['name'] = $name;
 }