public function prepare_items() { $profileNames = $this->profileManager->get_all_profile_names(); $totalItems = count($profileNames); $profilesPerPage = $this->get_items_per_page('wpmsm_profiles_per_page', 10); if ($totalItems < $profilesPerPage) { $page = 1; $totalPages = 1; } else { $page = $this->get_pagenum(); $totalPages = ceil($totalItems / $profilesPerPage); } if ($page > $totalPages) { $page = $totalPages; } $start = ($page - 1) * $profilesPerPage; if ($totalPages > 1) { $profileNames = array_slice($profileNames, $start, $profilesPerPage); } $this->items = array(); foreach ($profileNames as $name) { $this->items[$name] = $this->profileManager->get_profile($name); } $this->set_pagination_args(array('total_items' => $totalItems, 'per_page' => $profilesPerPage)); }
private static function _render_settings() { $profileManager = new WP_MSM_Profile_Manager(); $currentProfile = WP_MSM_Options::instance()->profile; $profiles = $profileManager->get_all_profile_names(); ?> <form method="post" action=""> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row"><label for="wpmsm_settings_profile">Please select a server profile</label></th> <td> <select id="wpmsm_settings_profile" name="wpmsm_settings[profile]"> <?php foreach ($profiles as $profile) { $profile = $profileManager->get_profile($profile); ?> <option value="<?php echo esc_attr($profile->name); ?> "<?php selected($profile->name, $currentProfile); ?> > <?php echo esc_html($profile->displayName); ?> </option> <?php } ?> </select> </td> </tr> </tbody> </table> </form> <?php }