PluginProbe
Advanced Custom Fields (ACF®) / 6.8.7
Advanced Custom Fields (ACF®) v6.8.7
6.8.9 6.8.8 6.8.7 6.8.6 6.8.5 6.8.4 6.8.3 6.8.2 6.8.1 5.8.5 5.8.6 5.8.7 5.8.8 5.8.9 5.9.0 5.9.1 5.9.2 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 5.9.9 6.0.0 All 230 releases
advanced-custom-fields / includes / locations / class-acf-location-widget.php
class-acf-location-widget.php
88 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package ACF
4 * @author WP Engine
5 *
6 * © 2026 Advanced Custom Fields (ACF®). All rights reserved.
7 * "ACF" is a trademark of WP Engine.
8 * Licensed under the GNU General Public License v2 or later.
9 * https://www.gnu.org/licenses/gpl-2.0.html
10 */
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // Exit if accessed directly
14 }
15
16 if ( ! class_exists( 'ACF_Location_Widget' ) ) :
17
18 class ACF_Location_Widget extends ACF_Location {
19
20 /**
21 * Initializes props.
22 *
23 * @date 5/03/2014
24 * @since 5.0.0
25 *
26 * @param void
27 * @return void
28 */
29 public function initialize() {
30 $this->name = 'widget';
31 $this->label = __( 'Widget', 'acf' );
32 $this->category = 'forms';
33 $this->object_type = 'widget';
34 }
35
36 /**
37 * Matches the provided rule against the screen args returning a bool result.
38 *
39 * @date 9/4/20
40 * @since 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['widget'] ) ) {
51 $widget = $screen['widget'];
52 } else {
53 return false;
54 }
55
56 // Compare rule against $widget.
57 return $this->compare_to_rule( $widget, $rule );
58 }
59
60 /**
61 * Returns an array of possible values for this rule type.
62 *
63 * @date 9/4/20
64 * @since 5.9.0
65 *
66 * @param array $rule A location rule.
67 * @return array
68 */
69 public function get_values( $rule ) {
70 global $wp_widget_factory;
71
72 // Populate choices.
73 $choices = array(
74 'all' => __( 'All', 'acf' ),
75 );
76 if ( $wp_widget_factory->widgets ) {
77 foreach ( $wp_widget_factory->widgets as $widget ) {
78 $choices[ $widget->id_base ] = $widget->name;
79 }
80 }
81 return $choices;
82 }
83 }
84
85 // initialize
86 acf_register_location_type( 'ACF_Location_Widget' );
87 endif; // class_exists check
88