Plugin Directory

Changeset 427608


Ignore:
Timestamp:
08/23/2011 02:11:06 PM (15 years ago)
Author:
BenIrvin
Message:
 
Location:
admin-dashboard-site-notes/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • admin-dashboard-site-notes/trunk/admin-styles.css

    r426806 r427608  
    5555}
    5656*/
     57#dsn_instructions ul.depth-0.notes,
    5758#dsn_dashboard ul.depth-0 {
    5859    margin:0;
     
    6162    margin-bottom:1em;
    6263}
    63 #dsn_dashboard .dashboard_note li {
     64#dsn_instructions .site_note li,
     65#dsn_dashboard .site_note li {
    6466    margin-left:1em;
    6567    padding-top:0.5em;
    6668    border-top:2px dotted #ccc;
    6769}
     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  
    44Plugin URI: http://innerdvations.com/plugins/admin-dashboard-notes/
    55Description: Create site notes to appear either on the dashboard or at the top of various admin pages.
    6 Version: 0.9.2
     6Version: 1.0
    77Author: Ben Irvin
    88Author URI: http://innerdvations.com/
     
    1414/*
    1515== 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
    1719* Italian translation
    18 * add config option for title of dashboard widget
    19 * add config option for choosing what roles can create notes
    2020* expirations/time ranges
    2121* 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)
     
    2323
    2424== 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
    2532= 0.9.2 =
    2633* added translation support and English .pot file
     
    5461    public  static $custom_field_prefix = '_dsn_'; // the _ hides it from dropdowns
    5562    public  static $custom; // custom field cache for this post
     63    private static $instruction_page_title;
     64    private static $instruction_nav_title;
    5665   
    5766    function __construct() {
     67        self::$instruction_nav_title = __("Site Instructions");
     68        self::$instruction_page_title = __("Site Instruction Manual");
     69       
    5870        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__);
    6072        if(is_admin()) { // if we're in the admin pages...
    6173            load_plugin_textdomain(self::$plugin_id, false, basename( dirname( __FILE__ ) ) . '/languages' );
     
    7890                add_action('wp_dashboard_setup', array($this,'setup_dashboard'));
    7991            }
    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;
    81137    }
    82138   
     
    100156    }
    101157   
     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    }
    102181    // recursively get the post and it's children
    103182    public static function note_with_children($post,$depth=0,$full_post=false) {
     
    105184            return "Error: note output aborted, hierarchy depth too deep (>64)";
    106185        }
    107         $output = "<ul class='depth-{$depth}'>";
     186        $output = "<ul class='notes depth-{$depth}'>";
    108187        $id = $post->ID;
    109188        $t = $post->post_title;
     
    117196        if(count($children)) {
    118197            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);
    120199            }
    121200        }
    122201        $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>
    125204            <div class='content'>{$c}</div>
    126205            {$child_output}
     
    148227        switch($pagenow) {
    149228            case 'index.php':
     229                if(isset($_GET['page'])) {
     230                    if($_GET['page']==self::$plugin_id) {
     231                        return 'instructions';
     232                    }
     233                    break;
     234                }
    150235                return 'dashboard';
    151236            case 'edit.php':
     
    158243        return '';
    159244    }
    160     public static function get_current_loc() {
     245    public static function get_current_loc($action=null) {
    161246        $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        }
    163253        $loc = "loc_";
    164254        $loc .= $on_action;
     
    179269    public static function get_notes($args=array()) {
    180270        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)) {
    182272            return;
    183273        }
    184274        $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        }
    186281        // set up the subquery for role checking
    187282        $wheres_arr = array();
     
    210305       
    211306        // 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        }
    230341        $res = $wpdb->get_results($sql);
    231342        return $res;
     
    235346    public function all_admin_notices() {
    236347        // 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() == '') {
    238351            return;
    239352        }
  • admin-dashboard-site-notes/trunk/readme.txt

    r427507 r427608  
    55Requires at least: 3.0
    66Tested up to: 3.2.1
    7 Stable tag: 0.9.2.1
     7Stable tag: 1.0
    88
    99Add notes about the site to various admin locations, as well as compile them into an instruction manual.
     
    1111== Description ==
    1212
    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.
     13Add notes about the site to various admin locations, as well as compile them into an instruction manual.
    1414
    1515== Installation ==
     
    2121== Frequently Asked Questions ==
    2222
     23= Why isn't one of my notes showing up in the dashboard/instructions? =
     24If 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? =
     27Make sure that the excerpt field for your note is either empty or contains the short content you want to include.
     28
    2329== Screenshots ==
    2430
     
    26321. The dashboard widget that appears after notes are created there.
    27331. A note as it appears on the list/search page.
     341. Generated instruction manual from notes
    2835
    2936== Changelog ==
     37= 1.0 =
     38* added instruction manual page
     39
    3040= 0.9.2.1 =
    3141* fixed fatal error bug and display bug
Note: See TracChangeset for help on using the changeset viewer.