<?php
/**
 * GravityView default widgets and generic widget class
 *
 * @package   GravityView
 * @license   GPL2+
 * @link      https://www.gravitykit.com
 * @copyright Copyright 2020, Katz Web Services, Inc.
 */

/**
 * Register the default widgets
 *
 * Widget classes are loaded via PSR-4 autoloading and eager alias resolution
 * in legacy-aliases.php. Widgets must be instantiated to register themselves
 * via the `gravityview/widgets/register` filter (constructor adds the hook).
 *
 * Some PSR-4 widget files (PageLinks, PageSize, PaginationInfo, Poll) have
 * `new` at the bottom of their class file, which triggers during autoload.
 * Other widgets need explicit instantiation here. The Widget::is_registered()
 * guard prevents double registration.
 *
 * @since 3.0.0 Restored widget instantiation after PSR-4 migration.
 *
 * @return void
 */
function gravityview_register_gravityview_widgets() {
	new \GravityView_Widget_Search();
	new \GravityView_Widget_Custom_Content();
	new \GravityView_Widget_Export_Link();
	new \GravityView_Widget_Gravity_Forms();
	new \GravityKit\GravityView\Widget\Types\BulkActions();
}

// Load default widgets
add_action( 'init', 'gravityview_register_gravityview_widgets', 11 );
