<?php
/**
 * Dynamic Tag: User Login / Logout URL
 *
 * @package captain-widgets-kit
 * @since   1.1.0
 */

use Elementor\Core\DynamicTags\Tag;
use Elementor\Modules\DynamicTags\Module;
if ( ! defined( 'ABSPATH' ) ) {
	exit; }
/**
 * Class Captwiki_Tag_User_Login_Logout_URL
 * Outputs the WordPress login URL for guests and logout URL for logged-in users.
 */
class Captwiki_Tag_User_Login_Logout_URL extends Tag {
	/**
	 * Get tag name.
	 *
	 * @return string
	 */
	public function get_name(): string {
		return 'captwiki-tag-user-login-logout-url'; }
	/**
	 * Get tag title.
	 *
	 * @return string
	 */
	public function get_title(): string {
		return esc_html__( 'User Login/Logout URL', 'captain-widgets-kit' ); }
	/**
	 * Get tag group.
	 *
	 * @return array
	 */
	public function get_group(): array {
		return array( 'captwiki-user' ); }
	/**
	 * Get tag categories.
	 *
	 * @return array
	 */
	public function get_categories(): array {
		return array( Module::URL_CATEGORY ); }
	/**
	 * Register tag controls.
	 *
	 * @return void
	 */
	protected function register_controls(): void {}
	/**
	 * Handle register advanced section.
	 *
	 * @return void
	 */
	protected function register_advanced_section(): void {}
	/**
	 * Render tag output.
	 *
	 * @return void
	 */
	public function render(): void {
		$url = is_user_logged_in() ? wp_logout_url( get_permalink() ) : wp_login_url( get_permalink() );
		if ( ! empty( $url ) ) {
			echo esc_url( $url ); }
	}
}
