Skip to:
Content

bbPress.org

Ticket #1409: 1409.diff

File 1409.diff, 3.2 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( 'admin_menu',                  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
     
    298302
    299303                return $parent_id;
    300304        }
     305       
     306        /**
     307         * anonymous_metabox ()
     308         *
     309         * Allows editing of information about an anonymous user
     310         *
     311         * @param int $post_id
     312         * @return int
     313         */
     314       
     315        function anonymous_metabox ( ) {
     316                global $bbp;
     317               
     318                if ( 0 != bbp_get_reply_author_id( (int) $_GET['post'] ) )
     319                                return true;
     320               
     321                add_meta_box (
     322                        'bbp_anonymous_metabox',
     323                        __( 'Anonymous Information', 'bbpress'),
     324                        'bbp_anonymous_metabox',
     325                        $bbp->topic_id,
     326                        'normal'
     327                );
     328               
     329                add_meta_box (
     330                        'bbp_anonymous_metabox',
     331                        __( 'Anonymous Information', 'bbpress'),
     332                        'bbp_anonymous_metabox',
     333                        $bbp->reply_id,
     334                        'normal'
     335                );
     336               
     337                do_action('bbp_anonymous_metabox');
     338        }
     339       
     340        /**
     341         * anonymous_metabox_save ()
     342         *
     343         * Saves all of the anonymous information about an anonymous user.
     344         *
     345         * @param int $post_id
     346         * @return int
     347         */
     348       
     349        function anonymous_metabox_save ( $post_id ) {
     350                if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
     351                        return $post_id;
     352                       
     353                if( !current_user_can( 'edit_post', $post_id ) )
     354                        return $post_id;
     355               
     356                update_post_meta( $post_id, '_bbp_anonymous_name', $_POST['bbp_anonymous_name'] );
     357               
     358                update_post_meta( $post_id, '_bbp_anonymous_email', $_POST['bbp_anonymous_email'] );
     359                               
     360                do_action('bbp_anonymous_metabox_save');
     361               
     362                return $post_id;
     363                       
     364        }
     365       
    301366
    302367        /**
    303368         * admin_head ()
     
    11131178        do_action( 'bbp_topic_reply_metabox' );
    11141179}
    11151180
     1181
    11161182/**
     1183 * bbp_anonymous_metabox ()
     1184 *
     1185 *
     1186 *
     1187 * @package bbPress
     1188 * @subpackage Template Tags
     1189 * @since bbPress (r2464)
     1190 *
     1191 * @todo Alot ;)
     1192 * @global object $post
     1193 */
     1194function bbp_anonymous_metabox () {
     1195        global $post, $bbp;
     1196       
     1197        ?>
     1198        <p>IP Address: <?php echo get_post_meta($post->ID, '_bbp_anonymous_ip', true); ?></p>
     1199        <p><strong><?php _e('Name', 'bbpress'); ?></strong></p>
     1200        <label class="screen-reader-text" for="parent_id"><?php _e('Name', 'bbpress'); ?></label>
     1201        <input type="text" name="bbp_anonymous_name" value="<?php echo get_post_meta($post->ID, '_bbp_anonymous_name', true); ?>" size="23" /></label>
     1202       
     1203        <p><strong><?php _e('Email', 'bbpress'); ?></strong></p>
     1204        <label class="screen-reader-text" for="parent_id"><?php _e('Email', 'bbpress'); ?></label>
     1205        <input type="text" name="bbp_anonymous_email" value="<?php echo get_post_meta($post->ID, '_bbp_anonymous_email', true); ?>" size="23" /></label>       
     1206        <?php
     1207}
     1208
     1209
     1210/**
    11171211 * bbp_admin_dropdown ()
    11181212 *
    11191213 * General wrapper for creating a drop down of selectable parents