<?php
/**
 * Page Header - Template
 * 
 * @package OrokuBlocks
 * @author OrokuBlocks (https://orokublocks.com/)
 * 
 * @since 1.0.0
 * 
 * @param array $args {
 *   @type string $pretitle       Page header pretitle.
 *   @type string $title          Page header title.
 *   @type string $text           Page header text.
 *   @type array $button {
 *      @type string $text        Button text.
 *      @type string $form_id     Id of the form this button should be associated with.
 *      @type bool   $disabled    True if button is disabled, false otherwise. Default: false.
 *   }
 * }
 */

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

$defaults = [];

$options = array_merge( $defaults, $args );

?>
<header class="oroku-page-header">
  <div class="oroku-page-header__item">
    <p class="oroku-page-header__pretitle"><?php echo esc_html( $options['pretitle'] ); ?></p>
    <h2 class="oroku-page-header__title oroku-h2"><?php echo esc_html( $options['title'] ); ?></h2>
    <p class="oroku-page-header__text oroku-paragraph"><?php echo esc_html( $options['text'] ); ?></p>
  </div>

<?php if ( array_key_exists( 'button', $options ) ) : ?>
  <div class="oroku-page-header__item">
    <button
      class="oroku-button oroku-button--theme--primary"
      form="<?php echo esc_attr( $options['button']['form_id'] ); ?>"
    <?php if ( array_key_exists( 'disabled', $options['button'] ) && $options['button']['disabled'] ) : ?>
      disabled
    <?php endif; ?>
    >
      <span><?php echo esc_html( $options['button']['text'] ); ?></span>
      <div class="oroku-loader oroku-loader--size--small"></div>
    </button>
  </div>
<?php endif; ?>
</header>