12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- if ( ! defined( 'ABSPATH' ) ) {
- exit;
- }
- if ( ! class_exists( 'ACF_Location_Widget' ) ) :
- class ACF_Location_Widget extends ACF_Location {
-
- public function initialize() {
- $this->name = 'widget';
- $this->label = __( 'Widget', 'acf' );
- $this->category = 'forms';
- $this->object_type = 'widget';
- }
-
- public function match( $rule, $screen, $field_group ) {
-
- if ( isset( $screen['widget'] ) ) {
- $widget = $screen['widget'];
- } else {
- return false;
- }
-
- return $this->compare_to_rule( $widget, $rule );
- }
-
- public function get_values( $rule ) {
- global $wp_widget_factory;
-
- $choices = array(
- 'all' => __( 'All', 'acf' ),
- );
- if ( $wp_widget_factory->widgets ) {
- foreach ( $wp_widget_factory->widgets as $widget ) {
- $choices[ $widget->id_base ] = $widget->name;
- }
- }
- return $choices;
- }
- }
-
- acf_register_location_type( 'ACF_Location_Widget' );
- endif;
|