Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /******************************************************************************************************************
- Plugin Name: cets_simple_dashboard
- Plugin URI:
- Description: WordPressMU plugin for simplifying the wordpress dashboard.
- Version: 1.0
- Author: Deanna Schneider
- Copyright:
- Copyright 2008 CETS
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *******************************************************************************************************************/
- function cets_simple_dashboard_setup() {
- // get the site options
- $dashoptions = get_site_option('cets_dashoptions');
- if ($dashoptions['primaryfeed'] == TRUE) {
- wp_unregister_sidebar_widget("dashboard_primary");
- if (!is_site_admin){
- wp_unregister_widget_control("dashboard_primary");
- }
- }
- if ($dashoptions['secondaryfeed'] == TRUE){
- wp_unregister_sidebar_widget("dashboard_secondary");
- wp_unregister_widget_control("dashboard_secondary");
- }
- if ($dashoptions['incominglinks'] == TRUE){
- wp_unregister_sidebar_widget("dashboard_incoming_links");
- wp_unregister_widget_control("dashboard_incoming_links");
- }
- if ($dashoptions['recentcomments'] == TRUE){
- wp_unregister_sidebar_widget("dashboard_recent_comments");
- wp_unregister_widget_control("dashboard_recent_comments");
- }
- if (strlen($dashoptions['feed'])) {
- $widget_options['dashboard_new'] = array(
- 'link' => apply_filters( 'dashboard_primary_link', __( $dashoptions['feedlink'] ) ),
- 'url' => apply_filters( 'dashboard_primary_feed', __( $dashopions['feed'] ) ),
- 'title' => apply_filters( 'dashboard_primary_title', __( $dashoptions['feedtitle'] ) ),
- 'items' => 2,
- 'show_summary' => 1,
- 'show_author' => 0,
- 'show_date' => 1
- );
- wp_register_sidebar_widget( 'dashboard_primary', $widget_options['dashboard_new']['title'], 'wp_dashboard_empty',
- array( 'all_link' => $widget_options['dashboard_new']['link'], 'feed_link' => $widget_options['dashboard_new']['url'], 'width' => 'half', 'class' => 'widget_rss' ),
- 'wp_dashboard_cached_rss_widget', 'wp_dashboard_rss_output'
- );
- }
- // if allow editing is true, then add the widget control
- wp_register_widget_control( 'dashboard_primary', __( 'Primary Feed' ), 'wp_dashboard_rss_control', array(),
- array( 'widget_id' => 'dashboard_primary' )
- );
- }
- /* *************************************************************************
- Create the page for the admins to set up stuff
- ************************************************************************** */
- function cets_simple_dashboard_admin() {
- $dashoptions = get_site_option('cets_dashoptions');
- $primaryfeed = $dashoptions['primaryfeed'];
- $primaryfeedchecked = ($primaryfeed == 1) ? 'checked= checked' : '';
- $secondaryfeed = $dashoptions['secondaryfeed'];
- $secondaryfeedchecked = ($secondaryfeed == 1) ? 'checked= checked' : '';
- $incominglinks = $dashoptions['incominglinks'];
- $incominglinks = ($incominglinks == 1) ? 'checked= checked' : '';
- $recentcomments = $dashoptions['recentcomments'];
- $recentcomments = ($recentcomments == 1) ? 'checked= checked' : '';
- $feedtitle = $dashoptions['feedtitle'];
- $feedlink = $dashoptions['feedlink'];
- $feed = $dashoptions['feed'];
- $allowedit = $dashoptions['allowedit'];
- $allowedit = ($allowedit == 1) ? 'checked= checked' : '';
- ?><h3><?php _e('Dashboard Options') ?></h3>
- <table class="form-table">
- <tr valign="top">
- <th scope="row"><?php _e('Remove the following widgets:') ?></th>
- <td>
- <input name="cets_sd_primaryfeed" type="checkbox" id="cets_sd_primaryfeed" value="1" <?php echo $primaryfeedchecked; ?> /> <?php _e('Primary Feed'); ?>
- <br />
- <input name="cets_sd_secondaryfeed" type="checkbox" id="cets_sd_secondaryfeed" value="1" <?php echo $secondaryfeedchecked; ?> /> <?php _e('Secondary Feed'); ?>
- <br />
- <input name="cets_sd_incominglinks" type="checkbox" id="cets_sd_incominglinks" value="1" <?php echo $incominglinks; ?> /> <?php _e('Incoming Links'); ?>
- <br />
- <input name="cets_sd_recentcomments" type="checkbox" id="cets_sd_recentcomments" value="1" <?php echo $recentcomments; ?> /> <?php _e('Recent Comments'); ?>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><?php _e('Modify the Primary Feed') ?></th>
- <td>
- Feed Title: <input type="text" name="cets_sd_feedtitle" id="cets_sd_feedtitle" value="<?php echo $feedtitle; ?>" /> <br />
- Feed URL: <input type="text" name="cets_sd_feed" id="cets_sd_feed" value="<?php echo $feed; ?>" /> <br />
- Blog URL: <input type="text" name="cets_sd_feedlink" id="cets_sd_feedlink" value="<?php echo $feedlink; ?>" /> <br />
- Allow Editing: <input name="cets_sd_allowedit" type="checkbox" id="cets_sd_allowedit" value="1" <?php echo $allowedit; ?> />
- </td>
- </tr>
- </table>
- <?php
- }
- /* *************************************************************************
- Handle the posts when admins update options
- ************************************************************************** */
- function cets_simple_dashboard_admin_update() {
- $options = array('primaryfeed'=>FALSE,
- 'secondaryfeed' => FALSE,
- 'incominglinks'=>FALSE);
- $options['primaryfeed'] = ($_POST['cets_sd_primaryfeed'] == 1) ? TRUE : FALSE;
- $options['secondaryfeed'] = ($_POST['cets_sd_secondaryfeed'] == 1) ? TRUE : FALSE;
- $options['incominglinks'] = ($_POST['cets_sd_incominglinks'] == 1) ? TRUE : FALSE;
- $options['recentcomments'] = ($_POST['cets_sd_recentcomments'] == 1) ? TRUE : FALSE;
- $options['allowedit'] = ($_POST['cets_sd_allowedit'] == 1) ? TRUE : FALSE;
- $options['feedtitle'] = strip_tags($_POST['cets_sd_feedtitle']);
- $options['feedlink'] = strip_tags($_POST['cets_sd_feedlink']);
- $options['feed'] = strip_tags($_POST['cets_sd_feed']);
- if (!is_array(get_site_option('cets_dashoptions'))) {
- add_site_option('cets_dashoptions', $options);
- }
- else {
- update_site_option('cets_dashoptions', $options);
- }
- }
- add_action( 'wp_dashboard_setup', 'cets_simple_dashboard_setup' );
- add_action('wpmu_options', 'cets_simple_dashboard_admin');
- add_action( 'update_wpmu_options', 'cets_simple_dashboard_admin_update' );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement