Skip to:
Content

bbPress.org

Changeset 4261


Ignore:
Timestamp:
10/19/2012 01:14:09 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Suggest:

  • Combine admin/ajax.php into admin/admin.php.
  • Tweak metabox output and CSS.
  • Adds phpdoc and inline doc.
  • Fixes #1901
Location:
trunk/bbp-includes/admin
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bbp-includes/admin/admin.php

    r4260 r4261  
    9999                require( $this->admin_dir . 'replies.php'   );
    100100                require( $this->admin_dir . 'users.php'     );
    101                 require( $this->admin_dir . 'ajax.php'      );
    102101        }
    103102
     
    121120                add_action( 'bbp_register_admin_settings', array( $this, 'register_admin_settings'    ) ); // Add settings
    122121                add_action( 'bbp_activation',              array( $this, 'new_install'                ) ); // Add menu item to settings menu
     122                add_action( 'admin_enqueue_scripts',       array( $this, 'enqueue_scripts'            ) ); // Add enqueued JS and CSS
    123123                add_action( 'wp_dashboard_setup',          array( $this, 'dashboard_widget_right_now' ) ); // Forums 'Right now' Dashboard widget
     124
     125                /** Ajax **************************************************************/
     126
     127                add_action( 'wp_ajax_bbp_suggest_forum',        array( $this, 'suggest_forum' ) );
     128                add_action( 'wp_ajax_nopriv_bbp_suggest_forum', array( $this, 'suggest_forum' ) );
     129                add_action( 'wp_ajax_bbp_suggest_topic',        array( $this, 'suggest_topic' ) );
     130                add_action( 'wp_ajax_nopriv_bbp_suggest_topic', array( $this, 'suggest_topic' ) );
    124131
    125132                /** Filters ***********************************************************/
     
    468475
    469476        /**
     477         * Enqueue any admin scripts we might need
     478         * @since bbPress (4260)
     479         */
     480        public function enqueue_scripts() {
     481                wp_enqueue_script( 'suggest' );
     482        }
     483       
     484        /**
    470485         * Add some general styling to the admin area
    471486         *
     
    503518                $topic_class = sanitize_html_class( bbp_get_topic_post_type() );
    504519                $reply_class = sanitize_html_class( bbp_get_reply_post_type() ); ?>
     520
     521                <script type="text/javascript">
     522                        jQuery(document).ready(function() {
     523
     524                                var bbp_forum_id = jQuery( '#bbp_forum_id' );
     525
     526                                bbp_forum_id.suggest( ajaxurl + '?action=bbp_suggest_forum', {
     527                                        onSelect: function() {
     528                                                var value = this.value;
     529                                                bbp_forum_id.val( value.substr( 0, value.indexOf( ' ' ) ) );
     530                                        }
     531                                } );
     532
     533                                var bbp_topic_id = jQuery( '#bbp_topic_id' );
     534
     535                                bbp_topic_id.suggest( ajaxurl + '?action=bbp_suggest_topic', {
     536                                        onSelect: function() {
     537                                                var value = this.value;
     538                                                bbp_topic_id.val( value.substr( 0, value.indexOf( ' ' ) ) );
     539                                        }
     540                                } );
     541                        });
     542                </script>
    505543
    506544                <style type="text/css" media="screen">
     
    11771215        }
    11781216
     1217        /** Ajax ******************************************************************/
     1218
     1219        /**
     1220         * Ajax action for facilitating the forum auto-suggest
     1221         *
     1222         * @since bbPress (rxxxx)
     1223         *
     1224         * @uses get_posts()
     1225         * @uses bbp_get_forum_post_type()
     1226         * @uses bbp_get_forum_id()
     1227         * @uses bbp_get_forum_title()
     1228         */
     1229        public function suggest_forum() {
     1230                foreach ( get_posts( array( 's' => like_escape( $_REQUEST['q'] ), 'post_type' => bbp_get_forum_post_type() ) ) as $post ) {
     1231                        echo sprintf( __( '%s - %s', 'bbpress' ), bbp_get_forum_id( $post->ID ), bbp_get_forum_title( $post->ID ) ) . "\n";
     1232                }
     1233                die();
     1234        }
     1235
     1236        /**
     1237         * Ajax action for facilitating the forum auto-suggest
     1238         *
     1239         * @since bbPress (rxxxx)
     1240         *
     1241         * @uses get_posts()
     1242         * @uses bbp_get_topic_post_type()
     1243         * @uses bbp_get_topic_id()
     1244         * @uses bbp_get_topic_title()
     1245         */
     1246        public function suggest_topic() {
     1247                foreach ( get_posts( array( 's' => like_escape( $_REQUEST['q'] ), 'post_type' => bbp_get_topic_post_type() ) ) as $post ) {
     1248                        echo sprintf( __( '%s - %s', 'bbpress' ), bbp_get_topic_id( $post->ID ), bbp_get_topic_title( $post->ID ) ) . "\n";
     1249                }
     1250                die();
     1251        }
     1252
    11791253        /** About *****************************************************************/
    11801254
  • trunk/bbp-includes/admin/metaboxes.php

    r4260 r4261  
    299299                <strong class="label"><?php _e( 'Parent:', 'bbpress' ); ?></strong>
    300300                <label class="screen-reader-text" for="parent_id"><?php _e( 'Forum Parent', 'bbpress' ); ?></label>
    301                 <input name="parent_id" id="bbp_forum_id" value="<?php echo esc_attr( $post_parent ); ?>" />
     301                <input name="parent_id" id="bbp_forum_id" type="text" value="<?php echo esc_attr( $post_parent ); ?>" />
    302302        </p>
    303303
     
    330330        $post_id = get_the_ID(); ?>
    331331
    332         <p><strong><?php _e( 'Topic Type', 'bbpress' ); ?></strong></p>
    333 
    334         <p>
     332        <p>
     333                <strong class="label"><?php _e( 'Type:', 'bbpress' ); ?></strong>
    335334                <label class="screen-reader-text" for="bbp_stick_topic"><?php _e( 'Topic Type', 'bbpress' ); ?></label>
    336335                <?php bbp_topic_type_select( array( 'topic_id' => $post_id ) ); ?>
    337336        </p>
    338337
    339         <p><strong><?php _e( 'Forum', 'bbpress' ); ?></strong></p>
    340 
    341         <p>
     338        <p>
     339                <strong class="label"><?php _e( 'Forum:', 'bbpress' ); ?></strong>
    342340                <label class="screen-reader-text" for="parent_id"><?php _e( 'Forum', 'bbpress' ); ?></label>
    343341                <input name="parent_id" id="bbp_forum_id" type="text" value="<?php bbp_topic_forum_id( $post_id ); ?>" />
     
    373371        if ( current_user_can( 'edit_others_replies' ) || current_user_can( 'moderate' ) ) : ?>
    374372
    375                 <p><strong><?php _e( 'Forum', 'bbpress' ); ?></strong></p>
    376 
    377373                <p>
     374                        <strong class="label"><?php _e( 'Forum:', 'bbpress' ); ?></strong>
    378375                        <label class="screen-reader-text" for="bbp_forum_id"><?php _e( 'Forum', 'bbpress' ); ?></label>
    379376                        <input name="bbp_forum_id" id="bbp_forum_id" type="text" value="<?php echo esc_attr( $reply_forum_id ); ?>" />
     
    382379        <?php endif; ?>
    383380
    384         <p><strong><?php _e( 'Topic', 'bbpress' ); ?></strong></p>
    385 
    386         <p>
     381        <p>
     382                <strong class="label"><?php _e( 'Topic:', 'bbpress' ); ?></strong>
    387383                <label class="screen-reader-text" for="parent_id"><?php _e( 'Topic', 'bbpress' ); ?></label>
    388384                <input name="parent_id" id="bbp_topic_id" type="text" value="<?php echo esc_attr( $reply_topic_id ); ?>" />
     
    414410        if ( bbp_is_reply_anonymous( $post_id ) || bbp_is_topic_anonymous( $post_id ) ) : ?>
    415411
    416                 <p><strong><?php _e( 'Name', 'bbpress' ); ?></strong></p>
    417 
    418412                <p>
     413                        <strong class="label"><?php _e( 'Name:', 'bbpress' ); ?></strong>
    419414                        <label class="screen-reader-text" for="bbp_anonymous_name"><?php _e( 'Name', 'bbpress' ); ?></label>
    420                         <input type="text" id="bbp_anonymous_name" name="bbp_anonymous_name" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_anonymous_name', true ) ); ?>" size="25" />
     415                        <input type="text" id="bbp_anonymous_name" name="bbp_anonymous_name" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_anonymous_name', true ) ); ?>" />
    421416                </p>
    422417
    423                 <p><strong><?php _e( 'Email', 'bbpress' ); ?></strong></p>
    424 
    425418                <p>
     419                        <strong class="label"><?php _e( 'Email:', 'bbpress' ); ?></strong>
    426420                        <label class="screen-reader-text" for="bbp_anonymous_email"><?php _e( 'Email', 'bbpress' ); ?></label>
    427                         <input type="text" id="bbp_anonymous_email" name="bbp_anonymous_email" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_anonymous_email', true ) ); ?>" size="25" />
     421                        <input type="text" id="bbp_anonymous_email" name="bbp_anonymous_email" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_anonymous_email', true ) ); ?>" />
    428422                </p>
    429423
    430                 <p><strong><?php _e( 'Website', 'bbpress' ); ?></strong></p>
    431 
    432424                <p>
     425                        <strong class="label"><?php _e( 'Website:', 'bbpress' ); ?></strong>
    433426                        <label class="screen-reader-text" for="bbp_anonymous_website"><?php _e( 'Website', 'bbpress' ); ?></label>
    434                         <input type="text" id="bbp_anonymous_website" name="bbp_anonymous_website" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_anonymous_website', true ) ); ?>" size="25" />
     427                        <input type="text" id="bbp_anonymous_website" name="bbp_anonymous_website" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_anonymous_website', true ) ); ?>" />
    435428                </p>
    436429
    437430        <?php endif; ?>
    438431
    439         <p><strong><?php _e( 'IP Address', 'bbpress' ); ?></strong></p>
    440 
    441         <p>
     432        <p>
     433                <strong class="label"><?php _e( 'IP:', 'bbpress' ); ?></strong>
    442434                <label class="screen-reader-text" for="bbp_author_ip_address"><?php _e( 'IP Address', 'bbpress' ); ?></label>
    443                 <input type="text" id="bbp_author_ip_address" name="bbp_author_ip_address" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_author_ip', true ) ); ?>" size="25" disabled="disabled" />
     435                <input type="text" id="bbp_author_ip_address" name="bbp_author_ip_address" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_author_ip', true ) ); ?>" disabled="disabled" />
    444436        </p>
    445437
  • trunk/bbp-includes/admin/replies.php

    r4250 r4261  
    425425                <style type="text/css" media="screen">
    426426                /*<![CDATA[*/
     427
     428                        strong.label {
     429                                display: inline-block;
     430                                width: 60px;
     431                        }
    427432
    428433                        .column-bbp_forum_topic_count,
  • trunk/bbp-includes/admin/topics.php

    r4250 r4261  
    440440                <style type="text/css" media="screen">
    441441                /*<![CDATA[*/
     442
     443                        strong.label {
     444                                display: inline-block;
     445                                width: 60px;
     446                        }
    442447
    443448                        .column-bbp_forum_topic_count,
Note: See TracChangeset for help on using the changeset viewer.