# templately/3.5.2/includes/Builder/Conditions/PostByAuthor.php

Templately – Elementor &amp; Gutenberg Template Library: 6500+ Free &amp; Pro Ready Templates And Cloud!, version 3.5.2. 46 lines.

- Page: https://pluginprobe.com/plugins/templately/3.5.2/code/includes/Builder/Conditions/PostByAuthor.php
- Raw: https://pluginprobe.com/plugins/templately/3.5.2/raw/includes/Builder/Conditions/PostByAuthor.php
- Modified: 2024-01-24T10:10:10+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/templately/3.5.2/code/includes/Builder/Conditions/PostByAuthor.php#L10-L20`.

```php
<?php

namespace Templately\Builder\Conditions;

class PostByAuthor extends Condition {
	private $post_type;

	public function __construct( $args = [] ) {
		$this->post_type = $args;

		parent::__construct( $args );
	}

	public function get_priority(): int {
		return 40;
	}

	public function get_label(): string {
		return sprintf( __( '%s By Author', 'templately' ), $this->post_type->label );
	}

	public function get_type(): string {
		return 'singular';
	}

	public function get_name(): string {
		return $this->post_type->name . '_by_author';
	}

	public function check( $args = [] ): bool {
		if ( ! isset( $args['id'] ) ) {
			return false;
		}

		return is_singular( $this->post_type->name ) && get_post_field( 'post_author' ) === $args['id'];
	}

	protected function register_controls() {
		$this->add_control( $this->get_name(), [
			'field'      => 'ID',
			'query_type' => 'authors',
			'options'    => [ '' => 'All' ],
			'query'      => []
		] );
	}
}
```
