Skip to:
Content

bbPress.org

Ticket #1409: 1409-2.diff

File 1409-2.diff, 4.0 KB (added by anthonycole, 16 years ago)
  • bbp-admin/bbp-admin.php

     
    9898                add_action( 'admin_menu',                  array( $this, 'reply_parent_metabox'      ) );
    9999                add_action( 'save_post',                   array( $this, 'reply_parent_metabox_save' ) );
    100100
     101                // Anonymous save metabox actions
     102                add_action( 'add_meta_boxes',                  array( $this, 'anonymous_metabox'      ) );
     103                add_action( 'save_post',                   array( $this, 'anonymous_metabox_save' ) );
     104
    101105                // Register bbPress admin style
    102106                add_action( 'admin_init',                  array( $this, 'register_admin_style' ) );
    103107
     
    282286         * Pass the topic reply post parent id for processing
    283287         *
    284288         * @param int $post_id
    285          * @return int
     289         * @return void
     290         * @uses current_user_can, do_action
     291         * @since bbPress (r2727)
    286292         */
    287293        function reply_parent_metabox_save ( $post_id ) {
    288294                if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
     
    298304
    299305                return $parent_id;
    300306        }
     307       
     308        /**
     309         * anonymous_metabox ()
     310         *
     311         * Allows editing of information about an anonymous user
     312         *
     313         * @uses bbp_get_reply_author_id, add_meta_box, do_action
     314         * @since bbPress (r)
     315         * @return void
     316         */
     317       
     318        function anonymous_metabox () {
     319                global $bbp;
     320               
     321                if ( 0 != bbp_get_reply_author_id( (int) $_GET['post'] ) )
     322                                return true;
     323               
     324                add_meta_box (
     325                        'bbp_anonymous_metabox',
     326                        __( 'Anonymous Information', 'bbpress'),
     327                        'bbp_anonymous_metabox',
     328                        $bbp->topic_id,
     329                        'normal'
     330                );
     331               
     332                add_meta_box (
     333                        'bbp_anonymous_metabox',
     334                        __( 'Anonymous Information', 'bbpress'),
     335                        'bbp_anonymous_metabox',
     336                        $bbp->reply_id,
     337                        'normal'
     338                );
     339               
     340                do_action('bbp_anonymous_metabox');
     341        }
     342       
     343        /**
     344         * anonymous_metabox_save ()
     345         *
     346         * Saves all of the anonymous information about an anonymous user.
     347         *
     348         * @param int $post_id
     349         * @return void
     350         * @since bbPress (r)
     351         */
     352       
     353        function anonymous_metabox_save ( $post_id ) {
     354                if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
     355                        return $post_id;
     356                       
     357                if( !current_user_can( 'edit_post', $post_id ) )
     358                        return $post_id;
     359               
     360                $filter = bbp_filter_anonymous_post_data();
     361               
    301362
     363               
     364                update_post_meta( $post_id, '_bbp_anonymous_name', $filter['bbp_anonymous_name'] );
     365               
     366                update_post_meta( $post_id, '_bbp_anonymous_email', $filter['bbp_anonymous_email'] );
     367               
     368                update_post_meta( $post_id, '_bbp_anonymous_website', $filter['bbp_anonymous_website'] );
     369                               
     370                do_action('bbp_anonymous_metabox_save');
     371               
     372                return $post_id;
     373                       
     374        }
     375       
     376
    302377        /**
    303378         * admin_head ()
    304379         *
     
    11131188        do_action( 'bbp_topic_reply_metabox' );
    11141189}
    11151190
     1191
    11161192/**
     1193 * bbp_anonymous_metabox ()
     1194 *
     1195 * metabox for anonymous poster
     1196 *
     1197 * @package bbPress
     1198 * @since bbPress (r)
     1199 * @global object $post, object $bbp
     1200 */
     1201function bbp_anonymous_metabox () {
     1202        global $post, $bbp;
     1203       
     1204        ?>
     1205        <p><strong><?php _e('Name', 'bbpress'); ?></strong></p>
     1206        <label class="screen-reader-text" for="parent_id"><?php _e('Name', 'bbpress'); ?></label>
     1207        <input type="text" name="bbp_anonymous_name" value="<?php echo get_post_meta($post->ID, '_bbp_anonymous_name', true); ?>" size="38" /></label>
     1208        <p><strong><?php _e('Email', 'bbpress'); ?></strong></p>
     1209        <label class="screen-reader-text" for="parent_id"><?php _e('Email', 'bbpress'); ?></label>
     1210        <input type="text" name="bbp_anonymous_email" value="<?php echo get_post_meta($post->ID, '_bbp_anonymous_email', true); ?>" size="38" /></label>       
     1211        <p><strong><?php _e('Website', 'bbpress'); ?></strong></p>
     1212        <label class="screen-reader-text" for="parent_id"><?php _e('Email', 'bbpress'); ?></label>
     1213        <input type="text" name="bbp_anonymous_website" value="<?php echo get_post_meta($post->ID, '_bbp_anonymous_website', true); ?>" size="38" /></label>   
     1214        <br />
     1215        <p>IP Address: <?php echo get_post_meta($post->ID, '_bbp_anonymous_ip', true); ?></p>
     1216        <?php
     1217}
     1218
     1219
     1220/**
    11171221 * bbp_admin_dropdown ()
    11181222 *
    11191223 * General wrapper for creating a drop down of selectable parents