function facebook_publishing_metabox() { global $post; $opt = $this->_get_option('wdfb_autopost'); $is_published = get_post_meta($post->ID, 'wdfb_published_on_fb', true); if ($is_published) { echo '<div style="margin: 5px 0 15px; background-color: #FFFFE0; border-color: #E6DB55; border-radius: 3px 3px 3px 3px; border-style: solid; border-width: 1px; padding: 0 0.6em;">' . '<p>' . __("This post has already been published on Facebook", 'wdfb') . '</p>' . '</div>'; } $stored = get_post_meta($post->ID, 'wdfb_scheduled_publish', true); $stored = is_array($stored) ? $stored : array(); $title = !empty($stored['wdfb_metabox_publishing_title']) ? $stored['wdfb_metabox_publishing_title'] : ''; $stored_publish = !empty($stored['wdfb_metabox_publishing_publish']); $stored_publishing_user = !empty($stored['wdfb_metabox_publishing_account']) ? $stored['wdfb_metabox_publishing_account'] : ''; echo '<div>'; echo '<label for="">' . __('Publish on Facebook with different title:', 'wdfb') . '</label>'; echo '<input type="text" class="widefat" name="wdfb_metabox_publishing_title" id="wdfb_metabox_publishing_title" value="' . esc_attr($title) . '" />'; echo __('<p><small>Leave this value blank to use the post title.</small></p>', 'wdfb'); echo '</div>'; if (!@$opt['allow_autopost']) { echo '<div>'; echo ' <input type="checkbox" name="wdfb_metabox_publishing_publish" id="wdfb_metabox_publishing_publish" value="1" ' . checked($stored_publish, true, false) . ' />'; echo ' <label for="wdfb_metabox_publishing_publish">' . __('I want to publish this post to Facebook', 'wdfb') . '</label>'; echo __('<p><small>If checked, the post will be unconditionally published on Facebook</small></p>', 'wdfb'); echo '</div>'; echo '<div class="wdfb_perms_not_granted" style="display:none">' . '<div class="error below-h2">' . '<p>' . __("Your app doesn't have enough permissions to publish on Facebook", 'wdfb') . '<br />' . '<a class="wdfb_grant_perms" href="#" data-wdfb_perms="' . Wdfb_Permissions::get_publisher_permissions() . '" data-wdfb_locale="' . wdfb_get_locale() . '" >' . __('Grant needed permissions now', 'wdfb') . '</a>' . '</p>' . '</div>' . '</div>'; $user = wp_get_current_user(); $fb_accounts = $this->_get_api_accounts($user->ID); /* $fb_accounts = get_user_meta($user->ID, 'wdfb_api_accounts', true); $fb_accounts = isset($fb_accounts['auth_accounts']) ? $fb_accounts['auth_accounts'] : array(); */ if ($fb_accounts) { echo '<div>'; echo ' <label for="wdfb_metabox_publishing_account">' . __('Publish to wall of this Facebook account:', 'wdfb') . '</label>'; echo ' <select name="wdfb_metabox_publishing_account" id="wdfb_metabox_publishing_account">'; foreach ($fb_accounts as $aid => $aval) { $selected = selected($stored_publishing_user, $aid, false); echo "<option value='{$aid}' {$selected}>{$aval}</option>"; } echo ' </select>'; echo '<br />'; echo '<label for="post_as_page">' . __("If posting to a page, post <b>AS</b> page", "wdfb") . '</label> ' . '<input type="checkbox" name="wdfb_post_as_page" id="post_as_page" value="1" />'; echo '</div>'; echo '<p class="wdfb_perms_not_granted"><small>' . __('Please make sure that you granted extended permissions to your Facebook App', 'wdfb') . '</small></p>'; } } echo '<script type="text/javascript" src="' . WDFB_PLUGIN_URL . '/js/check_permissions.js"></script>'; }