]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/formatting.php
Wordpress 3.7
[autoinstalls/wordpress.git] / wp-includes / formatting.php
index aef2b6378caf83ca27b3482818ce406e782bc54f..904c99b17b71288d8ce3736af5036736c4232a31 100644 (file)
@@ -1483,25 +1483,26 @@ function rawurlencode_deep( $value ) {
  *
  * @since 0.71
  *
- * @param string $emailaddy Email address.
- * @param int $mailto Optional. Range from 0 to 1. Used for encoding.
+ * @param string $email_address Email address.
+ * @param int $hex_encoding Optional. Set to 1 to enable hex encoding.
  * @return string Converted email address.
  */
-function antispambot($emailaddy, $mailto=0) {
-       $emailNOSPAMaddy = '';
-       srand ((float) microtime() * 1000000);
-       for ($i = 0; $i < strlen($emailaddy); $i = $i + 1) {
-               $j = floor(rand(0, 1+$mailto));
-               if ($j==0) {
-                       $emailNOSPAMaddy .= '&#'.ord(substr($emailaddy,$i,1)).';';
-               } elseif ($j==1) {
-                       $emailNOSPAMaddy .= substr($emailaddy,$i,1);
-               } elseif ($j==2) {
-                       $emailNOSPAMaddy .= '%'.zeroise(dechex(ord(substr($emailaddy, $i, 1))), 2);
+function antispambot( $email_address, $hex_encoding = 0 ) {
+       $email_no_spam_address = '';
+       for ( $i = 0; $i < strlen( $email_address ); $i++ ) {
+               $j = rand( 0, 1 + $hex_encoding );
+               if ( $j == 0 ) {
+                       $email_no_spam_address .= '&#' . ord( $email_address[$i] ) . ';';
+               } elseif ( $j == 1 ) {
+                       $email_no_spam_address .= $email_address[$i];
+               } elseif ( $j == 2 ) {
+                       $email_no_spam_address .= '%' . zeroise( dechex( ord( $email_address[$i] ) ), 2 );
                }
        }
-       $emailNOSPAMaddy = str_replace('@','&#64;',$emailNOSPAMaddy);
-       return $emailNOSPAMaddy;
+
+       $email_no_spam_address = str_replace( '@', '&#64;', $email_no_spam_address );
+
+       return $email_no_spam_address;
 }
 
 /**
@@ -1743,29 +1744,29 @@ function wp_rel_nofollow_callback( $matches ) {
 /**
  * Convert one smiley code to the icon graphic file equivalent.
  *
+ * Callback handler for {@link convert_smilies()}.
  * Looks up one smiley code in the $wpsmiliestrans global array and returns an
  * <img> string for that smiley.
  *
  * @global array $wpsmiliestrans
  * @since 2.8.0
  *
- * @param string $smiley Smiley code to convert to image.
+ * @param array $matches Single match. Smiley code to convert to image.
  * @return string Image string for smiley.
  */
-function translate_smiley($smiley) {
+function translate_smiley( $matches ) {
        global $wpsmiliestrans;
 
-       if (count($smiley) == 0) {
+       if ( count( $matches ) == 0 )
                return '';
-       }
 
-       $smiley = trim(reset($smiley));
-       $img = $wpsmiliestrans[$smiley];
-       $smiley_masked = esc_attr($smiley);
+       $smiley = trim( reset( $matches ) );
+       $img = $wpsmiliestrans[ $smiley ];
+       $smiley_masked = esc_attr( $smiley );
 
-       $srcurl = apply_filters('smilies_src', includes_url("images/smilies/$img"), $img, site_url());
+       $src_url = apply_filters( 'smilies_src', includes_url( "images/smilies/$img" ), $img, site_url() );
 
-       return " <img src='$srcurl' alt='$smiley_masked' class='wp-smiley' /> ";
+       return " <img src='$src_url' alt='$smiley_masked' class='wp-smiley' /> ";
 }
 
 /**
@@ -2570,21 +2571,16 @@ function wp_htmledit_pre($output) {
  * @since 2.8.1
  * @access private
  *
- * @param string|array $search
- * @param string $subject
- * @return string The processed string
+ * @param string|array $search The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
+ * @param string $subject The string being searched and replaced on, otherwise known as the haystack.
+ * @return string The string with the replaced svalues.
  */
 function _deep_replace( $search, $subject ) {
-       $found = true;
        $subject = (string) $subject;
-       while ( $found ) {
-               $found = false;
-               foreach ( (array) $search as $val ) {
-                       while ( strpos( $subject, $val ) !== false ) {
-                               $found = true;
-                               $subject = str_replace( $val, '', $subject );
-                       }
-               }
+
+       $count = 1;
+       while ( $count ) {
+               $subject = str_replace( $search, '', $subject, $count );
        }
 
        return $subject;
@@ -2598,8 +2594,8 @@ function _deep_replace( $search, $subject ) {
  * is preparing an array for use in an IN clause.
  *
  * @since 2.8.0
- * @param string $data Unescaped data
- * @return string Escaped data
+ * @param string|array $data Unescaped data
+ * @return string|array Escaped data
  */
 function esc_sql( $data ) {
        global $wpdb;
@@ -2961,6 +2957,11 @@ function sanitize_option($option, $value) {
                        $value = esc_url_raw( $value );
                        $value = str_replace( 'http://', '', $value );
                        break;
+
+               case 'default_role' :
+                       if ( ! get_role( $value ) && get_role( 'subscriber' ) )
+                               $value = 'subscriber';
+                       break;
        }
 
        $value = apply_filters("sanitize_option_{$option}", $value, $option);