Skip to content
Browse files

Merge branch 'feature/broadcast-defaults-via-xmlrpc-103' into develop

  • Loading branch information...
2 parents a949624 + 97e95f0 commit 3330438626dbd45a93d588f0b7bb15001e94d9e9 @jondavidjohn jondavidjohn committed Sep 12, 2012
Showing with 19 additions and 7 deletions.
  1. +19 −7 social.php
View
26 social.php
@@ -966,7 +966,7 @@ public function transition_post_status($new, $old, $post) {
else {
$xmlrpc = false;
if ($new == 'publish') {
- if (defined('XMLRPC_REQUEST') and $old != 'publish') {
+ if ( ( defined('XMLRPC_REQUEST') or defined('WP_MAIL') ) and $old != 'publish') {
$xmlrpc = true;
$this->xmlrpc_publish_post($post);
}
@@ -995,9 +995,14 @@ public function xmlrpc_publish_post($post) {
Social::log('Broadcasting triggered by XML-RPC.');
$broadcast_accounts = array();
+ $broadcast_content = array();
+ $broadcast_meta = array();
+
foreach ($this->default_accounts($post) as $service_key => $accounts) {
$service = $this->service($service_key);
if ($service !== false) {
+ $broadcast_content[$service_key] = array();
+ $broadcast_meta[$service_key] = array();
foreach ($accounts as $key => $id) {
// TODO abstract this to the Facebook plugin
if ($service_key == 'facebook' and $key === 'pages') {
@@ -1031,6 +1036,8 @@ public function xmlrpc_publish_post($post) {
);
}
}
+ $broadcast_content[$service_key][$page_id] = $service->format_content($post, Social::option('broadcast_format'));
+ $broadcast_meta[$service_key][$page_id] = $service->get_broadcast_extras($page_id, $post);
}
}
}
@@ -1045,18 +1052,18 @@ public function xmlrpc_publish_post($post) {
'id' => $account->id(),
'universal' => $account->universal()
);
+
+ $broadcast_content[$service_key][$account->id()] = $service->format_content($post, Social::option('broadcast_format'));
+ $broadcast_meta[$service_key][$account->id()] = $service->get_broadcast_extras($account->id(), $post);
}
}
}
-
- // Content
- if (isset($broadcast_accounts[$service_key])) {
- $content = $service->format_content($post, Social::option('broadcast_format'));
- update_post_meta($post->ID, '_social_'.$service_key.'_content', addslashes_deep($content));
- }
}
}
+ update_post_meta($post->ID, '_social_broadcast_content', addslashes_deep($broadcast_content));
+ update_post_meta($post->ID, '_social_broadcast_meta', addslashes_deep($broadcast_meta));
+
if (count($broadcast_accounts)) {
Social::log('There are default accounts, running broadcast');
update_post_meta($post->ID, '_social_broadcast_accounts', addslashes_deep($broadcast_accounts));
@@ -2168,6 +2175,10 @@ function social_wpdb_escape($str) {
return $wpdb->escape($str);
}
+function social_wp_mail_indicator() {
+ define('WP_MAIL', true);
+}
+
$social_file = __FILE__;
if (isset($plugin)) {
$social_file = $plugin;
@@ -2210,6 +2221,7 @@ function social_wpdb_escape($str) {
add_action('wp_after_admin_bar_render', array($social, 'admin_bar_footer_css'));
add_action('wp_after_admin_bar_render', array($social, 'admin_bar_footer_js'));
add_action('set_user_role', array($social, 'set_user_role'), 10, 2);
+add_action('wp-mail.php', 'social_wp_mail_indicator');
add_action('social_settings_save', array('Social_Service_Facebook', 'social_settings_save'));
// CRON Actions

1 comment on commit 3330438

@thefrosty

Sweet!

Please sign in to comment.
Something went wrong with that request. Please try again.