<?php
/**
 * Gutenberg Plugin Sidebar Post Settings class.
 *
 * @package Page_Generator_Pro
 * @author WP Zinc
 */

/**
 * Gutenberg Plugin Sidebar Post Settings definition.
 *
 * @package Page_Generator_Pro
 * @author  WP Zinc
 */
class Page_Generator_Pro_Gutenberg_Plugin_Sidebar_Post extends Page_Generator_Pro_Gutenberg_Plugin_Sidebar {

	/**
	 * Holds the base object.
	 *
	 * @since   5.5.5
	 *
	 * @var     object
	 */
	public $base;

	/**
	 * Constructor
	 *
	 * @since   5.5.5
	 *
	 * @param   object $base    Base Plugin Class.
	 */
	public function __construct( $base ) {

		$this->base = $base;

		// Register this as a plugin sidebar in the Plugin.
		add_filter( 'page_generator_pro_gutenberg_plugin_sidebars', array( $this, 'register' ) );

	}

	/**
	 * Returns this plugin sidebar's programmatic name, excluding the page-generator-pro- prefix.
	 *
	 * @since   5.5.5
	 *
	 * @return  string
	 */
	public function get_name() {

		return 'post';

	}

	/**
	 * Returns this plugin sidebar's title.
	 *
	 * @since   5.5.5
	 */
	public function get_title() {

		return $this->base->plugin->displayName;

	}

	/**
	 * Returns this plugin sidebar's attributes
	 *
	 * @since   5.5.5
	 *
	 * @return  array
	 */
	public function get_attributes() {

		return array(
			'_page_generator_pro_exclude' => array(
				'type'    => 'boolean',
				'default' => $this->get_default_value( '_page_generator_pro_exclude' ),
			),
		);

	}

	/**
	 * Returns this plugin sidebar's Fields
	 *
	 * @since   5.5.5
	 *
	 * @return  bool|array
	 */
	public function get_fields() {

		return array(
			'_page_generator_pro_exclude' => array(
				'label'         => __( 'Exclude from regeneration?', 'page-generator-pro' ),
				'type'          => 'toggle',
				'description'   => __( 'If enabled, the post will not be regenerated when the Content Group\'s Generate functionality is run, even if the Content Group is set to overwrite.', 'page-generator-pro' ),
				'default_value' => $this->get_default_value( '_page_generator_pro_exclude' ),
			),
		);

	}

	/**
	 * Returns this plugin sidebar's Default Values
	 *
	 * @since   5.5.5
	 *
	 * @return  array
	 */
	public function get_default_values() {

		return array(
			'_page_generator_pro_exclude' => false,
		);

	}

}
