Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 3330438626dbd45a93d588f0b7bb15001e94d9e9 2 parents a949624 + 97e95f0
Jonathan Johnson jondavidjohn authored

Showing 1 changed file with 19 additions and 7 deletions. Show diff stats Hide diff stats

  1. +19 7 social.php
26 social.php
@@ -966,7 +966,7 @@ public function transition_post_status($new, $old, $post) {
966 966 else {
967 967 $xmlrpc = false;
968 968 if ($new == 'publish') {
969   - if (defined('XMLRPC_REQUEST') and $old != 'publish') {
  969 + if ( ( defined('XMLRPC_REQUEST') or defined('WP_MAIL') ) and $old != 'publish') {
970 970 $xmlrpc = true;
971 971 $this->xmlrpc_publish_post($post);
972 972 }
@@ -995,9 +995,14 @@ public function xmlrpc_publish_post($post) {
995 995 Social::log('Broadcasting triggered by XML-RPC.');
996 996
997 997 $broadcast_accounts = array();
  998 + $broadcast_content = array();
  999 + $broadcast_meta = array();
  1000 +
998 1001 foreach ($this->default_accounts($post) as $service_key => $accounts) {
999 1002 $service = $this->service($service_key);
1000 1003 if ($service !== false) {
  1004 + $broadcast_content[$service_key] = array();
  1005 + $broadcast_meta[$service_key] = array();
1001 1006 foreach ($accounts as $key => $id) {
1002 1007 // TODO abstract this to the Facebook plugin
1003 1008 if ($service_key == 'facebook' and $key === 'pages') {
@@ -1031,6 +1036,8 @@ public function xmlrpc_publish_post($post) {
1031 1036 );
1032 1037 }
1033 1038 }
  1039 + $broadcast_content[$service_key][$page_id] = $service->format_content($post, Social::option('broadcast_format'));
  1040 + $broadcast_meta[$service_key][$page_id] = $service->get_broadcast_extras($page_id, $post);
1034 1041 }
1035 1042 }
1036 1043 }
@@ -1045,18 +1052,18 @@ public function xmlrpc_publish_post($post) {
1045 1052 'id' => $account->id(),
1046 1053 'universal' => $account->universal()
1047 1054 );
  1055 +
  1056 + $broadcast_content[$service_key][$account->id()] = $service->format_content($post, Social::option('broadcast_format'));
  1057 + $broadcast_meta[$service_key][$account->id()] = $service->get_broadcast_extras($account->id(), $post);
1048 1058 }
1049 1059 }
1050 1060 }
1051   -
1052   - // Content
1053   - if (isset($broadcast_accounts[$service_key])) {
1054   - $content = $service->format_content($post, Social::option('broadcast_format'));
1055   - update_post_meta($post->ID, '_social_'.$service_key.'_content', addslashes_deep($content));
1056   - }
1057 1061 }
1058 1062 }
1059 1063
  1064 + update_post_meta($post->ID, '_social_broadcast_content', addslashes_deep($broadcast_content));
  1065 + update_post_meta($post->ID, '_social_broadcast_meta', addslashes_deep($broadcast_meta));
  1066 +
1060 1067 if (count($broadcast_accounts)) {
1061 1068 Social::log('There are default accounts, running broadcast');
1062 1069 update_post_meta($post->ID, '_social_broadcast_accounts', addslashes_deep($broadcast_accounts));
@@ -2168,6 +2175,10 @@ function social_wpdb_escape($str) {
2168 2175 return $wpdb->escape($str);
2169 2176 }
2170 2177
  2178 +function social_wp_mail_indicator() {
  2179 + define('WP_MAIL', true);
  2180 +}
  2181 +
2171 2182 $social_file = __FILE__;
2172 2183 if (isset($plugin)) {
2173 2184 $social_file = $plugin;
@@ -2210,6 +2221,7 @@ function social_wpdb_escape($str) {
2210 2221 add_action('wp_after_admin_bar_render', array($social, 'admin_bar_footer_css'));
2211 2222 add_action('wp_after_admin_bar_render', array($social, 'admin_bar_footer_js'));
2212 2223 add_action('set_user_role', array($social, 'set_user_role'), 10, 2);
  2224 +add_action('wp-mail.php', 'social_wp_mail_indicator');
2213 2225 add_action('social_settings_save', array('Social_Service_Facebook', 'social_settings_save'));
2214 2226
2215 2227 // CRON Actions

1 comment on commit 3330438

Austin Passy

Sweet!

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