• File: route-permission-trait.php
  • Full Path: /home/docteuh/www/generator/user-interface/route-permission-trait.php
  • Date Modified: 06/23/2026 4:19 PM
  • File size: 624 bytes
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.

namespace Yoast\WP\SEO\AI\Generator\User_Interface;

/**
 * Trait for common permission checks in route classes.
 */
trait Route_Permission_Trait {

	/**
	 * Checks:
	 * - if the user is logged
	 * - if the user can edit posts
	 *
	 * @return bool Whether the user is logged in, can edit posts and the feature is active.
	 */
	public function check_permissions(): bool {
		$user = \wp_get_current_user();
		if ( $user === null || $user->ID < 1 ) {
			return false;
		}

		return \user_can( $user, 'edit_posts' );
	}
}