← All changes
|
modules/global-classes/global-classes-relations.php
+8
-10
4.2.1
→
4.1.0-dev3
View file →
| @@ -343,9 +343,15 @@ | ||
| 343 | 343 | private function get_document_for_post( int $post_id ): ?Document { |
| 344 | 344 | $documents = Plugin::$instance->documents; |
| 345 | 345 | |
| 346 | 346 | if ( ! $this->is_preview() ) { |
| 347 | - return $this->get_document_or_null( $documents->get( $post_id ) ); | |
| 347 | + $document = $documents->get( $post_id ); | |
| 348 | + | |
| 349 | + if ( ! $document ) { | |
| 350 | + return null; | |
| 351 | + } | |
| 352 | + | |
| 353 | + return $document ?? null; | |
| 348 | 354 | } |
| 349 | 355 | |
| 350 | 356 | $document = $documents->get_doc_or_auto_save( $post_id, get_current_user_id() ); |
| 351 | 357 | |
| @@ -352,15 +358,7 @@ | ||
| 352 | 358 | if ( ! $document ) { |
| 353 | 359 | $document = $documents->get( $post_id ); |
| 354 | 360 | } |
| 355 | 361 | |
| 356 | - return $this->get_document_or_null( $document ); | |
| 357 | - } | |
| 358 | - | |
| 359 | - private function get_document_or_null( $document ): ?Document { | |
| 360 | - if ( empty( $document ) ) { | |
| 361 | - return null; | |
| 362 | - } | |
| 363 | - | |
| 364 | - return $document; | |
| 362 | + return $document ?? null; | |
| 365 | 363 | } |
| 366 | 364 | } |