use static method to upgrade post content to shortcodes

This commit is contained in:
Matthias Pfefferle 2023-01-23 20:31:14 +01:00
parent d4b88f228d
commit cb1c26a365
2 changed files with 11 additions and 15 deletions

View file

@ -50,8 +50,7 @@ class Admin {
switch ( $tab ) { switch ( $tab ) {
case 'settings': case 'settings':
$post_model = new \Activitypub\Model\Post(); \Activitypub\Model\Post::upgrade_post_content_template();
$post_model->upgrade_post_content_template();
\load_template( \dirname( __FILE__ ) . '/../templates/settings.php' ); \load_template( \dirname( __FILE__ ) . '/../templates/settings.php' );
break; break;

View file

@ -16,19 +16,16 @@ class Post {
private $tags; private $tags;
private $object_type; private $object_type;
public function __construct( $post = null ) { public function __construct( $post ) {
if ( $post ) { $this->post = \get_post( $post );
$this->post = \get_post( $post );
$this->post_author = $this->post->post_author;
$this->id = $this->generate_id();
$this->summary = $this->generate_the_title();
$this->content = $this->generate_the_content();
$this->attachments = $this->generate_attachments();
$this->tags = $this->generate_tags();
$this->object_type = $this->generate_object_type();
}
$this->post_author = $this->post->post_author;
$this->id = $this->generate_id();
$this->summary = $this->generate_the_title();
$this->content = $this->generate_the_content();
$this->attachments = $this->generate_attachments();
$this->tags = $this->generate_tags();
$this->object_type = $this->generate_object_type();
} }
public function __call( $method, $params ) { public function __call( $method, $params ) {
@ -289,7 +286,7 @@ class Post {
* *
* @return string the updated template content * @return string the updated template content
*/ */
public function upgrade_post_content_template() { public static function upgrade_post_content_template() {
// Get the custom template. // Get the custom template.
$old_content = \get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT ); $old_content = \get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT );