Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.1/wp-admin/admin-functions.php

    r5453 r5120  
    2323
    2424    // Check for autosave collisions
    25     $temp_id = false;
    2625    if ( isset($_POST['temp_ID']) ) {
    2726        $temp_id = (int) $_POST['temp_ID'];
     
    3534            $_POST['post_ID'] = $draft_ids[$temp_id];
    3635            unset($_POST['temp_ID']);
     36            relocate_children( $temp_id, $_POST['post_ID'] );
    3737            update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
    3838            return edit_post();
     
    113113
    114114    // Reunite any orphaned attachments with their parent
    115     if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
    116         $draft_ids = array();
    117     if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
    118         relocate_children( $draft_temp_id, $post_ID );
    119     if ( $temp_id && $temp_id != $draft_temp_id )
    120         relocate_children( $temp_id, $post_ID );
    121 
    122115    // Update autosave collision detection
    123116    if ( $temp_id ) {
     117        relocate_children( $temp_id, $post_ID );
    124118        $draft_ids[$temp_id] = $post_ID;
    125119        update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
     
    286280    add_meta( $post_ID );
    287281
    288     wp_update_post( $_POST );
    289 
    290     // Reunite any orphaned attachments with their parent
    291     if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
    292         $draft_ids = array();
    293     if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
    294         relocate_children( $draft_temp_id, $post_ID );
     282    wp_update_post( $_POST);
    295283
    296284    // Now that we have an ID we can fix any attachment anchor hrefs
     
    682670            // No selected categories, strange
    683671            $checked_categories[] = $default;
    684         }
     672        }   
    685673    } else {
    686674        $checked_categories[] = $default;
     
    706694function write_nested_categories( $categories ) {
    707695    foreach ( $categories as $category ) {
    708         echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : "" ), '/> ', wp_specialchars( apply_filters('the_category', $category['cat_name'] )), "</label></li>";
     696        echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : "" ), '/> ', wp_specialchars( $category['cat_name'] ), "</label></li>";
    709697
    710698        if ( $category['children'] ) {
     
    738726            // No selected categories, strange
    739727            $checked_categories[] = $default;
    740         }
     728        }   
    741729    } else {
    742730        $checked_categories[] = $default;
     
    769757        $categories = get_categories( 'hide_empty=0' );
    770758
    771     $children = _get_category_hierarchy();
    772 
    773759    if ( $categories ) {
    774760        ob_start();
     
    776762            if ( $category->category_parent == $parent) {
    777763                echo "\t" . _cat_row( $category, $level );
    778                 if ( isset($children[$category->cat_ID]) )
    779                     cat_rows( $category->cat_ID, $level +1, $categories );
     764                cat_rows( $category->cat_ID, $level +1, $categories );
    780765            }
    781766        }
    782767        $output = ob_get_contents();
    783768        ob_end_clean();
    784 
     769       
    785770        $output = apply_filters('cat_rows', $output);
    786771
     
    801786
    802787        if ( ($category->cat_ID != $default_cat_id ) && ($category->cat_ID != $default_link_cat_id ) )
    803             $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll posts that were only assigned to this category will be assigned to the '%s' category.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->cat_name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' )."</a>";
     788            $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll of its posts will go into the default category of '%s'\nAll of its bookmarks will go into the default category of '%s'.\n'OK' to delete, 'Cancel' to stop." ), $category->cat_name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' )."</a>";
    804789        else
    805790            $edit .= "<td style='text-align:center'>".__( "Default" );
     
    888873    $r .= "</td>\n\t</tr>";
    889874    return $r;
    890 }
    891 
    892 function _wp_get_comment_list( $s = false, $start, $num ) {
    893     global $wpdb;
    894 
    895     $start = (int) $start;
    896     $num = (int) $num;
    897 
    898     if ( $s ) {
    899         $s = $wpdb->escape($s);
    900         $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE
    901             (comment_author LIKE '%$s%' OR
    902             comment_author_email LIKE '%$s%' OR
    903             comment_author_url LIKE ('%$s%') OR
    904             comment_author_IP LIKE ('%$s%') OR
    905             comment_content LIKE ('%$s%') ) AND
    906             comment_approved != 'spam'
    907             ORDER BY comment_date DESC LIMIT $start, $num");
    908     } else {
    909         $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $num" );
    910     }
    911 
    912     $total = $wpdb->get_var( "SELECT FOUND_ROWS()" );
    913 
    914     return array($comments, $total);
    915 }
    916 
    917 function _wp_comment_list_item( $id, $alt = 0 ) {
    918     global $authordata, $comment, $wpdb;
    919     $id = (int) $id;
    920     $comment =& get_comment( $id );
    921     $class = '';
    922     $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
    923     $comment_status = wp_get_comment_status($comment->comment_ID);
    924     if ( 'unapproved' == $comment_status )
    925         $class .= ' unapproved';
    926     if ( $alt % 2 )
    927         $class .= ' alternate';
    928     echo "<li id='comment-$comment->comment_ID' class='$class'>";
    929 ?>
    930 <p><strong><?php comment_author(); ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
    931 
    932 <?php comment_text() ?>
    933 
    934 <p><?php comment_date(__('M j, g:i A'));  ?> &#8212; [
    935 <?php
    936 if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    937     echo " <a href='comment.php?action=editcomment&amp;c=".$comment->comment_ID."'>" .  __('Edit') . '</a>';
    938     echo ' | <a href="' . wp_nonce_url('ocomment.php?action=deletecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
    939     if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
    940         echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
    941         echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
    942     }
    943     echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;dt=spam&amp;p=" . $comment->comment_post_ID . "&amp;c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author))  . "', theCommentList );\">" . __('Spam') . "</a> ";
    944 }
    945 $post = get_post($comment->comment_post_ID);
    946 $post_title = wp_specialchars( $post->post_title, 'double' );
    947 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
    948 ?>
    949  ] &#8212; <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p>
    950         </li>
    951 <?php
    952875}
    953876
     
    12091132            $state = true;
    12101133            foreach ( $markerdata as $n => $markerline ) {
    1211                 if (strpos($markerline, '# BEGIN ' . $marker) !== false)
     1134                if ( strstr( $markerline, "# BEGIN {$marker}" ))
    12121135                    $state = false;
    12131136                if ( $state ) {
     
    12171140                        fwrite( $f, "{$markerline}" );
    12181141                }
    1219                 if (strpos($markerline, '# END ' . $marker) !== false) {
     1142                if ( strstr( $markerline, "# END {$marker}" ) ) {
    12201143                    fwrite( $f, "# BEGIN {$marker}\n" );
    12211144                    if ( is_array( $insertion ))
     
    12551178        $state = false;
    12561179        foreach ( $markerdata as $markerline ) {
    1257             if (strpos($markerline, '# END ' . $marker) !== false)
     1180            if ( strstr( $markerline, "# END {$marker}" ))
    12581181                $state = false;
    12591182            if ( $state )
    12601183                $result[] = $markerline;
    1261             if (strpos($markerline, '# BEGIN ' . $marker) !== false)
     1184            if ( strstr( $markerline, "# BEGIN {$marker}" ))
    12621185                $state = true;
    12631186        }
     
    13821305    if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )
    13831306        return false;
    1384 
     1307   
    13851308    if ( empty( $parent) ) {
    13861309        if ( isset( $_wp_menu_nopriv[$pagenow] ) )
     
    13941317                return false;
    13951318            if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) )
    1396             return false;
     1319            return false;   
    13971320        }
    13981321        return true;
     
    15161439                    $parent_file = $_wp_real_parent_file[$parent_file];
    15171440            return $parent_file;
    1518         }
     1441        }           
    15191442    }
    15201443
     
    15231446        if ( isset( $_wp_real_parent_file[$parent_file] ) )
    15241447            $parent_file = $_wp_real_parent_file[$parent_file];
    1525         return $parent_file;
     1448        return $parent_file;       
    15261449    }
    15271450
     
    17371660    }
    17381661
    1739     return array('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version);
     1662    return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1] );
    17401663}
    17411664
     
    17541677    if ( $plugins_dir ) {
    17551678        while (($file = $plugins_dir->read() ) !== false ) {
    1756             if ( substr($file, 0, 1) == '.' )
     1679            if ( preg_match( '|^\.+$|', $file ))
    17571680                continue;
    17581681            if ( is_dir( $plugin_root.'/'.$file ) ) {
     
    17601683                if ( $plugins_subdir ) {
    17611684                    while (($subfile = $plugins_subdir->read() ) !== false ) {
    1762                         if ( substr($subfile, 0, 1) == '.' )
     1685                        if ( preg_match( '|^\.+$|', $subfile ))
    17631686                            continue;
    1764                         if ( substr($subfile, -4) == '.php' )
     1687                        if ( preg_match( '|\.php$|', $subfile ))
    17651688                            $plugin_files[] = "$file/$subfile";
    17661689                    }
    17671690                }
    17681691            } else {
    1769                 if ( substr($file, -4) == '.php' )
     1692                if ( preg_match( '|\.php$|', $file ))
    17701693                    $plugin_files[] = $file;
    17711694            }
     
    18321755        ';
    18331756}
    1834 
    1835 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)
     1757if ( strstr( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ))
    18361758    add_action( 'admin_footer', 'browse_happy' );
    18371759
     
    18481770function get_importers() {
    18491771    global $wp_importers;
    1850     uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));
     1772
    18511773    return $wp_importers;
    18521774}
     
    19721894    // Compute the URL
    19731895    $url = $uploads['url'] . "/$filename";
    1974 
     1896   
    19751897    $return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) );
    19761898
     
    19941916    $size = strtolower( ini_get( 'upload_max_filesize' ) );
    19951917    $bytes = 0;
    1996     if (strpos($size, 'k') !== false)
     1918    if ( strstr( $size, 'k' ) )
    19971919        $bytes = $size * 1024;
    1998     if (strpos($size, 'm') !== false)
     1920    if ( strstr( $size, 'm' ) )
    19991921        $bytes = $size * 1024 * 1024;
    2000     if (strpos($size, 'g') !== false)
     1922    if ( strstr( $size, 'g' ) )
    20011923        $bytes = $size * 1024 * 1024 * 1024;
    20021924?>
    20031925<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>">
    20041926<p>
    2005 <?php wp_nonce_field('import-upload'); ?>
    20061927<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?> )
    20071928<input type="file" id="upload" name="import" size="25" />
     
    21322053    wp_clearcookie();
    21332054    // Set cookies for new paths.
    2134     wp_setcookie( $user_login, $user_pass_md5, true, get_option( 'home' ), get_option( 'siteurl' ));
     2055    wp_setcookie( $user_login, $user_pass_md5, true, get_option( 'home' ), get_option( 'siteurl' ));   
    21352056}
    21362057
     
    21542075    }
    21552076
    2156     if (function_exists('imageantialias'))
    2157         imageantialias( $dst, true );
    2158    
     2077    imageantialias( $dst, true );
    21592078    imagecopyresampled( $dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h );
    21602079
     
    22762195            // If no filters change the filename, we'll do a default transformation.
    22772196            if ( basename( $file ) == $thumb = apply_filters( 'thumbnail_filename', basename( $file ) ) )
    2278                 $thumb = preg_replace( '!(\.[^.]+)?$!', '.thumbnail' . '$1', basename( $file ), 1 );
     2197                $thumb = preg_replace( '!(\.[^.]+)?$!', __( '.thumbnail' ).'$1', basename( $file ), 1 );
    22792198
    22802199            $thumbpath = str_replace( basename( $file ), $thumb, $file );
Note: See TracChangeset for help on using the changeset viewer.