WordPress.org

Make WordPress Core

Changes in trunk [3503:4431]


Ignore:
Location:
trunk
Files:
116 added
23 deleted
155 edited

Legend:

Unmodified
Added
Removed
  • trunk/readme.html

    r3503 r4431  
    22<html xmlns="http://www.w3.org/1999/xhtml">
    33<head>
    4 <title>WordPress &rsaquo; ReadMe</title>
    5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    6 <style type="text/css" media="screen">
    7     <!--
    8     html {
    9         background: #eee;
    10     }
    11     body {
    12         background: #fff;
    13         color: #000;
    14         font-family: Georgia, "Times New Roman", Times, serif;
    15         margin-left: 25%;
    16         margin-right: 25%;
    17         padding: .2em 2em;
    18     }
    19    
    20     h1 {
    21         color: #006;
    22         font-size: 18px;
    23         font-weight: lighter;
    24     }
    25    
    26     h2 {
    27         font-size: 16px;
    28     }
    29    
    30     p, li, dt {
    31         line-height: 140%;
    32         padding-bottom: 2px;
    33     }
    34 
    35     ul, ol {
    36         padding: 5px 5px 5px 20px;
    37     }
    38     -->
    39     </style>
     4    <title>WordPress &rsaquo; ReadMe</title>
     5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     6    <link rel="stylesheet" href="wp-admin/install.css" type="text/css" />
    407</head>
    418<body>
    42 <h1 style="text-align: center"><img alt="WordPress" src="http://wordpress.org/images/wordpress.gif" /> <br />
    43     Version 2.0</h1>
    44 <p style="text-align: center"> Semantic Personal Publishing Platform </p>
     9<h1 id="logo" style="text-align: center">
     10    <img alt="WordPress" src="wp-admin/images/wordpress-logo.png" />
     11    <br /> Version 2.1-ALPHA
     12</h1>
     13<p style="text-align: center">Semantic Personal Publishing Platform</p>
     14
    4515<h1>First Things First</h1>
    4616<p>Welcome. WordPress is a very special project to me. Every developer and contributor adds something unique to the mix, and together we create something beautiful that I'm proud to be a part of. Thousands of hours have gone into WordPress, and we're dedicated to making it better every day. Thank you for making it part of your world.</p>
    4717<p style="text-align: right;">&#8212; Matt Mullenweg </p>
    4818
    49 <h1 id="installation">Installation: Famous 5-minute install</h1>
     19<h1>Installation: Famous 5-minute install</h1>
    5020<ol>
    5121    <li>Unzip the package in an empty directory</li>
     
    6939<h2>Template Changes</h2>
    7040<p>If you have customized your templates you will probably have to make some changes to them. If you're converting your 1.2 or earlier templates, <a href="http://codex.wordpress.org/Upgrade_1.2_to_1.5">we've created a special guide for you</a>. </p>
     41
    7142<h1>Online Resources</h1>
    7243<p>If you have any questions that aren't addressed in this document, please take advantage of WordPress' numerous online resources:</p>
    7344<dl>
    7445    <dt><a href="http://codex.wordpress.org/">The WordPress Codex </a></dt>
    75     <dd>The Codex is the encyclopedia of all things WordPress. It is the most comprehensive source of information for WordPress available. </dd>
     46        <dd>The Codex is the encyclopedia of all things WordPress. It is the most comprehensive source of information for WordPress available. </dd>
    7647    <dt><a href="http://wordpress.org/development/">The Development Blog</a></dt>
    77     <dd>This is where you'll find the latest updates and news related to WordPress. Bookmark and check often. </dd>
     48        <dd>This is where you'll find the latest updates and news related to WordPress. Bookmark and check often. </dd>
    7849    <dt><a href="http://planet.wordpress.org/">WordPress Planet </a></dt>
    79     <dd>The WordPress Planet is a news aggregator that brings together posts from WordPress blogs around the web. </dd>
     50        <dd>The WordPress Planet is a news aggregator that brings together posts from WordPress blogs around the web. </dd>
    8051    <dt><a href="http://wordpress.org/support/">WordPress Support Forums</a></dt>
    81     <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>
     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>
    8253    <dt><a href="http://codex.wordpress.org/IRC">WordPress IRC Channel</a></dt>
    83     <dd>Finally, there is an online chat channel that is used for discussion amoung people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. (irc.freenode.net #wordpresss) </dd>
     54        <dd>Finally, there is an online chat channel that is used for discussion amoung people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. (irc.freenode.net #wordpresss) </dd>
    8455</dl>
    8556
    86 <h1 id="requirements">System Recommendations</h1>
     57<h1>System Recommendations</h1>
    8758<ul>
    8859    <li>PHP version <strong>4.1</strong> or higher</li>
     
    9566<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>
    9667
    97 <h1 id="templates">XML-RPC Interface</h1>
     68<h1>XML-RPC Interface</h1>
    9869<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>
    9970
    10071<h1>Post via Email</h1>
    101 <p>You can post from an email client! To set this up go to your &quot;Writing&quot; options screen and fill in the connection details for your secret POP3 account. Then you need to set up <code>wp-mail.php</code> to execute periodically to check the mailbox for new posts. You can do it with Cron-jobs, or if your host doesn't support it you can look into the various website-monitoring services, and make them check your <code>wp-mail.php</code> URL. </p>
    102 <p> Posting is easy: Any email sent to the address you specify will be posted, with the subject as the title. It is best to keep the address dicrete. The script will <i>delete</i> emails that are successfully posted. </p>
    103 <h1 id="roles">User Roles </h1>
     72<p>You can post from an email client! To set this up go to your &quot;Writing&quot; options screen and fill in the connection details for your secret POP3 account. Then you need to set up <code>wp-mail.php</code> to execute periodically to check the mailbox for new posts. You can do it with Cron-jobs, or if your host doesn't support it you can look into the various website-monitoring services, and make them check your <code>wp-mail.php</code> URL.</p>
     73<p>Posting is easy: Any email sent to the address you specify will be posted, with the subject as the title. It is best to keep the address dicrete. The script will <i>delete</i> emails that are successfully posted.</p>
    10474
     75<h1>User Roles</h1>
    10576<p>We've eliminated user levels in order to make way for the much more flexible roles system introduced in 2.0. You can <a href="http://codex.wordpress.org/Roles_and_Capabilities">read more about Roles and Capabilities on the Codex</a>.</p>
    10677
  • trunk/wp-admin/admin-db.php

    r3503 r4431  
    44    global $wpdb;
    55    $user_id = (int) $user_id;
    6     $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_id ORDER BY ID DESC";
     6    $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = $user_id ORDER BY ID DESC";
    77    $query = apply_filters('get_users_drafts', $query);
    88    return $wpdb->get_results( $query );
     
    1515
    1616    $editable = get_editable_user_ids( $user_id );
    17    
     17
    1818    if( !$editable ) {
    1919        $other_drafts = '';
    2020    } else {
    2121        $editable = join(',', $editable);
    22         $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author IN ($editable) AND post_author != '$user_id' ");
     22        $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author IN ($editable) AND post_author != '$user_id' ");
    2323    }
    2424
     
    3535    } else {
    3636        $editable = join(',', $editable);
    37         $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable)" );
     37        $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
    3838    }
    3939
     
    4343function get_editable_user_ids( $user_id, $exclude_zeros = true ) {
    4444    global $wpdb;
    45    
     45
    4646    $user = new WP_User( $user_id );
    47    
     47
    4848    if ( ! $user->has_cap('edit_others_posts') ) {
    4949        if ( $user->has_cap('edit_posts') || $exclude_zeros == false )
     
    5858    if ( $exclude_zeros )
    5959        $query .= " AND meta_value != '0'";
    60        
     60
    6161    return $wpdb->get_col( $query );
    6262}
     
    8484
    8585    extract($catarr);
     86
     87    if( trim( $cat_name ) == '' )
     88        return 0;
    8689
    8790    $cat_ID = (int) $cat_ID;
     
    9396        $update = false;
    9497
    95     $cat_name = wp_specialchars($cat_name);
    96 
     98    $cat_name = apply_filters('pre_category_name', $cat_name);
     99   
    97100    if (empty ($category_nicename))
    98101        $category_nicename = sanitize_title($cat_name);
    99102    else
    100103        $category_nicename = sanitize_title($category_nicename);
     104    $category_nicename = apply_filters('pre_category_nicename', $category_nicename);
    101105
    102106    if (empty ($category_description))
    103107        $category_description = '';
    104 
    105     if (empty ($category_parent))
     108    $category_description = apply_filters('pre_category_description', $category_description);
     109
     110    $category_parent = (int) $category_parent;
     111    if ( empty($category_parent) || !get_category( $category_parent ) || $category_parent == $cat_ID )
    106112        $category_parent = 0;
    107113
     114    if ( isset($posts_private) )
     115        $posts_private = (int) $posts_private;
     116    else
     117        $posts_private = 0;
     118
     119    if ( isset($links_private) )
     120        $links_private = (int) $links_private;
     121    else
     122        $links_private = 0;
     123
    108124    if (!$update) {
    109         $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent')");
     125        $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')");
    110126        $cat_ID = $wpdb->insert_id;
    111127    } else {
    112         $wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent' WHERE cat_ID = '$cat_ID'");
    113     }
    114    
     128        $wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private' WHERE cat_ID = '$cat_ID'");
     129    }
     130
    115131    if ( $category_nicename == '' ) {
    116132        $category_nicename = sanitize_title($cat_name, $cat_ID );
     
    154170
    155171    // Don't delete the default cat.
    156     if (1 == $cat_ID)
     172    if ( $cat_ID == get_option('default_category') )
     173        return 0;
     174
     175    if ( $cat_ID == get_option('default_link_category') )
    157176        return 0;
    158177
     
    162181
    163182    // Delete the category.
    164     $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'");
     183    if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") )
     184        return 0;
    165185
    166186    // Update children to point to new parent.
    167187    $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'");
    168188
    169     // TODO: Only set categories to general if they're not in another category already
    170     $wpdb->query("UPDATE $wpdb->post2cat SET category_id='1' WHERE category_id='$cat_ID'");
    171 
     189    // Only set posts and links to the default category if they're not in another category already.
     190    $default_cat = get_option('default_category');
     191    $posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'");
     192    if ( is_array($posts) ) foreach ($posts as $post_id) {
     193        $cats = wp_get_post_categories($post_id);
     194        if ( 1 == count($cats) )
     195            $cats = array($default_cat);
     196        else
     197            $cats = array_diff($cats, array($cat_ID));
     198        wp_set_post_categories($post_id, $cats);
     199    }
     200
     201    $default_link_cat = get_option('default_link_category');
     202    $links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'");
     203    if ( is_array($links) ) foreach ($links as $link_id) {
     204        $cats = wp_get_link_cats($link_id);
     205        if ( 1 == count($cats) )
     206            $cats = array($default_link_cat);
     207        else
     208            $cats = array_diff($cats, array($cat_ID));
     209        wp_set_link_cats($link_id, $cats);
     210    }
     211   
    172212    wp_cache_delete($cat_ID, 'category');
    173213    wp_cache_delete('all_category_ids', 'category');
     
    194234
    195235    if ($post_id)
    196         wp_set_post_cats('', $post_id, $cat_ids);
     236        wp_set_post_categories($post_id, $cat_ids);
    197237
    198238    return $cat_ids;
     
    230270
    231271    // FINALLY, delete user
     272    do_action('delete_user', $id);
     273
    232274    $wpdb->query("DELETE FROM $wpdb->users WHERE ID = $id");
    233275    $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$id'");
     
    236278    wp_cache_delete($user->user_login, 'userlogins');
    237279
    238     do_action('delete_user', $id);
    239 
    240280    return true;
    241281}
    242282
    243 function get_link($link_id, $output = OBJECT) {
    244     global $wpdb;
     283function wp_revoke_user($id) {
     284    $id = (int) $id;
    245285   
    246     $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = '$link_id'");
    247 
    248     if ( $output == OBJECT ) {
    249         return $link;
    250     } elseif ( $output == ARRAY_A ) {
    251         return get_object_vars($link);
    252     } elseif ( $output == ARRAY_N ) {
    253         return array_values(get_object_vars($link));
    254     } else {
    255         return $link;
    256     }
     286    $user = new WP_User($id);
     287    $user->remove_all_caps();   
    257288}
    258289
    259290function wp_insert_link($linkdata) {
    260291    global $wpdb, $current_user;
    261    
     292
    262293    extract($linkdata);
    263294
    264295    $update = false;
     296
    265297    if ( !empty($link_id) )
    266298        $update = true;
    267299
     300    if( trim( $link_name ) == '' )
     301        return 0;
     302    $link_name = apply_filters('pre_link_name', $link_name);
     303
     304    if( trim( $link_url ) == '' )
     305        return 0;
     306    $link_url = apply_filters('pre_link_url', $link_url);
     307
    268308    if ( empty($link_rating) )
    269         $link_rating = 0;   
     309        $link_rating = 0;
     310    else
     311        $link_rating = (int) $link_rating;
     312
     313    if ( empty($link_image) )
     314        $link_image = '';
     315    $link_image = apply_filters('pre_link_image', $link_image);
    270316
    271317    if ( empty($link_target) )
    272         $link_target = ''; 
     318        $link_target = '';
     319    $link_target = apply_filters('pre_link_target', $link_target);
    273320
    274321    if ( empty($link_visible) )
    275322        $link_visible = 'Y';
    276        
     323    $link_visibile = preg_replace('/[^YNyn]/', '', $link_visible);
     324
    277325    if ( empty($link_owner) )
    278326        $link_owner = $current_user->id;
     327    else
     328        $link_owner = (int) $link_owner;
    279329
    280330    if ( empty($link_notes) )
    281331        $link_notes = '';
     332    $link_notes = apply_filters('pre_link_notes', $link_notes);
     333
     334    if ( empty($link_description) )
     335        $link_description = '';
     336    $link_description = apply_filters('pre_link_description', $link_description);
     337
     338    if ( empty($link_rss) )
     339        $link_rss = '';
     340    $link_rss = apply_filters('pre_link_rss', $link_rss);
     341
     342    if ( empty($link_rel) )
     343        $link_rel = '';
     344    $link_rel = apply_filters('pre_link_rel', $link_rel);
     345
     346    // Make sure we set a valid category
     347    if (0 == count($link_category) || !is_array($link_category)) {
     348        $link_category = array(get_option('default_link_category'));
     349    }
    282350
    283351    if ( $update ) {
    284352        $wpdb->query("UPDATE $wpdb->links SET link_url='$link_url',
    285353            link_name='$link_name', link_image='$link_image',
    286             link_target='$link_target', link_category='$link_category',
     354            link_target='$link_target',
    287355            link_visible='$link_visible', link_description='$link_description',
    288356            link_rating='$link_rating', link_rel='$link_rel',
     
    290358            WHERE link_id='$link_id'");
    291359    } else {
    292         $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_category', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
     360        $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
    293361        $link_id = $wpdb->insert_id;
    294362    }
    295    
     363
     364    wp_set_link_cats($link_id, $link_category);
     365
    296366    if ( $update )
    297367        do_action('edit_link', $link_id);
     
    306376
    307377    $link_id = (int) $linkdata['link_id'];
    308    
     378
    309379    $link = get_link($link_id, ARRAY_A);
    310    
     380
    311381    // Escape data pulled from DB.
    312382    $link = add_magic_quotes($link);
    313    
     383
     384    // Passed link category list overwrites existing category list if not empty.
     385    if ( isset($linkdata['link_category']) && is_array($linkdata['link_category'])
     386             && 0 != count($linkdata['link_category']) )
     387        $link_cats = $linkdata['link_category'];
     388    else
     389        $link_cats = $link['link_category'];
     390
    314391    // Merge old and new fields with new fields overwriting old ones.
    315392    $linkdata = array_merge($link, $linkdata);
     393    $linkdata['link_category'] = $link_cats;
    316394
    317395    return wp_insert_link($linkdata);
     
    322400
    323401    do_action('delete_link', $link_id);
    324     return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'");
    325 }
     402   
     403    $categories = wp_get_link_cats($link_id);
     404    if( is_array( $categories ) ) {
     405        foreach ( $categories as $category ) {
     406            $wpdb->query("UPDATE $wpdb->categories SET link_count = link_count - 1 WHERE cat_ID = '$category'");
     407            wp_cache_delete($category, 'category');
     408        }
     409    }
     410
     411    $wpdb->query("DELETE FROM $wpdb->link2cat WHERE link_id = '$link_id'");
     412    return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'");
     413}
     414
     415function wp_get_link_cats($link_ID = 0) {
     416    global $wpdb;
     417
     418    $sql = "SELECT category_id
     419        FROM $wpdb->link2cat
     420        WHERE link_id = $link_ID
     421        ORDER BY category_id";
     422
     423    $result = $wpdb->get_col($sql);
     424
     425    if ( !$result )
     426        $result = array();
     427
     428    return array_unique($result);
     429}
     430
     431function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
     432    global $wpdb;
     433    // If $link_categories isn't already an array, make it one:
     434    if (!is_array($link_categories) || 0 == count($link_categories))
     435        $link_categories = array(get_option('default_link_category'));
     436
     437    $link_categories = array_unique($link_categories);
     438
     439    // First the old categories
     440    $old_categories = $wpdb->get_col("
     441        SELECT category_id
     442        FROM $wpdb->link2cat
     443        WHERE link_id = $link_ID");
     444
     445    if (!$old_categories) {
     446        $old_categories = array();
     447    } else {
     448        $old_categories = array_unique($old_categories);
     449    }
     450
     451    // Delete any?
     452    $delete_cats = array_diff($old_categories,$link_categories);
     453
     454    if ($delete_cats) {
     455        foreach ($delete_cats as $del) {
     456            $wpdb->query("
     457                DELETE FROM $wpdb->link2cat
     458                WHERE category_id = $del
     459                    AND link_id = $link_ID
     460                ");
     461        }
     462    }
     463
     464    // Add any?
     465    $add_cats = array_diff($link_categories, $old_categories);
     466
     467    if ($add_cats) {
     468        foreach ($add_cats as $new_cat) {
     469            $wpdb->query("
     470                INSERT INTO $wpdb->link2cat (link_id, category_id)
     471                VALUES ($link_ID, $new_cat)");
     472        }
     473    }
     474   
     475    // Update category counts.
     476    $all_affected_cats = array_unique(array_merge($link_categories, $old_categories));
     477    foreach ( $all_affected_cats as $cat_id ) {
     478        $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
     479        $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
     480        wp_cache_delete($cat_id, 'category');
     481    }
     482}   // wp_set_link_cats()
    326483
    327484function post_exists($title, $content = '', $post_date = '') {
  • trunk/wp-admin/admin-footer.php

    r3503 r4431  
    11
    2 <div id="footer"><p><a href="http://wordpress.org/" id="wordpress-logo"><img src="images/wordpress-logo.png" alt="WordPress" /></a></p>
    3 <p>
    4 <a href="http://codex.wordpress.org/"><?php _e('Documentation'); ?></a> &#8212; <a href="http://wordpress.org/support/"><?php _e('Support Forums'); ?></a> <br />
    5 <?php bloginfo('version'); ?> &#8212; <?php printf(__('%s seconds'), number_format(timer_stop(), 2)); ?>
    6 </p>
    7 
     2<div id="footer">
     3<p class="logo"><a href="http://wordpress.org/" id="wordpress-logo"><img src="images/wordpress-logo.png" alt="WordPress" /></a></p>
     4<p class="docs"><?php _e('<a href="http://codex.wordpress.org/">Documentation</a>'); ?> &#8212; <?php _e('<a href="http://wordpress.org/support/">Support Forums</a>'); ?><br />
     5<?php bloginfo('version'); ?> &#8212; <?php printf(__('%s seconds'), timer_stop(0, 2)); ?></p>
    86</div>
    97<?php do_action('admin_footer', ''); ?>
    108<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
    11 
    12 <?php
    13 if ( (substr(php_sapi_name(), 0, 3) == 'cgi') && spawn_pinger() ) {
    14     echo '<iframe id="pingcheck" src="' . get_settings('siteurl') .'/wp-admin/execute-pings.php?time=' . time() . '" style="border:none;width:1px;height:1px;"></iframe>';
    15 }
    16 ?>
    17 
    189</body>
    1910</html>
  • trunk/wp-admin/admin-functions.php

    r3503 r4431  
    11<?php
    22
     3function write_post() {
     4    $result = wp_write_post();
     5    if( is_wp_error($result) )
     6        wp_die( $result->get_error_message() );
     7    else
     8        return $result;
     9}
     10
    311// Creates a new post from the "Write Post" form using $_POST information.
    4 function write_post() {
     12function wp_write_post() {
    513    global $user_ID;
    614
    7     if (!current_user_can('edit_posts'))
    8         die(__('You are not allowed to create posts or drafts on this blog.'));
     15    if ( 'page' == $_POST['post_type'] ) {
     16        if ( !current_user_can('edit_pages') )
     17            return new WP_Error('edit_pages', __('You are not allowed to create pages on this blog.'));
     18    } else {
     19        if ( !current_user_can('edit_posts') )
     20            return new WP_Error('edit_posts', __('You are not allowed to create posts or drafts on this blog.'));
     21    }
    922
    1023    // Rename.
     
    1629    if (!empty ($_POST['post_author_override'])) {
    1730        $_POST['post_author'] = (int) $_POST['post_author_override'];
    18     } else
     31    } else {
    1932        if (!empty ($_POST['post_author'])) {
    2033            $_POST['post_author'] = (int) $_POST['post_author'];
     
    2336        }
    2437
    25     if (($_POST['post_author'] != $_POST['user_ID']) && !current_user_can('edit_others_posts'))
    26         die(__('You cannot post as this user.'));
     38    }
     39
     40    if ($_POST['post_author'] != $_POST['user_ID']) {
     41        if ( 'page' == $_POST['post_type'] ) {
     42            if ( !current_user_can('edit_others_pages') )
     43                return new WP_Error('edit_others_pages', __('You cannot create pages as this user.'));
     44        } else {
     45            if ( !current_user_can('edit_others_posts') )
     46                return new WP_Error('edit_others_posts', __('You cannot post as this user.'));
     47
     48        }
     49    }
    2750
    2851    // What to do based on which button they pressed
     
    3558    if ('' != $_POST['advanced'])
    3659        $_POST['post_status'] = 'draft';
    37     if ('' != $_POST['savepage'])
    38         $_POST['post_status'] = 'static';
    39 
    40     if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
     60
     61    if ( 'page' == $_POST['post_type'] ) {
     62        if ('publish' == $_POST['post_status'] && !current_user_can('publish_pages'))
     63            $_POST['post_status'] = 'draft';
     64    } else {
     65        if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
     66            $_POST['post_status'] = 'draft';
     67    }
     68
     69    if (!isset ($_POST['comment_status']))
     70        $_POST['comment_status'] = 'closed';
     71
     72    if (!isset ($_POST['ping_status']))
     73        $_POST['ping_status'] = 'closed';
     74
     75    if (!empty ($_POST['edit_date'])) {
     76        $aa = $_POST['aa'];
     77        $mm = $_POST['mm'];
     78        $jj = $_POST['jj'];
     79        $hh = $_POST['hh'];
     80        $mn = $_POST['mn'];
     81        $ss = $_POST['ss'];
     82        $jj = ($jj > 31) ? 31 : $jj;
     83        $hh = ($hh > 23) ? $hh -24 : $hh;
     84        $mn = ($mn > 59) ? $mn -60 : $mn;
     85        $ss = ($ss > 59) ? $ss -60 : $ss;
     86        $_POST['post_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss);
     87        $_POST['post_date_gmt'] = get_gmt_from_date($_POST['post_date']);
     88    }
     89
     90    // Create the post.
     91    $post_ID = wp_insert_post($_POST);
     92    add_meta($post_ID);
     93
     94    // Reunite any orphaned attachments with their parent
     95    if ( $_POST['temp_ID'] )
     96        relocate_children($_POST['temp_ID'], $post_ID);
     97
     98    // Now that we have an ID we can fix any attachment anchor hrefs
     99    fix_attachment_links($post_ID);
     100
     101    return $post_ID;
     102}
     103
     104// Move child posts to a new parent
     105function relocate_children($old_ID, $new_ID) {
     106    global $wpdb;
     107    $old_ID = (int) $old_ID;
     108    $new_ID = (int) $new_ID;
     109    return $wpdb->query("UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID");
     110}
     111
     112// Replace hrefs of attachment anchors with up-to-date permalinks.
     113function fix_attachment_links($post_ID) {
     114    global $wp_rewrite;
     115
     116    $post = & get_post($post_ID, ARRAY_A);
     117
     118    $search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie";
     119
     120    // See if we have any rel="attachment" links
     121    if ( 0 == preg_match_all($search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER) )
     122        return;
     123
     124    $i = 0;
     125    $search = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i";
     126    foreach ( $anchor_matches[0] as $anchor ) {
     127        if ( 0 == preg_match($search, $anchor, $id_matches) )
     128            continue;
     129
     130        $id = $id_matches[3];
     131
     132        // While we have the attachment ID, let's adopt any orphans.
     133        $attachment = & get_post($id, ARRAY_A);
     134        if ( ! empty($attachment) && ! is_object(get_post($attachment['post_parent'])) ) {
     135            $attachment['post_parent'] = $post_ID;
     136            // Escape data pulled from DB.
     137            $attachment = add_magic_quotes($attachment);
     138            wp_update_post($attachment);
     139        }
     140
     141        $post_search[$i] = $anchor;
     142        $post_replace[$i] = preg_replace("#href=(\"|')[^'\"]*\\1#e", "stripslashes('href=\\1').get_attachment_link($id).stripslashes('\\1')", $anchor);
     143        ++$i;
     144    }
     145
     146    $post['post_content'] = str_replace($post_search, $post_replace, $post['post_content']);
     147
     148    // Escape data pulled from DB.
     149    $post = add_magic_quotes($post);
     150
     151    return wp_update_post($post);
     152}
     153
     154// Update an existing post with values provided in $_POST.
     155function edit_post() {
     156    global $user_ID;
     157
     158    $post_ID = (int) $_POST['post_ID'];
     159
     160    if ( 'page' == $_POST['post_type'] ) {
     161        if ( !current_user_can('edit_page', $post_ID) )
     162            wp_die(__('You are not allowed to edit this page.'));
     163    } else {
     164        if ( !current_user_can('edit_post', $post_ID) )
     165            wp_die(__('You are not allowed to edit this post.'));
     166    }
     167
     168    // Rename.
     169    $_POST['ID'] = (int) $_POST['post_ID'];
     170    $_POST['post_content'] = $_POST['content'];
     171    $_POST['post_excerpt'] = $_POST['excerpt'];
     172    $_POST['post_parent'] = $_POST['parent_id'];
     173    $_POST['to_ping'] = $_POST['trackback_url'];
     174
     175    if (!empty ($_POST['post_author_override'])) {
     176        $_POST['post_author'] = (int) $_POST['post_author_override'];
     177    } else
     178        if (!empty ($_POST['post_author'])) {
     179            $_POST['post_author'] = (int) $_POST['post_author'];
     180        } else {
     181            $_POST['post_author'] = (int) $_POST['user_ID'];
     182        }
     183
     184    if ($_POST['post_author'] != $_POST['user_ID']) {
     185        if ( 'page' == $_POST['post_type'] ) {
     186            if ( !current_user_can('edit_others_pages') )
     187                wp_die(__('You cannot edit pages as this user.'));
     188        } else {
     189            if ( !current_user_can('edit_others_posts') )
     190                wp_die(__('You cannot edit posts as this user.'));
     191
     192        }
     193    }
     194
     195    // What to do based on which button they pressed
     196    if ('' != $_POST['saveasdraft'])
    41197        $_POST['post_status'] = 'draft';
    42 
    43     if ('static' == $_POST['post_status'] && !current_user_can('edit_pages'))
    44         die(__('This user cannot edit pages.'));
     198    if ('' != $_POST['saveasprivate'])
     199        $_POST['post_status'] = 'private';
     200    if ('' != $_POST['publish'])
     201        $_POST['post_status'] = 'publish';
     202    if ('' != $_POST['advanced'])
     203        $_POST['post_status'] = 'draft';
     204
     205    if ( 'page' == $_POST['post_type'] ) {
     206        if ('publish' == $_POST['post_status'] && !current_user_can('edit_published_pages'))
     207            $_POST['post_status'] = 'draft';
     208    } else {
     209        if ('publish' == $_POST['post_status'] && !current_user_can('edit_published_posts'))
     210            $_POST['post_status'] = 'draft';
     211    }
     212
     213    if (!isset ($_POST['comment_status']))
     214        $_POST['comment_status'] = 'closed';
     215
     216    if (!isset ($_POST['ping_status']))
     217        $_POST['ping_status'] = 'closed';
    45218
    46219    if (!empty ($_POST['edit_date'])) {
     
    59232    }
    60233
    61     // Create the post.
    62     $post_ID = wp_insert_post($_POST);
    63     add_meta($post_ID);
    64 
    65     // Reunite any orphaned attachments with their parent
    66     if ( $_POST['temp_ID'] )
    67         relocate_children($_POST['temp_ID'], $post_ID);
    68 
    69     // Now that we have an ID we can fix any attachment anchor hrefs
    70     fix_attachment_links($post_ID);
    71 
    72     return $post_ID;
    73 }
    74 
    75 // Move child posts to a new parent
    76 function relocate_children($old_ID, $new_ID) {
    77     global $wpdb;
    78     $old_ID = (int) $old_ID;
    79     $new_ID = (int) $new_ID;
    80     return $wpdb->query("UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID");
    81 }
    82 
    83 // Replace hrefs of attachment anchors with up-to-date permalinks.
    84 function fix_attachment_links($post_ID) {
    85     global $wp_rewrite;
    86 
    87     $post = & get_post($post_ID);
    88 
    89     $search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie";
    90 
    91     // See if we have any rel="attachment" links
    92     if ( 0 == preg_match_all($search, $post->post_content, $anchor_matches, PREG_PATTERN_ORDER) )
    93         return;
    94 
    95     $i = 0;
    96     $search = "# id=(\"|')p(\d+)\\1#i";
    97     foreach ( $anchor_matches[0] as $anchor ) {
    98         if ( 0 == preg_match($search, $anchor, $id_matches) )
    99             continue;
    100 
    101         $id = $id_matches[2];
    102 
    103         // While we have the attachment ID, let's adopt any orphans.
    104         $attachment = & get_post($id);
    105         if ( ! is_object(get_post($attachment->post_parent)) ) {
    106             $attachment->post_parent = $post_ID;
    107             wp_update_post($attachment);
    108         }
    109 
    110         $post_search[$i] = $anchor;
    111         $post_replace[$i] = preg_replace("#href=(\"|')[^'\"]*\\1#e", "stripslashes('href=\\1').get_attachment_link($id).stripslashes('\\1')", $anchor);
    112         ++$i;
    113     }
    114 
    115     $post->post_content = str_replace($post_search, $post_replace, $post->post_content);
    116 
    117     return wp_update_post($post);
    118 }
    119 
    120 // Update an existing post with values provided in $_POST.
    121 function edit_post() {
    122     global $user_ID;
    123 
    124     $post_ID = (int) $_POST['post_ID'];
    125 
    126     if (!current_user_can('edit_post', $post_ID))
    127         die(__('You are not allowed to edit this post.'));
    128 
    129     // Rename.
    130     $_POST['ID'] = (int) $_POST['post_ID'];
    131     $_POST['post_content'] = $_POST['content'];
    132     $_POST['post_excerpt'] = $_POST['excerpt'];
    133     $_POST['post_parent'] = $_POST['parent_id'];
    134     $_POST['to_ping'] = $_POST['trackback_url'];
    135 
    136     if (!empty ($_POST['post_author_override'])) {
    137         $_POST['post_author'] = (int) $_POST['post_author_override'];
    138     } else
    139         if (!empty ($_POST['post_author'])) {
    140             $_POST['post_author'] = (int) $_POST['post_author'];
    141         } else {
    142             $_POST['post_author'] = (int) $_POST['user_ID'];
    143         }
    144 
    145     if (($_POST['post_author'] != $_POST['user_ID']) && !current_user_can('edit_others_posts'))
    146         die(__('You cannot post as this user.'));
    147 
    148     // What to do based on which button they pressed
    149     if ('' != $_POST['saveasdraft'])
    150         $_POST['post_status'] = 'draft';
    151     if ('' != $_POST['saveasprivate'])
    152         $_POST['post_status'] = 'private';
    153     if ('' != $_POST['publish'])
    154         $_POST['post_status'] = 'publish';
    155     if ('' != $_POST['advanced'])
    156         $_POST['post_status'] = 'draft';
    157     if ('' != $_POST['savepage'])
    158         $_POST['post_status'] = 'static';
    159 
    160     if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
    161         $_POST['post_status'] = 'draft';
    162 
    163     if ('static' == $_POST['post_status'] && !current_user_can('edit_pages'))
    164         die(__('This user cannot edit pages.'));
    165 
    166     if (!isset ($_POST['comment_status']))
    167         $_POST['comment_status'] = 'closed';
    168 
    169     if (!isset ($_POST['ping_status']))
    170         $_POST['ping_status'] = 'closed';
    171 
    172     if (!empty ($_POST['edit_date'])) {
    173         $aa = $_POST['aa'];
    174         $mm = $_POST['mm'];
    175         $jj = $_POST['jj'];
    176         $hh = $_POST['hh'];
    177         $mn = $_POST['mn'];
    178         $ss = $_POST['ss'];
    179         $jj = ($jj > 31) ? 31 : $jj;
    180         $hh = ($hh > 23) ? $hh -24 : $hh;
    181         $mn = ($mn > 59) ? $mn -60 : $mn;
    182         $ss = ($ss > 59) ? $ss -60 : $ss;
    183         $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
    184         $_POST['post_date_gmt'] = get_gmt_from_date("$aa-$mm-$jj $hh:$mn:$ss");
    185     }
    186 
    187234    // Meta Stuff
    188235    if ($_POST['meta']) {
     
    190237            update_meta($key, $value['key'], $value['value']);
    191238    }
    192    
     239
    193240    if ($_POST['deletemeta']) {
    194241        foreach ($_POST['deletemeta'] as $key => $value)
     
    213260
    214261    if (!current_user_can('edit_post', $comment_post_ID))
    215         die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.'));
     262        wp_die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.'));
    216263
    217264    $_POST['comment_author'] = $_POST['newcomment_author'];
     
    241288// Get an existing post and format it for editing.
    242289function get_post_to_edit($id) {
    243     global $richedit;
    244     $richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false;
    245290
    246291    $post = get_post($id);
    247292
    248     $post->post_content = format_to_edit($post->post_content, $richedit);
     293    $post->post_content = format_to_edit($post->post_content, user_can_richedit());
    249294    $post->post_content = apply_filters('content_edit_pre', $post->post_content);
    250295
     
    255300    $post->post_title = apply_filters('title_edit_pre', $post->post_title);
    256301
    257     if ($post->post_status == 'static')
     302    $post->post_password = format_to_edit($post->post_password);
     303
     304    if ($post->post_type == 'page')
    258305        $post->page_template = get_post_meta($id, '_wp_page_template', true);
    259306
     
    287334
    288335    $post->post_status = 'draft';
    289     $post->comment_status = get_settings('default_comment_status');
    290     $post->ping_status = get_settings('default_ping_status');
    291     $post->post_pingback = get_settings('default_pingback_flag');
    292     $post->post_category = get_settings('default_category');
     336    $post->comment_status = get_option('default_comment_status');
     337    $post->ping_status = get_option('default_ping_status');
     338    $post->post_pingback = get_option('default_pingback_flag');
     339    $post->post_category = get_option('default_category');
    293340    $post->post_content = apply_filters('default_content', $post_content);
    294341    $post->post_title = apply_filters('default_title', $post_title);
     
    302349
    303350function get_comment_to_edit($id) {
    304     global $richedit;
    305     $richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false;
    306 
    307351    $comment = get_comment($id);
    308352
    309     $comment->comment_content = format_to_edit($comment->comment_content, $richedit);
     353    $comment->comment_content = format_to_edit($comment->comment_content, user_can_richedit());
    310354    $comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content);
    311355
     
    323367}
    324368
     369function wp_dropdown_roles( $default = false ) {
     370    global $wp_roles;
     371    $r = '';
     372    foreach($wp_roles->role_names as $role => $name)
     373        if ( $default == $role ) // Make default first in list
     374            $p = "\n\t<option selected='selected' value='$role'>$name</option>";
     375        else
     376            $r .= "\n\t<option value='$role'>$name</option>";
     377    echo $p . $r;
     378}
     379
     380
     381function get_user_to_edit($user_id) {
     382    $user = new WP_User($user_id);
     383    $user->user_login = wp_specialchars($user->user_login, 1);
     384    $user->user_email = wp_specialchars($user->user_email, 1);
     385    $user->user_url = wp_specialchars($user->user_url, 1);
     386    $user->first_name = wp_specialchars($user->first_name, 1);
     387    $user->last_name = wp_specialchars($user->last_name, 1);
     388    $user->display_name = wp_specialchars($user->display_name, 1);
     389    $user->nickname = wp_specialchars($user->nickname, 1);
     390    $user->aim = wp_specialchars($user->aim, 1);
     391    $user->yim = wp_specialchars($user->yim, 1);
     392    $user->jabber = wp_specialchars($user->jabber, 1);
     393    $user->description = wp_specialchars($user->description);
     394
     395    return $user;
     396}
     397
    325398// Creates a new user from the "Users" form using $_POST information.
    326399
    327400function add_user() {
    328     return edit_user();
     401    if ( func_num_args() ) { // The hackiest hack that ever did hack
     402        global $current_user, $wp_roles;
     403        $user_id = func_get_arg(0);
     404
     405        if (isset ($_POST['role'])) {
     406            if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users')) {
     407                $user = new WP_User($user_id);
     408                $user->set_role($_POST['role']);
     409            }
     410        }
     411    } else {
     412        add_action('user_register', 'add_user'); // See above
     413        return edit_user();
     414    }
    329415}
    330416
    331417function edit_user($user_id = 0) {
    332418    global $current_user, $wp_roles, $wpdb;
    333 
    334419    if ($user_id != 0) {
    335420        $update = true;
     
    351436        $pass2 = $_POST['pass2'];
    352437
    353     if (isset ($_POST['role'])) {
     438    if (isset ($_POST['role']) && current_user_can('edit_users')) {
    354439        if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users'))
    355440            $user->role = $_POST['role'];
     
    371456        $user->display_name = wp_specialchars(trim($_POST['display_name']));
    372457    if (isset ($_POST['description']))
    373         $user->description = wp_specialchars(trim($_POST['description']));
     458        $user->description = trim($_POST['description']);
    374459    if (isset ($_POST['jabber']))
    375460        $user->jabber = wp_specialchars(trim($_POST['jabber']));
     
    379464        $user->yim = wp_specialchars(trim($_POST['yim']));
    380465
    381     $errors = array ();
     466    $errors = new WP_Error();
    382467
    383468    /* checking that username has been typed */
    384469    if ($user->user_login == '')
    385         $errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.');
     470        $errors->add('user_login', __('<strong>ERROR</strong>: Please enter a username.'));
    386471
    387472    /* checking the password has been typed twice */
    388     do_action('check_passwords', array ($user->user_login, & $pass1, & $pass2));
     473    do_action_ref_array('check_passwords', array ($user->user_login, & $pass1, & $pass2));
    389474
    390475    if (!$update) {
    391476        if ($pass1 == '' || $pass2 == '')
    392             $errors['pass'] = __('<strong>ERROR</strong>: Please enter your password twice.');
     477            $errors->add('pass', __('<strong>ERROR</strong>: Please enter your password twice.'));
    393478    } else {
    394479        if ((empty ($pass1) && !empty ($pass2)) || (empty ($pass2) && !empty ($pass1)))
    395             $errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once.");
     480            $errors->add('pass', __("<strong>ERROR</strong>: you typed your new password only once."));
    396481    }
    397482
    398483    /* Check for "\" in password */
    399484    if( strpos( " ".$pass1, "\\" ) )
    400         $errors['pass'] = __('<strong>ERROR</strong>: Passwords may not contain the character "\\".');
     485        $errors->add('pass', __('<strong>ERROR</strong>: Passwords may not contain the character "\\".'));
    401486
    402487    /* checking the password has been typed twice the same */
    403488    if ($pass1 != $pass2)
    404         $errors['pass'] = __('<strong>ERROR</strong>: Please type the same password in the two password fields.');
     489        $errors->add('pass', __('<strong>ERROR</strong>: Please type the same password in the two password fields.'));
    405490
    406491    if (!empty ($pass1))
     
    408493
    409494    if ( !validate_username($user->user_login) )
    410         $errors['user_login'] = __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.');
     495        $errors->add('user_login', __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.'));
    411496
    412497    if (!$update && username_exists($user->user_login))
    413         $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
     498        $errors->add('user_login', __('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
    414499
    415500    /* checking e-mail address */
    416501    if (empty ($user->user_email)) {
    417         $errors['user_email'] = __("<strong>ERROR</strong>: please type an e-mail address");
     502        $errors->add('user_email', __("<strong>ERROR</strong>: please type an e-mail address"));
    418503    } else
    419504        if (!is_email($user->user_email)) {
    420             $errors['user_email'] = __("<strong>ERROR</strong>: the email address isn't correct");
    421         }
    422 
    423     if (count($errors) != 0)
     505            $errors->add('user_email', __("<strong>ERROR</strong>: the email address isn't correct"));
     506        }
     507
     508    if ( $errors->get_error_codes() )
    424509        return $errors;
    425510
     
    430515        wp_new_user_notification($user_id);
    431516    }
    432 
    433     return $errors;
     517    return $user_id;
    434518}
    435519
     
    437521function get_link_to_edit($link_id) {
    438522    $link = get_link($link_id);
    439    
     523
    440524    $link->link_url = wp_specialchars($link->link_url, 1);
    441525    $link->link_name = wp_specialchars($link->link_name, 1);
    442     $link->link_description = wp_specialchars($link->link_description);
     526    $link->link_image = wp_specialchars($link->link_image, 1);
     527    $link->link_description = wp_specialchars($link->link_description, 1);
    443528    $link->link_notes = wp_specialchars($link->link_notes);
    444     $link->link_rss = wp_specialchars($link->link_rss);
    445    
     529    $link->link_rss = wp_specialchars($link->link_rss, 1);
     530    $link->link_rel = wp_specialchars($link->link_rel, 1);
     531    $link->post_category = $link->link_category;
     532
    446533    return $link;
    447534}
     
    452539    else
    453540        $link->link_url = '';
    454    
     541
    455542    if ( isset($_GET['name']) )
    456543        $link->link_name = wp_specialchars($_GET['name'], 1);
    457544    else
    458545        $link->link_name = '';
    459        
     546
     547    $link->link_visible = 'Y';
     548
    460549    return $link;
    461550}
    462551
    463552function add_link() {
    464     return edit_link(); 
     553    return edit_link();
    465554}
    466555
    467556function edit_link($link_id = '') {
    468557    if (!current_user_can('manage_links'))
    469         die(__("Cheatin' uh ?"));
     558        wp_die(__("Cheatin' uh ?"));
    470559
    471560    $_POST['link_url'] = wp_specialchars($_POST['link_url']);
     
    474563    $_POST['link_image'] = wp_specialchars($_POST['link_image']);
    475564    $_POST['link_rss'] = wp_specialchars($_POST['link_rss']);
    476     $auto_toggle = get_autotoggle($_POST['link_category']);
    477    
    478     // if we are in an auto toggle category and this one is visible then we
    479     // need to make the others invisible before we add this new one.
    480     // FIXME Add category toggle func.
    481     //if (($auto_toggle == 'Y') && ($link_visible == 'Y')) {
    482     //  $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category");
    483     //}
     565    $_POST['link_category'] = $_POST['post_category'];
    484566
    485567    if ( !empty($link_id) ) {
     
    513595function return_categories_list($parent = 0) {
    514596    global $wpdb;
    515     return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC LIMIT 100");
     597    return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC");
    516598}
    517599
     
    521603
    522604function get_nested_categories($default = 0, $parent = 0) {
    523     global $post_ID, $mode, $wpdb;
     605    global $post_ID, $link_id, $mode, $wpdb;
    524606
    525607    if ($post_ID) {
     
    534616            $checked_categories[] = $default;
    535617        }
    536 
     618    } else if ($link_id) {
     619        $checked_categories = $wpdb->get_col("
     620             SELECT category_id
     621             FROM $wpdb->categories, $wpdb->link2cat
     622             WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'
     623             ");
     624
     625        if (count($checked_categories) == 0) {
     626            // No selected categories, strange
     627            $checked_categories[] = $default;
     628        }   
    537629    } else {
    538630        $checked_categories[] = $default;
     
    550642        }
    551643    }
    552    
     644
    553645    usort($result, 'sort_cats');
    554646
     
    558650function write_nested_categories($categories) {
    559651    foreach ($categories as $category) {
    560         echo '<label for="category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label>\n";
    561 
    562         if (isset ($category['children'])) {
    563             echo "\n<span class='cat-nest'>\n";
     652        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>\n";
     653
     654        if ( $category['children'] ) {
     655            echo "<ul>\n";
    564656            write_nested_categories($category['children']);
    565             echo "</span>\n";
     657            echo "</ul>\n";
    566658        }
    567659    }
     
    572664}
    573665
     666function return_link_categories_list($parent = 0) {
     667    global $wpdb;
     668    return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC");
     669}
     670
     671function get_nested_link_categories( $default = 0, $parent = 0 ) {
     672    global $post_ID, $link_id, $mode, $wpdb;
     673
     674    if ($link_id) {
     675        $checked_categories = $wpdb->get_col("
     676             SELECT category_id
     677             FROM $wpdb->categories, $wpdb->link2cat
     678             WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'
     679             ");
     680
     681        if (count($checked_categories) == 0) {
     682            // No selected categories, strange
     683            $checked_categories[] = $default;
     684        }   
     685    } else {
     686        $checked_categories[] = $default;
     687    }
     688
     689    $cats = return_link_categories_list($parent);
     690    $result = array ();
     691
     692    if (is_array($cats)) {
     693        foreach ($cats as $cat) {
     694            $result[$cat]['children'] = get_nested_link_categories($default, $cat);
     695            $result[$cat]['cat_ID'] = $cat;
     696            $result[$cat]['checked'] = in_array($cat, $checked_categories);
     697            $result[$cat]['cat_name'] = get_the_category_by_ID($cat);
     698        }
     699    }
     700
     701    usort($result, 'sort_cats');
     702
     703    return $result;
     704}
     705
     706function dropdown_link_categories($default = 0) {
     707    write_nested_categories(get_nested_link_categories($default));
     708}
     709
    574710// Dandy new recursive multiple category stuff.
    575711function cat_rows($parent = 0, $level = 0, $categories = 0) {
    576     global $wpdb, $class;
    577 
    578712    if (!$categories)
    579         $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
     713        $categories = get_categories('hide_empty=0');
    580714
    581715    if ($categories) {
    582716        foreach ($categories as $category) {
    583717            if ($category->category_parent == $parent) {
    584                 $category->cat_name = wp_specialchars($category->cat_name);
    585                 $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
    586                 $pad = str_repeat('&#8212; ', $level);
    587                 if ( current_user_can('manage_categories') ) {
    588                     $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>";
    589                     $default_cat_id = get_option('default_category');
    590                    
    591                     if ($category->cat_ID != $default_cat_id)
    592                         $edit .= "<td><a href='categories.php?action=delete&amp;cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category &quot;%s&quot;.  All of its posts will go to the default category.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars($category->cat_name, 1))."' );\" class='delete'>".__('Delete')."</a>";
    593                     else
    594                         $edit .= "<td style='text-align:center'>".__("Default");
    595                 }
    596                 else
    597                     $edit = '';
    598 
    599                 $class = ('alternate' == $class) ? '' : 'alternate';
    600                 echo "<tr id='cat-$category->cat_ID' class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td>
    601                                 <td>$category->category_description</td>
    602                                 <td>$count</td>
    603                                 <td>$edit</td>
    604                                 </tr>";
     718                echo "\t" . _cat_row( $category, $level );
    605719                cat_rows($category->cat_ID, $level +1, $categories);
    606720            }
     
    611725}
    612726
    613 function page_rows($parent = 0, $level = 0, $pages = 0) {
     727function _cat_row( $category, $level, $name_override = false ) {
     728    global $class;
     729
     730    $pad = str_repeat('&#8212; ', $level);
     731    if ( current_user_can('manage_categories') ) {
     732        $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>";
     733        $default_cat_id = get_option('default_category');
     734        $default_link_cat_id = get_option('default_link_category');
     735
     736        if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) )
     737            $edit .= "<td><a href='" . wp_nonce_url("categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . sprintf(__("You are about to delete the category &quot;%s&quot;.\\nAll of its posts will go into the default category of &quot;%s&quot;\\nAll of its bookmarks will go into the default category of &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), js_escape($category->cat_name), js_escape(get_catname($default_cat_id)), js_escape(get_catname($default_link_cat_id))) . "' );\" class='delete'>".__('Delete')."</a>";
     738        else
     739            $edit .= "<td style='text-align:center'>".__("Default");
     740    } else
     741        $edit = '';
     742
     743    $class = ( ( defined('DOING_AJAX') && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
     744
     745    $category->category_count = number_format( $category->category_count );
     746    $category->link_count = number_format( $category->link_count );
     747    return "<tr id='cat-$category->cat_ID'$class>
     748        <th scope='row' style='text-align: center'>$category->cat_ID</th>
     749        <td>" . ( $name_override ? $name_override : $pad . ' ' . $category->cat_name ) . "</td>
     750        <td>$category->category_description</td>
     751        <td align='center'>$category->category_count</td>
     752        <td align='center'>$category->link_count</td>
     753        <td>$edit</td>\n\t</tr>\n";
     754}
     755
     756function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) {
    614757    global $wpdb, $class, $post;
     758
    615759    if (!$pages)
    616         $pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' ORDER BY menu_order");
    617 
    618     if ($pages) {
    619         foreach ($pages as $post) {
    620             start_wp();
    621             if ($post->post_parent == $parent) {
    622                 $post->post_title = wp_specialchars($post->post_title);
    623                 $pad = str_repeat('&#8212; ', $level);
    624                 $id = $post->ID;
    625                 $class = ('alternate' == $class) ? '' : 'alternate';
     760        $pages = get_pages('sort_column=menu_order');
     761
     762    if (! $pages)
     763        return false;
     764
     765    foreach ($pages as $post) {
     766        setup_postdata($post);
     767        if ( $hierarchy && ($post->post_parent != $parent) )
     768            continue;
     769
     770        $post->post_title = wp_specialchars($post->post_title);
     771        $pad = str_repeat('&#8212; ', $level);
     772        $id = $post->ID;
     773        $class = ('alternate' == $class) ? '' : 'alternate';
    626774?>
    627775  <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
    628     <th scope="row"><?php echo $post->ID; ?></th>
     776    <th scope="row" style="text-align: center"><?php echo $post->ID; ?></th>
    629777    <td>
    630       <?php echo $pad; ?><?php the_title() ?>
     778      <?php echo $pad; ?><?php the_title() ?>
     779      <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?>
    631780    </td>
    632781    <td><?php the_author() ?></td>
    633782    <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td>
    634783    <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
    635     <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
    636     <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td>
     784    <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
     785    <td><?php if ( current_user_can('delete_page', $id) ) { echo "<a href='" . wp_nonce_url("page.php?action=delete&amp;post=$id", 'delete-page_' . $id) .  "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), js_escape(get_the_title()) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
    637786  </tr>
    638787
    639788<?php
    640 
    641                 page_rows($id, $level +1, $pages);
    642             }
    643         }
    644     } else {
    645         return false;
    646     }
     789        if ( $hierarchy) page_rows($id, $level + 1, $pages);
     790    }
     791}
     792
     793function user_row( $user_object, $style = '' ) {
     794    if ( !(is_object($user_object) && is_a($user_object, 'WP_User')) )
     795        $user_object = new WP_User( (int) $user_object );
     796    $email = $user_object->user_email;
     797    $url = $user_object->user_url;
     798    $short_url = str_replace('http://', '', $url);
     799    $short_url = str_replace('www.', '', $short_url);
     800    if ('/' == substr($short_url, -1))
     801        $short_url = substr($short_url, 0, -1);
     802    if (strlen($short_url) > 35)
     803        $short_url =  substr($short_url, 0, 32).'...';
     804    $numposts = get_usernumposts($user_object->ID);
     805    $r = "<tr id='user-$user_object->ID'$style>
     806        <td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td>
     807        <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td>
     808        <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td>
     809        <td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td>
     810        <td><a href='$url' title='website: $url'>$short_url</a></td>";
     811    $r .= "\n\t\t<td align='center'>";
     812    if ($numposts > 0) {
     813        $r .= "<a href='edit.php?author=$user_object->ID' title='" . __('View posts by this author') . "' class='edit'>";
     814        $r .= sprintf(__('View %1$s %2$s'), $numposts, __ngettext('post', 'posts', $numposts));
     815    }
     816    $r .= "</td>\n\t\t<td>";
     817    $edit_link = add_query_arg('wp_http_referer', wp_specialchars(urlencode(stripslashes($_SERVER['REQUEST_URI']))), "user-edit.php?user_id=$user_object->ID");
     818    if ( current_user_can('edit_user', $user_object->ID) )
     819        $r .= "<a href='$edit_link' class='edit'>".__('Edit')."</a>";
     820    $r .= "</td>\n\t</tr>";
     821    return $r;
    647822}
    648823
    649824function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) {
    650     global $wpdb, $bgcolor;
    651     if (!$categories) {
    652         $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
    653     }
     825    global $wpdb;
     826    if (!$categories)
     827        $categories = get_categories('hide_empty=0');
     828
    654829    if ($categories) {
    655830        foreach ($categories as $category) {
    656831            if ($currentcat != $category->cat_ID && $parent == $category->category_parent) {
    657                 $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
    658832                $pad = str_repeat('&#8211; ', $level);
    659833                $category->cat_name = wp_specialchars($category->cat_name);
     
    668842        return false;
    669843    }
    670 }
    671 
    672 function link_category_dropdown($fieldname, $selected = 0) {
    673     global $wpdb;
    674    
    675     $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
    676     echo "\n<select name='$fieldname' size='1'>\n";
    677     foreach ($results as $row) {
    678         echo "\n\t<option value='$row->cat_id'";
    679         if ($row->cat_id == $selected)
    680             echo " selected='selected'";
    681         echo ">$row->cat_id : " . wp_specialchars($row->cat_name);
    682         if ($row->auto_toggle == 'Y')
    683             echo ' (auto toggle)';
    684         echo "</option>";
    685     }
    686     echo "\n</select>\n";
    687844}
    688845
     
    777934        return $error;
    778935    } else {
     936        apply_filters( 'wp_create_thumbnail', $thumbpath );
    779937        return $thumbpath;
    780938    }
     
    796954    global $post_ID;
    797955    // Exit if no meta
    798     if (!$meta)
     956    if (!$meta) {
     957        echo '<tbody id="the-list"><tr style="display: none;"><td>&nbsp;</td></tr></tbody>'; //TBODY needed for list-manipulation JS
    799958        return;
     959    }
    800960    $count = 0;
    801961?>
    802 <table id='meta-list' cellpadding="3">
     962    <thead>
    803963    <tr>
    804964        <th><?php _e('Key') ?></th>
     
    806966        <th colspan='2'><?php _e('Action') ?></th>
    807967    </tr>
     968    </thead>
    808969<?php
    809 
    810 
     970    $r ="\n\t<tbody id='the-list'>";
    811971    foreach ($meta as $entry) {
    812972        ++ $count;
     
    817977        if ('_' == $entry['meta_key'] { 0 })
    818978            $style .= ' hidden';
    819         echo "
    820             <tr class='$style'>
    821                 <td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>
    822                 <td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>
    823                 <td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br />
    824                 <input name='deletemeta[{$entry['meta_id']}]' type='submit' class='deletemeta' tabindex='6' value='".__('Delete')."' /></td>
    825             </tr>
    826         ";
    827     }
    828     echo "
    829         </table>
    830     ";
     979
     980        if ( is_serialized($entry['meta_value']) ) {
     981            if ( is_serialized_string($entry['meta_value']) ) {
     982                // this is a serialized string, so we should display it
     983                $entry['meta_value'] = maybe_unserialize($entry['meta_value']);
     984            } else {
     985                // this is a serialized array/object so we should NOT display it
     986                --$count;
     987                continue;
     988            }
     989        }
     990
     991        $key_js = js_escape($entry['meta_key']);
     992        $entry['meta_key'] = wp_specialchars( $entry['meta_key'], true );
     993        $entry['meta_value'] = wp_specialchars( $entry['meta_value'], true );
     994        $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
     995        $r .= "\n\t\t<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>";
     996        $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>";
     997        $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br />";
     998        $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '";
     999        $r .= sprintf(__("You are about to delete the &quot;%s&quot; custom field on this post.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), $key_js);
     1000        $r .= "' );\" class='deletemeta' tabindex='6' value='".__('Delete')."' /></td>";
     1001        $r .= "\n\t</tr>";
     1002    }
     1003    echo $r;
     1004    echo "\n\t</tbody>";
    8311005}
    8321006
     
    8461020function meta_form() {
    8471021    global $wpdb;
     1022    $limit = (int) apply_filters('postmeta_form_limit', 30);
    8481023    $keys = $wpdb->get_col("
    849             SELECT meta_key
    850             FROM $wpdb->postmeta
    851             GROUP BY meta_key
    852             ORDER BY meta_id DESC
    853             LIMIT 10");
     1024        SELECT meta_key
     1025        FROM $wpdb->postmeta
     1026        GROUP BY meta_key
     1027        ORDER BY meta_id DESC
     1028        LIMIT $limit");
     1029    natcasesort($keys);
    8541030?>
    8551031<h3><?php _e('Add a new custom field:') ?></h3>
    856 <table cellspacing="3" cellpadding="3">
     1032<table id="newmeta" cellspacing="3" cellpadding="3">
    8571033    <tr>
    8581034<th colspan="2"><?php _e('Key') ?></th>
     
    8611037    <tr valign="top">
    8621038        <td align="right" width="18%">
    863 <?php if ($keys) : ?>
     1039<?php if ( $keys ) : ?>
    8641040<select id="metakeyselect" name="metakeyselect" tabindex="7">
    8651041<option value="#NONE#"><?php _e('- Select -'); ?></option>
    8661042<?php
    8671043
    868     foreach ($keys as $key) {
     1044    foreach ( $keys as $key ) {
     1045        $key = wp_specialchars($key, 1);
    8691046        echo "\n\t<option value='$key'>$key</option>";
    8701047    }
     
    8781055
    8791056</table>
    880 <p class="submit"><input type="submit" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field &raquo;') ?>" /></p>
     1057<p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field &raquo;') ?>" /></p>
    8811058<?php
    8821059
     
    8851062function add_meta($post_ID) {
    8861063    global $wpdb;
     1064    $post_ID = (int) $post_ID;
    8871065
    8881066    $metakeyselect = $wpdb->escape(stripslashes(trim($_POST['metakeyselect'])));
    8891067    $metakeyinput = $wpdb->escape(stripslashes(trim($_POST['metakeyinput'])));
    890     $metavalue = $wpdb->escape(stripslashes(trim($_POST['metavalue'])));
     1068    $metavalue = maybe_serialize(stripslashes((trim($_POST['metavalue']))));
     1069    $metavalue = $wpdb->escape($metavalue);
    8911070
    8921071    if ( ('0' === $metavalue || !empty ($metavalue)) && ((('#NONE#' != $metakeyselect) && !empty ($metakeyselect)) || !empty ($metakeyinput)) ) {
     
    8941073        // input for the key have data, the input takes precedence:
    8951074
    896         if ('#NONE#' != $metakeyselect)
     1075        if ('#NONE#' != $metakeyselect)
    8971076            $metakey = $metakeyselect;
    8981077
     
    9051084                        VALUES ('$post_ID','$metakey','$metavalue')
    9061085                    ");
    907     }
     1086        return $wpdb->insert_id;
     1087    }
     1088    return false;
    9081089} // add_meta
    9091090
    9101091function delete_meta($mid) {
    9111092    global $wpdb;
    912 
    913     $result = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");
     1093    $mid = (int) $mid;
     1094
     1095    return $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");
    9141096}
    9151097
    9161098function update_meta($mid, $mkey, $mvalue) {
    9171099    global $wpdb;
    918 
     1100    $mvalue = maybe_serialize(stripslashes($mvalue));
     1101    $mvalue = $wpdb->escape($mvalue);
     1102    $mid = (int) $mid;
    9191103    return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'");
    9201104}
    9211105
     1106function get_post_meta_by_id($mid) {
     1107    global $wpdb;
     1108    $mid = (int) $mid;
     1109
     1110    $meta = $wpdb->get_row("SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'");
     1111    if ( is_serialized_string($meta->meta_value) )
     1112        $meta->meta_value = maybe_unserialize($meta->meta_value);
     1113    return $meta;
     1114}
     1115
    9221116function touch_time($edit = 1, $for_post = 1) {
    923     global $month, $post, $comment;
     1117    global $wp_locale, $post, $comment;
    9241118
    9251119    if ( $for_post )
     
    9281122    echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__('Edit timestamp').'</label></legend>';
    9291123
    930     $time_adj = time() + (get_settings('gmt_offset') * 3600);
     1124    $time_adj = time() + (get_option('gmt_offset') * 3600);
    9311125    $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
    9321126    $jj = ($edit) ? mysql2date('d', $post_date) : gmdate('d', $time_adj);
     
    9371131    $ss = ($edit) ? mysql2date('s', $post_date) : gmdate('s', $time_adj);
    9381132
    939     echo "<select name=\"mm\">\n";
     1133    echo "<select name=\"mm\" onchange=\"edit_date.checked=true\">\n";
    9401134    for ($i = 1; $i < 13; $i = $i +1) {
    9411135        echo "\t\t\t<option value=\"$i\"";
    9421136        if ($i == $mm)
    943             echo " selected='selected'";
    944         if ($i < 10) {
    945             $ii = "0".$i;
    946         } else {
    947             $ii = "$i";
    948         }
    949         echo ">".$month["$ii"]."</option>\n";
     1137            echo ' selected="selected"';
     1138        echo '>' . $wp_locale->get_month($i) . "</option>\n";
    9501139    }
    9511140?>
    9521141</select>
    953 <input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" />
    954 <input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" /> @
    955 <input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" /> :
    956 <input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" />
    957 <input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />
     1142<input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" onchange="edit_date.checked=true"/>
     1143<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" onchange="edit_date.checked=true" /> @
     1144<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> :
     1145<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
     1146<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
    9581147<?php
    9591148    if ( $edit ) {
    9601149        _e('Existing timestamp');
    961         echo ": {$month[$mm]} $jj, $aa @ $hh:$mn";
     1150        //echo ': ' . $wp_locale->get_month($mm) . "$jj, $aa @ $hh:$mn";
     1151        echo sprintf(__(': %1$s %2$s, %3$s @ %4$s:%5$s'), $wp_locale->get_month($mm), $jj, $aa, $hh, $mn);
    9621152    }
    9631153?>
     
    9841174        if ($markerdata) {
    9851175            $state = true;
    986             foreach ($markerdata as $markerline) {
     1176            foreach ($markerdata as $n => $markerline) {
    9871177                if (strstr($markerline, "# BEGIN {$marker}"))
    9881178                    $state = false;
    989                 if ($state)
    990                     fwrite($f, "{$markerline}\n");
     1179                if ($state) {
     1180                    if ( $n + 1 < count($markerdata) )
     1181                        fwrite($f, "{$markerline}\n");
     1182                    else
     1183                        fwrite($f, "{$markerline}");
     1184                }
    9911185                if (strstr($markerline, "# END {$marker}")) {
    9921186                    fwrite($f, "# BEGIN {$marker}\n");
     
    10711265}
    10721266
    1073 function the_quicktags() {
    1074     // Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP
    1075     if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Safari'))
    1076         echo '
    1077         <div id="quicktags">
    1078             <script src="../wp-includes/js/quicktags.js" type="text/javascript"></script>
    1079             <script type="text/javascript">if ( typeof tinyMCE == "undefined" || tinyMCE.configs.length < 1 ) edToolbar();</script>
    1080         </div>
    1081 ';
    1082     else echo '
    1083 <script type="text/javascript">
    1084 function edInsertContent(myField, myValue) {
    1085     //IE support
    1086     if (document.selection) {
    1087         myField.focus();
    1088         sel = document.selection.createRange();
    1089         sel.text = myValue;
    1090         myField.focus();
    1091     }
    1092     //MOZILLA/NETSCAPE support
    1093     else if (myField.selectionStart || myField.selectionStart == "0") {
    1094         var startPos = myField.selectionStart;
    1095         var endPos = myField.selectionEnd;
    1096         myField.value = myField.value.substring(0, startPos)
    1097                       + myValue
    1098                       + myField.value.substring(endPos, myField.value.length);
    1099         myField.focus();
    1100         myField.selectionStart = startPos + myValue.length;
    1101         myField.selectionEnd = startPos + myValue.length;
    1102     } else {
    1103         myField.value += myValue;
    1104         myField.focus();
    1105     }
    1106 }
    1107 </script>
    1108 ';
    1109 }
    1110 
    1111 function validate_current_theme() {
    1112     $theme_loc = 'wp-content/themes';
    1113     $theme_root = ABSPATH.$theme_loc;
    1114 
    1115     $template = get_settings('template');
    1116     $stylesheet = get_settings('stylesheet');
    1117 
    1118     if (($template != 'default') && (!file_exists("$theme_root/$template/index.php"))) {
    1119         update_option('template', 'default');
    1120         update_option('stylesheet', 'default');
    1121         do_action('switch_theme', 'Default');
    1122         return false;
    1123     }
    1124 
    1125     if (($stylesheet != 'default') && (!file_exists("$theme_root/$stylesheet/style.css"))) {
    1126         update_option('template', 'default');
    1127         update_option('stylesheet', 'default');
    1128         do_action('switch_theme', 'Default');
    1129         return false;
    1130     }
    1131 
    1132     return true;
    1133 }
    1134 
    11351267function get_broken_themes() {
    11361268    global $wp_broken_themes;
     
    11771309function parent_dropdown($default = 0, $parent = 0, $level = 0) {
    11781310    global $wpdb, $post_ID;
    1179     $items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_status = 'static' ORDER BY menu_order");
     1311    $items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order");
    11801312
    11811313    if ($items) {
     
    12051337    global $menu;
    12061338    global $submenu;
     1339    global $_wp_menu_nopriv;
     1340    global $_wp_submenu_nopriv;
     1341    global $plugin_page;
    12071342
    12081343    $parent = get_admin_page_parent();
    1209 
    1210     foreach ($menu as $menu_array) {
    1211         //echo "parent array: " . $menu_array[2];
    1212         if ($menu_array[2] == $parent) {
    1213             if (!current_user_can($menu_array[1])) {
     1344    /*echo "pa: $parent pn: $pagenow pp: $plugin_page<br/>";
     1345    echo "<pre>";
     1346    print_r($_wp_menu_nopriv);
     1347    print_r($_wp_submenu_nopriv);
     1348    echo "</pre>";*/
     1349    if ( isset($_wp_submenu_nopriv[$parent][$pagenow]) )
     1350        return false;
     1351
     1352    if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$parent][$plugin_page]) )
     1353        return false;
     1354   
     1355    if ( empty($parent) ) {
     1356        if ( isset($_wp_menu_nopriv[$pagenow]) )
     1357            return false;
     1358        if ( isset($_wp_submenu_nopriv[$pagenow][$pagenow]) )
     1359            return false;
     1360        if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$pagenow][$plugin_page]) )
     1361            return false;
     1362        foreach (array_keys($_wp_submenu_nopriv) as $key) {
     1363            if ( isset($_wp_submenu_nopriv[$key][$pagenow]) )
    12141364                return false;
    1215             } else {
    1216                 break;
    1217             }
    1218         }
     1365            if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$key][$plugin_page]) )
     1366            return false;   
     1367        }
     1368        return true;
    12191369    }
    12201370
     
    12221372        foreach ($submenu[$parent] as $submenu_array) {
    12231373            if ($submenu_array[2] == $pagenow) {
    1224                 if (!current_user_can($submenu_array[1])) {
     1374                if (current_user_can($submenu_array[1]))
     1375                    return true;
     1376                else
    12251377                    return false;
    1226                 } else {
    1227                     return true;
    1228                 }
    12291378            }
    12301379        }
    12311380    }
    12321381
     1382    foreach ($menu as $menu_array) {
     1383        if ($menu_array[2] == $parent) {
     1384            if (current_user_can($menu_array[1]))
     1385                return true;
     1386            else
     1387                return false;
     1388        }
     1389    }
     1390   
    12331391    return true;
    12341392}
     
    12871445    global $pagenow;
    12881446    global $plugin_page;
    1289 
    1290     if (isset ($parent_file) && !empty ($parent_file)) {
     1447    global $_wp_real_parent_file;
     1448    global $_wp_menu_nopriv;
     1449    global $_wp_submenu_nopriv;
     1450
     1451    if ( !empty ($parent_file) ) {
     1452        if ( isset($_wp_real_parent_file[$parent_file]) )
     1453            $parent_file = $_wp_real_parent_file[$parent_file];
     1454
    12911455        return $parent_file;
    12921456    }
     
    12961460            if ($parent_menu[2] == $plugin_page) {
    12971461                $parent_file = $plugin_page;
    1298                 return $plugin_page;
     1462                if ( isset($_wp_real_parent_file[$parent_file]) )
     1463                    $parent_file = $_wp_real_parent_file[$parent_file];
     1464                return $parent_file;
    12991465            }
    13001466        }
     1467        if ( isset($_wp_menu_nopriv[$plugin_page]) ) {
     1468            $parent_file = $plugin_page;
     1469            if ( isset($_wp_real_parent_file[$parent_file]) )
     1470                    $parent_file = $_wp_real_parent_file[$parent_file];
     1471            return $parent_file;
     1472        }           
     1473    }
     1474
     1475    if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$pagenow][$plugin_page]) ) {
     1476        $parent_file = $pagenow;
     1477        if ( isset($_wp_real_parent_file[$parent_file]) )
     1478            $parent_file = $_wp_real_parent_file[$parent_file];
     1479        return $parent_file;       
    13011480    }
    13021481
    13031482    foreach (array_keys($submenu) as $parent) {
    13041483        foreach ($submenu[$parent] as $submenu_array) {
     1484            if ( isset($_wp_real_parent_file[$parent]) )
     1485                $parent = $_wp_real_parent_file[$parent];
    13051486            if ($submenu_array[2] == $pagenow) {
    13061487                $parent_file = $parent;
     
    13371518    global $submenu;
    13381519    global $menu;
     1520    global $_wp_real_parent_file;
     1521    global $_wp_submenu_nopriv;
     1522    global $_wp_menu_nopriv;
     1523
     1524    $file = plugin_basename($file);
    13391525
    13401526    $parent = plugin_basename($parent);
    1341     $file = plugin_basename($file);
     1527    if ( isset($_wp_real_parent_file[$parent]) )
     1528        $parent = $_wp_real_parent_file[$parent];
     1529
     1530    if ( !current_user_can($access_level) ) {
     1531        $_wp_submenu_nopriv[$parent][$file] = true;
     1532        return false;
     1533    }
    13421534
    13431535    // If the parent doesn't already have a submenu, add a link to the parent
     
    13451537    // parent file someone is trying to link back to the parent manually.  In
    13461538    // this case, don't automatically add a link back to avoid duplication.
    1347     if (!isset ($submenu[$parent]) && $file != $parent) {
     1539    if (!isset ($submenu[$parent]) && $file != $parent  ) {
    13481540        foreach ($menu as $parent_menu) {
    1349             if ($parent_menu[2] == $parent) {
     1541            if ( $parent_menu[2] == $parent && current_user_can($parent_menu[1]) ) {
    13501542                $submenu[$parent][] = $parent_menu;
    13511543            }
     
    13971589    switch ($code) {
    13981590        case 1 :
    1399             die(__('Sorry, can&#8217;t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'));
     1591            wp_die(__('Sorry, can&#8217;t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'));
    14001592
    14011593        case 2 :
    1402             die(__('Sorry, can&#8217;t call files with their real path.'));
     1594            wp_die(__('Sorry, can&#8217;t call files with their real path.'));
    14031595
    14041596        case 3 :
    1405             die(__('Sorry, that file cannot be edited.'));
     1597            wp_die(__('Sorry, that file cannot be edited.'));
    14061598    }
    14071599}
    14081600
    14091601function get_home_path() {
    1410     $home = get_settings('home');
    1411     if ($home != '' && $home != get_settings('siteurl')) {
     1602    $home = get_option('home');
     1603    if ($home != '' && $home != get_option('siteurl')) {
    14121604        $home_path = parse_url($home);
    14131605        $home_path = $home_path['path'];
     
    14411633        return $wp_file_descriptions[basename($file)];
    14421634    }
    1443     elseif (file_exists(ABSPATH.$file)) {
    1444         $template_data = implode('', file(ABSPATH.$file));
     1635    elseif ( file_exists( ABSPATH . $file ) && is_file( ABSPATH . $file ) ) {
     1636        $template_data = implode('', file( ABSPATH . $file ));
    14451637        if (preg_match("|Template Name:(.*)|i", $template_data, $name))
    14461638            return $name[1];
     
    14731665    preg_match("|Author URI:(.*)|i", $plugin_data, $author_uri);
    14741666    if (preg_match("|Version:(.*)|i", $plugin_data, $version))
    1475         $version = $version[1];
     1667        $version = trim($version[1]);
    14761668    else
    14771669        $version = '';
    14781670
    1479     $description = wptexturize($description[1]);
     1671    $description = wptexturize(trim($description[1]));
    14801672
    14811673    $name = $plugin_name[1];
     
    14831675    $plugin = $name;
    14841676    if ('' != $plugin_uri[1] && '' != $name) {
    1485         $plugin = '<a href="'.$plugin_uri[1].'" title="'.__('Visit plugin homepage').'">'.$plugin.'</a>';
     1677        $plugin = '<a href="' . trim($plugin_uri[1]) . '" title="'.__('Visit plugin homepage').'">'.$plugin.'</a>';
    14861678    }
    14871679
    14881680    if ('' == $author_uri[1]) {
    1489         $author = $author_name[1];
    1490     } else {
    1491         $author = '<a href="'.$author_uri[1].'" title="'.__('Visit author homepage').'">'.$author_name[1].'</a>';
     1681        $author = trim($author_name[1]);
     1682    } else {
     1683        $author = '<a href="' . trim($author_uri[1]) . '" title="'.__('Visit author homepage').'">' . trim($author_name[1]) . '</a>';
    14921684    }
    14931685
     
    15031695
    15041696    $wp_plugins = array ();
    1505     $plugin_loc = 'wp-content/plugins';
    1506     $plugin_root = ABSPATH.$plugin_loc;
     1697    $plugin_root = ABSPATH . PLUGINDIR;
    15071698
    15081699    // Files in wp-content/plugins directory
     
    15291720    }
    15301721
    1531     if (!$plugins_dir || !$plugin_files) {
     1722    if ( !$plugins_dir || !$plugin_files )
    15321723        return $wp_plugins;
    1533     }
    1534 
    1535     sort($plugin_files);
    1536 
    1537     foreach ($plugin_files as $plugin_file) {
    1538         if ( !is_readable("$plugin_root/$plugin_file"))
     1724
     1725    foreach ( $plugin_files as $plugin_file ) {
     1726        if ( !is_readable("$plugin_root/$plugin_file") )
    15391727            continue;
    15401728
    15411729        $plugin_data = get_plugin_data("$plugin_root/$plugin_file");
    15421730
    1543         if (empty ($plugin_data['Name'])) {
     1731        if ( empty ($plugin_data['Name']) )
    15441732            continue;
    1545         }
    15461733
    15471734        $wp_plugins[plugin_basename($plugin_file)] = $plugin_data;
    15481735    }
     1736
     1737    uasort($wp_plugins, create_function('$a, $b', 'return strnatcasecmp($a["Name"], $b["Name"]);'));
    15491738
    15501739    return $wp_plugins;
     
    16551844        __("Failed to write file to disk."));
    16561845
    1657     // Accepted MIME types are set here as PCRE. Override with $override['mimes'].
    1658     $mimes = apply_filters('upload_mimes', array (
    1659         'jpg|jpeg|jpe' => 'image/jpeg',
    1660         'gif' => 'image/gif',
    1661         'png' => 'image/png',
    1662         'bmp' => 'image/bmp',
    1663         'tif|tiff' => 'image/tiff',
    1664         'ico' => 'image/x-icon',
    1665         'asf|asx|wax|wmv|wmx' => 'video/asf',
    1666         'avi' => 'video/avi',
    1667         'mov|qt' => 'video/quicktime',
    1668         'mpeg|mpg|mpe' => 'video/mpeg',
    1669         'txt|c|cc|h' => 'text/plain',
    1670         'rtx' => 'text/richtext',
    1671         'css' => 'text/css',
    1672         'htm|html' => 'text/html',
    1673         'mp3|mp4' => 'audio/mpeg',
    1674         'ra|ram' => 'audio/x-realaudio',
    1675         'wav' => 'audio/wav',
    1676         'ogg' => 'audio/ogg',
    1677         'mid|midi' => 'audio/midi',
    1678         'wma' => 'audio/wma',
    1679         'rtf' => 'application/rtf',
    1680         'js' => 'application/javascript',
    1681         'pdf' => 'application/pdf',
    1682         'doc' => 'application/msword',
    1683         'pot|pps|ppt' => 'application/vnd.ms-powerpoint',
    1684         'wri' => 'application/vnd.ms-write',
    1685         'xla|xls|xlt|xlw' => 'application/vnd.ms-excel',
    1686         'mdb' => 'application/vnd.ms-access',
    1687         'mpp' => 'application/vnd.ms-project',
    1688         'swf' => 'application/x-shockwave-flash',
    1689         'class' => 'application/java',
    1690         'tar' => 'application/x-tar',
    1691         'zip' => 'application/zip',
    1692         'gz|gzip' => 'application/x-gzip',
    1693         'exe' => 'application/x-msdownload'
    1694     ));
    1695 
    16961846    // All tests are on by default. Most can be turned off by $override[{test_name}] = false;
    16971847    $test_form = true;
     
    17211871        return $upload_error_handler($file, __('Specified file failed upload test.'));
    17221872
    1723     // A correct MIME type will pass this test.
     1873    // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
    17241874    if ( $test_type ) {
    1725         $type = false;
    1726         $ext = false;
    1727         foreach ($mimes as $ext_preg => $mime_match) {
    1728             $ext_preg = '![^.]\.(' . $ext_preg . ')$!i';
    1729             if ( preg_match($ext_preg, $file['name'], $ext_matches) ) {
    1730                 $type = $mime_match;
    1731                 $ext = $ext_matches[1];
    1732             }
    1733         }
     1875        $wp_filetype = wp_check_filetype($file['name'], $mimes);
     1876
     1877        extract($wp_filetype);
    17341878
    17351879        if ( !$type || !$ext )
     
    17581902                $filename = str_replace("$number$ext", ++$number . $ext, $filename);
    17591903        }
     1904        $filename = str_replace($ext, '', $filename);
     1905        $filename = sanitize_title_with_dashes($filename) . $ext;
    17601906    }
    17611907
     
    17631909    $new_file = $uploads['path'] . "/$filename";
    17641910    if ( false === @ move_uploaded_file($file['tmp_name'], $new_file) )
    1765         die(printf(__('The uploaded file could not be moved to %s.'), $file['path']));
     1911        wp_die(printf(__('The uploaded file could not be moved to %s.'), $uploads['path']));
    17661912
    17671913    // Set correct file permissions
     
    17721918    // Compute the URL
    17731919    $url = $uploads['url'] . "/$filename";
    1774 
    1775     return array('file' => $new_file, 'url' => $url, 'type' => $type);
     1920   
     1921    $return = apply_filters( 'wp_handle_upload', array('file' => $new_file, 'url' => $url, 'type' => $type) );
     1922
     1923    return $return;
    17761924}
    17771925
     
    17901938
    17911939function wp_import_upload_form($action) {
     1940    $size = strtolower( ini_get('upload_max_filesize') );
     1941    $bytes = 0;
     1942    if ( strstr( $size, 'k' ) )
     1943        $bytes = $size * 1024;
     1944    if ( strstr( $size, 'm' ) )
     1945        $bytes = $size * 1024 * 1024;
     1946    if ( strstr( $size, 'g' ) )
     1947        $bytes = $size * 1024 * 1024 * 1024;
    17921948?>
    1793 <script type="text/javascript">
    1794 function cancelUpload() {
    1795 o = document.getElementById('uploadForm');
    1796 o.method = 'GET';
    1797 o.action.value = 'view';
    1798 o.submit();
    1799 }
    1800 </script>
    1801 <form enctype="multipart/form-data" id="uploadForm" method="POST" action="<?php echo $action ?>">
    1802 <label for="upload"><?php _e('File:'); ?></label><input type="file" id="upload" name="import" />
     1949<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo $action ?>">
     1950<p>
     1951<label for="upload"><?php _e('Choose a file from your computer:'); ?></label> (<?php printf( __('Maximum size: %s'), $size ); ?>)
     1952<input type="file" id="upload" name="import" size="25" />
    18031953<input type="hidden" name="action" value="save" />
    1804 <div id="buttons">
    1805 <input type="submit" value="<?php _e('Import'); ?>" />
    1806 <input type="button" value="<?php _e('Cancel'); ?>" onclick="cancelUpload()" />
    1807 </div>
     1954<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
     1955</p>
     1956<p class="submit">
     1957<input type="submit" value="<?php _e('Upload file and import'); ?> &raquo;" />
     1958</p>
    18081959</form>
    1809 <?php   
     1960<?php
    18101961}
    18111962
     
    18181969
    18191970    $url = $file['url'];
    1820     $file = $file['file'];
     1971    $file = addslashes( $file['file'] );
    18211972    $filename = basename($file);
    18221973
     
    18351986}
    18361987
    1837 function user_can_richedit() {
    1838     if ( 'true' != get_user_option('rich_editing') )
    1839         return false;
    1840 
    1841     if ( preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) )
    1842         return false;
    1843 
    1844     return true; // Best guess
    1845 }
    1846 
    18471988function the_attachment_links($id = false) {
    18481989    $id = (int) $id;
    18491990    $post = & get_post($id);
    18501991
    1851     if ( $post->post_status != 'attachment' )
     1992    if ( $post->post_type != 'attachment' )
    18521993        return false;
    18531994
    18541995    $icon = get_attachment_icon($post->ID);
    1855 
     1996    $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true );
     1997    $thumb = isset($attachment_data['thumb']);
    18561998?>
    1857 <p><?php _e('Text linked to file') ?><br />
    1858 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo basename($post->guid) ?></a></textarea></p>
    1859 <p><?php _e('Text linked to subpost') ?><br />
    1860 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $post->post_title ?></a></textarea></p>
     1999<form id="the-attachment-links">
     2000<table>
     2001    <col />
     2002    <col class="widefat" />
     2003    <tr>
     2004        <th scope="row"><?php _e('URL') ?></th>
     2005        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo $post->guid ?></textarea></td>
     2006    </tr>
    18612007<?php if ( $icon ) : ?>
    1862 <p><?php _e('Thumbnail linked to file') ?><br />
    1863 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo $icon ?></a></textarea></p>
    1864 <p><?php _e('Thumbnail linked to subpost') ?><br />
    1865 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $icon ?></a></textarea></p>
     2008    <tr>
     2009        <th scope="row"><?php $thumb ? _e('Thumbnail linked to file') : _e('Image linked to file'); ?></th>
     2010        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid; ?>"><?php echo $icon ?></a></textarea></td>
     2011    </tr>
     2012    <tr>
     2013        <th scope="row"><?php $thumb ? _e('Thumbnail linked to page') : _e('Image linked to file'); ?></th>
     2014        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td>
     2015    </tr>
     2016<?php else : ?>
     2017    <tr>
     2018        <th scope="row"><?php _e('Link to file') ?></th>
     2019        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo basename($post->guid);  ?></a></textarea></td>
     2020    </tr>
     2021    <tr>
     2022        <th scope="row"><?php _e('Link to page') ?></th>
     2023        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>
     2024    </tr>
    18662025<?php endif; ?>
     2026</table>
     2027</form>
    18672028<?php
    18682029}
     
    18772038}
    18782039
     2040function wp_reset_vars($vars) {
     2041    for ($i=0; $i<count($vars); $i += 1) {
     2042        $var = $vars[$i];
     2043        global $$var;
     2044
     2045        if (!isset($$var)) {
     2046            if (empty($_POST["$var"])) {
     2047                if (empty($_GET["$var"]))
     2048                    $$var = '';
     2049                else
     2050                    $$var = $_GET["$var"];
     2051            } else {
     2052                $$var = $_POST["$var"];
     2053            }
     2054        }
     2055    }
     2056}
     2057
     2058// If siteurl or home changed, reset cookies and flush rewrite rules.
     2059function update_home_siteurl($old_value, $value) {
     2060    global $wp_rewrite, $user_login, $user_pass_md5;
     2061
     2062    if ( defined("WP_INSTALLING") )
     2063        return;
     2064
     2065    // If home changed, write rewrite rules to new location.
     2066    $wp_rewrite->flush_rules();
     2067    // Clear cookies for old paths.
     2068    wp_clearcookie();
     2069    // Set cookies for new paths.
     2070    wp_setcookie($user_login, $user_pass_md5, true, get_option('home'), get_option('siteurl'));
     2071}
     2072
     2073add_action('update_option_home', 'update_home_siteurl', 10, 2);
     2074add_action('update_option_siteurl', 'update_home_siteurl', 10, 2);
     2075
     2076function wp_crop_image($src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false) {
     2077    if ( ctype_digit($src_file) ) // Handle int as attachment ID
     2078        $src_file = get_attached_file($src_file);
     2079
     2080    $src = wp_load_image($src_file);
     2081
     2082    if ( !is_resource($src) )
     2083        return $src;
     2084
     2085    $dst = imagecreatetruecolor($dst_w, $dst_h);
     2086
     2087    if ( $src_abs ) {
     2088        $src_w -= $src_x;
     2089        $src_h -= $src_y;
     2090    }
     2091
     2092    imageantialias($dst, true);
     2093    imagecopyresampled($dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
     2094
     2095    if ( !$dst_file )
     2096        $dst_file = str_replace(basename($src_file), 'cropped-'.basename($src_file), $src_file);
     2097
     2098    $dst_file = preg_replace('/\\.[^\\.]+$/', '.jpg', $dst_file);
     2099
     2100    if ( imagejpeg($dst, $dst_file) )
     2101        return $dst_file;
     2102    else
     2103        return false;
     2104}
     2105
     2106function wp_load_image($file) {
     2107    if ( ctype_digit($file) )
     2108        $file = get_attached_file($file);
     2109
     2110    if ( !file_exists($file) )
     2111        return "File '$file' doesn't exist?";
     2112
     2113    $contents = file_get_contents($file);
     2114
     2115    $image = imagecreatefromstring($contents);
     2116
     2117    if ( !is_resource($image) )
     2118        return "File '$file' is not image?";
     2119
     2120    return $image;
     2121}
     2122
    18792123?>
  • trunk/wp-admin/admin-header.php

    r3503 r4431  
    1 <?php 
     1<?php
    22@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    33if (!isset($_GET["page"])) require_once('admin.php');
    44if ( $editing ) {
    5     $dbx_js = true;
    6     $cat_js = true;
     5    wp_enqueue_script( array("dbx-admin-key?pagenow=$pagenow",'admin-custom-fields') );
     6    if ( current_user_can('manage_categories') )
     7        wp_enqueue_script( 'ajaxcat' );
     8    if ( user_can_richedit() )
     9        wp_enqueue_script( 'wp_tiny_mce' );
    710}
    8 if ( $list_js || $cat_js )
    9     $sack_js = true;
     11
     12get_admin_page_title();
     13
    1014?>
    11 <?php get_admin_page_title(); ?>
    1215<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    13 <html xmlns="http://www.w3.org/1999/xhtml">
     16<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    1417<head>
    15 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
     18<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
    1619<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title>
    17 <link rel="stylesheet" href="<?php echo get_settings('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" />
     20<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" />
     21<?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
     22<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />
     23<?php endif; ?>
    1824<script type="text/javascript">
    1925//<![CDATA[
     
    2127//]]>
    2228</script>
    23 <script type="text/javascript" src="../wp-includes/js/fat.js"></script>
    24 <?php if ( $xfn_js ) { ?>
    25 <script type="text/javascript" src="xfn.js"></script>
    26 <?php } ?>
    27 <?php if ( $sack_js ) { ?>
    28 <script type="text/javascript" src="../wp-includes/js/tw-sack.js"></script>
    29 <?php } ?>
    30 <?php if ( $list_js ) { ?>
    31 <script type="text/javascript" src="list-manipulation.js"></script>
    32 <?php } ?>
    33 <?php if ( $dbx_js ) { ?>
    34 <script type="text/javascript" src="../wp-includes/js/dbx.js"></script>
    35 <script type="text/javascript">
    36 //<![CDATA[
    37 addLoadEvent( function() {
    38 <?php switch ( $pagenow ) : case 'post.php' : ?>
    39 var manager = new dbxManager('postmeta');
    40 <?php break; case 'page-new.php' : ?>
    41 var manager = new dbxManager('pagemeta');
    42 <?php break; endswitch; ?>
    43 });
    44 //]]>
    45 </script>
    46 <script type="text/javascript" src="../wp-includes/js/dbx-key.js"></script>
    47 <?php } ?>
    48 <?php if ( $editing && user_can_richedit() ) { ?>
    49 <script type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce_gzip.php?ver=20051211"></script>
    50 <?php } ?>
    51 <?php if ( $cat_js ) { ?>
    52 <script type="text/javascript" src="cat-js.php"></script>
    53 <?php } ?>
    5429<?php if ( ($parent_file != 'link-manager.php') && ($parent_file != 'options-general.php') ) : ?>
    5530<style type="text/css">* html { overflow-x: hidden; }</style>
    56 <?php endif; ?>
    57 <?php do_action('admin_head'); ?>
     31<?php endif;
     32if ( isset($page_hook) )
     33    do_action('admin_print_scripts-' . $page_hook);
     34else if ( isset($plugin_page) )
     35    do_action('admin_print_scripts-' . $plugin_page);
     36do_action('admin_print_scripts');
     37
     38if ( isset($page_hook) )
     39    do_action('admin_head-' . $page_hook);
     40else if ( isset($plugin_page) )
     41    do_action('admin_head-' . $plugin_page);
     42do_action('admin_head');
     43?>
    5844</head>
    5945<body>
    6046<div id="wphead">
    61 <h1><?php echo wptexturize(get_settings(('blogname'))); ?> <span>(<a href="<?php echo get_settings('home') . '/'; ?>"><?php _e('View site') ?> &raquo;</a>)</span></h1>
     47<h1><?php echo wptexturize(get_option(('blogname'))); ?> <span>(<a href="<?php echo get_option('home') . '/'; ?>"><?php _e('View site &raquo;') ?></a>)</span></h1>
    6248</div>
    63 <div id="user_info"><p><?php printf(__('Howdy, <strong>%s</strong>.'), $user_identity) ?> [<a href="<?php echo get_settings('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 Account'); ?></a>] </p></div>
     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>
    6450
    6551<?php
  • trunk/wp-admin/admin.php

    r3503 r4431  
    66
    77if ( get_option('db_version') != $wp_db_version )
    8     die (sprintf(__("Your database is out-of-date.  Please <a href='%s'>upgrade</a>."), get_option('siteurl') . '/wp-admin/upgrade.php'));
     8    wp_die(sprintf(__("Your database is out-of-date.  Please <a href='%s'>upgrade</a>."), get_option('siteurl') . '/wp-admin/upgrade.php'));
    99   
    1010require_once(ABSPATH . 'wp-admin/admin-functions.php');
    1111require_once(ABSPATH . 'wp-admin/admin-db.php');
    12 require_once(ABSPATH . WPINC . '/registration-functions.php');
     12require_once(ABSPATH . WPINC . '/registration.php');
    1313
    1414auth_redirect();
     
    1818update_category_cache();
    1919
    20 get_currentuserinfo();
     20wp_get_current_user();
    2121
    22 $posts_per_page = get_settings('posts_per_page');
    23 $what_to_show = get_settings('what_to_show');
    24 $date_format = get_settings('date_format');
    25 $time_format = get_settings('time_format');
     22$posts_per_page = get_option('posts_per_page');
     23$what_to_show = get_option('what_to_show');
     24$date_format = get_option('date_format');
     25$time_format = get_option('time_format');
    2626
    27 $wpvarstoreset = array('profile','redirect','redirect_url','a','popuptitle','popupurl','text', 'trackback', 'pingback');
    28 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    29     $wpvar = $wpvarstoreset[$i];
    30     if (!isset($$wpvar)) {
    31         if (empty($_POST["$wpvar"])) {
    32             if (empty($_GET["$wpvar"])) {
    33                 $$wpvar = '';
    34             } else {
    35                 $$wpvar = $_GET["$wpvar"];
    36             }
    37         } else {
    38             $$wpvar = $_POST["$wpvar"];
    39         }
    40     }
     27wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'popuptitle', 'popupurl', 'text', 'trackback', 'pingback'));
     28
     29wp_enqueue_script( 'fat' );
     30
     31$editing = false;
     32
     33if (isset($_GET['page'])) {
     34    $plugin_page = stripslashes($_GET['page']);
     35    $plugin_page = plugin_basename($plugin_page);
    4136}
    42 
    43 $xfn_js = $sack_js = $list_js = $cat_js = $dbx_js = $editing = false;
    4437
    4538require(ABSPATH . '/wp-admin/menu.php');
    4639
    4740// Handle plugin admin pages.
    48 if (isset($_GET['page'])) {
    49     $plugin_page = stripslashes($_GET['page']);
    50     $plugin_page = plugin_basename($plugin_page);
     41if (isset($plugin_page)) {
    5142    $page_hook = get_plugin_page_hook($plugin_page, $pagenow);
    5243
    5344    if ( $page_hook ) {
     45        do_action('load-' . $page_hook);
    5446        if (! isset($_GET['noheader']))
    5547            require_once(ABSPATH . '/wp-admin/admin-header.php');
    56        
     48
    5749        do_action($page_hook);
    5850    } else {
    5951        if ( validate_file($plugin_page) ) {
    60             die(__('Invalid plugin page'));
     52            wp_die(__('Invalid plugin page'));
    6153        }
    62        
    63         if (! file_exists(ABSPATH . "wp-content/plugins/$plugin_page"))
    64             die(sprintf(__('Cannot load %s.'), $plugin_page));
     54
     55        if (! file_exists(ABSPATH . PLUGINDIR . "/$plugin_page"))
     56            wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
     57
     58        do_action('load-' . $plugin_page);
    6559
    6660        if (! isset($_GET['noheader']))
    6761            require_once(ABSPATH . '/wp-admin/admin-header.php');
    68        
    69         include(ABSPATH . "wp-content/plugins/$plugin_page");
     62
     63        include(ABSPATH . PLUGINDIR . "/$plugin_page");
    7064    }
    71    
     65
    7266    include(ABSPATH . 'wp-admin/admin-footer.php');
    7367
    7468    exit();
    7569} else if (isset($_GET['import'])) {
    76    
     70
    7771    $importer = $_GET['import'];
    7872
     73    if ( ! current_user_can('import') )
     74        wp_die(__('You are not allowed to import.'));
     75
    7976    if ( validate_file($importer) ) {
    80         die(__('Invalid importer.'));
     77        wp_die(__('Invalid importer.'));
    8178    }
    82        
     79
    8380    if (! file_exists(ABSPATH . "wp-admin/import/$importer.php"))
    84         die(__('Cannot load importer.'));
    85    
     81        wp_die(__('Cannot load importer.'));
     82
    8683    include(ABSPATH . "wp-admin/import/$importer.php");
    8784
    88     $parent_file = 'import.php';
     85    $parent_file = 'edit.php';
     86    $submenu_file = 'import.php';
    8987    $title = __('Import');
    90    
     88
    9189    if (! isset($_GET['noheader']))
    9290        require_once(ABSPATH . 'wp-admin/admin-header.php');
     
    9896
    9997    call_user_func($wp_importers[$importer][2]);
    100            
     98
    10199    include(ABSPATH . 'wp-admin/admin-footer.php');
    102100
    103101    exit();
     102} else {
     103    do_action("load-$pagenow");
    104104}
    105105
  • trunk/wp-admin/bookmarklet.php

    r3503 r4431  
    44
    55if ( ! current_user_can('edit_posts') )
    6     die ("Cheatin' uh?");
     6    wp_die(__('Cheatin&#8217; uh?'));
    77
    88if ('b' == $a):
     
    2626$popuptitle = wp_specialchars(stripslashes($popuptitle));
    2727$text       = wp_specialchars(stripslashes(urldecode($text)));
    28    
     28
    2929$popuptitle = funky_javascript_fix($popuptitle);
    3030$text       = funky_javascript_fix($text);
    31    
     31
    3232$post_title = wp_specialchars($_REQUEST['post_title']);
    3333if (!empty($post_title))
     
    3535else
    3636    $post->post_title = $popuptitle;
    37    
     37
    3838 
    3939$content  = wp_specialchars($_REQUEST['content']);
     
    5151<head>
    5252<title><?php bloginfo('name') ?> &rsaquo; Bookmarklet &#8212; WordPress</title>
    53 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
     53<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
    5454<link rel="stylesheet" href="wp-admin.css" type="text/css" />
    5555
  • trunk/wp-admin/cat-js.php

    r3503 r4431  
    11<?php
    2 require_once('admin.php');
    3 header('Content-type: text/javascript; charset=' . get_settings('blog_charset'), true);
     2require_once('../wp-config.php');
     3cache_javascript_headers();
    44?>
    5 var ajaxCat = new sack();
    6 var newcat;
    7  
     5addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.topAdder=1;catList.alt=0;catList.showLink=0;});
     6addLoadEvent(newCatAddIn);
    87function newCatAddIn() {
    9     if ( !document.getElementById('jaxcat') ) return false;
    10     var ajaxcat = document.createElement('span');
    11     ajaxcat.id = 'ajaxcat';
    12 
    13     newcat = document.createElement('input');
    14     newcat.type = 'text';
    15     newcat.name = 'newcat';
    16     newcat.id = 'newcat';
    17     newcat.size = '16';
    18     newcat.setAttribute('autocomplete', 'off');
    19     newcat.onkeypress = ajaxNewCatKeyPress;
    20 
    21     var newcatSub = document.createElement('input');
    22     newcatSub.type = 'button';
    23     newcatSub.name = 'Button';
    24     newcatSub.id = 'catadd';
    25     newcatSub.value = '<?php echo addslashes(__('Add')); ?>';
    26     newcatSub.onclick = ajaxNewCat;
    27 
    28     ajaxcat.appendChild(newcat);
    29     ajaxcat.appendChild(newcatSub);
    30     document.getElementById('jaxcat').appendChild(ajaxcat);
    31 
    32     howto = document.createElement('span');
    33     howto.innerHTML = '<?php echo addslashes(__('Separate multiple categories with commas.')); ?>';
    34     howto.id = 'howto';
    35     ajaxcat.appendChild(howto);
     8    var jaxcat = $('jaxcat');
     9    if ( !jaxcat )
     10        return false;
     11    jaxcat.update('<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" id="catadd" value="<?php _e('Add'); ?>"/><span id="howto"><?php _e('Separate multiple categories with commas.'); ?></span></span>');
     12    $('newcat').onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','jaxcat');", e); };
     13    $('catadd').onclick = function() { catList.ajaxAdder('category', 'jaxcat'); };
    3614}
    37 
    38 addLoadEvent(newCatAddIn);
    39 
    40 function getResponseElement() {
    41     var p = document.getElementById('ajaxcatresponse');
    42     if (!p) {
    43         p = document.createElement('span');
    44         document.getElementById('jaxcat').appendChild(p);
    45         p.id = 'ajaxcatresponse';
    46     }
    47     return p;
    48 }
    49 
    50 function newCatLoading() {
    51     var p = getResponseElement();
    52     p.innerHTML = '<?php echo addslashes(__('Sending Data...')); ?>';
    53 }
    54 
    55 function newCatLoaded() {
    56     var p = getResponseElement();
    57     p.innerHTML = '<?php echo addslashes(__('Data Sent...')); ?>';
    58 }
    59 
    60 function newCatInteractive() {
    61     var p = getResponseElement();
    62     p.innerHTML = '<?php echo addslashes(__('Processing Request...')); ?>';
    63 }
    64 
    65 function newCatCompletion() {
    66     var p = getResponseElement();
    67     var id    = 0;
    68     var ids   = new Array();
    69     var names = new Array();
    70    
    71     ids   = myPload( ajaxCat.response );
    72     names = myPload( newcat.value );
    73     for ( i = 0; i < ids.length; i++ ) {
    74         id = ids[i].replace(/[\n\r]+/g, "");
    75         if ( id == '-1' ) {
    76             p.innerHTML = "<?php echo addslashes(__("You don't have permission to do that.")); ?>";
    77             return;
    78         }
    79         if ( id == '0' ) {
    80             p.innerHTML = "<?php echo addslashes(__('That category name is invalid.  Try something else.')); ?>";
    81             return;
    82         }
    83        
    84         var exists = document.getElementById('category-' + id);
    85        
    86         if (exists) {
    87             var moveIt = exists.parentNode;
    88             var container = moveIt.parentNode;
    89             container.removeChild(moveIt);
    90             container.insertBefore(moveIt, container.firstChild);
    91             moveIt.id = 'new-category-' + id;
    92             exists.checked = 'checked';
    93             var nowClass = moveIt.className;
    94             moveIt.className = nowClass + ' fade';
    95             Fat.fade_all();
    96             moveIt.className = nowClass;
    97         } else {
    98             var catDiv = document.getElementById('categorychecklist');
    99             var newLabel = document.createElement('label');
    100             newLabel.setAttribute('for', 'category-' + id);
    101             newLabel.id = 'new-category-' + id;
    102             newLabel.className = 'selectit fade';
    103    
    104             var newCheck = document.createElement('input');
    105             newCheck.type = 'checkbox';
    106             newCheck.value = id;
    107             newCheck.name = 'post_category[]';
    108             newCheck.id = 'category-' + id;
    109             newLabel.appendChild(newCheck);
    110    
    111             var newLabelText = document.createTextNode(' ' + names[i]);
    112             newLabel.appendChild(newLabelText);
    113    
    114             catDiv.insertBefore(newLabel, catDiv.firstChild);
    115             newCheck.checked = 'checked';
    116    
    117             Fat.fade_all();
    118             newLabel.className = 'selectit';
    119         }
    120         newcat.value = '';
    121     }
    122     p.parentNode.removeChild(p);
    123 //  var id = parseInt(ajaxCat.response, 10);
    124 }
    125 
    126 function ajaxNewCatKeyPress(e) {
    127     if (!e) {
    128         if (window.event) {
    129             e = window.event;
    130         } else {
    131             return;
    132         }
    133     }
    134     if (e.keyCode == 13) {
    135         ajaxNewCat();
    136         e.returnValue = false;
    137         e.cancelBubble = true;
    138         return false;
    139     }
    140 }
    141 
    142 function ajaxNewCat() {
    143     var newcat = document.getElementById('newcat');
    144     var split_cats = new Array(1);
    145     var catString = '';
    146 
    147     catString = 'ajaxnewcat=' + encodeURIComponent(newcat.value);
    148     ajaxCat.requestFile = 'edit-form-ajax-cat.php';
    149     ajaxCat.method = 'GET';
    150     ajaxCat.onLoading = newCatLoading;
    151     ajaxCat.onLoaded = newCatLoaded;
    152     ajaxCat.onInteractive = newCatInteractive;
    153     ajaxCat.onCompletion = newCatCompletion;
    154     ajaxCat.runAJAX(catString);
    155 }
    156 
    157 function myPload( str ) {
    158     var fixedExplode = new Array();
    159     var comma = new String(',');
    160     var count = 0;
    161     var currentElement = '';
    162 
    163     for( x=0; x < str.length; x++) {
    164         andy = str.charAt(x);
    165         if ( comma.indexOf(andy) != -1 ) {
    166             currentElement = currentElement.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // trim
    167             fixedExplode[count] = currentElement;
    168             currentElement = "";
    169             count++;
    170         } else {
    171             currentElement += andy;
    172         }
    173     }
    174 
    175     if ( currentElement != "" )
    176         fixedExplode[count] = currentElement;
    177     return fixedExplode;
    178 }
  • trunk/wp-admin/categories.php

    r3503 r4431  
    44$title = __('Categories');
    55$parent_file = 'edit.php';
    6 $list_js = true;
    76
    8 $wpvarstoreset = array('action','cat');
    9 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    10     $wpvar = $wpvarstoreset[$i];
    11     if (!isset($$wpvar)) {
    12         if (empty($_POST["$wpvar"])) {
    13             if (empty($_GET["$wpvar"])) {
    14                 $$wpvar = '';
    15             } else {
    16                 $$wpvar = $_GET["$wpvar"];
    17             }
    18         } else {
    19             $$wpvar = $_POST["$wpvar"];
    20         }
    21     }
    22 }
     7wp_reset_vars(array('action', 'cat'));
    238
    249switch($action) {
     
    2611case 'addcat':
    2712
     13    check_admin_referer('add-category');
     14
    2815    if ( !current_user_can('manage_categories') )
    29         die (__('Cheatin&#8217; uh?'));
    30    
    31     wp_insert_category($_POST);
     16        wp_die(__('Cheatin&#8217; uh?'));
    3217
    33     header('Location: categories.php?message=1#addcat');
     18    if( wp_insert_category($_POST ) ) {
     19        wp_redirect('categories.php?message=1#addcat');
     20    } else {
     21        wp_redirect('categories.php?message=4#addcat');
     22    }
    3423break;
    3524
    3625case 'delete':
    37 
    38     check_admin_referer();
     26    $cat_ID = (int) $_GET['cat_ID'];
     27    check_admin_referer('delete-category_' .  $cat_ID);
    3928
    4029    if ( !current_user_can('manage_categories') )
    41         die (__('Cheatin&#8217; uh?'));
     30        wp_die(__('Cheatin&#8217; uh?'));
    4231
    43     $cat_ID = (int) $_GET['cat_ID'];
    4432    $cat_name = get_catname($cat_ID);
    4533
    46     if ( 1 == $cat_ID )
    47         die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
     34    // Don't delete the default cats.
     35    if ( $cat_ID == get_option('default_category') )
     36        wp_die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
     37
     38    if ( $cat_ID == get_option('default_link_category') )
     39        wp_die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one for bookmarks"), $cat_name));
    4840
    4941    wp_delete_category($cat_ID);
    5042
    51     header('Location: categories.php?message=2');
     43    wp_redirect('categories.php?message=2');
    5244
    5345break;
     
    5850    $cat_ID = (int) $_GET['cat_ID'];
    5951    $category = get_category_to_edit($cat_ID);
    60     ?>
    61 
    62 <div class="wrap">
    63  <h2><?php _e('Edit Category') ?></h2>
    64  <form name="editcat" action="categories.php" method="post">
    65       <table class="editform" width="100%" cellspacing="2" cellpadding="5">
    66         <tr>
    67           <th width="33%" scope="row"><?php _e('Category name:') ?></th>
    68           <td width="67%"><input name="cat_name" type="text" value="<?php echo wp_specialchars($category->cat_name); ?>" size="40" /> <input type="hidden" name="action" value="editedcat" />
    69 <input type="hidden" name="cat_ID" value="<?php echo $category->cat_ID ?>" /></td>
    70         </tr>
    71         <tr>
    72             <th scope="row"><?php _e('Category slug:') ?></th>
    73             <td><input name="category_nicename" type="text" value="<?php echo wp_specialchars($category->category_nicename); ?>" size="40" /></td>
    74         </tr>
    75         <tr>
    76             <th scope="row"><?php _e('Category parent:') ?></th>
    77             <td>       
    78             <select name='category_parent'>
    79       <option value='0' <?php if (!$category->category_parent) echo " selected='selected'"; ?>><?php _e('None') ?></option>
    80       <?php wp_dropdown_cats($category->cat_ID, $category->category_parent); ?>
    81       </select></td>
    82         </tr>
    83         <tr>
    84             <th scope="row"><?php _e('Description:') ?></th>
    85             <td><textarea name="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->category_description, 1); ?></textarea></td>
    86         </tr>
    87         </table>
    88       <p class="submit"><input type="submit" name="submit" value="<?php _e('Edit category') ?> &raquo;" /></p>
    89  </form>
    90  <p><a href="categories.php"><?php _e('&laquo; Return to category list'); ?></a></p>
    91 </div>
    92     <?php
     52    include('edit-category-form.php');
    9353
    9454break;
    9555
    9656case 'editedcat':
     57    $cat_ID = (int) $_POST['cat_ID'];
     58    check_admin_referer('update-category_' . $cat_ID);
     59
    9760    if ( !current_user_can('manage_categories') )
    98         die (__('Cheatin&#8217; uh?'));
    99    
     61        wp_die(__('Cheatin&#8217; uh?'));
     62
    10063    wp_update_category($_POST);
    10164
    102     header('Location: categories.php?message=3');
     65    wp_redirect('categories.php?message=3');
    10366break;
    10467
    10568default:
    10669
     70wp_enqueue_script( 'admin-categories' );
    10771require_once ('admin-header.php');
    10872
     
    11074$messages[2] = __('Category deleted.');
    11175$messages[3] = __('Category updated.');
     76$messages[4] = __('Category not added.');
    11277?>
    11378
     
    12287    <h2><?php _e('Categories') ?> </h2>
    12388<?php endif; ?>
    124 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
     89<table class="widefat">
     90    <thead>
    12591    <tr>
    126         <th scope="col"><?php _e('ID') ?></th>
     92        <th scope="col" style="text-align: center"><?php _e('ID') ?></th>
    12793        <th scope="col"><?php _e('Name') ?></th>
    12894        <th scope="col"><?php _e('Description') ?></th>
    129         <th scope="col"><?php _e('# Posts') ?></th>
    130         <th colspan="2"><?php _e('Action') ?></th>
     95        <th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th>
     96        <th scope="col" width="90" style="text-align: center"><?php _e('Bookmarks') ?></th>
     97        <th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
    13198    </tr>
     99    </thead>
     100    <tbody id="the-list">
    132101<?php
    133102cat_rows();
    134103?>
     104    </tbody>
    135105</table>
    136 
    137 <div id="ajax-response"></div>
    138106
    139107</div>
     
    141109<?php if ( current_user_can('manage_categories') ) : ?>
    142110<div class="wrap">
    143 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete posts from that category, it will just set them back to the default category <strong>%s</strong>.'), get_catname(get_option('default_category'))) ?></p>
     111<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and bookmarks in that category.  Instead, posts in the deleted category are set to the category <strong>%s</strong> and bookmarks are set to <strong>%s</strong>.'), get_catname(get_option('default_category')), get_catname(get_option('default_link_category'))) ?></p>
    144112</div>
    145113
    146 <div class="wrap">
    147     <h2><?php _e('Add New Category') ?></h2>
    148     <form name="addcat" id="addcat" action="categories.php" method="post">
    149        
    150         <p><?php _e('Name:') ?><br />
    151         <input type="text" name="cat_name" value="" /></p>
    152         <p><?php _e('Category parent:') ?><br />
    153         <select name='category_parent' class='postform'>
    154         <option value='0'><?php _e('None') ?></option>
    155         <?php wp_dropdown_cats(0); ?>
    156         </select></p>
    157         <p><?php _e('Description: (optional)') ?> <br />
    158         <textarea name="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p>
    159         <p class="submit"><input type="hidden" name="action" value="addcat" /><input type="submit" name="submit" value="<?php _e('Add Category &raquo;') ?>" /></p>
    160     </form>
    161 </div>
     114<?php include('edit-category-form.php'); ?>
    162115<?php endif; ?>
    163116
     
    167120
    168121include('admin-footer.php');
     122
    169123?>
  • trunk/wp-admin/edit-comments.php

    r3503 r4431  
    44$title = __('Edit Comments');
    55$parent_file = 'edit.php';
    6 $list_js = true;
     6wp_enqueue_script( 'admin-comments' );
    77
    88require_once('admin-header.php');
     
    2424    }
    2525}
     26
     27function getNumChecked(form)
     28{
     29    var num = 0;
     30    for (i = 0, n = form.elements.length; i < n; i++) {
     31        if(form.elements[i].type == "checkbox") {
     32            if(form.elements[i].checked == true)
     33                num++;
     34        }
     35    }
     36    return num;
     37}
    2638//-->
    2739</script>
    2840<div class="wrap">
    2941<h2><?php _e('Comments'); ?></h2>
    30 <form name="searchform" action="" method="get">
     42<form name="searchform" action="" method="get" id="editcomments">
    3143  <fieldset>
    3244  <legend><?php _e('Show Comments That Contain...') ?></legend>
     
    3446  <input type="submit" name="submit" value="<?php _e('Search') ?>"  /> 
    3547  <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
    36   <?php _e('(Searches within comment text, e-mail, URI, and IP address.)') ?>
     48  <?php _e('(Searches within comment text, e-mail, URL, and IP address.)') ?>
    3749  </fieldset>
    3850</form>
     
    4052<?php
    4153if ( !empty( $_POST['delete_comments'] ) ) :
     54    check_admin_referer('bulk-comments');
     55
    4256    $i = 0;
    4357    foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
    4458        $comment = (int) $comment;
    4559        $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
    46         $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
    47         if ( current_user_can('edit_post', $post_id) ) :
    48             wp_set_comment_status($comment, "delete");
     60        // $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
     61        if ( current_user_can('edit_post', $post_id) ) {
     62            if ( !empty( $_POST['spam_button'] ) )
     63                wp_set_comment_status($comment, 'spam');
     64            else
     65                wp_set_comment_status($comment, 'delete');
    4966            ++$i;
    50         endif;
     67        }
    5168    endforeach;
    52     echo "<div class='wrap'><p>" . sprintf(__('%s comments deleted.'), $i) . "</p></div>";
     69    echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
     70    if ( !empty( $_POST['spam_button'] ) )
     71        printf(__('%s comments marked as spam.'), $i);
     72    else
     73        printf(__('%s comments deleted.'), $i);
     74    echo '</p></div>';
    5375endif;
    5476
     
    78100            $start = '';
    79101
    80         echo "<ol id='the-list' class='commentlist' $start>";
     102        echo "<ol id='the-comment-list' class='commentlist' $start>";
    81103        $i = 0;
    82104        foreach ($comments as $comment) {
     
    89111                $class .= ' alternate';
    90112            echo "<li id='comment-$comment->comment_ID' class='$class'>";
    91 ?>     
    92         <p><strong><?php _e('Name:') ?></strong> <?php comment_author() ?> <?php if ($comment->comment_author_email) { ?>| <strong><?php _e('E-mail:') ?></strong> <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url ) { ?> | <strong><?php _e('URI:') ?></strong> <?php comment_author_url_link() ?> <?php } ?>| <strong><?php _e('IP:') ?></strong> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
    93        
    94         <?php comment_text() ?>
    95 
    96         <p><?php _e('Posted'); echo ' '; comment_date('M j, g:i A'); 
    97             if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    98                 echo " | <a href=\"post.php?action=editcomment&amp;comment=".$comment->comment_ID."\">" . __('Edit Comment') . "</a>";
    99                 echo " | <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars( $comment->comment_author, 1 ))  . "' );\">" . __('Delete Comment') . "</a> &#8212; ";
    100             } // end if any comments to show
    101             // Get post title
    102             if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    103                 $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = $comment->comment_post_ID");
    104                 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
    105                 ?> <a href="post.php?action=edit&amp;post=<?php echo $comment->comment_post_ID; ?>"><?php printf(__('Edit Post &#8220;%s&#8221;'), stripslashes($post_title)); ?></a>
    106                 <?php } ?>
    107              | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p>
     113?>
     114<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>
     115
     116<?php comment_text() ?>
     117
     118<p><?php comment_date('M j, g:i A');  ?> &#8212; [
     119<?php
     120if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
     121    echo " <a href='comment.php?action=editcomment&amp;comment=".$comment->comment_ID."'>" .  __('Edit') . '</a>';
     122    echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $comment->comment_post_ID . '&amp;comment=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
     123    if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
     124        echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $comment->comment_post_ID . '&amp;comment=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
     125        echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $comment->comment_post_ID . '&amp;comment=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
     126    }
     127    echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;delete_type=spam&amp;p=" . $comment->comment_post_ID . "&amp;comment=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to mark as spam."), js_escape( $comment->comment_author))  . "', theCommentList );\">" . __('Spam') . "</a> ";
     128}
     129$post = get_post($comment->comment_post_ID);
     130$post_title = wp_specialchars( $post->post_title, 'double' );
     131$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
     132?>
     133 | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ]</p>
    108134        </li>
    109135
    110 <?php } // end foreach ?>
     136<?php } // end foreach($comment) ?>
    111137</ol>
    112138
     
    114140
    115141<?php
    116     } else {
     142    } else { //no comments to show
    117143
    118144        ?>
    119145        <p>
    120146        <strong><?php _e('No comments found.') ?></strong></p>
    121        
     147
    122148        <?php
    123149    } // end if ($comments)
     
    125151
    126152    if ($comments) {
    127         echo '<form name="deletecomments" id="deletecomments" action="" method="post">
    128         <table width="100%" cellpadding="3" cellspacing="3">
     153        echo '<form name="deletecomments" id="deletecomments" action="" method="post"> ';
     154        wp_nonce_field('bulk-comments');
     155        echo '<table class="widefat">
     156<thead>
    129157  <tr>
    130     <th scope="col">*</th>
     158    <th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById(\'deletecomments\'));" /></th>
    131159    <th scope="col">' .  __('Name') . '</th>
    132160    <th scope="col">' .  __('E-mail') . '</th>
    133161    <th scope="col">' . __('IP') . '</th>
    134162    <th scope="col">' . __('Comment Excerpt') . '</th>
    135     <th scope="col" colspan="3">' .  __('Actions') . '</th>
    136   </tr>';
     163    <th scope="col" colspan="3" style="text-align: center">' .  __('Actions') . '</th>
     164  </tr>
     165</thead>';
    137166        foreach ($comments as $comment) {
    138167        $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
     168        $comment_status = wp_get_comment_status($comment->comment_ID);
    139169        $class = ('alternate' == $class) ? '' : 'alternate';
    140 ?>
    141   <tr class='<?php echo $class; ?>'>
     170        $class .= ('unapproved' == $comment_status) ? ' unapproved' : '';
     171?>
     172  <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'>
    142173    <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
    143174    <td><?php comment_author_link() ?></td>
     
    145176    <td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td>
    146177    <td><?php comment_excerpt(); ?></td>
    147     <td><a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a></td>
     178    <td>
     179        <?php if ('unapproved' == $comment_status) { ?>
     180            (Unapproved)
     181        <?php } else { ?>
     182            <a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a>
     183        <?php } ?>
     184    </td>
    148185    <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    149     echo "<a href='post.php?action=editcomment&amp;comment=$comment->comment_ID' class='edit'>" .  __('Edit') . "</a>"; } ?></td>
     186    echo "<a href='comment.php?action=editcomment&amp;comment=$comment->comment_ID' class='edit'>" .  __('Edit') . "</a>"; } ?></td>
    150187    <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    151             echo "<a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n  \'Cancel\' to stop, \'OK\' to delete."), $comment->comment_author) . "')\"    class='delete'>" . __('Delete') . "</a>"; } ?></td>
     188        echo "<a href=\"comment.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape( $comment->comment_author ))  . "', theCommentList );\" class='delete'>" . __('Delete') . "</a> ";
     189        } ?></td>
    152190  </tr>
    153191        <?php
    154192        } // end foreach
    155193    ?></table>
    156     <p><a href="javascript:;" onclick="checkAll(document.getElementById('deletecomments')); return false; "><?php _e('Invert Checkbox Selection') ?></a></p>
    157             <p class="submit"><input type="submit" name="Submit" value="<?php _e('Delete Checked Comments') ?> &raquo;" onclick="return confirm('<?php _e("You are about to delete these comments permanently \\n  \'Cancel\' to stop, \'OK\' to delete.") ?>')" /> </p>
     194<p class="submit"><input type="submit" name="delete_button" class="delete" value="<?php _e('Delete Checked Comments &raquo;') ?>" onclick="var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php _e("Please select some comments to delete"); ?>'); return false } return confirm('<?php printf(__("You are about to delete %s comments permanently \\n  \'Cancel\' to stop, \'OK\' to delete."), "' + numchecked + '"); ?>')" />
     195            <input type="submit" name="spam_button" value="<?php _e('Mark Checked Comments as Spam &raquo;') ?>" onclick="return confirm('<?php _e("You are about to mark these comments as spam \\n  \'Cancel\' to stop, \'OK\' to mark as spam.") ?>')" /></p>
    158196  </form>
     197<div id="ajax-response"></div>
    159198<?php
    160199    } else {
  • trunk/wp-admin/edit-form-advanced.php

    r3503 r4431  
    1515
    1616<div class="wrap">
    17 <h2 id="write-post"><?php _e('Write Post'); ?><?php if ( 0 != $post_ID ) : ?>
    18  <small class="quickjump"><a href="#preview-post"><?php _e('preview &darr;'); ?></a></small><?php endif; ?></h2>
    1917<?php
    2018
     
    2220    $form_action = 'post';
    2321    $temp_ID = -1 * time();
    24     $form_extra = "<input type='hidden' name='temp_ID' value='$temp_ID' />";
     22    $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
     23    wp_nonce_field('add-post');
    2524} else {
    2625    $form_action = 'editpost';
    27     $form_extra = "<input type='hidden' name='post_ID' value='$post_ID' />";
     26    $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
     27    wp_nonce_field('update-post_' .  $post_ID);
    2828}
    2929
     
    3838    $already_pinged = explode("\n", trim($post->pinged));
    3939    foreach ($already_pinged as $pinged_url) {
    40         $pings .= "\n\t<li>$pinged_url</li>";
     40        $pings .= "\n\t<li>" . wp_specialchars($pinged_url) . "</li>";
    4141    }
    4242    $pings .= '</ul>';
     
    5050
    5151<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
    52 <input type="hidden" name="action" value="<?php echo $form_action ?>" />
     52<input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" />
     53<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
    5354<input type="hidden" name="post_author" value="<?php echo $post->post_author ?>" />
     55<input type="hidden" id="post_type" name="post_type" value="post" />
    5456
    5557<?php echo $form_extra ?>
     
    6769<div id="moremeta">
    6870<div id="grabit" class="dbx-group">
     71
     72<fieldset id="categorydiv" class="dbx-box">
     73<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
     74<div class="dbx-content">
     75<p id="jaxcat"></p>
     76<ul id="categorychecklist"><?php dropdown_categories(); ?></ul></div>
     77</fieldset>
    6978
    7079<fieldset id="commentstatusdiv" class="dbx-box">
     
    8089
    8190<fieldset id="passworddiv" class="dbx-box">
    82 <h3 class="dbx-handle"><?php _e('Password-Protect Post') ?></h3>
     91<h3 class="dbx-handle"><?php _e('Post Password') ?></h3>
    8392<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password ?>" /></div>
    8493</fieldset>
    8594
    8695<fieldset id="slugdiv" class="dbx-box">
    87 <h3 class="dbx-handle"><?php _e('Post slug') ?></h3>
     96<h3 class="dbx-handle"><?php _e('Post Slug') ?></h3>
    8897<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo $post->post_name ?>" /></div>
    8998</fieldset>
    9099
    91 <fieldset id="categorydiv" class="dbx-box">
    92 <h3 class="dbx-handle"><?php _e('Categories') ?></h3>
    93 <div class="dbx-content">
    94 <p id="jaxcat"></p>
    95 <div id="categorychecklist"><?php dropdown_categories(get_settings('default_category')); ?></div></div>
    96 </fieldset>
    97 
    98 <fieldset class="dbx-box">
     100<fieldset id="poststatusdiv" class="dbx-box">
    99101<h3 class="dbx-handle"><?php _e('Post Status') ?></h3>
    100102<div class="dbx-content"><?php if ( current_user_can('publish_posts') ) : ?>
    101 <label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); ?> /> <?php _e('Published') ?></label>
     103<label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label>
    102104<?php endif; ?>
    103105      <label for="post_status_draft" class="selectit"><input id="post_status_draft" name="post_status" type="radio" value="draft" <?php checked($post->post_status, 'draft'); ?> /> <?php _e('Draft') ?></label>
     
    106108
    107109<?php if ( current_user_can('edit_posts') ) : ?>
    108 <fieldset class="dbx-box">
     110<fieldset id="posttimestampdiv" class="dbx-box">
    109111<h3 class="dbx-handle"><?php _e('Post Timestamp'); ?>:</h3>
    110112<div class="dbx-content"><?php touch_time(($action == 'edit')); ?></div>
     
    112114<?php endif; ?>
    113115
    114 <?php if ( $authors = get_editable_authors( $current_user->id ) ) : // TODO: ROLE SYSTEM ?>
     116<?php
     117$authors = get_editable_authors( $current_user->id ); // TODO: ROLE SYSTEM
     118if ( $authors && count( $authors ) > 1 ) :
     119?>
    115120<fieldset id="authordiv" class="dbx-box">
    116 <h3 class="dbx-handle"><?php _e('Post author'); ?>:</h3>
     121<h3 class="dbx-handle"><?php _e('Post Author'); ?>:</h3>
    117122<div class="dbx-content">
    118123<select name="post_author_override" id="post_author_override">
     
    143148<legend><?php _e('Post') ?></legend>
    144149
    145 <?php
    146  $rows = get_settings('default_post_edit_rows');
    147  if (($rows < 3) || ($rows > 100)) {
    148      $rows = 12;
    149  }
    150 ?>
    151 <?php the_quicktags(); ?>
    152 
    153 <div><textarea <?php if ( user_can_richedit() ) echo 'title="true" '; ?>rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="2" id="content"><?php echo user_can_richedit() ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div>
    154 </fieldset>
    155 
    156 <script type="text/javascript">
    157 <!--
    158 edCanvas = document.getElementById('content');
    159 <?php if ( user_can_richedit() ) : ?>
    160 // This code is meant to allow tabbing from Title to Post (TinyMCE).
    161 if ( tinyMCE.isMSIE )
    162     document.getElementById('title').onkeydown = function (e)
    163         {
    164             e = e ? e : window.event;
    165             if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
    166                 var i = tinyMCE.selectedInstance;
    167                 if(typeof i ==  'undefined')
    168                     return true;
    169                                 tinyMCE.execCommand("mceStartTyping");
    170                 this.blur();
    171                 i.contentWindow.focus();
    172                 e.returnValue = false;
    173                 return false;
    174             }
    175         }
    176 else
    177     document.getElementById('title').onkeypress = function (e)
    178         {
    179             e = e ? e : window.event;
    180             if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
    181                 var i = tinyMCE.selectedInstance;
    182                 if(typeof i ==  'undefined')
    183                     return true;
    184                                 tinyMCE.execCommand("mceStartTyping");
    185                 this.blur();
    186                 i.contentWindow.focus();
    187                 e.returnValue = false;
    188                 return false;
    189             }
    190         }
    191 <?php endif; ?>
    192 //-->
    193 </script>
     150    <?php the_editor($post->post_content); ?>
     151</fieldset>
    194152
    195153<?php echo $form_pingback ?>
     
    197155
    198156
    199 <p class="submit"><?php echo $saveasdraft; ?> <input type="submit" name="submit" value="<?php _e('Save') ?>" style="font-weight: bold;" tabindex="4" />
     157<p class="submit">
     158<span id="autosave"></span>
     159<?php echo $saveasdraft; ?>
     160<input type="submit" name="submit" value="<?php _e('Save') ?>" style="font-weight: bold;" tabindex="4" />
    200161<?php
    201162if ('publish' != $post->post_status || 0 == $post_ID) {
     
    210171if ( !empty($_REQUEST['popupurl']) )
    211172    echo wp_specialchars($_REQUEST['popupurl']);
    212 else if ( url_to_postid($_SERVER['HTTP_REFERER']) == $post_ID )
     173else if ( url_to_postid(wp_get_referer()) == $post_ID )
    213174    echo 'redo';
    214175else
    215     echo wp_specialchars($_SERVER['HTTP_REFERER']);
     176    echo wp_specialchars(wp_get_referer());
    216177?>" /></p>
    217178
     
    221182if (current_user_can('upload_files')) {
    222183    $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
    223     $uploading_iframe_src = "inline-uploading.php?action=view&amp;post=$uploading_iframe_ID";
     184    $uploading_iframe_src = wp_nonce_url("upload.php?style=inline&amp;tab=upload&amp;post_id=$uploading_iframe_ID", 'inlineuploading');
    224185    $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
    225186    if ( false != $uploading_iframe_src )
    226         echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
     187        echo '<iframe id="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
    227188}
    228189?>
     
    230191<div id="advancedstuff" class="dbx-group" >
    231192
     193<div class="dbx-box-wrapper">
    232194<fieldset id="postexcerpt" class="dbx-box">
     195<div class="dbx-handle-wrapper">
    233196<h3 class="dbx-handle"><?php _e('Optional Excerpt') ?></h3>
     197</div>
     198<div class="dbx-content-wrapper">
    234199<div class="dbx-content"><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea></div>
    235 </fieldset>
    236 
    237 <fieldset class="dbx-box">
     200</div>
     201</fieldset>
     202</div>
     203
     204<div class="dbx-box-wrapper">
     205<fieldset id="trackbacksdiv" class="dbx-box">
     206<div class="dbx-handle-wrapper">
    238207<h3 class="dbx-handle"><?php _e('Trackbacks') ?></h3>
     208</div>
     209<div class="dbx-content-wrapper">
    239210<div class="dbx-content"><?php _e('Send trackbacks to'); ?>: <?php echo $form_trackback; ?> (<?php _e('Separate multiple URIs with spaces'); ?>)
    240211<?php
     
    243214?>
    244215</div>
    245 </fieldset>
    246 
     216</div>
     217</fieldset>
     218</div>
     219
     220<div class="dbx-box-wrapper">
    247221<fieldset id="postcustom" class="dbx-box">
     222<div class="dbx-handle-wrapper">
    248223<h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3>
     224</div>
     225<div class="dbx-content-wrapper">
    249226<div id="postcustomstuff" class="dbx-content">
    250 <?php
    251 if($metadata = has_meta($post_ID)) {
    252 ?>
    253 <?php
    254     list_meta($metadata);
    255 ?>
    256 <?php
    257 }
     227<table cellpadding="3">
     228<?php
     229$metadata = has_meta($post_ID);
     230list_meta($metadata);
     231?>
     232
     233</table>
     234<?php
    258235    meta_form();
    259236?>
    260 </div>
    261 </fieldset>
     237<div id="ajax-response"></div>
     238</div>
     239</div>
     240</fieldset>
     241</div>
    262242
    263243<?php do_action('dbx_post_advanced'); ?>
     
    265245</div>
    266246
    267 <?php if ('edit' == $action) : ?>
    268 <input name="deletepost" class="button" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this post') ?>" <?php echo "onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n  \'Cancel\' to stop, \'OK\' to delete."), addslashes($post->post_title) ) . "')\""; ?> />
     247<?php if ('edit' == $action) : $delete_nonce = wp_create_nonce( 'delete-post_' . $post_ID ); ?>
     248<input name="deletepost" class="button delete" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this post') ?>" <?php echo "onclick=\"if ( confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n  \'Cancel\' to stop, \'OK\' to delete."), js_escape($post->post_title) ) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}return false;\""; ?> />
    269249<?php endif; ?>
    270250
  • trunk/wp-admin/edit-form-comment.php

    r3503 r4431  
    66?>
    77
    8 <form name="post" action="post.php" method="post" id="post">
     8<form name="post" action="comment.php" method="post" id="post">
     9<?php wp_nonce_field('update-comment_' . $comment->comment_ID) ?>
    910<div class="wrap">
    1011<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
     
    1819</script>
    1920<fieldset id="namediv">
    20     <legend><?php _e('Name:') ?></legend>
     21    <legend><label for="name"><?php _e('Name:') ?></label></legend>
    2122    <div>
    22       <input type="text" name="newcomment_author" size="22" value="<?php echo $comment->comment_author ?>" tabindex="1" id="name" />
     23      <input type="text" name="newcomment_author" size="25" value="<?php echo $comment->comment_author ?>" tabindex="1" id="name" />
    2324    </div>
    2425</fieldset>
    2526<fieldset id="emaildiv">
    26         <legend><?php _e('E-mail:') ?></legend>
     27        <legend><label for="email"><?php _e('E-mail:') ?></label></legend>
    2728        <div>
    28           <input type="text" name="newcomment_author_email" size="30" value="<?php echo $comment->comment_author_email ?>" tabindex="2" id="email" />
     29          <input type="text" name="newcomment_author_email" size="20" value="<?php echo $comment->comment_author_email ?>" tabindex="2" id="email" />
    2930    </div>
    3031</fieldset>
    3132<fieldset id="uridiv">
    32         <legend><?php _e('URI:') ?></legend>
     33        <legend><label for="URL"><?php _e('URL:') ?></label></legend>
    3334        <div>
    3435          <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url ?>" tabindex="3" id="URL" />
     
    3839<fieldset style="clear: both;">
    3940        <legend><?php _e('Comment') ?></legend>
    40 <?php the_quicktags(); ?>
    41 
    42 <?php
    43  $rows = get_settings('default_post_edit_rows');
    44  if (($rows < 3) || ($rows > 100)) {
    45      $rows = 10;
    46  }
    47 ?>
    48 <div><textarea title="true" rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content" style="width: 99%"><?php echo user_can_richedit() ? wp_richedit_pre($comment->comment_content) : $comment->comment_content; ?></textarea></div>
     41    <?php the_editor($comment->comment_content, 'content', 'newcomment_author_url'); ?>
    4942</fieldset>
    5043
    51 <script type="text/javascript">
    52 <!--
    53 edCanvas = document.getElementById('content');
    54 <?php if ( user_can_richedit() ) : ?>
    55 // This code is meant to allow tabbing from Author URL to Post (TinyMCE).
    56 if ( tinyMCE.isMSIE )
    57     document.getElementById('newcomment_author_url').onkeydown = function (e)
    58         {
    59             e = e ? e : window.event;
    60             if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
    61                 var i = tinyMCE.selectedInstance;
    62                 if(typeof i ==  'undefined')
    63                     return true;
    64                                 tinyMCE.execCommand("mceStartTyping");
    65                 this.blur();
    66                 i.contentWindow.focus();
    67                 e.returnValue = false;
    68                 return false;
    69             }
    70         }
    71 else
    72     document.getElementById('newcomment_author_url').onkeypress = function (e)
    73         {
    74             e = e ? e : window.event;
    75             if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
    76                 var i = tinyMCE.selectedInstance;
    77                 if(typeof i ==  'undefined')
    78                     return true;
    79                                 tinyMCE.execCommand("mceStartTyping");
    80                 this.blur();
    81                 i.contentWindow.focus();
    82                 e.returnValue = false;
    83                 return false;
    84             }
    85         }
    86 <?php endif; ?>
    87 //-->
    88 </script>
    89 
    9044<p class="submit"><input type="submit" name="editcomment" id="editcomment" value="<?php echo $submitbutton_text ?>" style="font-weight: bold;" tabindex="6" />
    91   <input name="referredby" type="hidden" id="referredby" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" />
     45  <input name="referredby" type="hidden" id="referredby" value="<?php echo wp_get_referer(); ?>" />
    9246</p>
    9347
     
    10761<?php if ( current_user_can('edit_posts') ) : ?>
    10862    <tr>
    109         <th scope="row"><?php _e('Edit time'); ?>:</th>
    110         <td><?php touch_time(('editcomment' == $action), 0); ?></td>
     63        <th scope="row" valign="top"><?php _e('Edit time'); ?>:</th>
     64        <td><?php touch_time(('editcomment' == $action), 0); ?> </td>
    11165    </tr>
    11266<?php endif; ?>
    11367
    11468    <tr>
    115         <th scope="row"><?php _e('Delete'); ?>:</th>
    116         <td><p><a class="delete" href="post.php?action=confirmdeletecomment&amp;noredir=true&amp;comment=<?php echo $comment->comment_ID; ?>&amp;p=<?php echo $comment->comment_post_ID; ?>"><?php _e('Delete comment') ?></a></p></td>
     69        <th scope="row" valign="top"><?php _e('Delete'); $delete_nonce = wp_create_nonce( 'delete-comment_' . $comment->comment_ID ); ?>:</th>
     70        <td><input name="deletecomment" class="button delete" type="submit" id="deletecomment" tabindex="10" value="<?php _e('Delete this comment') ?>" <?php echo "onclick=\"if ( confirm('" . __("You are about to delete this comment \\n  \'Cancel\' to stop, \'OK\' to delete.") . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true; } return false;\""; ?> />
     71        <input type="hidden" name="comment" value="<?php echo $comment->comment_ID ?>" />
     72        <input type="hidden" name="p" value="<?php echo $comment->comment_post_ID ?>" />
     73        <input type="hidden" name="noredir" value="1" />
     74    </td>
    11775    </tr>
    11876</table>
  • trunk/wp-admin/edit-form.php

    r3503 r4431  
    3535<?php the_quicktags(); ?>
    3636<?php
    37  $rows = get_settings('default_post_edit_rows');
     37 $rows = get_option('default_post_edit_rows');
    3838 if (($rows < 3) || ($rows > 100)) {
    3939     $rows = 10;
     
    5252<input type="hidden" name="post_pingback" value="<?php echo get_option('default_pingback_flag') ?>" id="post_pingback" />
    5353
    54 <p><label for="trackback"> <?php printf(__('<a href="%s" title="Help on trackbacks"><strong>TrackBack</strong> a <abbr title="Universal Resource Identifier">URI</abbr></a>:</label> (Separate multiple <abbr title="Universal Resource Identifier">URI</abbr>s with spaces.)<br />'), 'http://wordpress.org/docs/reference/post/#trackback') ?>
     54<p><label for="trackback"> <?php printf(__('<a href="%s" title="Help on trackbacks"><strong>TrackBack</strong> a <abbr title="Universal Resource Locator">URL</abbr></a>:</label> (Separate multiple <abbr title="Universal Resource Locator">URL</abbr>s with spaces.)<br />'), 'http://wordpress.org/docs/reference/post/#trackback') ?>
    5555    <input type="text" name="trackback_url" style="width: 360px" id="trackback" tabindex="7" /></p>
    5656
     
    6565      echo '<input name="advanced" type="submit" id="advancededit" tabindex="7" value="' .  __('Advanced Editing &raquo;') . '" />';
    6666  } ?>
    67   <input name="referredby" type="hidden" id="referredby" value="<?php if (isset($_SERVER['HTTP_REFERER'])) echo urlencode($_SERVER['HTTP_REFERER']); ?>" />
     67  <input name="referredby" type="hidden" id="referredby" value="<?php if ( wp_get_referer() ) echo urlencode(wp_get_referer()); ?>" />
    6868</p>
    6969
  • trunk/wp-admin/edit-link-form.php

    r3503 r4431  
    11<?php
    22if ( ! empty($link_id) ) {
    3     $editing = true;
    4     $heading = __('Edit a link:');
     3    $heading = __('Edit Link');
    54    $submit_text = __('Save Changes &raquo;');
    6     $form = '<form action="" method="post" name="editlink" id="editlink">';
     5    $form = '<form name="editlink" id="editlink" method="post" action="link.php">';
     6    $nonce_action = 'update-bookmark_' . $link_id;
    77} else {
    8     $editing = false;
    9     $heading = __('<strong>Add</strong> a link:');
     8    $heading = __('Add Link');
    109    $submit_text = __('Add Link &raquo;');
    11     $form = '<form name="addlink" method="post" action="link-manager.php">';
     10    $form = '<form name="addlink" id="addlink" method="post" action="link.php">';
     11    $nonce_action = 'add-bookmark';
    1212}
    1313
     
    2929    }
    3030}
    31 
    3231?>
    3332
    3433<div class="wrap">
    35   <?php echo $form ?>
    36   <h2><?php echo $heading ?></h2>
    37 <fieldset class="options">
    38     <legend><?php _e('Basics') ?></legend>
    39         <table class="editform" width="100%" cellspacing="2" cellpadding="5">
    40          <tr>
    41            <th width="33%" scope="row"><?php _e('URI:') ?></th>
    42            <td width="67%"><input type="text" name="link_url" value="<?php echo $link->link_url; ?>" style="width: 95%;" /></td>
    43          </tr>
    44          <tr>
    45            <th scope="row"><?php _e('Link Name:') ?></th>
    46            <td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
    47          </tr>
    48          <tr>
    49             <th scope="row"><?php _e('Short description:') ?></th>
    50             <td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
    51             </tr>
    52         <tr>
    53            <th scope="row"><?php _e('Category:') ?></th>
    54            <td><?php link_category_dropdown('link_category', $link->link_category); ?></td>
    55          </tr>
     34<h2><?php echo $heading ?></h2>
     35<?php echo $form ?>
     36<?php wp_nonce_field($nonce_action); ?>
     37
     38<div id="poststuff">
     39<div id="moremeta">
     40<div id="grabit" class="dbx-group">
     41
     42<fieldset id="categorydiv" class="dbx-box">
     43<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
     44<div class="dbx-content">
     45<p id="jaxcat"></p>
     46<ul id="categorychecklist"><?php dropdown_link_categories(get_option('default_link_category')); ?></ul>
     47</div>
     48</fieldset>
     49
     50<fieldset class="dbx-box">
     51<h3 class="dbx-handle"><?php _e('Target') ?></h3>
     52<div class="dbx-content">
     53<label for="link_target_blank" class="selectit">
     54<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
     55<code>_blank</code></label>
     56<label for="link_target_top" class="selectit">
     57<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
     58<code>_top</code></label>
     59<label for="link_target_none" class="selectit">
     60<input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
     61<?php _e('none') ?></label>
     62</div>
     63</fieldset>
     64
     65<fieldset class="dbx-box">
     66<h3 class="dbx-handle"><?php _e('Visible') ?></h3>
     67<div class="dbx-content">
     68<label for="link_visible_yes" class="selectit">
     69<input id="link_visible_yes" type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
     70<?php _e('Yes') ?></label>
     71<label for="link_visible_no" class="selectit">
     72<input id="link_visible_no" type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" />
     73<?php _e('No') ?></label>
     74</div>
     75</fieldset>
     76
     77</div>
     78</div>
     79
     80<table class="editform" width="100%" cellspacing="2" cellpadding="5">
     81<tr>
     82<th scope="row" valign="top"><label for="link_name"><?php _e('Name:') ?></label></th>
     83<td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
     84</tr>
     85<tr>
     86<th width="20%" scope="row" valign="top"><label for="link_url"><?php _e('Address:') ?></label></th>
     87<td width="80%"><input type="text" name="link_url" value="<?php echo $link->link_url; if ( empty( $link->link_url ) ) echo 'http://'; ?>" style="width: 95%" /></td>
     88</tr>
     89<tr>
     90<th scope="row" valign="top"><label for="link_description"><?php _e('Description:') ?></label></th>
     91<td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
     92</tr>
    5693</table>
    57 </fieldset>
    58        <p class="submit">
    59        <input type="submit" name="submit" value="<?php echo $submit_text ?>" />
    60        </p>
    61     <fieldset class="options">
    62         <legend><?php _e('Link Relationship (XFN)') ?></legend>
    63         <table class="editform" width="100%" cellspacing="2" cellpadding="5">
    64             <tr>
    65                 <th width="33%" scope="row"><?php _e('rel:') ?></th>
    66                 <td width="67%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td>
    67             </tr>
    68             <tr>
    69                 <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th>
    70                 <td>
    71                     <table cellpadding="3" cellspacing="5">
    72               <tr>
    73               <th scope="row"> <?php _e('identity') ?> </th>
    74               <td>
    75                 <label for="me">
    76                 <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
    77           <?php _e('another web address of mine') ?></label>
    78               </td>
    79             </tr>
    80             <tr>
    81               <th scope="row"> <?php _e('friendship') ?> </th>
    82               <td>
    83                 <label for="contact">
    84                 <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
    85                 <label for="acquaintance">
    86                 <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> />  <?php _e('acquaintance') ?></label>
    87                 <label id="friend">
    88                 <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
    89                 <label for="friendship">
    90                 <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label>
    91               </td>
    92             </tr>
    93             <tr>
    94               <th scope="row"> <?php _e('physical') ?> </th>
    95               <td>
    96                 <label for="met">
    97                 <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
    98           <?php _e('met') ?></label>
    99               </td>
    100             </tr>
    101             <tr>
    102               <th scope="row"> <?php _e('professional') ?> </th>
    103               <td>
    104                 <label for="co-worker">
    105                 <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
    106           <?php _e('co-worker') ?></label>
    107                 <label for="colleague">
    108                 <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
    109           <?php _e('colleague') ?></label>
    110               </td>
    111             </tr>
    112             <tr>
    113               <th scope="row"> <?php _e('geographical') ?> </th>
    114               <td>
    115                 <label for="co-resident">
    116                 <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
    117           <?php _e('co-resident') ?></label>
    118                 <label for="neighbor">
    119                 <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
    120           <?php _e('neighbor') ?></label>
    121                 <label for="geographical">
    122                 <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
    123           <?php _e('none') ?></label>
    124               </td>
    125             </tr>
    126             <tr>
    127               <th scope="row"> <?php _e('family') ?> </th>
    128               <td>
    129                 <label for="child">
    130                 <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?>  />
    131           <?php _e('child') ?></label>
    132                 <label for="kin">
    133                 <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?>  />
    134           <?php _e('kin') ?></label>
    135                 <label for="parent">
    136                 <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
    137           <?php _e('parent') ?></label>
    138                 <label for="sibling">
    139                 <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
    140           <?php _e('sibling') ?></label>
    141                 <label for="spouse">
    142                 <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
    143           <?php _e('spouse') ?></label>
    144                 <label for="family">
    145                 <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
    146           <?php _e('none') ?></label>
    147               </td>
    148             </tr>
    149             <tr>
    150               <th scope="row"> <?php _e('romantic') ?> </th>
    151               <td>
    152                 <label for="muse">
    153                 <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
    154          <?php _e('muse') ?></label>
    155                 <label for="crush">
    156                 <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
    157          <?php _e('crush') ?></label>
    158                 <label for="date">
    159                 <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
    160          <?php _e('date') ?></label>
    161                 <label for="romantic">
    162                 <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
    163          <?php _e('sweetheart') ?></label>
    164               </td>
    165             </tr>
    166         </table>
    167           </td>
    168             </tr>
     94
     95<p class="submit">
     96<input type="submit" name="submit" value="<?php echo $submit_text ?>" />
     97</p>
     98
     99<div id="advancedstuff" class="dbx-group" >
     100
     101<fieldset id="xfn" class="dbx-box">
     102<h3 class="dbx-handle"><?php _e('Link Relationship (XFN)') ?></h3>
     103<div class="dbx-content">
     104<table class="editform" width="100%" cellspacing="2" cellpadding="5">
     105    <tr>
     106        <th width="20%" scope="row"><?php _e('rel:') ?></th>
     107        <td width="80%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td>
     108    </tr>
     109    <tr>
     110        <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th>
     111        <td>
     112            <table cellpadding="3" cellspacing="5">
     113                <tr>
     114                    <th scope="row"> <?php _e('identity') ?> </th>
     115                    <td>
     116                        <label for="me">
     117                        <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
     118                        <?php _e('another web address of mine') ?></label>
     119                    </td>
     120                </tr>
     121                <tr>
     122                    <th scope="row"> <?php _e('friendship') ?> </th>
     123                    <td>
     124                        <label for="contact">
     125                        <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
     126                        <label for="acquaintance">
     127                        <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> />  <?php _e('acquaintance') ?></label>
     128                        <label for="friend">
     129                        <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
     130                        <label for="friendship">
     131                        <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label>
     132                    </td>
     133                </tr>
     134                <tr>
     135                    <th scope="row"> <?php _e('physical') ?> </th>
     136                    <td>
     137                        <label for="met">
     138                        <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
     139                        <?php _e('met') ?></label>
     140                    </td>
     141                </tr>
     142                <tr>
     143                    <th scope="row"> <?php _e('professional') ?> </th>
     144                    <td>
     145                        <label for="co-worker">
     146                        <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
     147                        <?php _e('co-worker') ?></label>
     148                        <label for="colleague">
     149                        <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
     150                        <?php _e('colleague') ?></label>
     151                    </td>
     152                </tr>
     153                <tr>
     154                    <th scope="row"> <?php _e('geographical') ?> </th>
     155                    <td>
     156                        <label for="co-resident">
     157                        <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
     158                        <?php _e('co-resident') ?></label>
     159                        <label for="neighbor">
     160                        <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
     161                        <?php _e('neighbor') ?></label>
     162                        <label for="geographical">
     163                        <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
     164                        <?php _e('none') ?></label>
     165                    </td>
     166                </tr>
     167                <tr>
     168                    <th scope="row"> <?php _e('family') ?> </th>
     169                    <td>
     170                        <label for="child">
     171                        <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?>  />
     172                        <?php _e('child') ?></label>
     173                        <label for="kin">
     174                        <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?>  />
     175                        <?php _e('kin') ?></label>
     176                        <label for="parent">
     177                        <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
     178                        <?php _e('parent') ?></label>
     179                        <label for="sibling">
     180                        <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
     181                        <?php _e('sibling') ?></label>
     182                        <label for="spouse">
     183                        <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
     184                        <?php _e('spouse') ?></label>
     185                        <label for="family">
     186                        <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
     187                        <?php _e('none') ?></label>
     188                    </td>
     189                </tr>
     190                <tr>
     191                    <th scope="row"> <?php _e('romantic') ?> </th>
     192                    <td>
     193                        <label for="muse">
     194                        <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
     195                        <?php _e('muse') ?></label>
     196                        <label for="crush">
     197                        <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
     198                        <?php _e('crush') ?></label>
     199                        <label for="date">
     200                        <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
     201                        <?php _e('date') ?></label>
     202                        <label for="romantic">
     203                        <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
     204                        <?php _e('sweetheart') ?></label>
     205                    </td>
     206                </tr>
     207            </table>
     208        </td>
     209    </tr>
    169210</table>
    170 </fieldset>
    171        <p class="submit">
    172        <input type="submit" name="submit" value="<?php echo $submit_text ?>" />
    173        </p>
    174 <fieldset class="options">
    175         <legend><?php _e('Advanced') ?></legend>
    176         <table class="editform" width="100%" cellspacing="2" cellpadding="5">
    177          <tr>
    178            <th width="33%" scope="row"><?php _e('Image URI:') ?></th>
    179            <td width="67%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
    180          </tr>
    181 <tr>
    182            <th scope="row"><?php _e('RSS URI:') ?> </th>
    183            <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
    184          </tr>
    185          <tr>
    186            <th scope="row"><?php _e('Notes:') ?></th>
    187            <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td>
    188          </tr>
    189          <tr>
    190            <th scope="row"><?php _e('Rating:') ?></th>
    191            <td><select name="link_rating" size="1">
    192 <?php
    193     for ($r = 0; $r < 10; $r++) {
    194       echo('            <option value="'.$r.'" ');
    195       if ($link->link_rating == $r)
    196         echo 'selected="selected"';
    197       echo('>'.$r.'</option>');
    198     }
    199 ?>
    200            </select>
    201          &nbsp;<?php _e('(Leave at 0 for no rating.)') ?> </td>
    202          </tr>
    203          <tr>
    204            <th scope="row"><?php _e('Target') ?></th>
    205            <td><label>
    206           <input type="radio" name="link_target" value="_blank"   <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
    207           <code>_blank</code></label><br />
    208 <label>
    209 <input type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
    210 <code>_top</code></label><br />
    211 <label>
    212 <input type="radio" name="link_target" value=""     <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
    213 <?php _e('none') ?></label><br />
    214 <?php _e('(Note that the <code>target</code> attribute is illegal in XHTML 1.1 and 1.0 Strict.)') ?></td>
    215          </tr>
    216          <tr>
    217            <th scope="row"><?php _e('Visible:') ?></th>
    218            <td><label>
    219              <input type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
    220 <?php _e('Yes') ?></label><br /><label>
    221 <input type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" />
    222 <?php _e('No') ?></label></td>
    223          </tr>
     211</div>
     212</fieldset>
     213
     214<fieldset id="advanced" class="dbx-box">
     215<h3 class="dbx-handle"><?php _e('Advanced') ?></h3>
     216<div class="dbx-content">
     217<table class="editform" width="100%" cellspacing="2" cellpadding="5">
     218    <tr>
     219        <th width="20%" scope="row"><?php _e('Image Address:') ?></th>
     220        <td width="80%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
     221    </tr>
     222    <tr>
     223        <th scope="row"><?php _e('RSS Address:') ?> </th>
     224        <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
     225    </tr>
     226    <tr>
     227        <th scope="row"><?php _e('Notes:') ?></th>
     228        <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td>
     229    </tr>
     230    <tr>
     231        <th scope="row"><?php _e('Rating:') ?></th>
     232        <td><select name="link_rating" size="1">
     233        <?php
     234            for ($r = 0; $r < 10; $r++) {
     235                echo('            <option value="'.$r.'" ');
     236                if ($link->link_rating == $r)
     237                    echo 'selected="selected"';
     238                echo('>'.$r.'</option>');
     239            }
     240        ?></select>&nbsp;<?php _e('(Leave at 0 for no rating.)') ?>
     241        </td>
     242    </tr>
    224243</table>
    225244</fieldset>
    226 <p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p>
    227 <?php if ( $editing ) : ?>
    228           <input type="hidden" name="action" value="editlink" />
    229           <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
    230           <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
    231           <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
     245</div>
     246
     247<?php if ( $link_id ) : ?>
     248<input type="hidden" name="action" value="save" />
     249<input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
     250<input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
     251<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
    232252<?php else: ?>
    233         <input type="hidden" name="action" value="Add" />
     253<input type="hidden" name="action" value="add" />
    234254<?php endif; ?>
    235 </form>
    236 </div>
     255</div>
     256</form>
     257</div>
  • trunk/wp-admin/edit-page-form.php

    r3503 r4431  
    11
    22<div class="wrap">
    3 <h2 id="write-post"><?php _e('Write Page'); ?><?php if ( 0 != $post_ID ) : ?>
    4 <small class="quickjump"><a href="#preview-post"><?php _e('preview &darr;'); ?></a></small><?php endif; ?></h2>
     3<h2 id="write-post"><?php _e('Write Page'); ?></h2>
    54<?php
    65if (0 == $post_ID) {
    76    $form_action = 'post';
     7    $nonce_action = 'add-page';
    88    $temp_ID = -1 * time();
    9     $form_extra = "<input type='hidden' name='temp_ID' value='$temp_ID' />";
     9    $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
    1010} else {
    1111    $form_action = 'editpost';
    12     $form_extra = "<input type='hidden' name='post_ID' value='$post_ID' />";
     12    $nonce_action = 'update-page_' . $post_ID;
     13    $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
    1314}
    1415
    15 $sendto = $_SERVER['HTTP_REFERER'];
     16$sendto = wp_get_referer();
    1617
    1718if ( 0 != $post_ID && $sendto == get_permalink($post_ID) )
     
    2122?>
    2223
    23 <form name="post" action="post.php" method="post" id="post">
     24<form name="post" action="page.php" method="post" id="post">
    2425
    2526<?php
     27wp_nonce_field($nonce_action);
     28
    2629if (isset($mode) && 'bookmarklet' == $mode) {
    2730    echo '<input type="hidden" name="mode" value="bookmarklet" />';
     
    2932?>
    3033<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
    31 <input type="hidden" name="action" value='<?php echo $form_action ?>' />
     34<input type="hidden" id="hiddenaction" name="action" value='<?php echo $form_action ?>' />
     35<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
    3236<?php echo $form_extra ?>
    33 <input type="hidden" name="post_status" value="static" />
     37<input type="hidden" id="post_type" name="post_type" value="page" />
    3438
    3539<script type="text/javascript">
    36 <!--
     40// <![CDATA[
    3741function focusit() { // focus on first input field
    3842    document.post.title.focus();
    3943}
    4044addLoadEvent(focusit);
    41 //-->
     45// ]]>
    4246</script>
    4347<div id="poststuff">
     
    5660</fieldset>
    5761
     62<fieldset class="dbx-box">
     63<h3 class="dbx-handle"><?php _e('Page Status') ?></h3>
     64<div class="dbx-content"><?php if ( current_user_can('publish_pages') ) : ?>
     65<label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label>
     66<?php endif; ?>
     67      <label for="post_status_draft" class="selectit"><input id="post_status_draft" name="post_status" type="radio" value="draft" <?php checked($post->post_status, 'draft'); ?> /> <?php _e('Draft') ?></label>
     68      <label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="radio" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php _e('Private') ?></label></div>
     69</fieldset>
     70
    5871<fieldset id="passworddiv" class="dbx-box">
    59 <h3 class="dbx-handle"><?php _e('Password-Protect Post') ?></h3>
     72<h3 class="dbx-handle"><?php _e('Page Password') ?></h3>
    6073<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password ?>" /></div>
    6174</fieldset>
     
    7184
    7285<?php if ( 0 != count( get_page_templates() ) ) { ?>
    73 <fieldset id="pageparent" class="dbx-box">
     86<fieldset id="pagetemplate" class="dbx-box">
    7487<h3 class="dbx-handle"><?php _e('Page Template:') ?></h3>
    7588<div class="dbx-content"><p><select name="page_template">
     
    8295
    8396<fieldset id="slugdiv" class="dbx-box">
    84 <h3 class="dbx-handle"><?php _e('Post slug') ?></h3>
     97<h3 class="dbx-handle"><?php _e('Page Slug') ?></h3>
    8598<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo $post->post_name ?>" /></div>
    8699</fieldset>
     
    88101<?php if ( $authors = get_editable_authors( $current_user->id ) ) : // TODO: ROLE SYSTEM ?>
    89102<fieldset id="authordiv" class="dbx-box">
    90 <h3 class="dbx-handle"><?php _e('Post author'); ?>:</h3>
     103<h3 class="dbx-handle"><?php _e('Page Author'); ?>:</h3>
    91104<div class="dbx-content">
    92105<select name="post_author_override" id="post_author_override">
     
    122135<fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>">
    123136    <legend><?php _e('Page Content') ?></legend>
    124 <?php
    125  $rows = get_settings('default_post_edit_rows');
    126  if (($rows < 3) || ($rows > 100)) {
    127      $rows = 10;
    128  }
    129 ?>
    130 <?php the_quicktags(); ?>
    131 
    132 <div><textarea title="true" rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content"><?php echo user_can_richedit() ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div>
     137    <?php the_editor($post->post_content); ?>
    133138</fieldset>
    134139
    135 <script type="text/javascript">
    136 <!--
    137 edCanvas = document.getElementById('content');
    138 <?php if ( user_can_richedit() ) : ?>
    139 // This code is meant to allow tabbing from Title to Post (TinyMCE).
    140 if ( tinyMCE.isMSIE )
    141     document.getElementById('title').onkeydown = function (e)
    142         {
    143             e = e ? e : window.event;
    144             if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
    145                 var i = tinyMCE.selectedInstance;
    146                 if(typeof i ==  'undefined')
    147                     return true;
    148                                 tinyMCE.execCommand("mceStartTyping");
    149                 this.blur();
    150                 i.contentWindow.focus();
    151                 e.returnValue = false;
    152                 return false;
    153             }
    154         }
    155 else
    156     document.getElementById('title').onkeypress = function (e)
    157         {
    158             e = e ? e : window.event;
    159             if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
    160                 var i = tinyMCE.selectedInstance;
    161                 if(typeof i ==  'undefined')
    162                     return true;
    163                                 tinyMCE.execCommand("mceStartTyping");
    164                 this.blur();
    165                 i.contentWindow.focus();
    166                 e.returnValue = false;
    167                 return false;
    168             }
    169         }
    170 <?php endif; ?>
    171 //-->
    172 </script>
    173 
    174140<p class="submit">
    175 <?php if ( $post_ID ) : ?>
    176 <input name="save" type="submit" id="save" tabindex="5" value=" <?php _e('Save and Continue Editing'); ?> "/>
    177 <input name="savepage" type="submit" id="savepage" tabindex="6" value="<?php $post_ID ? _e('Save') : _e('Create New Page') ?> &raquo;" />
    178 <?php else : ?>
    179 <input name="savepage" type="submit" id="savepage" tabindex="6" value="<?php _e('Create New Page') ?> &raquo;" />
    180 <?php endif; ?>
     141<span id="autosave"></span>
     142<input name="save" type="submit" id="save" tabindex="3" value="<?php _e('Save and Continue Editing'); ?>" />
     143<input type="submit" name="submit" value="<?php _e('Save') ?>" style="font-weight: bold;" tabindex="4" />
     144<?php
     145if ('publish' != $post->post_status || 0 == $post_ID):
     146?>
     147<?php if ( current_user_can('publish_pages') ) : ?>
     148    <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
     149<?php endif; endif;?>
    181150<input name="referredby" type="hidden" id="referredby" value="<?php echo $sendto; ?>" />
    182151</p>
     
    187156if (current_user_can('upload_files')) {
    188157    $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
    189     $uploading_iframe_src = "inline-uploading.php?action=view&amp;post=$uploading_iframe_ID";
     158    $uploading_iframe_src = wp_nonce_url("upload.php?style=inline&amp;tab=upload&amp;post_id=$uploading_iframe_ID", 'inlineuploading');
    190159    $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
    191160    if ( false != $uploading_iframe_src )
    192         echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
     161        echo '<iframe id="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
    193162}
    194163?>
     
    199168<h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3>
    200169<div id="postcustomstuff" class="dbx-content">
     170<table cellpadding="3">
    201171<?php
    202 if($metadata = has_meta($post_ID)) {
     172$metadata = has_meta($post_ID);
     173list_meta($metadata);
    203174?>
     175
     176</table>
    204177<?php
    205     list_meta($metadata);
    206 ?>
    207 <?php
    208 }
    209178    meta_form();
    210179?>
    211180</div>
     181<div id="ajax-response"></div>
    212182</fieldset>
    213183
     
    216186</div>
    217187
    218 <?php if ('edit' == $action) : ?>
    219         <input name="deletepost" class="delete" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this page') ?>" <?php echo "onclick=\"return confirm('" . sprintf(__("You are about to delete this page \'%s\'\\n  \'Cancel\' to stop, \'OK\' to delete."), $wpdb->escape($post->post_title) ) . "')\""; ?> />
     188<?php if ('edit' == $action) :
     189    $delete_nonce = wp_create_nonce( 'delete-page_' . $post_ID );
     190    if ( current_user_can('delete_page', $post->ID) ) ?>
     191        <input name="deletepost" class="button delete" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this page') ?>" <?php echo "onclick=\"if ( confirm('" . sprintf(__("You are about to delete this page \'%s\'\\n  \'Cancel\' to stop, \'OK\' to delete."), js_escape($post->post_title) ) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}return false;\""; ?> />
    220192<?php endif; ?>
     193</div>
     194
    221195</form>
    222196
    223197</div>
    224 
    225 </div>
  • trunk/wp-admin/edit-pages.php

    r3503 r4431  
    33$title = __('Pages');
    44$parent_file = 'edit.php';
    5 $list_js = true;
     5wp_enqueue_script( 'listman' );
    66require_once('admin-header.php');
    77?>
     
    99<div class="wrap">
    1010<h2><?php _e('Page Management'); ?></h2>
    11 <p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page'); ?> &raquo;</a></p>
     11<p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page &raquo;'); ?></a></p>
    1212
    1313<form name="searchform" action="" method="get">
     
    2020
    2121<?php
     22wp('post_type=page&orderby=menu_order&what_to_show=posts&posts_per_page=-1&posts_per_archive_page=-1');
    2223
    23 $show_post_type = 'page';
    24 
    25 if ( isset($_GET['s']) )
    26     wp();
     24if ( $_GET['s'] )
     25    $all = false;
    2726else
    28     $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static'");
     27    $all = true;
    2928
    3029if ($posts) {
    3130?>
    32 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
    33   <tr>
    34     <th scope="col"><?php _e('ID') ?></th>
    35     <th scope="col"><?php _e('Title') ?></th>
     31<table class="widefat">
     32  <thead>
     33  <tr>
     34    <th scope="col" style="text-align: center"><?php _e('ID') ?></th>
     35    <th scope="col"><?php _e('Title') ?></th>
    3636    <th scope="col"><?php _e('Owner') ?></th>
    3737    <th scope="col"><?php _e('Updated') ?></th>
    38     <th scope="col"></th>
    39     <th scope="col"></th>
    40     <th scope="col"></th>
    41   </tr>
     38    <th scope="col" colspan="3" style="text-align: center"><?php _e('Action'); ?></th>
     39  </tr>
     40  </thead>
     41  <tbody id="the-list">
    4242<?php
    43 if ( isset($_GET['s']) ) {
    44 foreach ( $posts as $post ) :
    45     $class = ('alternate' != $class) ? 'alternate' : ''; ?>
    46   <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
    47     <th scope="row"><?php echo $post->ID; ?></th>
    48     <td>
    49       <?php echo $pad; ?><?php the_title() ?>
    50     </td>
    51     <td><?php the_author() ?></td>
    52     <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td>
    53     <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
    54     <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
    55     <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td>
    56   </tr>
    57 <?php
    58 endforeach;
    59 } else {
    60     page_rows();
    61 }
     43page_rows(0, 0, $posts, $all);
    6244?>
    63 </table>
     45  </tbody>
     46</table>
    6447
    6548<div id="ajax-response"></div>
     
    7356?>
    7457
    75 <h3><a href="page-new.php"><?php _e('Create New Page'); ?> &raquo;</a></h3>
     58<h3><a href="page-new.php"><?php _e('Create New Page &raquo;'); ?></a></h3>
    7659
    7760</div>
  • trunk/wp-admin/edit.php

    r3503 r4431  
    44$title = __('Posts');
    55$parent_file = 'edit.php';
    6 $list_js = true;
     6wp_enqueue_script( 1 == $_GET['c'] ? 'admin-comments' : 'listman' );
    77require_once('admin-header.php');
    88
     
    5656<h2>
    5757<?php
    58 $what_to_show = 'posts';
    59 $posts_per_page = 15;
    60 $posts_per_archive_page = -1;
    61 
    62 wp();
     58
     59wp('what_to_show=posts&posts_per_page=15&posts_per_archive_page=-1');
    6360
    6461if ( is_month() ) {
     
    7774</h2>
    7875
    79 <form name="searchform" action="" method="get" style="float: left; width: 16em; margin-right: 3em;">
     76<form name="searchform" id="searchform" action="" method="get">
    8077  <fieldset>
    8178  <legend><?php _e('Search Posts&hellip;') ?></legend>
    8279  <input type="text" name="s" value="<?php if (isset($s)) echo wp_specialchars($s, 1); ?>" size="17" />
    83   <input type="submit" name="submit" value="<?php _e('Search') ?>" />
     80  <input type="submit" name="submit" value="<?php _e('Search') ?>" class="button" />
    8481  </fieldset>
    8582</form>
    8683
    87 <?php $arc_result = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_date != '0000-00-00 00:00:00' ORDER BY post_date DESC");
     84<?php $arc_result = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC");
    8885
    8986if ( count($arc_result) ) { ?>
    9087
    91 <form name="viewarc" action="" method="get" style="float: left; width: 20em; margin-bottom: 1em;">
     88<form name="viewarc" id="viewarc" action="" method="get">
    9289    <fieldset>
    9390    <legend><?php _e('Browse Month&hellip;') ?></legend>
    9491    <select name='m'>
    9592    <?php
    96         foreach ($arc_result as $arc_row) {         
    97             $arc_year  = $arc_row->yyear;
    98             $arc_month = $arc_row->mmonth;
    99            
    100             if( isset($_GET['m']) && $arc_year . zeroise($arc_month, 2) == (int) $_GET['m'] )
     93        foreach ($arc_result as $arc_row) {
     94            if ( $arc_row->yyear == 0 )
     95                continue;
     96            $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
     97
     98            if( isset($_GET['m']) && $arc_row->yyear . $arc_row->mmonth == (int) $_GET['m'] )
    10199                $default = 'selected="selected"';
    102100            else
    103101                $default = null;
    104            
    105             echo "<option $default value=\"" . $arc_year.zeroise($arc_month, 2) . '">';
    106             echo $month[zeroise($arc_month, 2)] . " $arc_year";
     102
     103            echo "<option $default value='$arc_row->yyear$arc_row->mmonth'>";
     104            echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
    107105            echo "</option>\n";
    108106        }
    109107    ?>
    110108    </select>
    111         <input type="submit" name="submit" value="<?php _e('Show Month') ?>" />
     109        <input type="submit" name="submit" value="<?php _e('Show Month') ?>" class="button" />
    112110    </fieldset>
    113111</form>
     
    115113<?php } ?>
    116114
     115<form name="viewcat" id="viewcat" action="" method="get">
     116    <fieldset>
     117    <legend><?php _e('Browse Category&hellip;') ?></legend>
     118    <?php wp_dropdown_categories('show_option_all='.__('All').'&hide_empty=1&hierarchical=1&show_count=1&selected='.$cat);?>
     119    <input type="submit" name="submit" value="<?php _e('Show Category') ?>" class="button" />
     120    </fieldset>
     121</form>
     122
     123<?php do_action('restrict_manage_posts'); ?>
     124
    117125<br style="clear:both;" />
    118126
    119127<?php
    120 
    121128// define the columns to display, the syntax is 'internal name' => 'display name'
    122129$posts_columns = array(
     
    137144?>
    138145
    139 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
     146<table class="widefat">
     147    <thead>
    140148    <tr>
    141149
     
    145153
    146154    </tr>
     155    </thead>
     156    <tbody id="the-list">
    147157<?php
    148158if ($posts) {
    149159$bgcolor = '';
    150160foreach ($posts as $post) { start_wp();
     161add_filter('the_title','wp_specialchars');
    151162$class = ('alternate' == $class) ? '' : 'alternate';
    152163?>
     
    158169
    159170    switch($column_name) {
    160    
     171
    161172    case 'id':
    162173        ?>
    163         <th scope="row"><?php echo $id ?></th>
     174        <th scope="row" style="text-align: center"><?php echo $id ?></th>
    164175        <?php
    165176        break;
     
    185196    case 'comments':
    186197        ?>
    187         <td><a href="edit.php?p=<?php echo $id ?>&amp;c=1">
     198        <td style="text-align: center"><a href="edit.php?p=<?php echo $id ?>&amp;c=1">
    188199      <?php comments_number(__('0'), __('1'), __('%')) ?>
    189200      </a></td>
     
    211222    case 'control_delete':
    212223        ?>
    213         <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . sprintf(__("You are about to delete this post &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars(get_the_title('', ''), 1) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
     224        <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . sprintf(__("You are about to delete this post &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), js_escape(get_the_title()) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
    214225        <?php
    215226        break;
     
    233244<?php
    234245} // end if ($posts)
    235 ?>
     246?>
     247    </tbody>
    236248</table>
    237249
     
    249261    if ($comments) {
    250262    ?>
    251 <h3><?php _e('Comments') ?></h3>
    252 <ol id="comments">
    253 <?php
     263<h3 id="comments"><?php _e('Comments') ?></h3>
     264<ol id="the-comment-list" class="commentlist">
     265<?php
     266$i = 0;
    254267foreach ($comments as $comment) {
    255 $comment_status = wp_get_comment_status($comment->comment_ID);
    256 ?>
    257 
    258 <li <?php if ("unapproved" == $comment_status) echo "class='unapproved'"; ?> >
    259   <?php comment_date('Y-n-j') ?>
    260   @
    261   <?php comment_time('g:m:s a') ?>
    262   <?php
    263             if ( current_user_can('edit_post', $post->ID) ) {
    264                 echo "[ <a href=\"post.php?action=editcomment&amp;comment=".$comment->comment_ID."\">" .  __('Edit') . "</a>";
    265                 echo " - <a href=\"post.php?action=deletecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n  \'OK\' to delete, \'Cancel\' to stop."), $comment->comment_author) . "')\">" . __('Delete') . "</a> ";
    266                 if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
    267                     if ('approved' == wp_get_comment_status($comment->comment_ID)) {
    268                         echo " - <a href=\"post.php?action=unapprovecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\">" . __('Unapprove') . "</a> ";
    269                     } else {
    270                         echo " - <a href=\"post.php?action=approvecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\">" . __('Approve') . "</a> ";
    271                     }
    272                 }
    273                 echo "]";
    274             } // end if any comments to show
    275             ?>
    276   <br />
    277   <strong>
    278   <?php comment_author() ?>
    279   (
    280   <?php comment_author_email_link() ?>
    281   /
    282   <?php comment_author_url_link() ?>
    283   )</strong> (IP:
    284   <?php comment_author_IP() ?>
    285   )
    286   <?php comment_text() ?>
    287 
    288 </li>
    289 <!-- /comment -->
     268
     269        ++$i; $class = '';
     270        $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
     271            $comment_status = wp_get_comment_status($comment->comment_ID);
     272            if ('unapproved' == $comment_status)
     273                $class .= ' unapproved';
     274            if ($i % 2)
     275                $class .= ' alternate';
     276            echo "<li id='comment-$comment->comment_ID' class='$class'>";
     277?>
     278<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>
     279
     280<?php comment_text() ?>
     281
     282<p><?php comment_date('M j, g:i A');  ?> &#8212; [
     283<?php
     284if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
     285    echo " <a href='comment.php?action=editcomment&amp;comment=".$comment->comment_ID."\'>" .  __('Edit') . '</a>';
     286    echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
     287    if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
     288        echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
     289        echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
     290    }
     291    echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;delete_type=spam&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to mark as spam."), js_escape( $comment->comment_author))  . "', theCommentList );\">" . __('Spam') . "</a> ]";
     292} // end if any comments to show
     293?>
     294</p>
     295        </li>
     296
    290297<?php //end of the loop, don't delete
    291298        } // end foreach
  • trunk/wp-admin/import.php

    r3503 r4431  
    22require_once ('admin.php');
    33$title = __('Import');
    4 $parent_file = 'import.php';
     4$parent_file = 'edit.php';
    55require_once ('admin-header.php');
    66?>
     
    3131} else {
    3232?>
    33 <table width="100%" cellpadding="3" cellspacing="3">
     33<table class="widefat">
    3434
    3535<?php
     
    3737    foreach ($importers as $id => $data) {
    3838        $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate';
    39         $action = "<a href='admin.php?import=$id' title='{$data[1]}'>{$data[0]}</a>";
     39        $action = "<a href='admin.php?import=$id' title='".wptexturize(strip_tags($data[1]))."'>{$data[0]}</a>";
    4040
    4141        if ($style != '')
     
    4343        echo "
    4444            <tr $style>
    45                 <td class=\"togl\">$action</td>
    46                 <td class=\"desc\">{$data[1]}</td>
     45                <td class='import-system'>$action</td>
     46                <td class='desc'>{$data[1]}</td>
    4747            </tr>";
    4848    }
  • trunk/wp-admin/import/blogger.php

    r3503 r4431  
    2626    function restart() {
    2727        delete_option('import-blogger');
    28         header("Location: admin.php?import=blogger");
     28        wp_redirect("admin.php?import=blogger");
    2929        die();
    3030    }
     
    136136        if ($header) curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    137137        $response = curl_exec ($ch);
    138    
     138
    139139        if ($parse) {
    140140            $response = $this->parse_response($response);
     
    142142            return $response;
    143143        }
    144    
     144
    145145        return $response;
    146146    }
     
    211211        update_option('import-blogger', $this->import);
    212212    }
    213    
     213
    214214    // Redirects to next step
    215215    function do_next_step() {
    216         header("Location: admin.php?import=blogger&noheader=true&blog={$_GET['blog']}");
     216        wp_redirect("admin.php?import=blogger&noheader=true&blog={$_GET['blog']}");
    217217        die();
    218218    }
     
    225225                $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>');
    226226            }
    227        
    228             // Try logging in. If we get an array of cookies back, we at least connected.       
     227
     228            // Try logging in. If we get an array of cookies back, we at least connected.
    229229            $this->import['cookies'] = $this->login_blogger($_POST['user'], $_POST['pass']);
    230230            if ( !is_array( $this->import['cookies'] ) ) {
    231231                $this->login_form(__('Login failed. Please enter your credentials again.'));
    232232            }
    233            
     233
    234234            // Save the password so we can log the browser in when it's time to publish.
    235235            $this->import['pass'] = $_POST['pass'];
     
    242242            preg_match_all('#posts\.g\?blogID=(\d+)">([^<]+)</a>#U', $response['body'], $blogsary);
    243243            if ( ! count( $blogsary[1] < 1 ) )
    244                 die(__('No blogs found for this user.'));
     244                wp_die(__('No blogs found for this user.'));
    245245            $this->import['blogs'] = array();
    246246            $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>';
     
    274274            }
    275275            update_option('import-blogger', $this->import);
    276             header("Location: admin.php?import=blogger&noheader=true&step=1");
     276            wp_redirect("admin.php?import=blogger&noheader=true&step=1");
    277277        }
    278278        die();
     
    307307                            $response = $this->get_blogger("http://www.blogger.com/blog-publishing.g?blogID={$_GET['blog']}&publishMode=0", $headers);
    308308                            if ( $response['code'] >= 400 )
    309                                 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>');
     309                                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>');
    310310                            $this->import['blogs'][$_GET['blog']]['url'] = 'http://' . $optary['modify']['subdomain'] . '.blogspot.com/';
    311311                            sleep(2);
     
    322322                    $response = $this->post_blogger($posturl, $headers, $paramary);
    323323                    if ( $response['code'] >= 400 || strstr($response['body'], 'There are errors on this form') )
    324                         die('<p>'.__('Error on form submission. Retry or reset the importer.').'</p>' . addslashes(print_r($response, 1)));
     324                        wp_die('<p>'.__('Error on form submission. Retry or reset the importer.').'</p>' . addslashes(print_r($response, 1)));
    325325                }
    326326                $output .= "<del><p>$blog_opt</p></del>\n";
     
    342342                $form.= $body;
    343343                $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>";
    344                 $output.= '<p>'.sprintf('<strong>%s</strong> in progress, please wait...', $blog_opt)."</p>\n";
     344                $output.= '<p>'.sprintf(__('<strong>%s</strong> in progress, please wait...'), $blog_opt)."</p>\n";
    345345            } else {
    346346                $output.= "<p>$blog_opt</p>\n";
     
    365365        $bloghtml = $this->get_blogger($this->import['blogs'][$_GET['blog']]['url']);
    366366        if (! strstr($bloghtml['body'], '<a class="archive"') )
    367             die(__('Your Blogger blog did not take the new template or did not respond.'));
     367            wp_die(__('Your Blogger blog did not take the new template or did not respond.'));
    368368        preg_match_all('#<a class="archive" href="([^"]*)"#', $bloghtml['body'], $archives);
    369369        foreach ($archives[1] as $archive) {
     
    396396                $archive = $this->get_blogger($url);
    397397                if ( $archive['code'] > 200 )
    398                     continue;   
     398                    continue;
    399399                $posts = explode('<wordpresspost>', $archive['body']);
    400400                for ($i = 1; $i < count($posts); $i = $i + 1) {
     
    410410                    $post_author_name = $wpdb->escape(trim($postinfo[1]));
    411411                    $post_author_email = $postinfo[5] ? $postinfo[5] : 'user@wordpress.org';
    412    
     412
    413413                    if ( $this->lump_authors ) {
    414414                        // Ignore Blogger authors. Use the current user_ID for all posts imported.
     
    421421                            $user_password = substr(md5(uniqid(microtime())), 0, 6);
    422422                            $result = wp_create_user( $user_login, $user_password, $user_email );
    423                             $status.= sprintf('Registered user <strong>%s</strong>.', $user_login);
     423                            $status.= sprintf(__('Registered user <strong>%s</strong>.'), $user_login);
    424424                            $this->import['blogs'][$_GET['blog']]['newusers'][] = $user_login;
    425425                        }
     
    436436                    $postminute = zeroise($post_date_His[1], 2);
    437437                    $postsecond = zeroise($post_date_His[2], 2);
    438    
     438
    439439                    if (($post_date[2] == 'PM') && ($posthour != '12'))
    440440                        $posthour = $posthour + 12;
    441441                    else if (($post_date[2] == 'AM') && ($posthour == '12'))
    442442                        $posthour = '00';
    443    
     443
    444444                    $post_date = "$postyear-$postmonth-$postday $posthour:$postminute:$postsecond";
    445    
     445
    446446                    $post_content = addslashes($post_content);
    447447                    $post_content = str_replace(array('<br>','<BR>','<br/>','<BR/>','<br />','<BR />'), "\n", $post_content); // the XHTML touch... ;)
    448    
     448
    449449                    $post_title = addslashes($post_title);
    450            
     450
    451451                    $post_status = 'publish';
    452    
     452
    453453                    if ( $ID = post_exists($post_title, '', $post_date) ) {
    454454                        $post_array[$i]['ID'] = $ID;
     
    510510                }
    511511                $status = sprintf(__('%s post(s) parsed, %s skipped...'), $postcount,  $skippedpostcount).' '.
    512                     sprintf(__('%s comment(s) parsed, %s skipped...'), $commentcoun, $skippedcommentcount).' '.
     512                    sprintf(__('%s comment(s) parsed, %s skipped...'), $commentcount, $skippedcommentcount).' '.
    513513                    ' <strong>'.__('Done').'</strong>';
    514514                $import = $this->import;
     
    547547                        sleep(2);
    548548                        if ( $response['code'] >= 400 )
    549                             die('<h1>Error restoring publishMode.</h1><p>Please tell the devs.</p>' . addslashes(print_r($response, 1)) );
     549                            wp_die('<h1>'.__('Error restoring publishMode').'</h1><p>'.__('Please tell the devs.').'</p>' . addslashes(print_r($response, 1)) );
    550550                    }
    551551                }
     
    598598            $this->restart();
    599599        }
    600        
     600
    601601        if ( isset($_GET['noheader']) ) {
    602             $this->import = get_settings('import-blogger');
     602            header('Content-Type: text/html; charset=utf-8');
     603
     604            $this->import = get_option('import-blogger');
    603605
    604606            if ( false === $this->import ) {
     
    614616            }
    615617//echo "Step $step.";
    616 //die('<pre>'.print_r($this->import,1).'</pre');
     618//wp_die('<pre>'.print_r($this->import,1).'</pre');
    617619            switch ($step) {
    618620                case 0 :
     
    648650            }
    649651            die;
    650            
     652
    651653        } else {
    652654            $this->greet();
     
    661663$blogger_import = new Blogger_Import();
    662664
    663 register_importer('blogger', 'Blogger', __('Import posts and comments from a Blogger account'), array ($blogger_import, 'start'));
     665register_importer('blogger', __('Blogger and Blog*Spot'), __('Import <strong>posts and comments</strong> from your Blogger account'), array ($blogger_import, 'start'));
    664666