diff --git a/includes/class-admin.php b/includes/class-admin.php index df79d0b..872ceea 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -50,8 +50,7 @@ class Admin { switch ( $tab ) { case 'settings': - $post_model = new \Activitypub\Model\Post(); - $post_model->upgrade_post_content_template(); + \Activitypub\Model\Post::upgrade_post_content_template(); \load_template( \dirname( __FILE__ ) . '/../templates/settings.php' ); break; diff --git a/includes/model/class-post.php b/includes/model/class-post.php index c796035..1eccf4d 100644 --- a/includes/model/class-post.php +++ b/includes/model/class-post.php @@ -16,19 +16,16 @@ class Post { private $tags; private $object_type; - public function __construct( $post = null ) { - if ( $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(); - } + public function __construct( $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(); } public function __call( $method, $params ) { @@ -289,7 +286,7 @@ class Post { * * @return string the updated template content */ - public function upgrade_post_content_template() { + public static function upgrade_post_content_template() { // Get the custom template. $old_content = \get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT );