| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\Mcp\Abilities\Utils; |
| 4 |
|
| 5 |
use Elementor\Core\Base\Document; |
| 6 |
use Elementor\Core\Utils\Document\Document_Mutator; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
class Document_Mutation_Save { |
| 13 |
|
| 14 |
/** |
| 15 |
* @return Document|\WP_Error |
| 16 |
*/ |
| 17 |
public static function elements_preserving_live_status( |
| 18 |
Document_Mutator $mutator, |
| 19 |
Document $document, |
| 20 |
array $elements |
| 21 |
) { |
| 22 |
$result = $mutator->save_as_draft( $document, $elements, true ); |
| 23 |
|
| 24 |
if ( is_wp_error( $result ) ) { |
| 25 |
return $result; |
| 26 |
} |
| 27 |
|
| 28 |
if ( ! $result instanceof Document ) { |
| 29 |
return new \WP_Error( |
| 30 |
'elementor_save_failed', |
| 31 |
__( 'Could not save document.', 'elementor' ), |
| 32 |
[ 'status' => \WP_Http::INTERNAL_SERVER_ERROR ] |
| 33 |
); |
| 34 |
} |
| 35 |
|
| 36 |
return $result; |
| 37 |
} |
| 38 |
} |
| 39 |
|