<commit_before><?php
namespace Podlove\Modules\OpenGraph;

use Podlove\Model;
use Podlove\DomDocumentFragment;

class Open_Graph extends \Podlove\Modules\Base {

		protected $module_name = 'Open Graph Integration';
		protected $module_description = 'Adds Open Graph metadata to episodes. Useful for third party services.';
		protected $module_group = 'web publishing';

		public function load() {
			add_action( 'wp', array( $this, 'register_hooks' ) );
		}

		/**
		 * Register hooks on episode pages only.
		 */
		public function register_hooks() {
			
			if ( ! is_single() )
				return;

			if ( 'podcast' !== get_post_type() )
				return;

			add_filter( 'language_attributes', function ( $output = '' ) {
				return $output . ' prefix="og: http://ogp.me/ns#"';
			} );

			// as recommended in http://jetpack.me/2013/05/03/remove-open-graph-meta-tags/
			// @fixme Generate conflicts for known conflicting plugins.
			//        Get inspired by Jetpack's list class.jetpack.php "open_graph_conflicting_plugins"
			add_filter( 'jetpack_enable_open_graph', '__return_false' );

			add_action( 'wp_head', array( $this, 'the_open_graph_metadata' ) );
		}

		public function the_open_graph_metadata()
		{
			$cache_key = 'opgv2' . get_the_ID() . get_permalink();

			$cache = \Podlove\Cache\TemplateCache::get_instance();
			echo $cache->cache_for($cache_key, function() {
				return (string) \Podlove\Modules\OpenGraph\Open_Graph::get_open_graph_metadata();
			});
		}

		/**
		 * Insert HTML meta tags into site head.
		 *
		 * @todo  caching
		 * @todo  let user choose what's in og:description: subtitle, excerpt, ...
		 * @todo  handle multiple releases per episode
		 */
		public static function get_open_graph_metadata() {

			$post_id = get_the_ID();
			if ( ! $post_id )
				return;

			$post = get_post($episode->post_id);

			$episode = \Podlove\Model\Episode::find_one_by_post_id( $post_id );
			if ( ! $episode )
				return;<commit_msg>fix open graph typo<commit_after><?php
namespace Podlove\Modules\OpenGraph;

use Podlove\Model;
use Podlove\DomDocumentFragment;

class Open_Graph extends \Podlove\Modules\Base {

		protected $module_name = 'Open Graph Integration';
		protected $module_description = 'Adds Open Graph metadata to episodes. Useful for third party services.';
		protected $module_group = 'web publishing';

		public function load() {
			add_action( 'wp', array( $this, 'register_hooks' ) );
		}

		/**
		 * Register hooks on episode pages only.
		 */
		public function register_hooks() {
			
			if ( ! is_single() )
				return;

			if ( 'podcast' !== get_post_type() )
				return;

			add_filter( 'language_attributes', function ( $output = '' ) {
				return $output . ' prefix="og: http://ogp.me/ns#"';
			} );

			// as recommended in http://jetpack.me/2013/05/03/remove-open-graph-meta-tags/
			// @fixme Generate conflicts for known conflicting plugins.
			//        Get inspired by Jetpack's list class.jetpack.php "open_graph_conflicting_plugins"
			add_filter( 'jetpack_enable_open_graph', '__return_false' );

			add_action( 'wp_head', array( $this, 'the_open_graph_metadata' ) );
		}

		public function the_open_graph_metadata()
		{
			$cache_key = 'opgv2' . get_the_ID() . get_permalink();

			$cache = \Podlove\Cache\TemplateCache::get_instance();
			echo $cache->cache_for($cache_key, function() {
				return (string) \Podlove\Modules\OpenGraph\Open_Graph::get_open_graph_metadata();
			});
		}

		/**
		 * Insert HTML meta tags into site head.
		 *
		 * @todo  caching
		 * @todo  let user choose what's in og:description: subtitle, excerpt, ...
		 * @todo  handle multiple releases per episode
		 */
		public static function get_open_graph_metadata() {

			$post_id = get_the_ID();
			if ( ! $post_id )
				return;

			$post = get_post($post_id);

			$episode = \Podlove\Model\Episode::find_one_by_post_id( $post_id );
			if ( ! $episode )
				return;
{'fraction_non_alphanumeric': 0.1319640564826701, 'fraction_numerical': 0.004621309370988447, 'mean_word_length': 3.5674091441969518, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, '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': '3089118', 'n_tokens_mistral': 1483, 'n_tokens_neox': 1264, 'n_words': 296}