NonPublicCPTPreview.php
806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace WPML\TM\ATE\Review;
use WPML\FP\Fns;
use WPML\FP\Logic;
use WPML\FP\Lst;
use WPML\FP\Obj;
/**
* This will allow displaying private CPT reviews on the frontend.
*/
class NonPublicCPTPreview {
const POST_TYPE = 'wpmlReviewPostType';
/**
* @param array $args
*
* @return array
*/
public static function addArgs( array $args ) {
return Obj::assoc( self::POST_TYPE, \get_post_type( $args['preview_id'] ), $args );
}
/**
* @return callable
*/
public static function allowReviewPostTypeQueryVar() {
return Lst::append( self::POST_TYPE );
}
/**
* @return callable
*/
public static function enforceReviewPostTypeIfSet() {
return Logic::ifElse(
Obj::prop( self::POST_TYPE ),
Obj::renameProp( self::POST_TYPE, 'post_type' ),
Fns::identity()
) ;
}
}