190 } |
190 } |
191 update_option( 'recently_edited', $oldfiles ); |
191 update_option( 'recently_edited', $oldfiles ); |
192 } |
192 } |
193 |
193 |
194 /** |
194 /** |
195 * If siteurl or home changed, flush rewrite rules. |
195 * If siteurl, home or page_on_front changed, flush rewrite rules. |
196 * |
196 * |
197 * @since 2.1.0 |
197 * @since 2.1.0 |
198 * |
198 * |
199 * @param string $old_value |
199 * @param string $old_value |
200 * @param string $value |
200 * @param string $value |
207 flush_rewrite_rules(); |
207 flush_rewrite_rules(); |
208 } |
208 } |
209 |
209 |
210 add_action( 'update_option_home', 'update_home_siteurl', 10, 2 ); |
210 add_action( 'update_option_home', 'update_home_siteurl', 10, 2 ); |
211 add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); |
211 add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); |
|
212 add_action( 'update_option_page_on_front', 'update_home_siteurl', 10, 2 ); |
212 |
213 |
213 /** |
214 /** |
214 * Shorten an URL, to be used as link text |
215 * Shorten an URL, to be used as link text |
215 * |
216 * |
216 * @since 1.2.1 |
217 * @since 1.2.1 |
323 if ( !$user = wp_get_current_user() ) |
324 if ( !$user = wp_get_current_user() ) |
324 return; |
325 return; |
325 $option = $_POST['wp_screen_options']['option']; |
326 $option = $_POST['wp_screen_options']['option']; |
326 $value = $_POST['wp_screen_options']['value']; |
327 $value = $_POST['wp_screen_options']['value']; |
327 |
328 |
328 if ( !preg_match( '/^[a-z_-]+$/', $option ) ) |
329 if ( $option != sanitize_key( $option ) ) |
329 return; |
330 return; |
330 |
|
331 $option = str_replace('-', '_', $option); |
|
332 |
331 |
333 $map_option = $option; |
332 $map_option = $option; |
334 $type = str_replace('edit_', '', $map_option); |
333 $type = str_replace('edit_', '', $map_option); |
335 $type = str_replace('_per_page', '', $type); |
334 $type = str_replace('_per_page', '', $type); |
336 if ( in_array($type, get_post_types()) ) |
335 if ( in_array( $type, get_taxonomies() ) ) |
|
336 $map_option = 'edit_tags_per_page'; |
|
337 elseif ( in_array( $type, get_post_types() ) ) |
337 $map_option = 'edit_per_page'; |
338 $map_option = 'edit_per_page'; |
338 if ( in_array( $type, get_taxonomies()) ) |
339 else |
339 $map_option = 'edit_tags_per_page'; |
340 $option = str_replace('-', '_', $option); |
340 |
341 |
341 switch ( $map_option ) { |
342 switch ( $map_option ) { |
342 case 'edit_per_page': |
343 case 'edit_per_page': |
343 case 'users_per_page': |
344 case 'users_per_page': |
344 case 'edit_comments_per_page': |
345 case 'edit_comments_per_page': |
522 fwrite($fp, $config); |
523 fwrite($fp, $config); |
523 fclose($fp); |
524 fclose($fp); |
524 } |
525 } |
525 |
526 |
526 /** |
527 /** |
527 * Workaround for Windows bug in is_writable() function |
|
528 * |
|
529 * @since 2.8.0 |
|
530 * |
|
531 * @param string $path |
|
532 * @return bool |
|
533 */ |
|
534 function win_is_writable( $path ) { |
|
535 /* will work in despite of Windows ACLs bug |
|
536 * NOTE: use a trailing slash for folders!!! |
|
537 * see http://bugs.php.net/bug.php?id=27609 |
|
538 * see http://bugs.php.net/bug.php?id=30931 |
|
539 */ |
|
540 |
|
541 if ( $path[strlen( $path ) - 1] == '/' ) // recursively return a temporary file path |
|
542 return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp'); |
|
543 else if ( is_dir( $path ) ) |
|
544 return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' ); |
|
545 // check tmp file for read/write capabilities |
|
546 $should_delete_tmp_file = !file_exists( $path ); |
|
547 $f = @fopen( $path, 'a' ); |
|
548 if ( $f === false ) |
|
549 return false; |
|
550 fclose( $f ); |
|
551 if ( $should_delete_tmp_file ) |
|
552 unlink( $path ); |
|
553 return true; |
|
554 } |
|
555 |
|
556 /** |
|
557 * Display the default admin color scheme picker (Used in user-edit.php) |
528 * Display the default admin color scheme picker (Used in user-edit.php) |
558 * |
529 * |
559 * @since 3.0.0 |
530 * @since 3.0.0 |
560 */ |
531 */ |
561 function admin_color_scheme_picker() { |
532 function admin_color_scheme_picker() { |
564 <?php |
535 <?php |
565 $current_color = get_user_option('admin_color', $user_id); |
536 $current_color = get_user_option('admin_color', $user_id); |
566 if ( empty($current_color) ) |
537 if ( empty($current_color) ) |
567 $current_color = 'fresh'; |
538 $current_color = 'fresh'; |
568 foreach ( $_wp_admin_css_colors as $color => $color_info ): ?> |
539 foreach ( $_wp_admin_css_colors as $color => $color_info ): ?> |
569 <div class="color-option"><input name="admin_color" id="admin_color_<?php echo $color; ?>" type="radio" value="<?php echo esc_attr($color) ?>" class="tog" <?php checked($color, $current_color); ?> /> |
540 <div class="color-option"><input name="admin_color" id="admin_color_<?php echo esc_attr( $color ); ?>" type="radio" value="<?php echo esc_attr( $color ); ?>" class="tog" <?php checked($color, $current_color); ?> /> |
570 <table class="color-palette"> |
541 <table class="color-palette"> |
571 <tr> |
542 <tr> |
572 <?php foreach ( $color_info->colors as $html_color ): ?> |
543 <?php foreach ( $color_info->colors as $html_color ): ?> |
573 <td style="background-color: <?php echo $html_color ?>" title="<?php echo $color ?>"> </td> |
544 <td style="background-color: <?php echo esc_attr( $html_color ); ?>" title="<?php echo esc_attr( $color ); ?>"> </td> |
574 <?php endforeach; ?> |
545 <?php endforeach; ?> |
575 </tr> |
546 </tr> |
576 </table> |
547 </table> |
577 |
548 |
578 <label for="admin_color_<?php echo $color; ?>"><?php echo $color_info->name ?></label> |
549 <label for="admin_color_<?php echo esc_attr( $color ); ?>"><?php echo esc_html( $color_info->name ); ?></label> |
579 </div> |
550 </div> |
580 <?php endforeach; ?> |
551 <?php endforeach; ?> |
581 </fieldset> |
552 </fieldset> |
582 <?php |
553 <?php |
583 } |
554 } |