HEX
Server: LiteSpeed
System: Linux premium267.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: predezso (1249)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/predezso/uppoom.com/wp-content/plugins/bulk-delete/include/Core/Base/BaseDeletePage.php
<?php

namespace BulkWP\BulkDelete\Core\Base;

use BulkWP\BulkDelete\Core\BulkDelete;

defined( 'ABSPATH' ) || exit; // Exit if accessed directly.

/**
 * Base class for all Bulk Delete pages that will have modules.
 *
 * @since 6.0.0
 */
abstract class BaseDeletePage extends BasePage {
	/**
	 * Item Type. Possible values 'posts', 'pages', 'users' etc.
	 *
	 * @var string
	 */
	protected $item_type;

	/**
	 * Modules registered to this page.
	 *
	 * @var \BulkWP\BulkDelete\Core\Base\BaseModule[]
	 */
	protected $modules = array();

	/**
	 * Register the modules after the page is registered.
	 */
	public function register() {
		parent::register();

		if ( $this->has_modules() ) {
			$this->register_modules();
		}
	}

	/**
	 * Add a module to the page.
	 *
	 * @param \BulkWP\BulkDelete\Core\Base\BaseModule $module Module to add.
	 */
	public function add_module( $module ) {
		if ( in_array( $module, $this->modules, true ) ) {
			return;
		}

		$this->modules[ $module->get_name() ] = $module;
	}

	/**
	 * Get module object instance by module class name.
	 *
	 * @param string $module_class_name Module class name.
	 *
	 * @return \BulkWP\BulkDelete\Core\Base\BaseModule|null Module object instance or null if no match found.
	 */
	public function get_module( $module_class_name ) {
		$short_class_name = bd_get_short_class_name( $module_class_name );

		if ( isset( $this->modules[ $short_class_name ] ) ) {
			return $this->modules[ $short_class_name ];
		}

		return null;
	}

	protected function register_hooks() {
		parent::register_hooks();

		add_action( "load-{$this->hook_suffix}", array( $this, 'on_load_page' ) );
	}

	

	/**
	 * Trigger the add_meta_boxes hooks to allow modules to be added when the page is loaded.
	 */
	public function on_load_page() {
		do_action( 'add_meta_boxes_' . $this->hook_suffix, null ); //phpcs:ignore
	}

	/**
	 * Add additional nonce fields that are related to modules.
	 */
	protected function render_nonce_fields() {
		parent::render_nonce_fields();

		// Used to save closed meta boxes and their order.
		wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
		wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
	}

	/**
	 * Render meta boxes in body.
	 */
	protected function render_body() {
		do_meta_boxes( '', 'advanced', null );
	}

	/**
	 * Render footer.
	 */
	protected function render_footer() {
		parent::render_footer();

		/**
		 * Runs just before displaying the footer text in the admin page.
		 *
		 * This action is primarily for adding extra content in the footer of admin page.
		 *
		 * @since 5.5.4
		 */
		do_action( "bd_admin_footer_for_{$this->item_type}" ); //phpcs:ignore
	}

	/**
	 * Does this page have any modules?
	 *
	 * @return bool True if page has modules, False otherwise.
	 */
	protected function has_modules() {
		return ! empty( $this->modules );
	}

	/**
	 * Load all the registered modules.
	 */
	protected function register_modules() {
		foreach ( $this->modules as $module ) {
			$module->register( $this->hook_suffix, $this->page_slug );
			$this->actions[] = $module->get_action();
		}

		/**
		 * Triggered after all modules are registered.
		 *
		 * @since 6.0.0
		 */
		do_action( "bd_add_meta_box_for_{$this->get_item_type()}" ); //phpcs:ignore
	}

	/**
	 * Get the item type of the page.
	 *
	 * @return string Item type of the page.
	 */
	public function get_item_type() {
		return $this->item_type;
	}
}