Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
class-wp-revisions-control-bulk-actions.php 5.33 KiB
<?php
/**
 * Bulk actions.
 *
 * @package WP_Revisions_Control
 */

/**
 * Class WP_Revisions_Control_Bulk_Actions.
 */
class WP_Revisions_Control_Bulk_Actions {
	/**
	 * Singleton.
	 *
	 * @var static
	 */
	private static $__instance;

	/**
	 * Supported post types.
	 *
	 * @var array
	 */
	protected $post_types;

	/**
	 * Base for bulk action names.
	 *
	 * @var string
	 */
	protected $action_base = 'wp_rev_ctl_bulk_';

	/**
	 * Custom bulk actions.
	 *
	 * @var array
	 */
	protected $actions;

	/**
	 * Silence is golden!
	 */
	private function __construct() {}

	/**
	 * Singleton implementation.
	 *
	 * @param array $post_types Supported post types, used only on instantiation.
	 * @return static
	 */
	public static function get_instance( $post_types = array() ) {
		if ( ! is_a( static::$__instance, __CLASS__ ) ) {
			static::$__instance = new self();

			static::$__instance->setup( $post_types );
		}

		return static::$__instance;
	}

	/**
	 * One-time actions.
	 *
	 * @param array $post_types Supported post types.
	 */
	public function setup( $post_types ) {
		if ( empty( $post_types ) || ! is_array( $post_types ) ) {
			return;
		}