Changes from tags/2.1.3 at r5468 to tags/2.2 at r5480
- Location:
- tags
- Files:
-
- 29 added
- 8 deleted
- 163 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/2.2/readme.html
r5468 r5480 9 9 <h1 id="logo" style="text-align: center"> 10 10 <img alt="WordPress" src="wp-admin/images/wordpress-logo.png" /> 11 <br /> Version 2. 111 <br /> Version 2.2 12 12 </h1> 13 13 <p style="text-align: center">Semantic Personal Publishing Platform</p> … … 30 30 <h1>Upgrading</h1> 31 31 <p>Before you upgrade anything, make sure you have backup copies of any files you may have modified such as <code>index.php</code>.</p> 32 <h2>Upgrading from any previous WordPress to 2. 1:</h2>32 <h2>Upgrading from any previous WordPress to 2.2:</h2> 33 33 <ol> 34 34 <li>Delete your old WP files, saving ones you've modified.</li> … … 52 52 <dd>If you've looked everywhere and still can't find an answer, the support forums are very active and have a large community ready to help. To help them help you be sure to use a descriptive thread title and describe your question in as much detail as possible.</dd> 53 53 <dt><a href="http://codex.wordpress.org/IRC">WordPress IRC Channel</a></dt> 54 <dd>Finally, there is an online chat channel that is used for discussion among people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. ( irc.freenode.net #wordpress)</dd>54 <dd>Finally, there is an online chat channel that is used for discussion among people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. (<a href="irc://irc.freenode.net/wordpress">irc.freenode.net #wordpress</a>)</dd> 55 55 </dl> 56 56 57 57 <h1>System Recommendations</h1> 58 58 <ul> 59 <li>PHP version <strong>4. 1</strong> or higher.</li>59 <li>PHP version <strong>4.2</strong> or higher.</li> 60 60 <li>MySQL version <strong>4.0</strong> or higher.</li> 61 61 <li>... and a link to <a href="http://wordpress.org/">http://wordpress.org</a> on your site.</li> … … 64 64 65 65 <h1>Upgrading from another system</h1> 66 <p>WordPress can <a href="http://codex.wordpress.org/Importing_ from_other_blogging_software">import from a number of systems</a>. First you need to get WordPress installed and working as described above.</p>66 <p>WordPress can <a href="http://codex.wordpress.org/Importing_Content">import from a number of systems</a>. First you need to get WordPress installed and working as described above.</p> 67 67 68 <h1>XML-RPC Interface</h1>69 <p>You can now post to your WordPress blog with tools like <a href="http:// ecto.kung-foo.tv/">Ecto</a>, <a href="http://blogbuddy.sourceforge.net">BlogBuddy</a>, <a href="http://bloggar.com/">Bloggar</a>, <a href="http://www.ubique.ch/wapblogger/">WapBlogger</a> (post from your Wap cellphone!), <a href="http://radio.userland.com">Radio Userland</a> (which means you can use Radio's email-to-blog feature), <a href="http://www.zempt.com/">Zempt</a>, <a href="http://www.newzcrawler.com/">NewzCrawler</a>, and other tools that support the Blogging APIs! :) You can read more about <a href="http://codex.wordpress.org/XML-RPC_Support">XML-RPC support on the Codex</a>.</p>68 <h1>XML-RPC and Atom Interface</h1> 69 <p>You can now post to your WordPress blog with tools like <a href="http://windowslivewriter.spaces.live.com/">Windows Live Writer</a>, <a href="http://ecto.kung-foo.tv/">Ecto</a>, <a href="http://bloggar.com/">Bloggar</a>, <a href="http://radio.userland.com">Radio Userland</a> (which means you can use Radio's email-to-blog feature), <a href="http://www.newzcrawler.com/">NewzCrawler</a>, and other tools that support the Blogging APIs! :) You can read more about <a href="http://codex.wordpress.org/XML-RPC_Support">XML-RPC support on the Codex</a>.</p> 70 70 71 71 <h1>Post via Email</h1> -
tags/2.2/wp-admin/admin-ajax.php
r5468 r5480 152 152 $x->send(); 153 153 break; 154 case 'add-comment' : 155 if ( !current_user_can( 'edit_post', $id ) ) 156 die('-1'); 157 $search = isset($_POST['s']) ? $_POST['s'] : false; 158 $start = isset($_POST['page']) ? intval($_POST['page']) * 25 : 25; 159 160 list($comments, $total) = _wp_get_comment_list( $search, $start, 1 ); 161 162 if ( !$comments ) 163 die('1'); 164 $x = new WP_Ajax_Response(); 165 foreach ( (array) $comments as $comment ) { 166 get_comment( $comment ); 167 ob_start(); 168 _wp_comment_list_item( $comment->comment_ID ); 169 $comment_list_item = ob_get_contents(); 170 ob_end_clean(); 171 $x->add( array( 172 'what' => 'comment', 173 'id' => $comment->comment_ID, 174 'data' => $comment_list_item 175 ) ); 176 } 177 $x->send(); 178 break; 154 179 case 'add-meta' : 155 180 if ( !current_user_can( 'edit_post', $id ) ) … … 227 252 $_POST['post_category'] = explode(",", $_POST['catslist']); 228 253 if($_POST['post_type'] == 'page' || empty($_POST['post_category'])) 229 unset($_POST['post_category']); 230 254 unset($_POST['post_category']); 255 231 256 if($_POST['post_ID'] < 0) { 232 257 $_POST['temp_ID'] = $_POST['post_ID']; -
tags/2.2/wp-admin/admin-db.php
r5468 r5480 149 149 clean_category_cache($cat_ID); 150 150 151 if ($update) 152 do_action('edited_category', $cat_ID); 153 else 154 do_action('created_category', $cat_ID); 155 151 156 return $cat_ID; 152 157 } … … 416 421 $wpdb->query("DELETE FROM $wpdb->link2cat WHERE link_id = '$link_id'"); 417 422 return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'"); 423 424 do_action('deleted_link', $link_id); 418 425 } 419 426 -
tags/2.2/wp-admin/admin-functions.php
r5468 r5480 23 23 24 24 // Check for autosave collisions 25 $temp_id = false; 25 26 if ( isset($_POST['temp_ID']) ) { 26 27 $temp_id = (int) $_POST['temp_ID']; … … 34 35 $_POST['post_ID'] = $draft_ids[$temp_id]; 35 36 unset($_POST['temp_ID']); 36 relocate_children( $temp_id, $_POST['post_ID'] );37 37 update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids ); 38 38 return edit_post(); … … 113 113 114 114 // 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 115 122 // Update autosave collision detection 116 123 if ( $temp_id ) { 117 relocate_children( $temp_id, $post_ID );118 124 $draft_ids[$temp_id] = $post_ID; 119 125 update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids ); … … 280 286 add_meta( $post_ID ); 281 287 282 wp_update_post( $_POST); 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 ); 283 295 284 296 // Now that we have an ID we can fix any attachment anchor hrefs … … 670 682 // No selected categories, strange 671 683 $checked_categories[] = $default; 672 } 684 } 673 685 } else { 674 686 $checked_categories[] = $default; … … 694 706 function write_nested_categories( $categories ) { 695 707 foreach ( $categories as $category ) { 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>";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>"; 697 709 698 710 if ( $category['children'] ) { … … 726 738 // No selected categories, strange 727 739 $checked_categories[] = $default; 728 } 740 } 729 741 } else { 730 742 $checked_categories[] = $default; … … 757 769 $categories = get_categories( 'hide_empty=0' ); 758 770 771 $children = _get_category_hierarchy(); 772 759 773 if ( $categories ) { 760 774 ob_start(); … … 762 776 if ( $category->category_parent == $parent) { 763 777 echo "\t" . _cat_row( $category, $level ); 764 cat_rows( $category->cat_ID, $level +1, $categories ); 778 if ( isset($children[$category->cat_ID]) ) 779 cat_rows( $category->cat_ID, $level +1, $categories ); 765 780 } 766 781 } 767 782 $output = ob_get_contents(); 768 783 ob_end_clean(); 769 784 770 785 $output = apply_filters('cat_rows', $output); 771 786 … … 786 801 787 802 if ( ($category->cat_ID != $default_cat_id ) && ($category->cat_ID != $default_link_cat_id ) ) 788 $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&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>";803 $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&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>"; 789 804 else 790 805 $edit .= "<td style='text-align:center'>".__( "Default" ); … … 873 888 $r .= "</td>\n\t</tr>"; 874 889 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')); ?> — [ 935 <?php 936 if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 937 echo " <a href='comment.php?action=editcomment&c=".$comment->comment_ID."'>" . __('Edit') . '</a>'; 938 echo ' | <a href="' . wp_nonce_url('ocomment.php?action=deletecomment&p=' . $comment->comment_post_ID . '&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&p=' . $comment->comment_post_ID . '&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&p=' . $comment->comment_post_ID . '&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&dt=spam&p=" . $comment->comment_post_ID . "&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 ] — <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p> 950 </li> 951 <?php 875 952 } 876 953 … … 1132 1209 $state = true; 1133 1210 foreach ( $markerdata as $n => $markerline ) { 1134 if ( strstr( $markerline, "# BEGIN {$marker}" ))1211 if (strpos($markerline, '# BEGIN ' . $marker) !== false) 1135 1212 $state = false; 1136 1213 if ( $state ) { … … 1140 1217 fwrite( $f, "{$markerline}" ); 1141 1218 } 1142 if ( strstr( $markerline, "# END {$marker}" )) {1219 if (strpos($markerline, '# END ' . $marker) !== false) { 1143 1220 fwrite( $f, "# BEGIN {$marker}\n" ); 1144 1221 if ( is_array( $insertion )) … … 1178 1255 $state = false; 1179 1256 foreach ( $markerdata as $markerline ) { 1180 if ( strstr( $markerline, "# END {$marker}" ))1257 if (strpos($markerline, '# END ' . $marker) !== false) 1181 1258 $state = false; 1182 1259 if ( $state ) 1183 1260 $result[] = $markerline; 1184 if ( strstr( $markerline, "# BEGIN {$marker}" ))1261 if (strpos($markerline, '# BEGIN ' . $marker) !== false) 1185 1262 $state = true; 1186 1263 } … … 1305 1382 if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) ) 1306 1383 return false; 1307 1384 1308 1385 if ( empty( $parent) ) { 1309 1386 if ( isset( $_wp_menu_nopriv[$pagenow] ) ) … … 1317 1394 return false; 1318 1395 if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) ) 1319 return false; 1396 return false; 1320 1397 } 1321 1398 return true; … … 1439 1516 $parent_file = $_wp_real_parent_file[$parent_file]; 1440 1517 return $parent_file; 1441 } 1518 } 1442 1519 } 1443 1520 … … 1446 1523 if ( isset( $_wp_real_parent_file[$parent_file] ) ) 1447 1524 $parent_file = $_wp_real_parent_file[$parent_file]; 1448 return $parent_file; 1525 return $parent_file; 1449 1526 } 1450 1527 … … 1660 1737 } 1661 1738 1662 return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1]);1739 return array('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version); 1663 1740 } 1664 1741 … … 1677 1754 if ( $plugins_dir ) { 1678 1755 while (($file = $plugins_dir->read() ) !== false ) { 1679 if ( preg_match( '|^\.+$|', $file ))1756 if ( substr($file, 0, 1) == '.' ) 1680 1757 continue; 1681 1758 if ( is_dir( $plugin_root.'/'.$file ) ) { … … 1683 1760 if ( $plugins_subdir ) { 1684 1761 while (($subfile = $plugins_subdir->read() ) !== false ) { 1685 if ( preg_match( '|^\.+$|', $subfile ))1762 if ( substr($subfile, 0, 1) == '.' ) 1686 1763 continue; 1687 if ( preg_match( '|\.php$|', $subfile ))1764 if ( substr($subfile, -4) == '.php' ) 1688 1765 $plugin_files[] = "$file/$subfile"; 1689 1766 } 1690 1767 } 1691 1768 } else { 1692 if ( preg_match( '|\.php$|', $file ))1769 if ( substr($file, -4) == '.php' ) 1693 1770 $plugin_files[] = $file; 1694 1771 } … … 1755 1832 '; 1756 1833 } 1757 if ( strstr( $_SERVER['HTTP_USER_AGENT'], 'MSIE' )) 1834 1835 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) 1758 1836 add_action( 'admin_footer', 'browse_happy' ); 1759 1837 … … 1770 1848 function get_importers() { 1771 1849 global $wp_importers; 1772 1850 uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);')); 1773 1851 return $wp_importers; 1774 1852 } … … 1894 1972 // Compute the URL 1895 1973 $url = $uploads['url'] . "/$filename"; 1896 1974 1897 1975 $return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) ); 1898 1976 … … 1916 1994 $size = strtolower( ini_get( 'upload_max_filesize' ) ); 1917 1995 $bytes = 0; 1918 if ( strstr( $size, 'k' ))1996 if (strpos($size, 'k') !== false) 1919 1997 $bytes = $size * 1024; 1920 if ( strstr( $size, 'm' ))1998 if (strpos($size, 'm') !== false) 1921 1999 $bytes = $size * 1024 * 1024; 1922 if ( strstr( $size, 'g' ))2000 if (strpos($size, 'g') !== false) 1923 2001 $bytes = $size * 1024 * 1024 * 1024; 1924 2002 ?> 1925 2003 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>"> 1926 2004 <p> 2005 <?php wp_nonce_field('import-upload'); ?> 1927 2006 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?> ) 1928 2007 <input type="file" id="upload" name="import" size="25" /> … … 2053 2132 wp_clearcookie(); 2054 2133 // Set cookies for new paths. 2055 wp_setcookie( $user_login, $user_pass_md5, true, get_option( 'home' ), get_option( 'siteurl' )); 2134 wp_setcookie( $user_login, $user_pass_md5, true, get_option( 'home' ), get_option( 'siteurl' )); 2056 2135 } 2057 2136 … … 2075 2154 } 2076 2155 2077 imageantialias( $dst, true ); 2156 if (function_exists('imageantialias')) 2157 imageantialias( $dst, true ); 2158 2078 2159 imagecopyresampled( $dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); 2079 2160 … … 2195 2276 // If no filters change the filename, we'll do a default transformation. 2196 2277 if ( basename( $file ) == $thumb = apply_filters( 'thumbnail_filename', basename( $file ) ) ) 2197 $thumb = preg_replace( '!(\.[^.]+)?$!', __( '.thumbnail' ).'$1', basename( $file ), 1 );2278 $thumb = preg_replace( '!(\.[^.]+)?$!', '.thumbnail' . '$1', basename( $file ), 1 ); 2198 2279 2199 2280 $thumbpath = str_replace( basename( $file ), $thumb, $file ); -
tags/2.2/wp-admin/admin-header.php
r5468 r5480 14 14 ?> 15 15 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 16 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>16 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> 17 17 <head> 18 18 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> … … 45 45 <body> 46 46 <div id="wphead"> 47 <h1><?php echo wptexturize(get_option(('blogname'))); ?> <span>(<a href="<?php echo get_option('home') . '/'; ?>"><?php _e('View site »') ?></a>)</span></h1>47 <h1><?php bloginfo('name'); ?> <span>(<a href="<?php echo get_option('home') . '/'; ?>"><?php _e('View site »') ?></a>)</span></h1> 48 48 </div> 49 49 <div id="user_info"><p><?php printf(__('Howdy, <strong>%s</strong>.'), $user_identity) ?> [<a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php _e('Sign Out'); ?></a>, <a href="profile.php"><?php _e('My Profile'); ?></a>] </p></div> -
tags/2.2/wp-admin/admin.php
r5468 r5480 5 5 require_once('../wp-config.php'); 6 6 7 if ( get_option('db_version') != $wp_db_version ) 8 wp_die(sprintf(__("Your database is out-of-date. Please <a href='%s'>upgrade</a>."), get_option('siteurl') . '/wp-admin/upgrade.php')); 9 7 if ( get_option('db_version') != $wp_db_version ) { 8 wp_redirect(get_option('siteurl') . '/wp-admin/upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI']))); 9 exit; 10 } 11 10 12 require_once(ABSPATH . 'wp-admin/admin-functions.php'); 11 13 require_once(ABSPATH . 'wp-admin/admin-db.php'); -
tags/2.2/wp-admin/categories.js
r5468 r5480 3 3 document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); }; 4 4 theList.addComplete = function(what, where, update, transport) { 5 var name = getNodeValue(transport.responseXML, 'name') ;5 var name = getNodeValue(transport.responseXML, 'name').unescapeHTML(); 6 6 var id = transport.responseXML.getElementsByTagName(what)[0].getAttribute('id'); 7 7 var options = document.forms['addcat'].category_parent.options; -
tags/2.2/wp-admin/categories.php
r5468 r5480 115 115 <?php if ( current_user_can('manage_categories') ) : ?> 116 116 <div class="wrap"> 117 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and links in that category. Instead, posts in the deleted category are set to the category <strong>%s</strong> and links are set to <strong>%s</strong>.'), get_catname(get_option('default_category')), get_catname(get_option('default_link_category'))) ?></p>117 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and links in that category. Instead, posts that were only assigned to the deleted category are set to the category <strong>%s</strong> and links that were only assigned to the deleted category are set to <strong>%s</strong>.'), apply_filters('the_category', get_catname(get_option('default_category'))), apply_filters('the_category', get_catname(get_option('default_link_category')))) ?></p> 118 118 </div> 119 119 -
tags/2.2/wp-admin/custom-header.php
-
Property
svn:eol-style
set to
native
r5468 r5480 18 18 function js_includes() { 19 19 wp_enqueue_script('cropper'); 20 wp_enqueue_script('colorpicker'); 20 wp_enqueue_script('colorpicker'); 21 21 } 22 22 … … 24 24 25 25 if ( isset( $_POST['textcolor'] ) ) { 26 check_admin_referer('custom-header'); 26 27 if ( 'blank' == $_POST['textcolor'] ) { 27 28 set_theme_mod('header_textcolor', 'blank'); … … 32 33 } 33 34 } 34 if ( isset($_POST['resetheader']) ) 35 if ( isset($_POST['resetheader']) ) { 36 check_admin_referer('custom-header'); 35 37 remove_theme_mods(); 38 } 36 39 ?> 37 40 <script type="text/javascript"> … … 116 119 pickColor('<?php echo HEADER_TEXTCOLOR; ?>'); 117 120 } 118 121 119 122 function hide_text() { 120 123 $('name').style.display = 'none'; … … 127 130 Event.observe( $('hidetext'), 'click', show_text ); 128 131 } 129 132 130 133 function show_text() { 131 134 $('name').style.display = 'block'; … … 135 138 $('textcolor').value = '<?php echo HEADER_TEXTCOLOR; ?>'; 136 139 $('hidetext').value = '<?php _e('Hide Text'); ?>'; 137 Event.stopObserving( $('hidetext'), 'click', show_text ); 140 Event.stopObserving( $('hidetext'), 'click', show_text ); 138 141 Event.observe( $('hidetext'), 'click', hide_text ); 139 142 } … … 158 161 <p><?php _e('This is your header image. You can change the text color or upload and crop a new image.'); ?></p> 159 162 160 <div id="headimg" style="background: url(<?php header_image() ?>) no-repeat;">163 <div id="headimg" style="background: url(<?php clean_url(header_image()) ?>) no-repeat;"> 161 164 <h1><a onclick="return false;" href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>" id="name"><?php bloginfo('name'); ?></a></h1> 162 165 <div id="desc"><?php bloginfo('description');?></div> … … 166 169 <input type="button" value="<?php _e('Hide Text'); ?>" onclick="hide_text()" id="hidetext" /> 167 170 <input type="button" value="<?php _e('Select a Text Color'); ?>" onclick="colorSelect($('textcolor'), 'pickcolor')" id="pickcolor" /><input type="button" value="<?php _e('Use Original Color'); ?>" onclick="colorDefault()" id="defaultcolor" /> 168 <input type="hidden" name="textcolor" id="textcolor" value="#<?php header_textcolor() ?>" /><input name="submit" type="submit" value="<?php _e('Save Changes'); ?> »" /></form> 171 <?php wp_nonce_field('custom-header') ?> 172 <input type="hidden" name="textcolor" id="textcolor" value="#<?php attribute_escape(header_textcolor()) ?>" /><input name="submit" type="submit" value="<?php _e('Save Changes'); ?> »" /></form> 169 173 <?php } ?> 170 174 … … 178 182 <label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /><input type="file" id="upload" name="import" /> 179 183 <input type="hidden" name="action" value="save" /> 184 <?php wp_nonce_field('custom-header') ?> 180 185 <p class="submit"> 181 186 <input type="submit" value="<?php _e('Upload'); ?> »" /> … … 190 195 <p><?php _e('This will restore the original header image and color. You will not be able to retrieve any customizations.') ?></p> 191 196 <form method="post" action="<?php echo attribute_escape(add_query_arg('step', 1)) ?>"> 197 <?php wp_nonce_field('custom-header'); ?> 192 198 <input type="submit" name="resetheader" value="<?php _e('Restore Original Header'); ?>" /> 193 199 </form> … … 198 204 199 205 function step_2() { 206 check_admin_referer('custom-header'); 200 207 $overrides = array('test_form' => false); 201 208 $file = wp_handle_upload($_FILES['import'], $overrides); … … 223 230 224 231 if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) { 225 set_theme_mod('header_image', $url);232 set_theme_mod('header_image', clean_url($url)); 226 233 $header = apply_filters('wp_create_file_in_uploads', $file, $id); // For replication 227 234 return $this->finished(); … … 257 264 <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo $id; ?>" /> 258 265 <input type="hidden" name="oitar" id="oitar" value="<?php echo $oitar; ?>" /> 266 <?php wp_nonce_field('custom-header') ?> 259 267 <input type="submit" value="<?php _e('Crop Header »'); ?>" /> 260 268 </p> … … 266 274 267 275 function step_3() { 276 check_admin_referer('custom-header'); 268 277 if ( $_POST['oitar'] > 1 ) { 269 278 $_POST['x1'] = $_POST['x1'] * $_POST['oitar']; -
Property
svn:eol-style
set to
-
tags/2.2/wp-admin/edit-category-form.php
r5468 r5480 36 36 <th scope="row" valign="top"><label for="category_parent"><?php _e('Category parent:') ?></label></th> 37 37 <td> 38 <?php wp_dropdown_categories('hide_empty=0&name=category_parent& selected=' . $category->category_parent . '&hierarchical=1&show_option_none=' . __('None')); ?>38 <?php wp_dropdown_categories('hide_empty=0&name=category_parent&orderby=name&selected=' . $category->category_parent . '&hierarchical=1&show_option_none=' . __('None')); ?> 39 39 </td> 40 40 </tr> -
tags/2.2/wp-admin/edit-comments.js
r5468 r5480 3 3 if ( !theCommentList ) 4 4 return false; 5 6 theExtraCommentList = new listMan('the-extra-comment-list'); 7 if ( theExtraCommentList ) { 8 theExtraCommentList.showLink = 0; 9 theExtraCommentList.altOffset = 1; 10 if ( theExtraCommentList.theList && theExtraCommentList.theList.childNodes ) 11 var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length; 12 else 13 var commentNum = 0; 14 var urlQ = document.location.href.split('?'); 15 var params = urlQ[1] ? urlQ[1].toQueryParams() : []; 16 var search = params['s'] ? params['s'] : ''; 17 var page = params['apage'] ? params['apage'] : 1; 18 } 19 5 20 theCommentList.dimComplete = function(what,id,dimClass) { 6 21 var m = document.getElementById('awaitmod'); 7 if ( document.getElementById(what + '-' + id).className.match(dimClass) ) m.innerHTML = parseInt(m.innerHTML,10) + 1; 8 else m.innerHTML = parseInt(m.innerHTML,10) - 1; 22 if ( document.getElementById(what + '-' + id).className.match(dimClass) ) 23 m.innerHTML = parseInt(m.innerHTML,10) + 1; 24 else 25 m.innerHTML = parseInt(m.innerHTML,10) - 1; 9 26 } 27 10 28 theCommentList.delComplete = function(what,id) { 11 29 var m = document.getElementById('awaitmod'); 12 if ( document.getElementById(what + '-' + id).className.match('unapproved') ) m.innerHTML = parseInt(m.innerHTML,10) - 1; 30 what = what.split('-')[0]; 31 if ( document.getElementById(what + '-' + id).className.match('unapproved') ) 32 m.innerHTML = parseInt(m.innerHTML,10) - 1; 33 if ( theExtraCommentList && commentNum ) { 34 var theMover = theExtraCommentList.theList.childNodes[0]; 35 Element.removeClassName(theMover,'alternate'); 36 theCommentList.theList.appendChild(theMover); 37 theExtraCommentList.inputData += '&page=' + page; 38 if ( search ) 39 theExtraCommentList.inputData += '&s=' + search; // trust the URL not the search box 40 theExtraCommentList.addComplete = function() { 41 if ( theExtraCommentList.theList.childNodes ) 42 var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length; 43 else 44 var commentNum = 0; 45 } 46 theExtraCommentList.ajaxAdder( 'comment', 'ajax-response' ); // Dummy Request 47 } 13 48 } 49 14 50 if ( theList ) // the post list: edit.php 15 51 theList.delComplete = function() { -
tags/2.2/wp-admin/edit-comments.php
r5468 r5480 76 76 endif; 77 77 78 if (isset($_GET['s'])) { 79 $s = $wpdb->escape($_GET['s']); 80 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE 81 (comment_author LIKE '%$s%' OR 82 comment_author_email LIKE '%$s%' OR 83 comment_author_url LIKE ('%$s%') OR 84 comment_author_IP LIKE ('%$s%') OR 85 comment_content LIKE ('%$s%') ) AND 86 comment_approved != 'spam' 87 ORDER BY comment_date DESC"); 88 } else { 89 if ( isset( $_GET['apage'] ) ) 90 $page = (int) $_GET['apage']; 91 else 92 $page = 1; 93 $start = $offset = ( $page - 1 ) * 20; 94 95 $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, 20" ); 96 $total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1'" ); 97 } 98 ?> 99 <?php if ( $total > 20 ) { 100 $total_pages = ceil( $total / 20 ); 101 $r = ''; 102 if ( 1 < $page ) { 103 $args['apage'] = ( 1 == $page - 1 ) ? FALSE : $page - 1; 104 $r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">« '. __('Previous Page') .'</a>' . "\n"; 105 } 106 if ( ( $total_pages = ceil( $total / 20 ) ) > 1 ) { 107 for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) : 108 if ( $page == $page_num ) : 109 $r .= "<span>$page_num</span>\n"; 110 else : 111 $p = false; 112 if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) : 113 $args['apage'] = ( 1 == $page_num ) ? FALSE : $page_num; 114 $r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n"; 115 $in = true; 116 elseif ( $in == true ) : 117 $r .= "...\n"; 118 $in = false; 119 endif; 120 endif; 121 endfor; 122 } 123 if ( ( $page ) * 20 < $total || -1 == $total ) { 124 $args['apage'] = $page + 1; 125 $r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page') .' »</a>' . "\n"; 126 } 127 echo "<p class='pagenav'>$r</p>"; 128 ?> 129 130 <?php } ?> 131 132 <?php 78 if ( isset( $_GET['apage'] ) ) 79 $page = (int) $_GET['apage']; 80 else 81 $page = 1; 82 $start = $offset = ( $page - 1 ) * 20; 83 84 list($_comments, $total) = _wp_get_comment_list( isset($_GET['s']) ? $_GET['s'] : false, $start, 25 ); // Grab a few extra 85 86 $comments = array_slice($_comments, 0, 20); 87 $extra_comments = array_slice($_comments, 20); 88 89 $page_links = paginate_links( array( 90 'base' => 'edit-comments.php?%_%', 91 'format' => 'apage=%#%', 92 'total' => ceil($total / 20), 93 'current' => $page 94 )); 95 96 if ( $page_links ) 97 echo "<p class='pagenav'>$page_links</p>"; 98 133 99 if ('view' == $mode) { 134 100 if ($comments) { 135 ?> 136 <?php 137 $offset = $offset + 1; 138 $start = " start='$offset'"; 139 140 echo "<ol id='the-comment-list' class='commentlist' $start>"; 101 $offset = $offset + 1; 102 $start = " start='$offset'"; 103 104 echo "<ol id='the-comment-list' class='commentlist' $start>\n"; 141 105 $i = 0; 142 foreach ($comments as $comment) { 143 ++$i; $class = ''; 144 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); 145 $comment_status = wp_get_comment_status($comment->comment_ID); 146 if ('unapproved' == $comment_status) 147 $class .= ' unapproved'; 148 if ($i % 2) 149 $class .= ' alternate'; 150 echo "<li id='comment-$comment->comment_ID' class='$class'>"; 151 ?> 152 <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> 153 154 <?php comment_text() ?> 155 156 <p><?php comment_date('M j, g:i A'); ?> — [ 157 <?php 158 if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 159 echo " <a href='comment.php?action=editcomment&c=".$comment->comment_ID."'>" . __('Edit') . '</a>'; 160 echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&p=' . $comment->comment_post_ID . '&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> '; 161 if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { 162 echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>'; 163 echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>'; 164 } 165 echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&dt=spam&p=" . $comment->comment_post_ID . "&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> "; 166 } 167 $post = get_post($comment->comment_post_ID); 168 $post_title = wp_specialchars( $post->post_title, 'double' ); 169 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; 170 ?> 171 | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ]</p> 172 </li> 173 174 <?php } // end foreach($comment) ?> 175 </ol> 106 foreach ( $comments as $comment ) { 107 get_comment( $comment ); // Cache it 108 _wp_comment_list_item( $comment->comment_ID, ++$i ); 109 } 110 echo "</ol>\n\n"; 111 112 if ( $extra_comments ) : ?> 113 <div id="extra-comments" style="display:none"> 114 <ul id="the-extra-comment-list" class="commentlist"> 115 <?php 116 foreach ( $extra_comments as $comment ) { 117 get_comment( $comment ); // Cache it 118 _wp_comment_list_item( $comment->comment_ID, ++$i ); 119 } 120 ?> 121 </ul> 122 </div> 123 <?php endif; // $extra_comments ?> 176 124 177 125 <div id="ajax-response"></div> … … 243 191 } // end if ($comments) 244 192 } 245 ?> 246 <?php if ( $total > 20 ) { 247 $total_pages = ceil( $total / 20 ); 248 $r = ''; 249 if ( 1 < $page ) { 250 $args['apage'] = ( 1 == $page - 1 ) ? FALSE : $page - 1; 251 $r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">« '. __('Previous Page') .'</a>' . "\n"; 252 } 253 if ( ( $total_pages = ceil( $total / 20 ) ) > 1 ) { 254 for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) : 255 if ( $page == $page_num ) : 256 $r .= "<span>$page_num</span>\n"; 257 else : 258 $p = false; 259 if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) : 260 $args['apage'] = ( 1 == $page_num ) ? FALSE : $page_num; 261 $r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n"; 262 $in = true; 263 elseif ( $in == true ) : 264 $r .= "...\n"; 265 $in = false; 266 endif; 267 endif; 268 endfor; 269 } 270 if ( ( $page ) * 20 < $total || -1 == $total ) { 271 $args['apage'] = $page + 1; 272 $r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page') .' »</a>' . "\n"; 273 } 274 echo "<p class='pagenav'>$r</p>"; 275 ?> 276 277 <?php } ?> 193 194 if ( $page_links ) 195 echo "<p class='pagenav'>$page_links</p>"; 196 197 ?> 278 198 279 199 </div> -
tags/2.2/wp-admin/edit-form-advanced.php
r5468 r5480 108 108 <?php if ( current_user_can('edit_posts') ) : ?> 109 109 <fieldset id="posttimestampdiv" class="dbx-box"> 110 <h3 class="dbx-handle"><?php _e('Post Timestamp'); ?> :</h3>110 <h3 class="dbx-handle"><?php _e('Post Timestamp'); ?></h3> 111 111 <div class="dbx-content"><?php touch_time(($action == 'edit')); ?></div> 112 112 </fieldset> … … 118 118 ?> 119 119 <fieldset id="authordiv" class="dbx-box"> 120 <h3 class="dbx-handle"><?php _e('Post Author'); ?> :</h3>120 <h3 class="dbx-handle"><?php _e('Post Author'); ?></h3> 121 121 <div class="dbx-content"> 122 122 <select name="post_author_override" id="post_author_override"> … … 145 145 146 146 <fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>"> 147 <legend><?php _e('Post') ?></legend> 147 <legend><?php _e('Post') ?> 148 149 <?php if ( 'publish' == $post->post_status ) { ?> 150 <a href="<?php echo clean_url(get_permalink($post->ID)); ?>" class="view-link" target="_blank"><?php _e('View »'); ?></a> 151 <?php } elseif ( 'edit' == $action ) { ?> 152 <a href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" class="view-link" target="_blank"><?php _e('Preview »'); ?></a> 153 <?php } ?> 154 </legend> 148 155 149 156 <?php the_editor($post->post_content); ?> … … 245 252 246 253 <?php if ('edit' == $action) : $delete_nonce = wp_create_nonce( 'delete-post_' . $post_ID ); ?> 247 <input name="deletepost" class="button delete" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this post') ?>" <?php echo "onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}return false;\""; ?> />254 <input name="deletepost" class="button delete" type="submit" id="deletepost" tabindex="10" value="<?php echo ( 'draft' == $post->post_status ) ? __('Delete this draft') : __('Delete this post'); ?>" <?php echo "onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}return false;\""; ?> /> 248 255 <?php endif; ?> 249 256 -
tags/2.2/wp-admin/edit-form-comment.php
r5468 r5480 33 33 <legend><label for="newcomment_author_url"><?php _e('URL:') ?></label></legend> 34 34 <div> 35 <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url ?>" tabindex="3" id="URL"/>35 <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url ?>" tabindex="3" /> 36 36 </div> 37 37 </fieldset> -
tags/2.2/wp-admin/edit-link-form.php
r5468 r5480 23 23 24 24 if ('' == $value) { 25 if ('family' == $class && !strstr($link_rel, 'child') && !strstr($link_rel, 'parent') && !strstr($link_rel, 'sibling') && !strstr($link_rel, 'spouse') && !strstr($link_rel, 'kin')) echo ' checked="checked"';26 if ('friendship' == $class && !strstr($link_rel, 'friend') && !strstr($link_rel, 'acquaintance') && !strstr($link_rel, 'contact')) echo ' checked="checked"';27 if ('geographical' == $class && !strstr($link_rel, 'co-resident') && !strstr($link_rel, 'neighbor')) echo ' checked="checked"';25 if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"'; 26 if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"'; 27 if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"'; 28 28 if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"'; 29 29 } -
tags/2.2/wp-admin/edit-page-form.php
r5468 r5480 99 99 <?php if ( $authors = get_editable_authors( $current_user->id ) ) : // TODO: ROLE SYSTEM ?> 100 100 <fieldset id="authordiv" class="dbx-box"> 101 <h3 class="dbx-handle"><?php _e('Page Author'); ?> :</h3>101 <h3 class="dbx-handle"><?php _e('Page Author'); ?></h3> 102 102 <div class="dbx-content"> 103 103 <select name="post_author_override" id="post_author_override"> … … 132 132 133 133 <fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>"> 134 <legend><?php _e('Page Content') ?></legend> 134 <legend><?php _e('Page Content') ?> 135 136 <?php if ( 'publish' == $post->post_status ) { ?> 137 <a href="<?php echo clean_url(get_permalink($post->ID)); ?>" style="position: absolute; right: 2em; margin-right: 19em; text-decoration: underline;" target="_blank"><?php _e('View »'); ?></a> 138 <?php } elseif ( 'edit' == $action ) { ?> 139 <a href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" style="position: absolute; right: 2em; margin-right: 19em; text-decoration: underline;" target="_blank"><?php _e('Preview »'); ?></a> 140 <?php } ?> 141 </legend> 135 142 <?php the_editor($post->post_content); ?> 136 143 </fieldset> -
tags/2.2/wp-admin/edit.php
r5468 r5480 22 22 if (0 != $i) 23 23 echo ', '; 24 $draft->post_title = stripslashes($draft->post_title);24 $draft->post_title = apply_filters('the_title', stripslashes($draft->post_title)); 25 25 if ($draft->post_title == '') 26 26 $draft->post_title = sprintf(__('Post #%s'), $draft->ID); … … 29 29 } 30 30 ?> 31 31 .</p> 32 32 <?php } ?> 33 33 … … 39 39 if (0 != $i) 40 40 echo ', '; 41 $draft->post_title = stripslashes($draft->post_title);41 $draft->post_title = apply_filters('the_title', stripslashes($draft->post_title)); 42 42 if ($draft->post_title == '') 43 43 $draft->post_title = sprintf(__('Post #%s'), $draft->ID); … … 65 65 } else { 66 66 if ( is_single() ) 67 printf(__('Comments on %s'), $post->post_title);67 printf(__('Comments on %s'), apply_filters( "the_title", $post->post_title)); 68 68 elseif ( ! is_paged() || get_query_var('paged') == 1 ) 69 69 _e('Last 15 Posts'); … … 178 178 case 'date': 179 179 ?> 180 <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else the_time(_ ('Y-m-d \<\b\r \/\> g:i:s a')); ?></td>180 <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else the_time(__('Y-m-d \<\b\r \/\> g:i:s a')); ?></td> 181 181 <?php 182 182 break; -
tags/2.2/wp-admin/export.php
r5468 r5480 123 123 echo '<wp:category_description>' . wxr_cdata($c->category_description) . '</wp:category_description>'; 124 124 } 125 ?> 126 <!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. --> 127 <!-- It contains information about your blog's posts, comments, and categories. --> 128 <!-- You may use this file to transfer that content from one site to another. --> 129 <!-- This file is not intended to serve as a complete backup of your blog. --> 130 131 <!-- To import this information into a WordPress blog follow these steps. --> 132 <!-- 1. Log into that blog as an administrator. --> 133 <!-- 2. Go to Manage: Import in the blog's admin panels. --> 134 <!-- 3. Choose "WordPress" from the list. --> 135 <!-- 4. Upload this file using the form provided on that page. --> 136 <!-- 5. You will first be asked to map the authors in this export file to users --> 137 <!-- on the blog. For each author, you may choose to map to an --> 138 <!-- existing user on the blog or to create a new user --> 139 <!-- 6. WordPress will then import each of the posts, comments, and categories --> 140 <!-- contained in this file into your blog --> 125 126 print '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n"; 127 128 ?> 129 130 <!-- 131 This is a WordPress eXtended RSS file generated by WordPress as an export of 132 your blog. It contains information about your blog's posts, comments, and 133 categories. You may use this file to transfer that content from one site to 134 another. This file is not intended to serve as a complete backup of your 135 blog. 136 137 To import this information into a WordPress blog follow these steps: 138 139 1. Log into that blog as an administrator. 140 2. Go to Manage > Import in the blog's admin. 141 3. Choose "WordPress" from the list of importers. 142 4. Upload this file using the form provided on that page. 143 5. You will first be asked to map the authors in this export file to users 144 on the blog. For each author, you may choose to map an existing user on 145 the blog or to create a new user. 146 6. WordPress will then import each of the posts, comments, and categories 147 contained in this file onto your blog. 148 --> 141 149 142 150 <!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:m'); ?>"--> … … 178 186 <wp:status><?php echo $post->post_status; ?></wp:status> 179 187 <wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent> 188 <wp:menu_order><?php echo $post->menu_order; ?></wp:menu_order> 180 189 <wp:post_type><?php echo $post->post_type; ?></wp:post_type> 181 190 <?php -
tags/2.2/wp-admin/import.php
r5468 r5480 18 18 if ($imports_dir) { 19 19 while (($file = $imports_dir->read()) !== false) { 20 if ( preg_match('|^\.+$|', $file))20 if ($file{0} == '.') { 21 21 continue; 22 if (preg_match('|\.php$|', $file)) 23 require_once("$import_root/$file"); 22 } elseif (substr($file, -4) == '.php') { 23 require_once($import_root . '/' . $file); 24 } 24 25 } 25 26 } -
tags/2.2/wp-admin/import/blogger.php
r5468 r5480 1 1 <?php 2 2 3 define( 'MAX_RESULTS', 50 ); // How many records per GData query 4 define( 'MAX_EXECUTION_TIME', 20 ); // How many seconds to let the script run 5 define( 'STATUS_INTERVAL', 3 ); // How many seconds between status bar updates 6 3 7 class Blogger_Import { 4 8 5 var $lump_authors = false; 6 var $import = array(); 7 8 // Shows the welcome screen and the magic iframe. 9 // Shows the welcome screen and the magic auth link. 9 10 function greet() { 10 $title = __('Import Old Blogger'); 11 $welcome = __('Howdy! This importer allows you to import posts and comments from your Old Blogger account into your WordPress blog.'); 12 $noiframes = __('This feature requires iframe support.'); 13 $warning = js_escape(__('This will delete everything saved by the Blogger importer except your posts and comments. Are you sure you want to do this?')); 14 $reset = __('Reset this importer'); 15 $incompat = __('Your web server is not properly configured to use this importer. Please enable the CURL extension for PHP and then reload this page.'); 16 17 echo "<div class='wrap'><h2>$title</h2><p>$welcome</p>"; 18 echo "<p>" . __('Please note that this importer <em>does not work with new Blogger (using your Google account)</em>.') . "</p>"; 19 if ( function_exists('curl_init') ) 20 echo "<iframe src='admin.php?import=blogger&noheader=true' height='350px' width = '99%'>$noiframes</iframe><p><a href='admin.php?import=blogger&restart=true&noheader=true' onclick='return confirm(\"$warning\")'>$reset</a></p>"; 11 $next_url = get_option('siteurl') . '/wp-admin/index.php?import=blogger&noheader=true'; 12 $auth_url = "https://www.google.com/accounts/AuthSubRequest"; 13 $title = __('Import Blogger'); 14 $welcome = __('Howdy! This importer allows you to import posts and comments from your Blogger account into your WordPress blog.'); 15 $prereqs = __('To use this importer, you must have a Google account, an upgraded (New, was Beta) blog, and it must be on blogspot or a custom domain (not FTP).'); 16 $stepone = __('The first thing you need to do is tell Blogger to let WordPress access your account. You will be sent back here after providing authorization.'); 17 $auth = __('Authorize'); 18 19 echo " 20 <div class='wrap'><h2>$title</h2><p>$welcome</p><p>$prereqs</p><p>$stepone</p> 21 <form action='$auth_url' method='get'> 22 <p class='submit' style='text-align:left;'> 23 <input type='submit' value='$auth' /> 24 <input type='hidden' name='scope' value='http://www.blogger.com/feeds/' /> 25 <input type='hidden' name='session' value='1' /> 26 <input type='hidden' name='secure' value='0' /> 27 <input type='hidden' name='next' value='$next_url' /> 28 </p> 29 </form> 30 </div>\n"; 31 } 32 33 function uh_oh($title, $message, $info) { 34 echo "<div class='wrap'><h2>$title</h2><p>$message</p><pre>$info</pre></div>"; 35 } 36 37 function auth() { 38 // We have a single-use token that must be upgraded to a session token. 39 $token = preg_replace( '/[^-_0-9a-zA-Z]/', '', $_GET['token'] ); 40 $headers = array( 41 "GET /accounts/AuthSubSessionToken HTTP/1.0", 42 "Authorization: AuthSub token=\"$token\"" 43 ); 44 $request = join( "\r\n", $headers ) . "\r\n\r\n"; 45 $sock = $this->_get_auth_sock( ); 46 if ( ! $sock ) return false; 47 $response = $this->_txrx( $sock, $request ); 48 preg_match( '/token=([-_0-9a-z]+)/i', $response, $matches ); 49 if ( empty( $matches[1] ) ) { 50 $this->uh_oh( 51 __( 'Authorization failed' ), 52 __( 'Something went wrong. If the problem persists, send this info to support:' ), 53 htmlspecialchars($response) 54 ); 55 return false; 56 } 57 $this->token = $matches[1]; 58 59 wp_redirect( remove_query_arg( array( 'token', 'noheader' ) ) ); 60 } 61 62 function get_token_info() { 63 $headers = array( 64 "GET /accounts/AuthSubTokenInfo HTTP/1.0", 65 "Authorization: AuthSub token=\"$this->token\"" 66 ); 67 $request = join( "\r\n", $headers ) . "\r\n\r\n"; 68 $sock = $this->_get_auth_sock( ); 69 if ( ! $sock ) return; 70 $response = $this->_txrx( $sock, $request ); 71 return $this->parse_response($response); 72 } 73 74 function token_is_valid() { 75 $info = $this->get_token_info(); 76 77 if ( $info['code'] == 200 ) 78 return true; 79 80 return false; 81 } 82 83 function show_blogs($iter = 0) { 84 if ( empty($this->blogs) ) { 85 $headers = array( 86 "GET /feeds/default/blogs HTTP/1.0", 87 "Host: www2.blogger.com", 88 "Authorization: AuthSub token=\"$this->token\"" 89 ); 90 $request = join( "\r\n", $headers ) . "\r\n\r\n"; 91 $sock = $this->_get_blogger_sock( ); 92 if ( ! $sock ) return; 93 $response = $this->_txrx( $sock, $request ); 94 95 // Quick and dirty XML mining. 96 list( $headers, $xml ) = explode( "\r\n\r\n", $response ); 97 $p = xml_parser_create(); 98 xml_parse_into_struct($p, $xml, $vals, $index); 99 xml_parser_free($p); 100 101 $this->title = $vals[$index['TITLE'][0]]['value']; 102 103 // Give it a few retries... this step often flakes out the first time. 104 if ( empty( $index['ENTRY'] ) ) { 105 if ( $iter < 3 ) { 106 return $this->show_blogs($iter + 1); 107 } else { 108 $this->uh_oh( 109 __('Trouble signing in'), 110 __('We were not able to gain access to your account. Try starting over.'), 111 '' 112 ); 113 return false; 114 } 115 } 116 117 foreach ( $index['ENTRY'] as $i ) { 118 $blog = array(); 119 while ( ( $tag = $vals[$i] ) && ! ( $tag['tag'] == 'ENTRY' && $tag['type'] == 'close' ) ) { 120 if ( $tag['tag'] == 'TITLE' ) { 121 $blog['title'] = $tag['value']; 122 } elseif ( $tag['tag'] == 'SUMMARY' ) { 123 $blog['summary'] == $tag['value']; 124 } elseif ( $tag['tag'] == 'LINK' ) { 125 if ( $tag['attributes']['REL'] == 'alternate' && $tag['attributes']['TYPE'] == 'text/html' ) { 126 $parts = parse_url( $tag['attributes']['HREF'] ); 127 $blog['host'] = $parts['host']; 128 } elseif ( $tag['attributes']['REL'] == 'edit' ) 129 $blog['gateway'] = $tag['attributes']['HREF']; 130 } 131 ++$i; 132 } 133 if ( ! empty ( $blog ) ) { 134 $blog['total_posts'] = $this->get_total_results('posts', $blog['host']); 135 $blog['total_comments'] = $this->get_total_results('comments', $blog['host']); 136 $blog['mode'] = 'init'; 137 $this->blogs[] = $blog; 138 } 139 } 140 141 if ( empty( $this->blogs ) ) { 142 $this->uh_oh( 143 __('No blogs found'), 144 __('We were able to log in but there were no blogs. Try a different account next time.'), 145 '' 146 ); 147 return false; 148 } 149 } 150 //echo '<pre>'.print_r($this,1).'</pre>'; 151 $start = js_escape( __('Import') ); 152 $continue = js_escape( __('Continue') ); 153 $stop = js_escape( __('Importing...') ); 154 $authors = js_escape( __('Set Authors') ); 155 $loadauth = js_escape( __('Preparing author mapping form...') ); 156 $authhead = js_escape( __('Final Step: Author Mapping') ); 157 $nothing = js_escape( __('Nothing was imported. Had you already imported this blog?') ); 158 $title = __('Blogger Blogs'); 159 $name = __('Blog Name'); 160 $url = __('Blog URL'); 161 $action = __('The Magic Button'); 162 $posts = __('Posts'); 163 $comments = __('Comments'); 164 $noscript = __('This feature requires Javascript but it seems to be disabled. Please enable Javascript and then reload this page. Don\'t worry, you can turn it back off when you\'re done.'); 165 166 $interval = STATUS_INTERVAL * 1000; 167 168 foreach ( $this->blogs as $i => $blog ) { 169 if ( $blog['mode'] == 'init' ) 170 $value = $start; 171 elseif ( $blog['mode'] == 'posts' || $blog['mode'] == 'comments' ) 172 $value = $continue; 173 else 174 $value = $authors; 175 $blogtitle = js_escape( $blog['title'] ); 176 $pdone = isset($blog['posts_done']) ? (int) $blog['posts_done'] : 0; 177 $cdone = isset($blog['comments_done']) ? (int) $blog['comments_done'] : 0; 178 $init .= "blogs[$i]=new blog($i,'$blogtitle','{$blog['mode']}'," . $this->get_js_status($i) . ');'; 179 $pstat = "<div class='ind' id='pind$i'> </div><div id='pstat$i' class='stat'>$pdone/{$blog['total_posts']}</div>"; 180 $cstat = "<div class='ind' id='cind$i'> </div><div id='cstat$i' class='stat'>$cdone/{$blog['total_comments']}</div>"; 181 $rows .= "<tr id='blog$i'><td class='blogtitle'>$blogtitle</td><td class='bloghost'>{$blog['host']}</td><td class='bar'>$pstat</td><td class='bar'>$cstat</td><td class='submit'><input type='submit' id='submit$i' value='$value' /><input type='hidden' name='blog' value='$i' /></td></tr>\n"; 182 } 183 184 echo "<div class='wrap'><h2>$title</h2><noscript>$noscript</noscript><table cellpadding='5px'><thead><td>$name</td><td>$url</td><td>$posts</td><td>$comments</td><td>$action</td></thead>\n$rows</table></form></div>"; 185 echo " 186 <script type='text/javascript'> 187 var strings = {cont:'$continue',stop:'$stop',stopping:'$stopping',authors:'$authors',nothing:'$nothing'}; 188 var blogs = {}; 189 function blog(i, title, mode, status){ 190 this.blog = i; 191 this.mode = mode; 192 this.title = title; 193 this.status = status; 194 this.button = document.getElementById('submit'+this.blog); 195 }; 196 blog.prototype = { 197 start: function() { 198 this.cont = true; 199 this.kick(); 200 this.check(); 201 }, 202 kick: function() { 203 ++this.kicks; 204 var i = this.blog; 205 jQuery.post('admin.php?import=blogger&noheader=true',{blog:this.blog},function(text,result){blogs[i].kickd(text,result)}); 206 }, 207 check: function() { 208 ++this.checks; 209 var i = this.blog; 210 jQuery.post('admin.php?import=blogger&noheader=true&status=true',{blog:this.blog},function(text,result){blogs[i].checkd(text,result)}); 211 }, 212 kickd: function(text, result) { 213 if ( result == 'error' ) { 214 // TODO: exception handling 215 if ( this.cont ) 216 setTimeout('blogs['+this.blog+'].kick()', 1000); 217 } else { 218 if ( text == 'done' ) { 219 this.stop(); 220 this.done(); 221 } else if ( text == 'nothing' ) { 222 this.stop(); 223 this.nothing(); 224 } else if ( text == 'continue' ) { 225 this.kick(); 226 } else if ( this.mode = 'stopped' ) 227 jQuery(this.button).attr('value', strings.cont); 228 } 229 --this.kicks; 230 }, 231 checkd: function(text, result) { 232 if ( result == 'error' ) { 233 // TODO: exception handling 234 } else { 235 eval('this.status='+text); 236 jQuery('#pstat'+this.blog).empty().append(this.status.p1+'/'+this.status.p2); 237 jQuery('#cstat'+this.blog).empty().append(this.status.c1+'/'+this.status.c2); 238 this.update(); 239 if ( this.cont || this.kicks > 0 ) 240 setTimeout('blogs['+this.blog+'].check()', $interval); 241 } 242 --this.checks; 243 }, 244 update: function() { 245 jQuery('#pind'+this.blog).width(((this.status.p1>0&&this.status.p2>0)?(this.status.p1/this.status.p2*jQuery('#pind'+this.blog).parent().width()):1)+'px'); 246 jQuery('#cind'+this.blog).width(((this.status.c1>0&&this.status.c2>0)?(this.status.c1/this.status.c2*jQuery('#cind'+this.blog).parent().width()):1)+'px'); 247 }, 248 stop: function() { 249 this.cont = false; 250 }, 251 done: function() { 252 this.mode = 'authors'; 253 jQuery(this.button).attr('value', strings.authors); 254 }, 255 nothing: function() { 256 this.mode = 'nothing'; 257 jQuery(this.button).remove(); 258 alert(strings.nothing); 259 }, 260 getauthors: function() { 261 if ( jQuery('div.wrap').length > 1 ) 262 jQuery('div.wrap').gt(0).remove(); 263 jQuery('div.wrap').empty().append('<h2>$authhead</h2><h3>' + this.title + '</h3>'); 264 jQuery('div.wrap').append('<p id=\"auth\">$loadauth</p>'); 265 jQuery('p#auth').load('index.php?import=blogger&noheader=true&authors=1',{blog:this.blog}); 266 }, 267 init: function() { 268 this.update(); 269 var i = this.blog; 270 jQuery(this.button).bind('click', function(){return blogs[i].click();}); 271 this.kicks = 0; 272 this.checks = 0; 273 }, 274 click: function() { 275 if ( this.mode == 'init' || this.mode == 'stopped' || this.mode == 'posts' || this.mode == 'comments' ) { 276 this.mode = 'started'; 277 this.start(); 278 jQuery(this.button).attr('value', strings.stop); 279 } else if ( this.mode == 'started' ) { 280 return false; // let it run... 281 this.mode = 'stopped'; 282 this.stop(); 283 if ( this.checks > 0 || this.kicks > 0 ) { 284 this.mode = 'stopping'; 285 jQuery(this.button).attr('value', strings.stopping); 286 } else { 287 jQuery(this.button).attr('value', strings.cont); 288 } 289 } else if ( this.mode == 'authors' ) { 290 document.location = 'index.php?import=blogger&authors=1&blog='+this.blog; 291 //this.mode = 'authors2'; 292 //this.getauthors(); 293 } 294 return false; 295 } 296 }; 297 $init 298 jQuery.each(blogs, function(i, me){me.init();}); 299 </script>\n"; 300 } 301 302 // Handy function for stopping the script after a number of seconds. 303 function have_time() { 304 global $importer_started; 305 if ( time() - $importer_started > MAX_EXECUTION_TIME ) 306 die('continue'); 307 return true; 308 } 309 310 function get_total_results($type, $host) { 311 $headers = array( 312 "GET /feeds/$type/default?max-results=1&start-index=2 HTTP/1.0", 313 "Host: $host", 314 "Authorization: AuthSub token=\"$this->token\"" 315 ); 316 $request = join( "\r\n", $headers ) . "\r\n\r\n"; 317 $sock = $this->_get_blogger_sock( $host ); 318 if ( ! $sock ) return; 319 $response = $this->_txrx( $sock, $request ); 320 $response = $this->parse_response( $response ); 321 $parser = xml_parser_create(); 322 xml_parse_into_struct($parser, $response['body'], $struct, $index); 323 xml_parser_free($parser); 324 $total_results = $struct[$index['OPENSEARCH:TOTALRESULTS'][0]]['value']; 325 return (int) $total_results; 326 } 327 328 function import_blog($blogID) { 329 global $importing_blog; 330 $importing_blog = $blogID; 331 332 if ( isset($_GET['authors']) ) 333 return print($this->get_author_form()); 334 335 header('Content-Type: text/plain'); 336 337 if ( isset($_GET['status']) ) 338 die($this->get_js_status()); 339 340 if ( isset($_GET['saveauthors']) ) 341 die($this->save_authors()); 342 343 $blog = $this->blogs[$blogID]; 344 $total_results = $this->get_total_results('posts', $blog['host']); 345 $this->blogs[$importing_blog]['total_posts'] = $total_results; 346 347 $start_index = $total_results - MAX_RESULTS + 1; 348 349 if ( isset( $this->blogs[$importing_blog]['posts_start_index'] ) ) 350 $start_index = (int) $this->blogs[$importing_blog]['posts_start_index']; 351 elseif ( $total_results > MAX_RESULTS ) 352 $start_index = $total_results - MAX_RESULTS + 1; 21 353 else 22 echo "<p>$incompat</p>"; 23 echo "</div>\n"; 24 } 25 26 // Deletes saved data and redirect. 354 $start_index = 1; 355 356 // This will be positive until we have finished importing posts 357 if ( $start_index > 0 ) { 358 // Grab all the posts 359 $this->blogs[$importing_blog]['mode'] = 'posts'; 360 $query = "start-index=$start_index&max-results=" . MAX_RESULTS; 361 do { 362 $index = $struct = $entries = array(); 363 $headers = array( 364 "GET /feeds/posts/default?$query HTTP/1.0", 365 "Host: {$blog['host']}", 366 "Authorization: AuthSub token=\"$this->token\"" 367 ); 368 $request = join( "\r\n", $headers ) . "\r\n\r\n"; 369 $sock = $this->_get_blogger_sock( $blog['host'] ); 370 if ( ! $sock ) return; // TODO: Error handling 371 $response = $this->_txrx( $sock, $request ); 372 373 $response = $this->parse_response( $response ); 374 375 // Extract the entries and send for insertion 376 preg_match_all( '/<entry[^>]*>.*?<\/entry>/s', $response['body'], $matches ); 377 if ( count( $matches[0] ) ) { 378 $entries = array_reverse($matches[0]); 379 foreach ( $entries as $entry ) { 380 $entry = "<feed>$entry</feed>"; 381 $AtomParser = new AtomParser(); 382 $AtomParser->parse( $entry ); 383 $this->import_post($AtomParser->entry); 384 unset($AtomParser); 385 } 386 } else break; 387 388 // Get the 'previous' query string which we'll use on the next iteration 389 $query = ''; 390 $links = preg_match_all('/<link([^>]*)>/', $response['body'], $matches); 391 if ( count( $matches[1] ) ) 392 foreach ( $matches[1] as $match ) 393 if ( preg_match('/rel=.previous./', $match) ) 394 $query = html_entity_decode( preg_replace('/^.*href=[\'"].*\?(.+)[\'"].*$/', '$1', $match) ); 395 396 if ( $query ) { 397 parse_str($query, $q); 398 $this->blogs[$importing_blog]['posts_start_index'] = (int) $q['start-index']; 399 } else 400 $this->blogs[$importing_blog]['posts_start_index'] = 0; 401 $this->save_vars(); 402 } while ( !empty( $query ) && $this->have_time() ); 403 } 404 405 $total_results = $this->get_total_results( 'comments', $blog['host'] ); 406 $this->blogs[$importing_blog]['total_comments'] = $total_results; 407 408 if ( isset( $this->blogs[$importing_blog]['comments_start_index'] ) ) 409 $start_index = (int) $this->blogs[$importing_blog]['comments_start_index']; 410 elseif ( $total_results > MAX_RESULTS ) 411 $start_index = $total_results - MAX_RESULTS + 1; 412 else 413 $start_index = 1; 414 415 if ( $start_index > 0 ) { 416 // Grab all the comments 417 $this->blogs[$importing_blog]['mode'] = 'comments'; 418 $query = "start-index=$start_index&max-results=" . MAX_RESULTS; 419 do { 420 $index = $struct = $entries = array(); 421 $headers = array( 422 "GET /feeds/comments/default?$query HTTP/1.0", 423 "Host: {$blog['host']}", 424 "Authorization: AuthSub token=\"$this->token\"" 425 ); 426 $request = join( "\r\n", $headers ) . "\r\n\r\n"; 427 $sock = $this->_get_blogger_sock( $blog['host'] ); 428 if ( ! $sock ) return; // TODO: Error handling 429 $response = $this->_txrx( $sock, $request ); 430 431 $response = $this->parse_response( $response ); 432 433 // Extract the comments and send for insertion 434 preg_match_all( '/<entry[^>]*>.*?<\/entry>/s', $response['body'], $matches ); 435 if ( count( $matches[0] ) ) { 436 $entries = array_reverse( $matches[0] ); 437 foreach ( $entries as $entry ) { 438 $entry = "<feed>$entry</feed>"; 439 $AtomParser = new AtomParser(); 440 $AtomParser->parse( $entry ); 441 $this->import_comment($AtomParser->entry); 442 unset($AtomParser); 443 } 444 } 445 446 // Get the 'previous' query string which we'll use on the next iteration 447 $query = ''; 448 $links = preg_match_all('/<link([^>]*)>/', $response['body'], $matches); 449 if ( count( $matches[1] ) ) 450 foreach ( $matches[1] as $match ) 451 if ( preg_match('/rel=.previous./', $match) ) 452 $query = html_entity_decode( preg_replace('/^.*href=[\'"].*\?(.+)[\'"].*$/', '$1', $match) ); 453 454 parse_str($query, $q); 455 456 $this->blogs[$importing_blog]['comments_start_index'] = (int) $q['start-index']; 457 $this->save_vars(); 458 } while ( !empty( $query ) && $this->have_time() ); 459 } 460 $this->blogs[$importing_blog]['mode'] = 'authors'; 461 $this->save_vars(); 462 if ( !$this->blogs[$importing_blog]['posts_done'] && !$this->blogs[$importing_blog]['comments_done'] ) 463 die('nothing'); 464 do_action('import_done', 'blogger'); 465 die('done'); 466 } 467 468 function convert_date( $date ) { 469 preg_match('#([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:\.[0-9]+)?(Z|[\+|\-][0-9]{2,4}){0,1}#', $date, $date_bits); 470 $offset = iso8601_timezone_to_offset( $date_bits[7] ); 471 $timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]); 472 $timestamp -= $offset; // Convert from Blogger local time to GMT 473 $timestamp += get_option('gmt_offset') * 3600; // Convert from GMT to WP local time 474 return gmdate('Y-m-d H:i:s', $timestamp); 475 } 476 477 function no_apos( $string ) { 478 return str_replace( ''', "'", $string); 479 } 480 481 function min_whitespace( $string ) { 482 return preg_replace( '|\s+|', ' ', $string ); 483 } 484 485 function import_post( $entry ) { 486 global $wpdb, $importing_blog; 487 488 // The old permalink is all Blogger gives us to link comments to their posts. 489 if ( isset( $entry->draft ) ) 490 $rel = 'self'; 491 else 492 $rel = 'alternate'; 493 foreach ( $entry->links as $link ) { 494 if ( $link['rel'] == $rel ) { 495 $parts = parse_url( $link['href'] ); 496 $entry->old_permalink = $parts['path']; 497 break; 498 } 499 } 500 501 $post_date = $this->convert_date( $entry->published ); 502 $post_content = trim( addslashes( $this->no_apos( html_entity_decode( $entry->content ) ) ) ); 503 $post_title = trim( addslashes( $this->no_apos( $this->min_whitespace( $entry->title ) ) ) ); 504 $post_status = isset( $entry->draft ) ? 'draft' : 'publish'; 505 506 // Clean up content 507 $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 508 $post_content = str_replace('<br>', '<br />', $post_content); 509 $post_content = str_replace('<hr>', '<hr />', $post_content); 510 511 // Checks for duplicates 512 if ( 513 isset( $this->blogs[$importing_blog]['posts'][$entry->old_permalink] ) || 514 post_exists( $post_title, $post_content, $post_date ) 515 ) { 516 ++$this->blogs[$importing_blog]['posts_skipped']; 517 } else { 518 $post = compact('post_date', 'post_content', 'post_title', 'post_status'); 519 520 $post_id = wp_insert_post($post); 521 522 wp_create_categories( array_map( 'addslashes', $entry->categories ), $post_id ); 523 524 $author = $this->no_apos( strip_tags( $entry->author ) ); 525 526 add_post_meta( $post_id, 'blogger_blog', $this->blogs[$importing_blog]['host'], true ); 527 add_post_meta( $post_id, 'blogger_author', $author, true ); 528 add_post_meta( $post_id, 'blogger_permalink', $entry->old_permalink, true ); 529 530 $this->blogs[$importing_blog]['posts'][$entry->old_permalink] = $post_id; 531 ++$this->blogs[$importing_blog]['posts_done']; 532 } 533 $this->save_vars(); 534 } 535 536 function import_comment( $entry ) { 537 global $importing_blog; 538 539 // Drop the #fragment and we have the comment's old post permalink. 540 foreach ( $entry->links as $link ) { 541 if ( $link['rel'] == 'alternate' ) { 542 $parts = parse_url( $link['href'] ); 543 $entry->old_permalink = $parts['fragment']; 544 $entry->old_post_permalink = $parts['path']; 545 break; 546 } 547 } 548 549 $comment_post_ID = (int) $this->blogs[$importing_blog]['posts'][$entry->old_post_permalink]; 550 preg_match('#<name>(.+?)</name>.*(?:\<uri>(.+?)</uri>)?#', $entry->author, $matches); 551 $comment_author = addslashes( $this->no_apos( strip_tags( (string) $matches[1] ) ) ); 552 $comment_author_url = addslashes( $this->no_apos( strip_tags( (string) $matches[2] ) ) ); 553 $comment_date = $this->convert_date( $entry->updated ); 554 $comment_content = addslashes( $this->no_apos( html_entity_decode( $entry->content ) ) ); 555 556 // Clean up content 557 $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content); 558 $comment_content = str_replace('<br>', '<br />', $comment_content); 559 $comment_content = str_replace('<hr>', '<hr />', $comment_content); 560 561 // Checks for duplicates 562 if ( 563 isset( $this->blogs[$importing_blog]['comments'][$entry->old_permalink] ) || 564 comment_exists( $comment_author, $comment_date ) 565 ) { 566 ++$this->blogs[$importing_blog]['comments_skipped']; 567 } else { 568 $comment = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_date', 'comment_content'); 569 570 $comment_id = wp_insert_comment($comment); 571 572 $this->blogs[$importing_blog]['comments'][$entry->old_permalink] = $comment_id; 573 574 ++$this->blogs[$importing_blog]['comments_done']; 575 } 576 $this->save_vars(); 577 } 578 579 function get_js_status($blog = false) { 580 global $importing_blog; 581 if ( $blog === false ) 582 $blog = $this->blogs[$importing_blog]; 583 else 584 $blog = $this->blogs[$blog]; 585 $p1 = isset( $blog['posts_done'] ) ? (int) $blog['posts_done'] : 0; 586 $p2 = isset( $blog['total_posts'] ) ? (int) $blog['total_posts'] : 0; 587 $c1 = isset( $blog['comments_done'] ) ? (int) $blog['comments_done'] : 0; 588 $c2 = isset( $blog['total_comments'] ) ? (int) $blog['total_comments'] : 0; 589 return "{p1:$p1,p2:$p2,c1:$c1,c2:$c2}"; 590 } 591 592 function get_author_form($blog = false) { 593 global $importing_blog, $wpdb, $current_user; 594 if ( $blog === false ) 595 $blog = & $this->blogs[$importing_blog]; 596 else 597 $blog = & $this->blogs[$blog]; 598 599 if ( !isset( $blog['authors'] ) ) { 600 $post_ids = array_values($blog['posts']); 601 $authors = (array) $wpdb->get_col("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'blogger_author' AND post_id IN (" . join( ',', $post_ids ) . ")"); 602 $blog['authors'] = array_map(null, $authors, array_fill(0, count($authors), $current_user->ID)); 603 $this->save_vars(); 604 } 605 606 $directions = __('All posts were imported with the current user as author. Use this form to move each Blogger user\'s posts to a different WordPress user. You may <a href="users.php">add users</a> and then return to this page and complete the user mapping. This form may be used as many times as you like until you activate the "Restart" function below.'); 607 $heading = __('Author mapping'); 608 $blogtitle = "{$blog['title']} ({$blog['host']})"; 609 $mapthis = __('Blogger username'); 610 $tothis = __('WordPress login'); 611 $submit = js_escape( __('Save Changes »') ); 612 613 foreach ( $blog['authors'] as $i => $author ) 614 $rows .= "<tr><td><label for='authors[$i]'>{$author[0]}</label></td><td><select name='authors[$i]' id='authors[$i]'>" . $this->get_user_options($author[1]) . "</select></td></tr>"; 615 616 return "<div class='wrap'><h2>$heading</h2><h3>$blogtitle</h3><p>$directions</p><form action='index.php?import=blogger&noheader=true&saveauthors=1' method='post'><input type='hidden' name='blog' value='$importing_blog' /><table cellpadding='5'><thead><td>$mapthis</td><td>$tothis</td></thead>$rows<tr><td></td><td class='submit'><input type='submit' class='authorsubmit' value='$submit' /></td></tr></table></form></div>"; 617 } 618 619 function get_user_options($current) { 620 global $wpdb, $importer_users; 621 if ( ! isset( $importer_users ) ) 622 $importer_users = (array) get_users_of_blog(); 623 624 foreach ( $importer_users as $user ) { 625 $sel = ( $user->user_id == $current ) ? " selected='selected'" : ''; 626 $options .= "<option value='$user->user_id'$sel>$user->display_name</option>"; 627 } 628 629 return $options; 630 } 631 632 function save_authors() { 633 global $importing_blog, $wpdb; 634 $authors = (array) $_POST['authors']; 635 636 $host = $this->blogs[$importing_blog]['host']; 637 638 // Get an array of posts => authors 639 $post_ids = (array) $wpdb->get_col("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'blogger_blog' AND meta_value = '$host'"); 640 $post_ids = join( ',', $post_ids ); 641 $results = (array) $wpdb->get_results("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = 'blogger_author' AND post_id IN ($post_ids)"); 642 foreach ( $results as $row ) 643 $authors_posts[$row->post_id] = $row->meta_value; 644 645 foreach ( $authors as $author => $user_id ) { 646 $user_id = (int) $user_id; 647 648 // Skip authors that haven't been changed 649 if ( $user_id == $this->blogs[$importing_blog]['authors'][$author][1] ) 650 continue; 651 652 // Get a list of the selected author's posts 653 $post_ids = (array) array_keys( $authors_posts, $this->blogs[$importing_blog]['authors'][$author][0] ); 654 $post_ids = join( ',', $post_ids); 655 656 $wpdb->query("UPDATE $wpdb->posts SET post_author = $user_id WHERE id IN ($post_ids)"); 657 $this->blogs[$importing_blog]['authors'][$author][1] = $user_id; 658 } 659 $this->save_vars(); 660 661 wp_redirect('edit.php'); 662 } 663 664 function _get_auth_sock() { 665 // Connect to https://www.google.com 666 if ( !$sock = @ fsockopen('ssl://www.google.com', 443, $errno, $errstr) ) { 667 $this->uh_oh( 668 __('Could not connect to https://www.google.com'), 669 __('There was a problem opening a secure connection to Google. This is what went wrong:'), 670 "$errstr ($errno)" 671 ); 672 return false; 673 } 674 return $sock; 675 } 676 677 function _get_blogger_sock($host = 'www2.blogger.com') { 678 if ( !$sock = @ fsockopen($host, 80, $errno, $errstr) ) { 679 $this->uh_oh( 680 sprintf( __('Could not connect to %s'), $host ), 681 __('There was a problem opening a connection to Blogger. This is what went wrong:'), 682 "$errstr ($errno)" 683 ); 684 return false; 685 } 686 return $sock; 687 } 688 689 function _txrx( $sock, $request ) { 690 fwrite( $sock, $request ); 691 while ( ! feof( $sock ) ) 692 $response .= @ fread ( $sock, 8192 ); 693 fclose( $sock ); 694 return $response; 695 } 696 697 function revoke($token) { 698 $headers = array( 699 "GET /accounts/AuthSubRevokeToken HTTP/1.0", 700 "Authorization: AuthSub token=\"$token\"" 701 ); 702 $request = join( "\r\n", $headers ) . "\r\n\r\n"; 703 $sock = $this->_get_auth_sock( ); 704 if ( ! $sock ) return false; 705 $this->_txrx( $sock, $request ); 706 } 707 27 708 function restart() { 28 delete_option('import-blogger'); 29 wp_redirect("admin.php?import=blogger"); 30 die(); 31 } 32 33 // Generates a string that will make the page reload in a specified interval. 34 function refresher($msec) { 35 if ( $msec ) 36 return "<html><head><script type='text/javascript'>window.onload=setTimeout('window.location.reload()', $msec);</script>\n</head>\n<body>\n"; 37 else 38 return "<html><head><script type='text/javascript'>window.onload=window.location.reload();</script>\n</head>\n<body>\n"; 709 global $wpdb; 710 $options = get_option( 'blogger_importer' ); 711 712 if ( isset( $options['token'] ) ) 713 $this->revoke( $options['token'] ); 714 715 delete_option('blogger_importer'); 716 $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = 'blogger_author'"); 717 wp_redirect('?import=blogger'); 39 718 } 40 719 … … 63 742 } 64 743 65 // Prints a form for the user to enter Blogger creds.66 function login_form($text='') {67 echo '<h1>' . __('Log in to Blogger') . "</h1>\n$text\n";68 echo '<form method="post" action="admin.php?import=blogger&noheader=true&step=0"><table><tr><td>' . __('Username') . ':</td><td><input type="text" name="user" /></td></tr><tr><td>' . __('Password') . ':</td><td><input type="password" name="pass" /></td><td><input type="submit" value="' . __('Start') . '" /></td></tr></table></form>';69 die;70 }71 72 // Sends creds to Blogger, returns the session cookies an array of headers.73 function login_blogger($user, $pass) {74 $_url = 'http://www.blogger.com/login.do';75 $params = "username=$user&password=$pass";76 $ch = curl_init();77 curl_setopt($ch, CURLOPT_POST,1);78 curl_setopt($ch, CURLOPT_POSTFIELDS,$params);79 curl_setopt($ch, CURLOPT_URL,$_url);80 curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter');81 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);82 curl_setopt($ch, CURLOPT_HEADER,1);83 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);84 $response = curl_exec ($ch);85 86 $response = $this->parse_response($response);87 88 sleep(1);89 90 return $response['cookies'];91 }92 93 // Requests page from Blogger, returns the response array.94 function get_blogger($url, $header = '', $user=false, $pass=false) {95 $ch = curl_init();96 if ($user && $pass) curl_setopt($ch, CURLOPT_USERPWD,"{$user}:{$pass}");97 curl_setopt($ch, CURLOPT_URL,$url);98 curl_setopt($ch, CURLOPT_TIMEOUT, 10);99 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);100 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);101 curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter');102 curl_setopt($ch, CURLOPT_HEADER,1);103 if (is_array($header)) curl_setopt($ch, CURLOPT_HTTPHEADER, $header);104 $response = curl_exec ($ch);105 106 $response = $this->parse_response($response);107 $response['url'] = $url;108 109 if (curl_errno($ch)) {110 print curl_error($ch);111 } else {112 curl_close($ch);113 }114 115 return $response;116 }117 118 // Posts data to Blogger, returns response array.119 function post_blogger($url, $header = false, $paramary = false, $parse=true) {120 $params = '';121 if ( is_array($paramary) ) {122 foreach($paramary as $key=>$value)123 if($key && $value != '')124 $params.=$key."=".urlencode(stripslashes($value))."&";125 }126 if ($user && $pass) $params .= "username=$user&password=$pass";127 $params = trim($params,'&');128 $ch = curl_init();129 curl_setopt($ch, CURLOPT_POST,1);130 curl_setopt($ch, CURLOPT_POSTFIELDS,$params);131 if ($user && $pass) curl_setopt($ch, CURLOPT_USERPWD,"{$user}:{$pass}");132 curl_setopt($ch, CURLOPT_URL,$url);133 curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter');134 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);135 curl_setopt($ch, CURLOPT_HEADER,$parse);136 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);137 if ($header) curl_setopt($ch, CURLOPT_HTTPHEADER, $header);138 $response = curl_exec ($ch);139 140 if ($parse) {141 $response = $this->parse_response($response);142 $response['url'] = $url;143 return $response;144 }145 146 return $response;147 }148 149 // Prints the list of blogs for import.150 function show_blogs() {151 global $import;152 echo '<h1>' . __('Selecting a Blog') . "</h1>\n<ul>";153 foreach ( $this->import['blogs'] as $blog ) {154 if (9 == $blog['nextstep']) $status = "100%";155 elseif (8 == $blog['nextstep']) $status = "90%";156 elseif (7 == $blog['nextstep']) $status = "82.5%";157 elseif (6 == $blog['nextstep']) $status = "75%";158 elseif (5 == $blog['nextstep']) $status = "57%";159 elseif (4 == $blog['nextstep']) $status = "28%";160 elseif (3 == $blog['nextstep']) $status = "14%";161 else $status = "0%";162 echo "\t<li><a href='admin.php?import=blogger&noheader=true&blog={$blog['id']}'>{$blog['title']}</a> $status</li>\n";163 }164 die("</ul>\n");165 }166 167 // Publishes.168 function publish_blogger($i, $text) {169 $head = $this->refresher(2000) . "<h1>$text</h1>\n";170 if ( ! strstr($this->import['blogs'][$_GET['blog']]['publish'][$i], 'http') ) {171 // First call. Start the publish process with a fresh set of cookies.172 $this->import['cookies'] = $this->login_blogger($this->import['user'], $this->import['pass']);173 update_option('import-blogger', $this->import);174 $paramary = array('blogID' => $_GET['blog'], 'all' => '1', 'republishAll' => 'Republish Entire Blog', 'publish' => '1', 'redirectUrl' => "/publish.do?blogID={$_GET['blog']}&inprogress=true");175 176 $response = $this->post_blogger("http://www.blogger.com/publish.do?blogID={$_GET['blog']}", $this->import['cookies'], $paramary);177 if ( $response['code'] == '302' ) {178 $url = str_replace('publish.g', 'publish-body.g', $response['header']['Location']);179 $this->import['blogs'][$_GET['blog']]['publish'][$i] = $url;180 update_option('import-blogger', $this->import);181 $response = $this->get_blogger($url, $this->import['cookies']);182 preg_match('#<p class="progressIndicator">.*</p>#U', $response['body'], $matches);183 $progress = $matches[0];184 die($head . $progress);185 } else {186 $this->import['blogs'][$_GET['blog']]['publish'][$i] = false;187 update_option('import-blogger', $this->import);188 die($head);189 }190 } else {191 // Subsequent call. Keep checking status until Blogger reports publish complete.192 $url = $this->import['blogs'][$_GET['blog']]['publish'][$i];193 $response = $this->get_blogger($url, $this->import['cookies']);194 if ( preg_match('#<p class="progressIndicator">.*</p>#U', $response['body'], $matches) ) {195 $progress = $matches[0];196 if ( strstr($progress, '100%') ) {197 $this->set_next_step($i);198 $progress .= '<p>'.__('Moving on...').'</p>';199 }200 die($head . $progress);201 } else {202 $this->import['blogs'][$_GET['blog']]['publish'][$i] = false;203 update_option('import-blogger', $this->import);204 die("$head<p>" . __('Trying again...') . '</p>');205 }206 }207 }208 209 // Sets next step, saves options210 function set_next_step($step) {211 $this->import['blogs'][$_GET['blog']]['nextstep'] = $step;212 update_option('import-blogger', $this->import);213 }214 215 // Redirects to next step216 function do_next_step() {217 wp_redirect("admin.php?import=blogger&noheader=true&blog={$_GET['blog']}");218 die();219 }220 221 // Step 0: Do Blogger login, get blogid/title pairs.222 function do_login() {223 if ( ( ! $this->import['user'] && ! is_array($this->import['cookies']) ) ) {224 // The user must provide a Blogger username and password.225 if ( ! ( $_POST['user'] && $_POST['pass'] ) ) {226 $this->login_form(__('The script will log into your Blogger account, change some settings so it can read your blog, and restore the original settings when it\'s done. Here\'s what you do:').'</p><ol><li>'.__('Back up your Blogger template.').'</li><li>'.__('Back up any other Blogger settings you might need later.').'</li><li>'.__('Log out of Blogger').'</li><li>'.__('Log in <em>here</em> with your Blogger username and password.').'</li><li>'.__('On the next screen, click one of your Blogger blogs.').'</li><li>'.__('Do not close this window or navigate away until the process is complete.').'</li></ol>');227 }228 229 // Try logging in. If we get an array of cookies back, we at least connected.230 $this->import['cookies'] = $this->login_blogger($_POST['user'], $_POST['pass']);231 if ( !is_array( $this->import['cookies'] ) ) {232 $this->login_form(__('Login failed. Please enter your credentials again.'));233 }234 235 // Save the password so we can log the browser in when it's time to publish.236 $this->import['pass'] = $_POST['pass'];237 $this->import['user'] = $_POST['user'];238 239 // Get the Blogger welcome page and scrape the blog numbers and names from it240 $response = $this->get_blogger('http://www.blogger.com/home', $this->import['cookies']);241 if (! stristr($response['body'], 'signed in as') ) $this->login_form(__('Login failed. Please re-enter your username and password.'));242 $blogsary = array();243 preg_match_all('#posts\.g\?blogID=(\d+)">([^<]+)</a>#U', $response['body'], $blogsary);244 if ( ! count( $blogsary[1] < 1 ) )245 wp_die(__('No blogs found for this user.'));246 $this->import['blogs'] = array();247 $template = '<MainPage><br /><br /><br /><p>'.__('Are you looking for %title%? It is temporarily out of service. Please try again in a few minutes. Meanwhile, discover <a href="http://wordpress.org/">a better blogging tool</a>.').'</p><BloggerArchives><a class="archive" href="<$BlogArchiveURL$>"><$BlogArchiveName$></a><br /></BloggerArchives></MainPage><ArchivePage><Blogger><wordpresspost><$BlogItemDateTime$>|W|P|<$BlogItemAuthorNickname$>|W|P|<$BlogItemBody$>|W|P|<$BlogItemNumber$>|W|P|<$BlogItemTitle$>|W|P|<$BlogItemAuthorEmail$><BlogItemCommentsEnabled><BlogItemComments><wordpresscomment><$BlogCommentDateTime$>|W|P|<$BlogCommentAuthor$>|W|P|<$BlogCommentBody$></BlogItemComments></BlogItemCommentsEnabled></Blogger></ArchivePage>';248 foreach ( $blogsary[1] as $key => $id ) {249 // Define the required Blogger options.250 $blog_opts = array(251 'blog-options-basic' => false,252 'blog-options-archiving' => array('archiveFrequency' => 'm'),253 'blog-publishing' => array('publishMode'=>'0', 'blogID' => "$id", 'subdomain' => mt_rand().mt_rand(), 'pingWeblogs' => 'false'),254 'blog-formatting' => array('timeStampFormat' => '0', 'encoding'=>'UTF-8', 'convertLineBreaks'=>'false', 'floatAlignment'=>'false'),255 'blog-comments' => array('commentsTimeStampFormat' => '0'),256 'template-edit' => array( 'templateText' => str_replace('%title%', trim($blogsary[2][$key]), $template) )257 );258 259 // Build the blog options array template260 foreach ($blog_opts as $blog_opt => $modify)261 $new_opts["$blog_opt"] = array('backup'=>false, 'modify' => $modify, 'error'=>false);262 263 $this->import['blogs']["$id"] = array(264 'id' => $id,265 'title' => trim($blogsary[2][$key]),266 'options' => $new_opts,267 'url' => false,268 'publish_cookies' => false,269 'published' => false,270 'archives' => false,271 'lump_authors' => false,272 'newusers' => array(),273 'nextstep' => 2274 );275 }276 update_option('import-blogger', $this->import);277 wp_redirect("admin.php?import=blogger&noheader=true&step=1");278 }279 die();280 }281 282 // Step 1: Select one of the blogs belonging to the user logged in.283 function select_blog() {284 if ( is_array($this->import['blogs']) ) {285 $this->show_blogs();286 die();287 } else {288 $this->restart();289 }290 }291 292 // Step 2: Backup the Blogger options pages, updating some of them.293 function backup_settings() {294 $output.= '<h1>'.__('Backing up Blogger options')."</h1>\n";295 $form = false;296 foreach ($this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary) {297 if ( $blog_opt == $_GET['form'] ) {298 // Save the posted form data299 $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['backup'] = $_POST;300 update_option('import-blogger',$this->import);301 302 // Post the modified form data to Blogger303 if ( $optary['modify'] ) {304 $posturl = "http://www.blogger.com/{$blog_opt}.do";305 $headers = array_merge($this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['cookies'], $this->import['cookies']);306 if ( 'blog-publishing' == $blog_opt ) {307 if ( $_POST['publishMode'] > 0 ) {308 $response = $this->get_blogger("http://www.blogger.com/blog-publishing.g?blogID={$_GET['blog']}&publishMode=0", $headers);309 if ( $response['code'] >= 400 )310 wp_die('<h2>'.__('Failed attempt to change publish mode from FTP to BlogSpot.').'</h2><pre>' . addslashes(print_r($headers, 1)) . addslashes(print_r($response, 1)) . '</pre>');311 $this->import['blogs'][$_GET['blog']]['url'] = 'http://' . $optary['modify']['subdomain'] . '.blogspot.com/';312 sleep(2);313 } else {314 $this->import['blogs'][$_GET['blog']]['url'] = 'http://' . $_POST['subdomain'] . '.blogspot.com/';315 update_option('import-blogger', $this->import);316 $output .= "<del><p>$blog_opt</p></del>\n";317 continue;318 }319 $paramary = $optary['modify'];320 } else {321 $paramary = array_merge($_POST, $optary['modify']);322 }323 $response = $this->post_blogger($posturl, $headers, $paramary);324 if ( $response['code'] >= 400 || strstr($response['body'], 'There are errors on this form') )325 wp_die('<p>'.__('Error on form submission. Retry or reset the importer.').'</p>' . addslashes(print_r($response, 1)));326 }327 $output .= "<del><p>$blog_opt</p></del>\n";328 } elseif ( is_array($this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['backup']) ) {329 // This option set has already been backed up.330 $output .= "<del><p>$blog_opt</p></del>\n";331 } elseif ( ! $form ) {332 // This option page needs to be downloaded and given to the browser for submission back to this script.333 $response = $this->get_blogger("http://www.blogger.com/{$blog_opt}.g?blogID={$_GET['blog']}", $this->import['cookies']);334 $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['cookies'] = $response['cookies'];335 update_option('import-blogger',$this->import);336 $body = $response['body'];337 $body = preg_replace("|\<!DOCTYPE.*\<body[^>]*>|ms","",$body);338 $body = preg_replace("|/?{$blog_opt}.do|","admin.php?import=blogger&noheader=true&step=2&blog={$_GET['blog']}&form={$blog_opt}",$body);339 $body = str_replace("name='submit'","name='supermit'",$body);340 $body = str_replace('name="submit"','name="supermit"',$body);341 $body = str_replace('</body>','',str_replace('</html>','',$body));342 $form = "<div style='height:0px;width:0px;overflow:hidden;'>";343 $form.= $body;344 $form.= "</div><script type='text/javascript'>forms=document.getElementsByTagName('form');for(i=0;i<forms.length;i++){if(forms[i].action.search('{$blog_opt}')){forms[i].submit();break;}}</script>";345 $output.= '<p>'.sprintf(__('<strong>%s</strong> in progress, please wait...'), $blog_opt)."</p>\n";346 } else {347 $output.= "<p>$blog_opt</p>\n";348 }349 }350 if ( $form )351 die($output . $form);352 353 $this->set_next_step(4);354 $this->do_next_step();355 }356 357 // Step 3: Cancelled :-)358 359 // Step 4: Publish with the new template and settings.360 function publish_blog() {361 $this->publish_blogger(5, __('Publishing with new template and options'));362 }363 364 // Step 5: Get the archive URLs from the new blog.365 function get_archive_urls() {366 $bloghtml = $this->get_blogger($this->import['blogs'][$_GET['blog']]['url']);367 if (! strstr($bloghtml['body'], '<a class="archive"') )368 wp_die(__('Your Blogger blog did not take the new template or did not respond.'));369 preg_match_all('#<a class="archive" href="([^"]*)"#', $bloghtml['body'], $archives);370 foreach ($archives[1] as $archive) {371 $this->import['blogs'][$_GET['blog']]['archives'][$archive] = false;372 }373 $this->set_next_step(6);374 $this->do_next_step();375 }376 377 // Step 6: Get each monthly archive, import it, mark it done.378 function get_archive() {379 global $wpdb;380 $output = '<h2>'.__('Importing Blogger archives into WordPress').'</h2>';381 $did_one = false;382 $post_array = $posts = array();383 foreach ( $this->import['blogs'][$_GET['blog']]['archives'] as $url => $status ) {384 $archivename = substr(basename($url),0,7);385 if ( $status || $did_one ) {386 $foo = 'bar';387 // Do nothing.388 } else {389 // Import the selected month390 $postcount = 0;391 $skippedpostcount = 0;392 $commentcount = 0;393 $skippedcommentcount = 0;394 $status = __('in progress...');395 $this->import['blogs'][$_GET['blog']]['archives']["$url"] = $status;396 update_option('import-blogger', $import);397 $archive = $this->get_blogger($url);398 if ( $archive['code'] > 200 )399 continue;400 $posts = explode('<wordpresspost>', $archive['body']);401 for ($i = 1; $i < count($posts); $i = $i + 1) {402 $postparts = explode('<wordpresscomment>', $posts[$i]);403 $postinfo = explode('|W|P|', $postparts[0]);404 $post_date = $postinfo[0];405 $post_content = $postinfo[2];406 // Don't try to re-use the original numbers407 // because the new, longer numbers are too408 // big to handle as ints.409 //$post_number = $postinfo[3];410 $post_title = ( $postinfo[4] != '' ) ? $postinfo[4] : $postinfo[3];411 $post_author_name = $wpdb->escape(trim($postinfo[1]));412 $post_author_email = $postinfo[5] ? $postinfo[5] : 'user@wordpress.org';413 414 if ( $this->lump_authors ) {415 // Ignore Blogger authors. Use the current user_ID for all posts imported.416 $post_author = $GLOBALS['user_ID'];417 } else {418 // Add a user for each new author encountered.419 if (! username_exists($post_author_name) ) {420 $user_login = $wpdb->escape($post_author_name);421 $user_email = $wpdb->escape($post_author_email);422 $user_password = substr(md5(uniqid(microtime())), 0, 6);423 $result = wp_create_user( $user_login, $user_password, $user_email );424 $status.= sprintf(__('Registered user <strong>%s</strong>.'), $user_login);425 $this->import['blogs'][$_GET['blog']]['newusers'][] = $user_login;426 }427 $userdata = get_userdatabylogin( $post_author_name );428 $post_author = $userdata->ID;429 }430 $post_date = explode(' ', $post_date);431 $post_date_Ymd = explode('/', $post_date[0]);432 $postyear = $post_date_Ymd[2];433 $postmonth = zeroise($post_date_Ymd[0], 2);434 $postday = zeroise($post_date_Ymd[1], 2);435 $post_date_His = explode(':', $post_date[1]);436 $posthour = zeroise($post_date_His[0], 2);437 $postminute = zeroise($post_date_His[1], 2);438 $postsecond = zeroise($post_date_His[2], 2);439 440 if (($post_date[2] == 'PM') && ($posthour != '12'))441 $posthour = $posthour + 12;442 else if (($post_date[2] == 'AM') && ($posthour == '12'))443 $posthour = '00';444 445 $post_date = "$postyear-$postmonth-$postday $posthour:$postminute:$postsecond";446 447 $post_content = addslashes($post_content);448 $post_content = str_replace(array('<br>','<BR>','<br/>','<BR/>','<br />','<BR />'), "\n", $post_content); // the XHTML touch... ;)449 450 $post_title = addslashes($post_title);451 452 $post_status = 'publish';453 454 if ( $ID = post_exists($post_title, '', $post_date) ) {455 $post_array[$i]['ID'] = $ID;456 $skippedpostcount++;457 } else {458 $post_array[$i]['post'] = compact('post_author', 'post_content', 'post_title', 'post_category', 'post_author', 'post_date', 'post_status');459 $post_array[$i]['comments'] = false;460 }461 462 // Import any comments attached to this post.463 if ($postparts[1]) :464 for ($j = 1; $j < count($postparts); $j = $j + 1) {465 $commentinfo = explode('|W|P|', $postparts[$j]);466 $comment_date = explode(' ', $commentinfo[0]);467 $comment_date_Ymd = explode('/', $comment_date[0]);468 $commentyear = $comment_date_Ymd[2];469 $commentmonth = zeroise($comment_date_Ymd[0], 2);470 $commentday = zeroise($comment_date_Ymd[1], 2);471 $comment_date_His = explode(':', $comment_date[1]);472 $commenthour = zeroise($comment_date_His[0], 2);473 $commentminute = zeroise($comment_date_His[1], 2);474 $commentsecond = '00';475 if (($comment_date[2] == 'PM') && ($commenthour != '12'))476 $commenthour = $commenthour + 12;477 else if (($comment_date[2] == 'AM') && ($commenthour == '12'))478 $commenthour = '00';479 $comment_date = "$commentyear-$commentmonth-$commentday $commenthour:$commentminute:$commentsecond";480 $comment_author = addslashes(strip_tags($commentinfo[1]));481 if ( strpos($commentinfo[1], 'a href') ) {482 $comment_author_parts = explode('"', htmlentities($commentinfo[1]));483 $comment_author_url = $comment_author_parts[1];484 } else $comment_author_url = '';485 $comment_content = $commentinfo[2];486 $comment_content = str_replace(array('<br>','<BR>','<br/>','<BR/>','<br />','<BR />'), "\n", $comment_content);487 $comment_approved = 1;488 if ( comment_exists($comment_author, $comment_date) ) {489 $skippedcommentcount++;490 } else {491 $comment = compact('comment_author', 'comment_author_url', 'comment_date', 'comment_content', 'comment_approved');492 $post_array[$i]['comments'][$j] = wp_filter_comment($comment);493 }494 $commentcount++;495 }496 endif;497 $postcount++;498 }499 if ( count($post_array) ) {500 krsort($post_array);501 foreach($post_array as $post) {502 if ( ! $comment_post_ID = $post['ID'] )503 $comment_post_ID = wp_insert_post($post['post']);504 if ( $post['comments'] ) {505 foreach ( $post['comments'] as $comment ) {506 $comment['comment_post_ID'] = $comment_post_ID;507 wp_insert_comment($comment);508 }509 }510 }511 }512 $status = sprintf(__('%s post(s) parsed, %s skipped...'), $postcount, $skippedpostcount).' '.513 sprintf(__('%s comment(s) parsed, %s skipped...'), $commentcount, $skippedcommentcount).' '.514 ' <strong>'.__('Done').'</strong>';515 $import = $this->import;516 $import['blogs'][$_GET['blog']]['archives']["$url"] = $status;517 update_option('import-blogger', $import);518 $did_one = true;519 }520 $output.= "<p>$archivename $status</p>\n";521 }522 if ( ! $did_one )523 $this->set_next_step(7);524 die( $this->refresher(1000) . $output );525 }526 527 // Step 7: Restore the backed-up settings to Blogger528 function restore_settings() {529 $output = '<h1>'.__('Restoring your Blogger options')."</h1>\n";530 $did_one = false;531 // Restore options in reverse order.532 if ( ! $this->import['reversed'] ) {533 $this->import['blogs'][$_GET['blog']]['options'] = array_reverse($this->import['blogs'][$_GET['blog']]['options'], true);534 $this->import['reversed'] = true;535 update_option('import-blogger', $this->import);536 }537 foreach ( $this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary ) {538 if ( $did_one ) {539 $output .= "<p>$blog_opt</p>\n";540 } elseif ( $optary['restored'] || ! $optary['modify'] ) {541 $output .= "<p><del>$blog_opt</del></p>\n";542 } else {543 $posturl = "http://www.blogger.com/{$blog_opt}.do";544 $headers = array_merge($this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['cookies'], $this->import['cookies']);545 if ( 'blog-publishing' == $blog_opt) {546 if ( $optary['backup']['publishMode'] > 0 ) {547 $response = $this->get_blogger("http://www.blogger.com/blog-publishing.g?blogID={$_GET['blog']}&publishMode={$optary['backup']['publishMode']}", $headers);548 sleep(2);549 if ( $response['code'] >= 400 )550 wp_die('<h1>'.__('Error restoring publishMode').'</h1><p>'.__('Please tell the devs.').'</p>' . addslashes(print_r($response, 1)) );551 }552 }553 if ( $optary['backup'] != $optary['modify'] ) {554 $response = $this->post_blogger($posturl, $headers, $optary['backup']);555 if ( $response['code'] >= 400 || strstr($response['body'], 'There are errors on this form') ) {556 $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['error'] = true;557 update_option('import-blogger', $this->import);558 $output .= sprintf(__('%s failed. Trying again.'), "<p><strong>$blog_opt</strong> ").'</p>';559 } else {560 $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['restored'] = true;561 update_option('import-blogger', $this->import);562 $output .= sprintf(__('%s restored.'), "<p><strong>$blog_opt</strong> ").'</p>';563 }564 }565 $did_one = true;566 }567 }568 569 if ( $did_one ) {570 die( $this->refresher(1000) . $output );571 } elseif ( $this->import['blogs'][$_GET['blog']]['options']['blog-publishing']['backup']['publishMode'] > 0 ) {572 $this->set_next_step(9);573 } else {574 $this->set_next_step(8);575 }576 577 $this->do_next_step();578 }579 580 // Step 8: Republish, all back to normal581 function republish_blog() {582 $this->publish_blogger(9, __('Publishing with original template and options'));583 }584 585 744 // Step 9: Congratulate the user 586 745 function congrats() { 746 $blog = (int) $_GET['blog']; 587 747 echo '<h1>'.__('Congratulations!').'</h1><p>'.__('Now that you have imported your Blogger blog into WordPress, what are you going to do? Here are some suggestions:').'</p><ul><li>'.__('That was hard work! Take a break.').'</li>'; 588 748 if ( count($this->import['blogs']) > 1 ) 589 749 echo '<li>'.__('In case you haven\'t done it already, you can import the posts from your other blogs:'). $this->show_blogs() . '</li>'; 590 if ( $n = count($this->import['blogs'][$ _GET['blog']]['newusers']) )750 if ( $n = count($this->import['blogs'][$blog]['newusers']) ) 591 751 echo '<li>'.sprintf(__('Go to <a href="%s" target="%s">Authors & Users</a>, where you can modify the new user(s) or delete them. If you want to make all of the imported posts yours, you will be given that option when you delete the new authors.'), 'users.php', '_parent').'</li>'; 592 echo '<li>'.__('For security, click the link below to reset this importer. That will clear your Blogger credentials and options from the database.').'</li>';752 echo '<li>'.__('For security, click the link below to reset this importer.').'</li>'; 593 753 echo '</ul>'; 594 754 } … … 596 756 // Figures out what to do, then does it. 597 757 function start() { 598 if ( $_GET['restart'] == 'true' ) {758 if ( isset($_POST['restart']) ) 599 759 $this->restart(); 600 } 601 602 if ( isset($_GET['noheader']) ) { 603 header('Content-Type: text/html; charset=utf-8'); 604 605 $this->import = get_option('import-blogger'); 606 607 if ( false === $this->import ) { 608 $step = 0; 609 } elseif ( isset($_GET['step']) ) { 610 $step = (int) $_GET['step']; 611 } elseif ( isset($_GET['blog']) && isset($this->import['blogs'][$_GET['blog']]['nextstep']) ) { 612 $step = $this->import['blogs'][$_GET['blog']]['nextstep']; 613 } elseif ( is_array($this->import['blogs']) ) { 614 $step = 1; 760 761 $options = get_option('blogger_importer'); 762 763 if ( is_array($options) ) 764 foreach ( $options as $key => $value ) 765 $this->$key = $value; 766 767 if ( isset( $_REQUEST['blog'] ) ) { 768 $blog = is_array($_REQUEST['blog']) ? array_shift( array_keys( $_REQUEST['blog'] ) ) : $_REQUEST['blog']; 769 $blog = (int) $blog; 770 $this->import_blog( $blog ); 771 } elseif ( isset($_GET['token']) ) 772 $this->auth(); 773 elseif ( $this->token && $this->token_is_valid() ) 774 $this->show_blogs(); 775 else 776 $this->greet(); 777 778 $saved = $this->save_vars(); 779 780 if ( $saved && !isset($_GET['noheader']) ) { 781 $restart = __('Restart'); 782 $message = __('We have saved some information about your Blogger account in your WordPress database. Clearing this information will allow you to start over. Restarting will not affect any posts you have already imported. If you attempt to re-import a blog, duplicate posts and comments will be skipped.'); 783 $submit = __('Clear account information'); 784 echo "<div class='wrap'><h2>$restart</h2><p>$message</p><form method='post' action='?import=blogger&noheader=true'><p class='submit' style='text-align:left;'><input type='submit' value='$submit' name='restart' /></p></form></div>"; 785 } 786 } 787 788 function save_vars() { 789 $vars = get_object_vars($this); 790 update_option( 'blogger_importer', $vars ); 791 792 return !empty($vars); 793 } 794 795 function admin_head() { 796 ?> 797 <style type="text/css"> 798 td { text-align: center; line-height: 2em;} 799 thead td { font-weight: bold; } 800 .bar { 801 width: 200px; 802 text-align: left; 803 line-height: 2em; 804 padding: 0px; 805 } 806 .ind { 807 position: absolute; 808 background-color: #83B4D8; 809 width: 1px; 810 z-index: 9; 811 } 812 .stat { 813 z-index: 10; 814 position: relative; 815 text-align: center; 816 } 817 .submit { 818 text-align: center !important; 819 } 820 </style> 821 <?php 822 } 823 824 function Blogger_Import() { 825 global $importer_started; 826 $importer_started = time(); 827 if ( isset( $_GET['import'] ) && $_GET['import'] == 'blogger' ) { 828 wp_enqueue_script('jquery'); 829 add_action('admin_head', array(&$this, 'admin_head')); 830 } 831 } 832 } 833 834 $blogger_import = new Blogger_Import(); 835 836 register_importer('blogger', __('Blogger'), __('Import posts, comments, and users from a Blogger blog'), array ($blogger_import, 'start')); 837 838 class AtomEntry { 839 var $links = array(); 840 var $categories = array(); 841 } 842 843 class AtomParser { 844 845 var $ATOM_CONTENT_ELEMENTS = array('content','summary','title','subtitle','rights'); 846 var $ATOM_SIMPLE_ELEMENTS = array('id','updated','published','draft','author'); 847 848 var $depth = 0; 849 var $indent = 2; 850 var $in_content; 851 var $ns_contexts = array(); 852 var $ns_decls = array(); 853 var $is_xhtml = false; 854 var $skipped_div = false; 855 856 var $entry; 857 858 function AtomParser() { 859 860 $this->entry = new AtomEntry(); 861 $this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";'); 862 $this->map_xmlns_func = create_function('$p,$n', '$xd = "xmlns"; if(strlen($n[0])>0) $xd .= ":{$n[0]}"; return "{$xd}=\"{$n[1]}\"";'); 863 } 864 865 function parse($xml) { 866 867 global $app_logging; 868 array_unshift($this->ns_contexts, array()); 869 870 $parser = xml_parser_create_ns(); 871 xml_set_object($parser, $this); 872 xml_set_element_handler($parser, "start_element", "end_element"); 873 xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); 874 xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0); 875 xml_set_character_data_handler($parser, "cdata"); 876 xml_set_default_handler($parser, "_default"); 877 xml_set_start_namespace_decl_handler($parser, "start_ns"); 878 xml_set_end_namespace_decl_handler($parser, "end_ns"); 879 880 $contents = ""; 881 882 xml_parse($parser, $xml); 883 884 xml_parser_free($parser); 885 886 return true; 887 } 888 889 function start_element($parser, $name, $attrs) { 890 891 $tag = array_pop(split(":", $name)); 892 893 array_unshift($this->ns_contexts, $this->ns_decls); 894 895 $this->depth++; 896 897 if(!empty($this->in_content)) { 898 $attrs_prefix = array(); 899 900 // resolve prefixes for attributes 901 foreach($attrs as $key => $value) { 902 $attrs_prefix[$this->ns_to_prefix($key)] = $this->xml_escape($value); 903 } 904 $attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix))); 905 if(strlen($attrs_str) > 0) { 906 $attrs_str = " " . $attrs_str; 907 } 908 909 $xmlns_str = join(' ', array_map($this->map_xmlns_func, array_keys($this->ns_contexts[0]), array_values($this->ns_contexts[0]))); 910 if(strlen($xmlns_str) > 0) { 911 $xmlns_str = " " . $xmlns_str; 912 } 913 914 // handle self-closing tags (case: a new child found right-away, no text node) 915 if(count($this->in_content) == 2) { 916 array_push($this->in_content, ">"); 917 } 918 919 array_push($this->in_content, "<". $this->ns_to_prefix($name) ."{$xmlns_str}{$attrs_str}"); 920 } else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) { 921 $this->in_content = array(); 922 $this->is_xhtml = $attrs['type'] == 'xhtml'; 923 array_push($this->in_content, array($tag,$this->depth)); 924 } else if($tag == 'link') { 925 array_push($this->entry->links, $attrs); 926 } else if($tag == 'category') { 927 array_push($this->entry->categories, $attrs['term']); 928 } 929 930 $this->ns_decls = array(); 931 } 932 933 function end_element($parser, $name) { 934 935 $tag = array_pop(split(":", $name)); 936 937 if(!empty($this->in_content)) { 938 if($this->in_content[0][0] == $tag && 939 $this->in_content[0][1] == $this->depth) { 940 array_shift($this->in_content); 941 if($this->is_xhtml) { 942 $this->in_content = array_slice($this->in_content, 2, count($this->in_content)-3); 943 } 944 $this->entry->$tag = join('',$this->in_content); 945 $this->in_content = array(); 615 946 } else { 616 $step = 0; 617 } 618 //echo "Step $step."; 619 //wp_die('<pre>'.print_r($this->import,1).'</pre'); 620 switch ($step) { 621 case 0 : 622 $this->do_login(); 623 break; 624 case 1 : 625 $this->select_blog(); 626 break; 627 case 2 : 628 $this->backup_settings(); 629 break; 630 case 3 : 631 $this->wait_for_blogger(); 632 break; 633 case 4 : 634 $this->publish_blog(); 635 break; 636 case 5 : 637 $this->get_archive_urls(); 638 break; 639 case 6 : 640 $this->get_archive(); 641 break; 642 case 7 : 643 $this->restore_settings(); 644 break; 645 case 8 : 646 $this->republish_blog(); 647 break; 648 case 9 : 649 $this->congrats(); 650 break; 651 } 652 die; 653 654 } else { 655 $this->greet(); 656 } 657 } 658 659 function Blogger_Import() { 660 // This space intentionally left blank. 947 $endtag = $this->ns_to_prefix($name); 948 if (strpos($this->in_content[count($this->in_content)-1], '<' . $endtag) !== false) { 949 array_push($this->in_content, "/>"); 950 } else { 951 array_push($this->in_content, "</$endtag>"); 952 } 953 } 954 } 955 956 array_shift($this->ns_contexts); 957 958 #print str_repeat(" ", $this->depth * $this->indent) . "end_element('$name')" ."\n"; 959 960 $this->depth--; 961 } 962 963 function start_ns($parser, $prefix, $uri) { 964 #print str_repeat(" ", $this->depth * $this->indent) . "starting: " . $prefix . ":" . $uri . "\n"; 965 array_push($this->ns_decls, array($prefix,$uri)); 966 } 967 968 function end_ns($parser, $prefix) { 969 #print str_repeat(" ", $this->depth * $this->indent) . "ending: #" . $prefix . "#\n"; 970 } 971 972 function cdata($parser, $data) { 973 #print str_repeat(" ", $this->depth * $this->indent) . "data: #" . $data . "#\n"; 974 if(!empty($this->in_content)) { 975 // handle self-closing tags (case: text node found, need to close element started) 976 if (strpos($this->in_content[count($this->in_content)-1], '<') !== false) { 977 array_push($this->in_content, ">"); 978 } 979 array_push($this->in_content, $this->xml_escape($data)); 980 } 981 } 982 983 function _default($parser, $data) { 984 # when does this gets called? 985 } 986 987 988 function ns_to_prefix($qname) { 989 $components = split(":", $qname); 990 $name = array_pop($components); 991 992 if(!empty($components)) { 993 $ns = join(":",$components); 994 foreach($this->ns_contexts as $context) { 995 foreach($context as $mapping) { 996 if($mapping[1] == $ns && strlen($mapping[0]) > 0) { 997 return "$mapping[0]:$name"; 998 } 999 } 1000 } 1001 } 1002 return $name; 1003 } 1004 1005 function xml_escape($string) 1006 { 1007 return str_replace(array('&','"',"'",'<','>'), 1008 array('&','"',''','<','>'), 1009 $string ); 661 1010 } 662 1011 } 663 1012 664 $blogger_import = new Blogger_Import();665 666 register_importer('blogger', __('Old Blogger'), __('Import posts, comments, and users from an Old Blogger blog'), array ($blogger_import, 'start'));667 668 1013 ?> -
tags/2.2/wp-admin/import/dotclear.php
r5468 r5480 148 148 echo '<p>'.__('Your DotClear Configuration settings are as follows:').'</p>'; 149 149 echo '<form action="admin.php?import=dotclear&step=1" method="post">'; 150 wp_nonce_field('import-dotclear'); 150 151 $this->db_form(); 151 echo '<p class="submit"><input type="submit" name="submit" value="'. __('Import Categories').' »" /></p>';152 echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories »')).'" /></p>'; 152 153 echo '</form></div>'; 153 154 } … … 559 560 560 561 echo '<form action="admin.php?import=dotclear&step=2" method="post">'; 561 printf('<input type="submit" name="submit" value="%s" />', __('Import Users')); 562 wp_nonce_field('import-dotclear'); 563 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Users'))); 562 564 echo '</form>'; 563 565 … … 571 573 572 574 echo '<form action="admin.php?import=dotclear&step=3" method="post">'; 573 printf('<input type="submit" name="submit" value="%s" />', __('Import Posts')); 575 wp_nonce_field('import-dotclear'); 576 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Posts'))); 574 577 echo '</form>'; 575 578 } … … 582 585 583 586 echo '<form action="admin.php?import=dotclear&step=4" method="post">'; 584 printf('<input type="submit" name="submit" value="%s" />', __('Import Comments')); 587 wp_nonce_field('import-dotclear'); 588 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Comments'))); 585 589 echo '</form>'; 586 590 } … … 593 597 594 598 echo '<form action="admin.php?import=dotclear&step=5" method="post">'; 595 printf('<input type="submit" name="submit" value="%s" />', __('Import Links')); 599 wp_nonce_field('import-dotclear'); 600 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Links'))); 596 601 echo '</form>'; 597 602 } … … 605 610 606 611 echo '<form action="admin.php?import=dotclear&step=6" method="post">'; 607 printf('<input type="submit" name="submit" value="%s" />', __('Finish')); 612 wp_nonce_field('import-dotclear'); 613 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Finish'))); 608 614 echo '</form>'; 609 615 } … … 668 674 if ( $step > 0 ) 669 675 { 676 check_admin_referer('import-dotclear'); 677 670 678 if($_POST['dbuser']) 671 679 { 672 680 if(get_option('dcuser')) 673 681 delete_option('dcuser'); 674 add_option('dcuser', $_POST['dbuser']);682 add_option('dcuser', sanitize_user($_POST['dbuser'], true)); 675 683 } 676 684 if($_POST['dbpass']) … … 678 686 if(get_option('dcpass')) 679 687 delete_option('dcpass'); 680 add_option('dcpass', $_POST['dbpass']);688 add_option('dcpass', sanitize_user($_POST['dbpass'], true)); 681 689 } 682 690 … … 685 693 if(get_option('dcname')) 686 694 delete_option('dcname'); 687 add_option('dcname', $_POST['dbname']);695 add_option('dcname', sanitize_user($_POST['dbname'], true)); 688 696 } 689 697 if($_POST['dbhost']) … … 691 699 if(get_option('dchost')) 692 700 delete_option('dchost'); 693 add_option('dchost', $_POST['dbhost']);701 add_option('dchost', sanitize_user($_POST['dbhost'], true)); 694 702 } 695 703 if($_POST['dccharset']) … … 697 705 if(get_option('dccharset')) 698 706 delete_option('dccharset'); 699 add_option('dccharset', $_POST['dccharset']);707 add_option('dccharset', sanitize_user($_POST['dccharset'], true)); 700 708 } 701 709 if($_POST['dbprefix']) … … 703 711 if(get_option('dcdbprefix')) 704 712 delete_option('dcdbprefix'); 705 add_option('dcdbprefix', $_POST['dbprefix']);713 add_option('dcdbprefix', sanitize_user($_POST['dbprefix'], true)); 706 714 } 707 715 -
tags/2.2/wp-admin/import/greymatter.php
r5468 r5480 35 35 <input type="hidden" name="import" value="greymatter" /> 36 36 <input type="hidden" name="step" value="1" /> 37 <?php wp_nonce_field('import-greymatter'); ?> 37 38 <h3><?php _e('Second step: GreyMatter details:') ?></h3> 38 39 <p><table cellpadding="0"> … … 88 89 89 90 if (!chdir($archivespath)) 90 wp_die( sprintf(__("Wrong path, %s\ndoesn't exist\non the server"), $archivespath));91 wp_die(__("Wrong path, the path to the GM entries does not exist on the server")); 91 92 92 93 if (!chdir($gmpath)) 93 wp_die(sprintf(__("Wrong path, %s\ndoesn't exist\non the server"), $gmpath)); 94 94 wp_die(__("Wrong path, the path to the GM files does not exist on the server")); 95 96 $lastentry = (int) $lastentry; 97 95 98 $this->header(); 96 99 ?> … … 129 132 $user_id = wp_insert_user($user_info); 130 133 $this->gmnames[$userdata[0]] = $user_id; 131 134 132 135 printf('<li>'.__('user %s...').' <strong>'.__('Done').'</strong></li>', "<em>$user_login</em>"); 133 136 } … … 214 217 $user_url=$wpdb->escape(""); 215 218 $user_joindate=$wpdb->escape($user_joindate); 216 219 217 220 $user_info = array("user_login"=>$user_login, "user_pass"=>$pass1, "user_nickname"=>$user_nickname, "user_email"=>$user_email, "user_url"=>$user_url, "user_ip"=>$user_ip, "user_domain"=>$user_domain, "user_browser"=>$user_browser, "dateYMDhour"=>$user_joindate, "user_level"=>0, "user_idmode"=>"nickname"); 218 221 $user_id = wp_insert_user($user_info); 219 222 $this->gmnames[$postinfo[1]] = $user_id; 220 223 221 224 echo ': '; 222 225 printf(__('registered deleted user %s at level 0 '), "<em>$user_login</em>"); 223 226 } 224 227 225 228 if (array_key_exists($postinfo[1], $this->gmnames)) { 226 229 $post_author = $this->gmnames[$postinfo[1]]; … … 228 231 $post_author = $user_id; 229 232 } 230 233 231 234 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt'); 232 235 $post_ID = wp_insert_post($postdata); … … 298 301 break; 299 302 case 1: 303 check_admin_referer('import-greymatter'); 300 304 $this->import(); 301 305 break; -
tags/2.2/wp-admin/import/livejournal.php
r5468 r5480 154 154 break; 155 155 case 1 : 156 check_admin_referer('import-upload'); 156 157 $this->import(); 157 158 break; -
tags/2.2/wp-admin/import/mt.php
r5468 r5480 148 148 echo '<ol id="authors">'; 149 149 echo '<form action="?import=mt&step=2&id=' . $this->id . '" method="post">'; 150 wp_nonce_field('import-mt'); 150 151 $j = -1; 151 152 foreach ($authors as $author) { … … 418 419 break; 419 420 case 1 : 421 check_admin_referer('import-upload'); 420 422 $this->select_authors(); 421 423 break; 422 424 case 2: 425 check_admin_referer('import-mt'); 423 426 $this->import(); 424 427 break; -
tags/2.2/wp-admin/import/rss.php
r5468 r5480 157 157 break; 158 158 case 1 : 159 check_admin_referer('import-upload'); 159 160 $this->import(); 160 161 break; -
tags/2.2/wp-admin/import/textpattern.php
r5468 r5480 57 57 echo '<p>'.__('Your Textpattern Configuration settings are as follows:').'</p>'; 58 58 echo '<form action="admin.php?import=textpattern&step=1" method="post">'; 59 wp_nonce_field('import-textpattern'); 59 60 $this->db_form(); 60 echo '<p class="submit"><input type="submit" name="submit" value="'. __('Import Categories').' »" /></p>';61 echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories »')).'" /></p>'; 61 62 echo '</form>'; 62 63 echo '</div>'; … … 484 485 485 486 echo '<form action="admin.php?import=textpattern&step=2" method="post">'; 486 printf('<input type="submit" name="submit" value="%s" />', __('Import Users')); 487 wp_nonce_field('import-textpattern'); 488 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Users'))); 487 489 echo '</form>'; 488 490 … … 496 498 497 499 echo '<form action="admin.php?import=textpattern&step=3" method="post">'; 498 printf('<input type="submit" name="submit" value="%s" />', __('Import Posts')); 500 wp_nonce_field('import-textpattern'); 501 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Posts'))); 499 502 echo '</form>'; 500 503 } … … 507 510 508 511 echo '<form action="admin.php?import=textpattern&step=4" method="post">'; 509 printf('<input type="submit" name="submit" value="%s" />', __('Import Comments')); 512 wp_nonce_field('import-textpattern'); 513 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Comments'))); 510 514 echo '</form>'; 511 515 } … … 518 522 519 523 echo '<form action="admin.php?import=textpattern&step=5" method="post">'; 520 printf('<input type="submit" name="submit" value="%s" />', __('Import Links')); 524 wp_nonce_field('import-textpattern'); 525 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Links'))); 521 526 echo '</form>'; 522 527 } … … 530 535 531 536 echo '<form action="admin.php?import=textpattern&step=6" method="post">'; 532 printf('<input type="submit" name="submit" value="%s" />', __('Finish')); 537 wp_nonce_field('import-textpattern'); 538 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Finish'))); 533 539 echo '</form>'; 534 540 } … … 591 597 if ( $step > 0 ) 592 598 { 599 check_admin_referer('import-textpattern'); 600 593 601 if($_POST['dbuser']) 594 602 { 595 603 if(get_option('txpuser')) 596 604 delete_option('txpuser'); 597 add_option('txpuser', $_POST['dbuser']);605 add_option('txpuser', sanitize_user($_POST['dbuser'], true)); 598 606 } 599 607 if($_POST['dbpass']) … … 601 609 if(get_option('txppass')) 602 610 delete_option('txppass'); 603 add_option('txppass', $_POST['dbpass']);611 add_option('txppass', sanitize_user($_POST['dbpass'], true)); 604 612 } 605 613 … … 608 616 if(get_option('txpname')) 609 617 delete_option('txpname'); 610 add_option('txpname', $_POST['dbname']);618 add_option('txpname', sanitize_user($_POST['dbname'], true)); 611 619 } 612 620 if($_POST['dbhost']) … … 614 622 if(get_option('txphost')) 615 623 delete_option('txphost'); 616 add_option('txphost', $_POST['dbhost']);624 add_option('txphost', sanitize_user($_POST['dbhost'], true)); 617 625 } 618 626 if($_POST['dbprefix']) … … 620 628 if(get_option('tpre')) 621 629 delete_option('tpre'); 622 add_option('tpre', $_POST['dbprefix']);630 add_option('tpre', sanitize_user($_POST['dbprefix'])); 623 631 } 624 632 -
tags/2.2/wp-admin/import/wordpress.php
r5468 r5480 4 4 5 5 var $posts = array (); 6 var $posts_processed = array (); 7 // Array of arrays. [[0] => XML fragment, [1] => New post ID] 6 8 var $file; 7 9 var $id; … … 34 36 35 37 function get_tag( $string, $tag ) { 38 global $wpdb; 36 39 preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return); 37 $return = addslashes( trim( $return[1] ) );40 $return = $wpdb->escape( trim( $return[1] ) ); 38 41 return $return; 39 42 } … … 63 66 $user_id = username_exists($this->newauthornames[$this->j]); //check if the new author name defined by the user is a pre-existing wp user 64 67 if (!$user_id) { //banging my head against the desk now. 65 if ($ newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname68 if ($this->newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname 66 69 $user_id = wp_create_user($author, $pass); 67 70 $this->newauthornames[$this->j] = $author; //now we have a name, in the place of left_blank. … … 82 85 function get_entries() { 83 86 set_magic_quotes_runtime(0); 84 $importdata = file($this->file); // Read the file into an array 85 $importdata = implode('', $importdata); // squish it 86 $importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata); 87 preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts); 88 $this->posts = $this->posts[1]; 89 preg_match_all('|<wp:category>(.*?)</wp:category>|is', $importdata, $this->categories); 90 $this->categories = $this->categories[1]; 87 $importdata = array_map('rtrim', file($this->file)); // Read the file into an array 88 89 $this->posts = array(); 90 $this->categories = array(); 91 $num = 0; 92 $doing_entry = false; 93 foreach ($importdata as $importline) { 94 if ( false !== strpos($importline, '<wp:category>') ) { 95 preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category); 96 $this->categories[] = $category[1]; 97 continue; 98 } 99 if ( false !== strpos($importline, '<item>') ) { 100 $this->posts[$num] = ''; 101 $doing_entry = true; 102 continue; 103 } 104 if ( false !== strpos($importline, '</item>') ) { 105 $num++; 106 $doing_entry = false; 107 continue; 108 } 109 if ( $doing_entry ) { 110 $this->posts[$num] .= $importline . "\n"; 111 } 112 } 113 114 foreach ($this->posts as $post) { 115 $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); 116 if ($post_ID) { 117 $this->posts_processed[$post_ID][0] = &$post; 118 $this->posts_processed[$post_ID][1] = 0; 119 } 120 } 91 121 } 92 122 … … 151 181 echo '<ol id="authors">'; 152 182 echo '<form action="?import=wordpress&step=2&id=' . $this->id . '" method="post">'; 183 wp_nonce_field('import-wordpress'); 153 184 $j = -1; 154 185 foreach ($authors as $author) { … … 168 199 $file = wp_import_handle_upload(); 169 200 if ( isset($file['error']) ) { 170 $this->header();171 201 echo '<p>'.__('Sorry, there has been an error.').'</p>'; 172 202 echo '<p><strong>' . $file['error'] . '</strong></p>'; 173 $this->footer();174 203 return; 175 204 } … … 211 240 212 241 function process_posts() { 213 global $wpdb;214 242 $i = -1; 215 243 echo '<ol>'; 216 foreach ($this->posts as $post) { 217 218 // There are only ever one of these 219 $post_title = $this->get_tag( $post, 'title' ); 220 $post_date = $this->get_tag( $post, 'wp:post_date' ); 221 $post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' ); 222 $comment_status = $this->get_tag( $post, 'wp:comment_status' ); 223 $ping_status = $this->get_tag( $post, 'wp:ping_status' ); 224 $post_status = $this->get_tag( $post, 'wp:status' ); 225 $post_parent = $this->get_tag( $post, 'wp:post_parent' ); 226 $post_type = $this->get_tag( $post, 'wp:post_type' ); 227 $guid = $this->get_tag( $post, 'guid' ); 228 $post_author = $this->get_tag( $post, 'dc:creator' ); 229 230 $post_content = $this->get_tag( $post, 'content:encoded' ); 231 $post_content = str_replace(array ('<![CDATA[', ']]>'), '', $post_content); 232 $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 233 $post_content = str_replace('<br>', '<br />', $post_content); 234 $post_content = str_replace('<hr>', '<hr />', $post_content); 235 236 preg_match_all('|<category>(.*?)</category>|is', $post, $categories); 237 $categories = $categories[1]; 238 239 $cat_index = 0; 240 foreach ($categories as $category) { 241 $categories[$cat_index] = $wpdb->escape($this->unhtmlentities(str_replace(array ('<![CDATA[', ']]>'), '', $category))); 242 $cat_index++; 243 } 244 245 if ($post_id = post_exists($post_title, '', $post_date)) { 246 echo '<li>'; 247 printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title)); 248 } else { 249 echo '<li>'; 250 printf(__('Importing post <i>%s</i>...'), stripslashes($post_title)); 251 252 $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor 253 254 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'post_type'); 255 $comment_post_ID = $post_id = wp_insert_post($postdata); 256 // Add categories. 257 if (0 != count($categories)) { 258 wp_create_categories($categories, $post_id); 244 245 foreach ($this->posts as $post) 246 $this->process_post($post); 247 248 echo '</ol>'; 249 250 wp_import_cleanup($this->id); 251 252 echo '<h3>'.sprintf(__('All done.').' <a href="%s">'.__('Have fun!').'</a>', get_option('home')).'</h3>'; 253 } 254 255 function process_post($post) { 256 global $wpdb; 257 258 $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); 259 if ( $post_ID && !empty($this->posts_processed[$post_ID][1]) ) // Processed already 260 return 0; 261 262 // There are only ever one of these 263 $post_title = $this->get_tag( $post, 'title' ); 264 $post_date = $this->get_tag( $post, 'wp:post_date' ); 265 $post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' ); 266 $comment_status = $this->get_tag( $post, 'wp:comment_status' ); 267 $ping_status = $this->get_tag( $post, 'wp:ping_status' ); 268 $post_status = $this->get_tag( $post, 'wp:status' ); 269 $post_name = $this->get_tag( $post, 'wp:post_name' ); 270 $post_parent = $this->get_tag( $post, 'wp:post_parent' ); 271 $menu_order = $this->get_tag( $post, 'wp:menu_order' ); 272 $post_type = $this->get_tag( $post, 'wp:post_type' ); 273 $guid = $this->get_tag( $post, 'guid' ); 274 $post_author = $this->get_tag( $post, 'dc:creator' ); 275 276 $post_content = $this->get_tag( $post, 'content:encoded' ); 277 $post_content = str_replace(array ('<![CDATA[', ']]>'), '', $post_content); 278 $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 279 $post_content = str_replace('<br>', '<br />', $post_content); 280 $post_content = str_replace('<hr>', '<hr />', $post_content); 281 282 preg_match_all('|<category>(.*?)</category>|is', $post, $categories); 283 $categories = $categories[1]; 284 285 $cat_index = 0; 286 foreach ($categories as $category) { 287 $categories[$cat_index] = $wpdb->escape($this->unhtmlentities(str_replace(array ('<![CDATA[', ']]>'), '', $category))); 288 $cat_index++; 289 } 290 291 if ($post_id = post_exists($post_title, '', $post_date)) { 292 echo '<li>'; 293 printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title)); 294 } else { 295 296 // If it has parent, process parent first. 297 $post_parent = (int) $post_parent; 298 if ($parent = $this->posts_processed[$post_parent]) { 299 if (!$parent[1]) $this->process_post($parent[0]); // If not yet, process the parent first. 300 $post_parent = $parent[1]; // New ID of the parent; 301 } 302 303 echo '<li>'; 304 printf(__('Importing post <i>%s</i>...'), stripslashes($post_title)); 305 306 $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor 307 308 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'post_name', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'menu_order', 'post_type'); 309 $comment_post_ID = $post_id = wp_insert_post($postdata); 310 311 // Memorize old and new ID. 312 if ( $post_id && $post_ID && $this->posts_processed[$post_ID] ) 313 $this->posts_processed[$post_ID][1] = $post_id; // New ID. 314 315 // Add categories. 316 if (count($categories) > 0) { 317 $post_cats = array(); 318 foreach ($categories as $category) { 319 $cat_ID = (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name = '$category'"); 320 if ($cat_ID == 0) { 321 $cat_ID = wp_insert_category(array('cat_name' => $category)); 322 } 323 $post_cats[] = $cat_ID; 259 324 } 260 } 261 262 // Now for comments 263 preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments); 264 $comments = $comments[1]; 265 $num_comments = 0; 266 if ( $comments) { foreach ($comments as $comment) { 267 $comment_author = $this->get_tag( $comment, 'wp:comment_author'); 268 $comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email'); 269 $comment_author_IP = $this->get_tag( $comment, 'wp:comment_author_IP'); 270 $comment_author_url = $this->get_tag( $comment, 'wp:comment_author_url'); 271 $comment_date = $this->get_tag( $comment, 'wp:comment_date'); 272 $comment_date_gmt = $this->get_tag( $comment, 'wp:comment_date_gmt'); 273 $comment_content = $this->get_tag( $comment, 'wp:comment_content'); 274 $comment_approved = $this->get_tag( $comment, 'wp:comment_approved'); 275 $comment_type = $this->get_tag( $comment, 'wp:comment_type'); 276 $comment_parent = $this->get_tag( $comment, 'wp:comment_parent'); 277 278 if ( !comment_exists($comment_author, $comment_date) ) { 279 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent'); 280 wp_insert_comment($commentdata); 281 $num_comments++; 282 } 283 } } 284 if ( $num_comments ) 285 printf(' '.__('(%s comments)'), $num_comments); 286 287 // Now for post meta 288 preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta); 289 $postmeta = $postmeta[1]; 290 if ( $postmeta) { foreach ($postmeta as $p) { 291 $key = $this->get_tag( $p, 'wp:meta_key' ); 292 $value = $this->get_tag( $p, 'wp:meta_value' ); 293 add_post_meta( $post_id, $key, $value ); 294 } } 295 296 $index++; 297 } 298 299 echo '</ol>'; 300 301 wp_import_cleanup($this->id); 302 303 echo '<h3>'.sprintf(__('All done.').' <a href="%s">'.__('Have fun!').'</a>', get_option('home')).'</h3>'; 325 wp_set_post_categories($post_id, $post_cats); 326 } 327 } 328 329 // Now for comments 330 preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments); 331 $comments = $comments[1]; 332 $num_comments = 0; 333 if ( $comments) { foreach ($comments as $comment) { 334 $comment_author = $this->get_tag( $comment, 'wp:comment_author'); 335 $comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email'); 336 $comment_author_IP = $this->get_tag( $comment, 'wp:comment_author_IP'); 337 $comment_author_url = $this->get_tag( $comment, 'wp:comment_author_url'); 338 $comment_date = $this->get_tag( $comment, 'wp:comment_date'); 339 $comment_date_gmt = $this->get_tag( $comment, 'wp:comment_date_gmt'); 340 $comment_content = $this->get_tag( $comment, 'wp:comment_content'); 341 $comment_approved = $this->get_tag( $comment, 'wp:comment_approved'); 342 $comment_type = $this->get_tag( $comment, 'wp:comment_type'); 343 $comment_parent = $this->get_tag( $comment, 'wp:comment_parent'); 344 345 if ( !comment_exists($comment_author, $comment_date) ) { 346 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent'); 347 wp_insert_comment($commentdata); 348 $num_comments++; 349 } 350 } } 351 352 if ( $num_comments ) 353 printf(' '.__('(%s comments)'), $num_comments); 354 355 // Now for post meta 356 preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta); 357 $postmeta = $postmeta[1]; 358 if ( $postmeta) { foreach ($postmeta as $p) { 359 $key = $this->get_tag( $p, 'wp:meta_key' ); 360 $value = $this->get_tag( $p, 'wp:meta_value' ); 361 $value = stripslashes($value); // add_post_meta() will escape. 362 add_post_meta( $post_id, $key, $value ); 363 } } 304 364 } 305 365 … … 326 386 break; 327 387 case 1 : 388 check_admin_referer('import-upload'); 328 389 $this->select_authors(); 329 390 break; 330 391 case 2: 392 check_admin_referer('import-wordpress'); 331 393 $this->import(); 332 394 break; -
tags/2.2/wp-admin/index.php
r5468 r5480 16 16 add_action( 'admin_head', 'index_js' ); 17 17 wp_enqueue_script('prototype'); 18 wp_enqueue_script('interface'); 18 19 19 20 $title = __('Dashboard'); … … 50 51 if ( $comments ) { 51 52 foreach ($comments as $comment) { 52 echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>');53 echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . apply_filters('the_title', get_the_title($comment->comment_post_ID)) . '</a>'); 53 54 edit_comment_link(__("Edit"), ' <small>(', ')</small>'); 54 55 echo '</li>'; … … 61 62 62 63 <?php 63 if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) :64 if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) : 64 65 ?> 65 66 <div> … … 99 100 <h3><?php _e('Blog Stats'); ?></h3> 100 101 <?php 101 $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'"); 102 if (0 < $numposts) $numposts = number_format($numposts); 102 $numposts = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'"); 103 $numcomms = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); 104 $numcats = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories"); 103 105 104 $numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); 105 if (0 < $numcomms) $numcomms = number_format($numcomms); 106 $post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format($numposts), 'edit.php'); 107 $comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), number_format($numcomms), 'edit-comments.php'); 108 $cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), number_format($numcats), 'categories.php'); 109 ?> 106 110 107 $numcats = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories"); 108 if (0 < $numcats) $numcats = number_format($numcats); 109 ?> 110 <p><?php 111 $post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), $numposts, 'edit.php'); 112 $comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), $numcomms, 'edit-comments.php'); 113 $cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), $numcats, 'categories.php'); 114 115 printf(__('There are currently %1$s and %2$s, contained within %3$s.'), $post_str, $comm_str, $cat_str); ?></p> 111 <p><?php printf(__('There are currently %1$s and %2$s, contained within %3$s.'), $post_str, $comm_str, $cat_str); ?></p> 116 112 </div> 117 113 … … 127 123 <li><a href="profile.php"><?php _e('Update your profile or change your password'); ?></a></li> 128 124 <?php if ( current_user_can('manage_links') ) : ?> 129 <li><a href="link-add.php"><?php _e('Add a bookmark to your blogroll'); ?></a></li>125 <li><a href="link-add.php"><?php _e('Add a link to your blogroll'); ?></a></li> 130 126 <?php endif; ?> 131 127 <?php if ( current_user_can('switch_themes') ) : ?> -
tags/2.2/wp-admin/link-add.php
r5468 r5480 29 29 <div id="wp-link-bookmarklet" class="wrap"> 30 30 <h3><?php _e('Add Link Bookmarklet'); ?></h3> 31 <p><?php _e('Right click on the following link and choose "Bookmark This Link..." to create an add link shortcut. Right now this only works on Mozilla or Netscape, but we’re working on it.'); ?></p>31 <p><?php _e('Right click on the following link and choose “Bookmark This Link...” or “Add to Favorites...” to create a Link This shortcut.'); ?></p> 32 32 <?php printf('<p><a href="%s" title="'.__('Link add bookmarklet').'">'.__('Link This').'</a></p>', "javascript:void(linkmanpopup=window.open('" . get_option('siteurl') . "/wp-admin/link-add.php?action=popup&linkurl='+escape(location.href)+'&name='+escape(document.title),'LinkManager','scrollbars=yes,width=750,height=550,left=15,top=15,status=yes,resizable=yes'));linkmanpopup.focus();window.focus();linkmanpopup.focus();") ?> 33 33 </div> -
tags/2.2/wp-admin/link-import.php
r5468 r5480 13 13 <?php 14 14 switch ($step) { 15 case 0: 16 { 17 include_once('admin-header.php'); 18 if ( !current_user_can('manage_links') ) 19 wp_die(__('Cheatin’ uh?')); 15 case 0: { 16 include_once('admin-header.php'); 17 if ( !current_user_can('manage_links') ) 18 wp_die(__('Cheatin’ uh?')); 20 19 21 20 $opmltype = 'blogrolling'; // default. 22 21 ?> 23 22 24 23 <div class="wrap"> 24 25 25 <h2><?php _e('Import your blogroll from another system') ?> </h2> 26 26 <form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll"> … … 41 41 </div> 42 42 43 44 43 </div> 45 44 … … 50 49 foreach ($categories as $category) { 51 50 ?> 52 <option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars( $category->cat_name); ?></option>51 <option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars(apply_filters('link_category', $category->cat_name)); ?></option> 53 52 <?php 54 53 } // end foreach … … 61 60 </div> 62 61 <?php 63 64 62 break; 63 } // end case 0 65 64 66 65 case 1: { 67 66 check_admin_referer('import-bookmarks'); 68 67 69 70 71 68 include_once('admin-header.php'); 69 if ( !current_user_can('manage_links') ) 70 wp_die(__('Cheatin’ uh?')); 72 71 ?> 73 72 <div class="wrap"> 74 73 75 74 <h2><?php _e('Importing...') ?></h2> 76 75 <?php 77 $cat_id = $_POST['cat_id']; 78 if (($cat_id == '') || ($cat_id == 0)) { 79 $cat_id = 1; 80 } 76 $cat_id = $_POST['cat_id']; 77 if ( $cat_id == '' || $cat_id == 0 ) 78 $cat_id = 1; 81 79 82 $opml_url = $_POST['opml_url']; 83 if (isset($opml_url) && $opml_url != '' && $opml_url != 'http://') { 84 $blogrolling = true; 85 } 86 else // try to get the upload file. 87 { 88 $overrides = array('test_form' => false, 'test_type' => false); 89 $file = wp_handle_upload($_FILES['userfile'], $overrides); 80 $opml_url = $_POST['opml_url']; 81 if ( isset($opml_url) && $opml_url != '' && $opml_url != 'http://' ) { 82 $blogrolling = true; 83 } else { // try to get the upload file. 84 $overrides = array('test_form' => false, 'test_type' => false); 85 $file = wp_handle_upload($_FILES['userfile'], $overrides); 90 86 91 92 87 if ( isset($file['error']) ) 88 wp_die($file['error']); 93 89 94 95 96 97 90 $url = $file['url']; 91 $opml_url = $file['file']; 92 $blogrolling = false; 93 } 98 94 99 if (isset($opml_url) && $opml_url != '') { 100 $opml = wp_remote_fopen($opml_url); 101 include_once('link-parse-opml.php'); 95 if ( isset($opml_url) && $opml_url != '' ) { 96 if ( $blogrolling === true ) { 97 $opml = wp_remote_fopen($opml_url); 98 } else { 99 $opml = file_get_contents($opml_url); 100 } 101 102 include_once('link-parse-opml.php'); 102 103 103 104 for ($i = 0; $i < $link_count; $i++) {105 106 107 if ('http' == substr($titles[$i], 0, 4))108 109 $link = array( 'link_url' => $urls[$i], 'link_name' => $wpdb->escape($names[$i]), 'link_category' => array($cat_id), 'link_description' => $wpdb->escape($descriptions[$i]), 'link_owner' => $user_ID, 'link_rss' => $feeds[$i]); 110 111 112 104 $link_count = count($names); 105 for ( $i = 0; $i < $link_count; $i++ ) { 106 if ('Last' == substr($titles[$i], 0, 4)) 107 $titles[$i] = ''; 108 if ( 'http' == substr($titles[$i], 0, 4) ) 109 $titles[$i] = ''; 110 $link = array( 'link_url' => $urls[$i], 'link_name' => $wpdb->escape($names[$i]), 'link_category' => array($cat_id), 'link_description' => $wpdb->escape($descriptions[$i]), 'link_owner' => $user_ID, 'link_rss' => $feeds[$i]); 111 wp_insert_link($link); 112 echo sprintf('<p>'.__('Inserted <strong>%s</strong>').'</p>', $names[$i]); 113 } 113 114 ?> 114 <p><?php printf(__('Inserted %1$d links into category %2$s. All done! Go <a href="%3$s">manage those links</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p> 115 116 <p><?php printf(__('Inserted %1$d links into category %2$s. All done! Go <a href="%3$s">manage those links</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p> 117 115 118 <?php 116 117 118 119 120 119 } // end if got url 120 else 121 { 122 echo "<p>" . __("You need to supply your OPML url. Press back on your browser and try again") . "</p>\n"; 123 } // end else 121 124 122 if ( ! $blogrolling ) 123 @unlink($opml_url); 125 if ( ! $blogrolling ) 126 apply_filters( 'wp_delete_file', $opml_url); 127 @unlink($opml_url); 124 128 ?> 125 129 </div> 126 130 <?php 127 128 131 break; 132 } // end case 1 129 133 } // end switch 130 134 -
tags/2.2/wp-admin/link-manager.php
r5468 r5480 81 81 $select_cat .= '<option value="all"' . (($cat_id == 'all') ? " selected='selected'" : '') . '>' . __('All') . "</option>\n"; 82 82 foreach ((array) $categories as $cat) 83 $select_cat .= '<option value="' . $cat->cat_ID . '"' . (($cat->cat_ID == $cat_id) ? " selected='selected'" : '') . '>' . wp_specialchars( $cat->cat_name) . "</option>\n";83 $select_cat .= '<option value="' . $cat->cat_ID . '"' . (($cat->cat_ID == $cat_id) ? " selected='selected'" : '') . '>' . wp_specialchars(apply_filters('link_category', $cat->cat_name)) . "</option>\n"; 84 84 $select_cat .= "</select>\n"; 85 85 … … 132 132 <?php 133 133 foreach ($links as $link) { 134 $link->link_name = attribute_escape( $link->link_name);135 $link->link_description = wp_specialchars( $link->link_description);134 $link->link_name = attribute_escape(apply_filters('link_title', $link->link_name)); 135 $link->link_description = wp_specialchars(apply_filters('link_description', $link->link_description)); 136 136 $link->link_url = clean_url($link->link_url); 137 137 $link->link_category = wp_get_link_cats($link->link_id); … … 161 161 foreach ($link->link_category as $category) { 162 162 $cat_name = get_the_category_by_ID($category); 163 $cat_name = wp_specialchars( $cat_name);163 $cat_name = wp_specialchars(apply_filters('link_category', $cat_name)); 164 164 if ( $cat_id != $category ) 165 165 $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>"; … … 181 181 default: 182 182 ?> 183 <td><?php do_action('manage_link_custom_column', $column_name, $ id); ?></td>183 <td><?php do_action('manage_link_custom_column', $column_name, $link->link_id); ?></td> 184 184 <?php 185 185 break; -
tags/2.2/wp-admin/menu.php
r5468 r5480 7 7 $menu[0] = array(__('Dashboard'), 'read', 'index.php'); 8 8 9 if ( strstr($_SERVER['REQUEST_URI'], 'edit-pages.php'))9 if (strpos($_SERVER['REQUEST_URI'], 'edit-pages.php') !== false) 10 10 $menu[5] = array(__('Write'), 'edit_pages', 'page-new.php'); 11 11 else 12 12 $menu[5] = array(__('Write'), 'edit_posts', 'post-new.php'); 13 if ( strstr($_SERVER['REQUEST_URI'], 'page-new.php'))13 if (strpos($_SERVER['REQUEST_URI'], 'page-new.php') !== false) 14 14 $menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php'); 15 15 else 16 16 $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php'); 17 17 18 18 $menu[15] = array(__('Comments'), 'edit_posts', 'edit-comments.php'); 19 19 $menu[20] = array(__('Blogroll'), 'manage_links', 'link-manager.php'); … … 70 70 $submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php'); 71 71 72 do_action('_admin_menu'); 73 72 74 // Create list of page plugin hook names. 73 75 foreach ($menu as $menu_page) { … … 105 107 $_wp_real_parent_file[$old_parent] = $new_parent; 106 108 $menu[$id][2] = $new_parent; 107 109 108 110 foreach ($submenu[$old_parent] as $index => $data) { 109 111 $submenu[$new_parent][$index] = $submenu[$old_parent][$index]; -
tags/2.2/wp-admin/moderation.php
r5468 r5480 122 122 <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> 123 123 <?php comment_text() ?> 124 <p><?php comment_date( 'M j, g:i A'); ?> — [ <?php124 <p><?php comment_date(__('M j, g:i A')); ?> — [ <?php 125 125 echo '<a href="comment.php?action=editcomment&c='.$comment->comment_ID.'">' . __('Edit') . '</a> | '; 126 126 echo " <a href=\"post.php?action=deletecomment&p=".$comment->comment_post_ID."&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> | "; ?> -
tags/2.2/wp-admin/options-general.php
r5468 r5480 26 26 <tr valign="top"> 27 27 <th scope="row"><?php _e('WordPress address (URL):') ?></th> 28 <td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>" size="40" class="code "/></td>28 <td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>" size="40" class="code<?php if ( defined( 'WP_SITEURL' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> /></td> 29 29 </tr> 30 30 <tr valign="top"> 31 31 <th scope="row"><?php _e('Blog address (URL):') ?></th> 32 <td><input name="home" type="text" id="home" value="<?php form_option('home'); ?>" size="40" class="code " /><br /><?php _e('If you want your blog homepage <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">to be different than the directory</a> you installed WordPress in, enter that address here.'); ?></td>32 <td><input name="home" type="text" id="home" value="<?php form_option('home'); ?>" size="40" class="code<?php if ( defined( 'WP_HOME' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> /><br /><?php _e('Enter the address here if you want your blog homepage <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">to be different from the directory</a> you installed WordPress.'); ?></td> 33 33 </tr> 34 34 <tr valign="top"> … … 98 98 <p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /> 99 99 <input type="hidden" name="action" value="update" /> 100 <input type="hidden" name="page_options" value=" blogname,blogdescription,siteurl,admin_email,users_can_register,gmt_offset,date_format,time_format,home,start_of_week,comment_registration,default_role" />100 <input type="hidden" name="page_options" value="<?php if ( ! defined( 'WP_SITEURL' ) ) echo 'siteurl,'; if ( ! defined( 'WP_HOME' ) ) echo 'home,'; ?>blogname,blogdescription,admin_email,users_can_register,gmt_offset,date_format,time_format,start_of_week,comment_registration,default_role" /> 101 101 </p> 102 102 </form> -
tags/2.2/wp-admin/options-head.php
r5468 r5480 1 1 <?php wp_reset_vars(array('action', 'standalone', 'option_group_id')); ?> 2 3 <br clear="all" />4 2 5 3 <?php if (isset($_GET['updated'])) : ?> -
tags/2.2/wp-admin/options-misc.php
r5468 r5480 37 37 38 38 <p><input name="use_linksupdate" type="checkbox" id="use_linksupdate" value="1" <?php checked('1', get_option('use_linksupdate')); ?> /> 39 <label for="use_linksupdate"><?php _e('Track Bookmarks’ Update Times') ?></label></p>39 <label for="use_linksupdate"><?php _e('Track Links’ Update Times') ?></label></p> 40 40 <p> 41 41 <label><input type="checkbox" name="hack_file" value="1" <?php checked('1', get_option('hack_file')); ?> /> <?php _e('Use legacy <code>my-hacks.php</code> file support') ?></label> -
tags/2.2/wp-admin/options-writing.php
r5468 r5480 42 42 </tr> 43 43 <tr valign="top"> 44 <th scope="row"><?php _e('Default bookmark category:') ?></th>44 <th scope="row"><?php _e('Default link category:') ?></th> 45 45 <td><select name="default_link_category" id="default_link_category"> 46 46 <?php … … 104 104 <?php else : ?> 105 105 106 <p><?php printf(__('WordPress is not notifying any <a href="http://codex.wordpress.org/Update_Services">Update Services</a> because of your blog\'s <a href="%s">privacy settings</a> '), 'options-privacy.php'); ?>106 <p><?php printf(__('WordPress is not notifying any <a href="http://codex.wordpress.org/Update_Services">Update Services</a> because of your blog\'s <a href="%s">privacy settings</a>.'), 'options-privacy.php'); ?> 107 107 108 108 <?php endif; ?> -
tags/2.2/wp-admin/options.php
r5468 r5480 79 79 } 80 80 81 return $value; 81 return $value; 82 82 } 83 83 … … 149 149 <td>"; 150 150 151 if (str istr($value, "\n")) echo "<textarea class='$class' name='$option->option_name' id='$option->option_name' cols='30' rows='5'>$value</textarea>";151 if (strpos($value, "\n") !== false) echo "<textarea class='$class' name='$option->option_name' id='$option->option_name' cols='30' rows='5'>$value</textarea>"; 152 152 else echo "<input class='$class' type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . $value . "'$disabled />"; 153 153 154 154 echo "</td> 155 155 <td>$option->option_description</td> -
tags/2.2/wp-admin/page-new.php
r5468 r5480 5 5 $editing = true; 6 6 wp_enqueue_script('prototype'); 7 wp_enqueue_script('interface'); 7 8 wp_enqueue_script('autosave'); 8 9 require_once('admin-header.php'); -
tags/2.2/wp-admin/page.php
r5468 r5480 53 53 if($post->post_status == 'draft') { 54 54 wp_enqueue_script('prototype'); 55 wp_enqueue_script('interface'); 55 56 wp_enqueue_script('autosave'); 56 57 } … … 61 62 62 63 include('edit-page-form.php'); 63 ?>64 <div id='preview' class='wrap'>65 <h2 id="preview-post"><?php _e('Page Preview (updated when page is saved)'); ?></h2>66 <iframe src="<?php echo clean_url(apply_filters('preview_page_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe>67 </div>68 <?php69 64 break; 70 65 … … 107 102 108 103 if ( isset($_POST['save']) ) 109 $location = "page.php?action=edit&post=$page_ID"; 104 $location = "page.php?action=edit&post=$page_ID"; 110 105 } else { 111 106 if ($_POST['save']) { … … 148 143 149 144 $sendback = wp_get_referer(); 150 if (str str($sendback, 'page.php')) $sendback = get_option('siteurl') .'/wp-admin/page.php';151 elseif (str str($sendback, 'attachments.php')) $sendback = get_option('siteurl') .'/wp-admin/attachments.php';145 if (strpos($sendback, 'page.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/page.php'; 146 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/attachments.php'; 152 147 $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); 153 148 wp_redirect($sendback); -
tags/2.2/wp-admin/plugin-editor.php
r5468 r5480 31 31 fwrite($f, $newcontent); 32 32 fclose($f); 33 34 // Deactivate so we can test it. 35 $current = get_option('active_plugins'); 36 if ( in_array($file, $current) || isset($_POST['phperror']) ) { 37 if ( in_array($file, $current) ) { 38 array_splice($current, array_search( $file, $current), 1 ); // Array-fu! 39 update_option('active_plugins', $current); 40 } 41 wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1")); 42 exit(); 43 } 33 44 wp_redirect("plugin-editor.php?file=$file&a=te"); 34 45 } else { … … 44 55 if ( !current_user_can('edit_plugins') ) 45 56 wp_die('<p>'.__('You do not have sufficient permissions to edit plugins for this blog.').'</p>'); 57 58 if ( $_GET['liveupdate'] ) { 59 check_admin_referer('edit-plugin-test_' . $file); 60 $current = get_option('active_plugins'); 61 $plugin = $file; 62 if ( validate_file($plugin) ) 63 wp_die(__('Invalid plugin.')); 64 if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) 65 wp_die(__('Plugin file does not exist.')); 66 if (!in_array($plugin, $current)) { 67 wp_redirect("plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error 68 @include(ABSPATH . PLUGINDIR . '/' . $plugin); 69 $current[] = $plugin; 70 sort($current); 71 update_option('active_plugins', $current); 72 } 73 wp_redirect("plugin-editor.php?file=$file&a=te"); 74 } 46 75 47 76 require_once('admin-header.php'); … … 61 90 <?php if (isset($_GET['a'])) : ?> 62 91 <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div> 92 <?php elseif (isset($_GET['phperror'])) : ?> 93 <div id="message" class="updated fade"><p><?php _e('This plugin has been deactivated because your changes resulted in a <strong>fatal error</strong>.') ?></p></div> 63 94 <?php endif; ?> 64 95 <div class="wrap"> 65 96 <?php 66 if (is_writeable($real_file)) { 67 echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), $file) . '</h2>'; 97 if ( in_array($file, (array) get_option('active_plugins')) ) { 98 if (is_writeable($real_file)) { 99 echo '<h2>' . sprintf(__('Editing <strong>%s</strong> (active)'), $file) . '</h2>'; 100 } else { 101 echo '<h2>' . sprintf(__('Browsing <strong>%s</strong> (active)'), $file) . '</h2>'; 102 } 68 103 } else { 69 echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), $file) . '</h2>'; 104 if (is_writeable($real_file)) { 105 echo '<h2>' . sprintf(__('Editing <strong>%s</strong> (inactive)'), $file) . '</h2>'; 106 } else { 107 echo '<h2>' . sprintf(__('Browsing <strong>%s</strong> (inactive)'), $file) . '</h2>'; 108 } 70 109 } 71 110 ?> … … 91 130 </div> 92 131 <?php if ( is_writeable($real_file) ) : ?> 132 <?php if ( in_array($file, (array) get_option('active_plugins')) ) { ?> 133 <p><?php _e('<strong>Warning:</strong> Making changes to active plugins is not recommended. If your changes cause a fatal error, the plugin will be automatically deactivated.'); ?></p> 134 <?php } ?> 93 135 <p class="submit"> 94 136 <?php 95 echo "<input type='submit' name='submit' value=' " . __('Update File »') . "' tabindex='2' />"; 137 if ( isset($_GET['phperror']) ) 138 echo "<input type='hidden' name='phperror' value='1' /><input type='submit' name='submit' value='" . __('Update File and Attempt to Reactivate »') . "' tabindex='2' />"; 139 else 140 echo "<input type='submit' name='submit' value='" . __('Update File »') . "' tabindex='2' />"; 96 141 ?> 97 142 </p> -
tags/2.2/wp-admin/plugins.php
r5468 r5480 12 12 wp_die(__('Plugin file does not exist.')); 13 13 if (!in_array($plugin, $current)) { 14 wp_redirect('plugins.php?error=true'); // we'll override this later if the plugin can be included without fatal error 15 ob_start(); 16 @include(ABSPATH . PLUGINDIR . '/' . $plugin); 14 17 $current[] = $plugin; 15 18 sort($current); 16 19 update_option('active_plugins', $current); 17 include(ABSPATH . PLUGINDIR . '/' . $plugin);18 20 do_action('activate_' . $plugin); 21 ob_end_clean(); 19 22 } 20 wp_redirect('plugins.php?activate=true'); 23 wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above 21 24 } else if ('deactivate' == $_GET['action']) { 22 25 check_admin_referer('deactivate-plugin_' . $_GET['plugin']); … … 26 29 do_action('deactivate_' . trim( $_GET['plugin'] )); 27 30 wp_redirect('plugins.php?deactivate=true'); 31 } elseif ($_GET['action'] == 'deactivate-all') { 32 check_admin_referer('deactivate-all'); 33 $current = get_option('active_plugins'); 34 35 foreach ($current as $plugin) { 36 array_splice($current, array_search($plugin, $current), 1); 37 do_action('deactivate_' . $plugin); 38 } 39 40 update_option('active_plugins', array()); 41 wp_redirect('plugins.php?deactivate-all=true'); 28 42 } 29 43 exit; … … 59 73 ?> 60 74 61 <?php if (isset($_GET['activate'])) : ?> 62 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p> 63 </div> 64 <?php endif; ?> 65 <?php if (isset($_GET['deactivate'])) : ?> 66 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p> 67 </div> 75 <?php if ( isset($_GET['error']) ) : ?> 76 <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p></div> 77 <?php elseif ( isset($_GET['activate']) ) : ?> 78 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div> 79 <?php elseif ( isset($_GET['deactivate']) ) : ?> 80 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div> 81 <?php elseif (isset($_GET['deactivate-all'])) : ?> 82 <div id="message" class="updated fade"><p><?php _e('All plugins <strong>deactivated</strong>.'); ?></p></div> 68 83 <?php endif; ?> 69 84 … … 117 132 if ( $style != '' ) 118 133 $style = 'class="' . $style . '"'; 119 if ( is_writable(ABSPATH . 'wp-content/plugins/' . $plugin_file) )134 if ( is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) ) 120 135 $edit = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>"; 121 136 else … … 136 151 ?> 137 152 153 <tr> 154 <td colspan="3"> </td> 155 <td colspan="2" style="width:12em;"><a href="<?php echo wp_nonce_url('plugins.php?action=deactivate-all', 'deactivate-all'); ?>" class="delete"><?php _e('Deactivate All Plugins'); ?></a></td> 156 </tr> 157 138 158 </table> 139 159 <?php -
tags/2.2/wp-admin/post-new.php
r5468 r5480 5 5 $editing = true; 6 6 wp_enqueue_script('prototype'); 7 wp_enqueue_script('interface'); 7 8 wp_enqueue_script('autosave'); 8 9 require_once ('./admin-header.php'); -
tags/2.2/wp-admin/post.php
r5468 r5480 48 48 $post_ID = $p = (int) $_GET['post']; 49 49 $post = get_post($post_ID); 50 50 51 51 if ( 'page' == $post->post_type ) { 52 52 wp_redirect("page.php?action=edit&post=$post_ID"); … … 67 67 include('edit-form-advanced.php'); 68 68 69 ?>70 <div id='preview' class='wrap'>71 <h2 id="preview-post"><?php _e('Post Preview (updated when post is saved)'); ?></h2>72 <iframe src="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe>73 </div>74 <?php75 69 break; 76 70 … … 120 114 $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']); 121 115 $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer()); 122 116 123 117 if ($_POST['save']) { 124 118 $location = "post.php?action=edit&post=$post_ID"; … … 161 155 162 156 $sendback = wp_get_referer(); 163 if (str str($sendback, 'post.php')) $sendback = get_option('siteurl') .'/wp-admin/post-new.php';164 elseif (str str($sendback, 'attachments.php')) $sendback = get_option('siteurl') .'/wp-admin/attachments.php';157 if (strpos($sendback, 'post.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/post-new.php'; 158 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/attachments.php'; 165 159 $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); 166 160 wp_redirect($sendback); -
tags/2.2/wp-admin/rtl.css
r5468 r5480 15 15 #wphead h1 { font-size: 2.4em; } 16 16 17 #postdiv , #titlediv, #guiddiv { margin: 0 0 0 8px; }17 #postdiv, #titlediv, #guiddiv, #tagdiv { margin: 0 0 0 8px; } 18 18 19 19 #ed_toolbar input { margin: 3px 0 2px 2px; } … … 43 43 #adminmenu { 44 44 padding: .2em 2em .3em .2em; 45 height: 30px; 46 } 45 height: 28px; 46 } 47 48 #adminmenu li { line-height: 160%; } 47 49 48 50 #adminmenu a { … … 57 59 } 58 60 59 #adminmenu li { line-height: 180%; } 60 61 #submenu, #minisub { padding: 3px 3em 0 2em; } 61 #submenu, #minisub { padding: 1px 3em 0 2em; } 62 63 #submenu { height: 28px; } 64 65 #submenu li { line-height: 160%; } 66 67 #submenu a { 68 margin: 0 0 0 10px; 69 display: block; 70 float: right; 71 } 62 72 63 73 #submenu .current { … … 66 76 } 67 77 68 #submenu a {69 padding: .3em .4em .4em .4em;70 margin: 0 0 0 10px;71 display: block;72 float: right;73 }74 75 #submenu li { line-height: 120%; }76 77 78 #currenttheme img { 78 79 float: right; … … 91 92 } 92 93 93 * html #postexcerpt .dbx-toggle-open, * html #postexcerpt .dbx-toggle-open, #postexcerpt div, #attachmentlinks div { 94 #postexcerpt div, #attachmentlinks div { 95 margin-right: auto; 96 margin-left: 8px; 97 } 98 99 * html #postexcerpt .dbx-toggle-open { 94 100 padding-right: 0; 95 101 padding-left: 8px; … … 191 197 margin-left: 3px; 192 198 } 199 200 a.view-link { 201 right:auto; 202 left:5%; 203 margin-right:0; 204 margin-left:220px; 205 } -
tags/2.2/wp-admin/setup-config.php
r5468 r5480 158 158 switch (substr($line,0,16)) { 159 159 case "define('DB_NAME'": 160 fwrite($handle, str_replace(" wordpress", $dbname, $line));160 fwrite($handle, str_replace("putyourdbnamehere", $dbname, $line)); 161 161 break; 162 162 case "define('DB_USER'": 163 fwrite($handle, str_replace("'username '", "'$uname'", $line));163 fwrite($handle, str_replace("'usernamehere'", "'$uname'", $line)); 164 164 break; 165 165 case "define('DB_PASSW": 166 fwrite($handle, str_replace("' password'", "'$passwrd'", $line));166 fwrite($handle, str_replace("'yourpasswordhere'", "'$passwrd'", $line)); 167 167 break; 168 168 case "define('DB_HOST'": -
tags/2.2/wp-admin/templates.php
r5468 r5480 53 53 wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>'); 54 54 55 if ( strstr( $file, 'wp-config.php' ))55 if (strpos($file, 'wp-config.php') !== false) 56 56 wp_die('<p>'.__('The config file cannot be edited or viewed through the web interface. Sorry!').'</p>'); 57 57 -
tags/2.2/wp-admin/themes.php
r5468 r5480 27 27 <div id="message1" class="updated fade"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div> 28 28 <?php elseif ( isset($_GET['activated']) ) : ?> 29 <div id="message2" class="updated fade"><p><?php printf(__('New theme activated. <a href="%s">View site »</a>'), get_bloginfo(' home') . '/'); ?></p></div>29 <div id="message2" class="updated fade"><p><?php printf(__('New theme activated. <a href="%s">View site »</a>'), get_bloginfo('url') . '/'); ?></p></div> 30 30 <?php endif; ?> 31 31 -
tags/2.2/wp-admin/upgrade-functions.php
r5468 r5480 22 22 update_option('blog_public', $public); 23 23 $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://'; 24 $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); 24 25 if ( defined('WP_SITEURL') && '' != WP_SITEURL ) 26 $guessurl = WP_SITEURL; 27 else 28 $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); 29 25 30 update_option('siteurl', $guessurl); 26 31 … … 171 176 upgrade_130(); 172 177 } 178 179 maybe_disable_automattic_widgets(); 173 180 174 181 if ( $wp_current_db_version < 3308 ) … … 653 660 function __get_option($setting) { 654 661 global $wpdb; 655 662 663 if ( $setting == 'home' && defined( 'WP_HOME' ) ) { 664 return preg_replace( '|/+$|', '', constant( 'WP_HOME' ) ); 665 } 666 667 if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) { 668 return preg_replace( '|/+$|', '', constant( 'WP_SITEURL' ) ); 669 } 670 656 671 $option = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'"); 657 672 … … 923 938 if ($oldfile == 'index.php') { // Check to make sure it's not a new index 924 939 $index = implode('', file("$oldpath/$oldfile")); 925 if ( strstr( $index, 'WP_USE_THEMES' )) {940 if (strpos($index, 'WP_USE_THEMES') !== false) { 926 941 if (! @copy(ABSPATH . 'wp-content/themes/default/index.php', "$site_dir/$newfile")) 927 942 return false; … … 995 1010 996 1011 foreach ($stylelines as $line) { 997 if (str str($line, "Theme Name:")) $line = "Theme Name: $theme_name";998 elseif (str str($line, "Theme URI:")) $line = "Theme URI: " . __get_option('siteurl');999 elseif (str str($line, "Description:")) $line = "Description: Your theme";1000 elseif (str str($line, "Version:")) $line = "Version: 1";1001 elseif (str str($line, "Author:")) $line = "Author: You";1002 fwrite($f, "{$line}\n");1012 if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name; 1013 elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url'); 1014 elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.'; 1015 elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1'; 1016 elseif (strpos($line, 'Author:') !== false) $line = 'Author: You'; 1017 fwrite($f, $line . "\n"); 1003 1018 } 1004 1019 fclose($f); … … 1095 1110 } 1096 1111 1112 function maybe_disable_automattic_widgets() { 1113 $plugins = __get_option( 'active_plugins' ); 1114 1115 foreach ( (array) $plugins as $plugin ) { 1116 if ( basename( $plugin ) == 'widgets.php' ) { 1117 array_splice( $plugins, array_search( $plugin, $plugins ), 1 ); 1118 update_option( 'active_plugins', $plugins ); 1119 break; 1120 } 1121 } 1122 } 1123 1097 1124 ?> -
tags/2.2/wp-admin/upgrade-schema.php
r5468 r5480 1 1 <?php 2 2 // Here we keep the DB structure and option values 3 4 $charset_collate = ''; 5 6 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) { 7 if ( ! empty($wpdb->charset) ) 8 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 9 if ( ! empty($wpdb->collate) ) 10 $charset_collate .= " COLLATE $wpdb->collate"; 11 } 3 12 4 13 $wp_queries="CREATE TABLE $wpdb->categories ( … … 14 23 PRIMARY KEY (cat_ID), 15 24 KEY category_nicename (category_nicename) 16 ) ;25 ) $charset_collate; 17 26 CREATE TABLE $wpdb->comments ( 18 27 comment_ID bigint(20) unsigned NOT NULL auto_increment, … … 34 43 KEY comment_approved (comment_approved), 35 44 KEY comment_post_ID (comment_post_ID) 36 ) ;45 ) $charset_collate; 37 46 CREATE TABLE $wpdb->link2cat ( 38 47 rel_id bigint(20) NOT NULL auto_increment, … … 41 50 PRIMARY KEY (rel_id), 42 51 KEY link_id (link_id,category_id) 43 ) ;52 ) $charset_collate; 44 53 CREATE TABLE $wpdb->links ( 45 54 link_id bigint(20) NOT NULL auto_increment, … … 60 69 KEY link_category (link_category), 61 70 KEY link_visible (link_visible) 62 ) ;71 ) $charset_collate; 63 72 CREATE TABLE $wpdb->options ( 64 73 option_id bigint(20) NOT NULL auto_increment, … … 75 84 PRIMARY KEY (option_id,blog_id,option_name), 76 85 KEY option_name (option_name) 77 ) ;86 ) $charset_collate; 78 87 CREATE TABLE $wpdb->post2cat ( 79 88 rel_id bigint(20) NOT NULL auto_increment, … … 82 91 PRIMARY KEY (rel_id), 83 92 KEY post_id (post_id,category_id) 84 ) ;93 ) $charset_collate; 85 94 CREATE TABLE $wpdb->postmeta ( 86 95 meta_id bigint(20) NOT NULL auto_increment, … … 91 100 KEY post_id (post_id), 92 101 KEY meta_key (meta_key) 93 ) ;102 ) $charset_collate; 94 103 CREATE TABLE $wpdb->posts ( 95 104 ID bigint(20) unsigned NOT NULL auto_increment, … … 120 129 KEY post_name (post_name), 121 130 KEY type_status_date (post_type,post_status,post_date,ID) 122 ) ;131 ) $charset_collate; 123 132 CREATE TABLE $wpdb->users ( 124 133 ID bigint(20) unsigned NOT NULL auto_increment, … … 134 143 PRIMARY KEY (ID), 135 144 KEY user_login_key (user_login) 136 ) ;145 ) $charset_collate; 137 146 CREATE TABLE $wpdb->usermeta ( 138 147 umeta_id bigint(20) NOT NULL auto_increment, … … 143 152 KEY user_id (user_id), 144 153 KEY meta_key (meta_key) 145 ) ;";154 ) $charset_collate;"; 146 155 147 156 function populate_options() { -
tags/2.2/wp-admin/upgrade.php
r5468 r5480 9 9 10 10 if (isset($_GET['step'])) 11 $step = $_GET['step'];11 $step = (int) $_GET['step']; 12 12 else 13 13 $step = 0; … … 26 26 <body> 27 27 <h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1> 28 <?php 29 switch($step) { 28 29 <?php if ( get_option('db_version') == $wp_db_version ) : ?> 30 31 <h2><?php _e('No Upgrade Required'); ?></h2> 32 <p><?php _e('Your WordPress database is already up-to-date!'); ?></p> 33 <h2 class="step"><a href="<?php echo get_option('home'); ?>/"><?php _e('Continue »'); ?></a></h2> 34 35 <?php else : 36 switch($step) : 30 37 case 0: 31 38 $goback = clean_url(stripslashes(wp_get_referer())); 32 ?> 33 <p><?php _e('This file upgrades you from any previous version of WordPress to the latest. It may take a while though, so be patient.'); ?></p> 39 ?> 40 <h2><?php _e('Database Upgrade Required'); ?></h2> 41 <p><?php _e('Your WordPress database is out-of-date, and must be upgraded before you can continue.'); ?></p> 42 <p><?php _e('The upgrade process may take a while, so please be patient.'); ?></p> 34 43 <h2 class="step"><a href="upgrade.php?step=1&backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress »'); ?></a></h2> 35 44 <?php … … 39 48 40 49 if ( empty( $_GET['backto'] ) ) 41 $backto = __get_option('home') ;50 $backto = __get_option('home') . '/'; 42 51 else 43 52 $backto = clean_url(stripslashes($_GET['backto'])); 44 53 ?> 45 <h2><?php _e('Step 1'); ?></h2> 46 <p><?php printf(__("There's actually only one step. So if you see this, you're done. <a href='%s'>Have fun</a>!"), $backto); ?></p> 54 <h2><?php _e('Upgrade Complete'); ?></h2> 55 <p><?php _e('Your WordPress database has been successfully upgraded!'); ?></p> 56 <h2 class="step"><a href="<?php echo $backto; ?>"><?php _e('Continue »'); ?></a></h2> 47 57 48 58 <!-- … … 56 66 <?php 57 67 break; 58 } 68 endswitch; 69 endif; 59 70 ?> 60 71 </body> -
tags/2.2/wp-admin/upload-functions.php
r5468 r5480 14 14 if ( isset($attachment_data['width']) ) 15 15 list($width,$height) = wp_shrink_dimensions($attachment_data['width'], $attachment_data['height'], 171, 128); 16 16 17 17 ob_start(); 18 18 the_title(); 19 19 $post_title = attribute_escape(ob_get_contents()); 20 20 ob_end_clean(); 21 $post_content = a pply_filters( 'content_edit_pre', $post->post_content);22 21 $post_content = attribute_escape(apply_filters( 'content_edit_pre', $post->post_content )); 22 23 23 $class = 'text'; 24 24 $innerHTML = get_attachment_innerHTML( $id, false, $dims ); … … 36 36 37 37 if ( $href ) 38 $r .= "<a id='file-link-$id' href=' " . clean_url($href) ."' title='$post_title' class='file-link $class'>\n";38 $r .= "<a id='file-link-$id' href='$href' title='$post_title' class='file-link $class'>\n"; 39 39 if ( $href || $image_src ) 40 40 $r .= "\t\t\t$innerHTML"; … … 286 286 global $wpdb, $action, $paged; 287 287 $old_vars = compact( 'paged' ); 288 288 289 289 switch ( $action ) : 290 290 case 'edit' : … … 356 356 } 357 357 } 358 359 ?> -
tags/2.2/wp-admin/upload.css
r5468 r5480 45 45 46 46 #upload-menu li #current-tab-nav { 47 background: #f9fcfe; 47 48 float: left; 48 49 padding: 5px 5px 0 0; -
tags/2.2/wp-admin/upload.php
r5468 r5480 90 90 $href = add_query_arg( array('tab' => $t, 'ID' => '', 'action' => '', 'paged' => '') ); 91 91 if ( isset($tab_array[4]) && is_array($tab_array[4]) ) 92 add_query_arg( $tab_array[4], $href );92 $href = add_query_arg( $tab_array[4], $href ); 93 93 $_href = clean_url( $href); 94 94 $page_links = ''; -
tags/2.2/wp-admin/user-edit.php
r5468 r5480 56 56 <p><strong><?php _e('User updated.') ?></strong></p> 57 57 <?php if ( $wp_http_referer ) : ?> 58 <p><a href=" <?php echo clean_url($wp_http_referer); ?>"><?php _e('« Back to Authors and Users'); ?></a></p>58 <p><a href="users.php"><?php _e('« Back to Authors and Users'); ?></a></p> 59 59 <?php endif; ?> 60 60 </div> … … 83 83 <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" /> 84 84 </p> 85 86 <p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', $profileuser->rich_editing); ?> /> <?php _e('Use the visual editor when writing'); ?></label></p> 87 88 <p class="submit"><input type="submit" value="<?php _e('Update User »'); ?>" name="submit" /></p> 85 89 86 90 <fieldset> -
tags/2.2/wp-admin/users.php
r5468 r5480 86 86 'total' => ceil($this->total_users_for_query / $this->users_per_page), 87 87 'current' => $this->page, 88 'prev_text' => '« Previous Page',89 'next_text' => 'Next Page »',88 'prev_text' => __('« Previous Page'), 89 'next_text' => __('Next Page »'), 90 90 'base' => 'users.php?%_%', 91 91 'format' => 'userspage=%#%', … … 339 339 340 340 <form action="" method="get" name="search" id="search"> 341 <p><input type="text" name="usersearch" id="usersearch" value="<?php echo attribute_escape($wp_user_search->search_term); ?>" /> <input type="submit" value="<?php _e('Search users »'); ?>" class="button" /></p>341 <p><input type="text" name="usersearch" id="usersearch" value="<?php echo attribute_escape($wp_user_search->search_term); ?>" /> <input type="submit" value="<?php _e('Search Users »'); ?>" class="button" /></p> 342 342 </form> 343 343 … … 451 451 <div class="narrow"> 452 452 453 <?php echo '<p>'.sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), get_option('siteurl').'/wp-register.php').'</p>'; ?> 453 <?php 454 if ( get_option('users_can_register') ) 455 echo '<p>' . sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), get_option('siteurl').'/wp-register.php') . '</p>'; 456 else 457 echo '<p>' . sprintf(__('Users cannot currently <a href="%1$s">register themselves</a>, but you can manually create users here.'), get_option('siteurl').'/wp-admin/options-general.php#users_can_register') . '</p>'; 458 ?> 454 459 <form action="#add-new-user" method="post" name="adduser" id="adduser"> 455 460 <?php wp_nonce_field('add-user') ?> -
tags/2.2/wp-admin/wp-admin.css
r5468 r5480 202 202 border: 1px solid #b2b2b2; 203 203 color: #000; 204 font: 204 font: 13px Verdana, Arial, Helvetica, sans-serif; 205 205 margin: 1px; 206 206 padding: 3px; … … 209 209 #uploading { 210 210 border-style: none; 211 padding: 0 px;211 padding: 0; 212 212 margin-bottom: 16px; 213 213 height: 18em; … … 293 293 } 294 294 295 .commentlist li li { 296 border-bottom: 0px; 297 padding: 0; 298 } 299 295 300 .commentlist p { 296 301 padding: 0; … … 460 465 } 461 466 462 463 467 #adminmenu .current, #submenu .current { 464 468 font-weight: bold; … … 485 489 list-style: none; 486 490 text-align: center; 491 white-space: nowrap; 487 492 } 488 493 … … 530 535 } 531 536 532 533 537 #categorydiv input, #poststatusdiv input, #commentstatusdiv input, #pingstatusdiv input { 534 538 border: none; … … 537 541 #postdiv, #titlediv, #guiddiv { 538 542 margin: 0 8px 0 0; 539 padding: 0 px;543 padding: 0; 540 544 } 541 545 542 546 #postdivrich { 543 margin: 0 px;544 padding: 0 px;547 margin: 0; 548 padding: 0; 545 549 } 546 550 547 551 #content { 548 margin: 0 0 0 0;552 margin: 0; 549 553 width: 100%; 550 554 } 551 555 552 556 #postdivrich #content { 553 padding: .7em;557 padding: 5px; 554 558 line-height: 140%; 555 559 } 556 560 557 561 #titlediv input, #guiddiv input { 558 margin: 0 px;562 margin: 0; 559 563 width: 100%; 560 564 } … … 580 584 #postdivrich #quicktags { 581 585 background: #f0f0ee; 582 padding: 0 px;586 padding: 0; 583 587 border: 1px solid #ccc; 584 588 border-bottom: none; … … 594 598 595 599 #quicktags #ed_toolbar { 596 padding: 0 px2px;600 padding: 0 2px; 597 601 } 598 602 599 603 #ed_toolbar input { 600 background: #fff url( images/fade-butt.png ) repeat-x 0 px-2px;604 background: #fff url( images/fade-butt.png ) repeat-x 0 -2px; 601 605 margin: 3px 2px 2px; 602 606 } … … 626 630 #title { 627 631 font-size: 1.7em; 628 padding: 4px ;632 padding: 4px 3px; 629 633 } 630 634 … … 644 648 645 649 #excerpt, .attachmentlinks { 646 margin: 0 px;650 margin: 0; 647 651 height: 4em; 648 652 width: 100%; … … 729 733 display: block; 730 734 border-bottom: none; 731 } 732 733 #login .hide { 734 display: none; 735 text-indent: -9999px; 735 736 } 736 737 … … 815 816 #postcustom table { 816 817 border: 1px solid #ccc; 817 margin: 0 px;818 margin: 0; 818 819 width: 100%; 819 820 } … … 836 837 837 838 * html #template div { 838 margin-right: 0 px;839 margin-right: 0; 839 840 } 840 841 … … 891 892 letter-spacing: -.05em; 892 893 margin: 0; 893 font-family: Georgia, "Times New Roman", Times, serif 894 font-family: Georgia, "Times New Roman", Times, serif; 894 895 } 895 896 … … 968 969 set display:none; */ 969 970 .zerosize { 970 height: 0 px;971 width: 0 px;972 margin: 0 px;973 border: 0 px;974 padding: 0 px;971 height: 0; 972 width: 0; 973 margin: 0; 974 border: 0; 975 padding: 0; 975 976 overflow: hidden; 976 977 position: absolute; … … 979 980 /* Box stuff */ 980 981 .dbx-clone { 981 position: absolute;982 visibility: hidden;982 position: absolute; 983 visibility: hidden; 983 984 <