Compare commits

...

3 commits

5 changed files with 28 additions and 25 deletions

View file

@ -65,7 +65,7 @@ class Activity_Dispatcher {
return;
}
$transformer = \Activitypub\Transformer\Transformers_Manager::instance()->get_transformer( $wp_post );
$transformer = Transformers_Manager::instance()->get_transformer( $wp_post );
$object = $transformer->to_object();
$activity = new Activity();
@ -102,7 +102,7 @@ class Activity_Dispatcher {
return;
}
$transformer = \Activitypub\Transformer\Transformers_Manager::instance()->get_transformer( $wp_post );
$transformer = Transformers_Manager::instance()->get_transformer( $wp_post );
$object = $transformer->to_object();
$activity = new Activity();

View file

@ -33,8 +33,9 @@ class Post {
public function __construct( $post, $post_author = null ) {
_deprecated_function( __CLASS__, '1.0.0', '\Activitypub\Transformer\Post' );
$this->post = $post;
$this->object = Transformer_Post->set_wp_post( $post )->to_object();
$this->post = $post;
$transformer = new Transformer_Post();
$this->object = $transformer->set_wp_post( $post )->to_object();
}
/**

View file

@ -93,7 +93,7 @@ abstract class Base {
* @return string post_type Post type name.
*/
final public function supports_post_type( $post_type ) {
return in_array( $post_type, $this->get_supported_post_types() );
return in_array( $post_type, $this->get_supported_post_types(), true );
}
/**
@ -163,6 +163,26 @@ abstract class Base {
return $content;
}
/**
* Gets the template to use to generate the content of the activitypub item.
*
* @return string The Template.
*/
protected function get_post_content_template() {
if ( 'excerpt' === \get_option( 'activitypub_post_content_type', 'content' ) ) {
return "[ap_excerpt]\n\n[ap_permalink type=\"html\"]";
}
if ( 'title' === \get_option( 'activitypub_post_content_type', 'content' ) ) {
return "[ap_title]\n\n[ap_permalink type=\"html\"]";
}
if ( 'content' === \get_option( 'activitypub_post_content_type', 'content' ) ) {
return "[ap_content]\n\n[ap_permalink type=\"html\"]\n\n[ap_hashtags]";
}
return \get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT );
}
/**
* Returns the ID of the Post.

View file

@ -107,24 +107,5 @@ class Post extends Base {
return $object_type;
}
/**
* Gets the template to use to generate the content of the activitypub item.
*
* @return string The Template.
*/
protected function get_post_content_template() {
if ( 'excerpt' === \get_option( 'activitypub_post_content_type', 'content' ) ) {
return "[ap_excerpt]\n\n[ap_permalink type=\"html\"]";
}
if ( 'title' === \get_option( 'activitypub_post_content_type', 'content' ) ) {
return "[ap_title]\n\n[ap_permalink type=\"html\"]";
}
if ( 'content' === \get_option( 'activitypub_post_content_type', 'content' ) ) {
return "[ap_content]\n\n[ap_permalink type=\"html\"]\n\n[ap_hashtags]";
}
return \get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT );
}
}

View file

@ -284,7 +284,8 @@ class Transformers_Manager {
$post_type = get_post_type( $object );
$transformer_mapping = \get_option( 'activitypub_transformer_mapping', self::DEFAULT_TRANSFORMER_MAPPING );
$transformer_name = $transformer_mapping[ $post_type ];
$transformer_instance = new ( $this->get_transformers( $transformer_name ) );
$transformer_class = $this->get_transformers( $transformer_name );
$transformer_instance = new $transformer_class();
$transformer_instance->set_wp_post( $object );
return $transformer_instance;
case 'WP_Comment':