# depicter/trunk/app/src/Services/AuthorizationService.php

Depicter — Popup &amp; Slider Builder, version trunk. 67 lines.

- Page: https://pluginprobe.com/plugins/depicter/trunk/code/app/src/Services/AuthorizationService.php
- Raw: https://pluginprobe.com/plugins/depicter/trunk/raw/app/src/Services/AuthorizationService.php
- Modified: 2026-08-15T09:50:06+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/depicter/trunk/code/app/src/Services/AuthorizationService.php#L10-L20`.

```php
<?php

namespace Depicter\Services;

class AuthorizationService {

	/**
	 * Whether the current user has specified capabilities or not.
	 *
	 * @param string|array $capabilities
	 *
	 * @return bool
	 */
	public function currentUserCan( $capabilities ){
		if( empty( $capabilities ) ){
			return false;
		}

		$capabilities = (array) $capabilities;
		foreach( $capabilities as $capability ){
			if( current_user_can( $capability ) ){
				return true;
			}
		}

		return false;
	}

	/**
	 * Whether current user is allowed to publish document or not
	 *
	 * @return bool
	 */
	public function currentUserCanPublishDocument(){
		return $this->currentUserCan( [ 'manage_options', 'publish_depicter' ] );
	}

	/**
	 * Checks if user has enough quota to publish a new document based on their tier
	 *
	 * @return bool
	 */
	public function userHasPublishQuota(){
		// For free tier users, check if they've reached the limit (currently 2)
		if ( \Depicter::auth()->isFreeTier() ) {
			return \Depicter::documentRepository()->getNumberOfPublishedDocuments() < 2;
		}

		return true;
	}

	/**
	 * Get user session
	 *
	 * @return string
	 */
	public function getUserSession(){
		if ( !isset( $_COOKIE['depicter_session'] ) ) {
			$session = wp_generate_uuid4();
			setcookie( 'depicter_session', $session, 86400 * 30, '/' );
			return $session;
		}
		
		return $_COOKIE['depicter_session'];
	}
}

```
