]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/misc.php
WordPress 4.2
[autoinstalls/wordpress.git] / wp-admin / includes / misc.php
index f93e138819cd0ecca8535bca37766e4ab9a47d14..367611b075711847d567c2fd9112b6017b3f6d57 100644 (file)
@@ -58,8 +58,8 @@ function got_url_rewrite() {
  *
  * @since 1.5.0
  *
  *
  * @since 1.5.0
  *
- * @param unknown_type $filename
- * @param unknown_type $marker
+ * @param string $filename
+ * @param string $marker
  * @return array An array of strings from a file (.htaccess ) from between BEGIN and END markers.
  */
 function extract_from_markers( $filename, $marker ) {
  * @return array An array of strings from a file (.htaccess ) from between BEGIN and END markers.
  */
 function extract_from_markers( $filename, $marker ) {
@@ -94,9 +94,9 @@ function extract_from_markers( $filename, $marker ) {
  *
  * @since 1.5.0
  *
  *
  * @since 1.5.0
  *
- * @param unknown_type $filename
- * @param unknown_type $marker
- * @param unknown_type $insertion
+ * @param string $filename
+ * @param string $marker
+ * @param array  $insertion
  * @return bool True on write success, false on failure.
  */
 function insert_with_markers( $filename, $marker, $insertion ) {
  * @return bool True on write success, false on failure.
  */
 function insert_with_markers( $filename, $marker, $insertion ) {
@@ -211,7 +211,7 @@ function iis7_save_url_rewrite_rules(){
  *
  * @since 1.5.0
  *
  *
  * @since 1.5.0
  *
- * @param unknown_type $file
+ * @param string $file
  */
 function update_recently_edited( $file ) {
        $oldfiles = (array ) get_option( 'recently_edited' );
  */
 function update_recently_edited( $file ) {
        $oldfiles = (array ) get_option( 'recently_edited' );
@@ -294,7 +294,7 @@ function wp_reset_vars( $vars ) {
  *
  * @since 2.1.0
  *
  *
  * @since 2.1.0
  *
- * @param unknown_type $message
+ * @param string|WP_Error $message
  */
 function show_message($message) {
        if ( is_wp_error($message) ){
  */
 function show_message($message) {
        if ( is_wp_error($message) ){
@@ -621,7 +621,7 @@ function admin_color_scheme_picker( $user_id ) {
                        <div class="color-option <?php echo ( $color == $current_color ) ? 'selected' : ''; ?>">
                                <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 ); ?> />
                                <input type="hidden" class="css_url" value="<?php echo esc_url( $color_info->url ); ?>" />
                        <div class="color-option <?php echo ( $color == $current_color ) ? 'selected' : ''; ?>">
                                <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 ); ?> />
                                <input type="hidden" class="css_url" value="<?php echo esc_url( $color_info->url ); ?>" />
-                               <input type="hidden" class="icon_colors" value="<?php echo esc_attr( json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" />
+                               <input type="hidden" class="icon_colors" value="<?php echo esc_attr( wp_json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" />
                                <label for="admin_color_<?php echo esc_attr( $color ); ?>"><?php echo esc_html( $color_info->name ); ?></label>
                                <table class="color-palette">
                                        <tr>
                                <label for="admin_color_<?php echo esc_attr( $color ); ?>"><?php echo esc_html( $color_info->name ); ?></label>
                                <table class="color-palette">
                                        <tr>
@@ -662,10 +662,10 @@ function wp_color_scheme_settings() {
                $icon_colors = $_wp_admin_css_colors['fresh']->icon_colors;
        } else {
                // Fall back to the default set of icon colors if the default scheme is missing.
                $icon_colors = $_wp_admin_css_colors['fresh']->icon_colors;
        } else {
                // Fall back to the default set of icon colors if the default scheme is missing.
-               $icon_colors = array( 'base' => '#999', 'focus' => '#2ea2cc', 'current' => '#fff' );
+               $icon_colors = array( 'base' => '#999', 'focus' => '#00a0d2', 'current' => '#fff' );
        }
 
        }
 
-       echo '<script type="text/javascript">var _wpColorScheme = ' . json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";
+       echo '<script type="text/javascript">var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";
 }
 add_action( 'admin_head', 'wp_color_scheme_settings' );
 
 }
 add_action( 'admin_head', 'wp_color_scheme_settings' );
 
@@ -841,5 +841,49 @@ function post_form_autocomplete_off() {
                echo ' autocomplete="off"';
        }
 }
                echo ' autocomplete="off"';
        }
 }
-
 add_action( 'post_edit_form_tag', 'post_form_autocomplete_off' );
 add_action( 'post_edit_form_tag', 'post_form_autocomplete_off' );
+
+/**
+ * Remove single-use URL parameters and create canonical link based on new URL.
+ *
+ * Remove specific query string parameters from a URL, create the canonical link,
+ * put it in the admin header, and change the current URL to match.
+ *
+ * @since 4.2.0
+ */
+function wp_admin_canonical_url() {
+       $removable_query_args = array(
+               'message', 'settings-updated', 'saved',
+               'update', 'updated', 'activated',
+               'activate', 'deactivate', 'locked',
+               'deleted', 'trashed', 'untrashed',
+               'enabled', 'disabled', 'skipped',
+               'spammed', 'unspammed',
+       );
+
+       /**
+        * Filter the list of URL parameters to remove.
+        *
+        * @since 4.2.0
+        *
+        * @param array $removable_query_args An array of parameters to remove from the URL.
+        */
+       $removable_query_args = apply_filters( 'removable_query_args', $removable_query_args );
+
+       if ( empty( $removable_query_args ) ) {
+               return;
+       }
+
+       // Ensure we're using an absolute URL.
+       $current_url  = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
+       $filtered_url = remove_query_arg( $removable_query_args, $current_url );
+       ?>
+       <link id="wp-admin-canonical" rel="canonical" href="<?php echo esc_url( $filtered_url ); ?>" />
+       <script>
+               if ( window.history.replaceState ) {
+                       window.history.replaceState( null, null, document.getElementById( 'wp-admin-canonical' ).href + window.location.hash );
+               }
+       </script>
+<?php
+}
+add_action( 'admin_head', 'wp_admin_canonical_url' );