PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Rules / Condition / CPT / IsArchive.php

IsArchive.php in Depicter — Popup & Slider Builder trunk, at app/src/Rules/Condition/CPT/IsArchive.php

65 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Depicter\Rules\Condition\CPT;
4
5 use Averta\Core\Utility\Arr;
6 use Depicter\Rules\Condition\CPT\Base as CPTConditionBase;
7
8 class IsArchive extends CPTConditionBase
9 {
10 /**
11 * @inheritdoc
12 */
13 public $slug = 'CPT_IsArchive';
14
15 /**
16 * @inheritdoc
17 */
18 public $control = 'multiSelect';
19
20 /**
21 * @inheritdoc
22 */
23 protected $belongsTo = 'CPT';
24
25
26 /**
27 * @inheritdoc
28 */
29 public function getLabel(): ?string{
30 return __( "Archive Page", 'depicter' );
31 }
32
33 /**
34 * @inheritDoc
35 */
36 public function getControlOptions(){
37 $options = parent::getControlOptions();
38
39 $archiveOptions = [];
40 foreach( $this->availablePostTypes as $postType ) {
41 if ( $postType->name == 'product' ) {
42 continue;
43 }
44
45 $archiveOptions[] = [
46 /* translators: singular name of post type */
47 'label' => sprintf( __( '%s Archive', 'depicter' ), $postType->labels->singular_name ),
48 'value' => $postType->name
49 ];
50 }
51
52 return Arr::merge( $options, [ 'options' => $archiveOptions ]);
53 }
54
55 /**
56 * @inheritdoc
57 */
58 public function check( $value = null ): bool{
59
60 $isIncluded = !empty( $value ) ? is_post_type_archive( $value ) : is_archive();
61
62 return $this->selectionMode === 'include' ? $isIncluded : ! $isIncluded;
63 }
64 }
65