<?php
/**
 * Metabox abstract class.
 *
 * @link       https://flothemes.com/
 * @since      1.0.0
 *
 * @package    Flo_Flex_Builder
 * @subpackage Flo_Flex_Builder/admin
 */

abstract class Metabox
{
	/**
	 * Output screens of metabox.
	 *
	 * @var array
	 */
	public $screens = ['post', 'page', 'gallery', 'video'];

	/**
	 * Unique of metabox.
	 *
	 * @var string
	 */
	public $unique_id;

	/**
	 * Unique of metabox.
	 *
	 * @var string
	 */
	public $title;

	/**
	 * Context of metabox.
	 *
	 * @var string
	 */
	public $context;

	/**
	 * Priority of metabox.
	 *
	 * @var string
	 */
	public $priority;

	/**
	 * Method called via autoloader for action.
	 *
	 * @return void
	 */
	public function action()
	{
		//add and save metabox
		add_action('add_meta_boxes', [$this, 'add'], 5);
		add_action('save_post', [$this, 'save']);
	}

	/**
	 * Method that add metabox.
	 *
	 * @return void
	 */
	public function add()
	{
		foreach ($this->screens as $screen) {
			add_meta_box(
				$this->unique_id,
				$this->title,
				[$this, 'html'],
				$screen,
				$this->context,
				$this->priority
			);
		}
	}

	/**
	 * Method that called on save.
	 *
	 * @param $post_id
	 * @return void
	 */
	public function save($post_id)
	{
	}

	/**
	 * Method that render html of metabox.
	 *
	 * @param $post
	 * @return void
	 */
	public function html($post)
	{
	}
}
