|
1 <?php |
|
2 |
|
3 // expects the following variables to be passed in: |
|
4 // $services (full list of services) |
|
5 // $accounts (list of accounts to show for this screen) |
|
6 // $defaults (accounts that are checked for default broadcast) |
|
7 |
|
8 foreach ($services as $key => $service) { |
|
9 ?> |
|
10 <div class="social-accounts"> |
|
11 <?php |
|
12 $button = '<div class="social-connect-button cf-clearfix"><a href="'.esc_url($service->authorize_url()).'" id="'.esc_attr($key).'_signin" class="social-login" target="_blank"><span>'.sprintf(__('Sign in with %s.', 'social'), esc_html($service->title())).'</span></a></div>'; |
|
13 echo apply_filters('social_service_button', $button, $service); |
|
14 ?> |
|
15 <ul> |
|
16 <?php |
|
17 $i = 0; |
|
18 foreach ($service->accounts() as $account) { |
|
19 if (in_array($account->id(), $accounts[$key])) { |
|
20 $profile_url = esc_url($account->url()); |
|
21 $profile_name = esc_html($account->name()); |
|
22 $disconnect = $service->disconnect_link($account, true); |
|
23 $name = sprintf('<a href="%s">%s</a>', $profile_url, $profile_name); |
|
24 ?> |
|
25 <li class="social-accounts-item"> |
|
26 <img src="<?php echo esc_url($account->avatar()); ?>" width="32" height="32" /> |
|
27 <span class="name"><?php echo $name; ?></span> |
|
28 <label class="default" for="<?php echo esc_attr($key.$account->id()); ?>"> |
|
29 <input type="checkbox" name="social_default_accounts[]" id="<?php echo esc_attr($key.$account->id()); ?>" value="<?php echo esc_attr($key.'|'.$account->id()); ?>"<?php echo ((isset($defaults[$key]) and in_array($account->id(), array_values($defaults[$key]))) ? ' checked="checked"' : ''); ?> /> |
|
30 <?php _e('Default', 'social'); ?> |
|
31 </label> |
|
32 <span class="disconnect"><?php echo $disconnect; ?></span> |
|
33 <?php |
|
34 // this makes a live API call to get updated accounts |
|
35 $child_accounts = $account->fetch_child_accounts(); |
|
36 if (count($child_accounts)) { |
|
37 ?> |
|
38 <ul> |
|
39 <?php |
|
40 foreach ($child_accounts as $child_account) { |
|
41 if (isset($defaults[$service->key()]) and |
|
42 isset($defaults[$service->key()][$account->child_account_key()]) and |
|
43 isset($defaults[$service->key()][$account->child_account_key()][$account->id()]) and |
|
44 in_array($child_account->id, $defaults[$service->key()][$account->child_account_key()][$account->id()]) |
|
45 ) { |
|
46 $default_checked = ' checked="checked"'; |
|
47 } |
|
48 else { |
|
49 $default_checked = ''; |
|
50 } |
|
51 $is_profile = defined('IS_PROFILE_PAGE'); |
|
52 if ($account->page($child_account->id, $is_profile) !== false) { |
|
53 $enabled_checked = ' checked="checked"'; |
|
54 } |
|
55 else { |
|
56 $enabled_checked = ''; |
|
57 } |
|
58 ?> |
|
59 <li class="social-accounts-item"> |
|
60 <img src="<?php echo esc_url($account->child_account_avatar($child_account)); ?>" width="32" height="32" /> |
|
61 <span class="name"><?php echo esc_html($child_account->name); ?></span> |
|
62 <label class="default" for="<?php echo esc_attr($key.$child_account->id); ?>"> |
|
63 <input type="checkbox" name="social_default_pages[<?php echo esc_attr($account->id()); ?>][]" id="<?php echo esc_attr($key.$child_account->id); ?>" value="<?php echo esc_attr($child_account->id); ?>"<?php echo $default_checked; ?> /> |
|
64 <?php _e('Default', 'social'); ?> |
|
65 </label> |
|
66 <label class="enabled" for="social_enabled_child_accounts-<?php echo esc_attr($key.$child_account->id); ?>"> |
|
67 <input type="checkbox" name="social_enabled_child_accounts[<?php echo esc_attr($service->key()); ?>][]" id="social_enabled_child_accounts-<?php echo esc_attr($key.$child_account->id); ?>" value="<?php echo esc_attr($child_account->id); ?>"<?php echo $enabled_checked; ?> /> |
|
68 <?php _e('Enabled', 'social'); ?> |
|
69 </label> |
|
70 </li> |
|
71 <?php |
|
72 } |
|
73 ?> |
|
74 </ul> |
|
75 <?php |
|
76 } |
|
77 $i++; |
|
78 ?> |
|
79 </li><!-- /li.social-accounts-item --> |
|
80 <?php |
|
81 } |
|
82 } |
|
83 if ($i == 0) { |
|
84 ?> |
|
85 <li class="social-accounts-item none"> |
|
86 <img src="http://www.gravatar.com/avatar/a06082e4f876182b547f635d945e744e?s=32&d=mm" width="32" height="32" /> |
|
87 <span class="name"><?php _e('No Accounts', 'social'); ?></span> |
|
88 </li> |
|
89 <?php |
|
90 } |
|
91 ?> |
|
92 </ul> |
|
93 </div> |
|
94 <?php |
|
95 } |
|
96 ?> |
|
97 <p class="description" style="max-width: 450px;"><?php _e('Default accounts will auto-broadcast when you publish via XML-RPC or email.', 'social'); ?></p> |