Total users.

@since 160524 User utils.

@param array $args Behavioral args.

@return int Total users.
423239
public function total(array $args = []): int
    {
        // Establish args.

        $default_args = [
            // Also used by {@link all()}.
            'filters'  => [],
            'no_cache' => false,
        ];
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);

        $args['filters']  = (array) $args['filters'];
        $args['no_cache'] = (bool) $args['no_cache'];

        // Check cache; already did this query?

        $cache_keys = $args; // Keys to consider when checking the cache.
        unset($cache_keys['no_cache']); // Cache key exclusions.

        if (($total = &$this->cacheKey(__FUNCTION__, $cache_keys)) !== null && !$args['no_cache']) {
            return $total; // Already cached this.
        }
        // Establish total users in the query.

        $WP_User_Query = new \WP_User_Query(array_merge($args['filters'], [
            'fields' => 'ID', 'offset' => 0, 'paged' => 1, 'number' => 1, 'count_total' => true,
        ]));
        return $total = (int) $WP_User_Query->get_total();
    }
816824
public static function min(array $args)
    {
        usort(
            $args,
            function ($a, $b) {
                return count($a) < count($b) ? 1 : -1;
            }
        );
        return count(end($args));
    }
753073
public function userEnqueue($markup, array $args = [])
    {
        if (!isset($args['for_user_id'])) {
            $args['for_user_id'] = (int) get_current_user_id();
        }
        if (!$args['for_user_id']) {
            return; // Nothing to do.
        }
        $this->enqueue($markup, $args);
    }
1179868
public static function run($args, $extra = [])
    {
        static::$_out = '';
        $argv = explode(' ', "dummy-shell.php {$args}");
        $dispatcher = new WebShellDispatcher($argv);

        ob_start();
        $response = $dispatcher->dispatch($extra);
        static::$_out = ob_get_clean();

        return (int)($response === 0);
    }
1188938
public function triggerAndCount($name, ...$args)
    {
        if ($this->addThisToEvents) {
            array_unshift($args, $this);
        }
        $cnt = 0;
        if (isset($this->eventHandlers[$name])) {
            $this->lastEventName = $name;
            foreach ($this->eventHandlers[$name] as $cb) {
                if ($cb(...$args) !== 0) {
                    ++$cnt;
                }
            }
        }
        return $cnt;
    }
