WordPress.org

Make WordPress Core

Ticket #900: xmlrpc.php.diff

File xmlrpc.php.diff, 4.0 KB (added by redsweater, 11 years ago)

Patch to support mt_keywords as conveyance of WP native tags. (Second upload with small fix)

  • xmlrpc.php

     
    3636include_once(ABSPATH . 'wp-admin/admin-functions.php');
    3737include_once(ABSPATH . WPINC . '/class-IXR.php');
    3838
     39// Required by post.php when tags are included, to resolve category_exists()
     40include_once(ABSPATH . "wp-admin/admin-db.php");
     41
    3942// Turn off all warnings and errors.
    4043// error_reporting(0);
    4144
     
    989992          $post_excerpt = $content_struct['mt_excerpt'];
    990993          $post_more = $content_struct['mt_text_more'];
    991994
     995      $tags_input = $content_struct['mt_keywords'];
     996
    992997          $comment_status = (!isset($content_struct['mt_allow_comments'])) ?
    993998            get_option('default_comment_status')
    994999            : $content_struct['mt_allow_comments'];
     
    10271032          }
    10281033
    10291034          // We've got all the data -- post it:
    1030           $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order');
     1035          $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input');
    10311036
    10321037          $post_ID = wp_insert_post($postdata);
    10331038
     
    11711176          $post_more = $content_struct['mt_text_more'];
    11721177          $post_status = $publish ? 'publish' : 'draft';
    11731178
     1179      $tags_input = $content_struct['mt_keywords'];
     1180
    11741181          if ( ('publish' == $post_status) ) {
    11751182                if ( ( 'page' == $post_type ) && !current_user_can('publish_pages') )
    11761183                        return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.'));
     
    12021209          }
    12031210
    12041211          // We've got all the data -- post it:
    1205           $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author');
     1212          $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input');
    12061213
    12071214          $result = wp_update_post($newpost);
    12081215          if (!$result) {
     
    12431250              $categories[] = get_cat_name($catid);
    12441251            }
    12451252
     1253                $tagnames = array();
     1254                $tagids = get_post_tags($post_ID);
     1255                if (!empty( $tagids ) ) {
     1256                        foreach($tagids as $tagid) {
     1257                          $tagnames[] = $tagid->cat_name;
     1258                        }
     1259                }
     1260
    12461261            $post = get_extended($postdata['post_content']);
    12471262            $link = post_permalink($postdata['ID']);
    12481263
     
    12671282              'mt_text_more' => $post['extended'],
    12681283              'mt_allow_comments' => $allow_comments,
    12691284              'mt_allow_pings' => $allow_pings,
     1285              'mt_keywords' => implode(', ', $tagnames),
    12701286          'wp_slug' => $postdata['post_name'],
    12711287          'wp_password' => $postdata['post_password'],
    12721288          'wp_author_id' => $author->ID,
     
    13041320                foreach ($posts_list as $entry) {
    13051321
    13061322                        $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
     1323
    13071324                        $categories = array();
    13081325                        $catids = wp_get_post_categories($entry['ID']);
    13091326                        foreach($catids as $catid) {
    13101327                                $categories[] = get_cat_name($catid);
    13111328                        }
    13121329
     1330                        $tagnames = array();
     1331                        $tagids = get_post_tags($entry['ID']);
     1332                        if (!empty( $tagids ) ) {
     1333                                foreach($tagids as $tagid) {
     1334                                  $tagnames[] = $tagid->cat_name;
     1335                                }
     1336                        }
     1337
    13131338                        $post = get_extended($entry['post_content']);
    13141339                        $link = post_permalink($entry['ID']);
    13151340
     
    13341359                                'mt_text_more' => $post['extended'],
    13351360                                'mt_allow_comments' => $allow_comments,
    13361361                                'mt_allow_pings' => $allow_pings,
     1362                                'mt_keywords' => implode(', ', $tagnames),
    13371363                                'wp_slug' => $entry['post_name'],
    13381364                                'wp_password' => $entry['post_password'],
    13391365                                'wp_author_id' => $author->ID,