get_the_title(),
'content_type' => get_post_type(),
'content_ids' => get_the_ID(),
);
AFP_insert_fb_pixel_script($params);
}
}
add_action('wp_footer', 'AFP_FPViewContent');
// Function for single posts
function AFP_FPViewPost() {
if (is_single()) {
$category = get_the_category();
$cat_name = !empty($category) ? $category[0]->cat_name : '';
$params = array(
'content_name' => get_the_title(),
'content_category' => $cat_name,
'content_ids' => get_the_ID(),
'content_type' => get_post_type(),
);
AFP_insert_fb_pixel_script($params);
}
}
add_action('wp_footer', 'AFP_FPViewPost');
// Check if WooCommerce is active before defining WooCommerce-related functions
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
// Function for WooCommerce products
function AFP_FPProducts() {
if (is_product()) {
global $product;
$params = array(
'content_name' => get_the_title(),
'content_category' => wc_get_product_category_list($product->get_id()),
'content_ids' => get_the_ID(),
'content_type' => 'product',
'currency' => get_woocommerce_currency(),
'value' => $product->get_price(),
);
AFP_insert_fb_pixel_script($params);
}
}
add_action('woocommerce_after_single_product', 'AFP_FPProducts');
}
// Adding Open Graph in the Language Attributes
function AFP_OpengraphDoctype($output) {
return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';
}
add_filter('language_attributes', 'AFP_OpengraphDoctype');
// Adding Open Graph Meta Info
function AFP_FOpengraph() {
if (is_singular()) {
global $post;
echo '';
echo '';
echo '';
echo '';
if (has_post_thumbnail($post->ID)) {
echo '';
}
}
}
add_action('wp_head', 'AFP_FOpengraph');