/** * Returns the user array that creates the user dropdown in the authors metabox. * * Developer note: Using array_merge was reordering the array keys, causing the keys, * which signified the user id, to cause the plugin to assign incorrect authors. * This copying of arrays by brute force ensures that the order of elements and the * numbering of keys is retained. * * @param bool|integer|string $user_ids A user ID, or login, or an array of such * @param bool $existing_only If true, returns only existing users in a flat array. Otherwise, returns a structure with additional data. * @param bool $login_names If true, will return an array where keys are login names. Otherwise, the keys will be IDs. Values are the login names regardless. * @since 2.0 */ public static function get_users_array( $user_ids = false, $existing_only = false, $login_names = false ) { // Get the users $users = WPRSS_FTP_Settings::get_users( true, $user_ids ); // Copy all users into this array $user_options = array(); foreach ( $users as $key => $value ) { $user_options[$login_names ? $value : $key] = $value; } // Return only existing if needed if( $existing_only ) return $user_options; // Create a new array $return_array = array( '.' => 'Author in feed' ); $existing_key = __( 'Existing user', WPRSS_TEXT_DOMAIN ); $return_array[ $existing_key ] = $user_options; // Return the array return $return_array; }