PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.9.1
Secure Custom Fields v6.9.1
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-block.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-block.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-options-page.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-block.php
110 lines
1 <?php
2 /**
3 * Handles the location for the block functionality.
4 *
5 * @package wordpress/secure-custom-fields
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly
10 }
11
12 if ( ! class_exists( 'ACF_Location_Block' ) ) :
13
14 /**
15 * Handles the location for the block functionality.
16 */
17 class ACF_Location_Block extends ACF_Location {
18
19 /**
20 * Initializes props.
21 *
22 * @date 5/03/2014
23 * @since ACF 5.0.0
24 *
25 * @return void
26 */
27 public function initialize() {
28 $this->name = 'block';
29 $this->label = __( 'Block', 'secure-custom-fields' );
30 $this->category = 'forms';
31 $this->object_type = 'block';
32
33 add_filter( 'acf/field_group/list_table_classes', array( $this, 'field_group_list_table_classes' ), 10, 3 );
34 }
35
36 /**
37 * Matches the provided rule against the screen args returning a bool result.
38 *
39 * @date 9/4/20
40 * @since ACF 5.9.0
41 *
42 * @param array $rule The location rule.
43 * @param array $screen The screen args.
44 * @param array $field_group The field group settings.
45 * @return boolean
46 */
47 public function match( $rule, $screen, $field_group ) {
48
49 // Check screen args.
50 if ( isset( $screen['block'] ) ) {
51 $block = $screen['block'];
52 } else {
53 return false;
54 }
55
56 // Compare rule against $block.
57 return $this->compare_to_rule( $block, $rule );
58 }
59
60 /**
61 * Returns an array of possible values for this rule type.
62 *
63 * @date 9/4/20
64 * @since ACF 5.9.0
65 *
66 * @param array $rule A location rule.
67 * @return array
68 */
69 public function get_values( $rule ) {
70 $choices = array();
71
72 // Append block types.
73 $blocks = acf_get_block_types();
74 if ( $blocks ) {
75 $choices['all'] = __( 'All', 'secure-custom-fields' );
76 foreach ( $blocks as $block ) {
77 $choices[ $block['name'] ] = $block['title'];
78 }
79 } else {
80 $choices[''] = __( 'No block types exist', 'secure-custom-fields' );
81 }
82
83 // Return choices.
84 return $choices;
85 }
86
87 /**
88 * Adds block-specific classes to field groups in the Field Groups list table.
89 *
90 * @since ACF 6.2.8
91 *
92 * @param array $classes An array of the classes used by the field group.
93 * @param array $css_class An array of additional classes added to the field group.
94 * @param integer $post_id The ID of the field group.
95 * @return array
96 */
97 public function field_group_list_table_classes( $classes, $css_class, $post_id ) {
98 // Add a CSS class if the field group has a block location.
99 if ( acf_field_group_has_location_type( $post_id, 'block' ) ) {
100 $classes[] = 'acf-has-block-location';
101 }
102
103 return $classes;
104 }
105 }
106
107 // initialize
108 acf_register_location_type( 'ACF_Location_Block' );
109 endif; // class_exists check
110