| @@ -9,9 +9,9 @@ | ||
| 9 | 9 | use Elementor\TemplateLibrary\Source_Local; |
| 10 | 10 | use Elementor\Utils; |
| 11 | 11 | |
| 12 | 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | - exit; // Exit if accessed directly. | |
| 13 | + exit; // Exit if accessed directly | |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Elementor documents manager. |
| @@ -136,18 +136,18 @@ | ||
| 136 | 136 | * |
| 137 | 137 | * @since 2.0.0 |
| 138 | 138 | * @access public |
| 139 | 139 | * |
| 140 | - * @param string $type Document type name. | |
| 141 | - * @param string $class_name The name of the class that registers the document type. | |
| 142 | - * Full name with the namespace. | |
| 140 | + * @param string $type Document type name. | |
| 141 | + * @param string $class The name of the class that registers the document type. | |
| 142 | + * Full name with the namespace. | |
| 143 | 143 | * |
| 144 | 144 | * @return Documents_Manager The updated document manager instance. |
| 145 | 145 | */ |
| 146 | - public function register_document_type( $type, $class_name ) { | |
| 147 | - $this->types[ $type ] = $class_name; | |
| 146 | + public function register_document_type( $type, $class ) { | |
| 147 | + $this->types[ $type ] = $class; | |
| 148 | 148 | |
| 149 | - $cpt = $class_name::get_property( 'cpt' ); | |
| 149 | + $cpt = $class::get_property( 'cpt' ); | |
| 150 | 150 | |
| 151 | 151 | if ( $cpt ) { |
| 152 | 152 | foreach ( $cpt as $post_type ) { |
| 153 | 153 | $this->cpt[ $post_type ] = $type; |
| @@ -153,9 +153,9 @@ | ||
| 153 | 153 | $this->cpt[ $post_type ] = $type; |
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if ( $class_name::get_property( 'register_type' ) ) { | |
| 157 | + if ( $class::get_property( 'register_type' ) ) { | |
| 158 | 158 | Source_Local::add_template_type( $type ); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | return $this; |
| @@ -208,12 +208,14 @@ | ||
| 208 | 208 | |
| 209 | 209 | /** |
| 210 | 210 | * Retrieve a document after checking it exist and allowed to edit. |
| 211 | 211 | * |
| 212 | - * @param string $id | |
| 212 | + * @since 3.13.0 | |
| 213 | + * | |
| 214 | + * @param int $post_id The post ID of the document. | |
| 215 | + * | |
| 213 | 216 | * @return Document |
| 214 | - * @throws \Exception If the document is not found or the current user is not allowed to edit it. | |
| 215 | - * @since 3.13.0 | |
| 217 | + * @throws \Exception | |
| 216 | 218 | */ |
| 217 | 219 | public function get_with_permissions( $id ): Document { |
| 218 | 220 | $document = $this->get( $id ); |
| 219 | 221 | |
| @@ -230,11 +232,11 @@ | ||
| 230 | 232 | |
| 231 | 233 | /** |
| 232 | 234 | * A `void` version for `get_with_permissions`. |
| 233 | 235 | * |
| 234 | - * @param string $id | |
| 236 | + * @param $id | |
| 235 | 237 | * @return void |
| 236 | - * @throws \Exception If the document is not found or the current user is not allowed to edit it. | |
| 238 | + * @throws \Exception | |
| 237 | 239 | */ |
| 238 | 240 | public function check_permissions( $id ) { |
| 239 | 241 | $this->get_with_permissions( $id ); |
| 240 | 242 | } |
| @@ -274,9 +276,9 @@ | ||
| 274 | 276 | * @return false|Document The document if it exist, False otherwise. |
| 275 | 277 | */ |
| 276 | 278 | public function get_doc_for_frontend( $post_id ) { |
| 277 | 279 | $preview_id = (int) Utils::get_super_global_value( $_GET, 'preview_id' ); |
| 278 | - $is_preview = is_preview(); | |
| 280 | + $is_preview = is_preview() && $post_id === $preview_id; | |
| 279 | 281 | $is_nonce_verify = wp_verify_nonce( Utils::get_super_global_value( $_GET, 'preview_nonce' ), 'post_preview_' . $preview_id ); |
| 280 | 282 | |
| 281 | 283 | if ( ( $is_preview && $is_nonce_verify ) || Plugin::$instance->preview->is_preview_mode() ) { |
| 282 | 284 | $document = $this->get_doc_or_auto_save( $post_id, get_current_user_id() ); |
| @@ -322,10 +324,10 @@ | ||
| 322 | 324 | * |
| 323 | 325 | * @since 2.0.0 |
| 324 | 326 | * @access public |
| 325 | 327 | * |
| 326 | - * @param array $args Optional. An array of key => value arguments to match against | |
| 327 | - * the properties. Default is empty array. | |
| 328 | + * @param array $args Optional. An array of key => value arguments to match against | |
| 329 | + * the properties. Default is empty array. | |
| 328 | 330 | * @param string $operator Optional. The logical operation to perform. 'or' means only one |
| 329 | 331 | * element from the array needs to match; 'and' means all elements |
| 330 | 332 | * must match; 'not' means no elements may match. Default 'and'. |
| 331 | 333 | * |
| @@ -478,9 +480,9 @@ | ||
| 478 | 480 | * Filter Post Row Actions. |
| 479 | 481 | * |
| 480 | 482 | * Let the Document to filter the array of row action links on the Posts list table. |
| 481 | 483 | * |
| 482 | - * @param array $actions | |
| 484 | + * @param array $actions | |
| 483 | 485 | * @param \WP_Post $post |
| 484 | 486 | * |
| 485 | 487 | * @return array |
| 486 | 488 | */ |
| @@ -501,9 +503,9 @@ | ||
| 501 | 503 | * |
| 502 | 504 | * @since 2.0.0 |
| 503 | 505 | * @access public |
| 504 | 506 | * |
| 505 | - * @param array $request Post ID. | |
| 507 | + * @param $request Post ID. | |
| 506 | 508 | * |
| 507 | 509 | * @throws \Exception If current user don't have permissions to edit the post or the post is not using Elementor. |
| 508 | 510 | * |
| 509 | 511 | * @return array The document data after saving. |
| @@ -593,15 +595,16 @@ | ||
| 593 | 595 | * Ajax discard changes. |
| 594 | 596 | * |
| 595 | 597 | * Load the document data from an autosave, deleting unsaved changes. |
| 596 | 598 | * |
| 597 | - * @param array $request | |
| 599 | + * @param $request | |
| 598 | 600 | * |
| 599 | 601 | * @return bool True if changes discarded, False otherwise. |
| 600 | - * @throws \Exception If current user don't have permissions to edit the post or the post is not using Elementor. | |
| 602 | + * @throws \Exception | |
| 601 | 603 | * |
| 602 | 604 | * @since 2.0.0 |
| 603 | 605 | * @access public |
| 606 | + * | |
| 604 | 607 | */ |
| 605 | 608 | public function ajax_discard_changes( $request ) { |
| 606 | 609 | $document = $this->get_with_permissions( $request['editor_post_id'] ); |
| 607 | 610 | |
| @@ -731,9 +734,9 @@ | ||
| 731 | 734 | * Get create new post URL. |
| 732 | 735 | * |
| 733 | 736 | * Retrieve a custom URL for creating a new post/page using Elementor. |
| 734 | 737 | * |
| 735 | - * @param string $post_type Optional. Post type slug. Default is 'page'. | |
| 738 | + * @param string $post_type Optional. Post type slug. Default is 'page'. | |
| 736 | 739 | * @param string|null $template_type Optional. Query arg 'template_type'. Default is null. |
| 737 | 740 | * |
| 738 | 741 | * @return string A URL for creating new post using Elementor. |
| 739 | 742 | */ |