PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.4.0-beta2
Secure Custom Fields v6.4.0-beta2
6.9.5 6.9.4 6.9.3 6.9.2 6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / includes / locations / class-acf-location-post-type.php
secure-custom-fields / includes / locations Last commit date
abstract-acf-legacy-location.php 1 year ago abstract-acf-location.php 1 year ago class-acf-location-attachment.php 1 year ago class-acf-location-comment.php 1 year ago class-acf-location-current-user-role.php 1 year ago class-acf-location-current-user.php 1 year ago class-acf-location-nav-menu-item.php 1 year ago class-acf-location-nav-menu.php 1 year ago class-acf-location-page-parent.php 1 year ago class-acf-location-page-template.php 1 year ago class-acf-location-page-type.php 1 year ago class-acf-location-page.php 1 year ago class-acf-location-post-category.php 1 year ago class-acf-location-post-format.php 1 year ago class-acf-location-post-status.php 1 year ago class-acf-location-post-taxonomy.php 1 year ago class-acf-location-post-template.php 1 year ago class-acf-location-post-type.php 1 year ago class-acf-location-post.php 1 year ago class-acf-location-taxonomy.php 1 year ago class-acf-location-user-form.php 1 year ago class-acf-location-user-role.php 1 year ago class-acf-location-widget.php 1 year ago index.php 1 year ago
class-acf-location-post-type.php
96 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 if ( ! class_exists( 'ACF_Location_Post_Type' ) ) :
8
9 class ACF_Location_Post_Type extends ACF_Location {
10
11 /**
12 * Initializes props.
13 *
14 * @date 5/03/2014
15 * @since 5.0.0
16 *
17 * @param void
18 * @return void
19 */
20 public function initialize() {
21 $this->name = 'post_type';
22 $this->label = __( 'Post Type', 'acf' );
23 $this->category = 'post';
24 $this->object_type = 'post';
25 }
26
27 /**
28 * Matches the provided rule against the screen args returning a bool result.
29 *
30 * @date 9/4/20
31 * @since 5.9.0
32 *
33 * @param array $rule The location rule.
34 * @param array $screen The screen args.
35 * @param array $field_group The field group settings.
36 * @return boolean
37 */
38 public function match( $rule, $screen, $field_group ) {
39
40 // Check screen args.
41 if ( isset( $screen['post_type'] ) ) {
42 $post_type = $screen['post_type'];
43 } elseif ( isset( $screen['post_id'] ) ) {
44 $post_type = get_post_type( $screen['post_id'] );
45 } else {
46 return false;
47 }
48
49 // Compare rule against $post_type.
50 return $this->compare_to_rule( $post_type, $rule );
51 }
52
53 /**
54 * Returns an array of possible values for this rule type.
55 *
56 * @date 9/4/20
57 * @since 5.9.0
58 *
59 * @param array $rule A location rule.
60 * @return array
61 */
62 public function get_values( $rule ) {
63
64 // Get post types.
65 $post_types = acf_get_post_types(
66 array(
67 'show_ui' => 1,
68 'exclude' => array( 'attachment' ),
69 )
70 );
71
72 // Return array of [type => label].
73 return acf_get_pretty_post_types( $post_types );
74 }
75
76 /**
77 * Returns the object_subtype connected to this location.
78 *
79 * @date 1/4/20
80 * @since 5.9.0
81 *
82 * @param array $rule A location rule.
83 * @return string|array
84 */
85 public function get_object_subtype( $rule ) {
86 if ( $rule['operator'] === '==' ) {
87 return $rule['value'];
88 }
89 return '';
90 }
91 }
92
93 // initialize
94 acf_register_location_type( 'ACF_Location_Post_Type' );
95 endif; // class_exists check
96