<?php
/**
 * Plugin installation routines.
 *
 * @package PDFDraft
 */

namespace PDFDraft;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

use PDFDraft\Traits\Hooks;

/**
 * Handles initial plugin installation tasks.
 */
class Install {

	use Hooks;

	/**
	 * Run installation routines.
	 *
	 * @return void
	 */
	public function init() {
		$this->createDesignOrientations();
	}

	/**
	 * Create default design orientation taxonomy terms.
	 *
	 * @return void
	 */
	public function createDesignOrientations() {
		if ( wp_count_terms(
			array(
				'taxonomy'   => 'design_orientation',
				'hide_empty' => false,
			)
		) > 0 ) {
			return;
		}

		foreach ( array(
			'landscape' => __( 'Landscape', 'pdfdraft' ),
			'portrait'  => __( 'Portrait', 'pdfdraft' ),
		) as $orientation ) {
			! get_term_by( 'name', $orientation, 'design_orientation' ) && wp_insert_term( $orientation, 'design_orientation' );
		}
	}
}
