$val ) { if ( is_callable( $val ) ) { unset( $args['active_callback'][ $key ] ); } } if ( isset( $args['active_callback'][0] ) ) { $args['required'] = $args['active_callback']; } } } if ( ! empty( $args['required'] ) ) { $this->dependencies[ $args['settings'] ] = $args['required']; $args['active_callback'] = '__return_true'; return $args; } // No need to proceed any further if we're using the default value. if ( '__return_true' === $args['active_callback'] ) { return $args; } // Make sure the function is callable, otherwise fallback to __return_true. if ( ! is_callable( $args['active_callback'] ) ) { $args['active_callback'] = '__return_true'; } } else { // The ReactSelect field triggered from Background field doesn't have $args['active_callback'] argument. if ( ! empty( $args['required'] ) ) { $this->dependencies[ $args['settings'] ] = $args['required']; } } return $args; } /** * Enqueues the field-dependencies script * and adds variables to it using the wp_localize_script function. * The rest is handled via JS. * * @access public * @return void */ public function field_dependencies() { wp_enqueue_script( 'kirki_field_dependencies', URL::get_from_path( dirname( __DIR__ ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'customize-controls' ], '4.0', true ); wp_localize_script( 'kirki_field_dependencies', 'kirkiControlDependencies', $this->dependencies ); } }