Changeset 310

Show
Ignore:
Timestamp:
09/12/05 09:56:20 (3 years ago)
Author:
donncha
Message:

WP Merge

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-inst/wp-admin/admin-functions.php

    r293 r310  
    131131 
    132132        add_meta($post_ID); 
     133         
     134        return $post_ID; 
    133135} 
    134136 
     
    261263 
    262264        if ( $update ) { 
    263                 $rval = $wpdb->rows_affected; 
    264265                do_action('edit_category', $cat_ID); 
    265266        } else { 
    266                 $rval = $wpdb->insert_id; 
    267267                do_action('create_category', $rval); 
    268268                do_action('add_category', $rval); 
     
    271271        list( $update, $cat_ID, $category_nicename, $cat_name, $rval ) = apply_filters( "new_category", $update, $cat_ID, $category_nicename, $cat_name, $rval ); 
    272272 
    273         return $rval
     273        return $cat_ID
    274274} 
    275275 
     
    316316 
    317317        return 1; 
     318} 
     319 
     320function wp_create_category($cat_name) { 
     321        $cat_array = compact('cat_name'); 
     322        return wp_insert_category($cat_array); 
     323} 
     324 
     325 
     326function wp_create_categories($categories, $post_id = '') { 
     327        $cat_ids = array(); 
     328        foreach ($categories as $category) { 
     329                if ( $id = category_exists($category) ) 
     330                        $cat_ids[] = $id; 
     331                else if ( $id = wp_create_category($category) ) 
     332                        $cat_ids[] = $id;                                
     333        } 
     334         
     335        if ( $post_id ) 
     336                wp_set_post_cats('', $post_id, $cat_ids); 
     337                 
     338        return $cat_ids; 
     339} 
     340 
     341function category_exists($cat_name) { 
     342        global $wpdb; 
     343        if ( !$category_nicename = sanitize_title($cat_name) ) 
     344                return 0; 
     345                 
     346        return $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'"); 
    318347} 
    319348 
     
    353382 
    354383        return true; 
     384} 
     385 
     386 
     387function post_exists($title, $content = '', $post_date = '') { 
     388        global $wpdb; 
     389         
     390        if ( !empty($post_date) ) 
     391                $post_date = "AND post_date = '$post_date'"; 
     392 
     393        if ( ! empty($title) ) 
     394                return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' $post_date"); 
     395        else if ( ! empty($content) ) 
     396                return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_content = '$content' $post_date"); 
     397 
     398        return 0; 
    355399} 
    356400 
  • trunk/wp-inst/wp-admin/admin.php

    r205 r310  
    7575        if (! file_exists(ABSPATH . "wp-admin/import/$importer.php")) 
    7676                die(__('Cannot load importer.')); 
    77  
     77         
    7878        include(ABSPATH . "wp-admin/import/$importer.php"); 
    7979 
     
    8686        require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); 
    8787 
     88        define('WP_IMPORTING', true); 
     89 
    8890        call_user_func($wp_importers[$importer][2]); 
    8991                         
  • trunk/wp-inst/wp-admin/edit-form-ajax-cat.php

    r286 r310  
    88        die('-1'); 
    99 
    10 function grab_id() { 
    11         global $new_cat_id; 
    12         $new_cat_id = func_get_arg(0); 
    13 } 
    14  
    1510function get_out_now() { exit; } 
    1611 
    17  
    18 add_action('edit_category', 'grab_id'); 
    19 add_action('create_category', 'grab_id'); 
    2012add_action('shutdown', 'get_out_now', -1); 
    2113 
     
    2416if ( !$category_nicename = sanitize_title($cat_name) ) 
    2517        die('0'); 
    26 if ( $already = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'") ) 
     18if ( $already = category_exists($cat_name) ) 
    2719        die((string) $already); 
    2820 
    2921$cat_name = $wpdb->escape($cat_name); 
    30 $cat_array = compact('cat_name', 'category_nicename'); 
    31 wp_insert_category($cat_array); 
     22$new_cat_id = wp_create_category($cat_name); 
    3223die((string) $new_cat_id); 
    3324?> 
  • trunk/wp-inst/wp-admin/execute-pings.php

    r286 r310  
    3131                foreach($trackbacks as $trackback) { 
    3232                        //echo "trackback : $trackback->ID<br/>"; 
    33                         do_trackback($trackback->ID); 
     33                        do_trackbacks($trackback->ID); 
    3434                } 
    3535        } 
  • trunk/wp-inst/wp-admin/import/rss.php

    r205 r310  
    11<?php 
     2 
     3// Example: 
     4// define('RSSFILE', '/home/example/public_html/rss.xml'); 
     5define('RSSFILE', 'rss.xml'); 
     6 
    27class RSS_Import { 
    38 
    4         var $authors = array (); 
    59        var $posts = array (); 
    610 
     
    1418        } 
    1519 
     20        function unhtmlentities($string) { // From php.net for < 4.3 compat 
     21                $trans_tbl = get_html_translation_table(HTML_ENTITIES); 
     22                $trans_tbl = array_flip($trans_tbl); 
     23                return strtr($string, $trans_tbl); 
     24        } 
     25         
    1626        function greet() { 
    17                 $this->header(); 
    18 ?> 
    19 <p>Howdy! This importer allows you to extract posts from any RSS 2.0 file into your blog. This is useful if you want to import your posts from a system that is not handled by a custom import tool. To get started you must edit the following line in this file (<code>import/rss.php</code>) </p> 
     27                _e("<p>Howdy! This importer allows you to extract posts from any RSS 2.0 file into your blog. This is useful if you want to import your posts from a system that is not handled by a custom import tool. To get started you must edit the following line in this file (<code>import/rss.php</code>) </p> 
    2028<p><code>define('RSSFILE', '');</code></p> 
    2129<p>You want to define where the RSS file we'll be working with is, for example: </p> 
    2230<p><code>define('RSSFILE', 'rss.xml');</code></p> 
    23 <p>You have to do this manually for security reasons. When you're done reload this page and we'll take you to the next step.</p> 
    24 <?php if ('' != RSSFILE) : ?> 
    25 <a href="admin.php?import=rss&amp;step=1">Begin RSS Import &raquo;</a> 
    26 <?php 
    27  
    28                 endif; 
    29                 $this->footer(); 
     31<p>You have to do this manually for security reasons. When you're done reload this page and we'll take you to the next step.</p>"); 
     32                if ('' != RSSFILE) 
     33                        echo '<a href="admin.php?import=rss&amp;step=1">' . __('Begin RSS Import &raquo;') . '</a>'; 
    3034        } 
    3135 
    3236        function get_posts() { 
     37                global $wpdb; 
     38                 
    3339                set_magic_quotes_runtime(0); 
    3440                $datalines = file(RSSFILE); // Read the file into an array 
     
    3642                $importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata); 
    3743 
    38                 preg_match_all('|<item>(.*?)</item>|is', $importdata, $posts); 
    39                 $this->posts = $posts[1]; 
     44                preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts); 
     45                $this->posts = $this->posts[1]; 
     46                $index = 0; 
     47                foreach ($this->posts as $post) { 
     48                        preg_match('|<title>(.*?)</title>|is', $post, $post_title); 
     49                        $post_title = $wpdb->escape(trim($post_title[1])); 
     50 
     51                        preg_match('|<pubdate>(.*?)</pubdate>|is', $post, $post_date); 
     52 
     53                        if ($post_date) { 
     54                                $post_date = strtotime($post_date[1]); 
     55                        } else { 
     56                                // if we don't already have something from pubDate 
     57                                preg_match('|<dc:date>(.*?)</dc:date>|is', $post, $post_date); 
     58                                $post_date = preg_replace('|([-+])([0-9]+):([0-9]+)$|', '\1\2\3', $post_date[1]); 
     59                                $post_date = str_replace('T', ' ', $post_date); 
     60                                $post_date = strtotime($post_date); 
     61                        } 
     62 
     63                        $post_date = gmdate('Y-m-d H:i:s', $post_date); 
     64 
     65                        preg_match_all('|<category>(.*?)</category>|is', $post, $categories); 
     66                        $categories = $categories[1]; 
     67 
     68                        if (!$categories) { 
     69                                preg_match_all('|<dc:subject>(.*?)</dc:subject>|is', $post, $categories); 
     70                                $categories = $categories[1]; 
     71                        } 
     72 
     73                        $cat_index = 0; 
     74                        foreach ($categories as $category) { 
     75                                $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category)); 
     76                                $cat_index++; 
     77                        } 
     78 
     79                        preg_match('|<guid.+?>(.*?)</guid>|is', $post, $guid); 
     80                        if ($guid) 
     81                                $guid = $wpdb->escape(trim($guid[1])); 
     82                        else 
     83                                $guid = ''; 
     84 
     85                        preg_match('|<content:encoded>(.*?)</content:encoded>|is', $post, $post_content); 
     86                        $post_content = str_replace(array ('<![CDATA[', ']]>'), '', $wpdb->escape(trim($post_content[1]))); 
     87 
     88                        if (!$post_content) { 
     89                                // This is for feeds that put content in description 
     90                                preg_match('|<description>(.*?)</description>|is', $post, $post_content); 
     91                                $post_content = $wpdb->escape($this->unhtmlentities(trim($post_content[1]))); 
     92                        } 
     93 
     94                        // Clean up content 
     95                        $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 
     96                        $post_content = str_replace('<br>', '<br />', $post_content); 
     97                        $post_content = str_replace('<hr>', '<hr />', $post_content); 
     98 
     99                        $post_author = 1; 
     100                        $post_status = 'publish'; 
     101                        $post_date_gmt = $post_date; // FIXME 
     102                        $this->posts[$index] = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_status', 'guid', 'categories'); 
     103                        $index++; 
     104                } 
    40105        } 
    41106 
    42107        function import_posts() { 
    43108                echo '<ol>'; 
    44                 foreach ($this->posts as $post) 
    45                         : $title = $date = $categories = $content = $post_id = ''; 
    46                 echo "<li>Importing post... "; 
    47109 
    48                 preg_match('|<title>(.*?)</title>|is', $post, $title); 
    49                 $title = $wpdb->escape(trim($title[1])); 
    50                 $post_name = sanitize_title($title); 
     110                foreach ($this->posts as $post) { 
     111                        echo "<li>".__('Importing post...'); 
    51112 
    52                 preg_match('|<pubdate>(.*?)</pubdate>|is', $post, $date); 
     113                       extract($post); 
    53114 
    54                 if ($date) 
    55                         : $date = strtotime($date[1]); 
    56                 else 
    57                         : // if we don't already have something from pubDate 
    58                         preg_match('|<dc:date>(.*?)</dc:date>|is', $post, $date); 
    59                 $date = preg_replace('|([-+])([0-9]+):([0-9]+)$|', '\1\2\3', $date[1]); 
    60                 $date = str_replace('T', ' ', $date); 
    61                 $date = strtotime($date); 
    62                 endif; 
     115                        if ($post_id = post_exists($post_title, $post_content, $post_date)) { 
     116                                echo __('Post already imported'); 
     117                        } else { 
     118                                $post_id = wp_insert_post($post); 
     119                                if (!$post_id) 
     120                                        die(__("Couldn't get post ID")); 
     121         
     122                                if (0 != count($categories)) 
     123                                        wp_create_categories($categories, $post_id); 
     124                                echo __('Done !'); 
     125                        } 
     126                        echo '</li>'; 
     127                } 
    63128 
    64                 $post_date = gmdate('Y-m-d H:i:s', $date); 
    65  
    66                 preg_match_all('|<category>(.*?)</category>|is', $post, $categories); 
    67                 $categories = $categories[1]; 
    68  
    69                 if (!$categories) 
    70                         : preg_match_all('|<dc:subject>(.*?)</dc:subject>|is', $post, $categories); 
    71                 $categories = $categories[1]; 
    72                 endif; 
    73  
    74                 preg_match('|<guid.+?>(.*?)</guid>|is', $post, $guid); 
    75                 if ($guid) 
    76                         $guid = $wpdb->escape(trim($guid[1])); 
    77                 else 
    78                         $guid = ''; 
    79  
    80                 preg_match('|<content:encoded>(.*?)</content:encoded>|is', $post, $content); 
    81                 $content = str_replace(array ('<![CDATA[', ']]>'), '', $wpdb->escape(trim($content[1]))); 
    82  
    83                 if (!$content) 
    84                         : // This is for feeds that put content in description 
    85                         preg_match('|<description>(.*?)</description>|is', $post, $content); 
    86                 $content = $wpdb->escape(unhtmlentities(trim($content[1]))); 
    87                 endif; 
    88  
    89                 // Clean up content 
    90                 $content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $content); 
    91                 $content = str_replace('<br>', '<br />', $content); 
    92                 $content = str_replace('<hr>', '<hr />', $content); 
    93  
    94                 // This can mess up on posts with no titles, but checking content is much slower 
    95                 // So we do it as a last resort 
    96                 if ('' == $title) 
    97                         : $dupe = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_content = '$content' AND post_date = '$post_date'"); 
    98                 else 
    99                         : $dupe = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' AND post_date = '$post_date'"); 
    100                 endif; 
    101  
    102                 // Now lets put it in the DB 
    103                 if ($dupe) 
    104                         : echo 'Post already imported'; 
    105                 else 
    106                         : $wpdb->query("INSERT INTO $wpdb->posts  
    107                                         (post_author, post_date, post_date_gmt, post_content, post_title,post_status, comment_status, ping_status, post_name, guid) 
    108                                         VALUES  
    109                                         ('$post_author', '$post_date', DATE_ADD('$post_date', INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE), '$content', '$title', 'publish', '$comment_status', '$ping_status', '$post_name', '$guid')"); 
    110                 $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' AND post_date = '$post_date'"); 
    111                 if (!$post_id) 
    112                         die("couldn't get post ID"); 
    113                 if (0 != count($categories)) 
    114                         : foreach ($categories as $post_category) 
    115                                 : $post_category = unhtmlentities($post_category); 
    116                 // See if the category exists yet 
    117                 $cat_id = $wpdb->get_var("SELECT cat_ID from $wpdb->categories WHERE cat_name = '$post_category'"); 
    118                 if (!$cat_id && '' != trim($post_category)) { 
    119                         $cat_nicename = sanitize_title($post_category); 
    120                         $wpdb->query("INSERT INTO $wpdb->categories (cat_name, category_nicename) VALUES ('$post_category', '$cat_nicename')"); 
    121                         $cat_id = $wpdb->get_var("SELECT cat_ID from $wpdb->categories WHERE cat_name = '$post_category'"); 
    122                 } 
    123                 if ('' == trim($post_category)) 
    124                         $cat_id = 1; 
    125                 // Double check it's not there already 
    126                 $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = $cat_id"); 
    127  
    128                 if (!$exists) { 
    129                         $wpdb->query(" 
    130                                                 INSERT INTO $wpdb->post2cat 
    131                                                 (post_id, category_id) 
    132                                                 VALUES 
    133                                                 ($post_id, $cat_id) 
    134                                                 "); 
    135                 } 
    136                 endforeach; 
    137                 else 
    138                         : $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = 1"); 
    139                 if (!$exists) 
    140                         $wpdb->query("INSERT INTO $wpdb->post2cat (post_id, category_id) VALUES ($post_id, 1) "); 
    141                 endif; 
    142                 echo 'Done!</li>'; 
    143                 endif; 
    144  
    145                 endforeach; 
    146129                echo '</ol>'; 
    147130 
    148131        } 
    149          
    150          
     132 
    151133        function import() { 
    152                 // FIXME:  Don't die. 
    153                 if ('' != RSSFILE && !file_exists(RSSFILE)) die("The file you specified does not seem to exist. Please check the path you've given."); 
    154                 if ('' == RSSFILE) die("You must edit the RSSFILE line as described on the <a href='import-mt.php'>previous page</a> to continue."); 
    155          
     134                // FIXME:  Don't die 
     135                if ('' == RSSFILE) 
     136                        die("You must edit the RSSFILE line as described on the <a href='import-mt.php'>previous page</a> to continue."); 
     137 
     138                if (!file_exists(RSSFILE)) 
     139                        die("The file you specified does not seem to exist. Please check the path you've given."); 
     140 
    156141                $this->get_posts(); 
    157142                $this->import_posts(); 
    158                 echo '<h3>All done. <a href="../">Have fun!</a></h3>'; 
     143                echo '<h3>All done. <a href="' . get_option('home') . '">Have fun!</a></h3>'; 
    159144        } 
    160          
     145 
    161146        function dispatch() { 
    162                 if (empty($_GET['step'])) 
     147                if (empty ($_GET['step'])) 
    163148                        $step = 0; 
    164149                else 
    165150                        $step = (int) $_GET['step']; 
     151 
     152                $this->header(); 
    166153                 
    167154                switch ($step) { 
    168                         case 0
     155                        case 0
    169156                                $this->greet(); 
    170157                                break; 
    171                         case 1
     158                        case 1
    172159                                $this->import(); 
    173160                                break; 
    174161                } 
     162                 
     163                $this->footer(); 
    175164        } 
    176          
     165 
    177166        function RSS_Import() { 
    178167                // Nothing.      
     
    182171$rss_import = new RSS_Import(); 
    183172 
    184 register_importer('rss', 'RSS', 'Import posts from and RSS feed', array($rss_import, 'dispatch')); 
    185  
     173register_importer('rss', 'RSS', __('Import posts from an RSS feed'), array ($rss_import, 'dispatch')); 
    186174?> 
  • trunk/wp-inst/wp-admin/link-import.php

    r27 r310  
    9898 
    9999                if (isset($opml_url) && $opml_url != '') { 
    100                     $opml = implode('', file($opml_url)); 
     100                    $opml = wp_remote_fopen($opml_url); 
    101101                    include_once('link-parse-opml.php'); 
    102102 
  • trunk/wp-inst/wp-admin/list-manipulation.js

    r287 r310  
    4545        else if ( 0 == response ) { ajaxDel.myResponseElement.interHTML = "Something odd happened.  Try refreshing the page? Either that or what you tried to delete never existed in the first place."; } 
    4646        else if ( 1 == response ) { 
    47                 item = document.getElementById(id); 
    48                 Fat.fade_element(item.id,null,700,'#FF3333'); 
    49                 setTimeout('item.parentNode.removeChild(item)', 705); 
     47                theItem = document.getElementById(id); 
     48                Fat.fade_element(id,null,700,'#FF3333'); 
     49                setTimeout('theItem.parentNode.removeChild(theItem)', 705); 
    5050                var pos = getListPos(id); 
    5151                listItems.splice(pos,1); 
  • trunk/wp-inst/wp-admin/options-personal.php

    r136 r310  
    1111<h2><?php _e('Personal Options') ?></h2>  
    1212<form id="personal-options" method="post" action="options-personal-update.php">  
     13<fieldset> 
    1314<p><?php _e('Personal options are just for you, they don&#8217;t affect other users on blog.'); ?><input type="hidden" name="action" value="update" />  
    1415<input type="hidden" name="page_options" value="'rich_editing'<?php do_action('personal_option_list'); ?>" /></p> 
  • trunk/wp-inst/wp-admin/post.php

    r287 r310  
    9393 
    9494case 'editpost': 
    95         edit_post(); 
     95        $post_ID = edit_post(); 
    9696 
    9797        if ($_POST['save']) { 
  • trunk/wp-inst/wp-content/themes/default/archive.php

    r220 r310  
    3131 
    3232                <div class="navigation"> 
    33                         <div class="alignleft"><?php previous_posts_link('&laquo; Previous Entries') ?></div> 
    34                         <div class="alignright"><?php next_posts_link('Next Entries &raquo;') ?></div> 
     33                        <div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div> 
     34                        <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div> 
    3535                </div> 
    3636 
     
    5151 
    5252                <div class="navigation"> 
    53                         <div class="alignleft"><?php previous_posts_link('&laquo; Previous Entries') ?></div> 
    54                         <div class="alignright"><?php next_posts_link('Next Entries &raquo;') ?></div> 
     53                        <div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div> 
     54                        <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div> 
    5555                </div> 
    5656         
  • trunk/wp-inst/wp-includes/capabilities.php

    r205 r310  
    190190 
    191191        function remove_cap($cap) { 
    192                 if ( empty($this->roles[$cap]) ) return; 
     192                if ( empty($this->caps[$cap]) ) return; 
    193193                unset($this->caps[$cap]); 
    194194                update_usermeta($this->id, $this->cap_key, $this->caps); 
  • trunk/wp-inst/wp-includes/classes.php

    r286 r310  
    13661366                                // The requested permalink is in $pathinfo for path info requests and 
    13671367                                //  $req_uri for other requests. 
    1368                                 if (! empty($pathinfo)) { 
     1368                                if (! empty($pathinfo) && ($wp_rewrite->index != $pathinfo)) { 
    13691369                                        $request = $pathinfo; 
    13701370                                } else { 
  • trunk/wp-inst/wp-includes/functions-post.php

    r286 r310  
    155155        if ($post_status == 'publish') { 
    156156                do_action('publish_post', $post_ID); 
    157                 if ($post_pingback
     157                if ($post_pingback && !defined('WP_IMPORTING')
    158158                        $result = $wpdb->query(" 
    159159                                INSERT INTO $wpdb->postmeta  
  • trunk/wp-inst/wp-includes/functions.php

    r286 r310  
    371371// thx Alex Stapleton, http://alex.vort-x.net/blog/ 
    372372function add_option($name, $value = '', $description = '', $autoload = 'yes') { 
    373         global $wpdb; 
     373        global $wpdb, $cache_settings; 
     374 
     375        // Make sure the option doesn't already exist 
     376        if ( isset($cache_settings->$name) ) 
     377                return; 
     378 
    374379        $original = $value; 
    375380        if ( is_array($value) || is_object($value) ) 
  • trunk/wp-inst/wp-includes/template-functions-author.php

    r13 r310  
    33function get_the_author($idmode = '') { 
    44    global $authordata; 
    5     return $authordata->display_name
     5    return apply_filters('the_author', $authordata->display_name)
    66} 
    77 
  • trunk/wp-inst/wp-includes/template-functions-links.php

    r220 r310  
    180180 
    181181    $location = get_settings('siteurl') . "/wp-admin/post.php?action=edit&amp;post=$post->ID"; 
    182     echo "$before <a href=\"$location\">$link</a> $after"
     182    echo $before . "<a href=\"$location\">$link</a>" . $after
    183183} 
    184184 
     
    193193 
    194194    $location = get_settings('siteurl') . "/wp-admin/post.php?action=editcomment&amp;comment=$comment->comment_ID"; 
    195     echo "$before <a href='$location'>$link</a> $after"
     195    echo $before . "<a href='$location'>$link</a>" . $after
    196196} 
    197197 
     
    438438                                $max_page = $max_num_pages; 
    439439                        } else { 
    440         preg_match('#FROM (.*) GROUP BY#', $request, $matches); 
     440        preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); 
    441441        $fromwhere = $matches[1]; 
    442         $numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $fromwhere"); 
     442        $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere"); 
    443443        $max_page = $max_num_pages = ceil($numposts / $posts_per_page); 
    444444                        } 
     
    480480                if (get_query_var('what_to_show') == 'posts') { 
    481481                        if ( ! isset($max_num_pages) ) { 
    482                                 preg_match('#FROM (.*) GROUP BY#', $request, $matches); 
     482                                preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); 
    483483                                $fromwhere = $matches[1]; 
    484                                 $numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $fromwhere"); 
     484                                $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere"); 
    485485                                $max_num_pages = ceil($numposts / $posts_per_page); 
    486486                        } 
  • trunk/wp-inst/wp-rdf.php

    r13 r310  
    3333        <items> 
    3434                <rdf:Seq> 
    35                 <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?> 
     35                <?php while (have_posts()): the_post(); ?> 
    3636                        <rdf:li rdf:resource="<?php permalink_single_rss() ?>"/> 
    37                 <?php $wp_items[] = $row; $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?> 
     37                <?php endwhile; ?> 
    3838                </rdf:Seq> 
    3939        </items> 
    4040</channel> 
    41 <?php if ($posts) { foreach ($posts as $post) { start_wp(); ?> 
     41<?php rewind_posts(); while (have_posts()): the_post(); ?> 
    4242<item rdf:about="<?php permalink_single_rss() ?>"> 
    4343        <title><?php the_title_rss() ?></title> 
     
    5454        <?php do_action('rdf_item'); ?> 
    5555</item> 
    56 <?php } }  ?> 
     56<?php endwhile;  ?> 
    5757</rdf:RDF>