/** * Initialize the backend, administrative views * * @since 1.1 */ public function admin_init() { $admin_dir = $this->plugin_directory . 'admin/'; $sdk = $this->load_php_sdk(); if ($sdk) { if (!class_exists('Facebook_User')) { require_once dirname(__FILE__) . '/facebook-user.php'; } Facebook_User::extend_access_token(); } if (!class_exists('Facebook_Settings')) { require_once $admin_dir . 'settings.php'; } Facebook_Settings::init(); if (!class_exists('Facebook_Social_Publisher')) { require_once $admin_dir . 'social-publisher/social-publisher.php'; } new Facebook_Social_Publisher(); if (!class_exists('Facebook_Mentions_Search')) { require_once $admin_dir . 'social-publisher/mentions/mentions-search.php'; } Facebook_Mentions_Search::wp_ajax_handlers(); }
/** * Publish new posts to your Facebook page. * * @since 1.1 * * @return void */ public function display_publish_page() { $existing_page = get_option(self::OPTION_PUBLISH_TO_PAGE); if (is_array($existing_page) && isset($existing_page['id']) && isset($existing_page['name']) && isset($existing_page['access_token'])) { $page_id = $existing_page['id']; } else { $page_id = ''; } echo '<div id="facebook-page"'; if ($page_id) { echo ' data-fbid="' . esc_attr($existing_page['id']) . '" data-name="' . esc_attr($existing_page['name']) . '">'; echo '<p>'; echo sprintf(esc_html(_x('Publishing to %s', 'Currently publishing to the specified Facebook Page', 'facebook')), '<a href="' . esc_url(isset($existing_page['link']) ? $existing_page['link'] : 'https://www.facebook.com/' . $existing_page['id'], array('http', 'https')) . '" title="' . esc_attr(sprintf(__('%s page on Facebook', 'facebook'), $existing_page['name'])) . '" target="_blank">' . esc_html($existing_page['name']) . '</a>'); unset($link); // indicate the account responsible for publishing to the Facebook Page if (is_multi_author() && isset($existing_page['set_by_user'])) { if ($this->current_user->ID == $existing_page['set_by_user']) { echo '. ' . esc_html(_x('Saved by you.', 'Saved by the current viewer of the page.', 'facebook')); } else { $setter = get_userdata($existing_page['set_by_user']); if ($setter && isset($setter->display_name)) { echo '. ' . esc_html(sprintf(_x('Saved by %s.', 'saved by person name', 'facebook'), $setter->display_name)); } } } echo '</p>'; } else { echo '>'; } if ($this->user_associated_with_facebook_account) { // edits only avaialble to WordPress accounts connected with a Facebook account echo '<div id="facebook-login" data-option="' . self::PUBLISH_OPTION_NAME . '[page_timeline]"></div>'; if (!class_exists('Facebook_User')) { require_once dirname(dirname(__FILE__)) . '/facebook-user.php'; } // page permissions require active user access token Facebook_User::extend_access_token(); } else { // send to profile page to connect an account if no connected account stored for current WP user echo '<p><a href="' . esc_url(self_admin_url('profile.php'), array('http', 'https')) . '" target="_blank">' . esc_html('Add a Facebook account to your WordPress account') . '</a></p>'; } echo '</div>'; }