/**
  * Output the link to be sent to Facebook.
  *
  * @static
  * @param  object  $post
  * @param  object  $service
  * @param  object  $account
  * @return void
  */
 public static function social_broadcast_form_item_content($post, $service, $account)
 {
     if ($service->key() != 'facebook' || get_post_format($post) == 'status') {
         return;
     }
     remove_filter('social_view_set_file', array('Social_Facebook', 'social_view_set_file'), 10, 2);
     echo Social_View::factory('wp-admin/post/broadcast/facebook-link-preview', compact('post', 'service', 'account'))->render();
     add_filter('social_view_set_file', array('Social_Facebook', 'social_view_set_file'), 10, 2);
 }
            }
            $broadcasts = array();
            foreach ($ids[$key] as $user_id => $broadcasted) {
                $account = $service->account($user_id);
                if (empty($output)) {
                    $accounts_output = '<ul class="social-broadcasted">';
                }
                foreach ($broadcasted as $broadcasted_id => $data) {
                    if ($account === false) {
                        $class = 'Social_Service_' . $key . '_Account';
                        $account = new $class($data['account']);
                        if (!$account->has_user() and $key == 'twitter') {
                            $recovered = $service->recover_broadcasted_tweet_data($broadcasted_id, $post->ID);
                            if (isset($recovered->user)) {
                                $data['account']->user = $recovered->user;
                                $account = new $class($data['account']);
                            }
                        }
                    }
                    $broadcasts[] = Social_View::factory('wp-admin/post/meta/broadcast/parts/account', array('account' => $account, 'service' => $service, 'broadcasted_id' => $broadcasted_id, 'data' => $data));
                }
            }
            if (count($broadcasts)) {
                echo '<ul class="social-broadcasted">' . implode("\n", $broadcasts) . '</ul>';
            }
        }
    }
}
?>
</div>
Exemple #3
0
 /**
  * Displays a comment.
  *
  * @param  object  $comment  comment object
  * @param  array   $args
  * @param  int     $depth
  */
 public function comment($comment, array $args = array(), $depth = 0)
 {
     $GLOBALS['comment'] = $comment;
     $social_items = '';
     $status_url = null;
     $comment_type = $comment->comment_type;
     $ignored_types = apply_filters('social_ignored_comment_types', array('wordpress', 'pingback'));
     // set the comment type to WordPress if we can't load the Social service (perhaps it was deactivated)
     // and the type isn't an ignored type
     if (!($service = $this->service_for_comment_type($comment->comment_type)) && !in_array($comment->comment_type, $ignored_types)) {
         $comment_type = 'wordpress';
     }
     // set Social Items for Social comments
     if (!in_array($comment->comment_type, $ignored_types)) {
         $status_id = get_comment_meta($comment->comment_ID, 'social_status_id', true);
         if (is_string($status_id) && $status_id) {
             $status_url = $service->status_url(get_comment_author(), $status_id);
         }
         // Social items?
         if (!empty($comment->social_items) && isset($status_url)) {
             if (is_object($service) && method_exists($service, 'key')) {
                 $avatar_size = apply_filters('social_items_comment_avatar_size', array('width' => 18, 'height' => 18));
                 $social_items = Social_View::factory('comment/social_item', array('items' => $comment->social_items, 'service' => $service, 'avatar_size' => $avatar_size));
             } else {
                 Social::log('service not set for: ' . print_r($comment, true));
                 ob_start();
                 var_dump($service);
                 Social::log('$service: ' . ob_get_clean());
             }
         }
     }
     echo Social_View::factory('comment/comment', array('comment_type' => $comment_type, 'comment' => $comment, 'service' => $service, 'status_url' => $status_url, 'depth' => $depth, 'args' => $args, 'social_items' => $social_items));
 }
		</ul>

		<!-- panel items -->
		<div id="social-comments-tab-all" class="social-tabs-panel social-tabs-first-panel">
			<div id="comments" class="social-comments">
				<?php 
        if ($last_reply_time) {
            echo '<div class="social-last-reply-when">' . sprintf(__('Last reply was %s', 'social'), Social_Date::span_comment($last_reply_time)) . '</div>';
        }
        if (count($social_items)) {
            echo '<div id="social-items-wrapper">';
            foreach ($social_items as $group => $items) {
                $service = Social::instance()->service($group);
                if ($service !== false and count($items)) {
                    $avatar_size = apply_filters('social_items_avatar_size', array('width' => 24, 'height' => 24));
                    echo Social_View::factory('comment/social_item', compact('items', 'service', 'avatar_size'));
                }
            }
            echo '</div>';
        }
        if ($last_reply_time or count($social_items)) {
            echo '<div class="cf-clearfix"></div>';
        }
        if (count($comments)) {
            ?>
				<ol class="social-commentlist">
				<?php 
            wp_list_comments(array('callback' => array(Social::instance(), 'comment'), 'walker' => new Social_Walker_Comment()), $comments);
            ?>
				</ol>
				<?php 
<h3 id="social-accounts"><?php 
_e('Social Accounts', 'social');
?>
</h3>
<table class="form-table">
	<tr id="social-accounts">
		<th>
			<?php 
_e('Accounts', 'social');
?>
			<p class="description" style="padding-top: 40px;"><?php 
_e('Only I can broadcast to these accounts.', 'social');
?>
</p>
		</th>
		<td>
<?php 
echo Social_View::factory('wp-admin/parts/accounts', compact('services', 'accounts', 'defaults'));
?>
		</td>
	</tr>
</table>
<input type="hidden" name="social_profile" value="true" />
 /**
  * Sends an email to notify the post author about deauthorized accounts.
  *
  * @param  object  $post
  * @param  array   $accounts
  * @return void
  */
 private function send_publish_error($post, $accounts)
 {
     $author = get_userdata($post->post_author);
     $message = Social_View::factory('wp-admin/post/broadcast/error/email', array('social' => $this->social, 'accounts' => $accounts, 'post' => $post));
     $subject = sprintf(__('%s: Failed to broadcast post with Social.', 'social'), get_bloginfo('name'));
     wp_mail($author->user_email, $subject, $message);
 }
Exemple #7
0
 /**
  * Hook for 'comment_form_logged_in' action.
  *
  * @return string
  */
 public function logged_in_as()
 {
     $services = Social::instance()->services();
     $accounts = array();
     foreach ($services as $key => $service) {
         if (count($service->accounts())) {
             $accounts[$key] = $service->accounts();
         }
     }
     return Social_View::factory('comment/logged_in_as', array('services' => $services, 'accounts' => $accounts, 'current_user' => $this->current_user))->render();
 }
Exemple #8
0
 /**
  * Renders the log to HTML.
  *
  * @return Social_View
  */
 public function render()
 {
     return Social_View::factory('wp-admin/post/meta/log/output', array('log' => $this->_log, 'services' => Social::instance()->services()))->render();
 }
 /**
  * Handles the request for Social's settings.
  *
  * @return void
  */
 public function action_index()
 {
     if ($this->request->post('submit')) {
         Social::option('broadcast_format', $this->request->post('social_broadcast_format'));
         Social::option('comment_broadcast_format', $this->request->post('social_comment_broadcast_format'));
         Social::option('debug', $this->request->post('social_debug'));
         if (!Social::option('debug')) {
             delete_option('social_log_write_error');
         }
         if (isset($_POST['social_broadcast_by_default'])) {
             Social::option('broadcast_by_default', $_POST['social_broadcast_by_default']);
         } else {
             delete_option('social_broadcast_by_default');
         }
         if (isset($_POST['social_aggregate_comments'])) {
             Social::option('aggregate_comments', $_POST['social_aggregate_comments']);
         } else {
             delete_option('social_aggregate_comments');
         }
         // Store the default accounts
         $accounts = array();
         if (is_array($this->request->post('social_default_accounts'))) {
             foreach ($this->request->post('social_default_accounts') as $account) {
                 $account = explode('|', $account);
                 $accounts[$account[0]][] = $account[1];
             }
         }
         $accounts = apply_filters('social_settings_default_accounts', $accounts, $this);
         if (count($accounts)) {
             Social::option('default_accounts', $accounts);
         } else {
             delete_option('social_default_accounts');
         }
         // API accounts
         if ($this->request->post('social_api_accounts')) {
             Social::option('social_api_accounts', $this->request->post('social_api_accounts'));
         }
         // System CRON
         if ($this->request->post('social_cron') !== null) {
             Social::option('cron', $this->request->post('social_cron'));
             // Unschedule the CRONs
             if ($this->request->post('social_cron') != '1' and ($timestamp = wp_next_scheduled('socialcron15init')) !== false) {
                 wp_unschedule_event($timestamp, 'socialcron15init');
             }
         }
         if (isset($_POST['social_enabled_post_types'])) {
             Social::option('enabled_post_types', array_keys($_POST['social_enabled_post_types'], 1));
         }
         // Disable Social's comment display feature
         if (isset($_POST['social_use_standard_comments'])) {
             Social::option('use_standard_comments', '1');
         } else {
             delete_option('social_use_standard_comments');
         }
         // Disable Social's broadcast feature
         if (isset($_POST['social_disable_broadcasting'])) {
             Social::option('disable_broadcasting', '1');
         } else {
             delete_option('social_disable_broadcasting');
         }
         do_action('social_settings_save', $this);
         wp_redirect(Social::settings_url(array('saved' => 'true')));
         exit;
     }
     $accounts = array();
     foreach ($this->social->services() as $key => $service) {
         if (!isset($accounts[$key])) {
             $accounts[$key] = array();
         }
         foreach ($service->accounts() as $account) {
             if ($account->universal()) {
                 $accounts[$key][] = $account->id();
             }
         }
     }
     echo Social_View::factory('wp-admin/options', array('services' => $this->social->services(), 'accounts' => $accounts, 'defaults' => Social::option('default_accounts')));
 }
Exemple #10
0
<?php

echo '<div class="misc-pub-section">';
if (empty($accounts)) {
    _e('This post will not be broadcasted to any of your social accounts.', 'social');
} else {
    echo '<p class="mar-top-none">' . __('This post will be broadcasted to the following accounts.', 'social') . '</p>';
    foreach ($accounts as $service => $_accounts) {
        if (isset($services[$service])) {
            $service = $services[$service];
            $output = '';
            foreach ($_accounts as $account) {
                if (($account = $service->account($account->id)) !== false) {
                    $output .= Social_View::factory('wp-admin/post/meta/broadcast/parts/account', array('account' => $account, 'service' => $service));
                }
            }
            if (!empty($output)) {
                echo '<ul class="social-broadcasted">' . $output . '</ul>';
            }
        }
    }
}
echo '</div>';