380931
public function total(array $args = []): int
    {
        $WpDb = $this->s::wpDb();

        // Establish args.

        $default_args = [
            // Also used by {@link all()}.
            'for_comments_only' => false,

            'include_post_ids' => [],
            'exclude_post_ids' => [],

            'include_post_types' => [],
            'exclude_post_types' => [],

            'include_post_statuses' => [],
            'exclude_post_statuses' => [],

            'exclude_drafts'             => true,
            'exclude_revisions'          => true,
            'exclude_trash'              => true,
            'exclude_password_protected' => false,
            'exclude_nav_menu_items'     => true,

            'no_cache' => false,
        ];
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);

        // Also used by {@link all()}.
        $args['for_comments_only'] = (bool) $args['for_comments_only'];

        $args['include_post_ids'] = (array) $args['include_post_ids'];
        $args['exclude_post_ids'] = (array) $args['exclude_post_ids'];

        $args['include_post_types'] = (array) $args['include_post_types'];
        $args['exclude_post_types'] = (array) $args['exclude_post_types'];

        $args['include_post_statuses'] = (array) $args['include_post_statuses'];
        $args['exclude_post_statuses'] = (array) $args['exclude_post_statuses'];

        $args['exclude_drafts']             = (bool) $args['exclude_drafts'];
        $args['exclude_revisions']          = (bool) $args['exclude_revisions'];
        $args['exclude_trash']              = (bool) $args['exclude_trash'];
        $args['exclude_password_protected'] = (bool) $args['exclude_password_protected'];
        $args['exclude_nav_menu_items']     = (bool) $args['exclude_nav_menu_items'];

        $args['no_cache'] = (bool) $args['no_cache'];

        // Check cache; already did this query?

        $cache_keys = $args; // Keys to consider when checking the cache.
        unset($cache_keys['no_cache']); // Cache key exclusions.

        if (($total = &$this->cacheKey(__FUNCTION__, $cache_keys)) !== null && !$args['no_cache']) {
            return $total; // Already cached this.
        }
        // Build the full SQL based on the arguments/data above.

        $sql = 'SELECT SQL_CALC_FOUND_ROWS `ID` FROM `'.esc_sql($WpDb->posts).'`'.

                ' WHERE 1=1'.// Initialize the WHERE clause in this query.

                ($args['include_post_ids'] ? ' AND `ID` IN('.$this->c::quoteSqlIn($args['include_post_ids']).')' : '').
                ($args['exclude_post_ids'] ? ' AND `ID` NOT IN('.$this->c::quoteSqlIn($args['exclude_post_ids']).')' : '').

                ($args['include_post_types'] ? ' AND `post_type` IN('.$this->c::quoteSqlIn($args['include_post_types']).')' : '').
                ($args['exclude_post_types'] ? ' AND `post_type` NOT IN('.$this->c::quoteSqlIn($args['exclude_post_types']).')' : '').

                ($args['include_post_statuses'] ? ' AND `post_status` IN('.$this->c::quoteSqlIn($args['include_post_statuses']).')' : '').
                ($args['exclude_post_statuses'] ? ' AND `post_status` NOT IN('.$this->c::quoteSqlIn($args['exclude_post_statuses']).')' : '').

                ($args['exclude_drafts'] ? " AND `post_type` NOT IN('draft','auto-draft')" : '').
                ($args['exclude_revisions'] ? " AND `post_type` != 'revision'" : '').
                ($args['exclude_trash'] ? " AND `post_status` != 'trash'" : '').
                ($args['exclude_password_protected'] ? " AND `post_password` = ''" : '').
                ($args['exclude_nav_menu_items'] ? " AND `post_type` != 'nav_menu_item'" : '').

                ($args['for_comments_only'] ? " AND (`comment_status` IN('1', 'open', 'opened') OR `comment_count` > '0')" : '').

                ' LIMIT 1'; // Only one to check `FOUND_ROWS()`.

        // Run the query and return total.

        if ($WpDb->query($sql) === false) {
            throw $this->c::issue('Query failure.');
        }
        return $total = (int) $WpDb->get_var('SELECT FOUND_ROWS()');
    }
74150
public static function get_users_count($context, $search = '') {
        global $DB;

        list($sql, $params) = self::get_users_sql_and_params($context, $search, true);
        return $DB->count_records_sql($sql, $params);

    }
695336
public function gcdm( $args )
	 {
		if( count( $args ) )
		{
			$min = $this->min( $args );
			for( $i=$min; $i>0; $i-- )
			{
				$a = true;
				foreach( $args as $arg )
					if( $arg % $i != 0 )
						$a = false;
				if( $a )
					return $i;
			}
		}
		return false;
	}
1122749
protected function getExistingMatchingUser(array $args)
    {
        $user_id = $this->getUserIdFromLogin($args['user_login']);
        $user    = $this->getDriver()->user->get($user_id);

        /* users can have more than one role so needs to be a special case */
        if (array_key_exists('role', $args)) {
            $this->checkUserHasRole($user, $args['role']);
        }

        /*
         * Loop through each of the passed arguements.
         * if they are arguments which apply to users
         * then check that that which exist matches that which was specified.
         */
        foreach ($args as $parameter => $value) {
            if ($parameter === 'password') {
                continue;
            }

            if ($this->isValidUserParameter($parameter) && $user->$parameter !== $args[$parameter]) {
                throw new UnexpectedValueException('[W804] User with login: ' . $user->user_login . 'exists, but ' . $parameter . ' is ' . $user->$parameter . ' not ' . $args[$parameter] . 'which was specified');
            }
        }

        return $user;
    }
