Advertisement
Guest User

DeannaS

a guest
Oct 7th, 2008
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.86 KB | None | 0 0
  1. <?php
  2.  
  3. /******************************************************************************************************************
  4.  
  5. Plugin Name: cets_simple_dashboard
  6.  
  7. Plugin URI:
  8.  
  9. Description: WordPressMU plugin for simplifying the wordpress dashboard.
  10.  
  11. Version: 1.0
  12.  
  13. Author: Deanna Schneider
  14.  
  15. Copyright:
  16.  
  17. Copyright 2008 CETS
  18.  
  19. This program is free software; you can redistribute it and/or modify
  20. it under the terms of the GNU General Public License as published by
  21. the Free Software Foundation; either version 2 of the License, or
  22. (at your option) any later version.
  23.  
  24. This program is distributed in the hope that it will be useful,
  25. but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. GNU General Public License for more details.
  28.  
  29. You should have received a copy of the GNU General Public License
  30. along with this program; if not, write to the Free Software
  31. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  32.  
  33.  
  34. *******************************************************************************************************************/
  35.  
  36. function cets_simple_dashboard_setup() {
  37. // get the site options
  38. $dashoptions = get_site_option('cets_dashoptions');
  39.  
  40.  
  41.  
  42. if ($dashoptions['primaryfeed'] == TRUE) {
  43. wp_unregister_sidebar_widget("dashboard_primary");
  44. if (!is_site_admin){
  45. wp_unregister_widget_control("dashboard_primary");
  46. }
  47. }
  48. if ($dashoptions['secondaryfeed'] == TRUE){
  49. wp_unregister_sidebar_widget("dashboard_secondary");
  50. wp_unregister_widget_control("dashboard_secondary");
  51. }
  52.  
  53. if ($dashoptions['incominglinks'] == TRUE){
  54. wp_unregister_sidebar_widget("dashboard_incoming_links");
  55. wp_unregister_widget_control("dashboard_incoming_links");
  56. }
  57. if ($dashoptions['recentcomments'] == TRUE){
  58. wp_unregister_sidebar_widget("dashboard_recent_comments");
  59. wp_unregister_widget_control("dashboard_recent_comments");
  60. }
  61.  
  62.  
  63. if (strlen($dashoptions['feed'])) {
  64. $widget_options['dashboard_new'] = array(
  65. 'link' => apply_filters( 'dashboard_primary_link', __( $dashoptions['feedlink'] ) ),
  66. 'url' => apply_filters( 'dashboard_primary_feed', __( $dashopions['feed'] ) ),
  67. 'title' => apply_filters( 'dashboard_primary_title', __( $dashoptions['feedtitle'] ) ),
  68. 'items' => 2,
  69. 'show_summary' => 1,
  70. 'show_author' => 0,
  71. 'show_date' => 1
  72. );
  73.  
  74. wp_register_sidebar_widget( 'dashboard_primary', $widget_options['dashboard_new']['title'], 'wp_dashboard_empty',
  75. array( 'all_link' => $widget_options['dashboard_new']['link'], 'feed_link' => $widget_options['dashboard_new']['url'], 'width' => 'half', 'class' => 'widget_rss' ),
  76. 'wp_dashboard_cached_rss_widget', 'wp_dashboard_rss_output'
  77. );
  78.  
  79. }
  80.  
  81. // if allow editing is true, then add the widget control
  82. wp_register_widget_control( 'dashboard_primary', __( 'Primary Feed' ), 'wp_dashboard_rss_control', array(),
  83. array( 'widget_id' => 'dashboard_primary' )
  84. );
  85.  
  86.  
  87. }
  88.  
  89. /* *************************************************************************
  90. Create the page for the admins to set up stuff
  91. ************************************************************************** */
  92. function cets_simple_dashboard_admin() {
  93. $dashoptions = get_site_option('cets_dashoptions');
  94. $primaryfeed = $dashoptions['primaryfeed'];
  95. $primaryfeedchecked = ($primaryfeed == 1) ? 'checked= checked' : '';
  96. $secondaryfeed = $dashoptions['secondaryfeed'];
  97. $secondaryfeedchecked = ($secondaryfeed == 1) ? 'checked= checked' : '';
  98. $incominglinks = $dashoptions['incominglinks'];
  99. $incominglinks = ($incominglinks == 1) ? 'checked= checked' : '';
  100. $recentcomments = $dashoptions['recentcomments'];
  101. $recentcomments = ($recentcomments == 1) ? 'checked= checked' : '';
  102. $feedtitle = $dashoptions['feedtitle'];
  103. $feedlink = $dashoptions['feedlink'];
  104. $feed = $dashoptions['feed'];
  105. $allowedit = $dashoptions['allowedit'];
  106. $allowedit = ($allowedit == 1) ? 'checked= checked' : '';
  107.  
  108.  
  109. ?><h3><?php _e('Dashboard Options') ?></h3>
  110.  
  111.  
  112. <table class="form-table">
  113. <tr valign="top">
  114. <th scope="row"><?php _e('Remove the following widgets:') ?></th>
  115. <td>
  116. <input name="cets_sd_primaryfeed" type="checkbox" id="cets_sd_primaryfeed" value="1" <?php echo $primaryfeedchecked; ?> /> <?php _e('Primary Feed'); ?>
  117. <br />
  118. <input name="cets_sd_secondaryfeed" type="checkbox" id="cets_sd_secondaryfeed" value="1" <?php echo $secondaryfeedchecked; ?> /> <?php _e('Secondary Feed'); ?>
  119. <br />
  120. <input name="cets_sd_incominglinks" type="checkbox" id="cets_sd_incominglinks" value="1" <?php echo $incominglinks; ?> /> <?php _e('Incoming Links'); ?>
  121. <br />
  122. <input name="cets_sd_recentcomments" type="checkbox" id="cets_sd_recentcomments" value="1" <?php echo $recentcomments; ?> /> <?php _e('Recent Comments'); ?>
  123. </td>
  124. </tr>
  125. <tr valign="top">
  126. <th scope="row"><?php _e('Modify the Primary Feed') ?></th>
  127. <td>
  128. Feed Title: <input type="text" name="cets_sd_feedtitle" id="cets_sd_feedtitle" value="<?php echo $feedtitle; ?>" /> <br />
  129. Feed URL: <input type="text" name="cets_sd_feed" id="cets_sd_feed" value="<?php echo $feed; ?>" /> <br />
  130. Blog URL: <input type="text" name="cets_sd_feedlink" id="cets_sd_feedlink" value="<?php echo $feedlink; ?>" /> <br />
  131. Allow Editing: <input name="cets_sd_allowedit" type="checkbox" id="cets_sd_allowedit" value="1" <?php echo $allowedit; ?> />
  132. </td>
  133. </tr>
  134.  
  135.  
  136.  
  137. </table>
  138. <?php
  139.  
  140. }
  141. /* *************************************************************************
  142. Handle the posts when admins update options
  143. ************************************************************************** */
  144. function cets_simple_dashboard_admin_update() {
  145. $options = array('primaryfeed'=>FALSE,
  146. 'secondaryfeed' => FALSE,
  147. 'incominglinks'=>FALSE);
  148. $options['primaryfeed'] = ($_POST['cets_sd_primaryfeed'] == 1) ? TRUE : FALSE;
  149. $options['secondaryfeed'] = ($_POST['cets_sd_secondaryfeed'] == 1) ? TRUE : FALSE;
  150. $options['incominglinks'] = ($_POST['cets_sd_incominglinks'] == 1) ? TRUE : FALSE;
  151. $options['recentcomments'] = ($_POST['cets_sd_recentcomments'] == 1) ? TRUE : FALSE;
  152. $options['allowedit'] = ($_POST['cets_sd_allowedit'] == 1) ? TRUE : FALSE;
  153. $options['feedtitle'] = strip_tags($_POST['cets_sd_feedtitle']);
  154. $options['feedlink'] = strip_tags($_POST['cets_sd_feedlink']);
  155. $options['feed'] = strip_tags($_POST['cets_sd_feed']);
  156.  
  157.  
  158. if (!is_array(get_site_option('cets_dashoptions'))) {
  159. add_site_option('cets_dashoptions', $options);
  160. }
  161. else {
  162. update_site_option('cets_dashoptions', $options);
  163. }
  164. }
  165.  
  166.  
  167. add_action( 'wp_dashboard_setup', 'cets_simple_dashboard_setup' );
  168. add_action('wpmu_options', 'cets_simple_dashboard_admin');
  169. add_action( 'update_wpmu_options', 'cets_simple_dashboard_admin_update' );
  170.  
  171. ?>
  172.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement