<?php

/**
 * Management of the Lockee iframe
 */
class Lockee_Iframe extends Lockee_Singleton
{
  /**
   * Initialize the iframe functionality
   */
  protected function init() {}

  /**
   * Add custom query variables
   */
  public function add_query_vars($vars)
  {
    $vars[] = 'view';
    return $vars;
  }

  /**
   * Handle the iframe template for displaying locks
   */
  public function handle_iframe_template()
  {
    if (get_query_var('post_type') === 'lockee_lock' && get_query_var('view') === 'iframe') {
      $post = get_post();
      if (!$post || $post->post_type !== 'lockee_lock') {
        wp_die(__('Lock not found', 'lockee'));
      }

      include plugin_dir_path(dirname(__FILE__)) . 'templates/iframe.php';
      exit;
    }
  }
}
