PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.2.8
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.2.8
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
templately / includes / Builder / Conditions / Archive.php

Archive.php in Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! 3.2.8, at includes/Builder/Conditions/Archive.php

54 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Templately\Builder\Conditions;
4
5 class Archive extends Condition {
6 protected $sub_conditions = [
7 'search'
8 ];
9
10 public function get_priority(): int {
11 return 80;
12 }
13
14 public function get_name(): string {
15 return 'archive';
16 }
17
18 public function get_label(): string {
19 return 'Archive';
20 }
21
22 public function get_type(): string {
23 return 'archive';
24 }
25
26 public function get_all_label(): string {
27 return esc_html__( 'All Archives', 'templately' );
28 }
29
30 public function check( $args = [] ): bool {
31 $is_archive = is_archive() || is_home() || is_search();
32
33 // WooCommerce is handled by `woocommerce` module.
34 if ( $is_archive && class_exists( 'woocommerce' ) && is_woocommerce() ) {
35 $is_archive = is_woocommerce() || is_search() && 'product' === get_query_var( 'post_type' );
36 }
37
38 return $is_archive;
39 }
40
41 protected function register_sub_conditions() {
42 foreach ( $this->builder->get_public_post_types() as $post_type => $label ) {
43 if ( ! get_post_type_archive_link( $post_type ) ) {
44 continue;
45 }
46
47 $condition = new PostTypeArchive( [
48 'post_type' => $post_type,
49 ] );
50
51 $this->register_sub_condition( $condition );
52 }
53 }
54 }