HEX
Server: Apache/2.4.41
System: Linux mainweb 5.4.0-182-generic #202-Ubuntu SMP Fri Apr 26 12:29:36 UTC 2024 x86_64
User: nationalmedicaregrp (1119)
PHP: 8.3.7
Disabled: exec,passthru,shell_exec,system,popen,proc_open,pcntl_exec
Upload Files
File: /home/flbestac/public_html/wp-content/plugins/templately/includes/Builder/Conditions/Taxonomy.php
<?php

namespace Templately\Builder\Conditions;

class Taxonomy extends Condition {
	protected $taxonomy;

	public function __construct( $args = [] ) {
		$this->taxonomy = $args['instance'];

		parent::__construct( $args );
	}

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

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

	public function get_label(): string {
		return ucwords( $this->taxonomy->label );
	}

	public function check( $args = [] ): bool {
		$taxonomy = $this->get_name();
		$id       = (int) $args['id'];

		if ( 'category' === $taxonomy ) {
			return is_category( $id );
		}

		if ( 'post_tag' === $taxonomy ) {
			return is_tag( $id );
		}

		return is_tax( $taxonomy, $id );
	}

	public function get_name(): string {
		return $this->taxonomy->name;
	}

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