This commit is contained in:
André Menrath 2023-11-18 15:00:28 +01:00
parent 8696f9ed10
commit da3453a069
5 changed files with 87 additions and 22 deletions

View file

@ -0,0 +1,23 @@
<?php
/**
* Inspired by the PHP ActivityPub Library by @Landrok
*
* @link https://github.com/landrok/activitypub
*/
namespace Activitypub\Activity;
use ActivityPub\Activity\Base_Object;
/**
* Event is an implementation of one of the
* Activity Streams Event object type
*
* The Object is the primary base type for the Activity Streams
* vocabulary.
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-event
*/
class Note extends Base_Object {
protected $type = 'Event';
}

View file

@ -0,0 +1,23 @@
<?php
/**
* Inspired by the PHP ActivityPub Library by @Landrok
*
* @link https://github.com/landrok/activitypub
*/
namespace Activitypub\Activity;
use ActivityPub\Activity\Base_Object;
/**
* Note is an implementation of one of the
* Activity Streams Note object type
*
* The Object is the primary base type for the Activity Streams
* vocabulary.
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-note
*/
class Note extends Base_Object {
protected $type = 'Note';
}

View file

@ -5,13 +5,7 @@
* @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;
namespace Activitypub;
/**
* Base class to implement WordPress to ActivityPub transformers.
@ -26,7 +20,7 @@ abstract class Transformer_Base {
* @return string[] An array containing all the supported post types.
*/
public function get_supported_post_types() {
return \get_post_types( array(), 'names');
return \get_post_types( ['public' => true], 'names' );
}
/**

View file

@ -25,7 +25,7 @@ class Admin {
}
add_filter( 'activitypub/transformers/is_transformer_enabled', function( $should_register, Transformer_Base $widget_instance ) {
return ! Options::is_element_disabled( $widget_instance->get_name() );
return ! Options::is_transformer_disabled( $transformer_instance->get_name() );
}, 10, 2 );
}

View file

@ -7,6 +7,8 @@
namespace ActivityPub;
use function Activitypub\camel_to_snake_case;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
@ -128,21 +130,44 @@ class Transformers_Manager {
}
/**
* Register controls.
* Init transformers.
*
* This method creates a list of all the supported controls by requiring the
* control files and initializing each one of them.
* Initialize ActivityPub transformer manager.
*
* The list of supported controls includes the regular controls and the group
* controls.
* Include the builtin transformers by default and add third party ones.
*
* External developers can register new controls by hooking to the
* `elementor/controls/controls_registered` action.
*
* @since 3.1.0
* @since version_number_transformer_management_placeholder
* @access private
*/
private function register_controls() {
private function init_transformers() {
$builtin_transformers = [
'post'
];
$this->_transformers = [];
foreach ( $builtin_transformers as $transformer_name ) {
include ACTIVITYPUB_PLUGIN_DIR . 'includes/transformers/class-' . $transformer_name . '.php';
$class_name = camel_to_snake_case( $transformer_name );
$class_name = __NAMESPACE__ . '\Transformer_' . $class_name;
$this->register( new $class_name() );
}
/**
* After the transformers are registered.
*
* Fires after the built-in Actiitypub transformers are registered.
*
* @since version_number_transformer_management_placeholder
*
* @param Transformer_Manager $this The widgets manager.
*/
do_action( 'activitypub/transformers/register', $this );
}
}