| Server IP : 87.98.154.146 / Your IP : 216.73.216.165 Web Server : Apache System : Linux webm004.cluster126.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 : ohklomafyi ( 52085) PHP Version : 7.4.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/ohklomafyi/www/wp-content/plugins/templately/includes/Builder/Conditions/ |
Upload File : |
<?php
namespace Templately\Builder\Conditions;
class PostTypeArchive extends Condition {
protected $post_type;
protected $post_taxonomies = [];
public function __construct( $args = [] ) {
$this->post_type = get_post_type_object( $args['post_type'] );
$taxonomies = get_object_taxonomies( $args['post_type'], 'objects' );
$this->post_taxonomies = wp_filter_object_list( $taxonomies, [
'public' => true,
'show_in_nav_menus' => true,
] );
parent::__construct( $args );
}
public function get_priority(): int {
return 70;
}
public function get_name(): string {
return $this->post_type->name . '_archive';
}
public function get_all_label(): string {
return sprintf( __( '%s Archive', 'templately' ), $this->post_type->label );
}
public function get_label(): string {
return sprintf( __( '%s Archive', 'templately' ), $this->post_type->labels->singular_name );
}
public function get_type(): string {
return 'archive';
}
public function check( $args = [] ): bool {
return is_post_type_archive( $this->post_type->name ) || ( 'post' === $this->post_type->name && is_home() );
}
protected function register_sub_conditions() {
if ( ! empty( $this->post_taxonomies ) ) {
foreach ( $this->post_taxonomies as $taxonomy => $taxonomy_object ) {
$condition = new Taxonomy( [
'taxonomy' => $taxonomy,
'instance' => $taxonomy_object
] );
$this->register_sub_condition( $condition );
}
}
if ( $this->post_type->name === 'product' ) {
$condition = new ProductSearch();
$this->register_sub_condition( $condition );
}
}
}