[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
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-general-update' ); 8 9 foreach ( (array) $_POST as $option => $value ) { 10 if ( !in_array( $option, array( '_wpnonce', '_wp_http_referer', 'action', 'submit' ) ) ) { 11 $option = trim( $option ); 12 $value = is_array( $value ) ? $value : trim( $value ); 13 $value = stripslashes_deep( $value ); 14 if ( $option == 'uri' && !empty( $value ) ) { 15 $value = rtrim( $value, " \t\n\r\0\x0B/" ) . '/'; 16 } 17 if ( $value ) { 18 bb_update_option( $option, $value ); 19 } else { 20 bb_delete_option( $option ); 21 } 22 } 23 } 24 25 $goback = add_query_arg( 'updated', 'true', wp_get_referer() ); 26 bb_safe_redirect( $goback ); 27 exit; 28 } 29 30 if ( !empty( $_GET['updated'] ) ) { 31 bb_admin_notice( __( '<strong>Settings saved.</strong>' ) ); 32 } 33 34 $general_options = array( 35 'name' => array( 36 'title' => __( 'Site title' ), 37 'class' => 'long', 38 ), 39 'description' => array( 40 'title' => __( 'Tagline' ), 41 'class' => 'long', 42 'note' => __( 'In a few words, explain what this site is about.' ) 43 ), 44 'uri' => array( 45 'title' => __( 'bbPress address (URL)' ), 46 'class' => array('long', 'code'), 47 'note' => __( 'The full URL of your bbPress install.' ), 48 ), 49 'from_email' => array( 50 'title' => __( 'E-mail address' ), 51 'note' => __( 'This address is used for admin purposes, like new user notification.' ), 52 ) 53 ); 54 55 $time_options = array( 56 'gmt_offset' => array( 57 'title' => __( 'Time zone' ), 58 'type' => 'select', 59 'options' => array( 60 '-12' => '-12:00', 61 '-11.5' => '-11:30', 62 '-11' => '-11:00', 63 '-10.5' => '-10:30', 64 '-10' => '-10:00', 65 '-9.5' => '-9:30', 66 '-9' => '-9:00', 67 '-8.5' => '-8:30', 68 '-8' => '-8:00', 69 '-7.5' => '-7:30', 70 '-7' => '-7:00', 71 '-6.5' => '-6:30', 72 '-6' => '-6:00', 73 '-5.5' => '-5:30', 74 '-5' => '-5:00', 75 '-4.5' => '-4:30', 76 '-4' => '-4:00', 77 '-3.5' => '-3:30', 78 '-3' => '-3:00', 79 '-2.5' => '-2:30', 80 '-2' => '-2:00', 81 '-1.5' => '-1:30', 82 '-1' => '-1:00', 83 '-0.5' => '-0:30', 84 '0' => '', 85 '0.5' => '+0:30', 86 '1' => '+1:00', 87 '1.5' => '+1:30', 88 '2' => '+2:00', 89 '2.5' => '+2:30', 90 '3' => '+3:00', 91 '3.5' => '+3:30', 92 '4' => '+4:00', 93 '4.5' => '+4:30', 94 '5' => '+5:00', 95 '5.5' => '+5:30', 96 '5.75' => '+5:45', 97 '6' => '+6:00', 98 '6.5' => '+6:30', 99 '7' => '+7:00', 100 '7.5' => '+7:30', 101 '8' => '+8:00', 102 '8.5' => '+8:30', 103 '8.75' => '+8:45', 104 '9' => '+9:00', 105 '9.5' => '+9:30', 106 '10' => '+10:00', 107 '10.5' => '+10:30', 108 '11' => '+11:00', 109 '11.5' => '+11:30', 110 '12' => '+12:00', 111 '12.75' => '+12:45', 112 '13' => '+13:00', 113 '13.75' => '+13:45', 114 '14' => '+14:00' 115 ), 116 'after' => __( 'hours' ) 117 ), 118 'datetime_format' => array( 119 'title' => __( 'Date and time format' ), 120 'class' => 'short', 121 'value' => bb_get_datetime_formatstring_i18n(), 122 'after' => bb_datetime_format_i18n( bb_current_time() ), 123 'note' => array( 124 __( '<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>.' ), 125 __( 'Click "Save Changes" to update sample output.' ) 126 ) 127 ), 128 'date_format' => array( 129 'title' => __( 'Date format' ), 130 'class' => 'short', 131 'value' => bb_get_datetime_formatstring_i18n( 'date' ), 132 'after' => bb_datetime_format_i18n( bb_current_time(), 'date' ) 133 ) 134 ); 135 136 if ( !$gmt_offset = bb_get_option( 'gmt_offset' ) ) { 137 $gmt_offset = 0; 138 } 139 140 if ( wp_timezone_supported() ) { 141 unset( $time_options['gmt_offset'] ); 142 143 if ( !$timezone_string = bb_get_option( 'timezone_string' ) ) { 144 // set the Etc zone if no timezone string exists 145 $_gmt_offset = (integer) round( $gmt_offset ); 146 if ( $_gmt_offset === 0 ) { 147 $timezone_string = 'Etc/UTC'; 148 } elseif ( $_gmt_offset > 0 ) { 149 // Zoneinfo has these signed backwards to common convention 150 $timezone_string = 'Etc/GMT-' . abs( $_gmt_offset ); 151 } else { 152 // Zoneinfo has these signed backwards to common convention 153 $timezone_string = 'Etc/GMT+' . abs( $_gmt_offset ); 154 } 155 unset( $_gmt_offset ); 156 } 157 158 // Build the new selector 159 $_time_options = array( 160 'timezone_string' => array( 161 'title' => __( 'Time zone' ), 162 'type' => 'select', 163 'options' => wp_timezone_choice( $timezone_string ), // This passes a string of html, which gets used verbatim 164 'note' => array( 165 __( 'Choose a city in the same time zone as you.' ), 166 sprintf( __( '<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>' ), bb_gmdate_i18n( bb_get_datetime_formatstring_i18n(), bb_current_time() ) ), 167 sprintf( __( 'Local time is <code>%s</code>' ), bb_datetime_format_i18n( bb_current_time() ) ) 168 ) 169 ) 170 ); 171 172 $_now = localtime( bb_current_time(), true ); 173 if ( $now['tm_isdst'] ) { 174 $_time_options['timezone_string']['note'][] = __( 'This time zone is currently in daylight savings time.' ); 175 } else { 176 $_time_options['timezone_string']['note'][] = __( 'This time zone is currently in standard time.' ); 177 } 178 179 if ( function_exists( 'timezone_transitions_get' ) ) { 180 $timezone_object = new DateTimeZone( $timezone_string ); 181 $found_transition = false; 182 foreach ( timezone_transitions_get( $timezone_object ) as $timezone_transition ) { 183 if ( $timezone_transition['ts'] > time() ) { 184 $note = $timezone_transition['isdst'] ? __('Daylight savings time begins on <code>%s</code>') : __('Standard time begins on <code>%s</code>'); 185 $_time_options['timezone_string']['note'][] = sprintf( $note, bb_gmdate_i18n( bb_get_datetime_formatstring_i18n(), $timezone_transition['ts'], false ) ); 186 break; 187 } 188 } 189 } 190 191 $time_options = array_merge( $_time_options, $time_options ); 192 193 } else { 194 // Tidy up the old style dropdown 195 $time_options['gmt_offset']['note'] = array( 196 1 => sprintf( __( '<abbr title="Coordinated Universal Time">UTC</abbr> %s is <code>%s</code>' ), $time_options['gmt_offset']['options'][$gmt_offset], bb_datetime_format_i18n( bb_current_time() ) ), 197 2 => __( 'Unfortunately, you have to manually update this for Daylight Savings Time.' ) 198 ); 199 200 if ( $gmt_offset ) { 201 $time_options['gmt_offset']['note'][0] = sprintf( __( '<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>' ), bb_gmdate_i18n( bb_get_datetime_formatstring_i18n(), bb_current_time(), true ) ); 202 ksort($time_options['gmt_offset']['note']); 203 } 204 205 foreach ( $time_options['gmt_offset']['options'] as $_key => $_value ) { 206 $time_options['gmt_offset']['options'][$_key] = sprintf( __( 'UTC %s' ), $_value ); 207 } 208 } 209 210 211 $bb_admin_body_class = ' bb-admin-settings'; 212 213 bb_get_admin_header(); 214 215 ?> 216 217 <div class="wrap"> 218 219 <h2><?php _e('General Settings'); ?></h2> 220 <?php do_action( 'bb_admin_notices' ); ?> 221 222 <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 ); ?>"> 223 <fieldset> 224 <?php 225 foreach ( $general_options as $option => $args ) { 226 bb_option_form_element( $option, $args ); 227 } 228 foreach ( $time_options as $option => $args ) { 229 bb_option_form_element( $option, $args ); 230 } 231 ?> 232 </fieldset> 233 <fieldset class="submit"> 234 <?php bb_nonce_field( 'options-general-update' ); ?> 235 <input type="hidden" name="action" value="update" /> 236 <input class="submit" type="submit" name="submit" value="<?php _e('Save Changes') ?>" /> 237 </fieldset> 238 </form> 239 240 </div> 241 242 <?php 243 244 bb_get_admin_footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Dec 7 01:01:35 2017 | Cross-referenced by PHPXref 0.7.1 |