$matches[0] ) ); } /** * Generate a HTML div element with data-* attributes to be converted into a Like Button by the Facebook JavaScript SDK. * * @since 1.1.6 * * @param array $attributes shortcode attributes. overrides site options for specific button attributes * @param string $content shortcode content. no effect * @return string Like Button div HTML or empty string if minimum requirements not met */ public static function like_button( $attributes, $content = null ) { global $post; $site_options = get_option( 'facebook_like_button' ); if ( ! is_array( $site_options ) ) $site_options = array(); $options = shortcode_atts( array( 'href' => '', 'share' => isset( $site_options['share'] ) && $site_options['share'], 'layout' => isset( $site_options['layout'] ) ? $site_options['layout'] : '', 'show_faces' => isset( $site_options['show_faces'] ) && $site_options['show_faces'], 'width' => isset( $site_options['width'] ) ? $site_options['width'] : 0, 'action' => isset( $site_options['action'] ) ? $site_options['action'] : '', 'font' => isset( $site_options['font'] ) ? $site_options['font'] : '', 'colorscheme' => isset( $site_options['colorscheme'] ) ? $site_options['colorscheme'] : '', 'ref' => 'shortcode' ), $attributes, 'facebook_like_button' ); // check for valid href value. unset if not valid, allowing for a possible permalink replacement if ( is_string( $options['href'] ) && $options['href'] ) $options['href'] = esc_url_raw( $options['href'], array( 'http', 'https' ) ); if ( ! ( is_string( $options['href'] ) && $options['href'] ) ) { unset( $options['href'] ); if ( isset( $post ) ) $options['href'] = apply_filters( 'facebook_rel_canonical', get_permalink( $post->ID ) ); } foreach ( array( 'share', 'show_faces' ) as $bool_key ) { $options[$bool_key] = (bool) $options[$bool_key]; } $options['width'] = absint( $options['width'] ); if ( $options['width'] < 1 ) unset( $options['width'] ); foreach( array( 'layout', 'action', 'font', 'colorscheme', 'ref' ) as $key ) { $options[$key] = trim( $options[$key] ); if ( ! $options[$key] ) unset( $options[$key] ); } if ( ! function_exists( 'facebook_get_like_button' ) ) require_once( dirname(__FILE__) . '/social-plugins.php' ); return facebook_get_like_button( $options ); } /** * Generate a HTML div element with data-* attributes to be converted into a Send Button by the Facebook JavaScript SDK * * @since 1.1.6 * * @param array $attributes shortcode attributes. overrides site options for specific button attributes * @param string $content shortcode content. no effect * @return string send button HTML div or empty string if minimum requirements not met */ public static function send_button( $attributes, $content = null ) { global $post; $site_options = get_option( 'facebook_send_button' ); if ( ! is_array( $site_options ) ) $site_options = array(); $options = shortcode_atts( array( 'href' => '', 'font' => isset( $site_options['font'] ) ? $site_options['font'] : '', 'colorscheme' => isset( $site_options['colorscheme'] ) ? $site_options['colorscheme'] : '', 'ref' => 'shortcode' ), $attributes, 'facebook_send_button' ); // check for valid href value. unset if not valid, allowing for a possible permalink replacement if ( is_string( $options['href'] ) && $options['href'] ) $options['href'] = esc_url_raw( $options['href'], array( 'http', 'https' ) ); if ( ! ( is_string( $options['href'] ) && $options['href'] ) ) { unset( $options['href'] ); if ( isset( $post ) ) $options['href'] = apply_filters( 'facebook_rel_canonical', get_permalink( $post->ID ) ); } foreach ( array( 'font', 'colorscheme', 'ref' ) as $key ) { $options[$key] = trim( $options[$key] ); if ( ! $options[$key] ) unset( $options[$key] ); } if ( ! function_exists( 'facebook_get_send_button' ) ) require_once( dirname(__FILE__) . '/social-plugins.php' ); return facebook_get_send_button( $options ); } /** * Generate a HTML div element with data-* attributes to be converted into a Follow Button by the Facebook JavaScript SDK * The passed href URL value must be a Facebook User profile URL; this URL is not validated before attempting to use in a Follow Button parameter * * @since 1.5 * * @param array $attributes shortcode attributes. overrides site options for specific button attributes * @param string $content shortcode content. no effect * @return string Follow Button div HTML or empty string if minimum requirements not met */ public static function follow_button( $attributes, $content = null ) { $site_options = get_option( 'facebook_follow_button' ); if ( ! is_array( $site_options ) ) $site_options = array(); $options = shortcode_atts( array( 'href' => '', 'layout' => isset( $site_options['layout'] ) ? $site_options['layout'] : '', 'show_faces' => isset( $site_options['show_faces'] ) && $site_options['show_faces'], 'width' => isset( $site_options['width'] ) ? $site_options['width'] : 0, 'font' => isset( $site_options['font'] ) ? $site_options['font'] : '', 'colorscheme' => isset( $site_options['colorscheme'] ) ? $site_options['colorscheme'] : '', 'ref' => 'shortcode' ), $attributes, 'facebook_follow_button' ); // Facebook User profile URL required as the target of the follow if ( is_string( $options['href'] ) && $options['href'] ) $options['href'] = esc_url_raw( trim( $options['href'] ), array( 'http', 'https' ) ); else return ''; $options['show_faces'] = (bool) $options['show_faces']; $options['width'] = absint( $options['width'] ); if ( ! $options['width'] ) unset( $options['width'] ); foreach( array( 'layout', 'font', 'colorscheme' ) as $key ) { $options[$key] = trim( $options[$key] ); if ( ! $options[$key] ) unset( $options[$key] ); } if ( ! function_exists( 'facebook_get_follow_button' ) ) require_once( dirname(__FILE__) . '/social-plugins.php' ); return facebook_get_follow_button( $options ); } /** * Generate a HTML div element with data-* attributes to be converted into a Facebook embedded post * * @since 1.5 * * @param array $attributes shortcode attributes. overrides site options for specific button attributes * @param string $content shortcode content. no effect * @return string Follow Button div HTML or empty string if minimum requirements not met */ public static function embedded_post( $attributes, $content = null ) { global $content_width; $options = shortcode_atts( array( 'href' => '', 'width' => 0, 'show_border' => true ), $attributes, 'facebook_embedded_post' ); $options['href'] = trim( $options['href'] ); if ( ! $options['href'] ) return ''; if ( ! class_exists( 'Facebook_Embedded_Post' ) ) require_once( dirname(__FILE__) . '/class-facebook-embedded-post.php' ); $options['width'] = absint( $options['width'] ); if ( ! Facebook_Embedded_Post::isValidWidth( $options['width'] ) ) { unset($options['width']); if ( isset($content_width) ) { $width = absint($content_width); if ( Facebook_Embedded_Post::isValidWidth( $width ) ) $options['width'] = $width; } } $embed = Facebook_Embedded_Post::fromArray( $options ); if ( ! $embed ) return ''; return $embed->asHTML( array( 'class' => array( 'fb-social-plugin' ) ) ); } } ?>