<?php
/**
 * Top-level WordPress admin menu for Payments Square Connect.
 *
 * @package SHC4WC
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class SHC4WC_Admin_Menu {
	const MENU_SLUG     = 'payments-square-connect';
	const CONNECT_SLUG  = 'payments-square-connect';
	const CHECKOUT_SLUG      = 'payments-square-connect-checkout';
	const SUBSCRIPTIONS_SLUG = 'payments-square-connect-subscriptions';
	const SUPPORT_SLUG       = 'payments-square-connect-support';

	/**
	 * Admin URL for a plugin screen.
	 *
	 * @param string $page_slug Page slug.
	 * @param array  $args      Optional query args.
	 * @return string
	 */
	public static function page_url( $page_slug = self::CONNECT_SLUG, $args = array() ) {
		$url = admin_url( 'admin.php?page=' . rawurlencode( $page_slug ) );
		if ( ! empty( $args ) ) {
			$url = add_query_arg( $args, $url );
		}
		return $url;
	}

	/**
	 * Register the parent menu (submenus are added by each screen class).
	 */
	public static function register_parent_menu() {
		add_menu_page(
			__( 'Payments Square Connect', 'payments-connect-square' ),
			__( 'Payments Square Connect', 'payments-connect-square' ),
			'manage_options',
			self::MENU_SLUG,
			null,
			'dashicons-money-alt',
			56
		);
	}
}
