'', 'fcbk_bttn_plgn_my_page' => 1, 'fcbk_bttn_plgn_like' => 1, 'fcbk_bttn_plgn_send' => 1, 'fcbk_bttn_plgn_comment' => 0, 'fcbk_bttn_plgn_where' => '', 'fcbk_bttn_plgn_display_option' => '', 'fcbk_bttn_plgn_count_icon' => 1, 'fb_img_link' => plugins_url( "img/standart-facebook-ico.jpg", __FILE__ ), 'fcbk_bttn_plgn_locale' => 'en_US' ); if( ! get_option( 'btn_plgn_options_array' ) ) add_option( 'btn_plgn_options_array', $btn_plgn_options_array_default, '', 'yes' ); $btn_plgn_options_array = get_option( 'btn_plgn_options_array' ); //echo "
";print_r($btn_plgn_options_array);
		$btn_plgn_options_array = array_merge( $btn_plgn_options_array_default, $btn_plgn_options_array );
		update_option( 'btn_plgn_options_array', $btn_plgn_options_array );
	}
}

//Function formed content of the plugin's admin page.
if( ! function_exists( 'fcbk_bttn_plgn_settings_page' ) ) {
	function fcbk_bttn_plgn_settings_page() 
	{
		global $btn_plgn_options_array;
		$copy = false;
		
		if( @copy( plugin_dir_path( __FILE__ )."img/facebook-ico.jpg", plugin_dir_path( __FILE__ )."img/facebook-ico3.jpg" ) !== false )
			$copy = true;

		$message = "";
		$error = "";
		if( isset( $_REQUEST['btn_plgn_form_submit'] ) && check_admin_referer( plugin_basename(__FILE__), 'fcbk_bttn_plgn_nonce_name' ) ) {
			// Takes all the changed settings on the plugin's admin page and saves them in array 'btn_plgn_options_array'.
					
				$btn_plgn_options_array [ 'fcbk_bttn_plgn_app_id' ]			=	$_REQUEST [ 'fcbk_bttn_plgn_app_id' ];
				$btn_plgn_options_array [ 'fcbk_bttn_plgn_link' ]			=	$_REQUEST [ 'fcbk_bttn_plgn_link' ];
				$btn_plgn_options_array [ 'fcbk_bttn_plgn_where' ]		=	$_REQUEST [ 'fcbk_bttn_plgn_where' ];
				$btn_plgn_options_array [ 'fcbk_bttn_plgn_display_option' ]	=	$_REQUEST [ 'fcbk_bttn_plgn_display_option' ];
				$btn_plgn_options_array [ 'fcbk_bttn_plgn_my_page' ]	=	isset( $_REQUEST [ 'fcbk_bttn_plgn_my_page' ] ) ? 1 : 0 ;
				$btn_plgn_options_array [ 'fcbk_bttn_plgn_like' ]			=	isset( $_REQUEST [ 'fcbk_bttn_plgn_like' ] ) ? 1 : 0 ;
				$btn_plgn_options_array [ 'fcbk_bttn_plgn_send' ]			=	isset( $_REQUEST [ 'fcbk_bttn_plgn_send' ] ) ? 1 : 0 ;
				$btn_plgn_options_array [ 'fcbk_bttn_plgn_comment' ]			=	isset( $_REQUEST [ 'fcbk_bttn_plgn_comment' ] ) ? 1 : 0 ;
				if ( isset ( $_FILES [ 'uploadfile' ] [ 'tmp_name' ] ) &&  $_FILES [ 'uploadfile' ] [ 'tmp_name' ] != "" ) {		
					$btn_plgn_options_array [ 'fcbk_bttn_plgn_count_icon' ]	=	$btn_plgn_options_array [ 'fcbk_bttn_plgn_count_icon' ] + 1;
				}
				$btn_plgn_options_array [ 'fcbk_bttn_plgn_locale' ]		=	$_REQUEST [ 'fcbk_bttn_plgn_locale' ];
				
				if($btn_plgn_options_array [ 'fcbk_bttn_plgn_count_icon' ] > 2)
					$btn_plgn_options_array [ 'fcbk_bttn_plgn_count_icon' ] = 1;
					
				$btn_plgn_options_array [ 'tw_btn_via' ]	=	$_REQUEST [ 'tw_btn_via' ];
				$btn_plgn_options_array [ 'tw_btn_count' ]	=	isset( $_REQUEST [ 'tw_btn_count' ] ) ? '' : 'none' ;
				$btn_plgn_options_array [ 'tw_btn_large' ]			=	isset( $_REQUEST [ 'tw_btn_large' ] ) ? 'large' : '' ;
				
				$btn_plgn_options_array [ 'gplus_btn_annotation' ]	=	$_REQUEST [ 'gplus_btn_annotation' ];
				$btn_plgn_options_array [ 'gplus_btn_size' ]	=	$_REQUEST [ 'gplus_btn_size' ];
				
				$btn_plgn_options_array [ 'li_btn_count' ]			=	$_REQUEST [ 'li_btn_count' ];
				
				$btn_plgn_options_array [ 'tw_btn_chk' ]			=	isset( $_REQUEST [ 'tw_btn_chk' ] ) ? 1 : 0 ;
				$btn_plgn_options_array [ 'fb_btn_chk' ]			=	isset( $_REQUEST [ 'fb_btn_chk' ] ) ? 1 : 0 ;
				$btn_plgn_options_array [ 'gplus_btn_chk' ]			=	isset( $_REQUEST [ 'gplus_btn_chk' ] ) ? 1 : 0 ;
				$btn_plgn_options_array [ 'li_btn_chk' ]			=	isset( $_REQUEST [ 'li_btn_chk' ] ) ? 1 : 0 ;
				
				update_option	( 'btn_plgn_options_array', $btn_plgn_options_array );
				$message = "Options saved";
		
			
			
			fcbk_bttn_plgn_update_option();
	} 
		?>
	

Social Sharer Options

>

>

/>
>
' style="width:200px;" />
/>
/>
/>
/>
>
/>
/>
Via ' style="width:200px;" placeholder="@Twitter Username"/>
/>
>
Annotation:
Size: /> /> />
/>
>
Count Mode:
Button Position:
ID ); //Button $button = '
'; if( $btn_plgn_options_array [ 'fb_btn_chk' ] == 1 ) { if( $btn_plgn_options_array [ 'fcbk_bttn_plgn_send' ] == 1 ) { $send = "true";}else $send = "false"; $button .= '
'; } if( $btn_plgn_options_array [ 'tw_btn_chk' ] == 1 ) { $button .= '
'; } if( $btn_plgn_options_array [ 'li_btn_chk' ] == 1 ) { $button .= '
'; } if( $btn_plgn_options_array [ 'gplus_btn_chk' ] == 1 ) { $button .= '
'; } $button .= '
'; if( $btn_plgn_options_array [ 'fb_btn_chk' ] == 1 && $btn_plgn_options_array [ 'fcbk_bttn_plgn_comment' ] == 1 && is_single()) { add_filter( 'comments_template', 'dummy_comments_template'); $commentBox = '
'; } //Indication where show FaceBook Button depending on selected item in admin page. if ( $fcbk_bttn_plgn_where == 'before' ) { return $button . $content.$commentBox; } else if ( $fcbk_bttn_plgn_where == 'after' ) { return $content . $button.$commentBox; } else if ( $fcbk_bttn_plgn_where == 'beforeandafter' ) { return $button . $content . $button.$commentBox; } else if ( $fcbk_bttn_plgn_where == 'shortcode' ) { return $content; } else { return $content; } } } function dummy_comments_template() { return dirname( __FILE__ ) . '/includes/comments-template.php'; } //Function 'fcbk_bttn_plgn_shortcode' are using to create shortcode by FaceBook Button. if( ! function_exists( 'fcbk_bttn_plgn_shortcode' ) ) { function fcbk_bttn_plgn_shortcode( $content ) { $btn_plgn_options_array = get_option ( 'btn_plgn_options_array' ); $fcbk_bttn_plgn_where = $btn_plgn_options_array [ 'fcbk_bttn_plgn_where' ]; $img = $btn_plgn_options_array [ 'fb_img_link' ]; $url = $btn_plgn_options_array [ 'fcbk_bttn_plgn_link' ]; $permalink_post = get_permalink ( $post_ID ); $button = '
'; if( $btn_plgn_options_array [ 'fcbk_bttn_plgn_my_page' ] == 1 ) { $button .= ''; } if( $btn_plgn_options_array [ 'fcbk_bttn_plgn_like' ] == 1 ) { $button .= '
'; } $button .= '
'; return $button; } } //Function 'fcbk_bttn_plgn_action_links' are using to create action links on admin page. if( ! function_exists( 'fcbk_bttn_plgn_action_links' ) ) { function fcbk_bttn_plgn_action_links( $links, $file ) { //Static so we don't call plugin_basename on every plugin row. static $this_plugin; if ( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__); if ( $file == $this_plugin ){ $settings_link = '' . __( 'Settings', 'facebook' ) . ''; array_unshift( $links, $settings_link ); } return $links; } } // end function fcbk_bttn_plgn_action_links //Function 'fcbk_bttn_plgn_links' are using to create other links on admin page. if ( ! function_exists ( 'fcbk_bttn_plgn_links' ) ) { function fcbk_bttn_plgn_links($links, $file) { $base = plugin_basename(__FILE__); if ($file == $base) { $links[] = '' . __( 'Settings','facebook' ) . ''; $links[] = '' . __( 'FAQ','facebook' ) . ''; $links[] = '' . __( 'Support','facebook' ) . ''; } return $links; } } // end function fcbk_bttn_plgn_links //Function '_plugin_init' are using to add language files. if ( ! function_exists ( 'fcbk_plugin_init' ) ) { function fcbk_plugin_init() { load_plugin_textdomain( 'facebook', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); } } // end function fcbk_plugin_init if ( ! function_exists ( 'fcbk_admin_head' ) ) { function fcbk_admin_head() { wp_register_style( 'fcbkStylesheet', plugins_url( 'css/style.css', __FILE__ ) ); wp_enqueue_style( 'fcbkStylesheet' ); } } /** * Add Open Graph protocol markup to * * @since 1.0 */ function fb_add_og_protocol() { global $post; $meta_tags = array( 'http://ogp.me/ns#locale' => 'en_US', 'http://ogp.me/ns#site_name' => get_bloginfo( 'name' ), 'http://ogp.me/ns#type' => 'website' ); if ( is_home() || is_front_page() ) { $meta_tags['http://ogp.me/ns#title'] = get_bloginfo( 'name' ); $meta_tags['http://ogp.me/ns#description'] = get_bloginfo( 'description' ); } else if ( is_single() ) { $post_type = get_post_type(); $meta_tags['http://ogp.me/ns#type'] = 'article'; $meta_tags['http://ogp.me/ns#url'] = apply_filters( 'rel_canonical', get_permalink() ); if ( post_type_supports( $post_type, 'title' ) ) $meta_tags['http://ogp.me/ns#title'] = get_the_title(); if ( post_type_supports( $post_type, 'excerpt' ) ) { // thanks to Angelo Mandato (http://wordpress.org/support/topic/plugin-facebook-plugin-conflicts-with-powerpress?replies=16) // Strip and format the wordpress way, but don't apply any other filters which adds junk that ends up getitng stripped back out if ( !post_password_required($post) ) { // First lets get the post excerpt (shouldn't have any html, but anyone can enter anything...) $meta_tags['http://ogp.me/ns#description'] = fb_strip_and_format_desc ( $post ); } } $meta_tags['http://ogp.me/ns/article#published_time'] = get_the_date('c'); $meta_tags['http://ogp.me/ns/article#modified_time'] = get_the_modified_date('c'); if ( post_type_supports( $post_type, 'author' ) && isset( $post->post_author ) ) $meta_tags['http://ogp.me/ns/article#author'] = get_author_posts_url( $post->post_author ); // add the first category as a section. all other categories as tags $cat_ids = get_the_category(); if ( ! empty( $cat_ids ) ) { $cat = get_category( $cat_ids[0] ); if ( ! empty( $cat ) ) $meta_tags['http://ogp.me/ns/article#section'] = $cat->name; //output the rest of the categories as tags unset( $cat_ids[0] ); if ( ! empty( $cat_ids ) ) { $meta_tags['http://ogp.me/ns/article#tag'] = array(); foreach( $cat_ids as $cat_id ) { $cat = get_category( $cat_id ); $meta_tags['http://ogp.me/ns/article#tag'][] = $cat->name; unset( $cat ); } } } // add tags. treat tags as lower priority than multiple categories $tags = get_the_tags(); if ( $tags ) { if ( ! array_key_exists( 'http://ogp.me/ns/article#tag', $meta_tags ) ) $meta_tags['http://ogp.me/ns/article#tag'] = array(); foreach ( $tags as $tag ) { $meta_tags['http://ogp.me/ns/article#tag'][] = $tag->name; } } // does current post type and the current theme support post thumbnails? if ( post_type_supports( $post_type, 'thumbnail' ) && function_exists( 'has_post_thumbnail' ) && has_post_thumbnail() ) { list( $post_thumbnail_url, $post_thumbnail_width, $post_thumbnail_height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); if ( ! empty( $post_thumbnail_url ) ) { $image = array( 'url' => $post_thumbnail_url ); if ( ! empty( $post_thumbnail_width ) ) $image['width'] = absint( $post_thumbnail_width ); if ( ! empty($post_thumbnail_height) ) $image['height'] = absint( $post_thumbnail_height ); $meta_tags['http://ogp.me/ns#image'] = array( $image ); } } } else if ( is_author() && isset( $post->post_author ) ) { $meta_tags['http://ogp.me/ns#type'] = 'profile'; $meta_tags['http://ogp.me/ns/profile#first_name'] = get_the_author_meta( 'first_name', $post->post_author ); $meta_tags['http://ogp.me/ns/profile#last_name'] = get_the_author_meta( 'last_name', $post->post_author ); if ( is_multi_author() ) $meta_tags['http://ogp.me/ns/profile#username'] = get_the_author_meta( 'login', $post->post_author ); } else if ( is_page() ) { $meta_tags['http://ogp.me/ns#type'] = 'article'; $meta_tags['http://ogp.me/ns#title'] = get_the_title(); $meta_tags['http://ogp.me/ns#url'] = apply_filters( 'rel_canonical', get_permalink() ); } $options = get_option( 'fb_options' ); if ( ! empty( $options['app_id'] ) ) $meta_tags['http://ogp.me/ns/fb#app_id'] = $options['app_id']; $meta_tags = apply_filters( 'fb_meta_tags', $meta_tags, $post ); foreach ( $meta_tags as $property => $content ) { fb_output_og_protocol( $property, $content ); } } function fb_strip_and_format_desc( $post ) { $desc_no_html = ""; $desc_no_html = strip_shortcodes( $desc_no_html ); // Strip shortcodes first in case there is HTML inside the shortcode $desc_no_html = wp_strip_all_tags( $desc_no_html ); // Strip all html $desc_no_html = trim( $desc_no_html ); // Trim the final string, we may have stripped everything out of the post so this will make the value empty if that's the case // Check if empty, may be that the strip functions above made excerpt empty, doubhtful but we want to be 100% sure. if( empty($desc_no_html) ) { $desc_no_html = $post->post_content; // Start over, this time with the post_content $desc_no_html = strip_shortcodes( $desc_no_html ); // Strip shortcodes first in case there is HTML inside the shortcode $desc_no_html = str_replace(']]>', ']]>', $desc_no_html); // Angelo Recommendation, if for some reason ]]> happens to be in the_content, rare but We've seen it happen $desc_no_html = wp_strip_all_tags($desc_no_html); $excerpt_length = apply_filters('excerpt_length', 55); $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]'); $desc_no_html = wp_trim_words( $desc_no_html, $excerpt_length, $excerpt_more ); $desc_no_html = trim($desc_no_html); // Trim the final string, we may have stripped everything out of the post so this will make the value empty if that's the case } $desc_no_html = str_replace( array( "\r\n", "\r", "\n" ), ' ',$desc_no_html); // I take it Facebook doesn't like new lines? return $desc_no_html; } function fb_output_og_protocol( $property, $content ) { if ( empty( $property ) || empty( $content ) ) return; // array of property values or structured property if ( is_array( $content ) ) { foreach( $content as $structured_property => $content_value ) { // handle numeric keys from regular arrays // account for the special structured property of url which is equivalent to the root tag and sets up the structure if ( ! is_string( $structured_property ) || $structured_property === 'url' ) fb_output_og_protocol( $property, $content_value ); else fb_output_og_protocol( $property . ':' . $structured_property, $content_value ); } } else { echo "\n"; } } add_action( 'wp_head', 'fb_add_og_protocol' ); //Add language files add_action( 'init', 'fcbk_plugin_init' ); add_action( 'wp_enqueue_scripts', 'fcbk_admin_head' ); add_action( 'admin_enqueue_scripts', 'fcbk_admin_head' ); // adds "Settings" link to the plugin action page add_filter( 'plugin_action_links', 'fcbk_bttn_plgn_action_links', 10, 2 ); //Additional links on the plugin page add_filter( 'plugin_row_meta', 'fcbk_bttn_plgn_links', 10, 2 ); //Calling a function add administrative menu. add_action( 'admin_menu', 'fcbk_bttn_plgn_add_pages' ); //Add shortcode. add_shortcode( 'fb_button', 'fcbk_bttn_plgn_shortcode' ); //Add settings links. add_filter( 'the_content', 'fcbk_bttn_plgn_display_button' );