From 25f067c954c9f2b9e64a2174dc4fad41d9d085a1 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 1 Dec 2013 14:06:45 -0800 Subject: add categories and optional backlink to exported WP posts --- util/wp/post_to_red/post_to_red.php | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'util/wp/post_to_red') diff --git a/util/wp/post_to_red/post_to_red.php b/util/wp/post_to_red/post_to_red.php index 81ae9b3ed..11b1b48f7 100644 --- a/util/wp/post_to_red/post_to_red.php +++ b/util/wp/post_to_red/post_to_red.php @@ -69,6 +69,7 @@ function post_to_red_post($post_id) { $password = post_to_red_get_password(); $seed_location = post_to_red_get_seed_location(); $channel = post_to_red_get_channel_name(); + $backlink = get_option('post_to_red_backlink'); if ((isset($user_name)) && (isset($password)) && (isset($seed_location))) { // remove potential comments @@ -88,7 +89,23 @@ function post_to_red_post($post_id) { $message .= "
$tag_string"; } + $cats = ''; + + $terms = get_the_terms($post_id,'category'); + if($terms) { + foreach($terms as $term) { + if(strlen($cats)) + $cats .= ','; + $cats .= $term->name; + } + } + + + $bbcode = xpost_to_html2bbcode($message); + + if($backlink) + $bbcode .= "\n\n" . _('Source:') . ' ' . '[url]' . get_permalink($post_id) . '[/url]'; $url = $seed_location . '/api/statuses/update'; @@ -103,7 +120,9 @@ function post_to_red_post($post_id) { ); if($channel) $body['channel'] = $channel; - + if($cats) + $body['category'] = $cats; + // post: $request = new WP_Http; $result = $request->request($url , array( 'method' => 'POST', 'body' => $body, 'headers' => $headers)); @@ -188,7 +207,8 @@ function post_to_red_displayAdminContent() { $password = post_to_red_get_password(); $user_acct = post_to_red_get_acct_name(); $channel = post_to_red_get_channel_name(); - + $backlink = get_option('post_to_red_backlink'); + $backlink_checked = ((intval($backlink)) ? ' checked="checked" ' : ''); // debug... // echo "seed location: $seed_url
"; // echo "password: $password
"; @@ -204,10 +224,11 @@ function post_to_red_displayAdminContent() {

Configuration

Enter the login details of your Red Matrix account

-   - Password:   - Red Matrix URL:   - Optional channel nickname:   + Login (email):
+ Password:
+ Red Matrix URL:
+ Optional channel nickname:
+ Add permalink to posts?

@@ -266,7 +287,7 @@ function post_to_red_display_admin_page() { update_option('post_to_red_channel_name', $channelname); update_option('post_to_red_seed_location', $red_url); update_option('post_to_red_password', $password); - + update_option('post_to_red_backlink', $_REQUEST['post_to_red_backlink']); } post_to_red_displayAdminContent(); -- cgit v1.2.3