<commit_before><?php
/**
 * Meta tags, OG tags, mega tags, hot tags, mad tags
 */
// Heavily borrowing from https://wordpress.org/plugins/wp-facebook-open-graph-protocol/
namespace Firebelly\Metatags;
add_action('wp_head', __NAMESPACE__ . '\build_tags', 50);
function build_tags() {
  global $post;
  if(!is_object($post) || get_class($post) != 'WP_Post') {
    return;
  }
  // Get Facebook ID for OG tags
  $facebook_app_id = \Firebelly\SiteOptions\get_option('facebook_app_id');
  if ($facebook_app_id) {
    echo '<meta property="fb:app_id" content="' . esc_attr($facebook_app_id) . '"/>' . "\n";
  }
  // Not using this yet
  // if ($facebook_admin_ids) {
  //   echo '<meta property="fb:admins" content="' . esc_attr($facebook_admin_ids) . '"/>' . "\n";
  // }
  // URL
  if (is_front_page()) {
    $metatag_url = home_url();
  } else {
    $metatag_url = 'http' . (is_ssl() ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
  }
  echo '<meta property="og:url" content="' . esc_url(user_trailingslashit(trailingslashit(apply_filters('fb_metatag_url', $metatag_url)))) . '"/>' . "\n";
  // Title
  if (is_home() || is_front_page()) {
    $metatag_title = get_bloginfo('name');
  } else {
    $metatag_title = get_bloginfo('name').': '.get_the_title();
  }
  echo '<meta property="og:title" content="' . esc_attr(apply_filters('fb_metatag_title', $metatag_title)) . '"/>' . "\n";
  // Site name
  echo '<meta property="og:site_name" content="' . get_bloginfo('name') . '"/>' . "\n";
  // Description
  if(is_home() || is_front_page()) {
    $metatag_description = get_bloginfo('description');
  } elseif (is_singular()) {
    if (has_excerpt($post->ID)) {
      $metatag_description = strip_tags(get_the_excerpt());
    } else {
      $metatag_description = str_replace("\r\n", ' ' , substr(strip_tags(strip_shortcodes($post->post_content)), 0, 160));
    }
  } else {
    $metatag_description = get_bloginfo('description');
  }
  echo '<meta property="og:description" content="' . esc_attr(apply_filters('fb_metatag_description', $metatag_description)) . '"/>' . "\n";
  // Page type
  if (is_single()) {
    $metatag_type = 'article';
  } else {
    $metatag_type = 'website';
  }
  echo '<meta property="og:type" content="' . esc_attr(apply_filters('fb_metatag_type', $metatag_type)) . '"/>' . "\n";
  // Find/output any images for use in the OGP tags
  $metatag_images = array();
  // Only find images if it isn't the homepage and the fallback isn't being forced
  if (!is_home()) {
    // Find featured thumbnail of the current post/page
    if (function_exists('has_post_thumbnail') && has_post_thumbnail($post->ID)) {
      $thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
      $link = $thumbnail_src[0];
      if (! preg_match('/^https?:\/\//', $link)) {
        // Remove any starting slash with ltrim() and add one to the end of home_url()
        $link = home_url('/') . ltrim($link, '/');
      }
      $metatag_images[] = $link; // Add to images array
    }
    if (find_images() !== false && is_singular()) { // Use our function to find post/page images
      $metatag_images = array_merge($metatag_images, find_images()); // Returns an array already, so merge into existing
    }
  }
  // Get default metatag image from site_options
  $default_metatag_image = wp_get_attachment_image_src(\Firebelly\SiteOptions\get_option('default_metatag_image_id'), 'large');
  // Add the fallback image to the images array
  if ($default_metatag_image) {
    $metatag_images[] = $default_metatag_image;
    // $metatag_images = array_reverse($metatag_images);
  }
  // Make sure there were images passed as an array and loop through/output each
  if (!empty($metatag_images)) {
    foreach ($metatag_images as $image) {
      echo '<meta property="og:image" content="' . esc_url(apply_filters('fb_metatag_image', $image)) . '"/>' . "\n";
    }
  } else {
    // Placeholder tag for AJAX content
    echo '<meta property="og:image" content=""/>' . "\n";
  }
  // Locale<commit_msg>third try: make fb image a sized thumbnail instead of raw file<commit_after><?php
/**
 * Meta tags, OG tags, mega tags, hot tags, mad tags
 */
// Heavily borrowing from https://wordpress.org/plugins/wp-facebook-open-graph-protocol/
namespace Firebelly\Metatags;
add_action('wp_head', __NAMESPACE__ . '\build_tags', 50);
function build_tags() {
  global $post;
  if(!is_object($post) || get_class($post) != 'WP_Post') {
    return;
  }
  // Get Facebook ID for OG tags
  $facebook_app_id = \Firebelly\SiteOptions\get_option('facebook_app_id');
  if ($facebook_app_id) {
    echo '<meta property="fb:app_id" content="' . esc_attr($facebook_app_id) . '"/>' . "\n";
  }
  // Not using this yet
  // if ($facebook_admin_ids) {
  //   echo '<meta property="fb:admins" content="' . esc_attr($facebook_admin_ids) . '"/>' . "\n";
  // }
  // URL
  if (is_front_page()) {
    $metatag_url = home_url();
  } else {
    $metatag_url = 'http' . (is_ssl() ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
  }
  echo '<meta property="og:url" content="' . esc_url(user_trailingslashit(trailingslashit(apply_filters('fb_metatag_url', $metatag_url)))) . '"/>' . "\n";
  // Title
  if (is_home() || is_front_page()) {
    $metatag_title = get_bloginfo('name');
  } else {
    $metatag_title = get_bloginfo('name').': '.get_the_title();
  }
  echo '<meta property="og:title" content="' . esc_attr(apply_filters('fb_metatag_title', $metatag_title)) . '"/>' . "\n";
  // Site name
  echo '<meta property="og:site_name" content="' . get_bloginfo('name') . '"/>' . "\n";
  // Description
  if(is_home() || is_front_page()) {
    $metatag_description = get_bloginfo('description');
  } elseif (is_singular()) {
    if (has_excerpt($post->ID)) {
      $metatag_description = strip_tags(get_the_excerpt());
    } else {
      $metatag_description = str_replace("\r\n", ' ' , substr(strip_tags(strip_shortcodes($post->post_content)), 0, 160));
    }
  } else {
    $metatag_description = get_bloginfo('description');
  }
  echo '<meta property="og:description" content="' . esc_attr(apply_filters('fb_metatag_description', $metatag_description)) . '"/>' . "\n";
  // Page type
  if (is_single()) {
    $metatag_type = 'article';
  } else {
    $metatag_type = 'website';
  }
  echo '<meta property="og:type" content="' . esc_attr(apply_filters('fb_metatag_type', $metatag_type)) . '"/>' . "\n";
  // Find/output any images for use in the OGP tags
  $metatag_images = array();
  // Only find images if it isn't the homepage and the fallback isn't being forced
  if (!is_home()) {
    // Find featured thumbnail of the current post/page
    if (function_exists('has_post_thumbnail') && has_post_thumbnail($post->ID)) {
      $thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
      $link = $thumbnail_src[0];
      if (! preg_match('/^https?:\/\//', $link)) {
        // Remove any starting slash with ltrim() and add one to the end of home_url()
        $link = home_url('/') . ltrim($link, '/');
      }
      $metatag_images[] = $link; // Add to images array
    }
    if (find_images() !== false && is_singular()) { // Use our function to find post/page images
      $metatag_images = array_merge($metatag_images, find_images()); // Returns an array already, so merge into existing
    }
  }
  // Get default metatag image from site_options
  $default_metatag_image = wp_get_attachment_image_src(\Firebelly\SiteOptions\get_option('default_metatag_image_id'), 'large')[0];
  // Add the fallback image to the images array
  if ($default_metatag_image) {
    $metatag_images[] = $default_metatag_image;
    // $metatag_images = array_reverse($metatag_images);
  }
  // Make sure there were images passed as an array and loop through/output each
  if (!empty($metatag_images)) {
    foreach ($metatag_images as $image) {
      echo '<meta property="og:image" content="' . esc_url(apply_filters('fb_metatag_image', $image)) . '"/>' . "\n";
    }
  } else {
    // Placeholder tag for AJAX content
    echo '<meta property="og:image" content=""/>' . "\n";
  }
  // Locale
{'fraction_non_alphanumeric': 0.17460122699386504, 'fraction_numerical': 0.0018404907975460123, 'mean_word_length': 3.772248243559719, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '404398', 'n_tokens_mistral': 2873, 'n_tokens_neox': 2816, 'n_words': 600}