示例#1
0
    /**
     * Handles the display of the class blogs base admin page.
     *
     * @access private
     * @since 0.2
     */
    public function _class_blogs_admin_page()
    {
        // Disable any plugins that are not checked
        if ($_POST) {
            check_admin_referer('classblogs_admin');
            // Get a list of all plugins that are checked to be enabled
            $enabled = array();
            foreach ($_POST as $field => $value) {
                $plugin = str_replace('plugin_', '', $field);
                if ($plugin !== $field) {
                    $enabled[$plugin] = true;
                }
            }
            // Enable any plugins that were previously disabled, and disable any
            // that were previously enabled
            foreach (ClassBlogs::get_user_controlled_plugins() as $plugin) {
                if (array_key_exists($plugin->id, $enabled)) {
                    if (!$plugin->enabled) {
                        ClassBlogs::enable_plugin($plugin->id);
                    }
                } else {
                    if ($plugin->enabled) {
                        ClassBlogs::disable_plugin($plugin->id);
                    }
                }
            }
            self::show_admin_message(__('Enabled class-blogs plugins have been updated.  You must refresh the page to see the effects  of this.'), 'classblogs');
        }
        ?>
		<div class="wrap">
			<?php 
        ClassBlogs_Admin::show_admin_icon();
        ?>
			<h2><?php 
        _e('Class Blogs', 'classblogs');
        ?>
</h2>

			<p>
				<?php 
        _e('The class blogs plugin	suite will help you manage a blog for a class where you have control over the main blog and each student has full ownership of a child blog.', 'classblogs');
        ?>
			</p>
			<p>
				<?php 
        _e('The plugins that are part of this suite are provided in the list below.  Not every plugin has configurable options, but the ones that do will appear as links in the Class Blogs admin menu.  If you do not wish to use a certain component of the class-blogs suite, you can uncheck it in the list below and click on the "Update Enabled Plugins" button.', 'classblogs');
        ?>
			</p>

			<h3><?php 
        _e('Enabled Plugins', 'classblogs');
        ?>
</h3>

			<form method="post" action="">

				<table id="cb-enabled-plugins">

					<thead>
						<tr>
							<th class="toggle"><?php 
        _e('Enabled', 'classblogs');
        ?>
</th>
							<th class="name"><?php 
        _e('Name', 'classblogs');
        ?>
</th>
							<th class="description"><?php 
        _e('Description', 'classblogs');
        ?>
</th>
						</tr>
					</thead>

					<tbody>
						<?php 
        // Display each user-controlled plugin
        $plugins = ClassBlogs::get_user_controlled_plugins();
        foreach ($plugins as $plugin) {
            $field = 'plugin_' . $plugin->id;
            $name = $plugin->name ? $plugin->name : get_class($plugin->plugin);
            printf('
									<tr>
										<td class="toggle">
											<input type="checkbox" id="%1$s" name="%1$s" %2$s />
										</td>
										<td class="name">
											<label for="%1$s">%3$s</label>
										</td>
										<td class="description">%4$s</td>
									</tr>', esc_attr($field), $plugin->enabled ? 'checked="checked"' : '', esc_html($name), esc_html($plugin->description));
        }
        ?>
					</tbody>

				</table>

				<?php 
        nxt_nonce_field('classblogs_admin');
        ?>
				<p class="submit">
					<input type="submit" class="button-primary" name="Submit" value="<?php 
        _e('Update Enabled Plugins', 'classblogs');
        ?>
" />
				</p>
			</form>
		</div>
<?php 
    }