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 / IsSingle.php

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

66 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 class IsSingle extends CPTConditionBase
8 {
9 /**
10 * @inheritdoc
11 */
12 public $slug = 'CPT_IsSingle';
13
14 /**
15 * @inheritdoc
16 */
17 public $control = 'multiSelect';
18
19 /**
20 * @inheritdoc
21 */
22 protected $belongsTo = 'CPT';
23
24
25 /**
26 * @inheritdoc
27 */
28 public function getLabel(): ?string{
29 return __( "Single Page", 'depicter');
30 }
31
32 /**
33 * @inheritDoc
34 */
35 public function getControlOptions(){
36 $options = parent::getControlOptions();
37
38 $singleOptions = array_map( function( $postType ){
39 return [
40 /* translators: singular name of post type */
41 'label' => sprintf( __( '%s Single Page', 'depicter' ), $postType->labels->singular_name ),
42 'value' => $postType->name
43 ];
44 }, array_values( $this->availablePostTypes ) );
45
46 return Arr::merge( $options, [ 'options' => $singleOptions ]);
47 }
48
49 /**
50 * @inheritdoc
51 */
52 public function check( $value = null ): bool{
53 global $post;
54
55 if ( is_null( $post ) ) {
56 return false;
57 }
58
59 $value = $value ?? $this->value;
60
61 $isIncluded = ! empty ( $value ) ? is_singular( $value ) : is_singular();
62
63 return $this->selectionMode === 'include' ? $isIncluded : ! $isIncluded;
64 }
65 }
66