wordpress-activitypub/includes/managers/class-transformers-manager.php

74 lines
1.7 KiB
PHP
Raw Normal View History

<?php
/**
* Inspired by the way elementor handles addons.
*
* @link https://github.com/elementor/elementor/
*/
namespace ActivityPub;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* ActivityPub transformers manager.
*
* ActivityPub transformers manager handler class is responsible for registering and
* initializing all the supported WP-Pobject to ActivityPub transformers.
*
* @since version_number_transformer_management_placeholder
*/
class Transformers_Manager {
/**
* Transformers.
*
* Holds the list of all the transformers. Default is `null`.
*
* @since 1.0.0
* @access private
*
* @var Base_Control[]
*/
private $controls = null;
/**
* Transformers manager constructor.
*
* Initializing ActivityPub transformers manager.
*
* @since version_number_transformer_management_placeholder
* @access public
*/
public function __construct() {
$this->require_files();
add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] );
}
/**
* Register a transformer.
*
* @since version_number_transformer_management_placeholder
* @access public
*
* @param \ActivityPub\Base_Transformer $transformer_instance ActivityPub Transformer.
*
* @return bool True if the transformer was registered.
*/
public function register( Base_Transformer $control_instance, $control_id = null ) {
// TODO: For BC. Remove in the future.
if ( $control_id ) {
Plugin::instance()->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument(
'$control_id', '3.5.0'
);
} else {
$control_id = $control_instance->get_type();
}
$this->controls[ $control_id ] = $control_instance;
}
}