Skip to:
Content

bbPress.org


Ignore:
Timestamp:
03/26/2009 02:16:11 AM (18 years ago)
Author:
mdawaffe
Message:

bb_option_form_element() and grey out/disable options which are hardcoded in bb-config.php. Fixes #1061

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-admin/options-general.php

    r2011 r2042  
    11<?php
     2
    23require_once('admin.php');
    34
    … …  
    4647}
    4748
     49$general_options = array(
     50        'name' => array(
     51                'title' => __( 'Site title' ),
     52                'class' => 'long',
     53        ),
     54        'description' => array(
     55                'title' => __( 'Site description' ),
     56                'class' => 'long',
     57        ),
     58        'uri' => array(
     59                'title' => __( 'bbPress address (URL)' ),
     60                'class' => 'long',
     61                'note' => __( 'The full URL of your bbPress install.' ),
     62        ),
     63        'from_email' => array(
     64                'title' => __( 'E-mail address' ),
     65                'note' => __( 'Emails sent by the site will appear to come from this address.' ),
     66        ),
     67        'mod_rewrite' => array(
     68                'title' => __( 'Pretty permalink type' ),
     69                'type' => 'select',
     70                'options' => array(
     71                        '0' => __( 'None&nbsp;&nbsp;&nbsp;&hellip;/forums.php?id=1' ),
     72                        '1' => __( 'Numeric&nbsp;&nbsp;&nbsp;.../forums/1' ),
     73                        'slugs' => __( 'Name based&nbsp;&nbsp;&nbsp;.../forums/first-forum' ),
     74                ),
     75                'note' => sprintf(
     76                        __( 'If you activate "Numeric" or "Name based" permalinks, you will need to create a file at <code>%s</code> containing the url rewriting rules <a href="%s">provided here</a>.' ),
     77                        BB_PATH . '.htaccess',
     78                        bb_get_uri( 'bb-admin/rewrite-rules.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN )
     79                ),
     80        ),
     81        'page_topics' => array(
     82                'title' => __( 'Items per page' ),
     83                'class' => 'short',
     84                'note' => __( 'Number of topics, posts or tags to show per page.' ),
     85        ),
     86        'edit_lock' => array(
     87                'title' => __( 'Lock post editing after' ),
     88                'class' => 'short',
     89                'after' => __( 'minutes' ),
     90                'note' => 'A user can edit a post for this many minutes after submitting.',
     91        ),
     92);
     93
     94$date_time_options = array(
     95        'gmt_offset' => array(
     96                'title' => __( 'Times should differ<br />from UTC by' ),
     97                'class' => 'short',
     98                'after' => __( 'hours' ),
     99                'note' => __( 'Example: -7 for Pacific Daylight Time.' ),
     100        ),
     101        'datetime_format' => array(
     102                'title' => __( 'Date and time format' ),
     103                'value' => bb_get_datetime_formatstring_i18n(),
     104                'note' => sprintf( __( 'Output: <strong>%s</strong>' ), bb_datetime_format_i18n( bb_current_time() ) ),
     105        ),
     106        'date_format' => array(
     107                'title' => __( 'Date format' ),
     108                'value' => bb_get_datetime_formatstring_i18n( 'date' ),
     109                'note' => array(
     110                        sprintf( __( 'Output: <strong>%s</strong>' ), bb_datetime_format_i18n( bb_current_time(), 'date' ) ),
     111                        __( 'Click "Update settings" to update sample output.' ),
     112                        __( '<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>.' ),
     113                ),
     114        ),
     115);
     116
     117$remote_options = array(
     118        'enable_xmlrpc' => array(
     119                'title' => __( 'Enable XML-RPC' ),
     120                'type' => 'checkbox',
     121                'after' => __( 'Allow remote publishing and management via the bbPress <a href="http://codex.wordpress.org/Glossary#XML-RPC">XML-RPC</a> publishing protocol?' ),
     122        ),
     123        'enable_pingback' => array(
     124                'title' => __( 'Enable Pingbacks' ),
     125                'type' => 'checkbox',
     126                'after' => __( 'Allow sending and receiving of <a href="http://codex.wordpress.org/Glossary#PingBack">pingbacks</a>?' ),
     127        ),
     128);
     129
     130$bb_get_option_avatars_show = create_function( '$a', 'return 1;' );
     131add_filter( 'bb_get_option_avatars_show', $bb_get_option_avatars_show );
     132$avatar_options = array(
     133        'avatars_show' => array(
     134                'title' => __( 'Show avatars' ),
     135                'type' => 'checkbox',
     136                'after' => __( 'Display avatars on your site?' ),
     137        ),
     138        'avatars_default' => array(
     139                'title' => __( 'Gravatar default image' ),
     140                'type' => 'select',
     141                'options' => array(
     142                        'default' => __( 'Default' ),
     143                        'logo' => __( 'Gravatar Logo' ),
     144                        'monsterid' => __( 'MonsterID' ),
     145                        'wavatar' => __( 'Wavatar' ),
     146                        'identicon' => __( 'Identicon' ),
     147                ),
     148                'note' => array(
     149                        __( 'Select what style of avatar to display to users without a Gravatar:' ),
     150                        bb_get_avatar( 'anotherexample', 30, 'default' ) . __( 'Default' ),
     151                        bb_get_avatar( 'anotherexample', 30, 'logo' ) . __( 'Gravatar Logo' ),
     152                        bb_get_avatar( 'anotherexample', 30, 'monsterid' ) . __( 'MonsterID' ),
     153                        bb_get_avatar( 'anotherexample', 30, 'wavatar' ) . __( 'Wavatar' ),
     154                        bb_get_avatar( 'anotherexample', 30, 'identicon' ) . __( 'Identicon' ),
     155                ),
     156        ),
     157        'avatars_rating' => array(
     158                'title' => __( 'Gravatar maximum rating' ),
     159                'type' => 'select',
     160                'options' => array(
     161                        '0' => __( 'None' ),
     162                        'x' => __( 'X' ),
     163                        'r' => __( 'R' ),
     164                        'pg' => __( 'PG' ),
     165                        'g' => __( 'G' ),
     166                ),
     167                'note' => array(
     168                        '<img src="http://site.gravatar.com/images/gravatars/ratings/3.gif" alt="' . attribute_escape( __( 'Rated X' ) ) . '" /> ' . __( 'X rated gravatars may contain hardcore sexual imagery or extremely disturbing violence.' ),
     169                        '<img src="http://site.gravatar.com/images/gravatars/ratings/2.gif" alt="' . attribute_escape( __( 'Rated R' ) ) . '" /> ' . __( 'R rated gravatars may contain such things as harsh profanity, intense violence, nudity, or hard drug use.' ),
     170                        '<img src="http://site.gravatar.com/images/gravatars/ratings/1.gif" alt="' . attribute_escape( __( 'Rated PG' ) ). '" /> ' . __( 'PG rated gravatars may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.' ),
     171                        '<img src="http://site.gravatar.com/images/gravatars/ratings/0.gif" alt="' . attribute_escape( __( 'Rated G' ) ) . '" /> ' . __( 'A G rated gravatar is suitable for display on all websites with any audience type.' ),
     172                ),
     173        ),
     174);
     175remove_filter( 'bb_get_option_avatars_show', $bb_get_option_avatars_show );
     176
    48177bb_get_admin_header();
     178
    49179?>
    50180
    … …  
    54184
    55185<form class="settings" method="post" action="<?php bb_uri('bb-admin/options-general.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>">
    56         <fieldset>
    57                 <div>
    58                         <label for="name">
    59                                 <?php _e('Site title'); ?>
    60                         </label>
    61                         <div>
    62                                 <input class="text long" name="name" id="name" value="<?php bb_form_option('name'); ?>" />
    63                         </div>
    64                 </div>
    65                 <div>
    66                         <label for="description">
    67                                 <?php _e('Site description'); ?>
    68                         </label>
    69                         <div>
    70                                 <input class="text long" name="description" id="description" value="<?php bb_form_option('description'); ?>" />
    71                         </div>
    72                 </div>
    73                 <div>
    74                         <label for="uri">
    75                                 <?php _e('bbPress address (URL)'); ?>
    76                         </label>
    77                         <div>
    78                                 <input class="text long" name="uri" id="uri" value="<?php bb_form_option('uri'); ?>" />
    79                                 <p><?php _e('The full URL of your bbPress install.'); ?></p>
    80                         </div>
    81                 </div>
    82                 <div>
    83                         <label for="from_email">
    84                                 <?php _e('E-mail address') ?>
    85                         </label>
    86                         <div>
    87                                 <input class="text" name="from_email" id="from_email" value="<?php bb_form_option('from_email'); ?>" />
    88                                 <p><?php _e('Emails sent by the site will appear to come from this address.'); ?></p>
    89                         </div>
    90                 </div>
    91                 <div>
    92                         <label for="mod_rewrite">
    93                                 <?php _e('Pretty permalink type') ?>
    94                         </label>
    95                         <div>
    96                                 <select name="mod_rewrite" id="mod_rewrite">
    97                                         <option value="0"<?php selected( bb_get_option('mod_rewrite'), '0' ); ?>><?php _e('None'); ?>&nbsp;&nbsp;&nbsp;.../forums.php?id=1</option>
    98                                         <option value="1"<?php selected( bb_get_option('mod_rewrite'), '1' ); ?>><?php _e('Numeric'); ?>&nbsp;&nbsp;&nbsp;.../forums/1</option>
    99                                         <option value="slugs"<?php selected( bb_get_option('mod_rewrite'), 'slugs' ); ?>><?php _e('Name based'); ?>&nbsp;&nbsp;&nbsp;.../forums/first-forum</option>
    100                                 </select>
    101                                 <p><?php printf(__('If you activate "Numeric" or "Name based" permalinks, you will need to create a file at <code>%s</code> containing the url rewriting rules <a href="%s">provided here</a>.'), BB_PATH . '.htaccess', bb_get_uri('bb-admin/rewrite-rules.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN)); ?></p>
    102                         </div>
    103                 </div>
    104                 <div>
    105                         <label for="page_topics">
    106                                 <?php _e('Items per page') ?>
    107                         </label>
    108                         <div>
    109                                 <input class="text short" name="page_topics" id="page_topics" value="<?php bb_form_option('page_topics'); ?>" />
    110                                 <p><?php _e('Number of topics, posts or tags to show per page.') ?></p>
    111                         </div>
    112                 </div>
    113                 <div>
    114                         <label for="edit_lock">
    115                                 <?php _e('Lock post editing after') ?>
    116                         </label>
    117                         <div>
    118                                 <input class="text short" name="edit_lock" id="edit_lock" value="<?php bb_form_option('edit_lock'); ?>" />
    119                                 <?php _e('minutes') ?>
    120                                 <p><?php _e('A user can edit a post for this many minutes after submitting.'); ?></p>
    121                         </div>
    122                 </div>
    123         </fieldset>
     186        <fieldset><?php foreach ( $general_options as $option => $args ) bb_option_form_element( $option, $args ); ?></fieldset>
    124187        <fieldset>
    125188                <legend><?php _e('Date and Time') ?></legend>
    … …  
    132195                        </div>
    133196                </div>
    134                 <div>
    135                         <label for="gmt_offset">
    136                                 <?php _e('Times should differ<br />from UTC by') ?>
    137                         </label>
    138                         <div>
    139                                 <input class="text short" name="gmt_offset" id="gmt_offset" value="<?php bb_form_option('gmt_offset'); ?>" />
    140                                 <?php _e('hours') ?>
    141                                 <p><?php _e('Example: -7 for Pacific Daylight Time.'); ?></p>
    142                         </div>
    143                 </div>
    144                 <div>
    145                         <label for="datetime_format">
    146                                 <?php _e('Date and time format') ?>
    147                         </label>
    148                         <div>
    149                                 <input class="text" name="datetime_format" id="datetime_format" value="<?php echo(attribute_escape(bb_get_datetime_formatstring_i18n())); ?>" />
    150                                 <p><?php printf(__('Output: <strong>%s</strong>'), bb_datetime_format_i18n( bb_current_time() )); ?></p>
    151                         </div>
    152                 </div>
    153                 <div>
    154                         <label for="date_format">
    155                                 <?php _e('Date format') ?>
    156                         </label>
    157                         <div>
    158                                 <input class="text" name="date_format" id="date_format" value="<?php echo(attribute_escape(bb_get_datetime_formatstring_i18n('date'))); ?>" />
    159                                 <p><?php printf(__('Output: <strong>%s</strong>'), bb_datetime_format_i18n( bb_current_time(), 'date' )); ?></p>
    160                                 <p><?php _e('Click "Update settings" to update sample output.') ?></p>
    161                                 <p><?php _e('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>.'); ?></p>
    162                         </div>
    163                 </div>
     197<?php           foreach ( $date_time_options as $option => $args ) bb_option_form_element( $option, $args ); ?>
    164198        </fieldset>
    165199        <fieldset>
    … …  
    168202                        <?php _e('How do we describe this?'); ?>
    169203                </p>
    170                 <div>
    171                         <label for="enable_xmlrpc">
    172                                 <?php _e('Enable XML-RPC') ?>
    173                         </label>
    174                         <div>
    175                                 <input type="checkbox" class="checkbox" name="enable_xmlrpc" id="enable_xmlrpc" value="1"<?php checked( bb_get_option('enable_xmlrpc'), 1 ); ?> />
    176                                 <?php _e('Allows remote publishing and management via the bbPress <a href="http://codex.wordpress.org/Glossary#XML-RPC">XML-RPC</a> publishing protocol.'); ?>
    177                         </div>
    178                 </div>
    179                 <div>
    180                         <label for="enable_pingback">
    181                                 <?php _e('Enable Pingbacks') ?>
    182                         </label>
    183                         <div>
    184                                 <input type="checkbox" class="checkbox" name="enable_pingback" id="enable_pingback" value="1"<?php checked( bb_get_option('enable_pingback'), 1 ); ?> />
    185                                 <?php _e('Allows sending and receiving of <a href="http://codex.wordpress.org/Glossary#PingBack">pingbacks</a>.'); ?>
    186                         </div>
    187                 </div>
     204<?php           foreach ( $remote_options as $option => $args ) bb_option_form_element( $option, $args ); ?>
    188205        </fieldset>
    189206        <fieldset>
    … …  
    192209                        <?php _e('bbPress includes built-in support for <a href="http://gravatar.com/">Gravatars</a>, you can enable this feature here.'); ?>
    193210                </p>
    194                 <div>
    195                         <label for="avatars_show">
    196                                 <?php _e('Show avatars') ?>
    197                         </label>
    198                         <div>
    199                                 <input type="checkbox" class="checkbox" name="avatars_show" id="avatars_show" value="1"<?php checked( bb_get_option('avatars_show'), 1 ); ?> />
    200                         </div>
    201                 </div>
    202 <?php
    203         $bb_get_option_avatars_show = create_function( '$a', 'return 1;' );
    204         add_filter( 'bb_get_option_avatars_show', $bb_get_option_avatars_show );
    205 ?>
    206                 <div>
    207                         <label for="avatars_default">
    208                                 <?php _e('Gravatar default image'); ?>
    209                         </label>
    210                         <div>
    211                                 <select name="avatars_default" id="avatars_default">
    212                                         <option value="default"<?php selected( bb_get_option('avatars_default'), 'default' ); ?>><?php _e('Default'); ?></option>
    213                                         <option value="logo"<?php selected( bb_get_option('avatars_default'), 'logo' ); ?>><?php _e('Gravatar Logo'); ?></option>
    214                                         <option value="monsterid"<?php selected( bb_get_option('avatars_default'), 'monsterid' ); ?>><?php _e('MonsterID'); ?></option>
    215                                         <option value="wavatar"<?php selected( bb_get_option('avatars_default'), 'wavatar' ); ?>><?php _e('Wavatar'); ?></option>
    216                                         <option value="identicon"<?php selected( bb_get_option('avatars_default'), 'identicon' ); ?>><?php _e('Identicon'); ?></option>
    217                                 </select>
    218                                 <p><?php _e('Select what style of avatar to display to users without a Gravatar:'); ?></p>
    219                                 <p class="gravatarDefault">
    220                                         <?php echo bb_get_avatar( 'anotherexample', 30, 'default' ); ?><?php _e('Default'); ?>
    221                                 </p>
    222                                 <p class="gravatarDefault">
    223                                         <?php echo bb_get_avatar( 'anotherexample', 30, 'logo' ); ?><?php _e('Gravatar Logo'); ?>
    224                                 </p>
    225                                 <p class="gravatarDefault">
    226                                         <?php echo bb_get_avatar( 'anotherexample', 30, 'monsterid' ); ?><?php _e('MonsterID'); ?>
    227                                 </p>
    228                                 <p class="gravatarDefault">
    229                                         <?php echo bb_get_avatar( 'anotherexample', 30, 'wavatar' ); ?><?php _e('Wavatar'); ?>
    230                                 </p>
    231                                 <p class="gravatarDefault">
    232                                         <?php echo bb_get_avatar( 'anotherexample', 30, 'identicon' ); ?><?php _e('Identicon'); ?>
    233                                 </p>
    234                         </div>
    235                 </div>
    236 <?php
    237         remove_filter( 'bb_get_option_avatars_show', $bb_get_option_avatars_show );
    238 ?>
    239                 <div>
    240                         <label for="avatars_rating">
    241                                 <?php _e('Gravatar maximum rating'); ?>
    242                         </label>
    243                         <div>
    244                                 <select name="avatars_rating" id="avatars_rating">
    245                                         <option value="0"<?php selected( bb_get_option('avatars_rating'), 0 ); ?>><?php _e('None'); ?></option>
    246                                         <option value="x"<?php selected( bb_get_option('avatars_rating'), 'x' ); ?>><?php _e('X'); ?></option>
    247                                         <option value="r"<?php selected( bb_get_option('avatars_rating'), 'r' ); ?>><?php _e('R'); ?></option>
    248                                         <option value="pg"<?php selected( bb_get_option('avatars_rating'), 'pg' ); ?>><?php _e('PG'); ?></option>
    249                                         <option value="g"<?php selected( bb_get_option('avatars_rating'), 'g' ); ?>><?php _e('G'); ?></option>
    250                                 </select>
    251                                 <p class="gravatarRating">
    252                                         <img src="http://site.gravatar.com/images/gravatars/ratings/3.gif" alt="Rated X" />
    253                                         <?php _e('X rated gravatars may contain hardcore sexual imagery or extremely disturbing violence.'); ?>
    254                                 </p>
    255                                 <p class="gravatarRating">
    256                                         <img src="http://site.gravatar.com/images/gravatars/ratings/2.gif" alt="Rated R" />
    257                                         <?php _e('R rated gravatars may contain such things as harsh profanity, intense violence, nudity, or hard drug use.'); ?>
    258                                 </p>
    259                                 <p class="gravatarRating">
    260                                         <img src="http://site.gravatar.com/images/gravatars/ratings/1.gif" alt="Rated PG" />
    261                                         <?php _e('PG rated gravatars may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.'); ?>
    262                                 </p>
    263                                 <p class="gravatarRating">
    264                                         <img src="http://site.gravatar.com/images/gravatars/ratings/0.gif" alt="Rated G" />
    265                                         <?php _e('A G rated gravatar is suitable for display on all websites with any audience type.'); ?>
    266                                 </p>
    267                         </div>
    268                 </div>
     211<?php           foreach ( $avatar_options as $option => $args ) bb_option_form_element( $option, $args ); ?>
    269212        </fieldset>
    270213        <fieldset class="submit">
    … …  
    278221
    279222<?php
     223
    280224bb_get_admin_footer();
    281 ?>
Note: See TracChangeset for help on using the changeset viewer.