738402
public function handleDelete(Args $args)
    {
        $pluginClass = $args->getArgument('class');

        if (!$this->manager->hasPluginClass($pluginClass)) {
            throw new RuntimeException(sprintf(
                'The plugin class "%s" is not installed.',
                $pluginClass
            ));
        }

        $this->manager->removePluginClass($pluginClass);

        return 0;
    }
22048
public function actionStat($user = null)
    {
        if ($user === null) {
            $count = User::find()->count();
            echo "Total number of user(s): " . $count . "\n";
            if ($count == 0) {
                return static::EXIT_CODE_NORMAL;
            }
            $last = User::find()->orderByCreatedAt(SORT_DESC)->one();
            /* @var $last User */
            echo "Latest user (" . $last->getID() . ") registered at " . $last->getCreatedAt() . "\n";
            return static::EXIT_CODE_NORMAL;
        }
        $user = $this->getUser($user);
        return static::EXIT_CODE_NORMAL;
    }
153940
public function activity($args = null)
    {
        $this->areArgumentsValid($args, ['maxItems']);

        return $this->client->get("$this->endpoint/$this->id/latestActivity", $args)->response();
    }
369658
public function route_useradd($args) {
		return $this->core->pj(
			$this->adm_add_user($args, false, true, true), 403);
	}
1014292
public function deleteUser($args)
    {
        // Get dependencies
        $userMapper = ($this->container->dataMapper)('UserMapper');

        // Delete user
        $User = $userMapper->make();
        $User->id = $args['id'];
        $userMapper->delete($User);

        // Redirect back to list of users
        return $this->redirect('adminUsers');
    }
848135
public function fetchUserCount($username, $show_group)
    {
        // Fetch user count
        $num_users = DB::forTable('users')
            ->tableAlias('u')
            ->whereGt('u.id', 1)
            ->whereNotEqual('u.group_id', ForumEnv::get('FEATHER_UNVERIFIED'));

        if ($username != '') {
            $num_users = $num_users->whereLike('u.username', str_replace('*', '%', $username));
        }
        if ($show_group > -1) {
            $num_users = $num_users->where('u.group_id', $show_group);
        }

        $num_users = $num_users->count('id');

        $num_users = Container::get('hooks')->fire('model.userlist.fetch_user_count', $num_users);

        return $num_users;
    }
569460
public function total(array $args = []): int
    {
        // Establish args.

        $default_args = [
            // Also used by {@link all()}.
            'include'                   => [],
            'exclude'                   => [],
            'exclude_deprecated_levels' => true,
            'no_cache'                  => false,
        ];
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);

        $args['include']                   = (array) $args['include'];
        $args['exclude']                   = (array) $args['exclude'];
        $args['exclude_deprecated_levels'] = (bool) $args['exclude_deprecated_levels'];
        $args['no_cache']                  = (bool) $args['no_cache'];

        // Check cache; already did this query?

        $cache_keys = $args; // Keys to consider when checking the cache.
        unset($cache_keys['no_cache']); // Cache key exclusions.

        if (($total = &$this->cacheKey(__FUNCTION__, $cache_keys)) !== null && !$args['no_cache']) {
            return $total; // Already cached this.
        }
        // Establish total caps in the query.

        $caps = $this->collectAll(); // All possible caps.

        $caps = $args['include'] ? array_intersect_key($caps, array_fill_keys($args['include'], true)) : $caps;
        $caps = $args['exclude'] ? array_diff_key($caps, array_fill_keys($args['exclude'], true)) : $caps;
        $caps = $args['exclude_deprecated_levels'] ? array_diff_key($caps, array_fill_keys($this->deprecated_levels, true)) : $caps;

        return $total = count($caps);
    }
1192562
public function handleRename(Args $args)
    {
        $moduleName = $args->getArgument('name');
        $newName = $args->getArgument('new-name');

        $this->moduleManager->renameModule($moduleName, $newName);

        return 0;
    }