HEX
Server: Apache
System: Linux webm020.cluster127.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: bohousj (181416)
PHP: 8.4.22
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/b/o/h/bohousj/www/wp-content/plugins/perfect-woocommerce-brands/lib/class-term.php
<?php

namespace QuadLayers\PWB;

defined( 'ABSPATH' ) || die( 'No script kiddies please!' );

class Term {

	protected $term_obj;
	protected $id;
	protected $name;
	protected $link;
	protected $image;
	protected $banner;
	protected $banner_link;
	protected $desc;
	protected $slug;

	public function __construct( $term_obj ) {
		$this->term_obj = $term_obj;
		$this->is_wp_term();
	}

	private function is_wp_term() {
		if ( is_a( $this->term_obj, 'WP_Term' ) ) {
			$this->build_pwb_term( $this->term_obj );
		} else {
			throw new \Exception( esc_html__( 'Only WP_Term objects are allowed', 'perfect-woocommerce-brands' ) );
		}
	}

	protected function build_pwb_term() {
		$this->id          = $this->term_obj->term_id;
		$this->name        = $this->term_obj->name;
		$this->slug        = $this->term_obj->slug;
		$this->desc        = get_term_meta( $this->id, 'pwb_brand_banner_description', true );
		$this->link        = get_term_link( $this->term_obj->term_id );
		$this->image       = htmlentities( wp_get_attachment_image( get_term_meta( $this->id, 'pwb_brand_image', true ), 'full' ) );
		$this->banner      = htmlentities( wp_get_attachment_image( get_term_meta( $this->id, 'pwb_brand_banner', true ), 'full' ) );
		$this->banner_link = get_term_meta( $this->id, 'pwb_brand_banner_link', true );
	}

	public function get( $key = 'id' ) {
		return ( isset( $this->$key ) ) ? $this->$key : false;
	}
}