/**
  * Add Facebook settings to the WordPress administration menu.
  *
  * @since 1.1
  *
  * @global Facebook_Loader $facebook_loader Access loaded Facebook application credentials
  * @global $submenu array submenu created for the menu slugs
  * @return void
  */
 public static function settings_menu_items()
 {
     global $facebook_loader, $submenu;
     // main settings page
     if (!class_exists('Facebook_Application_Settings')) {
         require_once dirname(__FILE__) . '/settings-app.php';
     }
     $menu_hook = Facebook_Application_Settings::menu_item();
     if (!$menu_hook) {
         return;
     }
     $app_credentials_exist = self::app_credentials_exist();
     $menu_slug = Facebook_Application_Settings::PAGE_SLUG;
     // duplicate_hook
     $available_features = apply_filters('facebook_features', self::$features);
     // publisher could short-circuit all features
     if (!is_array($available_features) || empty($available_features)) {
         return;
     }
     // remove features for child directed sites
     if (get_option('facebook_kid_directed_site')) {
         unset($available_features['recommendations_bar']);
         unset($available_features['comments']);
     }
     if (isset($available_features['like'])) {
         if (!class_exists('Facebook_Like_Button_Settings')) {
             require_once dirname(__FILE__) . '/settings-like-button.php';
         }
         Facebook_Like_Button_Settings::add_submenu_item($menu_slug);
     }
     if (isset($available_features['send'])) {
         if (!class_exists('Facebook_Send_Button_Settings')) {
             require_once dirname(__FILE__) . '/settings-send-button.php';
         }
         Facebook_Send_Button_Settings::add_submenu_item($menu_slug);
     }
     if (isset($available_features['follow'])) {
         if (!class_exists('Facebook_Follow_Button_Settings')) {
             require_once dirname(__FILE__) . '/settings-follow-button.php';
         }
         Facebook_Follow_Button_Settings::add_submenu_item($menu_slug);
     }
     // some features require stored Facbook application credentials. don't be a tease.
     if ($app_credentials_exist) {
         if (isset($available_features['recommendations_bar'])) {
             if (!class_exists('Facebook_Recommendations_Bar_Settings')) {
                 require_once dirname(__FILE__) . '/settings-recommendations-bar.php';
             }
             Facebook_Recommendations_Bar_Settings::add_submenu_item($menu_slug);
         }
         if (isset($available_features['comments'])) {
             if (!class_exists('Facebook_Comments_Settings')) {
                 require_once dirname(__FILE__) . '/settings-comments.php';
             }
             Facebook_Comments_Settings::add_submenu_item($menu_slug);
         }
         if (isset($available_features['social_publisher']) && wp_http_supports(array('ssl' => true))) {
             if (!class_exists('Facebook_Social_Publisher_Settings')) {
                 require_once dirname(__FILE__) . '/settings-social-publisher.php';
             }
             Facebook_Social_Publisher_Settings::add_submenu_item($menu_slug);
         }
         if (!class_exists('Facebook_Settings_Debugger')) {
             require_once dirname(__FILE__) . '/settings-debug.php';
         }
         Facebook_Settings_Debugger::add_submenu_item($menu_slug);
     }
     // make an assumption about submenu mappings, but don't fail if our assumption is wrong
     // WordPress will automatically duplicate the top-level menu destination when a submenu is created
     // Change wording based on Facebook parent
     if (is_array($submenu) && isset($submenu[$menu_slug]) && is_array($submenu[$menu_slug]) && is_array($submenu[$menu_slug][0]) && is_string($submenu[$menu_slug][0][0])) {
         $submenu[$menu_slug][0][0] = __('General');
         if ($app_credentials_exist) {
             $submenu[$menu_slug][] = array(_x('Insights', 'Facebook Insights', 'facebook'), 'manage_options', esc_url('https://www.facebook.com/insights/' . $facebook_loader->credentials['app_id'], array('https', 'http')), '');
         }
     }
 }
Beispiel #2
0
 /**
  * Back-end widget form.
  *
  * @see WP_Widget::form()
  *
  * @since 1.0
  *
  * @param array $instance Previously saved values from database.
  * @return void
  */
 public function form($instance)
 {
     $instance = wp_parse_args((array) $instance, array('title' => '', 'href' => '', 'font' => '', 'colorscheme' => 'light'));
     $this->display_title($instance['title']);
     $this->display_href($instance['href']);
     if (!class_exists('Facebook_Send_Button_Settings')) {
         require_once dirname(dirname(dirname(__FILE__))) . '/admin/settings-send-button.php';
     }
     $send_button_settings = new Facebook_Send_Button_Settings($instance);
     echo '<div><label for="' . $this->get_field_id('font') . '">' . esc_html(__('Font', 'facebook')) . '</label>: ';
     $send_button_settings->display_font(array('id' => $this->get_field_id('font'), 'name' => $this->get_field_name('font')));
     echo '</div><p></p>';
     echo '<div style="line-height:2em">' . esc_html(__('Color scheme', 'facebook')) . ': ';
     $send_button_settings->display_colorscheme(array('id' => $this->get_field_id('colorscheme'), 'name' => $this->get_field_name('colorscheme')));
     echo '</div>';
 }
Beispiel #3
0
 /**
  * Migrate send button settings
  *
  * @since 1.1
  * @param array $options existing settings
  * @return result of update_option, if run
  */
 public static function migrate_send_button($options)
 {
     if (!is_array($options) || empty($options)) {
         return;
     }
     $options = self::show_on($options);
     if (!class_exists('Facebook_Send_Button_Settings')) {
         require_once dirname(__FILE__) . '/settings-send-button.php';
     }
     $options = Facebook_Send_Button_Settings::sanitize_options($options);
     if (!empty($options)) {
         return update_option(Facebook_Send_Button_Settings::OPTION_NAME, $options);
     }
 }