<?php

/**
 * Plugin glomex_oEmbed
 *
 * @package   glomex_oEmbed
 * @author    glomex <info@glomex.com>
 * @copyright 2022 glomex
 * @license   Apache-2.0
 * @link      https://glomex.com
 */

namespace glomex_oEmbed\Backend;

use glomex_oEmbed\Engine\Base;
use PointerPlus;

/**
 * All the WP pointers.
 */
class Pointers extends Base {

	/**
	 * Initialize the Pointers.
	 *
	 * @since 0.0.1
	 * @return void|bool
	 */
	public function initialize() {
		parent::initialize();

		new PointerPlus( array( 'prefix' => GLOMEX_OEMBED_TEXTDOMAIN ) );
		\add_filter( 'glomexoembed-pointerplus_list', array( $this, 'custom_initial_pointers' ), 10, 2 );
	}

	/**
	 * Add pointers.
	 * Check on https://github.com/Mte90/pointerplus/blob/master/pointerplus.php for examples
	 *
	 * @param array  $pointers The list of pointers.
	 * @param string $prefix   For your pointers.
	 * @since 0.0.1
	 * @return array
	 */
	public function custom_initial_pointers( array $pointers, string $prefix ) {
		$config = array(
			$prefix . '_glomex_oembed_to_plugin_settings' => array(
				'selector'   => '#' . GLOMEX_OEMBED_TEXTDOMAIN . '_settings_link',
				'title'      => \__( 'glomex oEmbed Help', 'glomex-oembed' ),
				'text'       => \__( 'Please go to the plugin settings page to configure it.', 'glomex-oembed' ),
				'edge'       => 'top',
				'align'      => 'left',
				'icon_class' => 'dashicons-welcome-learn-more',
			),
			$prefix . '_configure_structured_data'        => array(
				'selector'   => '#' . GLOMEX_OEMBED_TEXTDOMAIN . '_options #includeStructuredData',
				'title'      => \__( 'glomex oEmbed Help', 'glomex-oembed' ),
				'text'       => \__( 'Enable this checkbox if you would like to have a structured data included into the page upon embedding.', 'glomex-oembed' ),
				'edge'       => 'top',
				'align'      => 'left',
				'icon_class' => 'dashicons-welcome-learn-more',
			),
		);

		if ( empty( \getenv( 'GLOMEX_INTEGRATION_ID' ) ) ) {
			$config[$prefix . '_set_up_integration_id'] = array(
				'selector'   => '#' . GLOMEX_OEMBED_TEXTDOMAIN . '_options #integrationId',
				'title'      => \__( 'glomex oEmbed Help', 'glomex-oembed' ),
				'text'       => \__( 'Input your integration ID here.', 'glomex-oembed' ),
				'edge'       => 'top',
				'align'      => 'left',
				'icon_class' => 'dashicons-welcome-learn-more',
			);
		}

		return \array_merge( $pointers, $config );
	}

}
