[ Root ] [ Search ] [ Index ]

PHP Cross Reference of bbPress Trunk

Provided by Yoast

title

Body

[close]

/bb-admin/ -> options-discussion.php (source)

   1  <?php
   2  
   3  require_once ('admin.php');
   4  
   5  if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && $_POST['action'] == 'update') {
   6      
   7      bb_check_admin_referer( 'options-discussion-update' );
   8      
   9      // Deal with pingbacks checkbox when it isn't checked
  10      if ( !isset( $_POST['enable_pingback'] ) ) {
  11          $_POST['enable_pingback'] = false;
  12      }
  13  
  14      if ( !isset( $_POST['enable_loginless'] ) ) {
  15          $_POST['enable_loginless'] = false;
  16      }
  17      
  18      if ( !isset( $_POST['enable_subscriptions'] ) ) {
  19          $_POST['enable_subscriptions'] = false;
  20      }
  21      
  22      // Deal with avatars checkbox when it isn't checked
  23      if ( !isset( $_POST['avatars_show'] ) ) {
  24          $_POST['avatars_show'] = false;
  25      }
  26      
  27      foreach ( (array) $_POST as $option => $value ) {
  28          if ( !in_array( $option, array( '_wpnonce', '_wp_http_referer', 'action', 'submit' ) ) ) {
  29              $option = trim( $option );
  30              $value = is_array( $value ) ? $value : trim( $value );
  31              $value = stripslashes_deep( $value );
  32              if ( $value ) {
  33                  bb_update_option( $option, $value );
  34              } else {
  35                  bb_delete_option( $option );
  36              }
  37          }
  38      }
  39      
  40      $goback = add_query_arg('updated', 'true', wp_get_referer());
  41      bb_safe_redirect($goback);
  42      exit;
  43  }
  44  
  45  if ( !empty($_GET['updated']) ) {
  46      bb_admin_notice( __( '<strong>Settings saved.</strong>' ) );
  47  }
  48  
  49  $general_options = array(
  50      'enable_pingback' => array(
  51          'title' => __( 'Enable Pingbacks' ),
  52          'type' => 'checkbox',
  53          'options' => array(
  54              1 => __( 'Allow link notifications from other sites.' )
  55          )
  56      ),
  57  
  58      'enable_loginless' => array(
  59          'title' => __( 'Enable Login-less Posting' ),
  60          'type' => 'checkbox',
  61          'options' => array(
  62              1 => __( 'Allow users to create topics and posts without logging in.' )
  63          ),
  64      ),
  65      
  66      'enable_subscriptions' => array(
  67          'title' => __( 'Enable Subscriptions' ),
  68          'type' => 'checkbox',
  69          'options' => array(
  70              1 => __( 'Allow users to subscribe to topics and receive new posts via e-mail.' )
  71          ),
  72      ),
  73  );
  74  
  75  $bb_get_option_avatars_show = create_function( '$a', 'return 1;' );
  76  add_filter( 'bb_get_option_avatars_show', $bb_get_option_avatars_show );
  77  $avatar_options = array(
  78      'avatars_show' => array(
  79          'title' => __( 'Avatar display' ),
  80          'type' => 'radio',
  81          'options' => array(
  82              0 => __( 'Don&#8217;t show avatars' ),
  83              1 => __( 'Show avatars' )
  84          )
  85      ),
  86      'avatars_rating' => array(
  87          'title' => __( 'Maximum rating' ),
  88          'type' => 'radio',
  89          'options' => array(
  90              'g' => __( 'G &#8212; Suitable for all audiences' ),
  91              'pg' => __( 'PG &#8212; Possibly offensive, usually for audiences 13 and above' ),
  92              'r' => __( 'R &#8212; Intended for adult audiences above 17' ),
  93              'x' => __( 'X &#8212; Even more mature than above' )
  94          )
  95      ),
  96      'avatars_default' => array(
  97          'title' => __( 'Default avatar' ),
  98          'type' => 'radio',
  99          'options' => array(
 100              'default'   => bb_get_avatar( '',             32, 'default' )   . ' ' . __( 'Mystery Man' ),
 101              'blank'     => bb_get_avatar( '',             32, 'blank' )     . ' ' . __( 'Blank' ),
 102              'logo'      => bb_get_avatar( '',             32, 'logo' )      . ' ' . __( 'Gravatar Logo' ),
 103              'identicon' => bb_get_avatar( rand( 0, 999 ), 32, 'identicon' ) . ' ' . __( 'Identicon (Generated)' ),
 104              'wavatar'   => bb_get_avatar( rand( 0, 999 ), 32, 'wavatar' )   . ' ' . __( 'Wavatar (Generated)' ),
 105              'monsterid' => bb_get_avatar( rand( 0, 999 ), 32, 'monsterid' ) . ' ' . __( 'MonsterID  (Generated)' )
 106          ),
 107          'note' => array(
 108              __( 'For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their e-mail address.' )
 109          ),
 110      )
 111  );
 112  remove_filter( 'bb_get_option_avatars_show', $bb_get_option_avatars_show );
 113  
 114  $bb_admin_body_class = ' bb-admin-settings';
 115  
 116  bb_get_admin_header();
 117  
 118  ?>
 119  
 120  <div class="wrap">
 121  
 122  <h2><?php _e('Discussion Settings'); ?></h2>
 123  <?php do_action( 'bb_admin_notices' ); ?>
 124  
 125  <form class="settings" method="post" action="<?php bb_uri( 'bb-admin/options-discussion.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ); ?>">
 126      <fieldset>
 127  <?php
 128  foreach ( $general_options as $option => $args ) {
 129      bb_option_form_element( $option, $args );
 130  }
 131  ?>
 132      </fieldset>
 133      <fieldset>
 134          <legend><?php _e('Avatars'); ?></legend>
 135          <p>
 136              <?php _e('bbPress includes built-in support for <a href="http://gravatar.com/">Gravatars</a>. A Gravatar is an image that follows you from site to site, appearing beside your name when you comment on Gravatar enabled sites. Here you can enable the display of Gravatars on your site.'); ?>
 137          </p>
 138  <?php
 139  foreach ( $avatar_options as $option => $args ) {
 140      bb_option_form_element( $option, $args );
 141  }
 142  ?>
 143      </fieldset>
 144      <fieldset class="submit">
 145          <?php bb_nonce_field( 'options-discussion-update' ); ?>
 146          <input type="hidden" name="action" value="update" />
 147          <input class="submit" type="submit" name="submit" value="<?php _e('Save Changes') ?>" />
 148      </fieldset>
 149  </form>
 150  
 151  </div>
 152  
 153  <?php
 154  
 155  bb_get_admin_footer();


Generated: Mon Nov 15 04:45:27 2010 Cross-referenced by PHPXref 0.7