/Uis', '', $post->post_content); // get any tags and make them hashtags $post_tags = get_the_tags($post_id); if ($post_tags) { foreach($post_tags as $tag) { $tag_string .= "#" . $tag->name . " "; } } $message_namespace = 'wordpress'; $message_id = site_url() . '/' . $post_id; $message = $post->post_title . "

" . $message; $message .= "

permalink: " . $post->guid; if (isset($tag_string)) { $message .= "
$tag_string"; } $bbcode = xpost_to_html2bbcode($message); $url = $seed_location . '/api/statuses/update'; $headers = array('Authorization' => 'Basic '.base64_encode("$user_name:$password")); $body = array('status' => $bbcode,'source' => 'WordPress', 'namespace' => $message_namespace, 'remote_id' => $message_id); if($channel) $body['channel'] = $channel; // post: $request = new WP_Http; $result = $request->request($url , array( 'method' => 'POST', 'body' => $body, 'headers' => $headers)); } } } function post_to_red_displayAdminContent() { $seed_url = post_to_red_get_seed_location(); $password = post_to_red_get_password(); $user_acct = post_to_red_get_acct_name(); $channel = post_to_red_get_channel_name(); // debug... // echo "seed location: $seed_url
"; // echo "password: $password
"; // echo "user_acct: $user_acct
"; echo <<

CrossPost to Red Matrix

This plugin allows you to cross post to your Red Matrix channel.

Configuration

Enter the login details of your Red Matrix account

  Password:   Red Matrix URL:   Optional channel nickname:  

EOF; if(isset($_POST['submit'])) { echo "
Settings Saved!
"; } } function post_to_red_post_checkbox() { add_meta_box( 'post_to_red_meta_box_id', 'Cross Post to Red Matrix', 'post_to_red_post_meta_content', 'post', 'normal', 'default' ); } function post_to_red_post_meta_content($post_id) { wp_nonce_field(plugin_basename( __FILE__ ), 'post_to_red_nonce'); echo ' Cross post?'; } function post_to_red_post_field_data($post_id) { // check if this isn't an auto save if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; // security check if((! array_key_exists('post_to_red_nonce', $_POST)) || (!wp_verify_nonce( $_POST['post_to_red_nonce'], plugin_basename( __FILE__ )))) return; // now store data in custom fields based on checkboxes selected if (isset($_POST['post_to_red'])) { update_post_meta($post_id, 'post_to_red', 1); } else { update_post_meta($post_id, 'post_to_red', 0); } } function post_to_red_display_admin_page() { if ((isset($_REQUEST["post_to_red_acct_name"])) && (isset($_REQUEST["post_to_red_password"]))) { $password = $_REQUEST["post_to_red_password"]; $red_url = $_REQUEST["post_to_red_url"]; update_option('post_to_red_acct_name', $_REQUEST["post_to_red_acct_name"]); update_option('post_to_red_channel_name', $channelname); update_option('post_to_red_seed_location', $red_url); update_option('post_to_red_password', $password); } post_to_red_displayAdminContent(); } function post_to_red_settings_link($links) { $settings_link = 'Settings'; array_unshift($links, $settings_link); return $links; } function post_to_red_admin() { add_options_page("Crosspost to redmatrix", "Crosspost to redmatrix", "manage_options", "xpost-to-redmatrix", "post_to_red_display_admin_page"); } register_deactivation_hook( __FILE__, 'post_to_red_deactivate' ); add_filter("plugin_action_links_$plugin", "post_to_red_settings_link"); add_action("admin_menu", "post_to_red_admin"); add_action('publish_post', 'post_to_red_post'); add_action('add_meta_boxes', 'post_to_red_post_checkbox'); add_action('save_post', 'post_to_red_post_field_data'); // from: // http://www.docgate.com/tutorial/php/how-to-convert-html-to-bbcode-with-php-script.html function xpost_to_html2bbcode($text) { $htmltags = array( '/\(.*?)\<\/b\>/is', '/\(.*?)\<\/i\>/is', '/\(.*?)\<\/u\>/is', '/\(.*?)\<\/ul\>/is', '/\(.*?)\<\/li\>/is', '/\/is', // some smiley '/\/is', '/\/is', // some smiley '/\