Changeset 332

Show
Ignore:
Timestamp:
03/31/07 11:29:04 (2 years ago)
Author:
louisedade
Message:

Combined with 'Latest Replies' plugin for easier development.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • add-titles-to-replies/trunk/add-titles-to-replies.php

    r302 r332  
    33Plugin Name: Add Titles to Replies 
    44Plugin URI: http://www.classical-webdesigns.co.uk/articles/36_bbpress-plugin-add-titles-to-replies.html 
    5 Version: 0.2 
    6 Description: Allows users to add a title to their replies to topics
     5Version: 0.2.1 
     6Description: Allows users to add a title to their replies to topics, and displays the latest replies (by title) to discussions on the front page and a user's profile page
    77Author: Louise Dade 
    88Author URI: http://www.classical-webdesigns.co.uk/ 
     
    7676add_action( 'bb_update_post', 'ld_add_reply_title', 1, 1 ); // edit 
    7777 
     78/* Code from the Latest Replies Plugin */ 
     79 
     80// Get the latest replies 
     81function ld_get_latest_posts($limit=30, $poster=0, $page = 1 ) 
     82{ 
     83        global $bbdb, $bb_last_countable_query; 
     84 
     85        $page = (int) $page; 
     86 
     87        $where = 'WHERE post_status = 0'; 
     88 
     89        if ($poster > 0) 
     90                $where .= " AND poster_id = $poster"; 
     91 
     92        if ( 1 < $page ) 
     93                $limit = ($limit * ($page - 1)) . ", $limit"; 
     94 
     95        $bb_last_countable_query = "SELECT post_id,forum_id,topic_id,poster_id,post_title,post_time FROM $bbdb->posts $where ORDER BY post_time DESC LIMIT $limit"; 
     96 
     97        if ( $ld_latest_posts = $bbdb->get_results($bb_last_countable_query) ) 
     98                return $ld_latest_posts; 
     99        else 
     100                return false; 
     101} 
     102 
     103// Format a link to the post permalink 
     104function ld_reply_link( $id = 0, $reply = 0, $page = 1 ) { 
     105        echo apply_filters( 'topic_link', ld_get_reply_link($id, $reply), $id ); 
     106} 
     107 
     108function ld_get_reply_link( $id = 0, $reply = 0, $page = 1 ) { 
     109 
     110        $args = array(); 
     111 
     112        if ( bb_get_option('mod_rewrite') ) 
     113                $link = bb_get_option('uri') . "topic/$id" . ( 1 < $page ? "/page/$page" : '' ); 
     114        else { 
     115                $link = bb_get_option('uri') . 'topic.php'; 
     116                $args['id'] = $id; 
     117                $args['page'] = 1 < $page ? $page : ''; 
     118        } 
     119 
     120        if ( bb_current_user_can('write_posts') ) 
     121                $args['replies'] = $reply; 
     122        if ( $args ) 
     123                $link = add_query_arg( $args, $link ) . "#post-" . $reply; 
     124 
     125        return apply_filters( 'get_topic_link', $link, $id ); 
     126} 
     127 
     128// Time reply was posted 
     129function ld_post_time($t, $args = '' ) { 
     130        $args = _bb_parse_time_function_args( $args ); 
     131        $time = apply_filters( 'bb_post_time', ld_get_post_time($t, array('format' => 'mysql') + $args ), $args ); 
     132        return _bb_time_function_return( $time, $args ); 
     133} 
     134 
     135function ld_get_post_time($t, $args = '' ) { 
     136        $args = _bb_parse_time_function_args( $args ); 
     137 
     138        $time = apply_filters( 'bb_get_post_time', $t, $args ); 
     139 
     140        return _bb_time_function_return( $time, $args ); 
     141} 
     142 
     143 
    78144?> 
  • add-titles-to-replies/trunk/readme.txt

    r302 r332  
    11=== Add Titles to Replies === 
    2 Tags: replies, titles 
    3 Contributors: louisedade 
     2Tags: post, posts, reply, replies, titles, discussion, latest-discussion 
     3Contributors: LouiseDade 
    44Requires at least: 0.8 
    55Tested up to: 0.8.1 
    6 Stable Tag: 0.2 
     6Stable Tag: 0.2.1 
    77 
    8 Allows users to add a title to their replies to topics
     8Allows users to add a title to their replies to topics, and displays the latest replies (by title) to discussions on the front page and a user's profile page
    99 
    1010== Description == 
    1111 
    1212Plugin Name: Add Titles to Replies 
     13 
    1314Plugin URI: http://www.classical-webdesigns.co.uk/articles/36_bbpress-plugin-add-titles-to-replies.html 
    14 Description: Allows users to add a title to their replies to topics. 
     15 
     16Description: Allows users to add a title to their replies to topics, and displays the latest replies (by title) to discussions on the front page and a user's profile page. 
     17 
    1518Author: Louise Dade 
     19 
    1620Author URI: http://www.classical-webdesigns.co.uk/ 
    17 Version: 0.2 
     21 
     22Version: 0.2.1 
    1823 
    1924== Installation == 
    2025 
    21 NB: All examples are based on the kakumei theme. 
    22          
    23 1.  Open up your 'post-form.php' template file and find the following section (it's at the top): 
     26The installation instructions mostly involve editing templates and were getting too long to display here. Please find full installation instructions in the 'installation.txt' file included in this plugin package. 
    2427 
    25         <?php if ( !is_topic() ) : ?> 
    26         <p> 
    27                 <label for="topic"><?php _e('Topic title: (be brief and descriptive)'); ?> 
    28                         <input name="topic" type="text" id="topic" size="50" maxlength="80" tabindex="1" /> 
    29                 </label> 
    30         </p> 
    31         <?php endif; do_action( 'post_form_pre_post' ); ?> 
     28== Configuration == 
    3229 
    33 Replace it with the following: 
    34  
    35         <?php if ( !is_topic() ) { ?> 
    36  
    37         <p> 
    38                 <label for="topic"><?php _e('Topic title: (be brief and descriptive)'); ?><br /> 
    39                         <input name="topic" type="text" id="topic" size="60" maxlength="80" tabindex="1" /> 
    40                 </label> 
    41         </p> 
    42  
    43         <?php } else { ?> 
    44  
    45         <p> 
    46                 <label for="replytitle"><?php _e('Message Title: (be brief and descriptive)'); ?><br /> 
    47                         <input name="msgtitle" type="text" id="replytitle" size="60" maxlength="80" tabindex="1" value="Re: <?php topic_title(); ?>" /> 
    48                 </label> 
    49         </p> 
    50  
    51         <?php } do_action( 'post_form_pre_post' ); ?> 
    52  
    53  
    54 2.  Open up your 'edit-form.php' template file and find the following section (it's at the top): 
    55  
    56         <?php if ( $topic_title ) : ?> 
    57         <p> 
    58                 <label><?php _e('Topic:'); ?><br /> 
    59                         <input name="topic" type="text" id="topic" size="50" maxlength="80"  value="<?php echo attribute_escape( get_topic_title() ); ?>" /> 
    60                 </label> 
    61         </p> 
    62         <?php endif; ?> 
    63  
    64 Replace it with the following: 
    65  
    66         <?php if ( $topic_title ) { ?> 
    67         <p> 
    68                 <label><?php _e('Topic:'); ?><br /> 
    69                         <input name="topic" type="text" id="topic" size="50" maxlength="80"  value="<?php echo wp_specialchars(get_topic_title(), 1); ?>" /> 
    70                 </label> 
    71         </p> 
    72         <?php } else { ?> 
    73         <p> 
    74                 <label for="replytitle"><?php _e('Message Title:'); ?><br /> 
    75                         <input name="msgtitle" type="text" id="replytitle" size="80" maxlength="80" tabindex="1" value="<?php echo wp_specialchars(ld_get_post_title(), 1); ?>" /> 
    76                 </label> 
    77         </p> 
    78         <?php } ?> 
    79  
    80  
    81 3.  Open up your 'post.php' template file and add the following code to display the post title (wherever it suits you best): 
    82  
    83         <?php ld_post_title(); ?> 
    84  
    85 For example, in the kakumei theme you might add it like this: 
    86  
    87         <div class="threadpost"> 
    88                 <h3 class="post_title"><?php ld_post_title(); ?></h3> 
    89                 <div class="post"><?php post_text(); ?></div> 
    90                 <div class="poststuff"><?php printf( __('Posted %s ago'), bb_get_post_time() ); ?> <a href="<?php post_anchor_link(); ?>">#</a> <?php post_ip_link(); ?> <?php post_edit_link(); ?> <?php post_delete_link(); ?></div> 
    91         </div> 
    92  
    93  
    94 4.  Now we need to add a field to the database. If you are comfortable with MySQL, just login to your database admin and add the following field to the 'posts' table:   
    95  
    96                 post_title  VARCHAR(100)  NOT NULL 
    97  
    98 Alternatively, we do this by adding a temporary line of the code to your forum templates*. Add the following code to the bottom of your 'footer.php' template. 
    99  
    100         <?php ld_install_title_field(); ?> 
    101  
    102 Upload it to your working/test forum and load the forum in your browser.  This should add the new field to the database. 
    103  
    104  
    105 5.  Upload the edited templates ('post-form.php' and 'post.php') to the appropriate templates folder, and upload the 'reply-titles.php' plugin to your 'my-plugins' folder. 
    106  
    107  
    108 6. Test the forum by adding a message with a title to check that the installation function worked. If it did you'll see the reply title when you view topic replies.  You can then reopen your 'footer.php' file and REMOVE the following line (remembering to re-upload the file afterwards): 
    109                  
    110         <?php ld_install_title_field(); ?> 
    111  
    112  
    113 That's it, the Add Titles to Replies plugin is now installed and working. 
    114  
    115 * I made this a add, run, remove function because I really don't like adding unnecessary overhead to the code - once installed, there is no need to keep checking the database! 
    116  
    117 === Configuration === 
    118  
    119 None. 
     30None really; you can configure how many replies to show in the latest discussion in the template functions as explained in the installation instructions. 
    12031 
    12132== Frequently Asked Questions == 
    12233 
    123 None (yet). 
     34= Now that two plugins are combined ("Latest Replies" combined with "Add Titles to Replies") do I need to make any template changes. = 
    12435 
     36No, not at all, the two plugins have literally just been plumped together. All you have to do is delete the old "lastest-replies.php" plugin to avoid conflict. 
    12537 
    126 == Screenshots =
     38= I'm using another plugin to cross-post WordPress posts to bbPress topics, but it doesn't seem to work with this plugin, why?
    12739 
    128 Not applicable 
     40Probably because we have added an extra field to the database that your cross-post plugin does not account for.  For now there is no solution, but it is being worked on. 
    12941 
    130 CHANGE LOG 
     42== CHANGE LOG == 
    13143 
    132 2007-03-11      Ver. 0.2 enabled the title to be edited in "Edit Post" + template changes. 
    133 2007-03-10      ver. 0.1 relased 
     442007-03-31  Ver. 0.2.1 combined with "Latest Replies" plugin because the one doens't work without the other. 
     452007-03-11  Ver. 0.2 enabled the title to be edited in "Edit Post" + template changes. 
     462007-03-10  ver. 0.1 relased