12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- if ( ! defined( 'ABSPATH' ) ) {
- exit;
- }
- if ( ! class_exists( 'ACF_Location_Block' ) ) :
- class ACF_Location_Block extends ACF_Location {
-
- public function initialize() {
- $this->name = 'block';
- $this->label = __( 'Block', 'acf' );
- $this->category = 'forms';
- $this->object_type = 'block';
- }
-
- public function match( $rule, $screen, $field_group ) {
-
- if ( isset( $screen['block'] ) ) {
- $block = $screen['block'];
- } else {
- return false;
- }
-
- return $this->compare_to_rule( $block, $rule );
- }
-
- public function get_values( $rule ) {
- $choices = array();
-
- $blocks = acf_get_block_types();
- if ( $blocks ) {
- $choices['all'] = __( 'All', 'acf' );
- foreach ( $blocks as $block ) {
- $choices[ $block['name'] ] = $block['title'];
- }
- } else {
- $choices[''] = __( 'No block types exist', 'acf' );
- }
-
- return $choices;
- }
- }
-
- acf_register_location_type( 'ACF_Location_Block' );
- endif;
|