existing_options = $options; else $this->existing_options = array(); } /** * Evaluate the Facebook_Like_Button class file if it is not already loaded * * @since 1.1 * * @return void */ public static function require_like_button_builder() { if ( ! class_exists( 'Facebook_Like_Button' ) ) require_once( dirname( dirname(__FILE__) ) . '/social-plugins/class-facebook-like-button.php' ); } /** * Reference the social plugin by name. * * @since 1.1 * @return string social plugin name */ public static function social_plugin_name() { return __( 'Like Button', 'facebook' ); } /** * Navigate to the settings page through the Facebook top-level menu item. * * @since 1.1 * * @uses add_submenu_page() * @param string $parent_slug Facebook top-level menu item slug * @return string submenu hook suffix */ public static function add_submenu_item( $parent_slug ) { $like_button_settings = new Facebook_Like_Button_Settings(); $hook_suffix = add_submenu_page( $parent_slug, self::social_plugin_name(), self::social_plugin_name(), 'manage_options', self::PAGE_SLUG, array( &$like_button_settings, 'settings_page' ) ); if ( $hook_suffix ) { $like_button_settings->hook_suffix = $hook_suffix; register_setting( $hook_suffix, self::OPTION_NAME, array( 'Facebook_Like_Button_Settings', 'sanitize_options' ) ); add_action( 'load-' . $hook_suffix, array( &$like_button_settings, 'onload' ) ); } return $hook_suffix; } /** * Load stored options and scripts on settings page view. * * @since 1.1 * * @return void */ public function onload() { $options = get_option( self::OPTION_NAME ); if ( ! is_array( $options ) ) $options = array(); $this->existing_options = $options; $this->settings_api_init(); } /** * Load the page. * * @since 1.1 * * @return void */ public function settings_page() { if ( ! isset( $this->hook_suffix ) ) return; Facebook_Settings::settings_page_template( $this->hook_suffix, sprintf( __( '%s Settings', 'facebook' ), self::social_plugin_name() ) ); } /** * Hook into the settings API. * * @since 1.1 * * @uses add_settings_section() * @uses add_settings_field() * @return void */ private function settings_api_init() { if ( ! isset( $this->hook_suffix ) ) return; $section = 'facebook-like-button'; add_settings_section( $section, '', // no title for main section array( &$this, 'section_header' ), $this->hook_suffix ); /* when, where */ add_settings_field( 'facebook-like-show-on', _x( 'Show on', 'Display the social plugin in specific areas of a website', 'facebook' ), array( &$this, 'display_show_on' ), $this->hook_suffix, $section ); add_settings_field( 'facebook-like-position', _x( 'Position', 'Desired position of a Facebook social plugin relative to main post content.', 'facebook' ), array( &$this, 'display_position' ), $this->hook_suffix, $section, array( 'label_for' => 'facebook-like-position' ) ); /* like button options */ add_settings_field( 'facebook-like-share', __( 'Share Button', 'facebook' ), array( &$this, 'display_share' ), $this->hook_suffix, $section, array( 'label_for' => 'facebook-like-share' ) ); add_settings_field( 'facebook-like-layout', _x( 'Layout', 'Positioning of components of a Facebook social plugin relative to each other. Example layouts include button before interaction count or interaction count above button.', 'facebook' ), array( &$this, 'display_layout' ), $this->hook_suffix, $section ); add_settings_field( 'facebook-like-show-faces', _x( 'Show faces', 'Show the faces of Facebook friends who have interacted with this object.', 'facebook' ), array( &$this, 'display_show_faces' ), $this->hook_suffix, $section, array( 'label_for' => 'facebook-like-show-faces' ) ); add_settings_field( 'facebook-like-width', __( 'Width', 'facebook' ), array( &$this, 'display_width' ), $this->hook_suffix, $section, array( 'label_for' => 'facebook-like-width' ) ); add_settings_field( 'facebook-like-action', __( 'Action', 'facebook' ), array( &$this, 'display_action' ), $this->hook_suffix, $section ); add_settings_field( 'facebook-like-font', __( 'Font', 'facebook' ), array( &$this, 'display_font' ), $this->hook_suffix, $section, array( 'label_for' => 'facebook-like-font' ) ); add_settings_field( 'facebook-like-colorscheme', __( 'Color scheme', 'facebook' ), array( &$this, 'display_colorscheme' ), $this->hook_suffix, $section ); } /** * Introduce publishers to the Like Button social plugin * * @since 1.1 * * @return void */ public function section_header() { echo '

' . esc_html( __( 'Help your visitors share your pages on their Facebook profile with one click.', 'facebook' ) ) . ' ' . esc_html( __( 'Read more...', 'facebook' ) ) . '

'; } /** * Where should the button appear? * * @since 1.1 * * @param array $extra_attributes custom form attributes * @return void */ public function display_show_on( $extra_attributes = array() ) { $key = 'show_on'; extract( self::parse_form_field_attributes( $extra_attributes, array( 'id' => 'facebook-like-show-on', 'class' => '', 'name' => self::OPTION_NAME . '[' . $key . ']' ) ) ); echo '
' . self::show_on_choices( $name, self::get_display_conditionals_by_feature( 'like', 'all' ), 'all' ) . '
'; echo '

' . esc_html( self::show_on_description( self::social_plugin_name() ) ) . '

'; } /** * Where would you like it? * * @since 1.1 * * @param array $extra_attributes custom form attributes * @return void */ public function display_position( $extra_attributes = array() ) { $key = 'position'; extract( self::parse_form_field_attributes( $extra_attributes, array( 'id' => 'facebook-like-' . $key, 'class' => '', 'name' => self::OPTION_NAME . '[' . $key . ']' ) ) ); echo ''; } /** * Display the share button option checkbox. * * @since 1.5.4 * * @param array $extra_attributes custom form attributes * @return void */ public function display_share( $extra_attributes = array() ) { $key = 'share'; extract( self::parse_form_field_attributes( $extra_attributes, array( 'id' => 'facebook-like-' . $key, 'class' => '', 'name' => self::OPTION_NAME . '[' . $key . ']' ) ) ); echo ''; echo '

' . esc_html( __( 'Allows a Facebook user to easily share your URL on a Facebook Timeline, Page, group, or in a Facebook Message.', 'facebook' ) ) . '

'; } /** * Describe layout choices. * * @since 1.1 * * @return array layout descriptions keyed by layout choice */ public static function layout_descriptions() { $like_plural = _x( 'likes', 'plural of the noun: Facebook Likes', 'facebook' ); return array( 'standard' => __( 'Display social text next to the button.', 'facebook' ), 'button_count' => sprintf( __( 'Display total number of %s next to the button.', 'facebook' ), $like_plural ), 'box_count' => sprintf( __( 'Display total number of %s above the button.', 'facebook' ), $like_plural ) ); } /** * Choose a Like Button layout option. * * @since 1.1 * * @param array $extra_attributes custom form attributes * @return void */ public function display_layout( $extra_attributes = array() ) { $key = 'layout'; self::require_like_button_builder(); if ( isset( $this->existing_options[$key] ) && isset( Facebook_Like_Button::$layout_choices[ $this->existing_options[$key] ] ) ) $existing_value = $this->existing_options[$key]; else $existing_value = 'standard'; extract( self::parse_form_field_attributes( $extra_attributes, array( 'id' => 'facebook-like-' . $key, 'class' => '', 'name' => self::OPTION_NAME . '[' . $key . ']' ) ) ); $name = esc_attr( $name ); $descriptions = self::layout_descriptions(); $layout_choices = array_keys( Facebook_Like_Button::$layout_choices ); $choices = array(); foreach( $layout_choices as $layout ) { $choice = '