$ composer require inc2734/wp-ogp
<?php
add_action(
'wp_head',
function() {
$ogp = new \Inc2734\WP_OGP\Bootsrap();
?>
<meta property="og:title" content="<?php echo esc_attr( $ogp->get_title() ); ?>">
<meta property="og:type" content="<?php echo esc_attr( $ogp->get_type() ); ?>">
<meta property="og:url" content="<?php echo esc_attr( $ogp->get_url() ); ?>">
<meta property="og:image" content="<?php echo esc_attr( $ogp->get_image() ); ?>">
<meta property="og:site_name" content="<?php echo esc_attr( $ogp->get_site_name() ); ?>">
<meta property="og:description" content="<?php echo esc_attr( $ogp->get_description() ); ?>">
<meta property="og:locale" content="<?php echo esc_attr( $ogp->get_locale() ); ?>">
<?php
}
);
/**
* Customize og:title
*
* @param string $title
* @return string
*/
add_filter(
'inc2734_wp_ogp_title',
function( $title ) {
return $title;
}
);
/**
* Customize og:type
*
* @param string $type
* @return string
*/
add_filter(
'inc2734_wp_ogp_type',
function( $type ) {
return $type;
}
);
/**
* Customize og:url
*
* @param string $url
* @return string
*/
add_filter(
'inc2734_wp_ogp_url',
function( $url ) {
return $url;
}
);
/**
* Customize og:image
*
* @param string $image
* @return string
*/
add_filter(
'inc2734_wp_ogp_image',
function( $image ) {
return $image;
}
);
/**
* Customize og:description
*
* @param string $description
* @return string
*/
add_filter(
'inc2734_wp_ogp_description',
function( $description ) {
return $description;
}
);
/**
* Customize og:site_name
*
* @param string $site_name
* @return string
*/
add_filter(
'inc2734_wp_ogp_site_name',
function( $site_name ) {
return $site_name;
}
);
/**
* Customize og:locale
*
* @param string $locale
* @return string
*/
add_filter(
'inc2734_wp_ogp_locale',
function( locale ) {
return $locale;
}
);
/**
* Customize fb:app_id
*
* @param string $app_id
* @return string
*/
add_filter(
'inc2734_wp_ogp_app_id',
function( $app_id ) {
return $app_id;
}
);