wip
This commit is contained in:
parent
8696f9ed10
commit
da3453a069
5 changed files with 87 additions and 22 deletions
23
includes/activity/class-event.php
Normal file
23
includes/activity/class-event.php
Normal 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';
|
||||||
|
}
|
23
includes/activity/class-note.php
Normal file
23
includes/activity/class-note.php
Normal 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';
|
||||||
|
}
|
|
@ -5,13 +5,7 @@
|
||||||
* @link https://github.com/landrok/activitypub
|
* @link https://github.com/landrok/activitypub
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub\Activity;
|
namespace Activitypub;
|
||||||
|
|
||||||
use WP_Error;
|
|
||||||
use ReflectionClass;
|
|
||||||
|
|
||||||
use function Activitypub\camel_to_snake_case;
|
|
||||||
use function Activitypub\snake_to_camel_case;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class to implement WordPress to ActivityPub transformers.
|
* 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.
|
* @return string[] An array containing all the supported post types.
|
||||||
*/
|
*/
|
||||||
public function get_supported_post_types() {
|
public function get_supported_post_types() {
|
||||||
return \get_post_types( array(), 'names');
|
return \get_post_types( ['public' => true], 'names' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Admin {
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter( 'activitypub/transformers/is_transformer_enabled', function( $should_register, Transformer_Base $widget_instance ) {
|
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 );
|
}, 10, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
namespace ActivityPub;
|
namespace ActivityPub;
|
||||||
|
|
||||||
|
use function Activitypub\camel_to_snake_case;
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
exit; // Exit if accessed directly.
|
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
|
* Initialize ActivityPub transformer manager.
|
||||||
* control files and initializing each one of them.
|
*
|
||||||
|
* Include the builtin transformers by default and add third party ones.
|
||||||
*
|
*
|
||||||
* The list of supported controls includes the regular controls and the group
|
* @since version_number_transformer_management_placeholder
|
||||||
* controls.
|
|
||||||
*
|
|
||||||
* External developers can register new controls by hooking to the
|
|
||||||
* `elementor/controls/controls_registered` action.
|
|
||||||
*
|
|
||||||
* @since 3.1.0
|
|
||||||
* @access private
|
* @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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue