initial wip based on how elementor does it

This commit is contained in:
André Menrath 2023-11-17 16:28:04 +01:00
parent efd98acd0b
commit 23dfd11d39
2 changed files with 102 additions and 0 deletions

View file

@ -0,0 +1,28 @@
<?php
/**
* Inspired by the PHP ActivityPub Library by @Landrok
*
* @link https://github.com/landrok/activitypub
*/
namespace Activitypub\Activity;
use WP_Error;
use ReflectionClass;
use function Activitypub\camel_to_snake_case;
use function Activitypub\snake_to_camel_case;
/**
* Base_Object is an implementation of one of the
* Activity Streams Core Types.
*
* The Object is the primary base type for the Activity Streams
* vocabulary.
*
* Note: Object is a reserved keyword in PHP. It has been suffixed with
* 'Base_' for this reason.
*
* @see https://www.w3.org/TR/activitystreams-core/#object
*/
class Base_Object {

View file

@ -0,0 +1,74 @@
<?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;
}
}