[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-forums/bbpress/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 email.' )
  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              'retro'     => bb_get_avatar( rand( 0, 999 ), 32, 'retro' )     . ' ' . __( 'Retro  (Generated)' )
 107          ),
 108          'note' => array(
 109              __( 'For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their email address.' )
 110          ),
 111      )
 112  );
 113  remove_filter( 'bb_get_option_avatars_show', $bb_get_option_avatars_show );
 114  
 115  $bb_admin_body_class = ' bb-admin-settings';
 116  
 117  bb_get_admin_header();
 118  
 119  ?>
 120  
 121  <div class="wrap">
 122  
 123  <h2><?php _e('Discussion Settings'); ?></h2>
 124  <?php do_action( 'bb_admin_notices' ); ?>
 125  
 126  <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 ); ?>">
 127      <fieldset>
 128  <?php
 129  foreach ( $general_options as $option => $args ) {
 130      bb_option_form_element( $option, $args );
 131  }
 132  ?>
 133      </fieldset>
 134      <fieldset>
 135          <legend><?php _e('Avatars'); ?></legend>
 136          <p>
 137              <?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.'); ?>
 138          </p>
 139  <?php
 140  foreach ( $avatar_options as $option => $args ) {
 141      bb_option_form_element( $option, $args );
 142  }
 143  ?>
 144      </fieldset>
 145      <fieldset class="submit">
 146          <?php bb_nonce_field( 'options-discussion-update' ); ?>
 147          <input type="hidden" name="action" value="update" />
 148          <input class="submit" type="submit" name="submit" value="<?php _e('Save Changes') ?>" />
 149      </fieldset>
 150  </form>
 151  
 152  </div>
 153  
 154  <?php
 155  
 156  bb_get_admin_footer();


Generated: Thu Dec 7 01:01:35 2017 Cross-referenced by PHPXref 0.7.1