Changeset 427608
- Timestamp:
- 08/23/2011 02:11:06 PM (15 years ago)
- Location:
- admin-dashboard-site-notes/trunk
- Files:
-
- 3 edited
-
admin-styles.css (modified) (2 diffs)
-
dashboard-site-notes.php (modified) (13 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
admin-dashboard-site-notes/trunk/admin-styles.css
r426806 r427608 55 55 } 56 56 */ 57 #dsn_instructions ul.depth-0.notes, 57 58 #dsn_dashboard ul.depth-0 { 58 59 margin:0; … … 61 62 margin-bottom:1em; 62 63 } 63 #dsn_dashboard .dashboard_note li { 64 #dsn_instructions .site_note li, 65 #dsn_dashboard .site_note li { 64 66 margin-left:1em; 65 67 padding-top:0.5em; 66 68 border-top:2px dotted #ccc; 67 69 } 70 71 #dsn_instructions .index ol, 72 #dsn_instructions .index ul, 73 #dsn_instructions .index li, 74 #dsn_instructions .index h4 { 75 margin:0; 76 padding:0; 77 } 78 #dsn_instructions ul.index li { 79 margin-top:0.1em; 80 margin-left:1em; 81 } 82 83 #dsn_instructions .instruction_content, 84 #dsn_instructions .instruction_index { 85 margin:20px 0; 86 } 87 #dsn_instructions .instruction_index { 88 border-top:4px solid #bbb; 89 border-bottom:4px solid #bbb; 90 padding:20px 0; 91 } 92 #dsn_instructions .instruction_index h3 { 93 margin-top:0; 94 } -
admin-dashboard-site-notes/trunk/dashboard-site-notes.php
r427505 r427608 4 4 Plugin URI: http://innerdvations.com/plugins/admin-dashboard-notes/ 5 5 Description: Create site notes to appear either on the dashboard or at the top of various admin pages. 6 Version: 0.9.26 Version: 1.0 7 7 Author: Ben Irvin 8 8 Author URI: http://innerdvations.com/ … … 14 14 /* 15 15 == TODO == (roughly in order of importance and when they'll get done) 16 * add instruction manual, including hierarchy 16 * add config option for choosing what roles can create notes 17 * add taxonomy positions (edit-tags.php) 18 * add config option for title of dashboard widget and instruction manual 17 19 * Italian translation 18 * add config option for title of dashboard widget19 * add config option for choosing what roles can create notes20 20 * expirations/time ranges 21 21 * add locations like menu/widget/settings/comments/etc (maybe just allow entering the filename like options-general.php? that would allow it to work even on plugin pages, etc) … … 23 23 24 24 == Changelog == 25 = 1.0 = 26 * added instruction manual 27 28 = 0.9.2.1 = 29 * fixed fatal error bug and display bug 30 * fixed incorrect screenshots 31 25 32 = 0.9.2 = 26 33 * added translation support and English .pot file … … 54 61 public static $custom_field_prefix = '_dsn_'; // the _ hides it from dropdowns 55 62 public static $custom; // custom field cache for this post 63 private static $instruction_page_title; 64 private static $instruction_nav_title; 56 65 57 66 function __construct() { 67 self::$instruction_nav_title = __("Site Instructions"); 68 self::$instruction_page_title = __("Site Instruction Manual"); 69 58 70 self::$has_edit = is_super_admin(); 59 self::$base = plugin_basename(__FILE__); //'custom-post-type-taxonomy-archives/custom-post-type-taxonomy-archives.php';71 self::$base = plugin_basename(__FILE__); 60 72 if(is_admin()) { // if we're in the admin pages... 61 73 load_plugin_textdomain(self::$plugin_id, false, basename( dirname( __FILE__ ) ) . '/languages' ); … … 78 90 add_action('wp_dashboard_setup', array($this,'setup_dashboard')); 79 91 } 80 } 92 // add instruction manual page if entries exist 93 if(self::has_instruction_notes()) { 94 add_action( 'admin_menu', array($this,'admin_menu') ); 95 } 96 } 97 } 98 99 public function admin_menu() { 100 add_dashboard_page(self::$instruction_page_title, self::$instruction_nav_title, 'read', self::$plugin_id, array($this,'admin_page')); 101 } 102 public static function admin_page() { 103 echo "<div id='dsn_instructions' class='wrap'>"; 104 echo "<h2>" . self::$instruction_page_title . "</h2>"; 105 106 $posts = self::get_notes_by_parent(0); 107 108 // generate table of contents 109 $output = ''; 110 foreach($posts as $post) { 111 $output .= self::index_with_children($post); 112 } 113 echo "<div class='instruction_index'>"; 114 echo "<h3>" . __('Table of Contents') . "</h3>"; 115 echo $output; 116 echo "</div>"; 117 118 // generate instructions 119 $output = ''; 120 foreach($posts as $post) { 121 $output .= self::note_with_children($post, 0, true); 122 } 123 echo "<div class='instruction_content'>"; 124 echo $output; 125 echo "</div>"; 126 127 echo "</div>"; 128 } 129 130 public static function has_instruction_notes() { 131 $args = array('action'=>'instruction','post_parent'=>0); 132 $posts = self::get_notes($args); 133 if(count($posts)) { 134 return true; 135 } 136 return false; 81 137 } 82 138 … … 100 156 } 101 157 158 // recursively get the linked post title and it's children 159 public static function index_with_children($post,$depth=0) { 160 if($depth > 64) { // sanity check 161 return "Error: note output aborted, hierarchy depth too deep (>64)"; 162 } 163 $output = "<ul class='index depth-{$depth}'>"; 164 $id = $post->ID; 165 $t = $post->post_title; 166 $children = self::get_notes_by_parent($id); 167 $child_output = ''; 168 if(count($children)) { 169 foreach($children as $child) { 170 $child_output .= self::index_with_children($child,$depth + 1); 171 } 172 } 173 $output .= " 174 <li class='dsn dashboard_index depth-{$depth}'> 175 <a href='#note_{$id}'><h4>{$t}</h4></a> 176 {$child_output} 177 </li>"; 178 $output .= '</ul>'; 179 return $output; 180 } 102 181 // recursively get the post and it's children 103 182 public static function note_with_children($post,$depth=0,$full_post=false) { … … 105 184 return "Error: note output aborted, hierarchy depth too deep (>64)"; 106 185 } 107 $output = "<ul class=' depth-{$depth}'>";186 $output = "<ul class='notes depth-{$depth}'>"; 108 187 $id = $post->ID; 109 188 $t = $post->post_title; … … 117 196 if(count($children)) { 118 197 foreach($children as $child) { 119 $child_output .= self::note_with_children($child,$depth + 1 );198 $child_output .= self::note_with_children($child,$depth + 1,$full_post); 120 199 } 121 200 } 122 201 $output .= " 123 <li class='dsn dashboard_note depth-{$depth}'>124 < h4>{$t}</h4>202 <li class='dsn site_note depth-{$depth}'> 203 <a name='note_{$id}'></a><h4>{$t}</h4> 125 204 <div class='content'>{$c}</div> 126 205 {$child_output} … … 148 227 switch($pagenow) { 149 228 case 'index.php': 229 if(isset($_GET['page'])) { 230 if($_GET['page']==self::$plugin_id) { 231 return 'instructions'; 232 } 233 break; 234 } 150 235 return 'dashboard'; 151 236 case 'edit.php': … … 158 243 return ''; 159 244 } 160 public static function get_current_loc( ) {245 public static function get_current_loc($action=null) { 161 246 $on_content_type = self::current_post_type(); 162 $on_action = self::current_action(); 247 if($action) { 248 $on_action = 'instructions'; 249 } 250 else { 251 $on_action = self::current_action(); 252 } 163 253 $loc = "loc_"; 164 254 $loc .= $on_action; … … 179 269 public static function get_notes($args=array()) { 180 270 global $wpdb, $wp_roles, $current_user; 181 if(!isset($current_user->data->wp_capabilities) || self::current_action() == '') {271 if(!isset($current_user->data->wp_capabilities)) { 182 272 return; 183 273 } 184 274 $post_type_name = self::$post_type_name; 185 $which_location = self::get_current_loc(); 275 if(isset($args['action'])) { 276 $which_location = self::get_current_loc($args['action']); 277 } 278 else { 279 $which_location = self::get_current_loc(); 280 } 186 281 // set up the subquery for role checking 187 282 $wheres_arr = array(); … … 210 305 211 306 // build the full query 212 $sql = $wpdb->prepare(" 213 SELECT * 214 FROM {$wpdb->postmeta} 215 LEFT JOIN {$wpdb->posts} ON {$wpdb->posts}.id = {$wpdb->postmeta}.post_id 216 WHERE 217 {$wpdb->posts}.post_status = 'publish' 218 AND {$wpdb->posts}.post_type = '%s' 219 AND ( 220 ({$wpdb->postmeta}.meta_key = '%s' AND {$wpdb->postmeta}.meta_value = '1') 221 OR 222 ({$wpdb->postmeta}.meta_key = '%s' AND {$wpdb->postmeta}.meta_value = '1') 223 OR 224 ({$wpdb->postmeta}.meta_key = '{$pre}loc_everywhere' AND {$wpdb->postmeta}.meta_value = '1') 225 ) 226 AND {$wpdb->posts}.id IN ( {$role_query} ) 227 {$post_parent} 228 GROUP BY {$wpdb->posts}.id 229 ", $post_type_name, self::$custom_field_prefix . $which_location, self::get_everywhere_metakey() ); 307 if($which_location=='loc_instructions') { 308 $sql = $wpdb->prepare(" 309 SELECT * 310 FROM {$wpdb->postmeta} 311 LEFT JOIN {$wpdb->posts} ON {$wpdb->posts}.id = {$wpdb->postmeta}.post_id 312 WHERE 313 {$wpdb->posts}.post_status = 'publish' 314 AND {$wpdb->posts}.post_type = '%s' 315 AND ({$wpdb->postmeta}.meta_key = '%s' AND {$wpdb->postmeta}.meta_value = '0') 316 AND {$wpdb->posts}.id IN ( {$role_query} ) 317 {$post_parent} 318 GROUP BY {$wpdb->posts}.id 319 ", $post_type_name, self::$custom_field_prefix . 'instructions_exclude'); 320 } 321 else { 322 $sql = $wpdb->prepare(" 323 SELECT * 324 FROM {$wpdb->postmeta} 325 LEFT JOIN {$wpdb->posts} ON {$wpdb->posts}.id = {$wpdb->postmeta}.post_id 326 WHERE 327 {$wpdb->posts}.post_status = 'publish' 328 AND {$wpdb->posts}.post_type = '%s' 329 AND ( 330 ({$wpdb->postmeta}.meta_key = '%s' AND {$wpdb->postmeta}.meta_value = '1') 331 OR 332 ({$wpdb->postmeta}.meta_key = '%s' AND {$wpdb->postmeta}.meta_value = '1') 333 OR 334 ({$wpdb->postmeta}.meta_key = '{$pre}loc_everywhere' AND {$wpdb->postmeta}.meta_value = '1') 335 ) 336 AND {$wpdb->posts}.id IN ( {$role_query} ) 337 {$post_parent} 338 GROUP BY {$wpdb->posts}.id 339 ", $post_type_name, self::$custom_field_prefix . $which_location, self::get_everywhere_metakey() ); 340 } 230 341 $res = $wpdb->get_results($sql); 231 342 return $res; … … 235 346 public function all_admin_notices() { 236 347 // on the dashboard we print a pretty widget, not a notice 237 if(self::current_action() == 'dashboard' || self::current_action() == '') { 348 if(self::current_action() == 'dashboard' 349 || self::current_action() == 'instructions' 350 || self::current_action() == '') { 238 351 return; 239 352 } -
admin-dashboard-site-notes/trunk/readme.txt
r427507 r427608 5 5 Requires at least: 3.0 6 6 Tested up to: 3.2.1 7 Stable tag: 0.9.2.17 Stable tag: 1.0 8 8 9 9 Add notes about the site to various admin locations, as well as compile them into an instruction manual. … … 11 11 == Description == 12 12 13 Add notes about the site to various admin locations, as well as compile them into an instruction manual. The instruction manual has not yet been implemented but will be included in release 1.0.13 Add notes about the site to various admin locations, as well as compile them into an instruction manual. 14 14 15 15 == Installation == … … 21 21 == Frequently Asked Questions == 22 22 23 = Why isn't one of my notes showing up in the dashboard/instructions? = 24 If the note has a parent note, that parent must also be visible or else your note won't show up on the dashboard or in the instruction manual. Roles must also be selected; if you don't choose any roles, your note will not show up for anyone. Finally, make sure that you've checked the checkbox for appearing on the dashboard. 25 26 = Why is one of my notes showing up with empty text? = 27 Make sure that the excerpt field for your note is either empty or contains the short content you want to include. 28 23 29 == Screenshots == 24 30 … … 26 32 1. The dashboard widget that appears after notes are created there. 27 33 1. A note as it appears on the list/search page. 34 1. Generated instruction manual from notes 28 35 29 36 == Changelog == 37 = 1.0 = 38 * added instruction manual page 39 30 40 = 0.9.2.1 = 31 41 * fixed fatal error bug and display bug
Note: See TracChangeset
for help on using the changeset viewer.