<?php
/*
Plugin Name: FB Meta Insert
Description: This plugin will use for insert fb meta deta in website post.
Plugin URI: http://www.freeunlimited3ginternet.com/
Version: 1.0
Author: Anil Kumar Tanwar
Author URI: http://www.freeunlimited3ginternet.com/


*/
?>
<?php
add_action('wp_head','display_fbopengraph');

function display_fbopengraph(){
if(is_single()){ ?>
//fb meta data open graph display 0.1 Version 
<meta property="og : title" content="<?php the_title() ?>" />
<meta property="og : url" content="<?php the_permalink() ?>" />
<meta property="og : description" content="<?php the_excerpt() ?>" />
<meta property="og : site_name" content="<?php bloginfo('name') ?>" />
<?php
if(has_post_thumbnail()){
 $full_image = wp_get_attachment_image_src(get_post_thumbnail_id(),'full')

?>
<meta property="og : image" content="<?php echo $full_image[0]; ?>"/>
<?php } else { ?>

<meta property="og : image" content="<?php echo esc_attr(get_option('defult-image-url')); ?>"/>

  
//End fb meta data open graph display 0.1 Version
<?php }} }

//FB META INSERT SETTING PAGE

add_action('admin_menu','myfb_plugin_settings');

function myfb_plugin_settings(){
add_menu_page('My FB Meta Plugin', 'My FB Meta', 'administrator', 'my_fb_meta_insert', 'my_plugin_setting_page', 'dashicons-facebook', '90');

}

add_action('admin_init','my_plugin_option');

function my_plugin_option(){
	register_setting('my-meta-deta-group','activ-meta-data');
	register_setting('my-meta-deta-group','defult-image-url');

}


function my_plugin_setting_page(){
echo "<h1>My FB Meta Setting Page</h1> <br><br>";
?>
<div class="warp">
<form action="options.php" method="post">
<?php settings_fields( 'my-meta-deta-group' ); ?>
<?php do_settings_sections( 'my-meta-deta-group' ); ?>
<lable>Enter Defult Image</lable>
<input type="text" name="defult-image-url" value="<?php echo esc_attr(get_option('defult-image-url'));  ?>">
<?php submit_button(); ?>

</form>
</div>

 <?php
}



?>